PageSourceSearch

https://kuwait777.com/assets/index-CpRBAXqD.js

js kuwait777.com collected 2026-09-25 02:02:41 UTC 467,636 bytes, 12 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/@index-B4u4R3iw.js","assets/dnd-vendor-57FyRAmD.js","assets/rolldown-runtime-hePW80VL.js","assets/dist-D5zd71ZC.js","assets/vendor-BcMzpkHq.js","assets/react-vendor-BOqamS0N.js","assets/ui-vendor-BwLkSEMz.js","assets/GameView-gHwO5vMy.js","assets/endpoints-C88Ib4Q_.js","assets/FaqQuestionView-uTEeylXe.js","assets/@index-B21-r5oT.js","assets/@index-B0bAt4sM.js","assets/@index-DGHUHSE7.js","assets/@index-C2iiBtHZ.js","assets/qr-vendor-DdUKBb8S.js","assets/BingoPlay-CzQiik0f.js","assets/GameWrapper-Bi93Kax0.js","assets/GameWrapper-DFGiWI-_.css","assets/GameIndexView-BLHy6pQZ.js","assets/_id_-DlwyZS_r.js","assets/DockNavbar-Duy7AUsz.js","assets/BingoBoard-kZLfS8rm.js","assets/FindDifferenceResult-DqEWdK4W.js","assets/play-jh-Hp_m2.js","assets/_id_-FR7yixvS.js","assets/PlayerSuspended-BYdRhJ5i.js","assets/useTimer-V4v0zZWJ.js","assets/play-DstXqw20.js","assets/_id_-DnN9gvGH.js","assets/_id_-B6q1DMKF.css","assets/play-DnaCkO_n.js","assets/_id_-18cHhfaU.js","assets/Card-nAZmtv6I.js","assets/play-CsWnHFJW.js","assets/_id_-BKV8C5Lx.js"])))=>i.map(i=>d[i]);
2import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{l as n,u as r}from"./dnd-vendor-57FyRAmD.js";import{C as i,D as a,E as o,S as s,T as c,_ as l,a as u,g as d,h as f,v as p,w as m,x as h,y as g}from"./react-vendor-BOqamS0N.js";import{$ as _,A as v,B as y,Bt as b,C as x,D as S,Dt as C,Et as w,G as T,H as E,Ht as D,J as O,K as k,M as A,O as j,Ot as M,Q as N,R as P,Rt as F,S as I,St as L,T as ee,Tt as R,U as te,V as z,Vt as B,W as ne,X as re,Z as ie,_ as ae,_t as oe,a as se,at as ce,b as le,bt as ue,c as de,ct as V,d as fe,et as H,f as U,ft as W,g as pe,h as me,i as he,it as ge,j as _e,k as ve,kt as ye,l as be,lt as xe,m as Se,mt as Ce,n as we,nt as Te,o as Ee,ot as De,p as Oe,q as ke,r as Ae,rt as je,s as Me,st as Ne,tt as Pe,u as Fe,ut as G,v as Ie,w as Le,wt as Re,x as ze,xt as K,y as Be,yt as Ve,z as He,zt as q}from"./dist-D5zd71ZC.js";import{Q as Ue,a as We,f as Ge,i as Ke,m as qe,o as Je,p as Ye,s as Xe,t as Ze,u as Qe}from"./vendor-BcMzpkHq.js";import{A as $e,D as et,F as tt,I as nt,L as rt,M as it,N as at,P as ot,R as st,T as ct,V as lt,_ as ut,b as dt,g as ft,h as pt,i as mt,j as ht,n as gt,r as _t,t as vt,v as yt,w as bt,x as xt,y as St}from"./endpoints-C88Ib4Q_.js";import{$n as Ct,$r as wt,$t as Tt,An as Et,Ar as Dt,Bn as Ot,Br as kt,Cr as At,Dn as jt,Dr as Mt,En as Nt,Er as Pt,Fn as Ft,Gr as It,Gt as Lt,Hn as Rt,Hr as zt,In as Bt,Ir as Vt,Jn as Ht,Jt as Ut,Kr as Wt,Kt as Gt,Ln as Kt,Lr as qt,Mn as Jt,Mr as Yt,Or as Xt,Ot as Zt,Pn as Qt,Pr as $t,Qn as en,Qr as tn,Qt as nn,Rn as rn,Rr as an,Sn as on,Sr as sn,Tn as cn,Un as ln,Ur as un,Vn as dn,Vr as fn,Wn as pn,Wr as mn,Xn as hn,Xr as gn,Yr as _n,Zr as vn,_n as yn,_t as bn,an as xn,ar as Sn,bn as Cn,br as wn,cr as Tn,di as En,dn as Dn,dr as On,dt as kn,ei as An,en as jn,fi as Mn,fn as Nn,fr as Pn,gr as Fn,gt as In,hn as Ln,ht as Rn,in as zn,jn as Bn,kn as Vn,li as Hn,ln as Un,lr as Wn,mn as Gn,mr as Kn,mt as qn,n as Jn,ni as Yn,nn as Xn,nr as Zn,on as Qn,pr as $n,pt as er,qn as tr,qt as nr,ri as rr,rn as ir,rr as ar,sn as or,sr,t as cr,ti as lr,tn as ur,tr as dr,ui as fr,un as pr,ur as mr,vn as hr,vr as gr,vt as _r,wr as vr,xn as yr,xr as br,yn as xr,yr as Sr,zn as Cr}from"./ui-vendor-BwLkSEMz.js";import{t as wr}from"./FaqQuestionView-uTEeylXe.js";import{_ as Tr,a as Er,b as Dr,c as Or,d as kr,g as Ar,h as J,i as jr,l as Mr,m as Nr,n as Pr,o as Fr,p as Ir,r as Lr,s as Rr,t as zr,u as Br,v as Vr,y as Hr}from"./DockNavbar-Duy7AUsz.js";import{a as Ur,c as Wr,d as Gr,f as Kr,i as qr,l as Jr,n as Yr,o as Xr,p as Zr,r as Qr}from"./GameWrapper-Bi93Kax0.js";import{n as $r,r as ei,t as ti}from"./GameView-gHwO5vMy.js";import{a as ni,i as ri,n as ii,o as ai,r as oi,t as si}from"./form-vendor-_TNCKxkn.js";import{n as ci,r as li,t as ui}from"./GameIndexView-BLHy6pQZ.js";import{n as di}from"./qr-vendor-DdUKBb8S.js";import{a as fi,c as pi,d as mi,f as hi,i as gi,l as _i,n as vi,o as yi,r as bi,t as xi,u as Si}from"./BingoBoard-kZLfS8rm.js";import{t as Ci}from"./FindDifferenceResult-DqEWdK4W.js";import{t as wi}from"./PlayerSuspended-BYdRhJ5i.js";import{t as Ti}from"./useTimer-V4v0zZWJ.js";import{a as Ei,c as Di,d as Oi,f as ki,l as Ai,n as ji,o as Mi,p as Ni,r as Pi,s as Fi,t as Ii,u as Li}from"./Card-nAZmtv6I.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Y=t(r(),1),Ri=a(),zi=/view/giu,Bi=/(?=[A-Z])/gu;function Vi(e){let t;return e&&(typeof e==`object`||typeof e==`function`)&&`name`in e&&typeof e.name==`string`?{name:t}=e:t=String(e),t.replace(zi,``).split(Bi).join(` `)}function Hi(e,t,n){return n(e,(e,r=t)=>Hi(e,r,n),t)}var Ui=En,Wi=fr,X=n();function Gi({redirectPath:e,access:t,element:n}){let{state:{initializing:r,loading:i},hasAccess:a}=pt(),o=h();return r||i?(0,X.jsx)(`div`,{}):a(t)?n:(0,X.jsx)(l,{to:e,state:{from:o},replace:!0})}Gi.type=`ProtectedRoute`;function Ki(e,t=`/login`){let{handle:n}=e;return(n?.loginRequired??n?.requiresLogin??n?.rolesAllowed?.length)&&(e.element=(0,X.jsx)(Gi,{redirectPath:t,access:n,element:e.element})),e}function qi(e){return!e||`default`in e&&typeof e.default==`function`||`config`in e&&typeof e.config==`object`}function Ji(e){return e?`lazy`in e&&typeof e.lazy==`function`:!1}function Yi(e){return`${e.path??``}-${e.children?`n`:`i`}`}function Xi(e,t){if(typeof e.handle==`object`&&t in e.handle)return e.handle[t]}var Zi=class{#e=[];withReactRoutes(e){return this.update(e)}withFileRoutes(e){return this.update(e,({original:e,overriding:t,children:n})=>{if(t){let{module:r,path:i,flowLayout:a}=t;if(!qi(r)&&!Ji(r))throw Error(`The module for the "${i}" section doesn't have the React component exported by default or a ViewConfig object exported as "config"`);let o=Ji(r)?r:void 0,s=o?.config??r?.config,c=qi(r)&&r?.default?(0,Y.createElement)(r.default):void 0,l=o?.lazy,u={...s,title:s?.title??(qi(r)?Vi(r?.default):void 0),flowLayout:s?.flowLayout??a};return i===``&&!n?{...e,element:c,lazy:l?async()=>{let e=await l();if(!qi(e))throw Error(`The lazy module for the "${i}" section doesn't have the React component exported by default`);return{Component:e.default}}:void 0,handle:u,index:!0}:{...e,path:s?.route??i,element:c,lazy:l?async()=>{let e=await l();if(!qi(e))throw Error(`The lazy module for the "${i}" section doesn't have the React component exported by default`);return{Component:e.default}}:void 0,children:n,handle:u}}return e})}withFallback(e,t){this.withLayout(e);let n=[{path:`*`,element:(0,Y.createElement)(e),handle:t},{index:!0,element:(0,Y.createElement)(e),handle:t}];return this.update(n,({original:e,overriding:t,children:r,dupe:i})=>{if(e&&!Xi(e,`ignoreFallback`)&&!i){if(!r)return e;let t=[...n];return r.some(({path:e})=>
2e===`*`)&&t.shift(),r.some(({index:e,path:t})=>e??t?.includes(`?`))&&t.pop(),{...e,children:[...r,...t]}}return t}),this}withLayout(e){return this.#e.push(t=>{if(!t)return t;let n=Hi(t,null,(e,t)=>e.reduce((e,n)=>{let{server:r,client:i,ambivalent:a}=t(n.children??[]),o=Xi(n,`flowLayout`);return o===!0?e.server.push({...n,children:r.length+a.length>0?[...r,...a]:void 0}):r.length>0&&e.server.push({...n,children:r}),(o===!1||i.length>0)&&e.client.push({...n,children:i.length>0?i:void 0}),o===void 0&&(e.server.every(({path:e})=>e!==n.path)||a.length>0)&&e.ambivalent.push({...n,children:a.length>0?a:void 0}),e},{server:[],client:[],ambivalent:[]}));return[...n.server.length?[{element:(0,Y.createElement)(e),children:n.server,handle:{ignoreFallback:!0}}]:[],...n.client,...n.ambivalent]}),this}protect(e){return this.update(void 0,({original:t,children:n})=>{let r=Ki(t,e);return r.children=n,r}),this}update(e,t=({original:e,overriding:t,children:n})=>({...e,...t,children:n})){return this.#e.push(n=>Hi([n,e],null,([e,n],r)=>{if(e&&n){let i=[],a=new Set([...e.map(Yi),...n.map(Yi)]);for(let o of a){let a=e.filter(e=>Yi(e)===o),s=n.filter(e=>Yi(e)===o);if(s.length>1)throw Error(`Adding multiple routes with the same path is not allowed`);let c=s[0];if(a.length>0&&c)for(let e=0;e<a.length;e++)i.push(t({original:a[e],overriding:c,children:r([a[e].children,c.children]),dupe:e<a.length-1})??a[e]);else if(a.length>0)for(let e=0;e<a.length;e++)i.push(t({original:a[e],children:r([a[e].children,void 0]),dupe:e<a.length-1})??a[e]);else{let e=t({overriding:c,children:r([void 0,c.children]),dupe:!1});e&&i.push(e)}}return i.filter(e=>e!=null)}if(e)return e.map(e=>t({original:e,children:r([e.children,void 0]),dupe:!1})).filter(e=>e!=null);if(n)return n.map(e=>t({overriding:e,children:r([void 0,e.children]),dupe:!1})).filter(e=>e!=null)})),this}build(e){this.#t();let t=this.#e.reduce((e,t)=>t(e)??e,void 0)??[];return{routes:t,router:g([...t],{...e})}}#t(){return this.#e.push(e=>{if(!e)return e;let t=Hi(e,null,(e,t)=>e.reduce((e,n)=>{if(Xi(n,`skipLayouts`))return e.skipped.push(n),e;if(!n.children?.length)return e.regular.push(n),e;let{skipped:r,regular:i}=t(n.children??[]);if(r.length>0){let{element:t,...i}=n;e.skipped.push({...i,children:r})}return i.length>0&&e.regular.push({...n,children:i}),e},{skipped:[],regular:[]}));return[...t.skipped.length?[{children:t.skipped,handle:{ignoreFallback:!0}}]:[],...t.regular]}),this}};function Z(e,t,n){let r;return Array.isArray(t)?n=t:r=t,{path:e,module:r,children:n}}function Qi(){let e=s();return e[e.length-1]?.handle}var $i=({children:e})=>{let[t,n]=(0,Y.useState)(`ltr`),{isRtl:r,setRtl:i}=Hr(),{userLanguage:a}=W();return(0,Y.useEffect)(()=>{let e=a===`ar`?`rtl`:`ltr`;!r&&e===`rtl`?i(!0):r&&e!==`rtl`&&i(!1),e===`rtl`?(document.documentElement.setAttribute(`dir`,`rtl`),document.documentElement.setAttribute(`lang`,`ar`)):(document.documentElement.setAttribute(`dir`,`ltr`),document.documentElement.setAttribute(`lang`,`en`)),n(e)},[a]),(0,X.jsx)(Hn,{dir:t,children:e})},ea=`(prefers-color-scheme: dark)`,ta=`usehooks-ts-dark-mode`,na=(e={})=>{let{defaultValue:t,localStorageKey:n=ta,initializeWithValue:r=!0}=e,i=qe(ea,{initializeWithValue:r,defaultValue:t}),[a,o]=Ye(n,t??i??!1,{initializeWithValue:r});return{isDarkMode:a,toggle:()=>{o(e=>!e)},enable:()=>{o(!0)},disable:()=>{o(!1)},set:e=>{o(e)}}},ra=()=>{let[e,t]=(0,Y.useState)(null),{pathname:n}=h(),{isDarkMode:r,toggle:i}=na({localStorageKey:`dark-mode`});(0,Y.useEffect)(()=>{document.documentElement.scrollTo({top:0,left:0,behavior:`instant`})},[n]),(0,Y.useEffect)(()=>{r?document.documentElement.setAttribute(`class`,`dark`):document.documentElement.removeAttribute(`class`)},[r]);let{state:a,logout:o}=pt();(0,Y.useEffect)(()=>{a.loading||a.initializing||t(a.user?a.user:null)},[a]);let s=(0,Y.useCallback)(e=>{t({...e})},[]),c=(0,Y.useCallback)((...t)=>e?t.filter(t=>e.roles?.includes(t)).length!==0:t.includes(ct.ANONYMOUS),[e]);return{user:e,isDarkMode:r,loading:a.loading,initializing:a.initializing,error:a.error,isRole:c,updateUser:s,onDarkToggle:i,logout:o}},ia=({hovered:e,collapsed:t})=>{let{sidebarType:n,setCollapsed:r}=Dr();return(0,X.jsx)(`div`,{className:`px-4 py-4 `,children:(0,X.jsxs)(`div`,{className:` flex items-center`,children:[(0,X.jsxs)(`div`,{className:`flex flex-1 items-center gap-x-3  `,children:[(0,X.jsx)(`img`,{src:`/images/logo.png`,alt:D.name,className:`h-10 dar
2k:hidden`}),(0,X.jsx)(`img`,{src:`/images/logo-dark.png`,alt:D.name,className:`h-10 hidden dark:block`}),(!t||e)&&(0,X.jsx)(`div`,{className:`flex-1 text-base text-primary font-semibold`,children:D.name})]}),n===`classic`&&(!t||e)&&(0,X.jsx)(`div`,{className:`flex-none lg:block hidden`,children:(0,X.jsx)(`div`,{onClick:()=>r(!t),className:`h-4 w-4 border-[1.5px] border-default-900 dark:border-default-200 rounded-full transition-all duration-150
3          ${t?``:`ring-2 ring-inset ring-offset-4 ring-default-900 bg-default-900  dark:ring-offset-default-300`}
4          `})})]})})},aa=({collapsed:e,item:t})=>{let{badge:n,to:r,title:i}=t,{pathname:a}=h(),{t:o}=W();return(0,X.jsx)(d,{to:r,children:(0,X.jsx)(X.Fragment,{children:e?(0,X.jsx)(`div`,{children:(0,X.jsx)(`span`,{className:q(`h-12 w-12 mx-auto rounded-md  transition-all duration-300 inline-flex flex-col items-center justify-center  relative  `,{"bg-primary text-primary-foreground ":b(r,a)," text-default-600  ":!b(r,a)}),children:t.icon?(0,X.jsx)(t.icon,{className:`w-6 h-6`}):(0,X.jsx)(X.Fragment,{})})}):(0,X.jsxs)(`div`,{className:q(`flex gap-3  text-default-700 text-sm capitalize px-[10px] py-3 rounded cursor-pointer hover:bg-primary hover:text-primary-foreground`,{"bg-primary text-primary-foreground":b(r,a)}),children:[(0,X.jsx)(`span`,{className:`flex-grow-0`,children:t.icon?(0,X.jsx)(t.icon,{className:`w-5 h-5`}):(0,X.jsx)(X.Fragment,{})}),(0,X.jsx)(`div`,{className:`text-box flex-grow`,children:o(i??``)}),n&&(0,X.jsx)(C,{className:`rounded`,children:t.badge})]})})})},oa=({item:e,className:t})=>(0,X.jsx)(`div`,{className:q(`text-default-900 font-semibold uppercase mb-3 text-xs  mt-4`,t),children:e.title}),sa=({subItem:e,subIndex:t,activeMultiMenu:n,toggleMultiMenu:r,className:i})=>(0,X.jsxs)(`div`,{onClick:()=>r(t),className:q(`text-sm flex gap-3 rounded items-center transition-all duration-150 cursor-pointer relative before:absolute before:top-0 before:-left-5 before:w-[3px] before:h-0 before:transition-all before:duration-200`,i,{" text-primary before:bg-primary before:h-full":n===t," text-default-700 hover:text-primary":n!==t}),children:[(0,X.jsx)(`span`,{className:`flex-1`,children:e.title}),(0,X.jsx)(`div`,{className:`flex-none`,children:(0,X.jsx)(`span`,{className:q(`[&>*]:transform [&>*]:transition-all [&>*]:duration-300`,{"[&>*]:rotate-90":n===t}),children:(0,X.jsx)(u,{icon:`heroicons:chevron-right-20-solid`,className:`h-5 w-5`})})})]}),ca=({subItem:e,subIndex:t,activeMultiMenu:n})=>{let{pathname:r}=h(),{t:i}=W();return(0,X.jsx)(Ui,{open:n===t,children:(0,X.jsx)(Wi,{className:`CollapsibleContent`,children:(0,X.jsx)(`ul`,{className:`space-y-3 pl-1`,children:e?.multi_menu?.map((e,t)=>(0,X.jsx)(`li`,{className:`first:pt-3`,children:(0,X.jsx)(d,{to:e.to,children:(0,X.jsxs)(`span`,{className:q(`text-sm flex gap-3 items-center transition-all duration-150 capitalize hover:text-primary`,{"text-primary":b(e.to,r),"text-default-600":!b(e.to,r)}),children:[(0,X.jsx)(`span`,{className:q(`inline-flex h-2 w-2 border border-default-500 rounded-full`,{"bg-primary ring-primary/30 ring-[4px] border-primary":b(e.to,r)})}),(0,X.jsx)(`span`,{className:`flex-1`,children:i(e.title??``)})]})})},t))})})})},la=({children:e,item:t})=>t.badge?(0,X.jsxs)(`span`,{className:`text-sm flex space-x-3 items-center transition-all duration-150 opacity-50  cursor-not-allowed`,children:[(0,X.jsx)(`span`,{className:` h-2 w-2 rounded-full border border-default-600  inline-block flex-none`}),(0,X.jsxs)(`div`,{className:`flex-1 truncate  flex  text-default-600`,children:[(0,X.jsx)(`div`,{className:`flex-1  truncate`,children:t.title}),(0,X.jsx)(C,{className:`leading-0 capitalize flex-none px-1 text-xs font-normal`,children:t.badge})]})]}):(0,X.jsx)(d,{to:t.to,children:e}),ua=({item:e})=>{let{pathname:t}=h(),{t:n}=W();return(0,X.jsx)(la,{item:e,children:(0,X.jsx)(`div`,{className:q(`text-sm capitalize  font-normal flex gap-3 items-center transition-all duration-150 rounded dark:hover:text-primary  `,{" text-primary   ":b(e.to,t),"  text-default-600 dark:text-default-700  ":!b(e.to,t)}),children:(0,X.jsx)(`span`,{className:`flex-1 truncate`,children:n(e.title??``)})})})}
4,da=({activeSubmenu:e,item:t,index:n,activeMultiMenu:r,toggleMultiMenu:i})=>{let{pathname:a}=h();return(0,X.jsx)(Ui,{open:e===n,children:(0,X.jsx)(Wi,{className:`CollapsibleContent`,children:(0,X.jsx)(`ul`,{className:`sub-menu space-y-4 relative before:absolute before:left-4 before:top-0 before:h-[calc(100%-5px)] before:w-[3px] before:bg-primary/10 before:rounded`,children:t.children?.map((t,o)=>(0,X.jsx)(`li`,{className:q(`block pl-9   first:pt-4 last:pb-4  relative before:absolute first:before:top-4 before:top-0 before:left-4 before:w-[3px]`,{"before:bg-primary first:before:h-[calc(100%-16px)]  before:h-full":b(t.to,a)," ":e===n}),children:t?.children?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(sa,{subItem:t,subIndex:o,activeMultiMenu:r,toggleMultiMenu:i}),(0,X.jsx)(ca,{subItem:t,subIndex:o,activeMultiMenu:r})]}):(0,X.jsx)(ua,{item:t})},`sub_menu_${o}`))})})})},fa=({item:e,toggleSubmenu:t,index:n,activeSubmenu:r,collapsed:i})=>{let{t:a}=W();return(0,X.jsx)(X.Fragment,{children:i?(0,X.jsx)(`div`,{className:`inline-flex cursor-pointer items-center justify-center data-[state=open]:bg-primary-100 data-[state=open]:text-primary  w-12 h-12  rounded-md`,children:e.icon?(0,X.jsx)(e.icon,{className:`w-6 h-6`}):(0,X.jsx)(X.Fragment,{})}):(0,X.jsxs)(`div`,{onClick:()=>t(n),className:q(`flex  text-default-700 font-medium text-sm capitalize px-[10px] py-3 rounded cursor-pointer transition-all duration-100 hover:bg-primary hover:text-primary-foreground group`,{"bg-primary  text-primary-foreground":r===n}),children:[(0,X.jsxs)(`div`,{className:`flex-1  gap-3 flex items-start`,children:[(0,X.jsx)(`span`,{className:`inline-flex items-center text-lg`,children:e.icon?(0,X.jsx)(e.icon,{className:`w-5 h-5`}):(0,X.jsx)(X.Fragment,{})}),(0,X.jsx)(`div`,{children:a(e.title??``)})]}),(0,X.jsx)(`div`,{className:`flex-0`,children:(0,X.jsx)(`div`,{className:q(` text-base rounded-full flex justify-center items-center transition-all duration-300 group-hover:text-primary-foreground`,{"rotate-90  ":r===n," text-default-500  ":r!==n}),children:(0,X.jsx)(u,{icon:`heroicons:chevron-right-20-solid`,className:`h-5 w-5`})})})]})})},pa=({className:e})=>{let{state:{subscription:t}}=pt(),{t:n,tDateTimeParser:r}=W();return!t||!t.plan?null:(0,X.jsx)(Oe,{text:`${n(`Expires on`)}: ${oe({tDateTimeParser:r,t:n,format:`DD/MM/YYYY`,timestamp:t.endDate})}`,children:(0,X.jsxs)(`div`,{className:q(`flex items-center flex-col`,e),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 bg-gradient-to-r from-purple-500 to-indigo-600 text-white px-3 py-1.5 rounded-md shadow-md`,children:[(0,X.jsx)(Sr,{size:16,className:`animate-pulse`}),(0,X.jsx)(`span`,{className:`font-bold`,children:n(t.plan.name)})]}),(0,X.jsx)(`div`,{className:`w-full h-1.5 bg-gray-200 rounded-full mt-1 overflow-hidden`,children:(0,X.jsx)(`div`,{className:`h-full ${(()=>{if(!t)return`bg-gray-500`;switch(t.status){case bt.ACTIVE:case bt.HEALTHY:return`bg-green-500`;case bt.EXPIRING_SOON:return`bg-yellow-500`;case bt.EXPIRED:return`bg-red-500`;case bt.INACTIVE:default:return`bg-gray-500`}})()} rounded-full transition-all duration-500`,style:{width:`${t.remainingPercentage||0}%`}})})]})})},ma=({className:e,menus:t,collapsed:n=!1,hovered:r=!1})=>{let{sidebarBg:i,mobileMenu:a,setMobileMenu:o}=Dr(),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),d=e=>{c(s===e?null:e)},f=e=>{u(l===e?null:e)},p=h();return(0,Y.useEffect)(()=>{let e=null,n=null;t?.map((t,r)=>{t?.children&&t.children.map((t,i)=>{b(t.to,p.pathname)&&(e=r),t?.children&&t.children.map(t=>{b(t.to,p.pathname)&&(e=r,n=i)})})}),c(e),u(n),a&&o(!1)},[p.pathname]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:q(`fixed top-0  bg-card h-full w-[330px] z-[9999]`,e,{" -left-[330px] invisible opacity-0  ":!a," left-0 visible opacity-100  ":a}),children:[i!==`none`&&(0,X.jsx)(`div`,{className:` absolute left-0 top-0 z-[-1] w-full h-full bg-cover bg-center opacity-[0.07]`,style:{backgroundImage:`url(${i})`}}),(0,X.jsx)(ia,{hovered:r,collapsed:n}),(0,X.jsx)(pa,{className:`mb-2`}),(0,X.jsx)(te,{className:q(`sidebar-menu h-[calc(100%-120px)] `,{"px-4":!n}),children:(0,X.jsx)(`ul`,{className:q(``,{" space-y-2 text-center":n}),children:t?.map((e,t)=>(0,X.jsxs)(`li`,{className:`mb-1`,children:[!e.children&&!e.isHeader&&(0,X.jsx)(aa,{item:e,collapsed:n}),e.isHeader&&!e.children&&!n&&(0,X.jsx)(oa,{item:e}),e.children&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(fa,{item:e,toggleSubmenu:d,index:t,activeSubmenu:s,collapsed:n}),!n&&(0,X.jsx)(da,{toggleMultiMenu:f,activeMultiMenu:l,activeSubmenu:s,item:e,index:t})]})]},`menu_key_${t}`))})})]}),a&&(0,X.jsx)(`div`,{onClick:()=>o(!1),className:`overlay bg-black/60 backdrop-filter backdrop-blur-sm op
4acity-100 fixed inset-0 z-[999]`})]})},ha=({children:e,location:t,menus:n,animated:r=!0})=>r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Jn.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.8,delay:.3,ease:[0,.71,.2,1.01]},children:e}),(0,X.jsx)(ma,{menus:n,className:`left-[300px]`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Jn.div,{initial:`pageInitial`,animate:`pageAnimate`,exit:`pageExit`,variants:{pageInitial:{opacity:0,y:50},pageAnimate:{opacity:1,y:0},pageExit:{opacity:0,y:-50}},transition:{type:`tween`,ease:`easeInOut`,duration:.5},children:e},t),(0,X.jsx)(ma,{menus:n,className:`left-[300px]`})]}),ga=({children:e,className:t})=>(0,X.jsx)(`header`,{className:q(`z-50`,t),children:e}),_a=({onOpenSearch:e})=>{let{t}=W();return(0,X.jsxs)(`div`,{className:`flex items-center lg:gap-12 gap-3 `,children:[(0,X.jsx)(`div`,{children:(0,X.jsxs)(d,{to:`/`,className:` text-primary flex items-center gap-2 hover:no-underline`,children:[(0,X.jsx)(`img`,{src:`/images/logo.png`,alt:D.name,className:`h-10 dark:hidden`}),(0,X.jsx)(`img`,{src:`/images/logo-dark.png`,alt:D.name,className:`h-10 hidden dark:block`}),` `,(0,X.jsx)(`span`,{className:` text-xl font-semibold lg:inline-block hidden`,children:D.name})]})}),D.search&&(0,X.jsxs)(`button`,{onClick:e,className:` inline-flex lg:gap-2 lg:mr-0 mr-2 items-center text-default-600 text-sm`,children:[(0,X.jsx)(`span`,{children:(0,X.jsx)(Vn,{className:` h-4 w-4`})}),(0,X.jsx)(`span`,{className:` lg:inline-block hidden`,children:t(`Search...`)})]})]})},va=(0,Y.forwardRef)(({className:e,children:t,title:n,to:r,...i},a)=>{let{t:o}=W();return(0,X.jsx)(qn,{asChild:!0,children:(0,X.jsx)(d,{className:q(` select-none   text-sm  text-default-700 rounded-md flex  items-center gap-2 mb-4 last:mb-0  leading-none no-underline outline-none transition-colors  hover:text-primary  focus:text-primary`,e),to:r,...i,ref:a,children:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{children:t}),(0,X.jsx)(`div`,{className:` capitalize`,children:n&&o(n)})]})})})}),ya=({item:e,index:t,onNodeUpdate:n,onValueChange:r})=>{let{t:i}=W();if(e)return!e.children&&!e.megaMenu?(0,X.jsx)(va,{className:`text-sm font-medium text-default-700 py-4 cursor-pointer`,title:e.title,to:e.to,children:e.icon&&(0,X.jsx)(e.icon,{className:`h-5 w-5`})},`child-${t}`):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(bn,{ref:t=>n(t,e),asChild:!0,className:`flex items-center`,children:(0,X.jsxs)(`div`,{className:`flex items-center  py-4 cursor-pointer group data-[state=open]:text-primary`,children:[e.icon&&(0,X.jsx)(e.icon,{className:`h-5 w-5 mr-2`}),(0,X.jsx)(`span`,{className:`text-sm font-medium text-default-700`,children:e.title&&i(e.title)}),(0,X.jsx)(_n,{className:`relative top-[1px] ml-1 h-4 w-4 transition duration-200 group-data-[state=open]:rotate-180`,"aria-hidden":`true`})]})}),(0,X.jsxs)(kn,{className:q(`w-full rounded-md border bg-popover text-popover-foreground shadow-lg`),children:[!e.megaMenu&&e.children&&(0,X.jsx)(`div`,{className:` min-w-[200px] p-4`,children:e.children?.map((e,t)=>(0,X.jsx)(va,{className:`text-sm font-medium text-default-700`,title:e.title,to:e.to,children:e.icon&&(0,X.jsx)(e.icon,{className:`h-5 w-5`})},`child-${t}`))}),e.megaMenu&&(0,X.jsx)(`div`,{className:``,children:(0,X.jsxs)(pe,{defaultValue:e.megaMenu[0].title,onValueChange:r,className:`inline-block p-0`,children:[(0,X.jsx)(Ie,{className:`bg-transparent p-0 border-b-2 py-7 px-[30px] rounded-none w-full justify-start gap-10`,children:e.megaMenu?.map((e,t)=>(0,X.jsxs)(Be,{value:e.title&&i(e.title)||``,className:`capitalize data-[state=active]:shadow-none data-[state=active]:bg-transparent data-[state=active]:text-primary transition duration-150 before:transition-all before:duration-150 relative before:absolute\r
5                            before:left-1/2 before:-bottom-[30px] before:h-[2px] px-0\r
6                            before:-translate-x-1/2 before:w-0 data-[state=active]:before:bg-primary data-[state=active]:before:w-full`,children:[e.icon&&(0,X.jsx)(e.icon,{className:`h-5 w-5 mr-2`}),(0,X.jsx)(`span`,{className:`text-sm font-medium text-default-700`,children:e.title&&i(e.title)})]},`tab-${t}`))}),e.megaMenu?.map((e,t)=>(0,X.jsx)(ae,{value:e.title&&i(e.title)||``,className:q(`grid grid-cols-12 gap-4 px-6 py-2`,{"gap-2":e?.megaMenu?.length&&e?.megaMenu?.length<10}),children:(0,X.jsx)(`div`,{className:q(`col-span-8 grid gap-3 grid-cols-3`,{"col-span-5 grid-cols-1":e?.megaMenu?.length&&e?.megaMenu?.length<10}),children:e?.children?.map(e=>(0,X.jsx)(va,{className:`mb-0 text-sm font-medium text-default-600`,title:e.title&&i(e.title),to:e.to},`child-${e.title}`))})},`tab2-${t}`))]})})]})]})},ba=({menus:e=[]})=>{let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),{isRtl:a}=Hr(),o=(e,t)=>{if(e&&r===t.to){let t=e.getBoundingClientRect();if(a){let e=t.right+t.width/6;n(-Math.round(document.body.clientWidth-e))}else{let e=t.left-t.width/6;n(Math.round(e))}}else r===null&&n(null);return e};return(0,X.jsx)(`div`,{className:`relative`,children:(0,X.jsxs)(In,{onValueChange:i,className:` flex relative justify-between items-center group `,dir:a?`rtl`:`ltr`,children:[(0,X.jsx)(Rn,{className:`group flex list-none gap-5`,children:e?.map((e,t)=>(0,X.jsx)(er,{value:e.to,children:(0,X.jsx)(ya,{item:e,index:t,onNodeUpdate:o,onValueChange:i})},`item-${t}`))}),(0,X.jsx)(pa,{}),(0,X.jsx)(`div`,{className:`absolute top-full`,children:(0,X.jsx)(_r,{style:{display:t?void 0:`none`,transform:`translateX(${t}px)`,top:`100%`,transition:`all 0.5s ease`}})})]})})},xa=()=>{let{mobileMenu:e,setMobileMenu:t}=Dr();return(0,X.jsx)(`div`,{children:(0,X.jsx)(F,{onClick:()=>t(!e),variant:`ghost`,size:`icon`,className:`relative h-9 w-9 hover:bg-primary-100 dark:hover:bg-default-300 hover:text-primary text-default-500 dark:text-default-800  rounded-full `,children:(0,X.jsx)(Ct,{className:`h-5 w-5 `})})})},Sa=({loading:e})=>{let{user:t}
6=Zr(),{logout:n}=pt(),{t:r}=W();return e?(0,X.jsx)(se,{loading:!0,className:`relative`}):t?(0,X.jsxs)(Me,{children:[(0,X.jsx)(U,{asChild:!0,className:` cursor-pointer`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[t?.picture?.url&&(0,X.jsx)(`img`,{src:t?.picture?.url,alt:t?.name??``,width:`2.5rem`,height:`2.5rem`,className:`w-10 h-10 rounded-full`}),(0,X.jsx)(`span`,{children:t?.name??`JKuwait`})]})}),(0,X.jsxs)(de,{className:`w-56`,align:`end`,children:[(0,X.jsx)(be,{children:[{name:r(`Profile`),icon:(0,X.jsx)(jn,{className:`w-4 h-4`}),to:`/account`},{name:r(`Support`),icon:(0,X.jsx)(zt,{className:`w-4 h-4`}),to:`/tickets`}].map((e,t)=>(0,X.jsx)(d,{to:e.to,className:`cursor-pointer`,children:(0,X.jsxs)(Fe,{className:`flex items-center gap-2 text-sm font-medium text-default-600 capitalize px-3 py-1.5 dark:hover:bg-background cursor-pointer`,children:[e.icon,e.name]})},`info-menu-${t}`))}),(0,X.jsx)(fe,{}),(0,X.jsxs)(Fe,{onSelect:()=>n(),className:`flex items-center gap-2 text-sm font-medium text-default-600 capitalize my-1 px-3 dark:hover:bg-background cursor-pointer`,children:[(0,X.jsx)(rn,{className:`w-4 h-4`}),r(`Log out`)]})]})]}):(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(F,{asChild:!0,variant:`ghost`,size:`sm`,className:`sm:hidden`,children:(0,X.jsx)(d,{to:`/pricing`,children:r(`Pricing`)})}),(0,X.jsx)(`div`,{className:`border border-default-200 divide-y divide-default-100 h-5 sm:hidden`}),(0,X.jsx)(F,{asChild:!0,variant:`ghost`,size:`sm`,children:(0,X.jsx)(d,{to:`/login`,children:r(`Sign In`)})})]})},Ca=({isDesktop:e,sidebarType:t,loading:n})=>(0,X.jsxs)(`div`,{className:`nav-tools relative flex items-center gap-2`,children:[(0,X.jsx)(Gr,{}),(0,X.jsx)(`div`,{className:`ltr:pl-2 rtl:pr-2`,children:(0,X.jsx)(Sa,{loading:n})}),!e&&t!==`module`&&(0,X.jsx)(xa,{})]}),wa=({menus:e=[],onOpenSearch:t,loading:n})=>{let{sidebarType:r,setSidebarType:i}=Dr(),{layout:a,navbarType:o}=Hr(),s=qe(`(min-width: 768px)`),c=qe(`(min-width: 768px)`);return(0,Y.useEffect)(()=>{!s&&a===`horizontal`&&i(`classic`)},[s]),(0,X.jsxs)(ga,{className:q(` `,{"sticky top-0 z-20":o===`sticky`}),children:[(0,X.jsx)(`div`,{className:`w-full bg-card/90 backdrop-blur-lg md:px-6 px-[15px] py-3 border-b`,children:(0,X.jsxs)(`div`,{className:`flex justify-between items-center h-full`,children:[(0,X.jsx)(_a,{onOpenSearch:t}),(0,X.jsx)(Ca,{isDesktop:s,isMobile:c,sidebarType:r,loading:n})]})}),s&&(0,X.jsx)(`div`,{className:` bg-card bg-card/90 backdrop-blur-lg  w-full px-6  shadow-md`,children:(0,X.jsx)(ba,{menus:e})})]})},Ta=({className:e,children:t})=>(0,X.jsx)(`footer`,{className:q(`bg-card relative py-4 px-6  border-t z-50`,e),children:t}),Ea=()=>{let{t:e}=W();return(0,X.jsxs)(`footer`,{className:`bg-card bg-no-repeat   shadow-[0_-4px_29px_#9595952b] dark:shadow-[0_-4px_29px_#000000cc] footer-bg  border-t dark:border-none flex justify-around items-center backdrop-filter backdrop-blur-[40px] fixed left-0 w-full z-50 bottom-0 py-[12px] px-4`,children:[(0,X.jsx)(`div`,{className:`flex flex-col items-center justify-center`,children:(0,X.jsx)(`p`,{className:`mb-0 mt-1.5 text-xs text-default-600`,children:e(`Search`)})}),(0,X.jsx)(`div`,{className:`relative shadow-[0_-4px_10px_#9595952b] dark:shadow-[0_-4px_10px_#0000004d] bg-card border-t dark:border-none bg-no-repeat backdrop-filter backdrop-blur-[40px] rounded-full footer-bg  h-[70px] w-[70px] z-[-1] -mt-[40px] flex justify-center items-center`,children:(0,X.jsx)(`div`,{className:`rounded-full bg-primary p-3 h-[60px] w-[60px] flex items-center justify-center  relative left-0 top-0 custom-dropshadow  text-center`,children:(0,X.jsx)(d,{to:`/`,children:(0,X.jsx)(Ae,{className:`h-8 w-8  text-primary-foreground`})})})}),(0,X.jsx)(`div`,{className:`flex flex-col items-center justify-center`,children:(0,X.jsx)(`p`,{className:`mb-0 mt-1.5 text-xs text-default-600`,children:e(`Settings`)})})]})},Da=()=>{let{t:e}=W(),t=(0,Y.useCallback)(async()=>{if(`serviceWorker`in navigator){let e=await navigator.serviceWorker.getRegistrations();await Promise.all(e.map(e=>e.unregister())),console.log(`Service workers unregistered successfully`)}if(`caches`in window){let e=await caches.keys();console.log(`Number of caches cleared: ${e.length}`),await Promise.all(e.map(e=>caches.delete(e)))}setTimeout(()=>window.location.reload(),1e3)},[]);if(D.copyright)return(0,X.jsxs)(`div`,{className:`block md:flex md:justify-between text-muted-foreground`,children:[(0,X.jsxs)(`p`,{className:`sm:mb-0 text-xs md:text-sm`,children:[`© `,D.copyright]}),(0,X.jsxs)(`div`,{className:`flex items-center space-x-4 rtl:space-x-reverse`,children:[D.pwa&&(0,X.jsx)(`button`,{type:`button`,className:`text-xs md:text-sm hover:text-primary transition-colors`,onClick:t,children:e(`Clear Cache`)}),(0,X.jsx)(`span`,{className:`text-default-300`,children:`|`}),(0,X.jsx)(d,{to:`/terms`,className:`text-xs md:text-sm hover:text-primary transition-colors`,children:e(`Terms`)}),(0,X.jsx)(d,{to:`/privacy`,className:`text-xs md:text-sm hover:text-primary transition-colors`,children:e(`Privacy`)})]})]})},Oa=()=>{let{collapsed:e,sidebarType:t}=Dr(),{layout:n,footerType:r}=Hr(),i=Ge(),a=qe(`(min-width: 768px)`);return i?!a&&t===`module`?(0,X.jsx)(Ea,{}):r===`hidden`?null:n===`semibox`?(0,X.jsx)(`div`,{className:`xl:mx-20 mx-6`,children:(0,X.jsx)(Ta,{className:q(` rounded-md border`,{"ltr:xl:ml-[72px] rtl:xl:mr-[72px]":e,"ltr:xl:ml-[272px] rtl:xl:mr-[272px]":!e,"sticky bottom-0":r===`sticky`}),children:(0,X.jsx)(Da,{})})}):t!==`module`&&n!==`horizontal`?(0,X.jsx)(Ta,{className:q(``,{"ltr:xl:ml-[248px] rtl:xl:mr-[248px]":!e,"ltr:xl:ml-[72px] rtl:xl:mr-[72px]":e,"sticky bottom-0":r===`sticky`}),children:(0,X.jsx)(Da,{})}):n===`horizontal`?D.copyright?(0,X.jsx)(Ta,{className:q(``,{"sticky bottom-0":r===`sticky`}),children:(0,X.jsx)(Da,{})}):void 0:(0,X.jsx)(Ta,{className:q(``,{"ltr:xl:ml-[300px] rtl:xl:mr-[300px]":!e,"ltr:xl:ml-[72px] rtl:xl:mr-[72px]":e,"sticky bottom-0":r===`sticky`}),children:(0,X.jsx)(Da,{})}):null},ka=({children:e,className:t,hidden:n})=>{let[r,i]=(0,Y.useState)(!1),{theme:a,radius:o}=Hr(),{loading:s}=Zr(),c=Ge(),l=qe(`(min-width: 768px)`),{pathname:u}=h(),d=(0,Y.useMemo)(()=>[...ut()],[yt]);return(0,Y.useEffect)(()=>{document.body.className=q(`jk-app`,`theme-`+a),document.body.style.setProperty(`--radius`,`${o}rem`)},[a,o]),c?n?e:(0,X.jsxs)(X.Fragment,{children:[!n&&(0,X.jsx)(wa,{loading:s,menus:d,onOpenSearch:()=>i(!0)}),(0,X.jsx)(`div`,{className:q(`content-wrapper transition-all duration-150 `),children:(0,X.jsx)(`div`,{className:q(!n&&`md:pt-6 pb-[20px] pt-[15px] md:px-6 px-4  page-min-height-horizontal`,t),children:(0,X.jsx)(ha,{isMobile:l,setSearchOpened:i,searchOpened:r,animated:n,location:u,menus:d,children:e})})}),!n&&(0,X.jsx)(Oa,{})]}):(0,X.jsx)(we,{})},Aa=e({default:()=>Na}),ja=document.title,Ma=Xe(``);Je(()=>{document.title=Ma.value});function Na({children:e}){let t=Qi()?.title??ja,{t:n}=W(),{user:r,isDarkMode:i,loading:a,initializing:o,isRole:s,onDarkToggle:c,updateUser:l,logout:u}=ra();(0,Y.useEffect)(()=>{Ma.value=t===D.name?D.name:t.includes(D.name)?n(t):`${n(t)} | ${D.name}`});let d=(0,Y.useCallback)(e=>{Ma.value=n(e)},[]),f=(0,Y.useMemo)(()=>({user:r,isAdmin:s(ct.ADMIN),isRole:s,isDarkMode:i,layout:`classic`,onDarkToggle:c,updateUser:l,logout:u,setTitle:d,loading:a}),[r]);return o?(0,X.jsx)(we,{}):(0,X.jsxs)(Kr,{value:f,children:[(0,X.jsx)(Se,{}),(0,X.jsx)($i,{children:(0,X.jsx)(ka,{className:`p-0 md:pt-0 md:px-0`,children:(0,X.jsx)(Y.Suspense,{children:e||(0,X.jsx)(p,{})})})})]})}var Pa=e({default:()=>La}),Fa=document.title,Ia=Xe(``);Je(()=>{document.title=Ia.value});function La(){let e=Qi()?.title??Fa,{user:t,isDarkMode:n,initializing:r,isRole:i,onDarkToggle:a,updateUser:o,logout:s}=ra(),{t:c}=W();(0,Y.useEffect)(()=>{Ia.value=e===D.name?D.name:e.includes(D.name)?c(e):`${c(e)} | ${D.name}`});let l=(0,Y.useCallback)(e=>{Ia.value=c(e)},[]),u=(0,Y.useMemo)(()=>({user:t,isAdmin:i(ct.ADMIN),isRole:i,isDarkMode:n,layout:`classic`,onDarkToggle:a,updateUser:o,logout:s,setTitle:l}),[t]);return r?(0,X.jsx)(we,{}):(0,X.jsxs)(Kr,{value:u,children:[(0,X.jsx)(Se,{}),(0,X.jsx)($i,{children:(0,X.jsx)(ka,{hidden:!0,children:(0,X.jsx)(Y.Suspense,{children:(0,X.jsx)(p,{})})})})]})}var Ra=e({config:()=>za,default:()=>Wa}),za={menu:{order:0},title:B(`Games`)},Ba=e=>e.trim().toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``),Va=(e,t)=>{if(!t)return 0;let n=Ba(e),r=Ba(t);if(!n||!r)return-1;let i=n.indexOf(r);if(i===0)return 1e3-n.length;if(i>0)return 500-i;let a=0,o=0,s=-1;for(let e=0;e<n.length&&a<r.length;e++)n[e]===r[a]&&(s!==-1&&(o+=e-s-1),s=e,a++);return a===r.length?100-o:-1},Ha=(e,t)=>{let n=Ba(t);if(!n)return(0,X.jsx)(X.Fragment,{children:e});let r=Ba(e).indexOf(n);if(r!==-1){let t=e.slice(0,r),i=e.slice(r,r+n.length),a=e.slice(r+n.length);return(0,X.jsxs)(X.Fragment,{children:[t,(0,X.jsx)(`mark`,{className:`rounded bg-yellow-200/80 px-0.5 text-foreground shadow-[0_0_0_1px_rgba(0,0,0,0.04)]`,children:i}),a]})}let i=Array.from(e),a=i.map(e=>Ba(e)),o=Array.from(n);if(o.length===0)return(0,X.jsx)(X.Fragment,{children:e});let s=new Set,c=0;for(let e=0;e<a.length&&c<o.length;e++)a[e]===o[c]&&(s.add(e),c++);return c<o.length?(0,X.jsx)(X.Fragment,{children:e}):(0,X.jsx)(X.Fragment,{children:i.map((e,t)=>s.has(t)?(0,X.jsx)(`mark`,{className:`rounded bg-yellow-100/80 px-0.5 text-foreground`,children:e},t):(0,X.jsx)(`span`,{children:e},t))})},Ua=e=>{switch(e){case`SOLO`:return{label:`Solo`,description:`Solo: Indiv
6idual play`,Icon:jn,className:`bg-slate-950/80 text-slate-100 border-slate-700/80`};case`LIVE_VIEW`:return{label:`Watch Link`,description:`Live View: Watch link available`,Icon:Pt,className:`bg-sky-950/80 text-sky-100 border-sky-700/80`};case`LIVE_PLAY`:return{label:`Playable`,description:`Live Play: Can play`,Icon:Tt,className:`bg-emerald-950/80 text-emerald-100 border-emerald-700/80`};default:return{label:`Playable`,description:`Live Play: Can play`,Icon:Ot,className:`bg-slate-950/80 text-slate-100 border-slate-700/80`}}};function Wa(){let{t:e}=W(),{state:{rateLimits:t},isAdmin:n,isPublisher:r}=pt(),[i,a]=(0,Y.useState)([]),[o,s]=(0,Y.useState)([]),[c,l]=(0,Y.useState)(``),[u,f]=(0,Y.useState)(``),p=(0,Y.useRef)(null),m=(0,Y.useRef)(null),[h,g]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>(p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{f(c)},150),()=>{p.current!==null&&window.clearTimeout(p.current)}),[c]),(0,Y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&document.activeElement===m.current&&(l(``),m.current?.blur())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let _=(0,Y.useCallback)(()=>{a([]),s([]),l(``)},[]),v=(0,Y.useCallback)(e=>{s(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{filteredGames:y,totalAfterRateLimits:b}=(0,Y.useMemo)(()=>{let n=ei.map(e=>({game:e,isDisabled:t?.find(t=>t.gameId===e.id)?.active===!1})),r=u?n:n.filter(({isDisabled:e})=>!e),a=r.length,s=r;return i.length>0&&(s=s.filter(({game:e})=>i.some(t=>e.serviceLevels.includes(t)))),o.length>0&&(s=s.filter(({game:e})=>o.includes(e.interactionMode))),u&&(s=s.map(t=>({item:t,score:Va(e(t.game.title),u)})).filter(({score:e})=>e>=0).sort((e,t)=>t.score-e.score).map(({item:e})=>e)),{filteredGames:s,totalAfterRateLimits:a}},[u,t,o,i,e]),x=i.length>0||o.length>0||!!u,S=(0,Y.useMemo)(()=>{if(!u&&i.length===0&&o.length===0)return null;let t=`${y.length}/${b}`;return u?e(`Search results: {{base}}`,{base:t}):t},[u,y.length,o.length,i.length,e,b]),T=[{key:`SOLO`,...Ua(`SOLO`)},{key:`LIVE_VIEW`,...Ua(`LIVE_VIEW`)},{key:`LIVE_PLAY`,...Ua(`LIVE_PLAY`)}],E=e=>{let t=new Set(h);t.has(e)?t.delete(e):t.add(e),g(t)};return(0,X.jsxs)(`div`,{className:`md:pt-6 pb-[20px] pt-[15px] md:px-6 px-4 flex flex-col items-center`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center mb-10 space-y-4 w-full max-w-3xl`,id:`games-section`,children:[(0,X.jsx)(`h2`,{className:`text-3xl font-bold text-foreground tracking-tight`,children:e(`Games`)}),(0,X.jsxs)(`div`,{className:`w-full`,children:[(0,X.jsx)(`label`,{htmlFor:`games-search`,className:`sr-only`,children:e(`Search games`)}),(0,X.jsxs)(`div`,{className:`relative w-full`,children:[(0,X.jsx)(Vn,{className:`pointer-events-none absolute ltr:left-3 rtl:right-3 top-1/2 h-4 w-4 -translate-y-1/2 sm:h-5 sm:w-5 text-muted-foreground`}),(0,X.jsx)(Pe,{id:`games-search`,ref:m,type:`search`,autoComplete:`off`,spellCheck:!1,placeholder:e(`Search games by name...`),value:c,onChange:e=>l(e.target.value),className:q(`ltr:pl-10 ltr:pr-4 rtl:pr-10 rtl:pl-4 h-10 text-sm`,`shadow-[0_10px_30px_-15px_rgba(0,0,0,0.35)] border-border/60 bg-background/80 backdrop-blur`)})]}),S&&(0,X.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 text-[11px] font-bold text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:S}),x&&(0,X.jsxs)(F,{type:`button`,variant:`ghost`,size:`sm`,onClick:_,className:`h-6 gap-1 px-2 text-[11px] text-muted-foreground hover:text-foreground`,children:[(0,X.jsx)(Ut,{className:`h-3 w-3`}),e(`Reset Filter`)]})]})]})]}),(0,X.jsxs)(`div`,{className:`mb-3 w-full max-w-3xl p-4`,children:[(0,X.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:T.map(t=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>v(t.key),"aria-pressed":o.includes(t.key),className:q(`flex items-start gap-3 rounded-xl border p-3 text-start transition-all duration-200`,o.includes(t.key)?`border-primary bg-primary/10 shadow-sm ring-1 ring-primary/30`:`border-border/50 bg-background/70 hover:border-primary/40 hover:bg-background`),children:[(0,X.jsx)(C,{variant:`outline`,className:q(`mt-0.5 inline-flex shrink-0 items-center gap-1.5 rounded-full border px-2 py-1 text-[10px] font-bold shadow-sm`,t.className),children:(0,X.jsx)(t.Icon,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:e(t.description)})})]},t.key))}),(0,X.jsxs)(`div`,{className:`mt-2 px-1 text-[11px] text-muted-foreground
6/90 inline-flex items-center gap-1.5`,children:[(0,X.jsx)(jn,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:e(`All solo games are free.`)})]})]}),(0,X.jsx)(`div`,{className:`flex flex-col sm:grid sm:grid-cols-3 lg:grid-cols-4 gap-4 w-full max-w-7xl`,children:y.map(({game:t,isDisabled:i})=>{let a=i&&!n&&!r,o=h.has(t.id),s=e(t.description),c=s.length>100,l=t.ctas?.primary?.href??t.link,f=e(t.title),p=Ua(t.interactionMode);return(0,X.jsxs)(K,{className:q(`group/card relative h-full min-h-[350px] sm:min-h-full sm:overflow-hidden transition-all duration-300 flex flex-col bg-gradient-to-br from-card to-card-foreground/20 border border-border/50`,a?`opacity-80 saturate-75`:`hover:shadow-lg hover:transform hover:scale-[1.02]`),children:[(0,X.jsxs)(R,{className:`relative pb-2 p-3 flex-shrink-0`,children:[a?(0,X.jsx)(`div`,{className:`flex flex-col gap-2 cursor-not-allowed`,children:(0,X.jsx)(`div`,{className:`flex justify-between items-start gap-1`,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(w,{className:`min-w-0 text-sm font-bold leading-tight text-muted-foreground`,children:Ha(f,u)}),t.beta&&(0,X.jsxs)(C,{variant:`outline`,className:`text-xs px-1 py-0 bg-orange-100 text-orange-600 border-orange-300 flex items-center gap-1`,children:[(0,X.jsx)(sn,{size:10}),e(`Beta`)]}),t.update&&(0,X.jsxs)(C,{variant:`outline`,className:`text-xs px-1 py-0 bg-yellow-100 text-yellow-600 border-yellow-300 flex items-center gap-1`,children:[(0,X.jsx)(sn,{size:10}),e(`Updated`)]}),t.new&&(0,X.jsxs)(C,{variant:`outline`,className:`text-xs px-1 py-0 bg-green-100 text-green-600 border-green-300 flex items-center gap-1`,children:[(0,X.jsx)(mn,{size:10}),e(`New`)]}),(0,X.jsx)(C,{variant:`outline`,className:`border-red-300 bg-red-100 text-red-700 text-[10px] px-2 py-0.5`,children:e(`Unavailable`)})]})})}):(0,X.jsx)(d,{to:t.link,className:`flex flex-col gap-2`,children:(0,X.jsx)(`div`,{className:`flex justify-between items-start gap-1`,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(w,{className:`min-w-0 text-sm font-bold leading-tight`,children:Ha(f,u)}),t.beta&&(0,X.jsxs)(C,{variant:`outline`,className:`text-xs px-1 py-0 bg-orange-100 text-orange-600 border-orange-300 flex items-center gap-1`,children:[(0,X.jsx)(sn,{size:10}),e(`Beta`)]}),t.update&&(0,X.jsxs)(C,{variant:`outline`,className:`text-xs px-1 py-0 bg-yellow-100 text-yellow-600 border-yellow-300 flex items-center gap-1`,children:[(0,X.jsx)(sn,{size:10}),e(`Updated`)]}),t.new&&(0,X.jsxs)(C,{variant:`outline`,className:`text-xs px-1 py-0 bg-green-100 text-green-600 border-green-300 flex items-center gap-1`,children:[(0,X.jsx)(mn,{size:10}),e(`New`)]})]})})}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute top-1 ltr:right-3 rtl:left-3`,children:(0,X.jsx)(C,{variant:`outline`,className:q(`inline-flex items-center gap-1.5 opacity-85 rounded-full border px-2 py-1 text-[10px] font-bold shadow-sm`,p.className),children:(0,X.jsx)(p.Icon,{className:`h-3.5 w-3.5`})})})]}),(0,X.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[a?(0,X.jsx)(`div`,{className:`group/media block overflow-hidden aspect-video cursor-not-allowed`,"aria-disabled":`true`,children:(0,X.jsx)(`img`,{src:`/images/games/${t.id}.png`,alt:f,className:`w-full h-full object-cover grayscale transition-transform duration-500`})}):(0,X.jsx)(d,{to:t.link,className:`group/media block overflow-hidden aspect-video`,children:(0,X.jsx)(`img`,{src:`/images/games/${t.id}.png`,alt:f,className:`w-full h-full object-cover transition-transform duration-500 group-hover/media:scale-110`})}),a&&(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-black/40 backdrop-blur-[2px]`,children:(0,X.jsx)(C,{className:`border-amber-300 bg-amber-100 text-amber-800 font-bold`,children:e(`Coming Soon`)})}),!a&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 bg-gradient-to-t from-black/70 via-black/15 to-transparent opacity-100 sm:opacity-0 sm:transition-opacity sm:duration-300 sm:group-hover/card:opacity-100`}),(0,X.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 p-3 op
6acity-100 transition-all duration-300 sm:translate-y-2 sm:opacity-0 sm:group-hover/card:translate-y-0 sm:group-hover/card:opacity-100`,children:[t.external?(0,X.jsxs)(`a`,{href:l,"aria-label":`${e(`Play Now`)}: ${f}`,className:q(`pointer-events-auto group inline-flex items-center justify-center gap-2 rounded-lg`,`bg-primary/60 px-4 py-2 text-sm font-extrabold text-primary-foreground`,`shadow-sm transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,`hover:opacity-95`),children:[(0,X.jsx)(Ot,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:e(`Play Now`)}),(0,X.jsx)(Yn,{className:`h-4 w-4 rtl:rotate-180 opacity-80 transition-transform group-hover:translate-x-0.5`,"aria-hidden":`true`})]}):(0,X.jsxs)(d,{to:l,"aria-label":`${e(`Play Now`)}: ${f}`,className:q(`pointer-events-auto group inline-flex items-center justify-center gap-2 rounded-lg`,`bg-primary/60 px-4 py-2 text-sm font-extrabold text-primary-foreground`,`shadow-sm transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,`hover:opacity-95`),children:[(0,X.jsx)(Ot,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:e(`Play Now`)}),(0,X.jsx)(Yn,{className:`h-4 w-4 rtl:rotate-180 opacity-80 transition-transform group-hover:translate-x-0.5`,"aria-hidden":`true`})]}),`;`]})]})]}),(0,X.jsxs)(L,{className:`bg-card/95 p-3 flex flex-col flex-1`,children:[(0,X.jsx)(`p`,{className:q(`text-xs text-muted-foreground leading-relaxed`,!o&&c?`line-clamp-2`:``),children:s}),c&&(0,X.jsx)(`button`,{onClick:e=>{e.preventDefault(),E(t.id)},className:`flex items-center gap-1 text-xs text-primary hover:text-primary/80 transition-colors mt-1 font-medium`,children:o?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Wt,{size:12}),e(`Show Less`)]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_n,{size:12}),e(`Read More`)]})})]})]},t.id)})}),y.length===0&&(0,X.jsxs)(`div`,{className:`mt-8 p-6 bg-card/80 rounded-lg text-center max-w-xl w-full`,children:[(0,X.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted/60`,children:(0,X.jsx)(Vn,{className:`h-5 w-5 text-muted-foreground`})}),(0,X.jsx)(`h3`,{className:`text-xl font-bold mb-2`,children:e(`No Games Available`)}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:u?e(`No games match your search: {{query}}`,{query:`"${u}"`}).replace(/\{\{query\}\}/,`"${u}"`):e(`No games match the selected filter. Please select another service level.`)}),x&&(0,X.jsx)(F,{className:`mt-1`,onClick:_,children:e(`Reset Filter`)})]}),(0,X.jsx)(`div`,{id:`faq-section`,children:(0,X.jsx)(wr,{category:`general`})})]})}var Ga=()=>{let{state:{maintenance:e,maintenanceMessage:t}}=pt(),{t:n}=W(),r=!!(e||typeof t==`string`&&t.trim().length>0),i=typeof t==`string`&&t.trim().length>0?t:n(`We are currently under maintenance`),a=e=>{let t=document.getElementById(e);if(t){let e=t.getBoundingClientRect().top+window.scrollY-150;window.scrollTo({top:e,behavior:`smooth`})}};return(0,X.jsxs)(`div`,{className:`relative overflow-hidden bg-gradient-to-br from-[#2094b1]/5 via-[#2094b1]/10 to-[#3c3c3c]/5 dark:from-[#2094b1]/10 dark:via-[#2094b1]/5 dark:to-[#3c3c3c]/10 border border-[#2094b1]/10 dark:border-[#2094b1]/20 shadow-xl mb-12`,children:[(0,X.jsxs)(`div`,{className:`absolute inset-0 overflow-hidden pointer-events-none`,children:[(0,X.jsx)(`div`,{className:`absolute top-0 ltr:right-0 rtl:left-0 w-[500px] h-[500px] bg-[#2094b1]/20 rounded-full blur-[100px] -translate-y-1/2 translate-x-1/2 opacity-60`}),(0,X.jsx)(`div`,{className:`absolute bottom-0 ltr:left-0 rtl:right-0 w-[400px] h-[400px] bg-[#3c3c3c]/10 rounded-full blur-[80px] translate-y-1/2 -translate-x-1/2 opacity-60`})]}),(0,X.jsxs)(`div`,{className:`relative z-10 px-6 py-10 md:py-12 md:px-10 flex flex-col items-center text-center`,children:[r&&(0,X.jsxs)(M,{color:`warning`,className:`w-full max-w-3xl mb-6 bg-background/60 backdrop-blur-sm text-foreground dark:text-white`,children:[(0,X.jsx)(Vt,{className:`h-4 w-4 text-foreground dark:text-white`}),(0,X.jsx)(ye,{className:`text-foreground dark:text-white`,children:i})]}),(0,X.jsx)(`h1`,{className:`text-3xl sm:text-4xl md:text-6xl font-black text-foreground ltr:tracking-tighter rtl:tracking-normal mb-6 ltr:leading-[1.1] rtl:leading-normal max-w-4xl mx-auto bg-gradient-to-r from-[#2094b1] via-[#3c3c3c] to-[#2094b1] dark:from-white dark:via-[#2094b1] dark:to-white bg-clip-text text-transparent bg-[length:200%_auto] animate-shine rtl:py-2 will-change-[background-position]`,children:n(`Discover a World of Excitement and Challenge!`)}),(0,X.jsx)(`p`,{className:`text-sm md:text-xl text-muted-foreground max-w-3xl mx-auto mb-10 leading-relaxed`,children:n(`Our site features an exceptional collection of interactive games designed specifically to bring friends and family together. Get ready for exciting adventures!`)}),(0,X.jsx)(`div`,{className:`flex flex-col sm:flex-row gap-4 w-full justify-center mb-10`,children:(0,X.jsxs)(F,{size:`lg`,className:`text-lg px-8 h-14 roun
6ded-full bg-[#2094b1] hover:bg-[#1a7a91] hover:shadow-[#2094b1]/40 text-white hover:-translate-y-1 transition-all duration-300 font-bold`,onClick:()=>a(`games-section`),children:[(0,X.jsx)(wn,{className:`ltr:mr-2 rtl:ml-2 h-5 w-5`}),n(`Play Now`)]})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-4 w-full max-w-sm mx-auto mb-6 opacity-60`,children:[(0,X.jsx)(`div`,{className:`h-px bg-gradient-to-r from-transparent via-border to-transparent flex-1`}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground font-medium uppercase tracking-widest`,children:n(`Or join via code`)}),(0,X.jsx)(`div`,{className:`h-px bg-gradient-to-r from-transparent via-border to-transparent flex-1`})]}),(0,X.jsx)($r,{className:`animate-fade-in-up`})]})]})},Ka=e({config:()=>qa,default:()=>Ja}),qa={menu:{order:0,exclude:!0},title:D.name};function Ja(){return(0,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsx)(Ga,{}),(0,X.jsx)(Wa,{})]})}var Q=t(ai(),1),Ya=oi,Xa=Y.createContext(void 0),Za=Y.createContext(void 0),Qa=({...e})=>(0,X.jsx)(Xa.Provider,{value:{name:e.name},children:(0,X.jsx)(ii,{...e})}),$a=()=>{let e=Y.useContext(Xa),t=Y.useContext(Za),{getFieldState:n,formState:r}=ni();if(!e)throw Error(`useFormField should be used within <FormField>`);let i=n(e.name,r);if(!t)throw Error(`useFormField should be used within <FormItem>`);let{id:a}=t;return{id:a,name:e.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...i}},eo=Y.forwardRef(({className:e,...t},n)=>{let r=Y.useId();return(0,X.jsx)(Za.Provider,{value:{id:r},children:(0,X.jsx)(`div`,{ref:n,className:q(`space-y-2 w-full`,e),...t})})});eo.displayName=`FormItem`;var to=Y.forwardRef(({className:e,...t},n)=>{let{error:r,formItemId:i}=$a();return(0,X.jsx)(ue,{ref:n,className:q(r&&`text-destructive`,e),htmlFor:i,...t})});to.displayName=`FormLabel`;var no=Y.forwardRef(({...e},t)=>{let{error:n,formItemId:r,formDescriptionId:i,formMessageId:a}=$a();return(0,X.jsx)(Mn,{ref:t,id:r,"aria-describedby":n?`${i} ${a}`:`${i}`,"aria-invalid":!!n,...e})});no.displayName=`FormControl`;var ro=Y.forwardRef(({className:e,...t},n)=>{let{formDescriptionId:r}=$a();return(0,X.jsx)(`p`,{ref:n,id:r,className:q(`text-sm text-muted-foreground`,e),...t})});ro.displayName=`FormDescription`;var io=({value:e=``,onChange:t,disabled:n=!1,length:r=6})=>{let i=Math.max(1,Math.floor(r)),a=Y.useRef([]),[o,s]=Y.useState(()=>Array(i).fill(``));Y.useEffect(()=>{let t=(e||``).split(``).slice(0,i);s([...t,...Array(i-t.length).fill(``)])},[e,i]);let c=(e,n)=>{let r=n.target.value;if(!/^\d*$/.test(r))return;let c=[...o];if(r.length>1){let t=r.split(``).slice(0,i-e);for(let n=0;n<t.length;n++)e+n<i&&(c[e+n]=t[n]);let n=Math.min(e+t.length,i-1);setTimeout(()=>{a.current[n]?.focus()},0)}else c[e]=r,r&&e<i-1&&setTimeout(()=>{a.current[e+1]?.focus()},0);s(c),t(c.join(``))},l=(e,t)=>{t.key===`Backspace`&&!o[e]&&e>0&&setTimeout(()=>{a.current[e-1]?.focus()},0)},u=e=>{e.preventDefault();let n=e.clipboardData.getData(`text`);if(!/^\d*$/.test(n))return;let r=n.slice(0,i).split(``),o=Array(i).fill(``);r.forEach((e,t)=>{t<i&&(o[t]=e)}),s(o),t(o.join(``));let c=Math.min(r.length,i-1);setTimeout(()=>{a.current[c]?.focus()},0)};return(0,X.jsx)(`div`,{className:`flex justify-between gap-2 w-full`,children:Array(i).fill(0).map((e,t)=>(0,X.jsx)(Pe,{ref:e=>{a.current[t]=e},type:`text`,inputMode:`numeric`,maxLength:1,value:o[t]||``,onChange:e=>c(t,e),onKeyDown:e=>l(t,e),onPaste:t===0?u:void 0,className:`w-12 h-12 text-center text-lg`,disabled:n,"aria-label":`Digit ${t+1}`},t))})};function ao(e,t){if(!Ue(e))return e;let n=e.match(/^"([^"]+)"\s+(.*)$/);if(n){let e=n[1],r=n[2];return t(`{{field}} ${r}`,{field:e})}return t(e)}var oo=Y.forwardRef(({className:e,children:t,tooltip:n=!1,...r},i)=>{let{t:a}=W(),{error:o,formMessageId:s}=$a(),c=o?String(o?.message):t;if(!c||c===`undefined`)return null;let l=ao(c,a);return(0,X.jsx)(`p`,{ref:i,id:s,className:q(`text-xs text-destructive leading-none px-1.5 py-2  rounded-0.5`,e,{" bg-destructive text-destructive-foreground  inline-block":n}),...r,children:l})});oo.displayName=`FormMessage`;var so=({className:e,name:t,label:n,placeholder:r,control:i,error:a,required:o,disabled:s,help:c,onValueChanged:l,...u})=>
6(0,X.jsx)(Qa,{control:i,name:t,render:({field:{onChange:t,value:i=``,...d}})=>(0,X.jsxs)(eo,{className:`mb-4`,children:[(0,X.jsx)(to,{required:o,children:n}),(0,X.jsx)(no,{children:(0,X.jsx)(Pe,{placeholder:r,disabled:s,required:o,value:i,onChange:e=>{t(e),l?.(e)},...u,...d,className:q(e,{"border-destructive focus:border-destructive":a})})}),c&&(0,X.jsx)(`div`,{className:`text-xs text-default-400 dark:text-default-600  mb-4`,children:c}),(0,X.jsx)(oo,{tooltip:!0})]})}),co=({className:e,name:t,label:n,placeholder:r,control:i,error:a,required:o,disabled:s,help:c,onValueChanged:l,...u})=>(0,X.jsx)(Qa,{control:i,name:t,render:({field:{onChange:t,value:i=``,...d}})=>(0,X.jsxs)(eo,{className:`mb-4`,children:[(0,X.jsx)(to,{required:o,children:n}),(0,X.jsx)(no,{children:(0,X.jsx)(me,{placeholder:r,disabled:s,value:i,required:o,onChange:e=>{t(e),l?.(e)},...u,...d,className:q(e,{"border-destructive focus:border-destructive":a})})}),c&&(0,X.jsx)(`div`,{className:`text-xs text-default-400 dark:text-default-600  mb-4`,children:c}),(0,X.jsx)(oo,{tooltip:!0})]})}),lo=({name:e,label:t,control:n,error:r,help:i,onValueChanged:a,...o})=>(0,X.jsx)(Qa,{control:n,name:e,render:({field:{onChange:e,value:n=!1,...a}})=>(0,X.jsxs)(eo,{className:`mb-2`,children:[(0,X.jsx)(no,{children:(0,X.jsx)(Ve,{checked:n,onCheckedChange:t=>{e(t)},...o,...a,className:q(``,{"border-destructive focus:border-destructive":r}),children:t})}),i&&(0,X.jsx)(`div`,{className:`text-xs text-default-400 dark:text-default-600  mb-4`,children:i}),(0,X.jsx)(oo,{tooltip:!0})]})}),uo=({name:e,label:t,items:n,placeholder:r,help:i,control:a,required:o,error:s,isMulti:c,onValueChanged:l,...u})=>{let{t:d}=W();return(0,X.jsx)(Qa,{control:a,name:e,render:({field:{onChange:e,value:a,...f}})=>{let p;return c?(p=a?n.filter(e=>a.includes(e.value)):[],o&&p?.length===0&&(p=void 0)):p=n.find(e=>e.value===a),(0,X.jsxs)(eo,{className:`mb-4`,children:[(0,X.jsx)(to,{required:o,children:t}),(0,X.jsx)(no,{children:(0,X.jsx)(cr,{classNamePrefix:`select`,options:n,placeholder:r||d(`Select...`),value:p,isMulti:c,required:o,onChange:t=>{if(Array.isArray(t)){let n=t.map(e=>e.value);o&&n.length===0&&(n=void 0),e(n)}else e(t?.value);l?.(t)},classNames:{menuPortal:()=>`z-20`,menu:()=>`z-20`,control:()=>c?`h-auto max-h-70 overflow-hidden`:``},className:q(`react-select`,{"border-destructive focus:border-destructive":s}),...u,...f})}),i&&(0,X.jsx)(`div`,{className:`text-xs text-default-400 dark:text-default-600  mb-4`,children:i}),(0,X.jsx)(oo,{tooltip:!0})]})}})},fo=Q.default.object({code:Q.default.string().length(6).pattern(/^[0-9]+$/).required().messages({"string.length":`Verification code must be 6 digits`,"string.pattern.base":`Verification code must contain only numbers`,"string.empty":`Verification code is required`})}),po=e({config:()=>mo,default:()=>yo}),mo={menu:{exclude:!0},title:`Sign In`},ho=Q.default.object({login:Q.default.string().email({tlds:{allow:!1}}).required().messages({"string.empty":`Please enter the email.`}),password:Q.default.string().required().label(`Password`).messages({"string.min":`{{#label}} should have a minimum length of {#limit}`,"string.empty":`Please enter the password.`})}),go=300,_o=`loginActivationLastSent`,vo=()=>{let{login:e,setToken:t}=pt(),[n,r]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(0),[l,u]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(0),g=i(),{t:_}=W(),[v,y]=(0,Y.useState)(`password`),b=ri({resolver:si(ho),mode:`all`,defaultValues:{login:``,password:``}}),x=ri({resolver:si(fo),defaultValues:{code:``}}),S=qe(`(max-width: 1530px)`);(0,Y.useEffect)(()=>{let e=localStorage.getItem(_o);if(!e)return;let t=parseInt(e,10);if(!Number.isFinite(t))return;let n=Math.floor((Date.now()-t)/1e3);n<go?h(go-n):localStorage.removeItem(_o)},[]),(0,Y.useEffect)(()=>{if(m<=0)return;let e=window.setInterval(()=>{h(t=>t<=1?(window.clearInterval(e),0):t-1)},1e3);return()=>window.clearInterval(e)},[m]);let C=()=>{let e=Date.now();localStorage.setItem(_o,e.toString()),h(go)},w=()=>{v===`text`?y(`password`):v===`password`&&y(`text`)},T=async t=>{r(null),o(null);try{let n=await e(t.login,t.password);!n.error&&n.token?(g(`/`),b.reset()):n.activation?(u({login:t.login,password:t.password}),c(1),x.setValue(`code`,``,{shouldValidate:!0}),C()):r(n.errorMessage||_(`Invalid credentials.`))}catch{r(_(`Invalid credentials.`))}},E=async e=>{r(null),o(null);try{let n=await $e(e.code);
6if(typeof n.token==`string`&&n.token.trim().length>0){t(n.token),g(`/`),b.reset(),x.reset();return}r(_(`An error occurred. Please try again.`))}catch(e){e instanceof lt?r(_(`Invalid verification code. Please try again.`)):r(_(`An error occurred. Please try again.`))}},O=async()=>{if(f||m>0)return;let t=l||{login:b.getValues(`login`),password:b.getValues(`password`)};r(null),o(null),p(!0);try{if(await nt(t.login,t.password)){o(_(`A new verification code has been sent to your email`)),C();return}let n=await e(t.login,t.password);if(!n.error&&n.token){g(`/`),b.reset(),x.reset();return}r(n.errorMessage||_(`Invalid credentials.`)),c(0),u(null)}catch{r(_(`Invalid credentials.`)),c(0),u(null)}finally{p(!1)}};return(0,X.jsxs)(`div`,{className:`w-full `,children:[(0,X.jsx)(`div`,{className:`2xl:my-8 my-6 flex gap-4 items-center justify-center`,children:(0,X.jsxs)(d,{to:`/`,className:`inline-block`,children:[(0,X.jsx)(`img`,{src:`/images/logo.png`,alt:D.name,className:`dark:hidden`}),(0,X.jsx)(`img`,{src:`/images/logo-dark.png`,alt:D.name,className:`hidden dark:block`})]})}),(0,X.jsx)(`h2`,{className:`text-lg sm:text-xl font-bold mb-4 text-center`,children:_(s===0?`Sign In`:`Verification`)}),n&&(0,X.jsx)(M,{color:`destructive`,className:`p-2 mb-4`,children:(0,X.jsx)(ye,{children:n})}),a&&(0,X.jsx)(M,{color:`success`,className:`p-2 mb-4`,children:(0,X.jsx)(ye,{children:a})}),s===0?(0,X.jsx)(Ya,{...b,children:(0,X.jsxs)(`form`,{onSubmit:b.handleSubmit(T),className:`space-y-8`,children:[(0,X.jsx)(so,{type:`email`,name:`login`,label:_(`E-Mail Address`),size:S?`lg`:`xl`,disabled:b.formState.isSubmitting,control:b.control,error:b.formState.errors.login,onValueChanged:()=>{r(null),o(null)}}),(0,X.jsxs)(`div`,{className:`relative mt-6`,children:[(0,X.jsx)(so,{type:v===`password`?`password`:`text`,name:`password`,label:_(`Password`),size:S?`lg`:`xl`,disabled:b.formState.isSubmitting,control:b.control,error:b.formState.errors.password,onValueChanged:()=>{r(null),o(null)}}),(0,X.jsx)(F,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute top-10 -translate-y-1/2 ltr:right-3 rtl:left-3 h-8 w-8`,onClick:w,disabled:b.formState.isSubmitting,"aria-label":_(v===`password`?`Show password`:`Hide password`),children:v===`password`?(0,X.jsx)(Pt,{className:`w-4 h-4 text-default-400`}):(0,X.jsx)(Xt,{className:`w-4 h-4 text-default-400`})})]}),(0,X.jsx)(`div`,{className:`mt-5  mb-6 flex flex-wrap gap-2`,children:(0,X.jsx)(d,{to:`/forgot-password`,className:`flex-none text-sm text-primary`,children:_(`Forgot password?`)})}),(0,X.jsxs)(F,{type:`submit`,className:`w-full`,disabled:b.formState.isSubmitting,size:S?`md`:`lg`,children:[b.formState.isSubmitting&&(0,X.jsx)(ar,{className:`ltr:mr-2 rtl:ml-2 h-4 w-4 animate-spin`}),b.formState.isSubmitting?_(`Loading...`):_(`Log in`)]})]})}):(0,X.jsx)(Ya,{...x,children:(0,X.jsxs)(`form`,{onSubmit:x.handleSubmit(E),className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`text-sm font-medium`,children:_(`Verification Code`)}),(0,X.jsx)(io,{value:x.watch(`code`),onChange:e=>{r(null),o(null),x.setValue(`code`,e,{shouldValidate:!0})},disabled:x.formState.isSubmitting||f}),x.formState.errors.code&&(0,X.jsx)(`p`,{className:`text-xs text-destructive mt-1`,children:_(x.formState.errors.code.message)})]}),(0,X.jsxs)(`div`,{className:`text-sm text-center`,children:[(0,X.jsx)(`span`,{children:_(`Didn't receive the code?`)}),` `,m>0?(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[_(`Resend available in`),` `,Ur(m)]}):(0,X.jsx)(`button`,{type:`button`,onClick:O,className:`text-primary hover:underline`,disabled:x.formState.isSubmitting||f,children:_(`Resend`)})]}),(0,X.jsxs)(`div`,{className:`flex justify-between items-center gap-2`,children:[(0,X.jsx)(F,{type:`button`,variant:`ghost`,onClick:()=>{r(null),o(null),c(0)},disabled:x.formState.isSubmitting||f,children:_(`Back`)}),(0,X.jsxs)(F,{type:`submit`,disabled:x.formState.isSubmitting||f,size:S?`sm`:`md`,children:[x.formState.isSubmitting&&(0,X.jsx)(ar,{className:`ltr:mr-2 rtl:ml-2 h-4 w-4 animate-spin`}),x.formState.isSubmitting?_(`Verifying...`):_(`Verify Code`)]})]})]})}),(0,X.jsxs)(`div`,{className:`mt-6 text-center text-base text-default-600`,children:[_(`Don't have an account?`),` `,(0,X.jsxs)(d,{to:`/signup`,className:`text-primary`,children:[_(`Sign up`),` `]})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-center mt-6 space-x-4 rtl:space-x-reverse`,children:[(0,X.jsx)(d,{to:`/terms`,className:`text-xs md:text-sm hover:text-primary transition-colors`,children:_(`Terms`)}),(0,X.jsx)(d,{to:`/privacy`,className:`text-xs md:text-sm hover:text-primary transition-colors`,children:_(`Privacy`)})]})]})};function yo(){return(0,X.jsx)(`div`,{className:`absolute top-0 left-0 z-[60] w-screen h-screen`,children:(0,X.jsxs)(`div`,{className:`login-wrapper h-full flex justify-center items-center relative overflow-hidden`,children:[(0,X.jsx)(`img`,{src:`/images/auth/auth3-dark.png`,alt:`background image`,className:`absolute top-0 left-0 w-full h-full light:hidden`}),(0,X.jsx)(`img`,{src:`/images/auth/auth3-light.png`,alt:`background image`,className:`absolute top-0 left-0 w-full h-full dark:hidden`}),(0,X.jsx)(`div`,{className:`w-full bg-background   py-5 max-w-xl  rounded-xl relative z-10 2xl:p-16 xl:p-12 p-10 m-4 `,children:(0,X.jsx)(vo,{})})]})})}var bo=({user:e,isLoading:t})=>{let{t:n}=W();return t?(0,X.jsxs)(K,{children:[(0,X.jsx)(R,{children:(0,X.jsx)(w,{children:n(`User Profile`)})}),(0,X.jsx)(L,{children:(0,X.jsxs)(`div`,{className:`animate-pulse space-y-4`,children:[(0,X.jsx)(`div`,{className:`h-4 bg-default-200 rounded w-3/4`}),(0,X.jsx)(`div`,{className:`h-4 bg-default-200 rounded w-1/2`}),(0,X.jsx)(`div`,{className:`h-4 bg-default-200 rounded w-2/3`})]})})]}):(0,X.jsxs)(K,{children:[(0,X.jsx)(R,{children:(0,X.jsx)(w,{children:n(`User Profile`)})}),(0,X.jsxs)(L,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium text-muted-foreground`,children:n(`Name`)}),(0,X.jsx)(`p`,{className:`text-base`,children:e?.name||`-`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium text-muted-foreground`,children:n(`Email`)}),(0,X.jsx)(`p`,{className:`text-base`,children:e?.email||`-`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium text-muted-foreground`,children:n(`Gender`)}),(0,X.jsx)(`p`,{className:`text-base`,children:e?.gender?n(e.gender):`-`})]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium text-muted-foreground`,children:n(`Bio`)}),(0,X.jsx)(`p`,{className:`text-base whitespace-pre-wrap`,children:e?.bio||`-`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium text-muted-foreground`,children:n(`Mood`)}),(0,X.jsx)(`p`,{className:`text-base`,children:e?.mood||`-`})]})]})]})},xo=Q.default.object({name:Q.default.string().required().min(1).max(32).messages({"string.empty":`Name is required`,"string.min":`Name must be at least 1 character`,"string.max":`Name cannot exceed 32 characters`}),email:Q.default.string().required().email({tlds:!1}).max(254).messages({"string.empty":`Email is required`,"string.email":`Please enter a valid email address`,"string.max":`Email cannot exceed 254 characters`}),bio:Q.default.string().allow(``).max(500).messages({"string.max":`Bio cannot exceed 500 characters`}),mood:Q.default.string().allow(``).max(200).messages({"string.max":`Mood cannot exceed 200 characters`}),gender:Q.default.string().valid(`MALE`,`FEMALE`,`UNSPECIFIED`),current_password:Q.default.string().when(`.email`,{is:Q.default.string().required(),then:Q.default.string().required().messages({"string.empty":`Current password is required when changing email`}),otherwise:Q.default.string().allow(``)}).when(`new_password`,{is:Q.default.string().min(1),then:Q.default.string().required().messages({"string.empty":`Current password is required when changing password`}),otherwise:Q.default.string().allow(``)}),new_password:Q.default.string().allow(``).min(8).max(128).pattern(RegExp(`^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])`)).messages({"string.min":`Password must be at least 8 characters`,"string.max":`Password cannot exceed 128 characters`,"string.pattern.base":`Password must contain at least one uppercase letter, one lowercase letter, and one number`}),confirm_password:Q.default.string().valid(Q.default.ref(`new_password`)).when(`new_password`,{is:Q.default.exist().not(Q.default.equal(``)),then:Q.default.required().messages({"string.empty":`Please confirm your new password`,"any.only":`Passwords do not match`}),otherwise:Q.default.allow(``)})}),So=({userData:e,onSuccess:t})=>{let{t:n}=W(),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(!1),l=ri({defaultValues:{name:e?.name||``,email:e?.email||``,bio:e?.bio||``,mood:e?.mood||``,gender:e?.gender||`UNSPECIFIED`,current_password:``,new_password:``,confirm_password:``},resolver:si(xo)}),u=async r=>{i(!0),o(null),c(!1);try{let n=e&&e.email!==r.email,i=r.new_password&&r.new_password.length>0,a={name:r.name,email:r.email,bio:r.bio||null,mood:r.mood||null,gender:r.gender};(n||i)&&(a.current_password=r.current_password),i&&(a.password=r.new_password),await rt(a),c(!0),l.setValue(`current_password`,``),l.setValue(`new_password`,``),l.setValue(`confirm_password`,``),t()}catch(e){Jr(e,l,o,n,{password:`new_password`,confirmPassword:`confirm_password`})}finally{i(!1)}},d=[{label:n(`Male`),value:`MALE`},{label:n(`Female`),value:`FEMALE`},{label:n(`Prefer not to say`),value:`UNSPECIFIED`}];return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[a&&(0,X.jsx)(`div`,{className:`bg-destructive/10 text-destructive p-3 rounded-md`,children:a}),s&&(0,X.jsx)(`div`,{className:`bg-success/10 text-success p-3 rounded-md`,children:n(`Profile updated successfully`)}),(0,X.jsx)(Ya,{...l,children:(0,X.jsxs)(`form`,{onSubmit:l.handleSubmit(u),className:`space-y-4`,children:[(0,X.jsx)(so,{name:`name`,label:n(`Name`),placeholder:n(`Enter your name`),control:l.control,error:l.formState.errors.name,required:!0}),(0,X.jsx)(so,{name:`email`,label:n(`Email`),placeholder:n(`Enter your email`),control:l.control,error:l.formState.errors.email,required:!0}),(0,X.jsx)(uo,{name:`gender`,label:n(`Gender`),control:l.control,error:l.formState.errors.gender,items:d}),(0,X.jsx)(co,{name:`bio`,label:n(`Bio`),placeholder:n(`Tell us about yourself`),control:l.control,error:l.formState.errors.bio}),(0,X.jsx)(so,{name:`mood`,label:n(`Mood`),placeholder:n(`How are you feeling today?`),control:l.control,error:l.formState.errors.mood}),(0,X.jsxs)(`div`,{className:`border-t pt-4 mt-6`,children:[(0,X.jsx)(`h3`,{className:`text-lg font-medium mb-4`,children:n(`Change Password`)}),(0,X.jsx)(so,{name:`current_password`,label:n(`Current Password`),type:`password`,control:l.control,error:l.formState.errors.current_password}),(0,X.jsx)(so,{name:`new_password`,label:n(`New Password`),type:`password`,control:l.control,error:l.formState.errors.new_password}),(0,X.jsx)(so,{name:`confirm_password`,label:n(`Confirm New Password`),type:`password`,control:l.control,error:l.formState.errors.confirm_password})]}),(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsxs)(F,{type:`submit`,disabled:r,children:[r&&(0,X.jsx)(ar,{className:`ltr:mr-2 rtl:ml-2 h-4 w-4 animate-spin`}),n(r?`Saving...`:`Save Changes`)]})})]})})]})},Co=({subscriptions:e,isLoading:t})=>{let{t:n,tDateTimeParser:r}=W();if(t)return(0,X.jsxs)(K,{children:[(0,X.jsx)(R,{children:(0,X.jsx)(w,{children:n(`Subscriptions`)})}),(0,X.jsx)(L,{children:(0,X.jsxs)(`div`,{className:`animate-pulse space-y-4`,children:[(0,X.jsx)(`div`,{className:`h-4 bg-default-200 rounded w-3/4`}),(0,X.jsx)(`div`,{className:`h-4 bg-default-200 rounded w-1/2`}),(0,X.jsx)(`div`,{className:`h-4 bg-default-200 rounded w-2/3`})]})})]});if(!e||e.length===0)return(0,X.jsxs)(K,{children:[(0,X.jsx)(R,{children:(0,X.jsx)(w,{children:n(`Subscriptions`)})}),(0,X.jsx)(L,{children:(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:n(`No active subscriptions`)})})]});let i=e=>{if(e.cancelReason)return(0,X.jsx)(C,{color:`destructive`,children:n(`Cancelled`)});switch(e.status){case bt.ACTIVE:return(0,X.jsx)(C,{color:`success`,children:n(`Active`)});case bt.EXPIRING_SOON:return(0,X.jsx)(C,{color:`warning`,children:n(`Expiring Soon`)});case bt.EXPIRED:return(0,X.jsx)(C,{color:`destructive`,children:n(`Expired`)});case bt.INACTIVE:return(0,X.jsx)(C,{color:`secondary`,children:n(`Inactive`)});case bt.HEALTHY:return(0,X.jsx)(C,{color:`info`,children:n(`Healthy`)});default:return(0,X.jsx)(C,{children:n(`Unknown`)})}},a=e=>e?oe({tDateTimeParser:r,t:n,format:`DD/MM/YYYY`,timestamp:e}):`-`;return(0,X.jsxs)(K,{children:[(0,X.jsx)(R,{children:(0,X.jsx)(w,{children:n(`Subscriptions`)})}),(0,X.jsx)(L,{children:(0,X.jsx)(`div`,{className:`space-y-6`,children:e.map((e,t)=>(0,X.jsxs)(`div`,{className:`border rounded-lg p-4`,children:[(0,X.jsxs)(`div`,{className:`flex justify-between items-start mb-4`,children:[(0,X.jsx)(`h3`,{className:`text-lg font-medium`,children:e.plan?.name?n(e.plan?.name):n(`Subscription`)}),i(e)]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mb-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`text-sm font-medium text-muted-foreground`,children:n(`Start Date`)}),(0,X.jsx)(`p`,{children:a(e.startDate)})]}),e.active&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`text-sm font-medium text-muted-foreground`,children:n(`End Date`)}),(0,X.jsx)(`p`,{children:a(e.endDate)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`text-sm font-medium text-muted-foreground`,children:n(`Period`)}),(0,X.jsx)(`p`,{children:e.plan?.sku!==`free`&&e.period?n(e.period):`-`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`text-sm font-medium text-muted-foreground`,children:n(`Price`)}),(0,X.jsx)(`p`,{children:e.actualPrice||`-`})]})]}),e.remainingDays!==void 0&&(0,X.jsxs)(`div`,{className:`mt-2`,children:[(0,X.jsx)(`h4`,{className:`text-sm font-medium text-muted-foreground`,children:n(`Remaining Days`)}),(0,X.jsx)(`p`,{children:e.remainingDays}),e.remainingPercentage!==void 0&&(0,X.jsx)(`div`,{className:`w-full bg-default-200 rounded-full h-2.5 mt-1`,children:(0,X.jsx)(`div`,{className:`bg-primary h-2.5 rounded-full`,style:{width:`${e.remainingPercentage}%`}})})]}),e.active&&(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(F,{className:`w-full`,asChild:!0,children:(0,X.jsx)(d,{to:`/pricing?upgrade=${e.id}&period=${e.period}`,children:n(`Upgrade Plan`)})})})]},e.id||t))})})]})},wo=e({config:()=>To,default:()=>Eo}),To={menu:{order:0,exclude:!0},title:D.name,loginRequired:!0};function Eo(){let{t:e}=W(),[t,n]=(0,Y.useState)(!0),[r,i]=(0,Y.useState)(null),a=h(),o=new URLSearchParams(a.search).get(`tab`),[s,c]=(0,Y.useState)(o||`profile`),{state:{subscriptions:l}}=pt();return(0,Y.useEffect)(()=>{(async()=>{try{let e=await ot();e&&i(e)}catch(e){console.error(`Failed to load user profile`,e)}finally{n(!1)}})()},[]),(0,Y.useEffect)(()=>{o&&[`profile`,`edit`,`subscriptions`].includes(o)&&c(o)},[o]),(0,X.jsxs)(`div`,{className:`container mx-auto py-6 max-w-4xl`,children:[(0,X.jsx)(`h1`,{className:`text-2xl font-bold mb-6`,children:e(`Account Settings`)}),(0,X.jsx)(K,{children:(0,X.jsx)(L,{className:`p-6`,children:(0,X.jsxs)(pe,{value:s,onValueChange:c,className:`w-full`,children:[(0,X.jsxs)(Ie,{className:`w-full mb-6`,children:[(0,X.jsx)(Be,{value:`profile`,className:`flex-1`,children:e(`Profile`)}),(0,X.jsx)(Be,{value:`edit`,className:`flex-1`,children:e(`Edit Profile`)}),(0,X.jsx)(Be,{value:`subscriptions`,className:`flex-1`,children:e(`Subscriptions`)})]}),(0,X.jsx)(ae,{value:`profile`,className:`mt-0`,children:(0,X.jsx)(bo,{user:r,isLoading:t})}),(0,X.jsx)(ae,{value:`edit`,className:`mt-0`,children:(0,X.jsx)(So,{userData:r,onSuccess:async()=>{try{let e=await ot();e&&i(e)}catch(e){console.error(`Failed to refresh user profile`,e)}}})}),(0,X.jsx)(ae,{value:`subscriptions`,className:`mt-0`,children:(0,X.jsx)(Co,{subscriptions:l,isLoading:t})})]})})})]})}var Do=e({config:()=>Oo,default:()=>jo}),Oo={menu:{order:0,exclude:!0},title:D.name},ko=Q.default.object({email:Q.default.string().email({tlds:{allow:!1}}).required().messages({"string.email":`
6Please enter a valid email address`,"string.empty":`Email is required`})}),Ao=Q.default.object({password:Q.default.string().min(8).required().messages({"string.min":`Password must be at least 8 characters`,"string.empty":`Password is required`}),confirmPassword:Q.default.string().required().valid(Q.default.ref(`password`)).messages({"any.only":`Passwords do not match`,"string.empty":`Confirm password is required`})});function jo(){let{t:e}=W(),t=i(),[n,r]=(0,Y.useState)(0),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(0),v=qe(`(max-width: 1530px)`),y=ri({resolver:si(ko),defaultValues:{email:``}}),b=ri({resolver:si(fo),defaultValues:{code:``}}),x=ri({resolver:si(Ao),defaultValues:{password:``,confirmPassword:``}});(0,Y.useEffect)(()=>{let e=localStorage.getItem(`forgotPasswordLastSent`);if(e){let t=parseInt(e,10),n=Math.floor((Date.now()-t)/1e3);n<900?_(900-n):localStorage.removeItem(`forgotPasswordLastSent`)}},[]),(0,Y.useEffect)(()=>{if(g<=0)return;let e=setInterval(()=>{_(t=>t<=1?(clearInterval(e),0):t-1)},1e3);return()=>clearInterval(e)},[g]);let C=async t=>{u(!0),p(null);try{if(await at(t.email)){o(t.email),h(e(`A verification code has been sent to your email`)),r(1);let n=Date.now();localStorage.setItem(`forgotPasswordLastSent`,n.toString()),_(900)}else p(e(`Failed to send verification code. Please try again.`))}catch{p(e(`An error occurred. Please try again.`))}finally{u(!1)}},T=async t=>{u(!0),p(null);try{await ht(t.code)?(c(t.code),h(e(`Code verified successfully. Please set your new password.`)),r(2)):p(e(`Invalid verification code. Please try again.`))}catch{p(e(`An error occurred. Please try again.`))}finally{u(!1)}},E=async n=>{u(!0),p(null);try{await tt(s,n.password),h(e(`Password reset successfully. You can now login with your new password.`)),r(3),setTimeout(()=>{t(`/login`)},3e3)}catch{p(e(`Failed to reset password. Please try again.`))}finally{u(!1)}},O=async()=>{if(a){u(!0),p(null);try{if(await at(a)){h(e(`A new verification code has been sent to your email`));let t=Date.now();localStorage.setItem(`forgotPasswordLastSent`,t.toString()),_(900)}else p(e(`Failed to resend verification code. Please try again.`))}catch{p(e(`An error occurred. Please try again.`))}finally{u(!1)}}};return(0,X.jsx)(`div`,{className:`absolute top-0 left-0 z-[60] w-screen h-screen`,children:(0,X.jsxs)(`div`,{className:`login-wrapper h-full flex justify-center items-center relative overflow-hidden`,children:[(0,X.jsx)(`img`,{src:`/images/auth/auth3-dark.png`,alt:`background image`,className:`absolute top-0 left-0 w-full h-full light:hidden`}),(0,X.jsx)(`img`,{src:`/images/auth/auth3-light.png`,alt:`background image`,className:`absolute top-0 left-0 w-full h-full dark:hidden`}),(0,X.jsx)(`div`,{className:`w-full bg-background py-5 max-w-xl rounded-xl relative z-10 2xl:p-16 xl:p-12 p-10 m-4`,children:(0,X.jsxs)(`div`,{className:`w-full`,children:[(0,X.jsx)(`div`,{className:`2xl:my-8 my-6 flex gap-4 items-center justify-center`,children:(0,X.jsxs)(d,{to:`/`,className:`inline-block`,children:[(0,X.jsx)(`img`,{src:`/images/logo.png`,alt:D.name,className:`dark:hidden`}),(0,X.jsx)(`img`,{src:`/images/logo-dark.png`,alt:D.name,className:`hidden dark:block`})]})}),(0,X.jsx)(w,{className:`text-center mb-6`,children:e(`Forgot Password`)}),(0,X.jsxs)(`div`,{className:`space-y-6`,children:[n!==3&&(0,X.jsxs)(ve,{current:n,className:`mb-6`,children:[(0,X.jsx)(S,{index:0,children:(0,X.jsx)(j,{children:e(`Email`)})}),(0,X.jsx)(S,{index:1,children:(0,X.jsx)(j,{children:e(`Verification`)})}),(0,X.jsx)(S,{index:2,children:(0,X.jsx)(j,{children:e(`New Password`)})})]}),f&&(0,X.jsx)(`div`,{className:`p-3 bg-destructive/10 border border-destructive rounded-md text-destructive text-sm`,children:f}),m&&(0,X.jsx)(`div`,{className:`p-3 bg-success/10 border border-success rounded-md text-success text-sm`,children:m}),n===0&&(0,X.jsx)(Ya,{...y,children:(0,X.jsxs)(`form`,{onSubmit:y.handleSubmit(C),className:`space-y-4`,children:[(0,X.jsx)(so,{control:y.control,name:`email`,label:e(`Email`),placeholder:e(`Enter your email address`),type:`email`,size:v?`lg`:`xl`,required:!0}),(0,X.jsxs)(F,{type:`submit`,className:`w-full`,disabled:l,size:v?`md`:`lg`,children:[l&&(0,X.jsx)(ar,{className:`ltr:mr-2 rtl:ml-2 h-4 w-4 animate-spin`}),e(l?`Sending...`:`Send Verification Code`)]})]})}),n===1&&(0,X.jsx)(Ya,{...b,children:(0,X.jsxs)(`form`,{onSubmit:b.handleSubmit(T),className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`text-sm font-medium`,children:e(`Verification Code`)}
6),(0,X.jsx)(io,{value:b.watch(`code`),onChange:e=>b.setValue(`code`,e,{shouldValidate:!0}),disabled:l}),b.formState.errors.code&&(0,X.jsx)(`p`,{className:`text-xs text-destructive mt-1`,children:e(b.formState.errors.code.message)})]}),(0,X.jsxs)(`div`,{className:`text-sm text-center`,children:[(0,X.jsx)(`span`,{children:e(`Didn't receive the code?`)}),` `,g>0?(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[e(`Resend available in`),` `,Ur(g)]}):(0,X.jsx)(`button`,{type:`button`,onClick:O,className:`text-primary hover:underline`,disabled:l||g>0,children:e(`Resend`)})]}),(0,X.jsxs)(`div`,{className:`flex justify-between`,children:[(0,X.jsx)(F,{type:`button`,variant:`ghost`,onClick:()=>r(0),disabled:l,children:e(`Back`)}),(0,X.jsxs)(F,{type:`submit`,disabled:l,size:v?`sm`:`md`,children:[l&&(0,X.jsx)(ar,{className:`ltr:mr-2 rtl:ml-2 h-4 w-4 animate-spin`}),e(l?`Verifying...`:`Verify Code`)]})]})]})}),n===2&&(0,X.jsx)(Ya,{...x,children:(0,X.jsxs)(`form`,{onSubmit:x.handleSubmit(E),className:`space-y-4`,children:[(0,X.jsx)(so,{control:x.control,name:`password`,label:e(`New Password`),type:`password`,placeholder:e(`Enter new password`),size:v?`lg`:`xl`,required:!0}),(0,X.jsx)(so,{control:x.control,name:`confirmPassword`,label:e(`Confirm Password`),type:`password`,placeholder:e(`Confirm new password`),size:v?`lg`:`xl`,required:!0}),(0,X.jsxs)(`div`,{className:`flex justify-between`,children:[(0,X.jsx)(F,{type:`button`,variant:`ghost`,onClick:()=>r(1),disabled:l,children:e(`Back`)}),(0,X.jsxs)(F,{type:`submit`,disabled:l,size:v?`sm`:`md`,children:[l&&(0,X.jsx)(ar,{className:`ltr:mr-2 rtl:ml-2 h-4 w-4 animate-spin`}),e(l?`Resetting...`:`Reset Password`)]})]})]})})]}),(0,X.jsx)(`div`,{className:`mt-6 text-center text-base text-default-600`,children:(0,X.jsx)(d,{to:`/login`,className:`text-primary`,children:e(`Back to Login`)})})]})})]})})}var Mo=e({config:()=>No,default:()=>Fo}),No={menu:{order:0,exclude:!0},title:D.name},Po=Q.default.object({name:Q.default.string().required().min(1).max(32).messages({"string.empty":`Name is required`,"string.min":`Name must be at least 1 character`,"string.max":`Name cannot exceed 32 characters`}),email:Q.default.string().required().email({tlds:!1}).max(254).messages({"string.empty":`Email is required`,"string.email":`Please enter a valid email address`,"string.max":`Email cannot exceed 254 characters`}),password:Q.default.string().required().min(8).max(128).pattern(RegExp(`^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])`)).messages({"string.empty":`Password is required`,"string.min":`Password must be at least 8 characters`,"string.max":`Password cannot exceed 128 characters`,"string.pattern.base":`Password must contain at least one uppercase letter, one lowercase letter, and one number`}),confirmPassword:Q.default.string().required().valid(Q.default.ref(`password`)).messages({"string.empty":`Please confirm your password`,"any.only":`Passwords do not match`}),agreeTerms:Q.default.boolean().valid(!0).required().messages({"any.only":`You must agree to the terms and conditions`})});function Fo(){let{t:e}=W(),[t,n]=(0,Y.useState)(!1),[r,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(0),u=i(),{state:{user:f},setToken:p}=pt(),m=qe(`(max-width: 1530px)`),h=ri({defaultValues:{name:``,email:``,password:``,confirmPassword:``,agreeTerms:!1},resolver:si(Po)}),g=ri({resolver:si(fo),defaultValues:{code:``}});(0,Y.useEffect)(()=>{f&&u(`/`)},[u,f]);let _=async t=>{n(!0),a(null),s(null);
6try{let n=await it({name:t.name,email:t.email,password:t.password});if(n.verify){l(1),s(e(`A verification code has been sent to your email`)),g.setValue(`code`,``,{shouldValidate:!0});return}if(typeof n.token==`string`&&n.token.trim().length>0){p(n.token),u(`/`);return}u(`/login`)}catch(t){if(t instanceof lt&&t.validationErrorData.length&&t.validationErrorData.some(e=>e.parameterName===`registration`)){a(e(`Too many registrations. Please try again later.`));return}Jr(t,h,a,e,{confirmPassword:`confirmPassword`,password:`new_password`,name:`name`,email:`email`,phone:`phone`,bio:`bio`,mood:`mood`,gender:`gender`})}finally{n(!1)}},v=async t=>{n(!0),a(null),s(null);try{let n=await $e(t.code);if(typeof n.token==`string`&&n.token.trim().length>0){p(n.token),u(`/`);return}a(e(`An error occurred. Please try again.`))}catch(t){t instanceof lt?a(e(`Invalid verification code. Please try again.`)):a(e(`An error occurred. Please try again.`))}finally{n(!1)}};return(0,X.jsx)(`div`,{className:`fixed inset-0 z-[60] overflow-y-auto`,children:(0,X.jsxs)(`div`,{className:`login-wrapper min-h-[100dvh] flex justify-center items-start sm:items-center relative overflow-hidden px-4 py-6 sm:py-10`,children:[(0,X.jsx)(`img`,{src:`/images/auth/auth3-dark.png`,alt:`background image`,className:`absolute inset-0 w-full h-full object-cover light:hidden`}),(0,X.jsx)(`img`,{src:`/images/auth/auth3-light.png`,alt:`background image`,className:`absolute inset-0 w-full h-full object-cover dark:hidden`}),(0,X.jsx)(`div`,{className:`w-full bg-background max-w-md sm:max-w-lg lg:max-w-xl rounded-xl relative z-10 p-6 sm:p-8 lg:p-10 2xl:p-12`,children:(0,X.jsxs)(`div`,{className:`w-full`,children:[(0,X.jsx)(`div`,{className:`my-6 sm:my-8 flex gap-4 items-center justify-center`,children:(0,X.jsxs)(d,{to:`/`,className:`inline-block`,children:[(0,X.jsx)(`img`,{src:`/images/logo.png`,alt:D.name,className:`dark:hidden h-10 sm:h-12 w-auto`}),(0,X.jsx)(`img`,{src:`/images/logo-dark.png`,alt:D.name,className:`hidden dark:block h-10 sm:h-12 w-auto`})]})}),(0,X.jsx)(`h2`,{className:`text-lg sm:text-xl font-bold mb-4 text-center`,children:e(c===0?`Create an Account`:`Verification`)}),r&&(0,X.jsx)(M,{color:`destructive`,className:`p-2 mb-4`,children:(0,X.jsx)(ye,{children:r})}),o&&(0,X.jsx)(M,{color:`success`,className:`p-2 mb-4`,children:(0,X.jsx)(ye,{children:o})}),c===0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ya,{...h,children:(0,X.jsxs)(`form`,{onSubmit:h.handleSubmit(_),className:`space-y-4`,children:[(0,X.jsx)(so,{control:h.control,name:`name`,label:e(`Name`),placeholder:e(`Enter your name`),size:m?`lg`:`xl`,required:!0,disabled:t,autoComplete:`name`,onValueChanged:()=>{a(null),s(null)}}),(0,X.jsx)(so,{control:h.control,name:`email`,label:e(`Email`),placeholder:e(`Enter your email`),type:`email`,size:m?`lg`:`xl`,required:!0,disabled:t,autoComplete:`email`,onValueChanged:()=>{a(null),s(null)}}),(0,X.jsx)(so,{control:h.control,name:`password`,label:e(`Password`),placeholder:e(`Create a password`),type:`password`,size:m?`lg`:`xl`,required:!0,help:e(`Password must be at least 8 characters`),disabled:t,autoComplete:`new-password`,onValueChanged:()=>{a(null),s(null)}}),(0,X.jsx)(so,{control:h.control,name:`confirmPassword`,label:e(`Confirm Password`),placeholder:e(`Confirm your password`),type:`password`,size:m?`lg`:`xl`,required:!0,disabled:t,autoComplete:`new-password`,onValueChanged:()=>{a(null),s(null)}}),(0,X.jsx)(lo,{control:h.control,name:`agreeTerms`,label:e(`I agree to the terms and conditions`),disabled:t}),(0,X.jsxs)(`div`,{className:`-mt-1 flex items-center justify-center gap-3 text-xs text-default-600`,children:[(0,X.jsx)(d,{to:`/terms`,className:`hover:text-primary transition-colors`,children:e(`Terms`)}),(0,X.jsx)(`span`,{className:`text-default-400`,children:`|`}),(0,X.jsx)(d,{to:`/privacy`,className:`hover:text-primary transition-colors`,children:e(`Privacy`)})]}),(0,X.jsxs)(F,{type:`submit`,className:`w-full`,disabled:t,size:m?`md`:`lg`,children:[t&&(0,X.jsx)(ar,{className:`ltr:mr-2 rtl:ml-2 h-4 w-4 animate-spin`}),e(t?`Creating Account...`:`Sign Up`)]})]})}),(0,X.jsxs)(`div`,{className:`mt-6 text-center text-base text-default-600`,children:[e(`Already have an account?`),` `,` `,(0,X.jsxs)(d,{to:`/login`,className:`text-primary`,children:[e(`Log in`),` `,` `]})]})]}):(0,X.jsx)(Ya,{...g,children:(0,X.jsxs)(`form`,{onSubmit:g.handleSubmit(v),className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`text-sm font-medium`,children:e(`Verification Code`)}
6),(0,X.jsx)(io,{value:g.watch(`code`),onChange:e=>{a(null),g.setValue(`code`,e,{shouldValidate:!0})},disabled:t}),g.formState.errors.code&&(0,X.jsx)(`p`,{className:`text-xs text-destructive mt-1`,children:e(g.formState.errors.code.message)})]}),(0,X.jsxs)(`div`,{className:`flex justify-between`,children:[(0,X.jsx)(F,{type:`button`,variant:`ghost`,onClick:()=>{a(null),s(null),l(0)},disabled:t,children:e(`Back`)}),(0,X.jsxs)(F,{type:`submit`,disabled:t,size:m?`sm`:`md`,children:[t&&(0,X.jsx)(ar,{className:`ltr:mr-2 rtl:ml-2 h-4 w-4 animate-spin`}),e(t?`Verifying...`:`Verify Code`)]})]})]})})]})})]})})}var Io=e({config:()=>Lo,default:()=>Ro}),Lo={menu:{order:0,exclude:!0},title:B(`Find the difference`)};function Ro(){return(0,X.jsx)(ti,{gameId:`find-difference`})}async function zo(e){return st.call(`DifferenceImageEndpoint`,`getImagesStatistics`,{},e)}var Bo=e({config:()=>Vo,default:()=>Uo}),Vo={menu:{order:0,exclude:!0},title:B(`Find the difference`),loginRequired:!0},Ho=({options:e,onOptions:t,onFilterServiceLevel:n})=>{let[r,i]=(0,Y.useState)([]),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(null),{t:p}=W(),{hasServiceLevel:m}=pt(),h=(0,Y.useMemo)(()=>{let e=[...Yr.slice(1)];return e[0].label=p(e[0].label),e},[]),g=(0,Y.useMemo)(()=>!m(xt.PRO,xt.ULTIMATE),[m]),_=(0,Y.useMemo)(()=>!m(xt.ULTIMATE),[m]);(0,Y.useEffect)(()=>{mt().then(e=>{i(e)}),zo().then(e=>{f(e)})},[]);let v=n=>()=>{let r=e.packs||[];if(r?.includes(n.id)){let e=r.indexOf(n.id);r.splice(e,1)}else r.push(n.id);t({...e,packs:r})},b=()=>{g||c(e=>!e)},x=()=>{g||o(e=>!e)},S=()=>{g||u(e=>!e)},O=n=>()=>{let r=e.sizes||[];if(r?.includes(n)){let e=r.indexOf(n);r.splice(e,1)}else r.push(n);t({...e,sizes:r})},k=n=>{t({...e,randomize:n})},A=n=>{t({...e,competitionMode:n})},j=n=>{_||t({...e,count:Number(n)})},M=e=>!d||!d.packStatistics||!d.packStatistics.countByPack?0:d.packStatistics.countByPack[e]||0,N=e=>!d||!d.detailedPackStatistics||!d.detailedPackStatistics.detailedStats?{}:d.detailedPackStatistics.detailedStats[e]||{};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 animate-fadeIn p-3 mb-5`,children:[(0,X.jsxs)(K,{className:q(`bg-card/80 border-primary/20 shadow-lg`,g&&`bg-muted/80`),children:[(0,X.jsxs)(R,{className:q(`pb-2 flex flex-row justify-between gap-2`,!g&&`cursor-pointer`),onClick:x,children:[(0,X.jsxs)(w,{className:`flex-1 flex items-center gap-2 text-lg`,children:[(0,X.jsx)(wn,{className:q(`h-6 w-6`,g?`text-muted-foreground`:`text-primary animate-pulse`)}),(0,X.jsx)(`span`,{className:q(g&&`text-muted-foreground`),children:p(`Select Difficulty Level`)})]}),g?(0,X.jsx)(`div`,{className:`bg-muted-foreground/20 text-muted-foreground text-xs px-2 py-1 rounded-md`,children:p(`Premium Feature`)}):a?(0,X.jsx)(tr,{className:`w-4 h-4`}):(0,X.jsx)(Cr,{className:`w-4 h-4`})]}),a&&(0,X.jsx)(L,{className:`p-2`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-3`,children:h.map(t=>(0,X.jsxs)(F,{className:q(`flex items-center justify-center font-philosopher text-xs transition-all duration-300 transform hover:scale-105`,e.sizes?.includes(Number(t.value))?`bg-primary text-primary-foreground shadow-md`:`text-muted-foreground`),color:e.sizes?.includes(Number(t.value))?`primary`:`secondary`,variant:e.sizes?.includes(Number(t.value))?`default`:`ghost`,size:`sm`,onClick:O(Number(t.value)),children:[e.sizes?.includes(Number(t.value))&&(0,X.jsx)(yn,{className:`h-3 w-3 mr-1 rtl:ml-1 rtl:mr-0 animate-pulse`}),p(t.label)]},t.value))})})]}),(0,X.jsxs)(K,{className:q(`bg-card/80 border-primary/20 shadow-lg`,g&&`bg-muted/80`),children:[(0,X.jsxs)(R,{className:q(`pb-2 flex flex-row justify-between gap-2`,!g&&`cursor-pointer`),onClick:b,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 text-lg`,children:[(0,X.jsx)(yn,{className:q(`h-6 w-6`,g?`text-muted-foreground`:`text-primary animate-pulse`)}),(0,X.jsx)(`span`,{className:q(g&&`text-muted-foreground`),children:p(`Select Image Packs`)})]}),g?(0,X.jsx)(`div`,{className:`bg-muted-foreground/20 text-muted-foreground text-xs px-2 py-1 rounded-md`,children:p(`Premium Feature`)}):s?(0,X.jsx)(tr,{className:`w-4 h-4`}):(0,X.jsx)(Cr,{className:`w-4 h-4`})]}),s&&(0,X.jsxs)(L,{children:[(0,X.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 md:grid-cols-3 lg:grid-cols-3 gap-4`,children:r.map(t=>(0,X.jsxs)(`div`,{className:q(`relative flex flex-col gap-2 cursor-pointer select-none rounded-md p-3 border transition-all duration-300 hover:shadow-md transform hover:scale-105`,e.packs?.includes(t.id)?`border-primary bg-primary/10 dark:bg-primary/20`:`border-border bg-card`),onClick:v(t),children:[e.packs?.includes(t.id)&&(0,X.jsx)(yn,{className:`h-4 w-4 text-primary animate-pulse absolute top-2 ltr:right-2 rtl:left-2`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 `,children:[(0,X.jsx)(`div`,{className:`flex justify-between items-center`,children:(0,X.jsx)(`span`,{className:`font-bold text-sm`,children:p(t.name)})}),(0,X.jsx)(`div`,{className:`relative overflow-hidden rounded-md aspect-square`,children:(0,X.jsx)(`img`,{className:`w-full h-full object-cover transition-transform duration-500 hover:scale-110`,loading:`lazy`,alt:p(t.name),src:`${D.host}/games/difference/pack/${t.id}/cover.png`})}),(0,X.jsxs)(`div`,{className:`flex justify-center items-center gap-2`,children:[(0,X.jsx)(Wn,{className:`h-4 w-4`}),(0,X.jsx)(C,{variant:`outline`,className:`text-xs`,children:M(t.id)})]})]})]},t.id))}),r.length===0&&(0,X.jsx)(`div`,{className:`text-center py-8 text-muted-foreground`,children:p(`No packs match the search criteria`)})]})]}),(0,X.jsxs)(K,{className:q(`bg-card/80 border-primary/20 shadow-lg`,g&&`bg-muted/80`),children:[(0,X.jsxs)(R,{className:q(`pb-2 flex flex-row justify-between gap-2`,!g&&`cursor-pointer`),onClick:S,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 text-lg`,children:[(0,X.jsx)(vn,{className:q(`h-6 w-6`,g?`text-muted-foreground`:`text-primary animate-pulse`)}),(0,X.jsx)(`span`,{className:q(g&&`text-muted-foreground`),children:p(`Pack Statistics`)})]}
6),g?(0,X.jsx)(`div`,{className:`bg-muted-foreground/20 text-muted-foreground text-xs px-2 py-1 rounded-md`,children:p(`Premium Feature`)}):l?(0,X.jsx)(tr,{className:`w-4 h-4`}):(0,X.jsx)(Cr,{className:`w-4 h-4`})]}),l&&d&&(0,X.jsx)(L,{children:(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(`div`,{className:`bg-primary/5 p-3 rounded-md`,children:(0,X.jsxs)(`h3`,{className:`font-semibold`,children:[p(`Total Images`),`: `,d.totalImages]})}),(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(`h3`,{className:`font-semibold`,children:p(`Images by Pack`)}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:r.map(e=>{let t=N(e.id),n=M(e.id);return(0,X.jsxs)(`div`,{className:`bg-card border rounded-md p-3`,children:[(0,X.jsxs)(`div`,{className:`flex justify-between items-center mb-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:p(e.name)}),(0,X.jsx)(C,{variant:`outline`,children:n})]}),Object.entries(t).length>0&&(0,X.jsxs)(`div`,{className:`space-y-1 mt-2`,children:[(0,X.jsx)(`h4`,{className:`text-xs text-muted-foreground mb-1`,children:p(`By Difficulty`)}),(0,X.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-1 text-xs`,children:Object.entries(t).map(([e,t])=>(0,X.jsxs)(`div`,{className:`flex flex-col items-center bg-muted/30 p-1 rounded`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(C,{variant:`outline`,className:`text-xs`,children:t})]},e))})]})]},e.id)})})]}),d.difficultyStatistics&&d.difficultyStatistics.countByDifficulty&&(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(`h3`,{className:`font-semibold`,children:p(`Images by Difficulty`)}),(0,X.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-2`,children:Object.entries(d.difficultyStatistics.countByDifficulty).map(([e,t])=>(0,X.jsxs)(`div`,{className:`bg-card border rounded-md p-2 flex flex-col items-center`,children:[(0,X.jsxs)(`span`,{children:[p(`Difficulty`),` `,e]}),(0,X.jsx)(C,{variant:`outline`,children:t})]},e))})]})]})})]}),(0,X.jsx)(`div`,{className:`mt-4 flex items-center`,children:(0,X.jsx)(Ve,{id:`randomize-images`,checked:e.randomize||!1,onCheckedChange:k,lineThrough:!1,disabled:g,children:p(`Randomize images`)})}),(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.randomize?p(`Images will be shuffled randomly`):p(`Images will be ordered by difficulty (easiest to hardest)`)}),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`mb-3`,children:[(0,X.jsx)(ue,{className:`mb-2`,children:p(`Competition Mode`)}),(0,X.jsxs)(ne,{value:e.competitionMode||`INDIVIDUAL`,onValueChange:A,className:`flex gap-2`,orientation:`vertical`,disabled:_,children:[(0,X.jsx)(T,{value:`INDIVIDUAL`,children:p(`Individual`)}),(0,X.jsx)(T,{value:`TEAM`,children:p(`Team`)})]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(ue,{className:`mb-2`,children:p(`Number of Images`)}),(0,X.jsxs)(P,{value:`${e.count||50}`,onValueChange:j,disabled:_,children:[(0,X.jsx)(z,{children:(0,X.jsx)(E,{placeholder:p(`Select Number of Images`)})}),(0,X.jsx)(He,{children:[10,20,30,40,50].map(e=>(0,X.jsx)(y,{value:String(e),children:e},e))})]})]}),!g&&_&&(0,X.jsx)(F,{color:`primary`,className:`animate-pulse`,size:`sm`,onClick:()=>n(xt.ULTIMATE),children:p(`Upgrade Now`)})]}),g&&(0,X.jsxs)(`div`,{className:`bg-primary/5 border border-primary/10 rounded-lg p-4`,children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold mb-2`,children:p(`Premium Features`)}),(0,X.jsx)(`p`,{className:`text-muted-foreground mb-3`,children:p(`These features are exclusively available for "PRO" and "ULTIMATE" plans`)}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 mb-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(yn,{className:`h-4 w-4 text-primary`}),(0,X.jsx)(`span`,{children:p(`Customize difficulty levels`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(yn,{className:`h-4 w-4 text-primary`}),(0,X.jsx)(`span`,{children:p(`Select specific image packs`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(yn,{className:`h-4 w-4 text-primary`}),(0,X.jsx)(`span`,{children:p(`Randomize images`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(yn,{className:`h-4 w-4 text-primary`}),(0,X.jsx)(`span`,{children:p(`View detailed pack statistics`)})]})]}),(0,X.jsx)(F,{color:`primary`,className:`animate-pulse`,size:`sm`,onClick:()=>n(xt.PRO,xt.ULTIMATE),children:p(`Upgrade Now`)})]})]})};function Uo(){return(0,X.jsx)(ui,{gameId:`find-difference`,linkPrefix:`d`,title:`Find the difference`,checkLimits:!0,GameCreateForm:Ho})}var Wo=Xe(1500),Go=Xe(1e3),Ko=({ref:e,width:t,height:n,box:r=`content-box`,resize:i,disabled:a=!1})=>{let[o,s]=(0,Y.useState)({width:t,height:n,prevWindowWidth:t,prevWindowHeight:n,gameWidth:t,gameHeight:n}),c=Ge();(0,Y.useEffect)(()=>
6{if(!e.current||a)return;let t=new ResizeObserver(([e])=>{let t=r===`border-box`?`borderBoxSize`:r===`device-pixel-content-box`?`devicePixelContentBoxSize`:`contentBoxSize`,n=qo(e,t,`inlineSize`),i=qo(e,t,`blockSize`);u(n||0,i||0)});return t.observe(e.current,{box:r}),()=>{t.disconnect()}},[r,e,a]);let l=(0,Y.useCallback)((e,t)=>{a||s(n=>{let r,a;return t<e?(a=t,r=t/t*e):(r=e,a=e/e*t),c()&&i(r,a),{...n,prevWindowWidth:e,prevWindowHeight:t,gameWidth:r,gameHeight:a}})},[i,c,a]),u=(0,Y.useCallback)((e,t)=>{a||(o.prevWindowWidth!==e||o.prevWindowHeight!==t)&&(l(e,t),window.scrollTo(0,0))},[l,o.prevWindowWidth,o.prevWindowHeight,a]);return{config:o}};function qo(e,t,n){return e[t]?Array.isArray(e[t])?e[t][0][n]:e[t][n]:t===`contentBoxSize`?e.contentRect[n===`inlineSize`?`width`:`height`]:void 0}var Jo=Xe(!1),Yo=e=>{Jo.value=e};function Xo(){return Jo.value}var Zo=(e,t)=>{if(!t)return new Image;let n=document.createElement(`canvas`);n.width=t.width,n.height=t.height;let r=n.getContext(`2d`);if(!r)throw Error(`Could not get canvas context`);r.drawImage(e,t.x,t.y,t.width,t.height,0,0,t.width,t.height);let i=new Image;return i.src=n.toDataURL(),i.width=t.width,i.height=t.height,i},Qo=async(e,t,n)=>{let r=await fetch(e,{signal:n});if(!r.ok)throw Error(`Failed to load image: ${r.statusText}`);let i=r.headers.get(`Content-Length`),a=i?parseInt(i,10):0,o=0,s=r.body?.getReader();if(!s){let e=await r.blob();t(100);let n=new Image;return n.src=URL.createObjectURL(e),await n.decode(),n}let c=[];for(;;){let{done:e,value:n}=await s.read();if(e)break;n&&(c.push(n),o+=n.length,a>0&&t(o/a*100))}let l=new Blob(c),u=new Image;return u.src=URL.createObjectURL(l),await u.decode(),u},$o=async(e,t,n)=>{let r=async e=>{if(!(e.complete&&e.naturalWidth>0)){if(typeof e.decode==`function`)try{await e.decode();return}catch{}await new Promise((t,n)=>{let r=()=>{a(),t()},i=()=>{a(),n(Error(`Failed to decode image`))},a=()=>{e.removeEventListener(`load`,r),e.removeEventListener(`error`,i)};e.addEventListener(`load`,r),e.addEventListener(`error`,i)})}};await r(e);let i=document.createElement(`canvas`);i.width=e.width,i.height=e.height;let a=i.getContext(`2d`);if(!a)return e;a.drawImage(e,0,0,e.width,e.height);for(let e of t.differences??[]){let t=n[`${e.name}.png`];if(!t)continue;await r(t);let i=e.rect[2]>0?e.rect[2]:t.width,o=e.rect[3]>0?e.rect[3]:t.height;a.drawImage(t,e.rect[0],e.rect[1],i,o)}let o=new Image;return o.src=i.toDataURL(`image/webp`,.95),await o.decode(),o},es=new Map,ts=new Map,ns=()=>{let[e,t]=(0,Y.useState)({}),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(0),[o,s]=(0,Y.useState)(0),[c,l]=(0,Y.useState)(0),u=Xo(),d=(0,Y.useRef)(null),f=(0,Y.useRef)(null),p=(0,Y.useCallback)(async(e,n)=>{if(!e)return{images:{},dimensions:null};let i=`${e.machineName}`;for(let e of es.keys())e!==i&&(es.delete(e),ts.delete(e));if(es.has(i)){let e=es.get(i),n=Object.keys(e).length;return t(e),l(n),s(n),a(100),Yo(!1),{images:e,dimensions:e.base1?{width:e.base1.width,height:e.base1.height}:null,success:!0,loadedCount:n,totalCount:n}}r(null),a(0),s(0);let o=`${Date.now()}-${Math.random()}`;f.current=o,d.current&&d.current.abort(),d.current=new AbortController;let c=d.current.signal;Yo(!0),r(null),a(5);let u=`${n}/games/difference/assets/${e.machineName}`,p=null,m={};try{a(5);let n;if(ts.has(i))n=ts.get(i);else{let e=`${u}/data.json`,t=await fetch(e,{signal:c});if(!t.ok)throw Error(`Failed to load atlas data: ${t.statusText}`);n=await t.json(),ts.set(i,n)}if(c.aborted||f.current!==o)throw Error(`Operation was aborted or superseded`);a(10);let r=await Qo(`${u}/base.webp`,e=>{if(!c.aborted&&f.current===o){let t=10+e*.85;a(Math.round(t))}},c);if(c.aborted||f.current!==o)throw Error(`Operation was aborted or superseded`);n[`base.png`]&&(m.base1=Zo(r,n[`base.png`]),m.base2=Zo(r,n[`base.png`]),p={width:m.base1.width,height:m.base1.height});for(let e in n)e!==`base.png`&&(m[e]=Zo(r,n[e]));m.base2&&e.differences&&e.differences.length>0&&(m.base2=await $o(m.base2,e,m));let d=Object.keys(m).length;if(l(d),s(d),a(100),c.aborted||f.current!==o)throw Error(`Operation was aborted or superseded`);return es.set(i,m),t(m),{images:m,dimensions:p,success:!0,loadedCount:d,totalCount:d}}catch(e){if(f.current!==o||e instanceof Error&&(e.message===`Operation was aborted`||e.message===`Operation was aborted or superseded`))return{images:{},dimensions:null,success:!1};let t=e instanceof Error?e.message:`Unknown error during image loading`;return console.error(`Error loading images:`,e),r(t),a(0),s(0),{images:{},dimensions:null,error:t,success:!1}}finally{f.current===o&&!c.aborted&&Yo(!1)}},[e]),m=(0,Y.useCallback)(()=>{f.current=null,d.current&&=(d.current.abort(),null),t({}),r(null),Yo(!1),a(0),s(0),l(0)},[]);return(0,Y.useEffect)(()=>()=>{d.current&&d.current.abort()},[]),{images:e,loading:u,error:n,progress:i,loadedCount:o,totalCount:c,preloadImages:p,clearImages:m}},rs=window.innerWidth,is=window.innerHeight,as={width:rs,height:is,gameWidth:rs,gameHeight:is,prevWindowWidth:rs,prevWindowHeight:is},os={width:rs,height:is,zoomMin:.5,betweenPictures:0,picWidth:0,currentScale:.6,pic1:{x:0,y:0,width:0,height:0},pic2:{x:0,y:0,width:0,height:0}},ss=(e=[],t=[])=>{if(t.length===0)return e;let n=[...e],r=new Map;for(let e=0;e<n.length;e++)r.set(n[e].id,e);for(let e of t){let t=r.get(e.id);if(t===void 0){r.set(e.id,n.length),n.push(e);continue}n[t]={...n[t],...e}}return n},cs=e=>{let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)([]),[a,o]=(0,Y.useState)(os),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),d=(0,Y.useRef)(null),f=(0,Y.useRef)(null),p=(0,Y.useRef)(null),m=(0,Y.useRef)({width:0,height:0}),{session:h,player:g,players:_,debug:v,subscriptionClient:y,sendEvent:b,onSession:x,isHeaderVisible:S,logger:C}=J(),w=(0,Y.useMemo)(()=>h?.data,[h?.data]),T=(0,Y.useCallback)(()=>{b(`END_TURN`)},[]),{time:E,start:O,pause:k,reset:A}=hi({mode:`countdown`,initialSeconds:w?.time?w?.time:60,onComplete:T}),{error:j,images:M,loading:N,progress:P,loadedCount:F,totalCount:I,preloadImages:L,clearImages:ee}=ns(),R=(0,Y.useCallback)((e,t)=>{b(e,t)},[]),te=(0,Y.useCallback)((e,t,n=28)=>{let r=m.current.width||Wo.value,i=m.current.height||Go.value,a={width:e,height:t,zoomMin:.5,betweenPictures:0,picWidth:0,currentScale:.6,pic1:{x:0,y:0,width:0,height:0},pic2:{x:0,y:0,width:0,height:0}};if(r===0||i===0)return a;let o=S?n:0,s=Math.max(8,Math.min(20,e*.02)),c=Math.max(0,e-s*2),l=Math.max(0,t-o-20);if(c===0||l===0)return a;let u=Math.max(10,Math.min(24,Math.min(c,l)*.04)),d=1.5,f=Math.min((c-u)/2/r,l/i,d),p=Math.min(c/r,(l-u)/2/i,d),h=f>=p,g=Math.max(.1,h?f:p),_=r*g,v=i*g,y=o+10;if(h){let e=_*2+u,t=v,n=s+(c-e)/2,r=y+(l-t)/2;a.pic1.x=n,a.pic1.y=r,a.pic2.x=n+_+u,a.pic2.y=r,a.betweenPictures=u}else{let e=_,t=v*2+u,n=s+(c-e)/2,r=y+(l-t)/2;a.pic1.x=n,a.pic1.y=r,a.pic2.x=n,a.pic2.y=r+v+u,a.betweenPictures=u}return a.currentScale=g,a.zoomMin=g,a.pic1.width=_,a.pic1.height=v,a.pic2.width=_,a.pic2.height=v,a.picWidth=h?a.pic2.x+a.pic2.width-a.pic1.x:a.pic1.width,a},[S]),z=(0,Y.useCallback)((e,t)=>{if(e<=0||t<=0)return;let n=p.current;n&&n.width===e&&n.height===t||(p.current={width:e,height:t},f.current&&cancelAnimationFrame(f.current),f.current=requestAnimationFrame(()=>{let n=te(e,t);o(n),f.current=null}))},[te]),{config:B}=Ko({ref:e,resize:z,width:as.width,height:as.height,disabled:w?.showScore}),ne=(0,Y.useRef)(B);(0,Y.useEffect)(()=>{ne.current=B},[B]),(0,Y.useEffect)(()=>{!N&&M.base1&&B&&z(B.gameWidth,B.gameHeight)},[N,M.base1,M.base2,z,B]),(0,Y.useEffect)(()=>{B&&z(B.gameWidth,B.gameHeight)},[S,B,z]);let re=(0,Y.useCallback)(e=>{let t=e;switch(t.type){case`NEW_GAME`:t.image?(A(w?.time??60),c(!1),n([]),i([]),x(e=>({...e,data:{...e.data,index:t.index,image:t.image,startTime:-1,round:t.round,playing:!1}}))):t.endGame&&(u(!0),k(),c(!1),x(e=>({...e,data:{...e.data,endGame:!0,playing:!1}})));break;case`START`:c(!1),A(w?.time??60),O(),t.startGame?t.image&&t.image.id!==w?.image?.id?x(e=>({...e,data:{...e.data,image:t.image,startTime:t.startTime,round:t.round,playing:!0}})):x(e=>({...e,data:{...e.data,startTime:t.startTime,round:t.round,playing:!0}})):x(e=>({...e,data:{...e.data,initialized:!0,teams:t.teams}}));break;case`STOP`:x(e=>({...e,data:{...e.data,startTime:t.startTime,playing:!1}})),k(),c(!1);break;case`FOUND`:x(e=>{let n={},r=e.data;return t.data&&Object.assign(n,t.data),t.teams&&(n.teams=ss(r?.teams??[],t.teams)),Object.keys(n).length===0?e:{...e,data:{...e.data,...n}}})}if((g.id===t.player?.id||t.endGame)&&(t.endGame&&k(),t.wrong)){if(t.player?.lives<=0){d.current&&clearTimeout(d.current),c(!0);return}c(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{t.player?.lives>0&&c(!1)},300)}},[w]);(0,Y.useEffect)(()=>{let e=w?.time??60;if(w?.startTime!==void 0&&w?.startTime!==-1){let t=Math.floor((w?.startTime+e*1e3-Date.now())/1e3);t>0&&(A(t),O())}else A(e);return y.on([`NEW_GAME`,`START`,`STOP`,`WRONG`,`FOUND`],re),()=>y.off([`NEW_GAME`,`START`,`STOP`,`WRONG`,`FOUND`],re)},[w.image]);let ie=(0,Y.useRef)(ee),ae=(0,Y.useRef)(L);(0,Y.useEffect)(()=>{ie.current=ee,ae.current=L},[ee,L]);let oe=(0,Y.useCallback)(async()=>{try{ie.current(),R(`READY`,{ready:!1});let t=await ae.current(w.image,D.host_static);if(t.error||!t.success){C(`error`,`Error loading images: ${t.error||`Not all images loaded successfully`}`,{tags:[`event`,`client`]});return}if(t.success&&t.loadedCount===t.totalCount&&R(`READY`,{ready:!0}),t.dimensions&&(m.current=t.dimensions,Wo.value=t.dimensions.width,Go.value=t.dimensions.height,requestAnimationFrame(()=>{let t=e.current?.getBoundingClientRect(),n=ne.current?.gameWidth??window.innerWidth,r=ne.current?.gameHeight??window.innerHeight,i=Math.floor(t?.width??n),a=Math.floor(t?.height??r),s=te(i,a);o(s)}
6),w.image.version!==1&&w.image.differences)){let e=w.image.differences.map(e=>({completed:!1,...e}));n(e)}}catch(e){C(`error`,`Error loading images: ${e}`,{tags:[`event`,`client`]})}},[w?.image]),se=(0,Y.useCallback)(()=>{w?.image&&setTimeout(()=>{oe()},50)},[w?.image]);(0,Y.useEffect)(()=>{if(w?.image)try{se()}catch(e){C(`error`,`Error loading images: ${e}`,{tags:[`event`,`client`]})}},[w?.image]),(0,Y.useEffect)(()=>{if(w.image&&w.image.frames){let e=new Set,t=new Map,n=w?.competitionMode===`TEAM`,r=n?_.filter(e=>e.teamId===g.teamId):[],a=n?r.map(e=>({round:e.round,name:e.name})):[{round:g?.round,name:g?.name}];for(let r of a){let i=r.round;if(i?.data)for(let a of i.data.split(`,`)){let i=a.trim();i.length>0&&(e.add(i),n&&!t.has(i)&&t.set(i,r.name||`Unknown`))}}let o=n?r.some(e=>e.finish):!1,s=w.image.frames.map((r,i)=>({completed:e.has(String(i)),foundBy:n?t.get(String(i)):void 0,debug:w.playing&&(v||g.debug),mark:n?o:g.finish,...r}));i(s)}},[w.image,w.playing,w?.competitionMode,g?.round,g.teamId,g.finish,g.debug,_,v]);let ce=(0,Y.useCallback)(e=>{i(t=>t.map(t=>(t===e&&(t.completed=!0),t)))},[]),le=(0,Y.useCallback)(()=>{i(e=>e.map(e=>(e.completed||(e.mark=!0,e.debug=!1),e)))},[]);return{ref:e,error:j,image:w?.image,images:M,differences:t,frames:r,size:a,wrong:s,playing:w?.playing,time:E,showScore:w?.showScore,showPlayers:w.showPlayers,mode:w.mode,loadingImages:N,endGame:l||w?.endGame,loadingProgress:P,loadedCount:F,totalCount:I,sendEvent:R,onMark:ce,onMarkAll:le,retryLoadImages:se}},ls=()=>{let{t:e,userLanguage:t}=W(),{player:n}=J(),[r,i]=(0,Y.useState)(!0),a=(0,Y.useMemo)(()=>{if(t===`ar`){let e=[`ما شاء الله، لو انك محقق جان حليت كل الجرائم! 🕵️‍♂️🔎`,`عينك ليزر، حتى الغبار تشوفه! 👀💥`,`إنت تشوف اللي حتى الصورة مو مستوعبته! 🤯`,`مبروك، الحين عيونك رسميًا عليها تأمين! 🔐😂`,`إنت مو عادي، أكيد تدربت عند شيرلوك هولمز! 🕶🔍`,`ماكو فايدة، حتى الجن ما تقدر تخش عليك! 👻🤣`,`إنت سريع لدرجة إن الصورة توها تستوعب إنك فزت! 🏃‍♂️`,`لو في بطولة عالمية للاختلافات، كان اسمك محفور بالكأس! 🏆🔥`,`إنت مو بشر، إنت رادار كشف الاختلافات! 📡😂`,`عيونك HD، حتى الذبانه تحسدك على دقتك! 👀🎯`,`الاختلاف كان يبي ينخش، بس انتهى مكشوف! 🤭`,`الاختلاف كان يبي ينخش، ي حلوك طلعت قوي! 🤭`,`يباااااااااه! حتى الصورة استحت منك! 😳😂`,`بسرعتك هذي، لو تدخل سباق مع الضوء، الضوء يستسلم! ⚡🤣`,`إنت تعرف الاختلاف حتى قبل لا يحطونه بالصورة! 😆🔍`,`اللعبة للحين مصدومة، ما توقعت أحد يصيد الاختلاف بهالسرعة! 😱😂`,`الاختلاف كان يبي يشرد، بس عيونك ماسكة عليه 4K! 🔎🎥`,`الاختلاف كان يبي يشرد، بس عيونك ماسكة عليه سكوب 8! 🔎🎥`,`حتى لو يخفون الاختلاف تحت الزولية، بتشوفه! 😆😂`,`الحكومة تفكر توظفك بقسم كشف الغش! 🕵️‍♂️😜`,`االي ضدك رفع الراية البيضاء، استسلم خلاص! 🚩🤣`,`ما شاء الله عليك، الصورة تحسسك داخلها مو بس تشوفها! 📸🔥`];return e[Math.floor(Math.random()*e.length)]}return``},[t]);return r?(0,X.jsxs)(K,{className:`z-40 w-full sm:w-8/12 bg-card/70 relative`,children:[(0,X.jsx)(F,{variant:`ghost`,color:`secondary`,size:`icon`,className:`absolute right-2 top-2 bg-secondary text-muted hover:text-muted-foreground bg-default-500/50 hover:bg-default-300/50  dark:bg-default-500/50  dark:hover:bg-default-300/50`,onClick:()=>i(!1),children:(0,X.jsx)(Ut,{className:`h-4 w-4`})}),(0,X.jsxs)(L,{className:`flex flex-col items-center gap-2 p-5 text-center`,children:[(0,X.jsx)(`div`,{className:`text-3xl`,children:e(`Congratulations`)}),(0,X.jsx)(`div`,{className:`text-2xl font-bold text-slate-800 dark:text-slate-100`,children:a}
6),(0,X.jsx)(`img`,{src:`https://fonts.gstatic.com/s/e/notoemoji/latest/1f973/512.gif`,alt:`🥳`,width:`150`,height:`150`,style:{display:`block`}}),(0,X.jsx)(`div`,{className:`text-xl text-orange-700 dark:text-orange-400`,children:n?.name}),(0,X.jsx)(`div`,{className:`mt-5`,children:e(`Score`)}),(0,X.jsx)(C,{className:`text-3xl`,children:n?.score})]})]}):null},us=t(Ke(),1),ds=(0,Y.forwardRef)((e,t)=>{let{image:n,onWrong:r,wrong:i,waiting:a,loading:o,size:s}=e;return(0,X.jsx)(`img`,{ref:t,onClick:r,src:n.src,className:q(`rounded`,{grayscale:i||a,"blur-xl":a,"opacity-0":o}),draggable:!1,style:{pointerEvents:i?`none`:`auto`,top:s.y,left:s.x,width:s.width,height:s.height,position:`absolute`}})}),fs=Y.memo(ds,(e,t)=>e.image.src===t.image.src&&(0,us.default)(e.size,t.size)&&e.waiting===t.waiting&&e.loading===t.loading&&e.onWrong===t.onWrong&&e.wrong===t.wrong);function ps(e,t,n,r,i,a,o=!0){if(!o)return{x:e,y:t,width:n,height:r};let s=e,c=t;return c<0&&(c=0),c+r>a&&(c=a-r),s<0&&(s=0),s+n>i&&(s=i-n),{x:s,y:c,width:n,height:r}}var ms=({layer:e,pic:t,image:n,currentScale:r,mode:i,onFound:a})=>{if(!n)return;let o=ps(e.rect[0],e.rect[1],e.rect[2]>0?e.rect[2]:n.width,e.rect[3]>0?e.rect[3]:n.height,t.width/r,t.height/r,!1);if(!(i&&!e.completed&&!e.mark&&!e.debug))return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`img`,{className:q(`opacity-0`,e.debug&&`opacity-50`,(e.completed||e.mark)&&`opacity-100`),onClick:()=>a(e),draggable:!1,style:{willChange:e.completed||!e.mark&&!e.debug?void 0:`filter`,filter:e.completed||!e.mark&&!e.debug?void 0:`hue-rotate(245deg) saturate(8)`,top:t.y+o.y*r,left:t.x+o.x*r,width:o.width*r,height:o.height*r,position:`absolute`},src:n.src}),e.completed&&e.foundBy&&(0,X.jsx)(`div`,{className:`absolute z-40 px-1.5 py-0.5 text-[10px] leading-none rounded bg-black/70 text-white pointer-events-none whitespace-nowrap -translate-x-1/2 -translate-y-1/2`,style:{to
6p:t.y+(o.y+o.height/2)*r,left:t.x+(o.x+o.width/2)*r},children:e.foundBy})]})},hs=({progress:e=0,loadedCount:t=0,totalCount:n=0})=>{let{t:r}=W();return(0,X.jsxs)(`div`,{role:`status`,className:`w-full sm:w-8/12 space-y-8 z-40 animate-pulse md:space-y-0 md:space-x-8 rtl:space-x-reverse md:flex md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center w-full h-[440px] bg-gray-300 rounded dark:bg-gray-700 relative p-8`,children:[(0,X.jsx)(ar,{className:`w-12 h-12 text-gray-500 dark:text-gray-400 animate-spin mb-6`}),(0,X.jsxs)(`div`,{className:`text-center space-y-4 mb-6`,children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold text-gray-700 dark:text-gray-300`,children:r(`Loading Images`)}),(0,X.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:r(`Please wait while we load the game images...`)})]}),(0,X.jsxs)(`div`,{className:`w-full max-w-md space-y-2`,children:[(0,X.jsx)(ke,{value:e,color:`primary`,size:`md`,showValue:!0,customContent:`${Math.round(e)}%`,className:`w-full`}),(0,X.jsx)(`div`,{className:`text-center`,children:(0,X.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[r(`Loading progress`),`: `,Math.round(e),`%`,n>0&&(0,X.jsxs)(`span`,{className:`ml-2`,children:[`(`,t,`/`,n,`)`]})]})})]}),(0,X.jsx)(`svg`,{className:`w-20 h-20 text-gray-200 dark:text-gray-600 absolute opacity-10 -z-10`,"aria-hidden":`true`,xmlns:`http://www.w3.org/2000/svg`,fill:`currentColor`,viewBox:`0 0 20 18`,children:(0,X.jsx)(`path`,{d:`M18 0H2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2Zm-5.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm4.376 10.481A1 1 0 0 1 16 15H4a1 1 0 0 1-.895-1.447l3.5-7A1 1 0 0 1 7.468 6a.965.965 0 0 1 .9.5l2.775 4.757 1.546-1.887a1 1 0 0 1 1.618.1l2.541 4a1 1 0 0 1 .028 1.011Z`})})]}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[r(`Loading...`),` `,Math.round(e),`%`]})]})},gs=()=>{let{player:e}=J(),{t}=W(),[n,r]=(0,Y.useState)(!0);return n?(0,X.jsxs)(K,{className:`z-40 w-full bg-card/70 sm:w-8/12 relative`,children:[(0,X.jsx)(F,{variant:`ghost`,color:`secondary`,size:`icon`,className:`absolute right-2 top-2 bg-secondary text-muted hover:text-muted-foreground bg-default-500/50 hover:bg-default-300/50  dark:bg-default-500/50  dark:hover:bg-default-300/50`,onClick:()=>r(!1),children:(0,X.jsx)(Ut,{className:`h-4 w-4`})}),(0,X.jsxs)(L,{className:`flex flex-col items-center justify-center p-5 gap-2`,children:[(0,X.jsx)(`div`,{className:`text-3xl`,children:t(`Please wait`)}),(0,X.jsx)(`div`,{className:`text-xl text-orange-700 dark:text-orange-400`,children:e?.name}),(0,X.jsx)(`div`,{className:`text-3xl`,children:t(`Until the next round begins`)}),(0,X.jsx)(`div`,{className:`mt-5`,children:t(`Score`)}),(0,X.jsx)(C,{className:`text-3xl`,children:e?.score})]})]}):null},_s=()=>{let{player:e}=J(),{t,userLanguage:n}=W(),[r,i]=(0,Y.useState)(!0),a=(0,Y.useMemo)(()=>{if(n===`ar`){let e=[`يا ساتر! الاختلاف قاعد يطقك على راسك وتقول مو شايفه! 🤦‍♂️😆`,`نبي نعطيك عدسة مكبرة؟ شرايك؟ 🔍😂`,`شفت الاختلاف؟ لالا؟ خلاص، عطنا تلفونك ندور عنه بدالك! 📱👀`,`اللعبة تبي تبجي تقول ركّز! 😭🤣`,`المصور قاصد يخليك تفوز، بس إنت رافض تتعاون مع نفسك! 📸😂`,`حبيبي الاختلاف صار واضح لدرجة إنه كتب تغريدة عن نفسه! 📝🤣`,`ما عليه، حاول مرة ثانية، بس ها.. افتح عيونك هالمرة! 😆👀`,`الوضع صاير فيلم رعب، الاختلاف يطالعك وإنت ولا حاس فيه! 👻😂`,`الاختلاف طلع من الصورة، راح يسلم عليك، وإنت للحين ما شفته! 🤦‍♂️🤣`,`تبي مساعدة؟ نـقدر نخلي الاختلاف يطق لك جرس! 🔔😂`,`حتى لو الاختلاف ينط قـدامك، بتسأل وينه؟ 😆😆`,`الحين الصورة تفكر، هل المشكلة فيها ولا فيك؟ 😂`,`إنت مو خسران.. إنت بس قررت تعطي الاختلاف فرصة يختبئ أكثر! 😜`,`ماكو أمل، حتى الصورة نفسها دزّت لك موقع الاختلاف على الـواتساب! 📩😂`,`يـ خوك، الاختلاف كبر وصار واضح مثل القمر، وإنت للحين مو شايفه؟! 🌕😂`,`نقولك ركز، ما نقولك نام! 😴😂`,`الصورة للحين ناطرتك تطالعها عدل! 👀🤣`,`الاختلاف يبي يطلع هويته بنفسه ويقولك: هااا أنا هني! 😂`,`لا لا، إنت مو خسران.. إنت قاعد تسوي اختبار للنظام! 🤖😂`,`ما عليه، إنت لعبت زين.. بس الاختلاف لعب أحسن منك! 😜🔥`];return e[Math.floor(Math.random()*e.length)]}return``},[n]);return r?(0,X.jsxs)(K,{className:`z-40 w-full sm:w-8/12 bg-card/70 relative`,children:[(0,X.jsx)(F,{variant:`ghost`,color:`secondary`,size:`icon`,className:`absolute right-2 top-2 bg-secondary text-muted hover:text-muted-foreground bg-default-500/50 hover:bg-default-300/50  dark:bg-default-500/50  dark:hover:bg-default-300/50`,onClick:()=>i(!1),children:(0,X.jsx)(Ut,{className:`h-4 w-4`})}),(0,X.jsxs)(L,{className:`flex flex-col items-center gap-2 p-5 text-center`,children:[(0,X.jsx)(`div`,{className:`text-3xl`,children:t(`What a loss`)}),(0,X.jsx)(`div`,{className:`text-2xl font-bold text-slate-800 dark:text-slate-100`,children:a}
6),(0,X.jsx)(`img`,{src:`https://fonts.gstatic.com/s/e/notoemoji/latest/1f97a/512.gif`,alt:`🥳`,width:`150`,height:`150`,style:{display:`block`}}),(0,X.jsx)(`div`,{className:`text-xl text-orange-700 dark:text-orange-400`,children:e?.name}),(0,X.jsx)(`div`,{className:`mt-5`,children:t(`Score`)}),(0,X.jsx)(C,{className:`text-3xl`,children:e?.score})]})]}):null},vs=(e,t)=>{let n=0,r=0;e.pageX||e.pageY?(n=e.pageX,r=e.pageY):e.clientX||e.clientY?document.body.scrollLeft||document.body.scrollTop?(n=e.clientX+document.body.scrollLeft,r=e.clientY+document.body.scrollTop):(n=e.clientX+document.documentElement.scrollLeft,r=e.clientY+document.documentElement.scrollTop):(n=0,r=0);let i=0,a=0,o=null;if(t.offsetLeft||t.offsetTop)for(i=t.offsetLeft,a=t.offsetTop,o=t.offsetParent;o!=null;)i+=o.offsetLeft,a+=o.offsetTop,o=o.offsetParent;else i=0,a=0;return{posX:n,posY:r,x:n-i-2,y:r-a-2}},ys=()=>{let{t:e}=W(),{player:t,players:n}=J(),r=[...n].sort((e,t)=>(t.score||0)-(e.score||0)),i=r[0];return(0,X.jsx)(K,{className:`z-40 w-full bg-card/90 sm:w-8/12 max-w-lg`,children:(0,X.jsx)(L,{className:`p-5`,children:(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4`,children:[(0,X.jsx)(`div`,{className:`text-3xl font-bold text-center mb-2`,children:e(`Game Over`)}),(0,X.jsxs)(`div`,{className:`relative w-full`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-r from-yellow-400/20 to-amber-500/20 rounded-lg blur-sm`}),(0,X.jsxs)(`div`,{className:`relative bg-gradient-to-r from-yellow-400 to-amber-500 p-4 rounded-lg text-center`,children:[(0,X.jsx)(zn,{className:`inline-block text-white h-8 w-8 mb-2 animate-bounce`}),(0,X.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[e(`Winner`),`: `,i?.name]})]})]}),(0,X.jsxs)(`div`,{className:`w-full mt-4`,children:[(0,X.jsx)(`div`,{className:`text-xl font-semibold mb-2`,children:e(`Results`)}),(0,X.jsx)(`div`,{className:`space-y-2 max-h-60 overflow-y-auto pr-2`,children:r.map((e,n)=>(0,X.jsxs)(`div`,{className:q(`flex items-center justify-between p-3 rounded-lg`,n===0?`bg-yellow-100 dark:bg-yellow-900/30`:`bg-gray-100 dark:bg-gray-800/30`,e.id===t.id&&`border-2 border-primary`),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(C,{variant:n<3?`soft`:`outline`,className:`w-6 h-6 flex items-center justify-center p-0`,children:n+1}),(0,X.jsx)(`span`,{className:`font-medium`,children:e.name}),n===0&&(0,X.jsx)(Gn,{className:`h-4 w-4 text-yellow-500 fill-yellow-500`})]}),(0,X.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,X.jsx)(C,{variant:`outline`,className:`font-bold`,children:e.score||0})})]},e.id))})]}),t.host&&(0,X.jsx)(`div`,{className:`flex flex-col sm:flex-row gap-2 w-full mt-4`,children:(0,X.jsx)(F,{className:`flex-1 gap-2`,color:`primary`,asChild:!0,children:(0,X.jsxs)(d,{to:`/d`,children:[(0,X.jsx)(Qt,{className:`h-4 w-4 mr-2`}),e(`Play Again`)]})})})]})})})},bs=({onRetry:e})=>{let{t}=W();return(0,X.jsx)(K,{className:`z-40 w-full sm:w-8/12 bg-card/90 max-w-lg`,children:(0,X.jsxs)(L,{className:`flex flex-col items-center gap-4 p-6 text-center`,children:[(0,X.jsx)(xn,{className:`w-16 h-16 text-destructive animate-pulse`}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`h3`,{className:`text-xl font-semibold text-destructive`,children:t(`Error loading images`)}),(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:t(`Failed to load game images. Please try again.`)})]}),(0,X.jsxs)(F,{onClick:e,color:`primary`,size:`lg`,className:`mt-2`,children:[(0,X.jsx)(Qt,{className:`w-4 h-4 ltr:mr-2 rtl:ml-2`}),t(`Retry Loading`)]})]})})},xs=(e,t)=>e.id?e.id:String(t),Ss=({teams:e,players:t,currentPlayerId:n,currentTeamId:r,isHost:i,onJoinTeam:a,onLeaveTeam:o,onStart:s})=>{let{t:c}=W(),l=e=>t.find(t=>t.id===e)?.name||e,u=(0,Y.useMemo)(()=>{if(!n)return r;for(let t=0;t<e.length;t++){let r=e[t];if(r.playerIds.includes(n))return xs(r,t)}},[e,n,r]),d=(0,Y.useMemo)(()=>!!u,[u]),f=(0,Y.useMemo)(()=>e.filter(e=>e.playerIds.length>0).length,[e])>=1,p=(0,Y.useMemo)(()=>[...e].sort((e,t)=>(t.score??0)-(e.score??0)),[e]);return(0,X.jsx)(`div`,{className:`relative select-none h-full min-h-0 overflow-y-auto px-3 pb-4 pt-2`,children:(0,X.jsx)(`div`,{className:`w-full max-w-4xl mx-auto`,children:(0,X.jsx)(K,{className:`w-full bg-card/70`,children:(0,X.jsxs)(L,{className:`p-4 md:p-6 space-y-4`,children:[(0,X.jsx)(`div`,{className:`text-center space-y-2`,children:(0,X.jsx)(`h2`,{className:`text-2xl font-semibold`,children:c(`Choose your team`)})}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 lg:grid-cols-2 max-h-[62vh] overflow-y-auto pr-1`,children:p.map((e,t)=>{let n=xs(e,t),r=u===n,i=e.playerIds.length>=4;return(0,X.jsxs)(`div`,{className:q(`rounded-xl border p-3 space-y-3`,r?`border-primary bg-primary/10`:`border-border bg-card/40`),children:[(0,X.jsxs)(`div`,{className:q(`flex items-center justify-between gap-2 rounded-md px-2 py-1 text-white`,`bg-blue-500`,e.color&&Ir(e.color),e.color&&Nr(e.color)),children:[(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,X.jsx)(`span`,{className:`font-semibold`,children:e.name})}),(0,X.jsx)(C,{className:`bg-white/90 text-black`,children:e.playerIds.length})]}),(0,X.jsx)(`div`,{className:`min-h-12 text-sm text-muted-foreground`,children:e.playerIds.length>0?(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.playerIds.map(e=>(0,X.jsx)(C,{variant:`outline`,className:`bg-background/80 text-foreground border-border`,children:l(e)},e))}):(0,X.jsx)(`span`,{children:c(`No players yet`)})}),(0,X.jsx)(F,{className:`w-full`,color:r?`secondary`:`primary`,onClick:()=>a(n),disabled:r||i,children:c(r?`Joined`:i?`Team is full`:`Join team`)})]},n)})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,X.jsx)(F,{color:`secondary`,onClick:o,disabled:!d||!n,children:c(`Leave team`)}),i&&(0,X.jsx)(F,{color:`primary`,onClick:s,disabled:!f,children:c(`Start`)})]})]})})})})},Cs=({index:e,team:t,playersPreview:n})=>(0,X.jsx)(`div`,{className:q(`flex flex-col md:flex-row mx-3 gap-x-4 gap-y-2 md:items-center border p-2 text-lg duration-300 bg-gradient-to-br rounded-xl text-slate-100 from-slate-800/70 to-slate-900/70 border-slate-700`,{"border-yellow-400 bg-yellow-400/50 dark:bg-yellow-400/20":e===1,"border-gray-400 bg-gray-400/50 dark:bg-gray-400/20":e===2,"border-orange-400 bg-orange-400/50 dark:bg-orange-400/20":e===3}),children:(0,X.jsxs)(`div`,{className:`flex gap-4 flex-grow items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`text-lg w-10 font-philosopher`,children:[`# `,e]}),(0,X.jsxs)(`div`,{className:`flex flex-col items-start gap-0.5 font-semibold text-lg`,children:[(0,X.jsx)(`div`,{className:`hover:underline`,children:t.name}),(0,X.jsx)(`span`,{className:`text-xs text-slate-300`,children:n})]}),(0,X.jsx)(F,{size:`icon`,className:q(`w-9 h-9 font-philosopher rounded-full bg-slate-50 text-slate-800 hover:text-slate-50 hover:bg-slate-800/80`,{"bg-yellow-50 text-yellow-800 hover:text-yellow-50 hover:bg-yellow-800/80":e===1,"bg-gray-50 text-gray-800 hover:text-gray-50 hover:bg-gray-800/80":e===2,"bg-orange-50 text-orange-800 hover:text-orange-50 hover:bg-orange-800/80":e===3}),children:t.score??0})]})},t.id),ws=({index:e,team:t,playersPreview:n})=>(0,X.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,X.jsx)(`div`,{className:`font-semibold text-lg hover:underline`,children:t.name}),(0,X.jsx)(`div`,{className:`text-xs text-slate-500 dark:text-slate-300`,children:n}),(0,X.jsx)(`div`,{className:`py-2 mb-1 text-lg font-philosopher`,children:t.score??0}),(0,X.jsxs)(`div`,{className:q(`w-full font-philosopher h-20 bg-gradient-to-b text-slate-700 dark:text-white border-slate-700 from-orange-400/40 flex items-center justify-center text-3xl`,{"h-40 border-slate-700 from-yellow-500/60 rounded-t-xl":e===1,"h-28 border-slate-700 from-gray-400 rounded-tl-xl rtl:rounded-tl-none rtl:rounded-tr-xl":e===2,"rounded-tr-xl rtl:rounded-tr-none rtl:rounded-tl-xl":e===3}),children:[`#`,e]})]},t.id),Ts=()=>{let{t:e}=W(),{session:t,players:n}=J(),[r,i]=(0,Y.useState)(`teams`),a=t?.data,o=(0,Y.useMemo)(()=>
6[...a?.teams??[]].filter(e=>e.playerIds.length>0).sort((e,t)=>(t.score??0)-(e.score??0)),[a?.teams]),s=o.slice(0,3),c=o.slice(3),l=(0,Y.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e.name||e.id||``])),t=new Map;for(let n of o){let r=n.playerIds.map(t=>e.get(t)).filter(e=>!!e).slice(0,2),i=n.playerIds.length>2?` +`:``;t.set(n.id,r.join(`, `)+i)}return t},[o,n]);return r===`players`?(0,X.jsxs)(`div`,{className:`relative select-none w-full h-full flex flex-col gap-2 pt-2`,children:[(0,X.jsx)(`div`,{className:`flex justify-start`,children:(0,X.jsx)(F,{size:`sm`,color:`info`,onClick:()=>i(`teams`),children:e(`Show teams result`)})}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(Ci,{})})]}):(0,X.jsx)(`div`,{className:`relative select-none w-full h-full`,children:(0,X.jsx)(K,{className:`z-50 bg-card/40 p-4 w-full h-full`,children:(0,X.jsx)(te,{children:(0,X.jsxs)(`div`,{className:`space-y-1 page-height-horizontal`,children:[(0,X.jsx)(`div`,{className:`flex justify-start mb-2`,children:(0,X.jsx)(F,{size:`sm`,color:`info`,onClick:()=>i(`players`),children:e(`Show players result`)})}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-1 justify-end items-end mb-3`,children:[s[1]&&(0,X.jsx)(ws,{team:s[1],index:2,playersPreview:l.get(s[1].id)||``}),s[0]&&(0,X.jsx)(ws,{team:s[0],index:1,playersPreview:l.get(s[0].id)||``}),s[2]&&(0,X.jsx)(ws,{team:s[2],index:3,playersPreview:l.get(s[2].id)||``})]}),c.map((e,t)=>(0,X.jsx)(Cs,{team:e,index:t+4,playersPreview:l.get(e.id)||``},e.id))]})})})})},Es=()=>{let e=(0,Y.useRef)(null),t=(0,Y.useRef)(null),n=(0,Y.useRef)(null),{session:r,player:i,players:a}=J(),{image:o,images:s,size:c,frames:l,wrong:u,playing:d,time:f,showScore:p,mode:m,loadingImages:h,loadingProgress:g,loadedCount:_,totalCount:v,endGame:y,error:b,retryLoadImages:x,onMark:S,sendEvent:C}=cs(e),w=r?.data,T=w?.competitionMode===`TEAM`&&w?.initialized!==!0,E=w?.teams??[],D=w?.competitionMode===`TEAM`?l.filter(e=>e.completed).length:i.found??0;(0,Y.useEffect)(()=>{let e=e=>{e.touches.length>1&&e.preventDefault()};return document.addEventListener(`touchstart`,e,{passive:!1}),document.addEventListener(`touchmove`,e,{passive:!1}),()=>{document.removeEventListener(`touchstart`,e),document.removeEventListener(`touchmove`,e)}},[]);let O=(0,Y.useCallback)(()=>{!o||!d||u||i.finish||i.loser||C(`WRONG`,{})},[o,d,i.finish,i.loser]),k=e=>{!o||!d||u||i.finish||e.completed||i.loser||(C(`FOUND`,{found:{differences:o.count,index:l.indexOf(e)}}),S(e))},A=e=>{if(!o||!d||u||i.finish||i.loser)return;let{x:t,y:n}=vs(e,e.currentTarget);C(`FOUND`,{found:{x:t/c.currentScale,y:n/c.currentScale}})};if(!i.status)return(0,X.jsx)(wi,{});if(T)return(0,X.jsx)(Ss,{teams:E,players:a,currentPlayerId:i.id,currentTeamId:i.teamId,isHost:!!i.host,onJoinTeam:e=>C(`JOIN_TEAM`,{teamId:e}),onLeaveTeam:()=>C(`LEAVE_TEAM`,{teamId:i.teamId}),onStart:()=>C(`START`,{})});if(p)return w?.competitionMode===`TEAM`?(0,X.jsx)(Ts,{}):(0,X.jsx)(Ci,{});if(!o)return y?(0,X.jsx)(`div`,{className:`flex items-center justify-center gap-2`,children:(0,X.jsx)(ys,{})}):null;let j=i.winner||i.loser||h||!d||y||b,M=Math.max(1,(w?.time||0)*1e3),N=Math.max(0,f),P=Math.min(1,Math.max(0,N/M)),F=d&&N>0&&N<=5e3,I=F?Math.min(1,Math.max(0,(5e3-N)/5e3)):0;return(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(`div`,{className:`relative select-none page-height-horizontal`,children:(0,X.jsxs)(`div`,{ref:e,className:`relative w-full h-full mx-auto mt-0 mb-0`,children:[j&&(0,X.jsxs)(`div`,{className:`absolute top-5 w-full flex flex-col items-center justify-center gap-2`,children:[y&&(0,X.jsx)(ys,{}),!h&&b&&(0,X.jsx)(bs,{onRetry:x}),h&&(0,X.jsx)(hs,{progress:g,loadedCount:_,totalCount:v}),!i?.host&&!d&&!b&&(0,X.jsx)(gs,{}),i.winner&&d&&(0,X.jsx)(ls,{}),i.loser&&d&&(0,X.jsx)(_s,{})]}),(0,X.jsxs)(K,{className:q(`relative w-full h-8 overflow-hidden bg-card/40 transition-colors duration-300`,{hidden:h||b}),children:[(0,X.jsx)(`div`,{"aria-hidden":`true`,className:q(`pointer-events-none absolute inset-0 bg-red-600/80 transition-opacity duration-300`,{"animate-pulse":F}),style:{opacity:I}}),(0,X.jsxs)(L,{className:`p-1 text-lg`,children:[(0,X.jsxs)(`div`,{className:` flex items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 min-w-[100px]`,children:[(0,X.jsx)(Un,{className:`w-4 h-4 text-cyan-500`}),(0,X.jsx)(`span`,{children:Xr(f)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`div`,{children:[D,` `,(0,X.jsx)(`span`,{className:`text-slate-700 dark:text-slate-400`,children:`/`}),` `,o?.count||0]}),(0,X.jsx)(`hr`,{className:`h-4 w-1 bg-slate-300 dark:bg-slate-600`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`span`,{children:i.lives}),(0,X.jsx)(Pn,{className:`w-4 h-4 text-rose-500`})]})]})]}),(0,X.jsx)(`div`,{className:`relative h-2 overflow-hidden`,children:(0,X.jsx)(`div`,{className:`absolute inset-y-0 left-0 h-full w-full origin-left bg-gradient-to-r from-yellow-400 via-orange-500 to-red-500 transition-transform duration-100 ease-linear`,style:{transform:`scaleX(${P})`}})})]})]}),s.base1&&(0,X.jsxs)(X.Fragment,{children:[m&&(0,X.jsx)(`div`,{onClick:A,className:`z-30`,draggable:!1,style:{pointerEvents:u?`none`:`auto`,top:c.pic1.y,left:c.pic1.x,width:c.pic1.width,height:c.pic1.height,position:`absolute`}},`${c.pic1.width}-${c.pic1.height}-${c.pic1.x}-${c.pic1.y}-${c.currentScale}-div`),(0,X.jsx)(fs,{ref:t,image:s.base1,onWrong:O,wrong:u,waiting:!d,loading:h,size:c.pic1},`pic1-${c.pic1.width}-${c.pic1.height}-${c.pic1.x}-${c.pic1.y}-${c.currentScale}-${d}-${u}`)]}),s.base2&&(0,X.jsxs)(X.Fragment,{children:[m&&(0,X.jsx)(`div`,{onClick:A,className:`z-30`,draggable:!1,style:{pointerEvents:u?`none`:`auto`,top:c.pic2.y,left:c.pic2.x,width:c.pic2.width,height:c.pic2.height,position:`absolute`}},`${c.pic2.width}-${c.pic2.height}-${c.pic2.x}-${c.pic2.y}-${c.currentScale}-div`),(0,X.jsx)(fs,{ref:n,image:s.base2,onWrong:O,wrong:u,waiting:!d,loading:h,size:c.pic2},`pic2-${c.pic2.width}-${c.pic2.height}-${c.pic2.x}-${c.pic2.y}-${c.currentScale}-${d}-${u}`)]}),!h&&(0,X.jsxs)(X.Fragment,{children:[l.map((e,t)=>(0,X.jsx)(ms,{mode:m,layer:e,onFound:k,image:s[`${e.name}.png`]?s[`${e.name}.png`]:void 0,pic:c.pic1,currentScale:c.currentScale,waiting:!d},t)),l.map((e,t)=>(0,X.jsx)(ms,{mode:m,layer:e,onFound:k,image:s[`${e.name}.png`]?s[`${e.name}.png`]:void 0,pic:c.pic2,currentScale:c.currentScale,waiting:!d},t))]})]})})})},Ds=()=>{let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(`40`),[u,d]=(0,Y.useState)(`5`),[f,p]=(0,Y.useState)(!0),{session:m,isPlayerHost:h,sendEvent:g}=J(),{t:_}=W(),[v,y]=(0,Y.useState)(Xo()),b=(0,Y.useMemo)(()=>{let e=[];for(let t of Qr)e.push({label:_(t.label),value:String(t.value)});return e},[]);We(()=>{y(Xo())}),(0,Y.useEffect)(()=>{let e=m?.data;e&&(s(e?.fastest??!1),r(e?.chat??!1),l(String(e?.time)??`40`),d(String(e?.lives)??`5`),a(e?.showPlayers??!1),p(e?.mode??!1))},[m.data]);let x=(0,Y.useCallback)(()=>{g(`NEW_GAME`,{})},[g]),S=(0,Y.useCallback)(()=>{g(m?.data?.playing?`STOP`:`START`,{})},[m?.data]),C=(0,Y.useCallback)(()=>{g(`OPTIONS`,{options:{showScore:!m.data?.showScore}})},[m.data]),[w,T]=(0,Y.useState)(!1),E=(0,Y.useCallback)(()=>{T(!0),g(`OPTIONS`,{options:{fastest:o,chat:n,showPlayers:i,mode:f,time:Number(c),lives:Number(u)}}),setTimeout(()=>{t(!1),T(!1)},300)},[o,n,c,u,i,f]);return!m||!h?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(F,{size:`sm`,className:`px-1.5 text-xs`,onClick:x,color:v?`secondary`:`primary`,disabled:v,children:_(v?`Loading...`:`New image`)}),(0,X.jsx)(F,{size:`sm`,className:`px-1.5 text-xs`,onClick:S,color:m.data?.playing?`destructive`:`primary`,disabled:v,children:m.data?.playing?_(`End game`):_(`Start game`)}),(0,X.jsx)(F,{size:`sm`,className:`px-1.5 text-xs`,onClick:C,color:m.data?.showScore?`destructive`:`primary`,disabled:m.data?.playing&&!m.data?.endGame,children:_(`Show score`)}),(0,X.jsxs)(ge,{open:e,onOpenChange:t,children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsx)(F,{size:`sm`,variant:`ghost`,color:`secondary`,className:`px-1.5 text-xs`,disabled:m.data?.playing,children:(0,X.jsx)(Nt,{className:`w-6 h-6`})})}),(0,X.jsxs)(De,{children:[(0,X.jsx)(V,{children:(0,X.jsx)(xe,{children:_(`Settings`)})}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(ue,{htmlFor:`time`,children:_(`Time`)}
6),(0,X.jsx)(cr,{id:`time`,className:`react-select`,classNamePrefix:`select`,value:b.find(e=>e.value===c),options:b,onChange:e=>{l(e?.value||`40`)}})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(ue,{htmlFor:`lives`,children:_(`Number of lives`)}),(0,X.jsx)(Pe,{id:`lives`,min:1,max:15,className:`w-full`,type:`number`,value:u,onValueChanged:e=>d(e)})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(Ve,{id:`fastest`,checked:o,onCheckedChange:e=>s(!!e),children:_(`Fastest winner?`)}),(0,X.jsx)(Ve,{id:`showPlayers`,checked:i,onCheckedChange:e=>a(!!e),children:_(`Show Players`)}),D.conversationEnabled&&(0,X.jsx)(Ve,{id:`chat`,checked:n,onCheckedChange:e=>r(!!e),children:_(`Activate the conversation`)}),(0,X.jsx)(Ve,{id:`mode`,checked:f,onCheckedChange:e=>p(!!e),children:_(`Server is checking for differences`)})]}),(0,X.jsxs)(Ne,{children:[(0,X.jsx)(ce,{asChild:!0,children:(0,X.jsx)(F,{type:`button`,variant:`outline`,children:_(`Cancel`)})}),(0,X.jsx)(F,{type:`button`,onClick:E,disabled:w,children:_(w?`Updating...`:`Update`)})]})]})]})]})},Os=Zt(`relative rounded-xl font-bold transition-all duration-300 border-2 shadow-md hover:shadow-lg transform hover:scale-105`,{variants:{state:{active:`bg-gradient-to-br from-blue-500 to-blue-600 text-white border-blue-400 shadow-blue-200 dark:shadow-blue-900 ring-4 ring-blue-200 dark:ring-blue-800 scale-110`,completed:`bg-gradient-to-br from-green-500 to-green-600 text-white border-green-400 shadow-green-200 dark:shadow-green-900 opacity-80`,pending:`bg-gradient-to-br from-gray-200 to-gray-300 dark:from-gray-600 dark:to-gray-700 text-gray-600 dark:text-gray-300 border-gray-300 dark:border-gray-500 hover:from-gray-300 hover:to-gray-400 dark:hover:from-gray-500 dark:hover:to-gray-600`},size:{xs:`w-6 h-6 text-xs`,sm:`w-8 h-8 text-xs`,md:`w-12 h-12 text-sm`,lg:`w-16 h-16 text-base`,xl:`w-20 h-20 text-lg`}},defaultVariants:{state:`pending`,size:`md`}}),ks=Zt(`max-w-10xl mx-auto 5xl:px-10`,{variants:{size:{xs:`py-2 px-2`,sm:`py-2.5 px-3`,md:`py-4 px-4`,lg:`py-5 px-5`,xl:`py-6 px-6`}},defaultVariants:{size:`md`}}),As=Zt(`flex justify-center items-center`,{variants:{size:{xs:`gap-1`,sm:`gap-2`,md:`gap-3`,lg:`gap-4`,xl:`gap-5`}},defaultVariants:{size:`md`}}),js=({images:e,currentIndex:t,displayCount:n=3,onIndexChange:r,size:i=`md`,hideCompleted:a=!1})=>{let{t:o}=W();if(!e||e.length===0||e.every(t=>t===e[0]))return null;let s,c;if(a){c=t;let r=Math.min(e.length-1,t+n-1);s=e.slice(c,r+1)}else{let r=Math.floor(n/2);c=Math.max(0,t-r);let i=Math.min(e.length-1,c+n-1);i-c+1<n&&(c=Math.max(0,i-n+1)),s=e.slice(c,i+1)}let l={xs:{icon:`w-1 h-1`,checkIcon:`w-1.5 h-1.5`,pulse:`w-2 h-2`,connector:`w-3 h-0.5 -right-2`,text:`text-xs`},sm:{icon:`w-1.5 h-1.5`,checkIcon:`w-2 h-2`,pulse:`w-3 h-3`,connector:`w-4 h-0.5 -right-2.5`,text:`text-xs`},md:{icon:`w-2 h-2`,checkIcon:`w-3 h-3`,pulse:`w-4 h-4`,connector:`w-6 h-0.5 -right-3`,text:`text-sm`},lg:{icon:`w-2.5 h-2.5`,checkIcon:`w-4 h-4`,pulse:`w-5 h-5`,connector:`w-8 h-0.5 -right-4`,text:`text-base`},xl:{icon:`w-3 h-3`,checkIcon:`w-5 h-5`,pulse:`w-6 h-6`,connector:`w-10 h-0.5 -right-5`,text:`text-lg`}}[i||`md`];return(0,X.jsx)(`div`,{className:`mt-2 bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-gray-800 dark:to-gray-900 border-t border-blue-200 dark:border-gray-700 shadow-sm`,children:(0,X.jsx)(`div`,{className:ks({size:i}),children:(0,X.jsxs)(`div`,{className:As({size:i}),children:[(0,X.jsx)(`span`,{className:q(`font-medium text-gray-600 dark:text-gray-400 mr-4`,l.text),children:o(`Progress:`)}),s.map((e,n)=>{let o=c+n,u=o===t,d=o<t;if(a&&d)return null;let f=`pending`;return u?f=`active`:d&&(f=`completed`),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsxs)(F,{onClick:()=>r?.(o),className:Os({state:f,size:i}),children:[(0,X.jsx)(`span`,{className:`relative z-10`,children:e}),d&&!a&&(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(`div`,{className:q(`bg-white rounded-full flex items-center justify-center`,l.checkIcon),children:(0,X.jsx)(`svg`,{className:q(`text-green-600`,l.icon),fill:`currentColor`,viewBox:`0 0 20 20`,children:(0,X.jsx)(`path`,{fillRule:`evenodd`,d:`M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z`,clipRule:`evenodd`})})})}),u&&(0,X.jsx)(`div`,{className:q(`absolute -top-1 -right-1 bg-yellow-400 rounded-full animate-pulse border-2 border-white`,l.pulse),children:(0,X.jsx)(`div`,{className:`w-full h-full bg-yellow-400 rounded-full animate-ping`})})]}),n<s.length-1&&(0,X.jsx)(`div`,{className:q(`absolute top-1/2 transform -translate-y-1/2 transition-colors duration-300`,l.connector,o<t?`bg-green-400`:`bg-gray-300 dark:bg-gray-600`)})]},o)}),(0,X.jsx)(`div`,{className:q(`ml-4 text-gray-500 dark:text-gray-400`,l.text),children:(0,X.jsxs)(`div`,{children:[t+1,` / `,e.length]})})]})})})},Ms=(e,t)=>e.id?e.id:String(t),Ns=({teams:e})=>{let{t}=W(),{players:n,player:r,sendEvent:i}=J(),[a,o]=(0,Y.useState)(null),s=(0,Y.useMemo)(()=>e.filter(e=>e.playerIds.length>0).sort((e,t)=>
6(t.score??0)-(e.score??0)),[e]),c=(0,Y.useMemo)(()=>s.find(e=>e.id===a),[s,a]),l=(0,Y.useMemo)(()=>r.id?e.find(e=>e.playerIds.includes(r.id))?.id:r.teamId,[e,r.id,r.teamId]),u=(c?.playerIds.length??0)>=4,d=e=>e.playerIds.length?e.playerIds.every(e=>{let t=n.find(t=>t.id===e);return t?.ready===!0&&t?.online===!0}):!1;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-1`,children:s.map((e,t)=>{let r=e.playerIds.map(e=>n.find(t=>t.id===e)).filter(Boolean),i=r.length>0&&r.some(e=>e?.winner),a=r.length>0&&r.some(e=>e?.loser),s=r.length>0&&r.every(e=>e?.online===!1),c=r.length>0&&r.every(e=>e?.status===!1),l=!i&&!a&&!s&&!c;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),className:q(`h-7 text-xs text-white flex items-center justify-between gap-2 px-2 py-1 rounded-md transition-all duration-200`,{"bg-green-600 hover:bg-green-700":i,"bg-red-600 hover:bg-red-700":a&&!i,"bg-gray-500 text-gray-300 hover:bg-gray-600":s&&!i&&!a,"bg-rose-950 hover:bg-rose-800 text-rose-300":c&&!i&&!a&&!s,"bg-blue-500 hover:bg-blue-600":l&&!e.color},l&&e.color&&Ir(e.color),l&&e.color&&Nr(e.color)),children:[(0,X.jsxs)(`span`,{className:`truncate flex items-center gap-1`,children:[i&&(0,X.jsx)(zn,{className:`w-4 h-4 text-yellow-400`}),a&&!i&&(0,X.jsx)(fn,{className:`w-4 h-4 text-red-400`}),(0,X.jsx)(`span`,{children:e.name}),d(e)&&(0,X.jsx)(gn,{className:`w-4 h-4 text-green-400`})]}),(0,X.jsx)(C,{className:q(`text-xs px-1.5 py-0.5`,{"bg-green-700 text-white":i,"bg-red-700 text-white":a&&!i,"bg-white/90 text-black":!i&&!a}),children:e.score??0})]},Ms(e,t))})}),(0,X.jsx)(ge,{open:a!==null,onOpenChange:e=>{e||o(null)},children:(0,X.jsxs)(De,{children:[(0,X.jsx)(V,{children:(0,X.jsx)(xe,{children:c?.name||t(`Players`)})}),a&&(0,X.jsx)(kr,{teamId:a,layout:`vertical`,className:`w-full`,scrollAreaClassName:`max-h-[50vh] pr-1`}),!l&&(0,X.jsx)(Ne,{className:`flex-row justify-end`,children:(0,X.jsx)(F,{color:`primary`,size:`xs`,onClick:()=>{!c?.id||u||i(`JOIN_TEAM`,{teamId:c.id})},disabled:u,children:t(u?`Team is full`:`Join team`)})})]})})]})},Ps=()=>{let{session:e,player:t,isHeaderVisible:n,toggleHeaderVisibility:r}=J(),{t:i}=W(),a=e?.data;return t.status?(0,X.jsxs)(`header`,{className:`relative`,children:[(0,X.jsx)(`button`,{onClick:r,className:q(`absolute z-10 left-5 transform -translate-x-1/2 bg-red-500 text-white rounded-b-md p-1 shadow-md flex items-center justify-center`),style:{top:n?`auto`:`0`,bottom:n?a?.showScore?`-25px`:`11px`:`auto`,transform:`translateX(-50%)`},children:n?(0,X.jsx)(Wt,{size:16}):(0,X.jsx)(_n,{size:16})}),(0,X.jsxs)(`div`,{className:`bg-gradient py-2.5 2xl:py-4 transition-all duration-300 ease-in-out`,style:{maxHeight:n?`1000px`:`0`,overflow:`hidden`,opacity:+!!n,visibility:n?`visible`:`hidden`},children:[(0,X.jsx)(`div`,{className:`max-w-10xl px-4 mx-auto 5xl:px-10`,children:(0,X.jsxs)(`div`,{className:`grid gap-y-1.5 sm:gap-y-1.5 grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 items-center md:text-lg 2xl:text-[22px] max-sm:[&>*]:col-span-full`,children:[(0,X.jsxs)(`div`,{className:`grid grid-flow-col max-sm:flex max-sm:flex-wrap max-sm:items-center max-sm:justify-between gap-4 sm:gap-2 4xl:gap-20 sm:place-content-start md:ltr:place-content-end header-right-block`,children:[(0,X.jsx)(`div`,{className:`min-w-10 md:min-w-14 2xl:min-w-20`,children:(0,X.jsxs)(d,{to:`/`,children:[(0,X.jsx)(`img`,{src:`/images/logo.png`,className:`h-9 grid sm:place-content-center dark:hidden`,alt:`logo`}),(0,X.jsx)(`img`,{src:`/images/logo-dark.png`,className:`h-9 hidden dark:grid dark:sm:place-content-center`,alt:`logo`})]})}),(0,X.jsxs)(`div`,{className:`text-[18px] sm:text-[26px] 2xl:text-3xl 4xl:text-5xl leading-none whitespace-nowrap`,children:[e.name,` `]}),(0,X.jsxs)(`div`,{className:` flex items-center justify-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:i(`Round: {{round}}`,{round:e.data?.round})}),(0,X.jsx)(Gr,{})]})]}),(0,X.jsx)(`div`,{className:`max-sm:flex max-sm:justify-between grid grid-flow-col items-center gap-1.5 md:gap-4 sm:place-content-end max-xl:col-span-1 max-xl:col-start-2 max-xl:row-start-1 md:place-content-end sm:ltr:place-content-start`,children:(0,X.jsx)(Ds,{})})]})}),!a?.showScore&&a?.images&&a?.images.length>0&&(0,X.jsx)(js,{images:a.images,currentIndex:a.index,displayCount:3,hideCompleted:!0,size:`sm`})]}),!a?.showScore&&(0,X.jsx)(`div`,{className:`max-w-10xl px-4 mx-auto 5xl:px-10`,children:(e.data?.showPlayers||t.host)&&(0,X.jsx)(`div`,{className:`relative select-none overflow-hiddenm mt-1`,children:a?.competitionMode===`TEAM`?(0,X.jsx)(Ns,{teams:a?.teams??[]}):(0,X.jsx)(kr,{})})})]}):null},Fs=e({config:()=>Is,default:()=>Ls}),Is={menu:{order:0,exclude:!0},title:B(`Find the difference`)};function Ls(){return(0,X.jsxs)(Br,{onSendEvent:_t,gameId:`find-difference`,children:[(0,X.jsx)(Ps,{}),(0,X.jsx)(`main`,{className:`mx-auto px-4 h-full w-full`,children:(0,X.jsx)(Es,{})}),(0,X.jsx)(zr,{})]})}var Rs=e({config:()=>zs,default:()=>Bs}),zs={menu:{order:0,exclude:!0},title:B(`Jawabak`),loginRequired:!0};function Bs(){return(0,X.jsx)(ui,{gameId:`jawabak`,linkPrefix:`j`,title:`Jawabak`})}var Vs=e({config:()=>Hs,default:()=>Us}),Hs={menu:{order:0,exclude:!0},title:B(`Jawabak`)};function Us(){return(0,X.jsx)(ti,{gameId:`jawabak`})}var Ws=()=>{let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(`40`),[c,l]=(0,Y.useState)(`5`),[u,d]=(0,Y.useState)(!0),[f,p]=(0,Y.useState)(!1),{session:m,isPlayerHost:h,sendEvent:g}=J(),{t:_}=W();(0,Y.useEffect)(()=>{let e=m?.data;e&&(r(e?.chat??!1),a(e?.fastest??!1),s(String(e?.time)??`40`),l(String(e?.lives)??`5`),d(e?.showPlayers??!1))},[m.data]);let v=(0,Y.useCallback)(()=>{g(`NEW_QUESTION`,{})},[g]),y=(0,Y.useCallback)(()=>{g(m?.data?.playing?`STOP`:`START`,{})},[m?.data]),b=(0,Y.useCallback)(()=>{g(`OPTIONS`,{options:{showScore:!m.data?.showScore}})},[m.data]),x=(0,Y.useMemo)(()=>{let e=[];for(let t of Qr)e.push({label:_(t.label),value:String(t.value)});return e},[]),S=(0,Y.useCallback)(()=>
6{p(!0),g(`OPTIONS`,{options:{fastest:i,chat:n,showPlayers:u,time:Number(o),lives:Number(c)}}),setTimeout(()=>{t(!1),p(!1)},300)},[i,n,o,c,u]);return!m||!h?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(F,{size:`sm`,className:`px-1.5 text-xs`,onClick:v,children:m.data?.playing?_(`Next`):_(`New question`)}),(0,X.jsx)(F,{size:`sm`,className:`px-1.5 text-xs`,onClick:y,children:m.data?.playing?_(`End`):_(`Start`)}),(0,X.jsx)(F,{size:`sm`,className:`px-1.5 text-xs`,onClick:b,disabled:m.data?.playing,children:_(`Show score`)}),(0,X.jsxs)(ge,{open:e,onOpenChange:t,children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsx)(F,{size:`sm`,variant:`ghost`,color:`secondary`,className:`px-1.5 text-xs`,disabled:m.data?.playing,children:(0,X.jsx)(Nt,{className:`w-6 h-6`})})}),(0,X.jsxs)(De,{children:[(0,X.jsx)(V,{children:(0,X.jsx)(xe,{children:_(`Settings`)})}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(ue,{htmlFor:`time`,children:_(`Time`)}),(0,X.jsx)(cr,{id:`time`,className:`react-select`,classNamePrefix:`select`,value:x.find(e=>e.value===o),options:x,onChange:e=>{s(e?.value||`40`)}})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(ue,{htmlFor:`lives`,children:_(`Number of lives`)}),(0,X.jsx)(Pe,{id:`lives`,min:1,max:15,className:`w-full`,type:`number`,value:c,onValueChanged:e=>l(e)})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(Ve,{id:`fastest`,checked:i,onCheckedChange:e=>a(!!e),children:_(`Fastest winner?`)}),(0,X.jsx)(Ve,{id:`showPlayers`,checked:u,onCheckedChange:e=>d(!!e),children:_(`Show Players`)}),D.conversationEnabled&&(0,X.jsx)(Ve,{id:`chat`,checked:n,onCheckedChange:e=>r(!!e),children:_(`Activate the conversation`)})]}),(0,X.jsxs)(Ne,{children:[(0,X.jsx)(ce,{asChild:!0,children:(0,X.jsx)(F,{type:`button`,variant:`outline`,children:_(`Cancel`)})}),(0,X.jsx)(F,{type:`button`,onClick:S,disabled:f,children:_(f?`Updating...`:`Update`)})]})]})]})]})},Gs=()=>{let{session:e,player:t,isHeaderVisible:n,toggleHeaderVisibility:r}=J(),{t:i}=W();return(0,X.jsxs)(`header`,{className:`relative`,children:[(0,X.jsx)(`button`,{onClick:r,className:q(`absolute z-10 left-5 transform -translate-x-1/2 bg-red-500 text-white rounded-b-md p-1 shadow-md flex items-center justify-center`,{}),style:{top:n?`auto`:`0`,bottom:n?`11px`:`auto`,transform:`translateX(-50%)`},children:n?(0,X.jsx)(Wt,{size:16}):(0,X.jsx)(_n,{size:16})}),(0,X.jsx)(`div`,{className:`bg-gradient py-2.5 2xl:py-4 transition-all duration-300 ease-in-out`,style:{maxHeight:n?`1000px`:`0`,overflow:`hidden`,opacity:+!!n,visibility:n?`visible`:`hidden`},children:(0,X.jsx)(`div`,{className:`max-w-10xl px-4 mx-auto 5xl:px-10`,children:(0,X.jsxs)(`div`,{className:`grid gap-y-1.5 sm:gap-y-1.5 grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 items-center md:text-lg 2xl:text-[22px] max-sm:[&>*]:col-span-full`,children:[(0,X.jsxs)(`div`,{className:`grid grid-flow-col max-sm:flex max-sm:flex-wrap max-sm:items-center max-sm:justify-between gap-4 sm:gap-2 4xl:gap-20 sm:place-content-start md:ltr:place-content-end header-right-block`,children:[(0,X.jsx)(`div`,{className:`min-w-10 md:min-w-14 2xl:min-w-20`,children:(0,X.jsxs)(d,{to:`/`,children:[(0,X.jsx)(`img`,{src:`/images/logo.png`,className:`h-9 grid sm:place-content-center dark:hidden`,alt:`logo`}),(0,X.jsx)(`img`,{src:`/images/logo-dark.png`,className:`h-9 hidden dark:grid dark:sm:place-content-center`,alt:`logo`})]})}),(0,X.jsxs)(`div`,{className:`text-[18px] sm:text-[26px] 2xl:text-3xl 4xl:text-5xl leading-none whitespace-nowrap`,children:[e.name,` `]}),(0,X.jsxs)(`div`,{className:` flex items-center justify-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:i(`Round: {{round}}`,{round:e.data?.round})}),(0,X.jsx)(Gr,{})]})]}),(0,X.jsx)(`div`,{className:`max-sm:flex max-sm:justify-between grid grid-flow-col items-center gap-1.5 md:gap-4 sm:place-content-end max-xl:col-span-1 max-xl:col-start-2 max-xl:row-start-1 md:place-content-end sm:ltr:place-content-start`,children:(0,X.jsx)(Ws,{})})]})})}),(0,X.jsx)(`div`,{className:`max-w-10xl px-4 mx-auto 5xl:px-10`,children:(e.data?.showPlayers||t.host)&&(0,X.jsx)(`div`,{className:`relative select-none overflow-hiddenm mt-1`,children:(0,X.jsx)(kr,{})})})]})},Ks=()=>{let[e,t]=(0,Y.useState)(!1),n=(0,Y.useRef)(null),{session:r,player:i,subscriptionClient:a,sendEvent:o,onSession:s}=J(),c=(0,Y.useRef)(null),l=(0,Y.useMemo)(()=>r?.data,[r?.data]),u=(0,Y.useMemo)(()=>
6{if(!l?.question)return[];let e=i.round?.answers??[],t=[...l.question.answers];if(!l.playing)return t;for(let n of e){let e=t.findIndex(e=>e.index===n.index);t[e]={...t[e],answer:n.answer}}return t},[l?.question,l.playing,i.round]),d=(0,Y.useCallback)(()=>{o(`END_TURN`)},[]),[f,{startTimer:p,stopTimer:m,resetTimer:h}]=Ti({countStart:60,intervalMs:1e3,finishCallback:d});(0,Y.useEffect)(()=>{l?.time&&(h(l.time),l.playing&&p())},[l?.time,l.playing,h]);let g=(0,Y.useCallback)((e,t)=>{o(e,t)},[]),_=(0,Y.useCallback)(e=>{let r=e;switch(r.type){case`NEW_QUESTION`:r.question&&(t(!1),s(e=>{let t=e.data;return setTimeout(()=>{h(t?.time??60),t.playing&&p()},0),{...e,data:{...e.data,question:r.question,startTime:-1,round:r.round}}}));break;case`START`:t(!1),s(e=>{let t=e.data;return setTimeout(()=>{h(t?.time??60),p()},0),{...e,data:{...e.data,question:r.question&&r.question.id!==t?.question?.id?r.question:t?.question,startTime:r.startTime,round:r.round,playing:!0}}});break;case`STOP`:s(e=>{let t=e.data;return setTimeout(()=>{h(t?.time??60),m()},0),{...e,data:{...e.data,startTime:r.startTime,playing:!1}}}),t(!1)}if(i.id===r.player?.id&&((r.player?.loser||r.endGame)&&m(),r.wrong)){if(r.player?.lives<=0){n.current&&clearTimeout(n.current),t(!0);return}t(!0),n.current&&clearTimeout(n.current),n.current=window.setTimeout(()=>{r.player?.lives>0&&t(!1)},300)}},[i,s,h,p,m]);(0,Y.useEffect)(()=>{c.current=_},[_]),(0,Y.useEffect)(()=>{let e=l?.time??60;if(l?.playing){if(l?.startTime!==void 0&&l?.startTime!==-1){let t=Math.floor((l?.startTime+e*1e3-Date.now())/1e3);t>0?(h(t),p()):h(0)}return}h(e)},[l?.startTime,l?.playing,h,p]);let v=(0,Y.useCallback)(e=>{c.current&&c.current(e)},[]);return(0,Y.useEffect)(()=>(a.on([`NEW_QUESTION`,`START`,`STOP`,`WRONG`,`CHECK_ANSWER`,`SHOW_ANSWERS`],v),()=>a.off([`NEW_QUESTION`,`START`,`STOP`,`WRONG`,`CHECK_ANSWER`,`SHOW_ANSWERS`],v)),[a,v]),{wrong:e,time:f,model:l,answers:u,checkAnswer:(0,Y.useCallback)(t=>{!l.question||!l.playing||e||i.finish||g(`CHECK_ANSWER`,{answer:t})},[l.question,l.playing,i,e]),sendEvent:g}},qs=(0,Y.memo)(({score:e})=>{let{t,userLanguage:n}=W(),r=(0,Y.useMemo)(()=>{if(n===`ar`){let e=`كفو عليك! جبتهم كلهم! 🔥.يا سلام! ما خليت ولا إجابة! 😎.مية مية! إنت موسوعة متنقلة! 📚.ولا غلطة! مستحيل عليك! 💯.فنان، شطرتك واضحة! 🎭.محترف! ما خليت لهم مجال! 🏆.إجاباتك مثل الرشاش! 🔫😂.خلصت السؤال بكل أريحية! 😌.أسطورة! جبتهم قبل الوقت! ⏳🔥.يا سلام عليك! إنت البطل بهاللعبة! 👑.كأنك قاري الكتاب قبل! 😂📖.مو طبيعي، عبقري بمعنى الكلمة! 🧠.هذا الأداء اللي ينحط في القواميس! 🔥.تحب تفوز؟ شكلك مولود للفوز! 😆.رقم واحد بدون منافس! 🚀.إجاباتك أسرع من البرق! ⚡.وين نوقع عقد الاحتراف؟ 😎.أعطييهم درس في الإجابات الصحيحة! 🎓.والله إنك صامل! كفو عليك! 🤜🤛.عشت! إنت مثال الذكاء! 🏅.إجاباتك سريعة ودقيقة، ما يحتاج! 🎯.مستوى خارق! حطوا اسمك في الصدارة! 🏆.ماكو مجال للمنافسة، مسيطر على الوضع! 🤩.شوفوا وتعلّموا من هالبطل! 📢.ختمتها بطريقة خرافية! 🔥.مرة ثانية؟ عادي، ما راح تخسر! 😂.حاط عينك على الجواب الصح دايماً! 👀.كل الإجابات عندك، صاير جوجل؟ 😂.السؤال اختفى قبل لا يفكرون بالإجاباة! ⚡.فزت وكسرت الرقم القياسي! 🚀🔥.يا معود، فزت؟ شكلك مسوي اتفاق مع اللعبة! 😂.خلاص، اعتزلت القمة؟ ولا تبي فوز ثاني؟ 😎.انت مو تلعب، انت تسحر اللعبة! 🪄🔥.فزت لدرجة المنافسين قاموا يعيدون حساباتهم! 🤯.عادي، فوزك صار متوقع! وين التحدي؟ 🤨.خلاص، بيعطونك لقب "ملك الإجابات"! 👑.دقيقة! خل أكلم الدعم الفني، لأنك كسرت اللعبة! 🤣.إنت أسرع من جوجل بالإجابات! 📲⚡.شنو هذا؟ فزت بدون ما تفكر حتى! 🧠💨.إذا فزت مرة ثانية، راح نحط اسمك شعار اللعبة! 🏆😂`.split(`.`);return e[Math.floor(Math.random()*e.length)]}return``},[n]);return(0,X.jsxs)(`div`,{className:`flex flex-col justify-center items-center mb-5 py-6 relative`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-r from-[#2ecc71]/20 to-[#27ae60
6]/20 animate-pulse`}),(0,X.jsx)(zn,{size:48,className:`text-yellow-400 mb-2 animate-bounce`}),(0,X.jsx)(`div`,{className:`bg-gradient-to-r from-[#2ecc71] to-[#27ae60] py-3 px-6 rounded-lg shadow-lg`,children:(0,X.jsx)(`span`,{className:`text-3xl font-bold`,children:t(`You won!`)})}),(0,X.jsx)(`div`,{className:`mt-3 text-2xl font-bold`,children:r}),(0,X.jsxs)(`div`,{className:`mt-3 text-xl`,children:[t(`Score`),`: `,(0,X.jsx)(`span`,{className:`font-bold text-yellow-400`,children:e})]}),(0,X.jsx)(`div`,{className:`absolute -left-10 top-0 w-20 h-20 bg-yellow-400/30 rounded-full blur-xl`}),(0,X.jsx)(`div`,{className:`absolute -right-10 bottom-0 w-20 h-20 bg-green-400/30 rounded-full blur-xl`})]})}),Js=(0,Y.memo)(({score:e})=>{let{t,userLanguage:n}=W(),r=(0,Y.useMemo)(()=>{if(n===`ar`){let e=`يلا يلا، باقي لك شوي! 😭,كنت قريب بس راحت عليك! 😩,آخ، نقصتك إجابة وحدة بس! 🤦,خسارة! بس حاول مره ثانية! 🔄,الحظ ما كان وياك هالمرة! 🍀💔,انت قريب من الفوز، جرب مرة ثانية! 🔄,يا ساتر، ضاع الفوز من يدك! 😢,قوية، باقي لك كم إجاباة بس! 🤏,اوف! سؤال صعب شوي، صح؟ 😅,لا تزعل، الكل يخسر مره! 🙃,كنت عالحافة، بس للأسف طحت! 🚶💨,عندك شوية نسيان اليوم؟ 😂,ضيعت فرصة الفوز، يلا الجاي أحسن! ✌️,الإجاباة كانت بجيبك وراحت! 🫠,نص الفوز ما يعتبر فوز! 😆,كانت سهلة، شفيك نسيت؟ 🤯,لازم تشغل مخك عدل المرة الياية! 🧠,الخطوة الجاية تفوز فيها إن شاء الله! 🙏,شرايك تتأكد من إجاباتك قبل لا ترسلها؟ 😂,انزين، عرفت غلطك؟ 😜,معقولة؟ جاوبت كل شي إلا وحدة! 😨,هاردلك، بس لا تفقد الأمل! 💪,ما يخالف، حاول مرة ثانية وأقوى! 🔥,يعني انت عارف الحل بس خانتك السرعة؟ 😆,المرة الياية راح تكسر اللعبة! 🏆,قربت بس قرب مو كفاية! 😂,مو نهاية العالم، بس خسرت! 😜,جرب تسوي ريماتش وتعوضها! ♻️,حسافة، كان فوزك مضمون! 😩,أنت تحتاج تدريب شوي، بس عندك الإمكانيات! 💡,اوف، حظك اليوم مثل شبكة الواي فاي، ضعيف! 📶💀,خسرت؟ لا تحاتي، الدنيا ما وقفت... يمكن! 😆,تعال، تعال، خل نعطيك دورة في الإجابات الصحيحة! 📚😂,شرايك تعيد الجولة؟ أو نخليها سر وننسى اللي صار؟ 😜,آه يا القهر! الإجاباة كانت تطالعك وتقول خذني! 😭,لا لا، اكيد في أحد فصل عليك النت! 🚨🤣,ولا يهمك، حتى الأبطال يخسرون... بس مو بهالطريقة! 😅,خسرت؟ حلو، عندك عذر تأكل شوكولاتة الحين! 🍫😂,لا تزعل، يمكن اللعبة فيها خطأ تقني ضدك! 🔧😜,خلاص، تأكدنا... الحظ مو صاحبك اليوم! 🚶💔`.split(`,`);return e[Math.floor(Math.random()*e.length)]}return``},[n]);return(0,X.jsxs)(`div`,{className:`flex flex-col justify-center items-center mb-5 py-6 relative`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-r from-[#e74c3c]/20 to-[#c0392b]/20 animate-pulse`}),(0,X.jsx)(br,{size:48,className:`text-red-400 mb-2 animate-pulse`}),(0,X.jsx)(`div`,{className:`bg-gradient-to-r from-[#e74c3c] to-[#c0392b] py-3 px-6 rounded-lg shadow-lg`,children:(0,X.jsx)(`span`,{className:`text-3xl font-bold`,children:t(`You lost!`)})}),(0,X.jsx)(`div`,{className:`mt-3 text-2xl font-bold`,children:r}),(0,X.jsxs)(`div`,{className:`mt-3 text-xl`,children:[t(`Score`),`: `,(0,X.jsx)(`span`,{className:`font-bold`,children:e})]}),(0,X.jsx)(`div`,{className:`absolute -left-10 top-0 w-20 h-20 bg-red-400/30 rounded-full blur-xl`}),(0,X.jsx)(`div`,{className:`absolute -right-10 bottom-0 w-20 h-20 bg-red-500/30 rounded-full blur-xl`})]})}),Ys=(0,Y.memo)(()=>{let{t:e}=W();return(0,X.jsxs)(`div`,{className:`flex flex-col justify-center items-center mb-5 py-6 relative`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-r from-[#f1c40f]/20 to-[#f39c12]/20 animate-pulse`}),(0,X.jsx)(qt,{size:48,className:`text-yellow-400 mb-2 animate-spin-slow`}),(0,X.jsx)(`div`,{className:`bg-gradient-to-r from-[#f1c40f] to-[#f39c12] py-3 px-6 rounded-lg shadow-lg`,children:(0,X.jsx)(`span`,{className:`text-2xl font-bold`,children:e(`Waiting for host...`)})}),(0,X.jsx)(`div`,{className:`absolute -left-10 top-0 w-20 h-20 bg-yellow-400/30 rounded-full blur-xl`}),(0,X.jsx)(`div`,{className:`absolute -right-10 bottom-0 w-20 h-20 bg-orange-400/30 rounded-full blur-xl`})]})}),Xs=(0,Y.memo)(({player:e,model:t})=>e.winner&&t.playing?(0,X.jsx)(qs,{score:e.score}):e.loser&&t.playing?(0,X.jsx)(Js,{score:e.score}):!e?.host&&!t.playing?(0,X.jsx)(Ys,{}):null),Zs=()=>{let{session:e,player:t}=J(),[n,r]=(0,Y.useState)(``),{t:i}=W(),{time:a,model:o,wrong:s,answers:c,checkAnswer:l,sendEvent:u}=Ks(),{toast:d}
6=je(),[f,p]=Qe(),[m,h]=(0,Y.useState)([]),g=(0,Y.useCallback)(()=>{p(`${window.location.href}`).then(e=>{d(e?{title:i(`Copied`)}:{title:i(`Copy failed`)})})},[e]),v=()=>{l(qr(n)),r(``)},y=()=>{t.debug||u(`OPTIONS`,{options:{showAnswers:!o.showAnswers}})};if((0,Y.useEffect)(()=>{if(!t.debug&&(!o.showAnswers||!t.host)){h([]);return}gt(e.roomId,t.id).then(e=>{h(e)})},[o.showAnswers,o.question,t.host,t.debug]),!o.question)return(0,X.jsx)(`div`,{className:`flex justify-center items-center h-screen`,children:(0,X.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-blue-500`})});if(o.showScore)return(0,X.jsx)(Ci,{});let b=t.winner||t.loser||!o.playing;return(0,X.jsxs)(K,{className:`p-5 mt-5 bg-[#1a2b4a] text-white relative overflow-hidden ${s?`animate-shake`:``}`,children:[b&&(0,X.jsx)(Xs,{player:t,model:o}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2 justify-between items-center mb-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center bg-[#1a3b6d] py-1 px-4 h-9 rounded-md`,children:[(0,X.jsx)(`div`,{className:`bg-yellow-400 w-5 h-5 rounded-full ltr:mr-2 rtl:ml-2`}),(0,X.jsx)(`span`,{children:t.score})]}),t.host&&(0,X.jsx)(F,{size:`sm`,className:`px-1.5 text-xs bg-[#1a3b6d]`,onClick:y,children:o.showAnswers?(0,X.jsx)(Mt,{color:`white`,size:24}):(0,X.jsx)(Pt,{color:`white`,size:24})}),o.showAnswers&&(0,X.jsx)(`span`,{className:`py-1 px-3 rounded-md ltr:mr-2 rtl:ml-2 bg-red-600 animate-pulse`,children:i(`The host is watching the answers.`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center`,children:[(0,X.jsx)(`span`,{className:`py-1 px-3 rounded-md ltr:mr-2 rtl:ml-2 ${s?`bg-red-600 animate-pulse`:`bg-[#e74c3c]`}`,children:Ur(a)}),(0,X.jsxs)(`div`,{className:`flex gap-1`,children:[Array(t.lives).fill(0).map((e,t)=>(0,X.jsx)(Pn,{size:24,className:`fill-[#e74c3c] stroke-[#e46759]`},t)),Array(o.lives-t.lives).fill(0).map((e,t)=>(0,X.jsx)($n,{size:24,className:`fill-[#e74c3c] stroke-[#e46759]  opacity-30`},t))]})]})]}),(0,X.jsxs)(`div`,{className:`bg-[#1a3b6d] rounded-md text-center mb-5 ${!t?.host&&!o.playing?`blur-lg pointer-events-none`:``} ${s?`border-2 border-red-500`:``}`,children:[(0,X.jsx)(`h2`,{className:`text-2xl p-5`,children:o.question.question}),(0,X.jsx)(ke,{value:a/o.time*100,className:`rounded-none bg-[#1a3b6d]`,size:`sm`})]}),(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-3 mb-5 ${!t?.host&&!o.playing?`blur-lg pointer-events-none`:``}`,children:c.map((e,t)=>{let n=e.answer;return(0,X.jsxs)(`div`,{className:`${n?`bg-[#2ecc71]`:`bg-[#1a3b6d]`} p-4 rounded-md ${n?`animate-reveal`:``}`,children:[(0,X.jsxs)(`div`,{className:`flex justify-between`,children:[n?(0,X.jsx)(`span`,{children:n}):(0,X.jsx)(`span`,{children:`???`}),(0,X.jsx)(`span`,{className:`bg-[#f39c12] px-2 py-0.5 rounded-full text-sm`,children:i(`{{points}} points`,{points:e.score})})]}),m[t]&&(0,X.jsx)(`div`,{className:`flex gap-1 flex-wrap mt-2`,children:m[t].answer?.split(`,`).map((e,t)=>(0,X.jsx)(C,{children:e},t))})]},t)})}),(0,X.jsxs)(_,{"aria-disabled":!o.playing||t.loser,children:[(0,X.jsx)(Pe,{disabled:!o.playing||t.loser,type:`text`,value:n,onChange:e=>r(e.target.value),className:`rounded-md border-none bg-[#2c3e50] text-white placeholder:text-white ${s?`bg-red-900/50 animate-pulse`:``}`,placeholder:i(`Write your answer...`),size:`lg`,onKeyDown:e=>{e.key===`Enter`&&v()}}),(0,X.jsx)(H,{children:(0,X.jsx)(F,{onClick:v,className:`${s?`bg-red-500`:`bg-[#2ecc71]`}`,disabled:!o.playing||t.loser,children:(0,X.jsx)(gn,{})})})]}),s&&(0,X.jsx)(`div`,{className:`absolute inset-0 bg-red-500/20 pointer-events-none animate-flash`}),(0,X.jsx)(`div`,{onClick:g,className:`text-center mt-5`,children:window.location.href})]})},Qs=e({config:()=>$s,default:()=>ec}),$s={menu:{order:0,exclude:!0},title:B(`Jawabak`)};function ec(){return(0,X.jsxs)(Br,{onSendEvent:vt,gameId:`jawabak`,children:[(0,X.jsx)(Gs,{}),(0,X.jsx)(`main`,{className:`mx-auto px-4 score-card h-full w-full`,children:(0,X.jsx)(Zs,{})}),(0,X.jsx)(zr,{})]})}var tc=e({config:()=>nc,default:()=>rc}),nc={menu:{order:0,exclude:!0},title:B(`Wit`),loginRequired:!0};function rc(){return(0,X.jsx)(ui,{gameId:`wit`,linkPrefix:`w`,title:`Wit`})}var ic=e({config:()=>ac,default:()=>oc}),ac={menu:{order:0,exclude:!0},title:B(`Wit`)};function oc(){return(0,X.jsx)(ti,{gameId:`wit`})}async function sc(e,t){return st.fluxConnection.send(`WitEndpoint`,`send`,{roomId:e,request:t})}var cc=()=>{let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(`40`),[c,l]=(0,Y.useState)(`5`),[u,d]=(0,Y.useState)(!0),[f,p]=(0,Y.useState)(!1),{session:m,isPlayerHost:h,sendEvent:g}=J(),{t:_}=W();(0,Y.useEffect)(()=>{let e=m?.data;e&&(r(e?.chat??!1),a(e?.fastest??!1),s(String(e?.time)??`40`),l(String(e?.lives)??`5`),d(e?.showPlayers??!1))},[m.data]);let v=(0,Y.useCallback)(()=>{g(`NEW_CLUE`,{})},[g]),y=(0,Y.useCallback)(()=>{g(m?.data?.playing?`STOP`:`START`,{})},[m?.data]),b=(0,Y.useCallback)(()=>{g(`OPTIONS`,{options:{showScore:!m.data?.showScore}})},[m.data]),x=(0,Y.useMemo)(()=>{let e=[];for(let t of Qr)e.push({label:_(t.label),value:String(t.value)});return e},[]),S=(0,Y.useCallback)(()=>
6{p(!0),g(`OPTIONS`,{options:{fastest:i,chat:n,showPlayers:u,time:Number(o),lives:Number(c)}}),setTimeout(()=>{t(!1),p(!1)},300)},[i,n,o,c,u]);return!m||!h?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(F,{size:`sm`,className:`px-1.5 text-xs`,onClick:v,children:m.data?.playing?_(`Next`):_(`New question`)}),(0,X.jsx)(F,{size:`sm`,className:`px-1.5 text-xs`,onClick:y,children:m.data?.playing?_(`Stop`):_(`Start`)}),(0,X.jsx)(F,{size:`sm`,className:`px-1.5 text-xs`,onClick:b,disabled:m.data?.playing,children:_(`Show score`)}),(0,X.jsxs)(ge,{open:e,onOpenChange:t,children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsx)(F,{size:`sm`,variant:`ghost`,color:`secondary`,className:`px-1.5 text-xs`,disabled:m.data?.playing,children:(0,X.jsx)(Nt,{className:`w-6 h-6`})})}),(0,X.jsxs)(De,{children:[(0,X.jsx)(V,{children:(0,X.jsx)(xe,{children:_(`Settings`)})}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(ue,{htmlFor:`time`,children:_(`Time`)}),(0,X.jsx)(cr,{id:`time`,className:`react-select`,classNamePrefix:`select`,value:x.find(e=>e.value===o),options:x,onChange:e=>{s(e?.value||`40`)}})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(ue,{htmlFor:`lives`,children:_(`Number of lives`)}),(0,X.jsx)(Pe,{id:`lives`,min:1,max:15,className:`w-full`,type:`number`,value:c,onValueChanged:e=>l(e)})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(Ve,{id:`fastest`,checked:i,onCheckedChange:e=>a(!!e),children:_(`Fastest winner?`)}),(0,X.jsx)(Ve,{id:`showPlayers`,checked:u,onCheckedChange:e=>d(!!e),children:_(`Show Players`)}),D.conversationEnabled&&(0,X.jsx)(Ve,{id:`chat`,checked:n,onCheckedChange:e=>r(!!e),children:_(`Activate the conversation`)})]}),(0,X.jsxs)(Ne,{children:[(0,X.jsx)(ce,{asChild:!0,children:(0,X.jsx)(F,{type:`button`,variant:`outline`,children:_(`Cancel`)})}),(0,X.jsx)(F,{type:`button`,onClick:S,disabled:f,children:_(f?`Updating...`:`Update`)})]})]})]})]})},lc=()=>{let{session:e,player:t,isHeaderVisible:n,toggleHeaderVisibility:r}=J(),{t:i}=W();return(0,X.jsxs)(`header`,{className:`relative`,children:[(0,X.jsx)(`button`,{onClick:r,className:q(`absolute z-10 left-5 transform -translate-x-1/2 bg-red-500 text-white rounded-b-md p-1 shadow-md flex items-center justify-center`,{}),style:{top:n?`auto`:`0`,bottom:n?`11px`:`auto`,transform:`translateX(-50%)`},children:n?(0,X.jsx)(Wt,{size:16}):(0,X.jsx)(_n,{size:16})}),(0,X.jsx)(`div`,{className:`bg-gradient py-2.5 2xl:py-4 transition-all duration-300 ease-in-out`,style:{maxHeight:n?`1000px`:`0`,overflow:`hidden`,opacity:+!!n,visibility:n?`visible`:`hidden`},children:(0,X.jsx)(`div`,{className:`max-w-10xl px-4 mx-auto 5xl:px-10`,children:(0,X.jsxs)(`div`,{className:`grid gap-y-1.5 sm:gap-y-1.5 grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 items-center md:text-lg 2xl:text-[22px] max-sm:[&>*]:col-span-full`,children:[(0,X.jsxs)(`div`,{className:`grid grid-flow-col max-sm:flex max-sm:flex-wrap max-sm:items-center max-sm:justify-between gap-4 sm:gap-2 4xl:gap-20 sm:place-content-start md:ltr:place-content-end header-right-block`,children:[(0,X.jsx)(`div`,{className:`min-w-10 md:min-w-14 2xl:min-w-20`,children:(0,X.jsxs)(d,{to:`/`,children:[(0,X.jsx)(`img`,{src:`/images/logo.png`,className:`h-9 grid sm:place-content-center dark:hidden`,alt:`logo`}),(0,X.jsx)(`img`,{src:`/images/logo-dark.png`,className:`h-9 hidden dark:grid dark:sm:place-content-center`,alt:`logo`})]})}),(0,X.jsxs)(`div`,{className:`text-[18px] sm:text-[26px] 2xl:text-3xl 4xl:text-5xl leading-none whitespace-nowrap`,children:[e.name,` `]}),(0,X.jsxs)(`div`,{className:` flex items-center justify-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-sm`,children:i(`Round: {{round}}`,{round:e.data?.round})}),(0,X.jsx)(Gr,{})]})]}),(0,X.jsx)(`div`,{className:`max-sm:flex max-sm:justify-between grid grid-flow-col items-center gap-1.5 md:gap-4 sm:place-content-end max-xl:col-span-1 max-xl:col-start-2 max-xl:row-start-1 md:place-content-end sm:ltr:place-content-start`,children:(0,X.jsx)(cc,{})})]})})}),(0,X.jsx)(`div`,{className:`max-w-10xl px-4 mx-auto 5xl:px-10`,children:(e.data?.showPlayers||t.host)&&(0,X.jsx)(`div`,{className:`relative select-none overflow-hiddenm mt-1`,children:(0,X.jsx)(kr,{})})})]})},uc=()=>{let[e,t]=(0,Y.useState)(!1),n=(0,Y.useRef)(null),{session:r,player:i,subscriptionClient:a,sendEvent:o,onSession:s}=J(),c=(0,Y.useRef)(null),l=(0,Y.useMemo)(()=>r?.data,[r?.data]),u=(0,Y.useMemo)(()=>
6{if(!l?.puzzle)return[];let e=i.round?.answers??[],t=[...l.puzzle.clues];if(!l.playing)return t;for(let n of e){let e=t.findIndex(e=>e.id===n.id);t[e]={...t[e],answer:n.answer}}return t},[l?.puzzle,l.playing,i.round]),d=(0,Y.useMemo)(()=>{if(!l?.puzzle)return[];let e=[...l.puzzle.syllables],t=i.round?.answers?.reduce((e,t)=>t.values?[...e,...t.values??[]]:e,[])??[];if(!l.playing)return e;let n=[...t];return e.filter(e=>!n.includes(e)||(n.splice(n.indexOf(e),1),!1))},[l?.puzzle,l.playing,i.round]),f=(0,Y.useCallback)(()=>{o(`END_TURN`)},[]),[p,{startTimer:m,stopTimer:h,resetTimer:g}]=Ti({countStart:60,intervalMs:1e3,finishCallback:f});(0,Y.useEffect)(()=>{l?.time&&(g(l.time),l.playing&&m())},[l?.time,l.playing,g]);let _=(0,Y.useCallback)((e,t)=>{o(e,t)},[]),v=(0,Y.useCallback)(e=>{let r=e;switch(r.type){case`NEW_CLUE`:r.puzzle&&(t(!1),s(e=>{let t=e.data;return setTimeout(()=>{g(t?.time??60),t.playing&&m()},0),{...e,data:{...e.data,puzzle:r.puzzle,startTime:-1,round:r.round}}}));break;case`START`:t(!1),s(e=>{let t=e.data;return setTimeout(()=>{g(t?.time??60),m()},0),{...e,data:{...e.data,puzzle:r.puzzle?r.puzzle:t.puzzle,startTime:r.startTime,round:r.round,playing:!0}}});break;case`STOP`:s(e=>{let t=e.data;return setTimeout(()=>{g(t?.time??60),h()},0),{...e,data:{...e.data,startTime:r.startTime,playing:!1}}}),t(!1)}if(i.id===r.player?.id&&((r.player?.loser||r.endGame)&&h(),r.wrong)){if(r.player?.lives<=0){n.current&&clearTimeout(n.current),t(!0);return}t(!0),n.current&&clearTimeout(n.current),n.current=window.setTimeout(()=>{r.player?.lives>0&&t(!1)},300)}},[i,s,g,m,h]);(0,Y.useEffect)(()=>{c.current=v},[v]),(0,Y.useEffect)(()=>{let e=l?.time??60;if(l?.playing){if(l?.startTime!==void 0&&l?.startTime!==-1){let t=Math.floor((l?.startTime+e*1e3-Date.now())/1e3);t>0?(g(t),m()):g(0)}return}g(e)},[l?.startTime,l?.playing,g,m]);let y=(0,Y.useCallback)(e=>{c.current&&c.current(e)},[]);return(0,Y.useEffect)(()=>(a.on([`NEW_CLUE`,`START`,`STOP`,`WRONG`,`CHECK_ANSWER`,`SHOW_ANSWERS`],y),()=>a.off([`NEW_CLUE`,`START`,`STOP`,`WRONG`,`CHECK_ANSWER`,`SHOW_ANSWERS`],y)),[a,y]),{wrong:e,time:p,model:l,clues:u,availableSyllables:d,checkAnswer:(0,Y.useCallback)(t=>{!l.puzzle||!l.playing||e||i.finish||_(`CHECK_ANSWER`,{syllables:t})},[l.puzzle,l.playing,i,e]),sendEvent:_}};function dc(e){return e.split(` `).map(e=>`•`.repeat(e.length)).join(` `)}var fc=(0,Y.memo)(({score:e})=>{let{t,userLanguage:n}=W(),r=(0,Y.useMemo)(()=>{if(n===`ar`){let e=`كفو عليك! جبتهم كلهم! 🔥.يا سلام! ما خليت ولا إجابة! 😎.مية مية! إنت موسوعة متنقلة! 📚.ولا غلطة! مستحيل عليك! 💯.فنان، شطرتك واضحة! 🎭.محترف! ما خليت لهم مجال! 🏆.إجاباتك مثل الرشاش! 🔫😂.خلصت السؤال بكل أريحية! 😌.أسطورة! جبتهم قبل الوقت! ⏳🔥.يا سلام عليك! إنت البطل بهاللعبة! 👑.كأنك قاري الكتاب قبل! 😂📖.مو طبيعي، عبقري بمعنى الكلمة! 🧠.هذا الأداء اللي ينحط في القواميس! 🔥.تحب تفوز؟ شكلك مولود للفوز! 😆.رقم واحد بدون منافس! 🚀.إجاباتك أسرع من البرق! ⚡.وين نوقع عقد الاحتراف؟ 😎.أعطييهم درس في الإجابات الصحيحة! 🎓.والله إنك صامل! كفو عليك! 🤜🤛.عشت! إنت مثال الذكاء! 🏅.إجاباتك سريعة ودقيقة، ما يحتاج! 🎯.مستوى خارق! حطوا اسمك في الصدارة! 🏆.ماكو مجال للمنافسة، مسيطر على الوضع! 🤩.شوفوا وتعلّموا من هالبطل! 📢.ختمتها بطريقة خرافية! 🔥.مرة ثانية؟ عادي، ما راح تخسر! 😂.حاط عينك على الجواب الصح دايماً! 👀.كل الإجابات عندك، صاير جوجل؟ 😂.السؤال اختفى قبل لا يفكرون بالإجاباة! ⚡.فزت وكسرت الرقم القياسي! 🚀🔥.يا معود، فزت؟ شكلك مسوي اتفاق مع اللعبة! 😂.خلاص، اعتزلت القمة؟ ولا تبي فوز ثاني؟ 😎.انت مو تلعب، انت تسحر اللعبة! 🪄🔥.فزت لدرجة المنافسين قاموا يعيدون حساباتهم! 🤯.عادي، فوزك صار متوقع! وين التحدي؟ 🤨.خلاص، بيعطونك لقب "ملك الإجابات"! 👑.دقيقة! خل أكلم الدعم الفني، لأنك كسرت اللعبة! 🤣.إنت أسرع من جوجل بالإجابات! 📲⚡.شنو هذا؟ فزت بدون ما تفكر حتى! 🧠💨.إذا فزت مرة ثانية، راح نحط اسمك شعار اللعبة! 🏆😂`.split(`.`);return e[Math.floor(Math.random()*e.length)]}return``},[n]);return(0,X.jsxs)(`div`,{className:`flex flex-col justify-center items-center mb-5 py-6 relative`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-r from-[#2ecc71]/20 to-[#27ae60
6]/20 animate-pulse`}),(0,X.jsx)(zn,{size:48,className:`text-yellow-400 mb-2 animate-bounce`}),(0,X.jsx)(`div`,{className:`bg-gradient-to-r from-[#2ecc71] to-[#27ae60] py-3 px-6 rounded-lg shadow-lg`,children:(0,X.jsx)(`span`,{className:`text-3xl font-bold`,children:t(`You won!`)})}),(0,X.jsx)(`div`,{className:`mt-3 text-2xl font-bold`,children:r}),(0,X.jsxs)(`div`,{className:`mt-3 text-xl`,children:[t(`Score`),`: `,(0,X.jsx)(`span`,{className:`font-bold text-yellow-400`,children:e})]}),(0,X.jsx)(`div`,{className:`absolute -left-10 top-0 w-20 h-20 bg-yellow-400/30 rounded-full blur-xl`}),(0,X.jsx)(`div`,{className:`absolute -right-10 bottom-0 w-20 h-20 bg-green-400/30 rounded-full blur-xl`})]})}),pc=(0,Y.memo)(({score:e})=>{let{t,userLanguage:n}=W(),r=(0,Y.useMemo)(()=>{if(n===`ar`){let e=`يلا يلا، باقي لك شوي! 😭,كنت قريب بس راحت عليك! 😩,آخ، نقصتك إجابة وحدة بس! 🤦,خسارة! بس حاول مره ثانية! 🔄,الحظ ما كان وياك هالمرة! 🍀💔,انت قريب من الفوز، جرب مرة ثانية! 🔄,يا ساتر، ضاع الفوز من يدك! 😢,قوية، باقي لك كم إجاباة بس! 🤏,اوف! سؤال صعب شوي، صح؟ 😅,لا تزعل، الكل يخسر مره! 🙃,كنت عالحافة، بس للأسف طحت! 🚶💨,عندك شوية نسيان اليوم؟ 😂,ضيعت فرصة الفوز، يلا الجاي أحسن! ✌️,الإجاباة كانت بجيبك وراحت! 🫠,نص الفوز ما يعتبر فوز! 😆,كانت سهلة، شفيك نسيت؟ 🤯,لازم تشغل مخك عدل المرة الياية! 🧠,الخطوة الجاية تفوز فيها إن شاء الله! 🙏,شرايك تتأكد من إجاباتك قبل لا ترسلها؟ 😂,انزين، عرفت غلطك؟ 😜,معقولة؟ جاوبت كل شي إلا وحدة! 😨,هاردلك، بس لا تفقد الأمل! 💪,ما يخالف، حاول مرة ثانية وأقوى! 🔥,يعني انت عارف الحل بس خانتك السرعة؟ 😆,المرة الياية راح تكسر اللعبة! 🏆,قربت بس قرب مو كفاية! 😂,مو نهاية العالم، بس خسرت! 😜,جرب تسوي ريماتش وتعوضها! ♻️,حسافة، كان فوزك مضمون! 😩,أنت تحتاج تدريب شوي، بس عندك الإمكانيات! 💡,اوف، حظك اليوم مثل شبكة الواي فاي، ضعيف! 📶💀,خسرت؟ لا تحاتي، الدنيا ما وقفت... يمكن! 😆,تعال، تعال، خل نعطيك دورة في الإجابات الصحيحة! 📚😂,شرايك تعيد الجولة؟ أو نخليها سر وننسى اللي صار؟ 😜,آه يا القهر! الإجاباة كانت تطالعك وتقول خذني! 😭,لا لا، اكيد في أحد فصل عليك النت! 🚨🤣,ولا يهمك، حتى الأبطال يخسرون... بس مو بهالطريقة! 😅,خسرت؟ حلو، عندك عذر تأكل شوكولاتة الحين! 🍫😂,لا تزعل، يمكن اللعبة فيها خطأ تقني ضدك! 🔧😜,خلاص، تأكدنا... الحظ مو صاحبك اليوم! 🚶💔`.split(`,`);return e[Math.floor(Math.random()*e.length)]}return``},[n]);return(0,X.jsxs)(`div`,{className:`flex flex-col justify-center items-center mb-5 py-6 relative`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-r from-[#e74c3c]/20 to-[#c0392b]/20 animate-pulse`}),(0,X.jsx)(br,{size:48,className:`text-red-400 mb-2 animate-pulse`}),(0,X.jsx)(`div`,{className:`bg-gradient-to-r from-[#e74c3c] to-[#c0392b] py-3 px-6 rounded-lg shadow-lg`,children:(0,X.jsx)(`span`,{className:`text-3xl font-bold`,children:t(`You lost!`)})}),(0,X.jsx)(`div`,{className:`mt-3 text-2xl font-bold`,children:r}),(0,X.jsxs)(`div`,{className:`mt-3 text-xl`,children:[t(`Score`),`: `,(0,X.jsx)(`span`,{className:`font-bold`,children:e})]}),(0,X.jsx)(`div`,{className:`absolute -left-10 top-0 w-20 h-20 bg-red-400/30 rounded-full blur-xl`}),(0,X.jsx)(`div`,{className:`absolute -right-10 bottom-0 w-20 h-20 bg-red-500/30 rounded-full blur-xl`})]})}),mc=(0,Y.memo)(()=>{let{t:e}=W();return(0,X.jsxs)(`div`,{className:`flex flex-col justify-center items-center mb-5 py-6 relative`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-r from-[#f1c40f]/20 to-[#f39c12]/20 animate-pulse`}),(0,X.jsx)(qt,{size:48,className:`text-yellow-400 mb-2 animate-spin-slow`}),(0,X.jsx)(`div`,{className:`bg-gradient-to-r from-[#f1c40f] to-[#f39c12] py-3 px-6 rounded-lg shadow-lg`,children:(0,X.jsx)(`span`,{className:`text-2xl font-bold`,children:e(`Waiting for host...`)})}),(0,X.jsx)(`div`,{className:`absolute -left-10 top-0 w-20 h-20 bg-yellow-400/30 rounded-full blur-xl`}),(0,X.jsx)(`div`,{className:`absolute -right-10 bottom-0 w-20 h-20 bg-orange-400/30 rounded-full blur-xl`})]})}),hc=(0,Y.memo)(({player:e,model:t})=>e.winner&&t.playing?(0,X.jsx)(fc,{score:e.score}):e.loser&&t.playing?(0,X.jsx)(pc,{score:e.score}):!e?.host&&!t.playing?(0,X.jsx)(mc,{}):null),gc=()=>{let{session:e,player:t,debug:n,sendEvent:r}=J(),[i,a]=(0,Y.useState)([]),{t:o}=W(),{time:s,model:c,wrong:l,clues:u,availableSyllables:d,checkAnswer:f}=uc(),{toast:p}=je(),[m,h]=Qe(),[g,_]=(0,Y.useState)([]),v=(0,Y.useCallback)(()=>{h(`${window.location.href}`).then(e=>{p(e?{title:o(`Copied`)}:{title:o(`Copy failed`)})})},[e]),y=()=>{f(i)},b=(0,Y.useMemo)(()=>t.host&&c.showAnswers||t.debug||n,[c.showAnswers,n,t.debug]),x=(e,t,n=!0)=>
6{if(n)a([...i,e]),_([...g,t]);else{let t=i.indexOf(e),n=[...i];n.splice(t,1),a(n);let r=d.indexOf(e);if(r!==-1){let e=g.filter(e=>e!==r);_(e)}}},S=()=>{u&&(a([]),_([]))};(0,Y.useEffect)(()=>{if(i.length===0&&g.length>0&&_([]),i.length>0&&i.length!==g.length){let e=i.map(e=>d.indexOf(e)).filter(e=>e!==-1);_(e)}},[i,d]),(0,Y.useEffect)(()=>{u&&(a([]),_([]))},[d]);let w=()=>{r(`OPTIONS`,{options:{showAnswers:!c.showAnswers}})};if(!c.puzzle)return(0,X.jsx)(`div`,{className:`flex justify-center items-center h-screen`,children:(0,X.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-blue-500`})});if(c.showScore)return(0,X.jsx)(Ci,{});let T=t.winner||t.loser||!c.playing||s===0,E=u?.every(e=>e.answer);return(0,X.jsxs)(K,{className:`p-5 mt-5 bg-[#6c669c]/90 text-white relative overflow-hidden ${l?`animate-shake`:``}`,children:[T&&(0,X.jsx)(hc,{player:t,model:c}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2 justify-between items-center mb-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center bg-[#423a80] py-1 px-4 h-9 rounded-md`,children:[(0,X.jsx)(`div`,{className:`bg-yellow-400 w-5 h-5 rounded-full ltr:mr-2 rtl:ml-2`}),(0,X.jsx)(`span`,{children:t.score})]}),(t.host||n)&&(0,X.jsx)(F,{size:`sm`,className:`px-1.5 text-xs bg-[#423a80] hover:bg-[#423a80]/80`,onClick:w,children:b?(0,X.jsx)(Mt,{color:`white`,size:24}):(0,X.jsx)(Pt,{color:`white`,size:24})}),c.showAnswers&&(0,X.jsx)(`span`,{className:`py-1 px-3 rounded-md ltr:mr-2 rtl:ml-2 bg-red-600 animate-pulse`,children:o(`The host is watching the answers.`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center`,children:[(0,X.jsx)(`span`,{className:`py-1 px-3 rounded-md ltr:mr-2 rtl:ml-2 ${l?`bg-red-600 animate-pulse`:`bg-[#e74c3c]`}`,children:Ur(s)}),(0,X.jsxs)(`div`,{className:`flex gap-1`,children:[Array(t.lives).fill(0).map((e,t)=>(0,X.jsx)(Pn,{size:24,className:`fill-[#e74c3c] stroke-[#e46759]`},t)),Array(c.lives-t.lives).fill(0).map((e,t)=>(0,X.jsx)($n,{size:24,className:`fill-[#e74c3c] stroke-[#e46759]  opacity-30`},t))]})]})]}),(0,X.jsx)(ke,{value:s/c.time*100,className:`rounded-none bg-[#6c669c]/90`,size:`sm`}),(0,X.jsx)(`div`,{className:q(`grid grid-cols-3 gap-2 mb-6`,!t?.host&&!c.playing&&`blur-sm pointer-events-none`),children:u.map((e,t)=>(0,X.jsx)(K,{className:q(`transition-all border-2 border-[#423a80] bg-slate-500/50 mt-4`,e.answer?`border-2 border-success bg-success/10`:``),children:(0,X.jsxs)(L,{className:`p-1 min-h-[120px] text-white flex flex-col items-center justify-between relative`,children:[(0,X.jsxs)(`span`,{className:`absolute bottom-0 right-2 text-xs`,children:[`#`,t+1]}),(0,X.jsx)(C,{className:`absolute -top-2 -left-1 text-xs px-1.5`,children:e.score}),(0,X.jsx)(`p`,{className:`text-sm sm:text-lg font-medium text-center mt-2`,children:e.text}),e.answer?(0,X.jsx)(`div`,{className:`text-sm sm:text-xl font-bold text-success mt-2`,children:e.answer}):(0,X.jsxs)(`div`,{className:`w-full text-center`,children:[(0,X.jsx)(`div`,{className:`text-sm sm:text-lg text-yellow-600 tracking-widest`,children:dc(e.correctAnswer)}),b&&(0,X.jsx)(`div`,{className:`text-orange-50 opacity-50 w-full`,children:e.correctAnswer})]})]})},e.id))}),!E&&(0,X.jsxs)(K,{className:` bg-slate-300/50`,children:[(0,X.jsxs)(L,{children:[(0,X.jsx)(`div`,{className:`min-h-[50px]  text-white border-2 border-dashed border-default-300 rounded-md flex flex-wrap items-center gap-2 justify-center mb-4`,children:i.map((e,t)=>(0,X.jsx)(F,{color:`secondary`,size:`xs`,onClick:()=>x(e,t,!1),className:`text-lg`,children:e},t))}),(0,X.jsx)(`div`,{className:q(`grid grid-cols-5 gap-2 w-auto`,!t?.host&&!c.playing&&`blur-sm pointer-events-none`),children:d.map((e,t)=>(0,X.jsx)(F,{className:`bg-[#6c669c] hover:bg-[#6c669c]/80  text-white`,size:`sm`,onClick:()=>x(e,t,!0),disabled:g.includes(t)||s===0,children:e},t))})]}),(0,X.jsxs)(Re,{className:`flex justify-center gap-4`,children:[(0,X.jsx)(F,{className:`bg-[#423a80] hover:bg-[#423a80]/80 text-white`,onClick:y,disabled:i.length===0||s===0,children:o(`Verify`)}),(0,X.jsx)(F,{color:`destructive`,variant:`outline`,onClick:S,disabled:i.length===0||s===0,children:o(`Reset`)})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`div`,{className:`text-xs`,children:o(`{{ index }}/{{ count }}`,{index:c.puzzle.index,count:c.puzzle.count})}),(0,X.jsx)(`div`,{onClick:v,className:`text-center mt-5`,children:window.location.href}),(0,X.jsx)(`div`,{})]}),l&&(0,X.jsx)(`div`,{className:`absolute inset-0 bg-red-500/20 pointer-events-none animate-flash`})]})},_c=e({config:()=>vc,default:()=>yc}),vc={menu:{order:0,exclude:!0},title:B(`Wit`)};function yc(){return(0,X.jsxs)(Br,{onSendEvent:sc,gameId:`wit`,children:[(0,X.jsx)(lc,{}),(0,X.jsx)(`main`,{className:`mx-auto px-4 score-card h-full w-full`,children:(0,X.jsx)(gc,{})}),(0,X.jsx)(zr,{})]})}var bc=()=>{let{t:e}=W(),{state:{rateLimits:t}}=pt(),[n,r]=(0,Y.useState)(new Set),i=()=>(0,X.jsx)(`div`,{className:`mb-8 p-6 bg-primary/5 border border-primary/10 rounded-2xl relative overflow-hidden`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-4 relative z-10`,children:[(0,X.jsx)(`div`,{className:`p-2 bg-primary/10 rounded-full shrink-0`,children:(0,X.jsx)(Tn,{className:`w-6 h-6 text-primary`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-lg font-bold text-foreground mb-2`,children:e(`About Games and Waiting Times`)}),(0,X.jsxs)(`div`,{className:`text-sm text-muted-foreground space-y-3 leading-relaxed`,children:[(0,X.jsxs)(`p`,{children:[(0,X.jsxs)(`span`,{className:`font-semibold text-foreground`,children:[e(`Games List`),`:`]}),` `,e(`This table shows all available games in the platform with their current status and waiting periods.`)]}),(0,X.jsxs)(`p`,{children:[(0,X.jsxs)(`span`,{className:`font-semibold text-foreground`,children:[e(`Waiting Time Explanation`),`:`]}),` `,e(`After creating a game, you must wait for the specified time period before you can create another game of the same type. If you reach your game creation limit according to your subscription plan, you must wait for the cooldown period to reset before creating new games.`)]})]})]})]})}),a=t=>
6{if(t===0)return e(`No waiting`);if(t<60)return`${t} ${e(`minutes`)}`;if(t<1440){let n=Math.floor(t/60),r=t%60;return r===0?`${n} ${e(n===1?`hour`:`hours`)}`:`${n} ${e(n===1?`hour`:`hours`)} ${r} ${e(`minutes`)}`}let n=Math.floor(t/1440),r=Math.floor(t%1440/60);return r===0?`${n} ${e(n===1?`day`:`days`)}`:`${n} ${e(n===1?`day`:`days`)} ${r} ${e(r===1?`hour`:`hours`)}`},o=ei.map(e=>{let n=t?.find(t=>t.gameId===e.id);return{...e,cooldownMinutes:n?.cooldownMinutes||0,active:n?.active??!0,description:n?.description||e.description}}),s=e=>{let t=new Set(n);t.has(e)?t.delete(e):t.add(e),r(t)};return(0,X.jsx)(K,{className:`border-none shadow-none bg-transparent`,children:(0,X.jsxs)(L,{className:`px-0`,children:[i(),(0,X.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:o.map(t=>{let r=n.has(t.id),i=e(t.description).trim(),o=i.length>120;return(0,X.jsxs)(`div`,{className:`group flex flex-col bg-card border border-border/50 rounded-xl overflow-hidden hover:shadow-md transition-all duration-300`,children:[(0,X.jsx)(`div`,{className:`p-4 border-b border-border/50 bg-muted/30 flex items-start justify-between gap-3`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsxs)(`div`,{className:`w-10 h-10 rounded-lg bg-background border border-border flex items-center justify-center shrink-0`,children:[(0,X.jsx)(`img`,{src:`/images/games/${t.id}.png`,alt:e(t.title),className:`w-8 h-8 object-cover rounded`,onError:e=>{e.currentTarget.style.display=`none`,e.currentTarget.parentElement?.classList.add(`bg-primary/10`)}}),(0,X.jsx)(wn,{className:`w-5 h-5 text-primary hidden`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`font-bold text-sm line-clamp-1`,children:e(t.title)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[t.beta&&(0,X.jsx)(C,{variant:`outline`,className:`text-[10px] h-4 px-1 bg-orange-50 text-orange-600 border-orange-200`,children:e(`Beta`)}),(0,X.jsxs)(`div`,{className:q(`flex items-center gap-1 text-[10px] font-medium px-1.5 py-0.5 rounded-full`,{"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":t.active,"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400":!t.active}),children:[(0,X.jsx)(`div`,{className:q(`w-1.5 h-1.5 rounded-full`,{"bg-green-600 dark:bg-green-400":t.active,"bg-red-600 dark:bg-red-400":!t.active})}),t.active?e(`Available`):e(`Unavailable`)]})]})]})]})}),(0,X.jsxs)(`div`,{className:`p-4 flex flex-col flex-1 gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between p-2.5 rounded-lg bg-secondary/50 border border-border/50`,children:[(0,X.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground flex items-center gap-1.5`,children:[(0,X.jsx)(qt,{size:14}),e(`Waiting Time`)]}),(0,X.jsx)(`span`,{className:`text-xs font-bold text-foreground`,children:a(t.cooldownMinutes)})]}),(0,X.jsxs)(`div`,{className:`flex-1`,children:[(0,X.jsx)(`p`,{className:q(`text-xs text-muted-foreground leading-relaxed`,!r&&o?`line-clamp-2`:``),children:i}),o&&(0,X.jsx)(`button`,{onClick:e=>{e.preventDefault(),s(t.id)},className:`flex items-center gap-1 text-xs text-primary hover:text-primary/80 transition-colors mt-2 font-medium`,children:r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Wt,{size:12}),e(`Show Less`)]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_n,{size:12}),e(`Read More`)]})})]})]})]},t.id)})})]})})},xc=e({config:()=>Sc,default:()=>Cc}),Sc={menu:{order:0},title:B(`Pricing Plans`)};function Cc(){return(0,X.jsxs)(`div`,{className:`md:pt-6 pb-[20px] pt-[15px] md:px-6 px-4`,children:[(0,X.jsx)(li,{}),(0,X.jsx)(bc,{})]})}var wc=e({config:()=>Tc,default:()=>Ec}),Tc={menu:{order:0,exclude:!0},title:B(`Payment Successful`)};function Ec(){let{t:e}=W();return(0,X.jsxs)(K,{className:`p-6 max-w-2xl mx-auto my-8`,children:[(0,X.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,X.jsx)(`div`,{className:`w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4`,children:(0,X.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`32`,height:`32`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`text-green-600`,children:[(0,X.jsx)(`path`,{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`}),(0,X.jsx)(`polyline`,{points:`22 4 12 14.01 9 11.01`})]})}),(0,X.jsx)(`h1`,{className:`text-2xl font-bold mb-2`,children:e(`Payment Successful`)}),(0,X.jsx)(`p`,{className:`text-gray-600 mb-4`,children:e(`Your payment has been processed successfully and your subscription plan has been activated.`)}),(0,X.jsx)(`p`,{className:`text-gray-600`,children:e(`You can now enjoy all the features included in your subscription plan.`)})]}),(0,X.jsxs)(`div`,{className:`flex justify-center gap-4`,children:[(0,X.jsx)(d,{to:`/games`,className:`px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors`,children:e(`Games`)}),(0,X.jsx)(d,{to:`/account?tab=subscriptions`,className:`px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors`,children:e(`View My Subscription`)})]})]})}var Dc=e({config:()=>Oc,default:()=>kc}),Oc={menu:{order:0,exclude:!0},title:B(`Payment Cancelled`)};function kc(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1),{id:o}=m(),{t:s}=W();return(0,Y.useEffect)(()=>{o&&(a(!0),et(Number(o)).then(e=>{e&&t(e)}).catch(()=>{r(s(`We couldn't load the transaction reference.`))}).finally(()=>{a(!1)}))},[o]),i?(0,X.jsx)(we,{}):(0,X.jsxs)(K,{className:`p-6 max-w-2xl mx-auto my-8`,children:[(0,X.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,X.jsx)(`div`,{className:`w-16 h-16 bg-yellow-100 rounded-full flex items-center justify-center mx-auto mb-4`,children:(0,X.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,
6width:`32`,height:`32`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`text-yellow-600`,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,X.jsx)(`line`,{x1:`8`,y1:`12`,x2:`16`,y2:`12`})]})}),(0,X.jsx)(`h1`,{className:`text-2xl font-bold mb-2`,children:s(`Payment Cancelled`)}),(0,X.jsx)(`p`,{className:`text-gray-600 mb-4`,children:s(`Your payment process has been cancelled and no charges have been made.`)}),(0,X.jsx)(`p`,{className:`text-gray-600`,children:s(`You can try again whenever you're ready.`)}),n&&(0,X.jsx)(`p`,{className:`text-sm text-destructive mt-4`,children:n}),e&&(0,X.jsxs)(`div`,{className:`bg-gray-100 p-4 rounded-md mb-4 mt-4`,children:[(0,X.jsx)(`p`,{className:`text-gray-700 mb-1 font-medium`,children:s(`Transaction Reference`)}),(0,X.jsx)(`p`,{className:`text-gray-800 font-mono bg-gray-200 p-2 rounded inline-block`,children:e}),(0,X.jsx)(`p`,{className:`text-gray-600 mt-2 text-sm`,children:s(`Please use this reference number when contacting customer support.`)})]})]}),(0,X.jsxs)(`div`,{className:`flex justify-center gap-4`,children:[(0,X.jsx)(d,{to:`/pricing`,className:`px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors`,children:s(`View Plans`)}),(0,X.jsx)(d,{to:`/`,className:`px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition-colors`,children:s(`Go to Homepage`)})]})]})}var Ac=e({config:()=>jc,default:()=>Mc}),jc={menu:{order:0,exclude:!0},title:B(`Payment Error`)};function Mc(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1),{id:o}=m(),{t:s}=W();return(0,Y.useEffect)(()=>{o&&(a(!0),et(Number(o)).then(e=>{e&&t(e)}).catch(()=>{r(s(`We couldn't load the transaction reference.`))}).finally(()=>{a(!1)}))},[o]),i?(0,X.jsx)(we,{}):(0,X.jsxs)(K,{className:`p-6 max-w-2xl mx-auto my-8`,children:[(0,X.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,X.jsx)(`div`,{className:`w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-4`,children:(0,X.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`32`,height:`32`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`text-red-600`,children:[(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,X.jsx)(`line`,{x1:`15`,y1:`9`,x2:`9`,y2:`15`}),(0,X.jsx)(`line`,{x1:`9`,y1:`9`,x2:`15`,y2:`15`})]})}),(0,X.jsx)(`h1`,{className:`text-2xl font-bold mb-2`,children:s(`Payment Error`)}),(0,X.jsx)(`p`,{className:`text-gray-600 mb-4`,children:s(`We encountered an error while processing your payment.`)}),(0,X.jsx)(`p`,{className:`text-gray-600 mb-4`,children:s(`This could be due to an incorrect payment information or a technical issue during the payment process.`)}),n&&(0,X.jsx)(`p`,{className:`text-sm text-destructive mb-4`,children:n}),e&&(0,X.jsxs)(`div`,{className:`bg-gray-100 p-4 rounded-md mb-4`,children:[(0,X.jsx)(`p`,{className:`text-gray-700 mb-1 font-medium`,children:s(`Transaction Reference`)}),(0,X.jsx)(`p`,{className:`text-gray-800 font-mono bg-gray-200 p-2 rounded inline-block`,children:e}),(0,X.jsx)(`p`,{className:`text-gray-600 mt-2 text-sm`,children:s(`Please use this reference number when contacting customer support.`)})]})]}),(0,X.jsxs)(`div`,{className:`flex justify-center gap-4`,children:[(0,X.jsx)(d,{to:`/pricing`,className:`px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors`,children:s(`Try Again`)}),(0,X.jsx)(d,{to:`/`,className:`px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition-colors`,children:s(`Go to Homepage`)})]})]})}var Nc=e({config:()=>Pc,default:()=>Fc}),Pc={menu:{order:0,exclude:!0},title:B(`Quiz`)};function Fc(){return(0,X.jsx)(ti,{gameId:`quiz`})}var Ic=function(e){return e.NONE=`NONE`,e.EASY=`EASY`,e.NORMAL=`NORMAL`,e.HARD=`HARD`,e}({}),Lc=function(e){return e.WRONG_QUESTION=`WRONG_QUESTION`,e.WRONG_ANSWER=`WRONG_ANSWER`,e.LANGUAGE_MISTAKE=`LANGUAGE_MISTAKE`,e.DUPLICATE=`DUPLICATE`,e.OTHER=`OTHER`,e}({}),Rc=function(e){return e.NORMAL=`NORMAL`,e.STEAL_POINTS=`STEAL_POINTS`,e.PENALTY=`PENALTY`,e}({}),zc=function(e){return e.BEFORE_QUESTION=`BEFORE_QUESTION`,e.DURING_QUESTION=`DUR
6ING_QUESTION`,e.BOTH=`BOTH`,e}({}),Bc=function(e){return e.CURRENT_TEAM_ONLY=`CURRENT_TEAM_ONLY`,e.ANY_TEAM=`ANY_TEAM`,e.OTHER_TEAMS_ONLY=`OTHER_TEAMS_ONLY`,e}({}),Vc=function(e){return e.IMMEDIATE=`IMMEDIATE`,e.MANUAL_CONFIRMATION=`MANUAL_CONFIRMATION`,e.TIMED=`TIMED`,e}({}),Hc=function(e){return e.OWNER_TEAM_ONLY=`OWNER_TEAM_ONLY`,e.ANY_CORRECT_TEAM=`ANY_CORRECT_TEAM`,e}({}),$=function(e){return e.SCORE_MULTIPLIER=`SCORE_MULTIPLIER`,e.OPPONENT_SCORE_DEDUCTION=`OPPONENT_SCORE_DEDUCTION`,e.REMOVE_WRONG_ANSWERS=`REMOVE_WRONG_ANSWERS`,e.ADD_TIME=`ADD_TIME`,e.FREEZE_TIMER=`FREEZE_TIMER`,e.LOCK_ANSWER_TO_CURRENT_TEAM=`LOCK_ANSWER_TO_CURRENT_TEAM`,e.BLOCK_OTHER_TEAMS_HELPERS=`BLOCK_OTHER_TEAMS_HELPERS`,e.TRANSFER_TURN_TO_OWNER_TEAM=`TRANSFER_TURN_TO_OWNER_TEAM`,e.REPLACE_QUESTION=`REPLACE_QUESTION`,e}({}),Uc=function(e){return e.DEFAULT=`DEFAULT`,e.DRAW=`DRAW`,e}({}),Wc=({className:e,label:t})=>(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,className:e,"aria-hidden":`true`,children:(0,X.jsx)(`text`,{x:`12`,y:`12`,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`22`,fontWeight:`900`,fontFamily:`ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial`,fill:`currentColor`,children:t})}),Gc=[{value:`phone`,label:`Phone`,icon:dn,aliases:[`callFriend`]},{value:`remove-two`,label:`Brain`,icon:wt,aliases:[`twoAnswers`]},{value:`red-card`,label:`Red Card`,icon:Qn,aliases:[`redCard`]},{value:`x2`,label:`Double`,icon:({className:e})=>(0,X.jsx)(Wc,{className:e,label:`2x`})},{value:`x3`,label:`Triple`,icon:({className:e})=>(0,X.jsx)(Wc,{className:e,label:`3x`})},{value:`x4`,label:`Quadruple`,icon:({className:e})=>(0,X.jsx)(Wc,{className:e,label:`4x`})},{value:`x5`,label:`Quintuple`,icon:({className:e})=>(0,X.jsx)(Wc,{className:e,label:`5x`})},{value:`x6`,label:`Sextuple`,icon:({className:e})=>(0,X.jsx)(Wc,{className:e,label:`6x`})},{value:`x7`,label:`Septuple`,icon:({className:e})=>(0,X.jsx)(Wc,{className:e,label:`7x`})},{value:`x8`,label:`Octuple`,icon:({className:e})=>(0,X.jsx)(Wc,{className:e,label:`8x`})},{value:`x9`,label:`Nonuple`,icon:({className:e})=>(0,X.jsx)(Wc,{className:e,label:`9x`})},{value:`x10`,label:`Decuple`,icon:({className:e})=>(0,X.jsx)(Wc,{className:e,label:`10x`})},{value:`shield`,label:`Shield`,icon:on},{value:`freeze`,label:`Freeze`,icon:hr},{value:`clock`,label:`Clock`,icon:an},{value:`sword`,label:`Sword`,icon:Nn},{value:`gift`,label:`Gift`,icon:gr},{value:`flame`,label:`Flame`,icon:At},{value:`crown`,label:`Crown`,icon:$t},{value:`target`,label:`Target`,icon:pr},{value:`zap`,label:`Zap`,icon:nr},{value:`refresh`,label:`Refresh`,icon:Ft},{value:`custom`,label:`Generic`,icon:yn},{value:`lock`,label:`Lock`,icon:Zn},{value:`replace`,label:`Replace`,icon:Jt},{value:`users`,label:`Users`,icon:Tt},{value:`x`,label:`X`,icon:Ut},{value:`heart`,label:`Heart`,icon:Pn},{value:`rotate`,label:`Rotate`,icon:Bn},{value:`settings`,label:`Settings`,icon:jt}],Kc=Gc.find(e=>e.value===`custom`),qc=e=>e?Gc.find(t=>t.value===e||`aliases`in t&&t.aliases?.some(t=>t===e))??Kc:Kc,Jc=e=>qc(e).icon,Yc=e({config:()=>Xc,default:()=>Ml}),Xc={menu:{order:0,exclude:!0},title:B(`Quiz`),loginRequired:!0},Zc=4,Qc=4,$c=15,el=15,tl=100,nl=2,rl=3,il=2,al=3,ol=[`callFriend`,`twoAnswers`,`replaceQuestion`,`redCard`,`x2`],sl=`quiz-custom-helpers`,cl=`quiz-selected-preset-helper-keys`,ll=`quiz-selected-custom-helper-keys`,ul=[`blue`,`rose`,`orange`,`purple`,`amber`,`emerald`,`fuchsia`,`yellow`,`teal`,`pink`,`cyan`,`violet`,`sky`,`slate`,`lime`,`indigo`],dl=[{key:`callFriend`,name:`Call a friend`,description:`Allow the current team to make a call and use the helper time to get an answer.`,duration:60,maxUses:1,availabilityStage:zc.DURING_QUESTION,teamAvailability:Bc.CURRENT_TEAM_ONLY,triggerMode:Vc.TIMED,effects:[],iconKey:`phone`},{key:`twoAnswers`,name:`Double answer`,description:`Double answer to the question.`,maxUses:1,availabilityStage:zc.DURING_QUESTION,teamAvailability:Bc.CURRENT_TEAM_ONLY,triggerMode:Vc.IMMEDIATE,effects:[],iconKey:`remove-two`},{key:`replaceQuestion`,name:`Replace question`,description:`Replace the question.`,maxUses:1,availabilityStage:zc.DURING_QUESTION,teamAvailability:Bc.CURRENT_TEAM_ONLY,triggerMode:Vc.IMMEDIATE,effects:[{type:$.REPLACE_QUESTION}],iconKey:`replace`},{key:`redCard`,name:`Red card`,description:`Answer correctly, and deduct the number of points you won from the other team's score.`,maxUses:1,availabilityStage:zc.BEFORE_QUESTION,teamAvailability:Bc.CURRENT_TEAM_ONLY,triggerMode:Vc.IMMEDIATE,effects:[{type:$.OPPONENT_SCORE_DEDUCTION,mode:`SAME_POINTS`}],iconKey:`red-card`},{key:`x2`,name:`Double Points`,description:`If you answer correctly, your points will be doubled.`,maxUses:1,availabilityStage:zc.BEFORE_QUESTION,teamAvailability:Bc.CURRENT_TEAM_ONLY,triggerMode:Vc.IMMEDIATE,effects:[{type:$.SCORE_MULTIPLIER,value:2,mode:Hc.OWNER_TEAM_ONLY}],iconKey:`x2`}
6],fl=[{value:zc.BEFORE_QUESTION,label:`Before Question`},{value:zc.DURING_QUESTION,label:`During Question`},{value:zc.BOTH,label:`Both`}],pl=[{value:Bc.CURRENT_TEAM_ONLY,label:`Current Team Only`},{value:Bc.ANY_TEAM,label:`Any Team`},{value:Bc.OTHER_TEAMS_ONLY,label:`Other Teams Only`}],ml=[{value:Hc.OWNER_TEAM_ONLY,label:`Only helper owner`},{value:Hc.ANY_CORRECT_TEAM,label:`Any correct team`}],hl=e=>e===zc.BEFORE_QUESTION||e===zc.BOTH,gl=e=>e===zc.DURING_QUESTION||e===zc.BOTH,_l=e=>{let t=0,n=0;for(let r of e)hl(r.availabilityStage)&&(t+=1),gl(r.availabilityStage)&&(n+=1);return{beforeQuestion:t,duringQuestion:n}},vl=(e,t)=>!e?.type||t!==Rc.STEAL_POINTS||e.type!==$.OPPONENT_SCORE_DEDUCTION,yl=(e,t)=>(e.effects??[]).every(e=>vl(e,t)),bl=(e,t,n)=>{let r=_l([...e,t]);return r.duringQuestion>Zc?n(`You can select at most {{count}} helpers during the question.`,{count:Zc}):r.beforeQuestion>Qc?n(`You can select at most {{count}} helpers before the question.`,{count:Qc}):null},xl=e=>e.toLowerCase().trim().replace(/[^\p{L}\p{N}]+/gu,`_`).replace(/^_+|_+$/g,``),Sl=(e,t)=>e.slice(0,t),Cl=(e,t)=>e.replace(/\D+/g,``).slice(0,t),wl=(e,t)=>{let n=xl(e)||`custom_helper`,r=`custom_${n}`,i=2;for(;t.has(r);)r=`custom_${n}_${i}`,i+=1;return r},Tl=e=>fl.find(t=>t.value===e)?.label??`During Question`,El=e=>pl.find(t=>t.value===e)?.label??`Current Team Only`,Dl=e=>{switch(e){case zc.BEFORE_QUESTION:return[on];case zc.BOTH:return[on,an];case zc.DURING_QUESTION:default:return[an]}},Ol=e=>{switch(e){case Bc.ANY_TEAM:return Tt;case Bc.OTHER_TEAMS_ONLY:return Nn;case Bc.CURRENT_TEAM_ONLY:default:return on}},kl={[$.SCORE_MULTIPLIER]:{label:`Score multiplier`,icon:nr,className:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-800/60 dark:bg-violet-950/30 dark:text-violet-300`},[$.OPPONENT_SCORE_DEDUCTION]:{label:`Opponent deduction`,icon:Nn,className:`border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-800/60 dark:bg-rose-950/30 dark:text-rose-300`},[$.LOCK_ANSWER_TO_CURRENT_TEAM]:{label:`Only current team can answer`,icon:on,className:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-300`},[$.BLOCK_OTHER_TEAMS_HELPERS]:{label:`Block other teams helpers`,icon:An,className:`border-red-200 bg-red-50 text-red-700 dark:border-red-800/60 dark:bg-red-950/30 dark:text-red-300`},[$.TRANSFER_TURN_TO_OWNER_TEAM]:{label:`Transfer turn to helper owner`,icon:rr,className:`border-indigo-200 bg-indigo-50 text-indigo-700 dark:border-indigo-800/60 dark:bg-indigo-950/30 dark:text-indigo-300`},[$.ADD_TIME]:{label:`Question timer bonus`,icon:an,className:`border-sky-200 bg-sky-50 text-sky-700 dark:border-sky-800/60 dark:bg-sky-950/30 dark:text-sky-300`},[$.FREEZE_TIMER]:{label:`Freeze question timer`,icon:hr,className:`border-cyan-200 bg-cyan-50 text-cyan-700 dark:border-cyan-800/60 dark:bg-cyan-950/30 dark:text-cyan-300`},[$.REPLACE_QUESTION]:{label:`Replace question`,icon:Ft,className:`border-orange-200 bg-orange-50 text-orange-700 dark:border-orange-800/60 dark:bg-orange-950/30 dark:text-orange-300`}},Al=e=>{let t=[],n=new Set;e.duration&&(t.push({key:`timer`,label:`Helper timer`,icon:an,className:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-300`}),n.add(`timer`));for(let r of e.effects??[]){let e=r.type;if(!e||n.has(e))continue;let i=kl[e];i&&(t.push({key:e,...i}),n.add(e))}if(t.length===0){let n=qc(e.iconKey??e.key);t.push({key:`default`,label:e.name??`Helpers`,icon:n.icon,className:`border-primary/20 bg-primary/5 text-primary dark:border-primary/30 dark:bg-primary/10`})}return t},jl=({options:e,onOptions:t,onCreate:n,onFilterServiceLevel:r})=>{let i=(0,Y.useRef)(!1),a=(0,Y.useRef)(!1),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(!0),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(null),[v,b]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(null),[T,D]=(0,Y.useState)(``),[O,k]=(0,Y.useState)(``),[A,j]=(0,Y.useState)(`1`),[N,I]=(0,Y.useState)(``),[ee,te]=(0,Y.useState)(zc.DURING_QUESTION),[B,ne]=(0,Y.useState)(Bc.CURRENT_TEAM_ONLY),[re,ie]=(0,Y.useState)(`custom`),[ae,oe]=(0,Y.useState)(!1),[se,ce]=(0,Y.useState)(`2`),[le,ue]=(0,Y.useState)(Hc.OWNER_TEAM_ONLY),[de,V]=(0,Y.useState)(!1),[fe,H]=(0,Y.useState)(!1),[U,pe]=(0,Y.useState)(!1),[me,he]=(0,Y.useState)(!1),[ge,_e]=(0,Y.useState)(!1),[ve,be]=(0,Y.useState)(`10`),[xe,Se]=(0,Y.useState)(!1),[Ce,we]=(0,Y.useState)(`5`),[Te,Ee]=(0,Y.useState)(!1),[De,ke]=Ye(sl,[]),[Ae,je]=Ye(cl,ol),[Me,Ne]=Ye(ll,[]),Fe=(0,Y.useMemo)(()=>De.filter(e=>
6e.key&&Me.includes(e.key)),[De,Me]);(0,Y.useEffect)(()=>{Te&&ee!==zc.DURING_QUESTION&&te(zc.DURING_QUESTION)},[ee,Te]);let{t:G}=W(),{hasServiceLevel:Ie,state:Le}=pt(),Re=(0,Y.useMemo)(()=>Ie(xt.ULTIMATE),[Ie]),ze=(0,Y.useMemo)(()=>!Ie(xt.PRO,xt.ULTIMATE),[Ie]);(0,Y.useEffect)(()=>{n(!((e.teams||[]).length>=2))},[n,e.categories?.length,e.teams?.length]),(0,Y.useEffect)(()=>{if(!i.current){if(e.enabledHelperKeys!==void 0&&e.customHelpers!==void 0){i.current=!0;return}i.current=!0,t({...e,enabledHelperKeys:e.enabledHelperKeys??Ae,customHelpers:e.customHelpers??Fe})}},[t,e,Fe,Ae]);let Be=()=>{ze||l(e=>!e)},Ve=()=>{d(e=>!e)},Ue=()=>{p(e=>!e)};(0,Y.useEffect)(()=>{Le.user?.id!==1||a.current||(a.current=!0,t({...e,hardcore:!1,scoringMode:Rc.NORMAL,free:!1,teams:[{name:`Team 1`,color:`blue`},{name:`Team 2`,color:`indigo`}],enabledHelperKeys:Ae,customHelpers:Fe}))},[t,e,Fe,Ae,Le.user?.id]);let We=()=>{if(o.trim()===``)return;let n=e.teams||[];if(ze&&n.length>=6)return;let r=n[n.length-1]?.color||``,i=(ul.indexOf(r)+1)%ul.length;t({...e,teams:[...n,{name:Sl(o.trim(),$c),color:ul[i]}]}),s(``)},Ge=n=>{let r=e.teams||[];r.splice(n,1),t({...e,teams:[...r]})},Ke=e=>{s(Sl(e.target.value,$c))},qe=(n,r)=>{let i=e.teams||[];i[n].color=r,t({...e,teams:[...i]})},Je=e=>{e.key===`Enter`&&(e.preventDefault(),We())},Xe=(e.teams||[]).length>=2,Ze=e.teams||[],Qe=e.scoringMode??Rc.NORMAL,$e=g??Qe,et=e.enabledHelperKeys??Ae,tt=e.customHelpers??Fe,nt=(0,Y.useMemo)(()=>[{mode:Rc.NORMAL,name:`Normal`,imageSrc:`/images/quiz/normal-scoring.png`,description:`Each correct answer adds points to your team.`},{mode:Rc.STEAL_POINTS,name:`Steal Points`,imageSrc:`/images/quiz/steal-points-scoring.png`,description:`Correct answers add points to your team and subtract the same points from the other team.`},{mode:Rc.PENALTY,name:`Penalty`,imageSrc:`/images/quiz/penalty-scoring.png`,description:`Wrong answers subtract points from your team.`}],[]),rt=(0,Y.useMemo)(()=>nt.find(e=>e.mode===$e)?.description,[$e,nt]),it=(0,Y.useMemo)(()=>[{key:`hardcore`,name:`Auto Reveal Answer`,imageSrc:`/images/quiz/answer-displayed.png`,description:`If enabled, the answer will be displayed automatically to all players.`,enabled:!!e.hardcore,disabled:!1},{key:`free`,name:`Free selection of categories`,imageSrc:`/images/quiz/free-categories-duplicate.png`,description:`If this option is enabled, you can freely select categories. If the number of selected categories is less than six, the selected categories will be duplicated equally.`,enabled:!!e.free,disabled:!Re}],[Re,e.free,e.hardcore]),at=(0,Y.useMemo)(()=>it.find(e=>e.key===v)?.description??null,[v,it]),ot=(0,Y.useMemo)(()=>dl.filter(e=>e.key&&et.includes(e.key)),[et]),st=(0,Y.useMemo)(()=>[...dl,...De],[De]),ct=(0,Y.useMemo)(()=>[...ot,...tt],[tt,ot]),lt=(0,Y.useMemo)(()=>_l(ct),[ct]);(0,Y.useEffect)(()=>{let n=et.filter(e=>{let t=dl.find(t=>t.key===e);return t?yl(t,Qe):!1}),r=tt.filter(e=>yl(e,Qe));(n.length!==et.length||r.length!==tt.length)&&(je(n),Ne(r.map(e=>e.key).filter(e=>!!e)),t({...e,enabledHelperKeys:n,customHelpers:r}),S(`Some helpers were removed because they are not supported by the selected scoring mode.`))},[t,e,tt,et,Qe]);let ut=()=>{D(``),k(``),j(`1`),I(``),te(zc.DURING_QUESTION),ne(Bc.CURRENT_TEAM_ONLY),ie(`custom`),oe(!1),ce(`2`),ue(Hc.OWNER_TEAM_ONLY),V(!1),H(!1),pe(!1),he(!1),_e(!1),be(`10`),Se(!1),we(`5`),Ee(!1)},dt=n=>{if(!n.key)return;if(S(null),dl.some(e=>e.key===n.key)){if(et.includes(n.key)){let r=et.filter(e=>e!==n.key);je(r),t({...e,enabledHelperKeys:r});return}if(!yl(n,Qe)){S(`This helper is not supported by the selected scoring mode.`);return}let r=bl(ct,n,G);if(r){S(r);return}t({...e,enabledHelperKeys:[...et,n.key]}),je([...et,n.key]);return}if(tt.some(e=>e.key===n.key)){let r=tt.filter(e=>e.key!==n.key);Ne(r.map(e=>e.key).filter(e=>!!e)),t({...e,customHelpers:r});return}if(!yl(n,Qe)){S(`This helper is not supported by the selected scoring mode.`);return}let r=bl(ct,n,G);if(r){S(r);return}Ne([...tt.map(e=>e.key).filter(e=>!!e),n.key]),t({...e,customHelpers:[...tt,n]})},ft=n=>{n&&(S(null),ke(e=>e.filter(e=>e.key!==n)),Ne(e=>e.filter(e=>e!==n)),t({...e,customHelpers:tt.filter(e=>e.key!==n)}))};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 animate-fadeIn p-3 mb-5`,children:[ze&&(0,X.jsxs)(`div`,{className:`bg-primary/5 border border-primary/10 rounded-lg p-4 text-center`,children:[(0,X.jsx)(`h3`,{className:`text-base sm:text-lg font-semibold mb-2`,children:G(`This game is not available for your current subscription level`)}),(0,X.jsx)(`p`,{className:`text-xs sm:text-sm text-muted-foreground mb-3`,children:G(`This game is exclusively available for "PRO" and "ULTIMATE" subscribers only`)}),(0,X.jsx)(F,{color:`primary`,className:`animate-pulse`,size:`xs`,onClick:()=>r(xt.PRO,xt.ULTIMATE),children:G(`Upgrade Subscription Now`)})]}),(0,X.jsxs)(K,{className:q(`bg-card/80 border-primary/20 shadow-lg`,ze&&`bg-muted/80`),children:[(0,X.jsxs)(R,{className:q(`pb-2 flex flex-row justify-between gap-2`,!ze&&`cursor-pointer`),onClick:Be,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 text-base sm:text-lg`,children:[(0,X.jsx)(Tt,{className:q(`h-6 w-6`,ze?`text-muted-foreground`:`text-primary animate-pulse`)}),(0,X.jsx)(`span`,{className:q(ze&&`text-muted-foreground`),children:G(`Participating Teams`)}
6)]}),ze?(0,X.jsx)(`div`,{className:`bg-muted-foreground/20 text-muted-foreground text-[10px] sm:text-xs px-2 py-1 rounded-md`,children:G(`Premium Feature`)}):c?(0,X.jsx)(tr,{className:`w-4 h-4`}):(0,X.jsx)(Cr,{className:`w-4 h-4`})]}),c&&(0,X.jsx)(L,{children:(0,X.jsxs)(`div`,{className:`mb-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,X.jsx)(Pe,{value:o,onChange:Ke,onKeyDown:Je,maxLength:$c,placeholder:G(`Enter team name`),className:`flex-1`}),(0,X.jsx)(F,{onClick:We,size:`sm`,className:`h-9 px-3 text-xs sm:text-sm`,disabled:o.trim()===``||ze&&Ze.length>=6,children:G(`Add`)})]}),ze&&Ze.length>=6&&(0,X.jsxs)(M,{color:`warning`,className:`mb-2`,children:[(0,X.jsx)(It,{className:`h-4 w-4`}),(0,X.jsx)(ye,{children:G(`You've reached the maximum number of teams ({{count}}) for your current plan`,{count:6})})]}),!Xe&&(0,X.jsxs)(M,{color:`info`,className:`mb-2`,children:[(0,X.jsx)(It,{className:`h-4 w-4`}),(0,X.jsx)(ye,{children:G(`You need at least {{count}} teams to start the game`,{count:2})})]}),Ze.length>0?(0,X.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 mt-4`,children:Ze.map((e,t)=>(0,X.jsxs)(`div`,{className:q(`text-xs text-white flex items-center justify-between gap-1 px-1 py-1 rounded-md transition-all duration-200`,Ir(e.color||`indigo`)),children:[(0,X.jsx)(`span`,{children:e.name}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(mi,{onClick:e=>qe(t,e),colors:ul}),(0,X.jsx)(F,{variant:`ghost`,size:`sm`,className:`h-7 w-7 sm:h-8 sm:w-8 p-0 text-white`,onClick:()=>Ge(t),children:(0,X.jsx)(Ut,{className:`h-4 w-4`})})]})]},t))}):(0,X.jsx)(`div`,{className:`text-center text-muted-foreground py-4`,children:G(`No teams added yet`)})]})})]}),(0,X.jsxs)(K,{className:`bg-card/80 border-primary/20 shadow-lg`,children:[(0,X.jsxs)(R,{className:`pb-2 flex flex-row justify-between gap-2 cursor-pointer`,onClick:Ve,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 text-base sm:text-lg`,children:[(0,X.jsx)(xr,{className:`h-6 w-6 text-primary`}),(0,X.jsx)(`span`,{children:G(`Game Options`)})]}),u?(0,X.jsx)(tr,{className:`w-4 h-4`}):(0,X.jsx)(Cr,{className:`w-4 h-4`})]}),u&&(0,X.jsxs)(L,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 sm:gap-4`,role:`group`,"aria-label":G(`Game Options`),onMouseLeave:()=>b(null),children:[it.map(n=>{let r=n.enabled;return(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:n.disabled,className:q(`group relative bg-transparent p-0 flex flex-col items-center`,`rounded-2xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2`,n.disabled&&`opacity-50 cursor-not-allowed`),onMouseEnter:()=>b(n.key),onFocus:()=>b(n.key),onBlur:()=>b(null),onClick:()=>{if(n.key===`hardcore`){t({...e,hardcore:!e.hardcore});return}if(n.key===`free`){if(!Re)return;t({...e,free:!e.free})}},children:[(0,X.jsxs)(`div`,{className:q(`relative transition-transform duration-200 ease-out`,!n.disabled&&`group-hover:scale-[1.06] active:scale-[0.98]`,r&&`scale-[1.06]`,r?`drop-shadow-[0_0_18px_rgba(59,130,246,0.55)]`:`drop-shadow-[0_0_14px_rgba(0,0,0,0.25)] group-hover:drop-shadow-[0_0_18px_rgba(59,130,246,0.35)]`),children:[(0,X.jsx)(`img`,{src:n.imageSrc,alt:n.name,className:q(`select-none object-contain`,`h-14 w-14 sm:h-16 sm:w-16`),draggable:!1}),r&&(0,X.jsx)(`div`,{className:`absolute top-1 ltr:right-1 rtl:left-1`,children:(0,X.jsx)(`div`,{className:`h-4 w-4 sm:h-5 sm:w-5 rounded-full bg-primary text-primary-foreground shadow-sm flex items-center justify-center`,children:(0,X.jsx)(gn,{className:`h-2.5 w-2.5 sm:h-3 sm:w-3`})})})]}),(0,X.jsx)(`div`,{className:`mt-1 text-[10px] sm:text-xs font-semibold text-center text-foreground/90 leading-tight`,children:G(n.name)})]},n.key)}),!Re&&(0,X.jsx)(`div`,{className:`flex items-center`,children:(0,X.jsx)(F,{color:`primary`,className:`animate-pulse h-7 px-2 text-xs`,size:`xs`,onClick:()=>r(xt.ULTIMATE),children:G(`Upgrade to Ultimate Plan`)})})]}),(0,X.jsx)(`div`,{className:`mt-2 text-[11px] sm:text-xs text-muted-foreground min-h-[2.50rem]`,children:at?G(at):null}),(0,X.jsx)(`div`,{className:`mt-4 text-xs sm:text-sm font-medium`,children:G(`Scoring Mode`)}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap items-start gap-3 sm:gap-4`,role:`radiogroup`,"aria-label":G(`Scoring Mode`),onMouseLeave:()=>_(null),children:nt.map(n=>{let r=Qe===n.mode;return(0,X.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,className:q(`group relative bg-transparent p-0 flex flex-col items-center`,`w-14 sm:w-16`,`rounded-2xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2`),onMouseEnter:()=>_(n.mode),onFocus:()=>_(n.mode),onBlur:()=>_(null),onClick:()=>{S(null),t({...e,scoringMode:n.mode})},children:[(0,X.jsxs)(`div`,{className:q(`relative transition-transform duration-200 ease-out`,`group-hover:scale-[1.06] active:scale-[0.98]`,r&&`scale-[1.06]`,r?`drop-shadow-[0_0_18px_rgba(59,130,246,0.55)]`:`drop-shadow-[0_0_14px_rgba(0,0,0,0.25)] group-hover:drop-shadow-[0_0_18px_rgba(59,130,246,0.35)]`),children:[(0,X.jsx)(`img`,{src:n.imageSrc,alt:n.name,className:q(`select-none object-contain`,`h-14 w-14 sm:h-16 sm:w-16`),draggable:!1}),r&&(0,X.jsx)(`div`,{className:`absolute top-1 ltr:right-1 rtl:left-1`,children:(0,X.jsx)(`div`,{className:`h-4 w-4 sm:h-5 sm:w-5 rounded-full bg-primary text-primary-foreground shadow-sm flex items-center justify-center`,children:(0,X.jsx)(gn,{className:`h-2.5 w-2.5 sm:h-3 sm:w-3`})})})]}),(0,X.jsx)(`div`,{className:`mt-1 text-[10px] sm:text-xs font-semibold text-center text-foreground
6/90 leading-tight`,children:G(n.name)})]},n.mode)})}),(0,X.jsx)(`div`,{className:`mt-2 text-[11px] sm:text-xs text-muted-foreground min-h-[2.50rem]`,children:rt?G(rt):null})]})]}),(0,X.jsxs)(K,{className:`bg-card/80 border-primary/20 shadow-lg`,children:[(0,X.jsxs)(R,{className:`pb-2 flex flex-col sm:flex-row sm:items-center justify-between gap-3 cursor-pointer`,onClick:Ue,children:[(0,X.jsxs)(w,{className:`flex items-center gap-2 text-base sm:text-lg`,children:[(0,X.jsx)(jt,{className:`h-6 w-6 text-primary`}),(0,X.jsx)(`span`,{children:G(`Helpers`)})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 self-end sm:self-auto`,children:[(0,X.jsx)(Oe,{text:`${G(`During question limit`)}: ${Zc}`,children:(0,X.jsxs)(C,{variant:`outline`,className:`gap-1.5 border-amber-300 bg-amber-50 text-amber-700 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-300`,children:[(0,X.jsx)(an,{className:`h-3.5 w-3.5`}),lt.duringQuestion]})}),(0,X.jsx)(Oe,{text:`${G(`Before question limit`)}: ${Qc}`,children:(0,X.jsxs)(C,{variant:`outline`,className:`gap-1.5 border-sky-300 bg-sky-50 text-sky-700 dark:border-sky-800/60 dark:bg-sky-950/30 dark:text-sky-300`,children:[(0,X.jsx)(on,{className:`h-3.5 w-3.5`}),lt.beforeQuestion]})}),f?(0,X.jsx)(tr,{className:`w-4 h-4`}):(0,X.jsx)(Cr,{className:`w-4 h-4`})]})]}),f&&(0,X.jsxs)(L,{className:`space-y-5 text-start`,children:[x&&(0,X.jsxs)(M,{color:`warning`,children:[(0,X.jsx)(It,{className:`h-4 w-4`}),(0,X.jsx)(ye,{children:G(x)})]}),(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:st.map(e=>{let t=e.key??``,n=qc(e.iconKey??e.key),r=Al(e),i=Dl(e.availabilityStage),a=dl.some(e=>e.key===t),o=a?et.includes(t):tt.some(e=>e.key===t),s=yl(e,Qe),c=Tl(e.availabilityStage),l=El(e.teamAvailability),u=Ol(e.teamAvailability);return(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:()=>dt(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),dt(e))},className:q(`flex h-full flex-col rounded-2xl border p-4 text-start transition-all duration-200`,o?`border-primary bg-primary/5 shadow-sm shadow-primary/10`:`border-border hover:border-primary/40 hover:bg-primary/[0.04]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2`,!s&&`opacity-50`),children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl border border-primary/15 bg-primary/[0.08] text-primary dark:border-primary/20 dark:bg-primary/10`,children:(0,X.jsx)(n.icon,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:(0,X.jsx)(`div`,{className:`font-semibold`,children:G(e.name??t)})}),(0,X.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:G(e.description??`Helper configuration`)})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[o&&(0,X.jsx)(`div`,{className:`rounded-full bg-primary text-primary-foreground p-1`,children:(0,X.jsx)(gn,{className:`h-3 w-3`})}),a?null:(0,X.jsx)(F,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:e=>{e.preventDefault(),e.stopPropagation(),ft(t)},children:(0,X.jsx)(Ut,{className:`h-3.5 w-3.5`})})]})]}),(0,X.jsxs)(`div`,{className:`mt-auto pt-4 flex flex-wrap items-center gap-2`,children:[r.map(e=>(0,X.jsx)(Oe,{text:G(e.label),children:(0,X.jsx)(`div`,{className:q(`flex h-9 min-w-9 items-center justify-center rounded-xl border px-2 transition-transform duration-200 hover:scale-105`,e.className),title:G(e.label),children:(0,X.jsx)(e.icon,{className:`h-4 w-4`})})},e.key)),(0,X.jsx)(Oe,{text:G(c),children:(0,X.jsx)(`div`,{className:`flex h-9 min-w-9 items-center justify-center gap-1 rounded-xl border border-border/70 bg-background/70 px-2 transition-transform duration-200 hover:scale-105`,title:G(c),children:i.map((e,n)=>(0,X.jsx)(e,{className:`h-3.5 w-3.5`},`${t}-stage-${n}`))})}),(0,X.jsx)(Oe,{text:G(l),children:(0,X.jsx)(`div`,{className:`flex h-9 min-w-9 items-center justify-center gap-1 rounded-xl border border-border/70 bg-background/70 px-2 transition-transform duration-200 hover:scale-105`,title:G
6(l),children:(0,X.jsx)(u,{className:`h-3.5 w-3.5`})})}),(0,X.jsx)(Oe,{text:G(`Max uses`),children:(0,X.jsxs)(`div`,{className:`flex h-9 min-w-9 items-center justify-center gap-1 rounded-xl border border-border/70 bg-background/70 px-2 transition-transform duration-200 hover:scale-105`,title:G(`Max uses`),children:[(0,X.jsx)(Bn,{className:`h-3.5 w-3.5`}),(0,X.jsx)(`span`,{className:`text-xs font-medium`,children:e.maxUses??1})]})}),e.duration?(0,X.jsx)(Oe,{text:G(`Timer`),children:(0,X.jsxs)(`div`,{className:`flex h-9 min-w-9 items-center justify-center gap-1 rounded-xl border border-border/70 bg-background/70 px-2 transition-transform duration-200 hover:scale-105`,title:G(`Timer`),children:[(0,X.jsx)(an,{className:`h-3.5 w-3.5`}),(0,X.jsxs)(`span`,{className:`text-xs font-medium`,children:[e.duration,`s`]})]})}):null,s?null:(0,X.jsx)(Oe,{text:G(`Not supported in this scoring mode`),children:(0,X.jsx)(`div`,{className:`flex h-9 min-w-9 items-center justify-center rounded-xl border border-destructive/30 bg-destructive/5 px-2 text-destructive transition-transform duration-200 hover:scale-105`,title:G(`Not supported in this scoring mode`),children:(0,X.jsx)(It,{className:`h-4 w-4`})})})]})]},t)})}),(0,X.jsx)(`div`,{className:`flex justify-end`,children:Re?(0,X.jsx)(F,{size:`sm`,variant:`outline`,onClick:()=>h(e=>!e),children:G(m?`Cancel`:`Add`)}):(0,X.jsx)(F,{color:`primary`,className:`animate-pulse h-7 px-2 text-xs`,size:`xs`,onClick:()=>r(xt.ULTIMATE),children:G(`Upgrade to Ultimate Plan`)})})]}),Re&&m&&(0,X.jsxs)(`div`,{className:`rounded-2xl border border-primary/20 bg-primary/[0.03] p-4 space-y-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-sm font-semibold`,children:G(`Add Custom Helper`)}),(0,X.jsxs)(C,{variant:`outline`,className:`w-fit gap-1.5 border-primary/30 bg-primary/5 text-primary`,children:[(0,X.jsx)(on,{className:`h-3.5 w-3.5`}),G(`Saved in local storage on this device only.`)]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium`,children:G(`Helper name`)}),(0,X.jsx)(Pe,{value:T,onChange:e=>D(Sl(e.target.value,el)),maxLength:el,placeholder:G(`Example: Power Attack`)})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium`,children:G(`Description`)}),(0,X.jsx)(Pe,{value:O,onChange:e=>k(Sl(e.target.value,tl)),maxLength:tl,placeholder:G(`Optional helper description`)})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium`,children:G(`Availability stage`)}),(0,X.jsxs)(P,{value:ee,onValueChange:e=>te(e),disabled:Te,children:[(0,X.jsx)(z,{children:(0,X.jsx)(E,{})}),(0,X.jsx)(He,{children:fl.map(e=>(0,X.jsx)(y,{value:e.value,children:G(e.label)},e.value))})]}),Te?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:G(`Replace question can only be used during the question.`)}):null]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium`,children:G(`Team availability`)}),(0,X.jsxs)(P,{value:B,onValueChange:e=>ne(e),disabled:me||U,children:[(0,X.jsx)(z,{children:(0,X.jsx)(E,{})}),(0,X.jsx)(He,{children:pl.map(e=>(0,X.jsx)(y,{value:e.value,children:G(e.label)},e.value))})]}),me||U?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:G(`This effect requires other teams only.`)}):null]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium`,children:G(`Icon`)}),(0,X.jsx)(`div`,{className:`flex gap-2 overflow-x-auto pb-1`,children:Gc.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>ie(e.value),className:q(`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl border transition-colors`,re===e.value?`border-primary bg-primary/10 text-primary`:`border-border bg-background hover:border-primary/40 hover:bg-primary/5`),"aria-label":G(e.label),children:(0,X.jsx)(e.icon,{className:`h-4 w-4`})},e.value))})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium`,children:G(`Max uses`)}),(0,X.jsx)(Pe,{type:`number`,min:1,value:A,inputMode:`numeric`,onChange:e=>j(Cl(e.target.value,nl))})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium`,children:G(`Helper timer duration in seconds`)}),(0,X.jsx)(Pe,{type:`number`,min:1,value:N,inputMode:`numeric`,onChange:e=>I(Cl(e.target.value,rl)),placeholder:G(`Leave empty for no helper timer`)})]})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium`,children:G(`Effects`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-2`,children:[(0,X.jsxs)(F,{type:`button`,size:`sm`,variant:ae?`default`:`outline`,onClick:()=>oe(e=>!e),className:`justify-start gap-2`,children:[(0,X.jsx)(nr,{className:`h-4 w-4`}),G(`Score multiplier`)]}),(0,X.jsxs)(F,{type:`button`,size:`sm`,variant:de?`default`:`outline`,onClick:()=>V(e=>!e),disabled:!vl({type:$.OPPONENT_SCORE_DEDUCTION},Qe),className:`justify-start gap-2`,children:[(0,X.jsx)(Nn,{className:`h-4 w-4`}),G(`Opponent deduction`)]}),(0,X.jsxs)(F,{type:`button`,size:`sm`,variant:fe?`default`:`outline`,onClick:()=>H(e=>!e),className:`justify-start gap-2`,children:[(0,X.jsx)(on,{className:`h-4 w-4 shrink-0`}
6),G(`Current team only`)]}),(0,X.jsxs)(F,{type:`button`,size:`sm`,variant:U?`default`:`outline`,onClick:()=>pe(e=>!e),className:`justify-start gap-2`,children:[(0,X.jsx)(An,{className:`h-4 w-4`}),G(`Block other teams helpers`)]}),(0,X.jsxs)(F,{type:`button`,size:`sm`,variant:me?`default`:`outline`,onClick:()=>he(e=>!e),className:`justify-start gap-2`,children:[(0,X.jsx)(rr,{className:`h-4 w-4`}),G(`Transfer turn to helper owner`)]}),(0,X.jsxs)(F,{type:`button`,size:`sm`,variant:ge?`default`:`outline`,onClick:()=>_e(e=>!e),className:`justify-start gap-2`,children:[(0,X.jsx)(an,{className:`h-4 w-4`}),G(`Question timer bonus`)]}),(0,X.jsxs)(F,{type:`button`,size:`sm`,variant:xe?`default`:`outline`,onClick:()=>Se(e=>!e),className:`justify-start gap-2`,children:[(0,X.jsx)(hr,{className:`h-4 w-4`}),G(`Freeze question timer`)]}),(0,X.jsxs)(F,{type:`button`,size:`sm`,variant:Te?`default`:`outline`,onClick:()=>Ee(e=>!e),className:`justify-start gap-2`,children:[(0,X.jsx)(Ft,{className:`h-4 w-4`}),G(`Replace question`)]})]})]}),ae&&(0,X.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium`,children:G(`Multiplier value`)}),(0,X.jsx)(Pe,{type:`number`,min:2,value:se,inputMode:`numeric`,onChange:e=>ce(Cl(e.target.value,il))})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium`,children:G(`Multiplier target`)}),(0,X.jsxs)(P,{value:le,onValueChange:e=>ue(e),children:[(0,X.jsx)(z,{children:(0,X.jsx)(E,{})}),(0,X.jsx)(He,{children:ml.map(e=>(0,X.jsx)(y,{value:e.value,children:G(e.label)},e.value))})]})]})]}),ge&&(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium`,children:G(`Question timer bonus in seconds`)}),(0,X.jsx)(Pe,{type:`number`,min:1,value:ve,inputMode:`numeric`,onChange:e=>be(Cl(e.target.value,al))})]}),xe&&(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium`,children:G(`Freeze question timer for seconds`)}),(0,X.jsx)(Pe,{type:`number`,min:1,value:Ce,inputMode:`numeric`,onChange:e=>we(Cl(e.target.value,al))})]}),(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsxs)(F,{size:`sm`,onClick:()=>{S(null);let e=T.trim();if(!e){S(`Custom helper name is required.`);return}let t=Number.parseInt(A,10);if(!Number.isFinite(t)||t<1){S(`Max uses must be at least 1.`);return}let n=N.trim()===``?void 0:Number.parseInt(N,10);if(n!==void 0&&(!Number.isFinite(n)||n<1)){S(`Duration must be a positive number.`);return}let r=[];if(ae){let e=Number.parseInt(se,10);if(!Number.isFinite(e)||e<2){S(`Score multiplier must be at least 2.`);return}r.push({type:$.SCORE_MULTIPLIER,value:e,mode:le})}if(de){if(!vl({type:$.OPPONENT_SCORE_DEDUCTION},Qe)){S(`Opponent deduction is not allowed with Steal Points scoring mode.`);return}r.push({type:$.OPPONENT_SCORE_DEDUCTION,mode:`SAME_POINTS`})}if(fe&&r.push({type:$.LOCK_ANSWER_TO_CURRENT_TEAM}),U&&r.push({type:$.BLOCK_OTHER_TEAMS_HELPERS}),me&&r.push({type:$.TRANSFER_TURN_TO_OWNER_TEAM}),ge){let e=Number.parseInt(ve,10);if(!Number.isFinite(e)||e<1){S(`Question timer bonus must be a positive number.`);return}r.push({type:$.ADD_TIME,value:e})}if(xe){let e=Number.parseInt(Ce,10);if(!Number.isFinite(e)||e<1){S(`Freeze timer seconds must be a positive number.`);return}r.push({type:$.FREEZE_TIMER,value:e})}Te&&r.push({type:$.REPLACE_QUESTION});let i={key:wl(e,new Set([...dl,...De].map(e=>e.key).filter(e=>!!e))),name:e,description:O.trim().slice(0,tl)||void 0,duration:n,maxUses:t,availabilityStage:Te?zc.DURING_QUESTION:ee,teamAvailability:me||U?Bc.OTHER_TEAMS_ONLY:B,triggerMode:n?Vc.TIMED:Vc.IMMEDIATE,effects:r,iconKey:re},a=bl(ct,i,G);if(a){S(a);return}ke(e=>[...e,i]),ut(),h(!1)},children:[(0,X.jsx)(yn,{className:`h-4 w-4 ltr:mr-2 rtl:ml-2`}),G(`Save Helper`)]})})]})]})]})]})};function Ml(){return(0,X.jsx)(ui,{gameId:`quiz`,linkPrefix:`q`,title:`Quiz`,size:`2xl`,checkLimits:!0,GameCreateForm:jl})}async function Nl(e){return st.call(`CategoryEndpoint`,`clearAllQuestions`,{},e)}async function Pl(e,t){return st.call(`CategoryEndpoint`,`clearQuestionsForCategory`,{categoryId:e},t)}async function Fl(e,t){return st.call(`QuizEndpoint`,`getCategories`,{roomId:e},t)}async function Il(e,t){return st.call(`QuizEndpoint`,`getData`,{roomId:e},t)}async function Ll(e,t){return st.fluxConnection.send(`QuizEndpoint`,`send`,{roomId:e,request:t})}async function Rl(e,t,n){return st.call(`QuizEndpoint`,`startGame`,{roomId:e,playerId:t},n)}var zl=(e,t)=>
6{if(t)return e?.helpers?.find(e=>e.helperKey===t)},Bl=(e,t)=>{if(t)return e?.find(e=>e.key===t)},Vl=(e,t)=>{let n=e.availabilityStage??zc.DURING_QUESTION;return n===zc.BOTH?!0:t?n===zc.DURING_QUESTION:n===zc.BEFORE_QUESTION},Hl=(e,t)=>{switch(e.teamAvailability??Bc.CURRENT_TEAM_ONLY){case Bc.ANY_TEAM:return!0;case Bc.OTHER_TEAMS_ONLY:return!t;case Bc.CURRENT_TEAM_ONLY:default:return t}},Ul=(e,t)=>!!e?.effects?.some(e=>e.type===t),Wl=e=>e?e.duration||e.triggerMode===Vc.TIMED||e.triggerMode===Vc.MANUAL_CONFIRMATION?!0:!!e.effects?.some(e=>e?.type?[$.SCORE_MULTIPLIER,$.OPPONENT_SCORE_DEDUCTION,$.LOCK_ANSWER_TO_CURRENT_TEAM,$.BLOCK_OTHER_TEAMS_HELPERS].includes(e.type):!1):!1,Gl=(e,t,n,r)=>!e?.active||!n?!1:Wl(n)?!0:Ul(t,$.BLOCK_OTHER_TEAMS_HELPERS)&&e.teamId!==r,Kl=(e,t)=>e?.effects?.find(e=>e.type===t),ql=(e,t)=>{let n=Kl(e,t)?.value;return typeof n==`number`?n:void 0},Jl=e=>e?.key?e.name??e.key:e?.name??``,Yl=e=>e?.key?e.description??Jl(e):e?.description??``,Xl=e=>Jc(e?.iconKey??e?.key),Zl=(e,t)=>{if(t)return`opacity-50 grayscale`;switch(e?.key){case`callFriend`:return`bg-green-100 hover:bg-green-200 text-green-600 dark:bg-green-900/30 dark:hover:bg-green-900/50 dark:text-green-400 border border-green-200 dark:border-green-800`;case`twoAnswers`:return`bg-yellow-100 hover:bg-yellow-200 text-yellow-600 dark:bg-yellow-900/30 dark:hover:bg-yellow-900/50 dark:text-yellow-400 border border-yellow-200 dark:border-yellow-800`;case`redCard`:return`bg-red-100 hover:bg-red-200 text-red-600 dark:bg-red-900/30 dark:hover:bg-red-900/50 dark:text-red-400 border border-red-200 dark:border-red-800`;case`x2`:return`bg-violet-100 hover:bg-violet-200 text-violet-700 dark:bg-violet-900/30 dark:hover:bg-violet-900/50 dark:text-violet-300 border border-violet-200 dark:border-violet-800`;default:return`bg-sky-100 hover:bg-sky-200 text-sky-700 dark:bg-sky-900/30 dark:hover:bg-sky-900/50 dark:text-sky-300 border border-sky-200 dark:border-sky-800`}},Ql=e=>!!e?.runtimeData?.confirmed,$l=(e,t)=>{let n=e?.runtimeData?.duration;
6return typeof n==`number`?n:t?.duration??60},eu=(e,t)=>{let n=$l(e,t);if(!Ql(e))return n;let r=e?.startedAt;if(typeof r!=`number`||Number.isNaN(r))return n;let i=Math.max(0,Math.floor((Date.now()-r)/1e3));return Math.max(0,n-i)},tu=(0,Y.createContext)(null),nu=({children:e})=>{let[t,n]=(0,Y.useState)(`default`),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)({}),{session:s,subscriptionClient:c,sendEvent:l,onSession:u}=J(),d=(0,Y.useMemo)(()=>s?.data,[s?.data]),[f,p]=(0,Y.useState)(d.questions||[]),[m,h]=(0,Y.useState)(d.teams||[]),[g,_]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{p(d.questions||[]),h(d.teams||[]),_(d.teamHelper||null)},[d]);let v=(0,Y.useMemo)(()=>m.find(e=>e.id===d.turn)||m[0],[m,d.turn]),y=(0,Y.useMemo)(()=>f.find(e=>e.id===d.questionId)||null,[f,d.questionId]),b=(0,Y.useMemo)(()=>d.gameEnded||!1,[d.gameEnded]),x=(0,Y.useCallback)(e=>{let t=e;switch(t.type){case`SELECT_CATEGORIES`:case`SELECT_CATEGORY`:case`REMOVE_CATEGORY`:u(e=>{if(!e)return e;let n=e.data;return{...e,data:{...n,categories:t.categories}}});break;case`END_GAME`:u(e=>{if(!e)return e;let n=e.data;return{...e,data:{...n,drawState:t.drawState??t.data?.drawState??null,gameEnded:!0}}});break;case`START_GAME`:u(e=>{if(!e)return e;let t=e.data;return{...e,data:{...t,gameEnded:!1}}});break;case`USE_HELPER`:t.questionId&&o(e=>({...e,[t.questionId]:(e[t.questionId]??0)+1})),_(t.teamHelper??null),u(e=>{if(!e)return e;let n=e.data,r=t.data;return{...e,data:{...n,questions:r?.questions??n.questions,questionId:t.questionId??r?.questionId??n.questionId,turn:r?.turn??n.turn,helperUsages:t.helperUsages??r?.helperUsages??n.helperUsages,teams:r?.teams??n.teams.map(e=>t.team?.id&&e.id===t.team.id?{...e,...t.team}:e),teamHelper:t.teamHelper??r?.teamHelper??null}}});break;case`CALL_FRIEND`:case`START_HELPER_TIMER`:if(!t.teamHelper)return;_(t.teamHelper),u(e=>{if(!e)return e;let n=e.data;return{...e,data:{...n,teamHelper:t.teamHelper}}});break;case`AWARD_POINTS`:t.team?.id&&i(t.team.id),_(null),u(e=>({...e,data:{...e.data,turn:t.teamId,teams:t.teams?t.teams:e.data.teams.map(e=>t.team&&e.id===t.team.id?{...e,...t.team}:e),questions:e.data.questions.map(e=>e.id===t.questionId?{...e,answered:!0,teamAnswered:t?.noOneAnswered?null:t?.team?.id}:e),teamHelper:null,drawState:t.drawState??t.data?.drawState??null,questionId:null,gameEnded:t.gameEnded?t.gameEnded:!1}}));break;case`CANCEL_QUESTION`:_(null),u(e=>({...e,data:{...e.data,drawState:t.drawState??t.data?.drawState??null,helperUsages:t.helperUsages?t.helperUsages:e.data.helperUsages,teams:t.teams?t.teams:e.data.teams.map(e=>t.team?.id&&e.id===t.team.id?{...e,...t.team}:e),questionId:null,teamHelper:null}}));break;case`SELECT_QUESTION`:u(e=>({...e,data:{...e.data,questionId:t.questionId,drawState:t.drawState??t.data?.drawState??null}}));break;case`SELECT_PLAYER`:u(e=>{if(!e)return e;let n=e.data,r=t.data;return{...e,data:{...n,drawState:t.drawState??r?.drawState??null}}});break;case`TURN`:u(e=>{if(!e)return e;let n=e.data;return{...e,data:{...n,turn:t.teamId}}});break;case`UPDATE_SCORE`:u(e=>{if(!e)return e;let n=e.data,r=n.teams,a=r.find(e=>e.id===t.teamId),o=r.map(e=>e.id===t.teamId?{...e,score:t.score}:e);if(a&&a.id){if(t.score>=(a.score||0))i(a.id||null);else{let e=o.reduce((e,t)=>(e.score||0)>(t.score||0)?e:t);(e.score||0)===0?i(null):i(e.id||null)}}return{...e,data:{...n,teams:o}}})}},[u]);(0,Y.useEffect)(()=>(c.on(x),()=>{c.off(x)}),[c,x]);let S=(0,Y.useCallback)((e,t={})=>{l(e,t)},[l]),C=(0,Y.useCallback)(e=>{b||S(`CHANGE_TEAM`,{teamId:e})},[]),w=(0,Y.useCallback)(e=>{b||S(`CHANGE_TEAM`,{teamId:`-1`,targetPlayerId:e})},[]),T=(0,Y.useCallback)(()=>{b||S(`TOGGLE_SPECTATOR`)},[]),E=(0,Y.useCallback)(e=>{b||S(`REMOVE_SPECTATOR`,{targetPlayerId:e})},[]),D=(0,Y.useCallback)(()=>{b||S(`TURN`)},[m]),O=(0,Y.useCallback)(e=>{p(e)},[]),k=(0,Y.useCallback)(e=>{p(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?t:(t[n]=e,[...t])})},[]),A=(0,Y.useCallback)(e=>{o(t=>({...t,[e]:(t[e]??0)+1}))},[]),j=(0,Y.useCallback)(e=>{n(e)},[]),M=(0,Y.useCallback)(()=>{S(`END_GAME`)},[]),N=(0,Y.useCallback)(e=>{S(`SELECT_QUESTION`,{questionId:e.id})},[]),P=(0,Y.useCallback)(e=>{S(`AWARD_POINTS`,{teamId:e||void 0,noOneAnswered:e===null})},[]),F=(0,Y.useCallback)((e,t=50,n=!1)=>{S(`UPDATE_SCORE`,{teamId:e,amount:t,isDecrease:n})},[]),I=(0,Y.useCallback)(e=>{_(t=>t===null?t:{...t,runtimeData:{...t.runtimeData??{},duration:e}})},[]),L=(0,Y.useCallback)((e,t)=>{let n=Bl(d.availableHelpers,t),r=Bl(d.availableHelpers,g?.helperKey),i=m.find(t=>
6t.id===e),a=zl(i?.helperDetails,t);if(!n||!a||!i)return!1;let o=e===v.id,s=!!y;if(!Hl(n,o)||!Vl(n,s))return!1;let c=a.maxUses??n.maxUses??1;return(a.usedCount??0)>=c||Gl(g,r,n,e)?!1:(S(`USE_HELPER`,{helperKey:t,helperType:t,teamId:e,questionId:y?.id}),!0)},[d.availableHelpers,y,y?.id,S,v,g,m]),ee=(0,Y.useMemo)(()=>({model:d,questions:f,teams:m,teamHelpers:g,team:v,categories:d.categories,theme:t,selectedQuestion:y,isGameEnded:b,attacker:r,mediaReloadKeyByQuestionId:a,reloadQuestionMedia:A,changeTheme:j,updateQuestions:O,updateQuestion:k,changeTeam:C,removePlayerFromTeam:w,toggleSpectator:T,removeSpectator:E,nextTeam:D,endGame:M,selectQuestion:N,awardPoints:P,increaseOrDecreaseScore:F,useHelperAction:L,updateHelperTimer:I,sendEvent:S}),[d,r,b,y,v,t,g,P,D,f,m,L,a,A]);return(0,X.jsx)(tu.Provider,{value:ee,children:e})},ru=()=>{let e=(0,Y.useContext)(tu);if(!e)throw Error(`useQuiz must be used within QuizProvider`);return e},iu=Zt(q(`inline-flex items-center justify-center text-sm font-semibold ring-offset-background focus-visible:outline-none focus-visible:ring-0   disabled:opacity-50  whitespace-nowrap disabled:pointer-events-none`,`relative overflow-hidden shadow-md hover:shadow-xl group`,`bg-gradient-to-r`),{variants:{color:{red:`from-red-400 to-red-600 hover:from-red-500 hover:to-red-700 dark:from-red-600 dark:to-red-800 dark:hover:from-red-700 dark:hover:to-red-900`,orange:`from-orange-400 to-orange-600 hover:from-orange-500 hover:to-orange-700 dark:from-orange-600 dark:to-orange-800 dark:hover:from-orange-700 dark:hover:to-orange-900`,yellow:`from-yellow-400 to-yellow-600 hover:from-yellow-500 hover:to-yellow-700 dark:from-yellow-600 dark:to-yellow-800 dark:hover:from-yellow-700 dark:hover:to-yellow-900`,green:`from-green-400 to-green-600 hover:from-green-500 hover:to-green-700 dark:from-green-600 dark:to-green-800 dark:hover:from-green-700 dark:hover:to-green-900`,rose:`from-rose-400 to-rose-600 hover:from-rose-500 hover:to-rose-700 dark:from-rose-600 dar
6k:to-rose-800 dark:hover:from-rose-700 dark:hover:to-rose-900`,gray:`from-gray-400 to-gray-600 hover:from-gray-500 hover:to-gray-700 dark:from-gray-600 dark:to-gray-800 dark:hover:from-gray-700 dark:hover:to-gray-900`,blue:`from-blue-400 to-blue-600 hover:from-blue-500 hover:to-blue-700 dark:from-blue-600 dark:to-blue-800 dark:hover:from-blue-700 dark:hover:to-blue-900`},transition:{default:`transition-colors`,scale:`transition-all duration-300 transform hover:scale-110 hover:rotate-1`},variant:{default:`rounded-md`,left:`ltr:rounded-bl-2xl rtl:rounded-br-2xl ltr:rounded-tl-2xl rtl:rounded-tr-2xl`,right:`ltr:rounded-br-2xl rtl:rounded-bl-2xl ltr:rounded-tr-2xl rtl:rounded-tl-2xl`,none:`rounded-none`},size:{sm:`h-9 px-3`,lg:`h-11 px-[18px] py-[10px] text-base`,xl:`h-12 px-6 py-3 text-base`,md:`h-9 px-4 py-2`,xs:`h-9 px-[14px] py-[6px]`}},compoundVariants:[{variant:`left`},{variant:`right`},{variant:`none`}],defaultVariants:{color:`blue`,size:`md`,variant:`default`,transition:`default`}}),au=(0,Y.forwardRef)(({className:e,variant:t,size:n,color:r,transition:i,effect:a=!1,asChild:o=!1,children:s,...c},l)=>(0,X.jsxs)(o?Mn:`button`,{className:q(iu({variant:t,size:n,color:r,transition:i,className:e})),ref:l,...c,children:[a&&(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-r from-transparent via-white/30 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-700 pointer-events-none`}),s]}));au.displayName=`Button`;var ou={[Ic.NONE]:0,[Ic.EASY]:1,[Ic.NORMAL]:2,[Ic.HARD]:3},su=(0,Y.memo)(({category:e,teamQuestions:t,teamNameById:n,onSelectQuestion:r,color:i})=>{let a=e=>{switch(e){case Ic.EASY:return`green`;case Ic.NORMAL:return`yellow`;case Ic.HARD:return`red`;default:return`blue`}},o=e=>n.get(e),s=(0,Y.useMemo)(()=>[...t[0]].sort((e,t)=>ou[e.difficulty]-ou[t.difficulty]),[t]),c=(0,Y.useMemo)(()=>[...t[1]].sort((e,t)=>ou[e.difficulty]-ou[t.difficulty]),[t]);return(0,X.jsx)(`div`,{className:`flex w-full aspect-[4/3] sm:aspect-[4/3] xl:aspect-[16/7] [@media(orientation:landscape)_and_(max-width:1024px)]:aspect-[16/5]`,children:(0,X.jsxs)(`div`,{className:`flex w-full h-full relative overflow-hidden rounded-xl shadow-lg bg-gradient-to-br from-slate-50 to-slate-100 dark:from-slate-800 dark:to-slate-900 border-2 border-primary/30`,children:[(0,X.jsx)(`div`,{className:`w-1/3 flex flex-col gap-1 p-1 sm:p-2 ltr:pr-0 rtl:pl-0 relative z-10 [@media(orientation:landscape)_and_(max-width:1024px)]:grid [@media(orientation:landscape)_and_(max-width:1024px)]:grid-rows-3 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-0.5 [@media(orientation:landscape)_and_(max-width:1024px)]:p-1`,children:s.map(e=>(0,X.jsxs)(`div`,{className:`flex-1 flex relative h-full [@media(orientation:landscape)_and_(max-width:1024px)]:h-full [@media(orientation:landscape)_and_(max-width:1024px)]:min-h-0`,children:[e.teamAnswered&&(0,X.jsx)(`span`,{className:`text-red-500 drop-shadow-sm text-xs absolute top-1 left-2 [@media(orientation:landscape)_and_(max-width:1024px)]:top-0.5 [@media(orientation:landscape)_and_(max-width:1024px)]:left-0.5 [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px]`,children:o(e.teamAnswered)}),(0,X.jsx)(au,{variant:`left`,color:i||a(e.difficulty),className:q(`flex-1 text-xs sm:text-sm md:text-base lg:text-lg font-bold font-philosopher min-h-[28px] sm:min-h-[32px] md:min-h-[36px] h-full [@media(orientation:landscape)_and_(max-width:1024px)]:h-full [@media(orientation:landscape)_and_(max-width:1024px)]:min-h-0 [@media(orientation:landscape)_and_(max-width:1024px)]:px-1 [@media(orientation:landscape)_and_(max-width:1024px)]:py-0 [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px] [@media(orientation:landscape)_and_(max-width:1024px)]:leading-none`,e.answered?`opacity-30 grayscale cursor-not-allowed`:void 0,`border-2 border-white/20 backdrop-blur-sm shadow-none hover:shadow-none`),effect:!1,onClick:()=>{e.answered||r(e)},disabled:e.answered,children:(0,X.jsx)(`div`,{className:`flex items-center justify-center gap-1 relative z-10`,children:(0,X.jsx)(`span`,{className:`text-white drop-shadow-lg text-xs sm:text-sm md:text-base lg:text-lg [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px]`,children:e.points})})})]},e.id))}),(0,X.jsx)(`div`,{className:`relative w-1/3 flex items-center justify-center`,children:(0,X.jsx)(`div`,{className:`w-full h-full overflow-hidden relative`,children:(0,X.jsxs)(`div`,{className:`h-full flex flex-col relative`,children:[e.image&&(0,X.jsxs)(`div`,{className:`h-[75%] w-full overflow-hidden relative flex items-center justify-center [@media(orientation:landscape)_and_(max-width:1024px)]:h-auto [@media(orientation:landscape)_and_(max-width:1024px)]:flex-1`,children:[(0,X.jsx)(`img`,{src:e.image?.url,alt:e.name,className:`w-full h-full object-contain object-center max-h-[160px] filter brightness-110 contrast-110 [@media(orientation:landscape)_and_(max-width:1024px)]:max-h-[64px]`,loading:`lazy`}),(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-t from-black/20 via-trans
6parent to-transparent`})]}),!e.image&&(0,X.jsx)(`div`,{className:`h-[75%] w-full bg-gradient-to-br from-primary/20 to-secondary/20 flex items-center justify-center`,children:(0,X.jsx)(`div`,{className:`text-3xl opacity-30`,children:(0,X.jsx)(yn,{className:`w-10 h-10`})})}),(0,X.jsx)(`div`,{className:`h-[25%] min-h-[32px] sm:min-h-[36px] flex justify-center items-center bg-gradient-to-r from-via-sky-700 to-secondary border-t-2 via-sky-600/20 relative overflow-hidden [@media(orientation:landscape)_and_(max-width:1024px)]:h-[42%] [@media(orientation:landscape)_and_(max-width:1024px)]:min-h-[22px]`,children:(0,X.jsx)(`span`,{className:`text-xs sm:text-sm md:text-base lg:text-lg text-center font-bold font-zain p-1 sm:p-1.5 max-w-full via-sky-900 drop-shadow-lg relative z-10 leading-tight [@media(orientation:landscape)_and_(max-width:1024px)]:p-0.5 [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px]`,children:e.name})})]})})}),(0,X.jsx)(`div`,{className:`w-1/3 flex flex-col gap-1 p-1 sm:p-2 ltr:pl-0 rtl:pr-0 relative z-10 [@media(orientation:landscape)_and_(max-width:1024px)]:grid [@media(orientation:landscape)_and_(max-width:1024px)]:grid-rows-3 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-0.5 [@media(orientation:landscape)_and_(max-width:1024px)]:p-1`,children:c.map(e=>(0,X.jsxs)(`div`,{className:`flex-1 flex relative h-full [@media(orientation:landscape)_and_(max-width:1024px)]:h-full [@media(orientation:landscape)_and_(max-width:1024px)]:min-h-0`,children:[e.teamAnswered&&(0,X.jsx)(`span`,{className:`text-red-500 drop-shadow-sm text-xs absolute top-1 right-2 [@media(orientation:landscape)_and_(max-width:1024px)]:top-0.5 [@media(orientation:landscape)_and_(max-width:1024px)]:right-0.5 [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px]`,children:o(e.teamAnswered)}),(0,X.jsx)(au,{variant:`right`,color:i||a(e.difficulty),className:q(`flex-1 text-xs sm:text-sm md:text-base lg:text-lg font-bold font-philosopher min-h-[28px] sm:min-h-[32px] md:min-h-[36px] h-full [@media(orientation:landscape)_and_(max-width:1024px)]:h-full [@media(orientation:landscape)_and_(max-width:1024px)]:min-h-0 [@media(orientation:landscape)_and_(max-width:1024px)]:px-1 [@media(orientation:landscape)_and_(max-width:1024px)]:py-0 [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px] [@media(orientation:landscape)_and_(max-width:1024px)]:leading-none`,e.answered?`opacity-30 grayscale cursor-not-allowed`:void 0,`border-2 border-white/20 backdrop-blur-sm shadow-none hover:shadow-none`),effect:!1,onClick:()=>{e.answered||r(e)},disabled:e.answered,children:(0,X.jsx)(`div`,{className:`flex items-center justify-center gap-1 relative z-10`,children:(0,X.jsx)(`span`,{className:`text-white drop-shadow-lg text-xs sm:text-sm md:text-base lg:text-lg [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px]`,children:e.points})})})]},e.id))})]})})}),cu=(0,Y.memo)(({value:e,durationMs:t=450})=>{let[n,r]=(0,Y.useState)(e),i=(0,Y.useRef)(e),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null),s=(0,Y.useRef)(e),c=(0,Y.useRef)(e);return(0,Y.useEffect)(()=>{if(typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches){s.current=e,c.current=e,i.current=e,r(e);return}let n=i.current,l=e;if(n===l)return;a.current&&=(cancelAnimationFrame(a.current),null),o.current=null,s.current=n,c.current=l;let u=e=>1-(1-e)**3,d=e=>{o.current===null&&(o.current=e);let n=e-o.current,l=Math.min(1,n/t),f=u(l),p=s.current+(c.current-s.current)*f,m=c.current>=s.current?Math.floor(p):Math.ceil(p);i.current=m,r(m),l<1?a.current=requestAnimationFrame(d):(a.current=null,i.current=c.current,r(c.current))};return a.current=requestAnimationFrame(d),()=>{a.current&&=(cancelAnimationFrame(a.current),null)}},[t,e]),(0,X.jsx)(X.Fragment,{children:n})});cu.displayName=`AnimatedNumber`;var lu=()=>{let{teams:e,attacker:t,removePlayerFromTeam:n,removeSpectator:r,toggleSpectator:i}=ru(),{players:a,player:o}=J(),{t:s}=W(),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),m=(0,Y.useMemo)(()=>{let e=new Map;for(let t of a||[]){let n=t.teamId;n&&e.set(n,(e.get(n)||0)+1)}return e},[a]),h=(0,Y.useMemo)(()=>{let e=0;for(let t of a||[])t.spectator&&e++;return e},[a]),g=(0,Y.useMemo)(()=>{let e=[];for(let t of a||[])t.spectator&&e.push(t);return e},[a]),_=(0,Y.useMemo)(()=>
6{if(!e||e.length===0)return[];let t=e.map(e=>e.score||0),n=Math.min(...t),r=t.map(e=>n<0?e-n:e),i=Math.max(...r);return i<=0?e.map(e=>({...e,score:e.score||0,visibilityScore:1})):e.map((e,t)=>{let n=e.score||0,a=(r[t]??0)/i;return{...e,score:n,visibilityScore:.25+a}})},[e]),v=(0,Y.useMemo)(()=>!e||!u?null:e.find(e=>e.id===u)||null,[e,u]);return(0,X.jsxs)(`div`,{className:`w-full flex flex-col gap-2 p-2 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-1 [@media(orientation:landscape)_and_(max-width:1024px)]:p-1`,children:[(0,X.jsxs)(`div`,{className:`relative w-full h-8 flex rounded-2xl overflow-hidden shadow-[0_10px_30px_-10px_rgba(0,0,0,0.5)] bg-gray-900/40 backdrop-blur-xl border border-white/10 p-1 gap-0 [@media(orientation:landscape)_and_(max-width:1024px)]:h-6 [@media(orientation:landscape)_and_(max-width:1024px)]:p-0.5`,children:[_.map((e,n)=>{let r=e.id===t,i=e.id&&m.get(e.id)||0,a=!!e.id;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{e.id&&(d(e.id),l(!0))},className:q(`h-full flex min-w-0 items-center justify-center transition-[flex-grow,transform,filter,opacity] duration-500 ease-overshoot relative overflow-hidden rounded-none ltr:first:rounded-l-xl ltr:last:rounded-r-xl rtl:first:rounded-r-xl rtl:last:rounded-l-xl`,Ir(e.color||`gray`),`shadow-[inset_0_1px_1px_rgba(255,255,255,0.4),inset_0_-2px_4px_rgba(0,0,0,0.2)]`,`opacity-90 hover:opacity-100`,a?`cursor-pointer`:`cursor-default`,r?`z-30 shadow-[0_0_14px_rgba(255,255,255,0.16)] ring-1 ring-inset ring-white/25`:``),style:{flexGrow:e.visibilityScore,flexBasis:0},"aria-label":`${e.name||`Team`}: ${e.score||0}`,disabled:!a,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-b from-white/12 via-transparent to-black/25`}),(0,X.jsx)(`div`,{className:`absolute inset-0 opacity-70 mix-blend-overlay bg-[radial-gradient(circle_at_20%_20%,rgba(255,255,255,0.16),transparent_40%),radial-gradient(circle_at_80%_30%,rgba(255,255,255,0.10),transparent_45%),radial-gradient(circle_at_50%_80%,rgba(0,0,0,0.20),transparent_55%)]`}),r&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-[linear-gradient(110deg,transparent,rgba(255,255,255,0.26),transparent)] bg-[length:200%_100%] animate-shine`}),(0,X.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-[3px] bg-gradient-to-r from-transparent via-white/70 to-transparent shadow-[0_0_14px_rgba(255,255,255,0.35)] animate-pulse`})]}),(0,X.jsxs)(`div`,{className:`z-20 flex min-w-0 items-center justify-center gap-2 px-2`,children:[(0,X.jsx)(`span`,{className:q(`font-black tabular-nums drop-shadow-[0_2px_8px_rgba(0,0,0,0.65)]`,r?`text-white text-sm [@media(orientation:landscape)_and_(max-width:1024px)]:text-xs`:`text-white/95 text-xs [@media(orientation:landscape)_and_(max-width:1024px)]:text-[11px]`),children:(0,X.jsx)(cu,{value:e.score||0})}),(0,X.jsxs)(`span`,{className:`inline-flex h-4 items-center gap-1 rounded-full border border-white/15 bg-black/35 px-1.5 text-[9px] font-black tabular-nums text-white/85 backdrop-blur shadow-[0_4px_14px_rgba(0,0,0,0.25)] sm:h-5 sm:gap-1.5 sm:px-2 sm:text-[10px] [@media(orientation:landscape)_and_(max-width:1024px)]:h-3.5 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-1 [@media(orientation:landscape)_and_(max-width:1024px)]:px-1 [@media(orientation:landscape)_and_(max-width:1024px)]:text-[8px]`,children:[(0,X.jsx)(Tt,{className:`h-2.5 w-2.5 shrink-0 text-white/75 sm:h-3 sm:w-3 [@media(orientation:landscape)_and_(max-width:1024px)]:h-2 [@media(orientation:landscape)_and_(max-width:1024px)]:w-2`}),(0,X.jsx)(`span`,{className:`leading-none`,children:i})]})]})]},e.id||n)}),h>0&&(0,X.jsxs)(`div`,{className:`absolute left-1/2 top-1/2 z-40 -translate-x-1/2 -translate-y-1/2 flex items-center`,children:[(0,X.jsx)(`div`,{className:`h-6 w-px bg-gradient-to-b from-transparent via-white/50 to-transparent [@media(orientation:landscape)_and_(max-width:1024px)]:h-4`}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>p(!0),className:`absolute left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2 flex items-center gap-1 rounded-full border border-white/20 bg-black/55 px-2 py-0.5 backdrop-blur-md shadow-[0_4px_14px_rgba(0,0,0,0.45)] transition-transform hover:scale-105 active:scale-95 cursor-pointer sm:px-2.5 sm:py-1`,"aria-label":`Spectators: ${h}`,children:[(0,X.jsx)(Pt,{className:`h-2.5 w-2.5 shrink-0 text-slate-300 sm:h-3 sm:w-3 [@media(orientation:landscape)_and_(max-width:1024px)]:h-2 [@media(orientation:landscape)_and_(max-width:1024px)]:w-2`}),(0,X.jsx)(`span`,{className:`text-[9px] font-black tabular-nums leading-none text-white/90 sm:text-[10px] [@media(orientation:landscape)_and_(max-width:1024px)]:text-[8px]`,children:h})]}),(0,X.jsx)(`div`,{className:`h-6 w-px bg-gradient-to-b from-transparent via-white/50 to-transparent [@media(orientation:landscape)_and_(max-width:1024px)]:h-4`})]}),_.length===0&&(0,X.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-white/50 text-xs font-bold uppercase tracking-widest animate-pulse`,children:`Ready to Start`})]}),(0,X.jsx)(ge,{open:c,onOpenChange:e=>{l(e),e||d(null)},children:(0,X.jsxs)(De,{overlayClass:`bg-gradient-to-b from-background/60 to-primary/30`,children:[(0,X.jsx)(V,{children:(0,X.jsx)(xe,{className:`text-base font-medium text-center`,children:v?.name||`Players`})}),(0,X.jsx)(`div`,{className:`rounded-xl border border-white/10 bg-black/10 p-3`,children:u?(0,X.jsx)(kr,{teamId:u,onRemovePlayerFromTeam:n,hideScore:!0,layout:`vertical`,scrollAreaClassName:`max-h-[70vh]`}):(0,X.jsx)(`div`,{className:`text-xs text-white/60`,children:`No team selected`})})]})}),(0,X.jsx)(ge,{open:f,onOpenChange:p,children:(0,X.jsxs)(De,{overlayClass:`bg-gradient-to-b from-background/60 to-primary/30`,children:[(0,X.jsx)(V,{children:(0,X.jsxs)(xe,{className:`text-base font-medium text-center flex items-center justify-center gap-2`,children:[(0,X.jsx)(Pt,{className:`h-4 w-4 text-slate-400`}),s(`Spectators`),(0,X.jsx)(`span`,{className:`inline-flex h-5 min-w-[1.25rem] items-center justify-center rounded-full bg-slate-700/60 px-1.5 text-[10px] font-black tabular-nums text-slate-200`,children:h})]})}),(0,X.jsx)(`div`,{className:`rounded-xl border border-white/10 bg-black/10 p-3`,children:g.length===0?(0,X.jsx)(`div`,{className:`text-xs text-white/60 text-center py-6`,children:s(`No spectators`)}
6):(0,X.jsx)(te,{className:`max-h-[70vh]`,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>{let t=!!o?.host,n=o?.id===e.id;return(0,X.jsxs)(`div`,{className:q(`flex items-center gap-2 rounded-lg border px-2 py-1.5 transition-all`,`bg-slate-100/95 text-slate-500 border-slate-200`,n&&`ring-1 ring-inset ring-orange-400/60`),children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 flex-1`,children:[e.host&&(0,X.jsx)($t,{className:`h-4 w-4 shrink-0 text-yellow-500`}),(0,X.jsx)(Pt,{className:`h-4 w-4 shrink-0 text-slate-400`}),n&&(0,X.jsx)(jn,{className:`h-4 w-4 shrink-0 text-orange-500`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate font-bold text-sm`,children:e.name}),!e.online&&(0,X.jsx)(`span`,{className:`ml-auto text-[10px] font-black uppercase tracking-widest text-slate-400`,children:s(`Offline`)})]}),(0,X.jsxs)(F,{type:`button`,size:`sm`,color:`secondary`,disabled:!t&&!n,onClick:()=>{e.id&&(t?r(e.id):n&&i())},className:q(`h-7 shrink-0 gap-1.5 text-[11px] font-black`,`bg-white/80 hover:bg-white text-slate-700 border border-slate-200 shadow-sm`,(t||n)&&`hover:bg-green-50 hover:text-green-700 hover:border-green-200`),title:s(t?`Remove from spectator mode`:n?`Leave spectator mode`:`Request`),children:[(0,X.jsx)(ur,{className:`h-3.5 w-3.5`}),(0,X.jsx)(`span`,{className:`leading-none`,children:s(t||n?`Join`:`Request`)})]})]},e.id)})})})})]})})]})},uu=()=>{let{t:e}=W(),{team:t,nextTeam:n,endGame:r}=ru(),{session:i,isPlayerHost:a,toggleFullScreen:o,fullScreenHandle:s}=J(),[c,l]=(0,Y.useState)(!1),[u,f]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{className:`min-h-[12vh] h-auto flex flex-col shrink-0`,children:[(0,X.jsxs)(`div`,{className:`flex-1 w-full flex flex-row md:flex-row items-center justify-between p-2 md:pl-4 gap-1 bg-gradient-to-r from-card to-card/10 shadow-sm border-transparent`,children:[(0,X.jsxs)(`div`,{className:`flex flex-row items-center gap-2 `,children:[(0,X.jsxs)(d,{to:`/`,children:[(0,X.jsx)(`img`,{src:`/images/logo.png`,className:`h-9 grid sm:place-content-center dark:hidden`,alt:D.name}),(0,X.jsx)(`img`,{src:`/images/logo-dark.png`,className:`h-9 hidden dark:grid dark:sm:place-content-center `,alt:D.name})]}),i.data?.playing&&a&&(0,X.jsxs)(F,{variant:`outline`,className:`relative hover:bg-default-100 dar
6k:hover:bg-default-200 data-[state=open]:bg-default-100 dark:data-[state=open]:bg-default-200 hover:text-primary text-default-500 dark:text-default-800 flex gap-1 rtl:flex-row-reverse`,size:`xs`,onClick:n,children:[(0,X.jsx)(yr,{className:`w-6 h-6`}),(0,X.jsx)(`span`,{className:`hidden md:block`,children:e(`Team turn: {{ team }}`,{team:t.name})})]})]}),(0,X.jsx)(`div`,{className:`text-sm sm:text-lg md:text-xl font-bold text-center`,children:i?.name||e(`Quizzes`)}),(0,X.jsxs)(`div`,{className:`flex flex-row items-center gap-2`,children:[(0,X.jsx)(F,{onClick:()=>{window.location.reload()},variant:`ghost`,size:`icon`,className:`relative md:h-9 md:w-9 h-7 w-7 hover:bg-default-100 dark:hover:bg-default-200 hover:text-primary text-default-500 dark:text-default-800  rounded-full`,children:(0,X.jsx)(Ft,{className:`w-6 h-6`})}),(0,X.jsx)(Oe,{text:e(`QR code to join game`),children:(0,X.jsx)(F,{type:`button`,size:`icon`,variant:`ghost`,onClick:e=>{f(e=>!e),e.preventDefault(),e.stopPropagation()},className:`relative md:h-9 md:w-9 h-7 w-7 hover:bg-default-100 dar
6k:hover:bg-default-200 hover:text-primary text-default-500 dark:text-default-800  rounded-full`,children:(0,X.jsx)(Kt,{className:`w-6 h-6`})})}),u&&(0,X.jsx)(ci,{session:i,linkPrefix:`q`,onClose:()=>f(!1)}),(0,X.jsx)(F,{onClick:o,variant:`ghost`,size:`icon`,className:`relative hidden sm:flex md:h-9 md:w-9 h-7 w-7 hover:bg-default-100 dark:hover:bg-default-200 data-[state=open]:bg-default-100  dark:data-[state=open]:bg-default-200 hover:text-primary text-default-500 dark:text-default-800 rounded-full`,children:s.active?(0,X.jsx)(Ht,{className:`w-6 h-6`}):(0,X.jsx)(dr,{className:`w-6 h-6`})}),(0,X.jsx)(Gr,{}),a&&i.data?.playing&&(0,X.jsxs)(ge,{open:c,onOpenChange:l,children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(F,{variant:`outline`,size:`xs`,className:`flex gap-1 rtl:flex-row-reverse`,children:[(0,X.jsx)(lr,{className:`w-6 h-6`}),(0,X.jsx)(`span`,{className:`hidden md:block`,children:e(`End game`)})]})}),(0,X.jsxs)(De,{className:`sm:max-w-md`,children:[(0,X.jsx)(V,{children:(0,X.jsx)(xe,{children:e(`End Game Confirmation`)})}),(0,X.jsx)(`div`,{className:`py-4`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`Are you sure you want to end the game? This action cannot be undone.`)})}),(0,X.jsxs)(Ne,{className:`flex gap-2`,children:[(0,X.jsx)(ce,{asChild:!0,children:(0,X.jsx)(F,{variant:`outline`,children:e(`Cancel`)})}),(0,X.jsxs)(F,{color:`destructive`,onClick:()=>{r(),l(!1)},className:`flex gap-1 rtl:flex-row-reverse`,children:[(0,X.jsx)(lr,{className:`w-4 h-4`}),e(`End Game`)]})]})]})]})]})]}),(0,X.jsx)(`div`,{className:`flex-shrink-0 overflow-hidden`,children:(0,X.jsx)(lu,{})})]})},du=({team:e,isPlayerHost:t})=>{let{model:n,team:r,teamHelpers:i,sendEvent:a}=ru(),{subscriptionClient:o}=J(),{t:s}=W(),c=(0,Y.useMemo)(()=>Bl(n.availableHelpers,i?.helperKey),[n.availableHelpers,i?.helperKey]),l=Xl(c),u=$l(i,c),d=eu(i,c),f=Ql(i),[p,{startTimer:m,stopTimer:h,resetTimer:g}]=Ti({countStart:d,intervalMs:1e3,isIncrement:!1});(0,Y.useEffect)(()=>{if(r.id!==e.id){h();return}if(!i||!c?.duration){h();return}let t=eu(i,c);return g(t),f&&t>0?m():h(),()=>{h()}},[f,c,g,r.id,m,h,e.id,i]);let _=(0,Y.useCallback)(()=>{let e=eu(i,c);g(e),e>0&&m()},[c,g,m,i]);(0,Y.useEffect)(()=>(o.on(`START_HELPER_TIMER`,_),()=>{o.off(`START_HELPER_TIMER`,_)}),[o]);let v=(0,Y.useCallback)(()=>{a(`START_HELPER_TIMER`)},[a]);return(0,X.jsx)(K,{className:q(`w-full h-full flex flex-col justify-center items-center rounded-lg border-2 bg-gradient-to-br from-green-50 to-blue-50 dark:from-green-900/20 dark:to-blue-900/20 shadow-md transition-all duration-300`,r.id===e.id&&`border-primary shadow-primary/30`),children:(0,X.jsx)(L,{className:`w-full p-2 sm:p-3`,children:(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(yn,{className:`h-4 w-4 text-primary animate-pulse`}),(0,X.jsx)(`span`,{className:`text-center text-sm sm:text-base font-bold bg-gradient-to-r from-primary to-purple-500 bg-clip-text text-transparent truncate max-w-[120px]`,children:s(e.name??`Timed helper`)}),(0,X.jsx)(yn,{className:`h-4 w-4 text-primary animate-pulse`})]}),(0,X.jsx)(K,{className:`w-full bg-gradient-to-r from-primary/10 to-purple-500/10 border-primary/20 text-xs p-1.5 flex flex-col items-center justify-center rounded-md shadow-inner`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(l,{className:`h-3 w-3 text-primary`}),(0,X.jsx)(`span`,{className:`text-xs font-bold text-primary`,children:s(c?.name??`Timed helper`)})]})}),!t||f?(0,X.jsx)(`div`,{className:`mt-1`,children:(0,X.jsx)(k,{size:`sm`,value:100*p/Math.max(u,1),showValue:!0,customContent:p,className:`animate-pulse w-8 h-8`})}):(0,X.jsxs)(F,{className:`flex gap-1 text-xs px-2 py-1 mt-1 bg-gradient-to-r from-green-500 to-blue-500 hover:from-green-600 hover:to-blue-600 transition-all duration-300 transform hover:scale-105 shadow-md`,onClick:v,children:[(0,X.jsx)(l,{className:`h-3 w-3`}),s(`Start`)]})]})})})},fu=({team:e,question:t,isCurrentTeam:n,activeHelper:r,availableHelpers:i,onUseHelper:
6a})=>{let{t:o}=W();if(r?.teamId===e.id)return null;let s=!!t,c=i.filter(e=>e.key&&Vl(e,s));return(0,X.jsx)(X.Fragment,{children:c.map(t=>{let s=t.key;if(!s)return null;let c=Xl(t),l=Bl(i,r?.helperKey),u=zl(e.helperDetails,s),d=u?.usedCount??0,f=u?.maxUses??t.maxUses??1,p=!Hl(t,n)||d>=f||Gl(r,l,t,e.id);return(0,X.jsx)(Oe,{text:o(Yl(t)),children:(0,X.jsx)(F,{size:`sm`,onClick:()=>a(s),disabled:p,className:q(`h-7 w-7 p-0 rounded-full transition-all duration-300 hover:scale-110 shadow-md flex items-center justify-center [@media(orientation:landscape)_and_(max-width:1024px)]:h-5 [@media(orientation:landscape)_and_(max-width:1024px)]:w-5 [@media(orientation:landscape)_and_(max-width:1024px)]:shadow-sm [@media(orientation:landscape)_and_(max-width:1024px)]:hover:scale-105`,Zl(t,d>=f)),children:(0,X.jsx)(c,{className:`h-4 w-4 [@media(orientation:landscape)_and_(max-width:1024px)]:h-2.5 [@media(orientation:landscape)_and_(max-width:1024px)]:w-2.5`})})},s)})})},pu=({team:e,hideIncreaseOrDecrease:t=!1})=>{let{model:n,team:r,selectedQuestion:i,teamHelpers:a,increaseOrDecreaseScore:o,useHelperAction:s}=ru(),{t:c}=W(),{isPlayerHost:l}
6=J(),u=r.id===e.id,d=n.availableHelpers??[],f=Bl(d,a?.helperKey),p=Xl(f),m=a?.teamId===e.id;return m&&f?.triggerMode===Vc.TIMED?(0,X.jsx)(`div`,{className:`h-full w-full px-[1px] xl:px-1`,children:(0,X.jsx)(du,{team:e,isPlayerHost:l})}):(0,X.jsx)(`div`,{className:`h-full w-full px-[1px] xl:px-1`,children:(0,X.jsx)(K,{className:q(`w-full h-full flex flex-col justify-center items-center rounded-lg border-2 bg-gradient-to-br from-card/50 to-card shadow-md transition-all duration-300 hover:shadow-lg`,r.id===e.id&&`border-primary shadow-primary/30 bg-gradient-to-br from-primary/5 to-purple-500/5`),children:(0,X.jsx)(L,{className:`w-full p-2 sm:p-3 [@media(orientation:landscape)_and_(max-width:1024px)]:p-0.5`,children:(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center space-y-1 [@media(orientation:landscape)_and_(max-width:1024px)]:space-y-0.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 min-h-[24px] [@media(orientation:landscape)_and_(max-width:1024px)]:min-h-[18px]`,children:[r.id===e.id&&(0,X.jsx)(hn,{className:`h-3 w-3 text-primary animate-bounce [@media(orientation:landscape)_and_(max-width:1024px)]:h-2.5 [@media(orientation:landscape)_and_(max-width:1024px)]:w-2.5`}),(0,X.jsx)(`span`,{className:q(`text-center font-bold transition-all duration-300 text-xs sm:text-sm md:text-base truncate max-w-[100px] sm:max-w-[120px] md:max-w-[150px]`,`[@media(orientation:landscape)_and_(max-width:1024px)]:text-[11px] [@media(orientation:landscape)_and_(max-width:1024px)]:max-w-[90px]`,r.id===e.id?`text-primary bg-gradient-to-r from-primary to-purple-500 bg-clip-text text-transparent`:`text-foreground`),children:e.name}),r.id===e.id&&(0,X.jsx)(hn,{className:`h-3 w-3 text-primary animate-bounce [@media(orientation:landscape)_and_(max-width:1024px)]:h-2.5 [@media(orientation:landscape)_and_(max-width:1024px)]:w-2.5`})]}),(0,X.jsxs)(`div`,{className:`w-full flex items-center justify-center gap-1`,children:[l&&!t&&(0,X.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-4 w-4 sm:h-5 sm:w-5 hover:bg-green-100 dark:hover:bg-green-900/20 hover:text-green-600 text-green-500 dark:text-green-400 rounded-full transition-all duration-300 hover:scale-110 [@media(orientation:landscape)_and_(max-width:1024px)]:h-4 [@media(orientation:landscape)_and_(max-width:1024px)]:w-4`,onClick:()=>o(e.id,100,!0),children:(0,X.jsx)(Cr,{className:`h-2 w-2 sm:h-2.5 sm:w-2.5 [@media(orientation:landscape)_and_(max-width:1024px)]:h-2 [@media(orientation:landscape)_and_(max-width:1024px)]:w-2`})}),(0,X.jsx)(`div`,{className:q(`font-philosopher text-sm sm:text-lg md:text-xl font-bold transition-all duration-300 min-w-[30px] sm:min-w-[40px] text-center`,`[@media(orientation:landscape)_and_(max-width:1024px)]:text-sm [@media(orientation:landscape)_and_(max-width:1024px)]:min-w-[26px]`,r.id===e.id?`text-primary scale-105`:`text-foreground`),children:e.score}),l&&!t&&(0,X.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-4 w-4 sm:h-5 sm:w-5 hover:bg-red-100 dark:hover:bg-red-900/20 hover:text-red-600 text-red-500 dark:text-red-400 rounded-full transition-all duration-300 hover:scale-110 [@media(orientation:landscape)_and_(max-width:1024px)]:h-4 [@media(orientation:landscape)_and_(max-width:1024px)]:w-4`,onClick:()=>o(e.id,100,!1),children:(0,X.jsx)(tr,{className:`h-2 w-2 sm:h-2.5 sm:w-2.5 [@media(orientation:landscape)_and_(max-width:1024px)]:h-2 [@media(orientation:landscape)_and_(max-width:1024px)]:w-2`})})]}),(0,X.jsxs)(`div`,{className:`w-full flex justify-center items-center gap-1`,children:[m&&f&&f.triggerMode!==Vc.TIMED&&(0,X.jsxs)(K,{className:`w-full bg-gradient-to-r from-primary/10 to-purple-500/10 border-primary/30 text-primary p-1 text-[10px] sm:text-xs text-center flex justify-center items-center gap-1 rounded-md shadow-sm animate-pulse`,children:[(0,X.jsx)(p,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{className:`font-semibold truncate`,children:c(Jl(f))})]}),(0,X.jsx)(`div`,{className:`flex gap-1`,children:(0,X.jsx)(fu,{team:e,activeHelper:a,availableHelpers:d,question:i,isCurrentTeam:u,onUseHelper:t=>{!l||!e.id||s(e.id,t)}})})]})]})})})})},mu=({layout:e=`horizontal`,hideIncreaseOrDecrease:t=!1,showSeparators:n=!1,className:r,containerClassName:i,teamClassName:a,scrollToSelected:o=!1})=>{let{teams:s,team:c}=ru(),l=(0,Y.useRef)({}),u=(0,Y.useRef)(null);(0,Y.useEffect)(()=>
6{if(o&&c?.id){let e=l.current[c.id];e&&(u.current&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{e.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`center`})},100))}return()=>{u.current&&=(window.clearTimeout(u.current),null)}},[c?.id,o]);let d=()=>{switch(e){case`vertical`:return`flex xl:flex-col max-xl:flex-row gap-3 xl:gap-4`;case`grid`:return`grid grid-cols-1 sm:grid-cols-2 gap-6 justify-items-center`;default:return`px-1 flex flex-row gap-3 py-1 [@media(orientation:landscape)_and_(max-width:1024px)]:px-0.5 [@media(orientation:landscape)_and_(max-width:1024px)]:py-0.5 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-1.5`}},f=()=>{switch(e){case`vertical`:return`xl:overflow-y-auto max-xl:overflow-x-auto h-full w-full styled-scrollbar`;case`grid`:return`w-full`;default:return`overflow-x-auto h-full w-full styled-scrollbar`}},p=()=>{let t=``;switch(e){case`vertical`:t=`max-xl:min-w-[180px] max-sm:min-w-[160px] xl:w-full flex-shrink-0`;break;case`grid`:t=`w-full max-w-[200px]`;break;default:t=`min-w-[120px] max-w-[140px] sm:min-w-[160px] sm:max-w-[180px] flex-shrink-0 [@media(orientation:landscape)_and_(max-width:1024px)]:min-w-[96px] [@media(orientation:landscape)_and_(max-width:1024px)]:max-w-[110px]`}return e===`horizontal`&&n&&(t+=` relative`),q(t,a)};return(0,X.jsx)(`div`,{className:q(f(),i),children:(0,X.jsx)(`div`,{className:q(d(),r),children:s.map((r,i)=>(0,X.jsxs)(`div`,{className:p(),ref:e=>{r.id&&(l.current[r.id]=e)},children:[e===`horizontal`&&n&&i<s.length-1&&(0,X.jsx)(`div`,{className:`absolute ltr:right-[-8px] rtl:left-[-8px] top-[10%] h-[80%
6] w-[1px] bg-primary/30`}),(0,X.jsx)(pu,{team:r,hideIncreaseOrDecrease:t})]},r.id||i))})})},hu=new Map,gu=[],_u=(e,t)=>{let n=hu.get(t);if(n)return n;let r=e.loadImage(t);if(hu.set(t,r),gu.push(t),gu.length>60){let e=gu.splice(0,gu.length-60);for(let t of e)hu.delete(t)}return r},vu=(e,t,n,r,i)=>{let a=Math.max(1,n),o=Math.max(1,r),s=Math.min(a/e,o/t),c=Math.max(.01,s),l=i?.preventUpscaleBelowHeight??180,u=i?.preventUpscaleBelowHeightRatio??.25,d=Math.min(l,o*u);return c>1&&t<=d&&(c=1),i?.maxScale!==void 0&&(c=Math.min(c,Math.max(.01,i.maxScale))),{width:e*c,height:t*c}},yu=(e,t,n,r,i)=>{let a=Math.max(1,n),o=Math.max(1,r),s=Math.max(a/e,o/t),c=Math.max(.01,s),l=i?.preventUpscaleBelowHeight??180,u=i?.preventUpscaleBelowHeightRatio??.25,d=Math.min(l,o*u);return c>1&&t<=d&&(c=1),i?.maxScale!==void 0&&(c=Math.min(c,Math.max(.01,i.maxScale))),{width:e*c,height:t*c}},bu={SQUARE:{width:1080,height:1080},PORTRAIT:{width:1080,height:1350}},xu={width:1080,height:1350,questionText:{xOffset:30,y:120,widthPadding:250,height:200},answerText:{bottomPadding:120,height:200,widthPadding:150},category:{x:210,y:25,width:270,height:60,fontSize:25},imageBox:{x:125,y:330,width:810,height:670},fontSize:{question:40}},Su=({question:e,category:t,indexAnswer:n,onImageGenerated:r})=>{let{t:i}=W(),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null),s=(0,Y.useRef)(0),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(!1),v=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{v.current=g},[g]);let y=async(e,t,n)=>{let r=await _u(e,`${D.host_static}/images/post.png`);return e.sprite(r,0,0,t,n)},b=async(e,t,n,r,i,a=null)=>{if(e.rectangle(t,n,r,i,{fillColor:`rgba(211, 243, 250, 0.5)`}),!a)return;let o=await _u(e,a),s={preventUpscaleBelowHeight:180,preventUpscaleBelowHeightRatio:.25},c=Math.min(180,i*.25),{width:l,height:u}=o.height<=c?vu(o.width,o.height,r,i,s):yu(o.width,o.height,r,i,s),d=1.8;(l>r*d||u>i*d)&&({width:l,height:u}=vu(o.width,o.height,r,i,s));let f=t+(r-l)/2,p=n+(i-u)/2;return e.sprite(o,f,p,l,u)},x=(e,t,n,r,i,a,o,s,c=!1)=>{c&&e.roundRect(t-r/2,n,r,i,20,{fillColor:`rgba(255, 255, 255, 0.5)`,strokeColor:`rgba(0, 0, 0, 0.2)`,strokeWidth:0});let l={font:{family:C(a)?`Zain, "Arial Unicode MS", Arial, sans-serif`:`Arial, sans-serif`,size:o,weight:`bold`},color:c?`green`:`#313B3E`,align:`center`,baseline:`top`,direction:C(a)?`rtl`:`ltr`,lineHeight:s,maxWidth:r,maxHeight:i,minFontSize:12},u=n+(i-e.measureText(a,l).height)/2;e.text(a,t,u,l)},S=(e,t,n,r,i,a,o,s,c=!1)=>{let l={font:{family:C(a)?`Zain, "Arial Unicode MS", Arial, sans-serif`:`Arial, sans-serif`,size:o,weight:`bold`},color:c?`green`:`#313B3E`,align:`center`,baseline:`top`,direction:C(a)?`rtl`:`ltr`,lineHeight:s,maxWidth:r,maxHeight:i,minFontSize:12},u=n+(i-e.measureText(a,l).height)/2;e.text(a,t+r/2,u,l)},C=e=>/[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/.test(e),w=(0,Y.useCallback)(async(i=`square`,a)=>{if(!o.current||!e.question)return;l(!0);let c=++s.current,u=a?.showAnswer??v.current,f=o.current,m=bu[i.toUpperCase()],{width:g,height:_}=m,w=g/xu.width,T=_/xu.height,E=Math.min(w,T),D=n!==void 0&&e.answers?e.answers[n]:e.answers?.find(e=>e.correct);f.resize(m.width,m.height),f.clear();try{let n=Math.round(xu.fontSize.question*E),o=1.25,m=xu.imageBox.x*w,v=xu.imageBox.y*T,O=xu.imageBox.width*w,k=xu.imageBox.height*T;if(e.letters&&(!u||!D?.image)){let t=(xu.imageBox.width-150)*w,n=(xu.imageBox.height-150)*T,r=await _u(f,`/images/favicon.png`),i=f.group(m,v);i.addChild(new Ni(0,0,O,k,{fillColor:`rgba(211, 243, 250, 0.5)`})),i.addChild(new Mi((O-t)/2,(k-n)/2,t,n,{centerImage:r,selectedLetter:e.letter}))}else if(e.content){let t=(xu.imageBox.width-120)*w,r=(xu.imageBox.height-150)*T;f.rectangle(m,v,O,k,{fillColor:`rgba(211, 243, 250, 0.5)`});let i=C(e.content),a=m+(O-t)/2,s=i?a+t:a,c=v+(k-r)/2,l={font:{family:C(e.content)?`Zain, "Arial Unicode MS", Arial, sans-serif`:`Arial, sans-serif`,size:n,weight:`bold`},color:`#313B3E`,align:i?`right`:`left`,baseline:`top`,direction:i?`rtl`:`ltr`,lineHeight:o,maxWidth:t,maxHeight:r,minFontSize:12},u=f.measureText(e.content,l),d=Math.max(0,(r-u.height)/2);f.text(e.content,s,c+d,l)}else await b(f,m,v,O,k,u||e.preview?D?.image:e.image);await y(f,g,_),x(f,g/2+xu.questionText.xOffset*w,xu.questionText.y*T,g-xu.questionText.widthPadding*w,xu.questionText.height*T,e.question,n,o),u&&D?.answer&&x(f,g/2,_-xu.answerText.bottomPadding*T-xu.answerText.height*T,g-xu.answerText.widthPadding*w,xu.answerText.height*T,D.answer,n,o,!0),S(f,xu.category.x*w,xu.category.y*T,xu.category.width*w,xu.category.height*T,t?.name||``,Math.round(xu.category.fontSize*E),o),f.render();let A=f.captureImage(`image/png`);if(c!==s.current){l(!1);return}p(A),h(i),l(!1),a?.openDialog!==!1&&d(!0),r&&r(A)}catch(e){console.error(`Error generating image:`,e),alert(`Failed to generate image. Please try again.`),l(!1)}},[e,t,r]),T=(0,Y.useCallback)(()=>
6{if(f){let t=document.createElement(`a`);t.download=`question-${e.id||`unknown`}-${m}.png`,t.href=f,t.click()}},[f,e,m]);return(0,Y.useEffect)(()=>(a.current&&!o.current&&(o.current=new Ei(a.current,{enableHighDPI:!0})),()=>{s.current+=1}),[]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`canvas`,{ref:a,style:{display:`none`},"aria-hidden":`true`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:(0,X.jsx)(F,{size:`icon`,className:`flex items-center gap-2 bg-pink-200 hover:bg-pink-300 sm:text-base text-xs font-semibold [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px] [@media(orientation:landscape)_and_(max-width:1024px)]:h-7 [@media(orientation:landscape)_and_(max-width:1024px)]:px-2`,disabled:c,onClick:()=>w(`portrait`,{openDialog:!0}),children:c?(0,X.jsx)(ar,{className:`w-6 h-6 animate-spin`}):(0,X.jsx)(sr,{className:`w-6 h-6 text-pink-600`})})}),(0,X.jsx)(ge,{open:u,onOpenChange:d,children:(0,X.jsxs)(De,{className:`w-[95dvw] max-w-2xl max-h-[90dvh] overflow-auto`,children:[(0,X.jsx)(xe,{className:`text-2xl font-bold text-center hidden`,children:i(`Image`)}),f&&(0,X.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,X.jsx)(`img`,{src:f,alt:`image`,className:`max-w-full max-h-[70dvh] w-auto h-auto border rounded-lg shadow-lg`})}),(0,X.jsxs)(Ne,{children:[(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,X.jsx)(F,{size:`sm`,variant:g?`default`:`outline`,onClick:()=>{let e=!v.current;_(e),m&&w(m,{openDialog:!1,showAnswer:e})},className:`sm:text-base text-xs font-semibold [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px] [@media(orientation:landscape)_and_(max-width:1024px)]:h-7 [@media(orientation:landscape)_and_(max-width:1024px)]:px-2`,children:i(g?`Hide Answer`:`Show Answer`)})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(F,{size:`sm`,onClick:T,className:`flex items-center gap-2 sm:text-base text-xs font-semibold [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px] [@media(orientation:landscape)_and_(max-width:1024px)]:h-7 [@media(orientation:landscape)_and_(max-width:1024px)]:px-2`,children:[(0,X.jsx)(Yt,{size:16}),i(`Download Image`)]}),(0,X.jsx)(ce,{asChild:!0,children:(0,X.jsx)(F,{variant:`outline`,size:`sm`,className:`sm:text-base text-xs font-semibold [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px] [@media(orientation:landscape)_and_(max-width:1024px)]:h-7 [@media(orientation:landscape)_and_(max-width:1024px)]:px-2`,children:i(`Close`)})})]})]})]})})]})},Cu=()=>{let{teams:e,team:t,awardPoints:n,model:r,teamHelpers:i}=ru(),{t:a}=W(),o=Bl(r.availableHelpers,i?.helperKey),s=i?.active&&i?.teamId===t.id&&Ul(o,$.LOCK_ANSWER_TO_CURRENT_TEAM),c=s?e.filter(e=>e.id===t.id):e;return r.scoringMode===Rc.PENALTY?(0,X.jsxs)(`div`,{className:`w-full px-2 sm:px-4 [@media(orientation:landscape)_and_(max-width:1024px)]:px-1`,children:[(0,X.jsx)(`h2`,{className:`flex justify-center items-center w-full leading-[1.3_!important] text-xl sm:text-2xl question-content text-center py-4 font-extrabold [@media(orientation:landscape)_and_(max-width:1024px)]:text-base`,children:a(`Did {{teamName}} answer correctly?`,{teamName:t.name})}),(0,X.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:flex-wrap sm:justify-center items-center gap-2 sm:gap-4 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-1`,children:[(0,X.jsx)(F,{onClick:()=>n(t.id),size:`lg`,className:q(`w-full sm:w-1/3 h-auto p-2 xl:p-4 rounded-2xl flex flex-row justify-center items-center transition-all hover:scale-105`,`[@media(orientation:landscape)_and_(max-width:1024px)]:p-1 [@media(orientation:landscape)_and_(max-width:1024px)]:rounded-lg [@media(orientation:landscape)_and_(max-width:1024px)]:hover:scale-100`,t.color?`text-white`:`bg-primary text-primary-foreground hover:bg-primary/90`,t.color&&Ir(t.color),t.color&&Nr(t.color)),children:(0,X.jsx)(`span`,{className:`text-sm lg:text-lg text-center font-bold font-zain [@media(orientation:landscape)_and_(max-width:1024px)]:text-xs`,children:a(`Correct answer`)})}),(0,X.jsx)(F,{onClick:()=>n(null),variant:`ghost`,color:`secondary`,className:`w-full sm:w-1/3 h-auto p-2 xl:p-4 roun
6ded-2xl flex flex-row justify-center items-center mt-2 sm:mt-0 [@media(orientation:landscape)_and_(max-width:1024px)]:p-1 [@media(orientation:landscape)_and_(max-width:1024px)]:rounded-lg [@media(orientation:landscape)_and_(max-width:1024px)]:mt-1`,children:a(`Wrong answer`)})]})]}):(0,X.jsxs)(`div`,{className:`w-full px-2 sm:px-4 [@media(orientation:landscape)_and_(max-width:1024px)]:px-1`,children:[(0,X.jsx)(`h2`,{className:`flex justify-center items-center w-full leading-[1.3_!important] text-xl sm:text-2xl question-content text-center py-4 font-extrabold [@media(orientation:landscape)_and_(max-width:1024px)]:text-base`,children:s?a(`Did {{teamName}} answer correctly?`,{teamName:t.name}):a(`Who answered correctly?`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 sm:flex sm:flex-wrap sm:justify-center items-center gap-2 sm:gap-4 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-1`,children:[c.map(e=>(0,X.jsx)(F,{onClick:()=>n(e.id),size:`lg`,className:q(`w-full sm:w-1/3 h-auto p-2 xl:p-4 rounded-2xl flex flex-row justify-center items-center transition-all hover:scale-105`,`[@media(orientation:landscape)_and_(max-width:1024px)]:p-1 [@media(orientation:landscape)_and_(max-width:1024px)]:rounded-lg [@media(orientation:landscape)_and_(max-width:1024px)]:hover:scale-100`,e.color&&`text-white`,e.color&&Ir(e.color),e.color&&Nr(e.color)),children:(0,X.jsx)(`span`,{className:`text-sm lg:text-lg text-center font-bold font-zain [@media(orientation:landscape)_and_(max-width:1024px)]:text-xs`,children:e.name})},e.id)),(0,X.jsx)(F,{onClick:()=>n(null),variant:`ghost`,color:`secondary`,className:`w-full sm:w-1/3 h-auto p-2 xl:p-4 rounded-2xl flex flex-row justify-center items-center col-span-2 sm:col-span-1 mt-2 sm:mt-0 [@media(orientation:landscape)_and_(max-width:1024px)]:p-1 [@media(orientation:landscape)_and_(max-width:1024px)]:rounded-lg [@media(orientation:landscape)_and_(max-width:1024px)]:mt-1`,children:a(s?`Wrong answer`:`No one answered`)})]})]})},wu=3e3,Tu=3e3,Eu=`#ffffff`,Du=`rgba(15, 23, 42, 0.08)`,Ou=.4,ku=1.8,Au=.15,ju={tool:`pen`,strokeColor:`#111827`,fillColor:null,strokeWidth:4},Mu=`absolute inset-0 h-full w-full`,Nu=({backgroundCanvasRef:e,className:t,disabled:n=!1,drawingCanvasRef:r,height:i,onPointerCancel:a,onPointerDown:o,onPointerMove:s,onPointerUp:c,onWheel:l,previewCanvasRef:u,toolCursorClassName:d,toolCursorStyle:f,width:p})=>((0,Y.useEffect)(()=>{let e=u.current;if(e)return e.addEventListener(`wheel`,l,{passive:!1}),()=>{e.removeEventListener(`wheel`,l)}},[l,u]),(0,X.jsxs)(`div`,{className:q(`relative overflow-hidden rounded-3xl border border-slate-200 bg-slate-100 shadow-inner select-none`,t),style:{width:p,height:i,touchAction:`none`,overscrollBehavior:`contain`},children:[(0,X.jsx)(`canvas`,{ref:e,className:Mu}),(0,X.jsx)(`canvas`,{ref:r,className:Mu}),(0,X.jsx)(`canvas`,{ref:u,className:q(Mu,n?`cursor-not-allowed`:d),style:n?void 0:f,tabIndex:0,onPointerCancel:a,onPointerDown:o,onPointerMove:s,onPointerUp:c})]})),Pu=({operationCount:e,tool:t,zoom:n})=>{let{t:r}=W();return(0,X.jsx)(`div`,{className:`absolute right-4 top-4 z-20 rounded-2xl border border-slate-200/80 bg-white/90 px-2 py-1 text-xs font-medium text-slate-600 shadow-lg backdrop-blur md:top-auto md:bottom-4`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsxs)(`span`,{className:`hidden sm:block`,children:[r(`Tool`),`: `,r(Ce(t))]}),(0,X.jsxs)(`span`,{className:`hidden sm:block`,children:[r(`Ops`),`: `,e]}),(0,X.jsxs)(`span`,{children:[r(`Zoom`),`: `,Math.round(n*100),`%`]})]})})},Fu=[{tool:`pan`,label:B(`Pan`),icon:Kn},{tool:`pen`,label:B(`Pen`),icon:Rt},{tool:`line`,label:B(`Line`),icon:tr},{tool:`rectangle`,label:B(`Rectangle`),icon:Ln},{tool:`circle`,label:B(`Circle`),icon:kt},{tool:`eraser`,label:B(`Eraser`),icon:Dt}],Iu=`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-slate-200 bg-white text-slate-700 shadow-sm transition hover:border-slate-300 hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50 md:h-10 md:w-10`,Lu=({brush:e,canRedo:t,canUndo:n,currentBackgroun
6dColor:r,hiddenControls:i,isGridVisible:a,onClear:o,onDownloadImage:s,onDownloadJson:c,onRedo:l,onResetView:u,onSetBackgroundColor:d,onSetFillColor:f,onSetStrokeColor:p,onSetStrokeWidth:m,onSetTool:h,onTriggerImport:g,onToggleGrid:_,onUndo:v,onZoomIn:y,onZoomOut:b,zoom:x})=>{let{t:S}=W(),C=typeof document<`u`&&document.documentElement.dir===`rtl`,w=e=>!!i?.[e],T=!w(`tools`),E=!w(`backgroundColor`),D=!w(`strokeColor`),O=!w(`fillColor`),k=!w(`strokeWidth`),A=!w(`undo`)||!w(`redo`),j=!w(`zoom`)||!w(`resetView`),M=!w(`exportJson`)||!w(`exportImage`)||!w(`import`),N=!w(`gridToggle`)||!w(`clear`),P=[T,E,D,O,k,A,j,M].filter(Boolean).length,F=0,I=()=>(F+=1,F>=P?null:(0,X.jsx)(`div`,{className:`h-8 w-px bg-slate-200`}));return(0,X.jsx)(`div`,{className:`absolute bottom-4 left-1/2 z-20 flex w-[calc(100%-1rem)] max-w-[calc(100%-1rem)] -translate-x-1/2 overflow-x-auto rounded-2xl border border-slate-200/80 bg-white/90 p-2 shadow-lg backdrop-blur md:left-4 md:top-4 md:bottom-auto md:w-auto md:max-w-[calc(100%-2rem)] md:translate-x-0 md:p-3`,children:(0,X.jsxs)(`div`,{className:`flex min-w-max items-center gap-2 md:gap-3`,children:[N&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!w(`gridToggle`)&&(0,X.jsx)(`button`,{type:`button`,className:q(Iu,a&&`border-slate-900 bg-slate-900 text-white hover:bg-slate-800`),onClick:_,title:S(`Toggle Grid`),"aria-label":S(`Toggle Grid`),"aria-pressed":a,children:(0,X.jsx)(Fn,{className:`h-4 w-4`})}),!w(`clear`)&&(0,X.jsx)(`button`,{type:`button`,className:Iu,onClick:o,title:S(`Clear`),"aria-label":S(`Clear`),children:(0,X.jsx)(or,{className:`h-4 w-4`})})]}),N&&T&&I(),T&&(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:Fu.map(({icon:t,label:n,tool:r})=>(0,X.jsx)(`button`,{type:`button`,title:S(n),"aria-label":S(n),"aria-pressed":e.tool===r,onClick:()=>h(r),className:q(Iu,e.tool===r&&`border-slate-900 bg-slate-900 text-white hover:bg-slate-800`),children:(0,X.jsx)(t,{className:`h-4 w-4`})},r))}),T&&I(),E&&I(),E&&(0,X.jsxs)(`label`,{className:`flex items-center gap-2 rounded-xl border border-slate-200 bg-white px-2.5 py-2 text-xs font-medium text-slate-600 shadow-sm md:px-3`,children:[(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:S(`Background`)}),(0,X.jsx)(`input`,{type:`color`,value:r,onChange:e=>d(e.target.value),className:`h-7 w-7 cursor-pointer rounded border-0 bg-transparent p-0`})]}),E&&I(),D&&(0,X.jsxs)(`label`,{className:`flex items-center gap-2 rounded-xl border border-slate-200 bg-white px-2.5 py-2 text-xs font-medium text-slate-600 shadow-sm md:px-3`,children:[(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:S(`Stroke`)}),(0,X.jsx)(`input`,{type:`color`,value:e.strokeColor,onChange:e=>p(e.target.value),className:`h-7 w-7 cursor-pointer rounded border-0 bg-transparent p-0`})]}),D&&I(),O&&(0,X.jsxs)(`label`,{className:`flex items-center gap-2 rounded-xl border border-slate-200 bg-white px-2.5 py-2 text-xs font-medium text-slate-600 shadow-sm md:px-3`,children:[(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:S(`Fill`)}),(0,X.jsx)(`input`,{type:`color`,value:e.fillColor??`#ffffff`,onChange:e=>f(e.target.value),className:`h-7 w-7 cursor-pointer rounded border-0 bg-transparent p-0`})]}),O&&I(),k&&(0,X.jsxs)(`label`,{className:`flex items-center gap-2 rounded-xl border border-slate-200 bg-white px-2.5 py-2 text-xs font-medium text-slate-600 shadow-sm md:px-3`,children:[(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:S(`Size`)}),(0,X.jsx)(`input`,{type:`range`,min:1,max:150,value:e.strokeWidth,onChange:e=>m(Number(e.target.value)),className:`w-20 md:w-24`}),(0,X.jsx)(`span`,{className:`min-w-7 text-right text-slate-900`,children:e.strokeWidth})]}),k&&I(),A&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!w(`undo`)&&(0,X.jsx)(`button`,{type:`button`,className:Iu,onClick:v,disabled:!n,title:S(`Undo`),"aria-label":S(`Undo`),children:C?(0,X.jsx)(Bt,{className:`h-4 w-4`}):(0,X.jsx)(ir,{className:`h-4 w-4`})}),!w(`redo`)&&(0,X.jsx)(`button`,{type:`button`,className:Iu,onClick:l,disabled:!t,title:S(`Redo`),"aria-label":S(`Redo`),children:C?(0,X.jsx)(ir,{className:`h-4 w-4`}):(0,X.jsx)(Bt,{className:`h-4 w-4`})})]}),A&&I(),j&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!w(`zoom`)&&(0,X.jsx)(`button`,{type:`button`,className:Iu,onClick:b,title:S(`Zoom Out`),"aria-label":S(`Zoom Out`),children:(0,X.jsx)(Lt,{className:`h-4 w-4`})}),!w(`zoom`)&&(0,X.jsxs)(`div`,{className:`min-w-14 text-center text-sm font-semibold text-slate-700 md:min-w-16`,children:[Math.round(x*100),`%`]}),!w(`zoom`)&&(0,X.jsx)(`button`,{type:`button`,className:Iu,onClick:y,title:S(`Zoom In`),"aria-label":S(`Zoom In`),children:(0,X.jsx)(Gt,{className:`h-4 w-4`})}),!w(`resetView`)&&(0,X.jsx)(`button`,{type:`button`,className:Iu,onClick:u,title:S(`Reset View`),"aria-label":S(`Reset View`),children:(0,X.jsx)(Ft,{className:`h-4 w-4`})})]}),j&&I(),M&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!w(`exportJson`)&&(0,X.jsx)(`button`,{type:`button`,className:Iu,onClick:c,title:S(`Export JSON`),"aria-label":S(`Export JSON`),children:(0,X.jsx)(Yt,{className:`h-4 w-4`})}),!w(`exportImage`)&&(0,X.jsx)(`button`,{type:`button`,className:Iu,onClick:s,title:S(`Export PNG`),"aria-label":S(`Export PNG`),children:(0,X.jsx)(Yt,{className:`h-4 w-4`})}),!w(`import`)&&(0,X.jsx)(`button`,{type:`button`,className:Iu,onClick:g,title:S(`Import JSON`),"aria-label":S(`Import JSON`),children:(0,X.jsx)(Xn,{className:`h-4 w-4`})})]})]})})},Ru=e=>typeof e==`string`?JSON.parse(e):e,zu=e=>JSON.stringify(e),Bu=e=>{let t=Ru(e);return{...t,version:1,operations:Array.isArray(t.operations)?t.operations:[]}},Vu=e=>JSON.stringify(e),Hu=e=>Ru(e),Uu=e=>JSON.stringify(e),Wu=e=>{let t=Ru(e);if(`centerXRatio`in t||`centerYRatio`in t){let e=t;return{centerXRatio:typeof e.centerXRatio==`number`&&Number.isFinite(e.centerXRatio)?e.centerXRatio:.5,centerYRatio:typeof e.centerYRatio==`number`&&Number.isFinite(e.centerYRatio)?e.centerYRatio:.5,zoom:typeof e.zoom==`number`&&Number.isFinite(e.zoom)?e.zoom:1}}return{offsetX:Number.isFinite(t.offsetX)?t.offsetX:0,offsetY:Number.isFinite(t.offsetY)?t.offsetY:0,zoom:Number.isFinite(t.zoom)?t.zoom:1}}
6,Gu=(e,t,n)=>({type:e,payload:t,meta:n}),Ku=(e,t,n)=>Math.min(n,Math.max(t,e)),qu=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`draw-${Date.now()}-${Math.random().toString(36).slice(2,10)}`,Ju=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),Yu=(e,t)=>{e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height)},Xu=(e,t,n,r)=>{let i=Math.max(n,1),a=t.width/i;e.setTransform(a*r.zoom,0,0,a*r.zoom,a*r.offsetX,a*r.offsetY)},Zu=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}),Qu=(e,t)=>{let n=t.compositeOperation===`destination-out`;e.strokeStyle=n?`#000000`:t.strokeColor,e.fillStyle=n?`#000000`:t.fillColor??`transparent`,e.lineWidth=t.strokeWidth,e.lineCap=`round`,e.lineJoin=`round`,e.globalCompositeOperation=t.compositeOperation??`source-over`},$u=(e,t)=>{let[n]=t.points;e.beginPath(),e.arc(n.x,n.y,t.strokeWidth/2,0,Math.PI*2),e.fill()},ed=(e,t)=>{if(t.points.length===0)return;let n=t.strokeWidth/2,r=Math.max(.5,n*.35);e.beginPath();let i=t=>{e.moveTo(t.x+n,t.y),e.arc(t.x,t.y,n,0,Math.PI*2)};i(t.points[0]);for(let e=1;e<t.points.length;e+=1){let n=t.points[e-1],a=t.points[e],o=Ju(n,a),s=Math.max(1,Math.ceil(o/r));for(let e=1;e<=s;e+=1){let t=e/s;i({x:n.x+(a.x-n.x)*t,y:n.y+(a.y-n.y)*t})}}e.fill()},td=(e,t)=>{if(t.points.length!==0){if(t.points.length===1){$u(e,t);return}if(t.tool===`eraser`||t.compositeOperation===`destination-out`){ed(e,t);return}e.beginPath(),e.moveTo(t.points[0].x,t.points[0].y);for(let n=1;n<t.points.length;n+=1){let r=t.points[n];e.lineTo(r.x,r.y)}e.stroke()}},nd=(e,t)=>{e.beginPath(),e.moveTo(t.start.x,t.start.y),e.lineTo(t.end.x,t.end.y),e.stroke()},rd=(e,t)=>{let n=Zu(t.start,t.end);e.beginPath(),e.rect(n.x,n.y,n.width,n.height),t.fillColor&&e.fill(),e.stroke()},id=(e,t)=>{let n=Ju(t.center,t.edge);e.beginPath(),e.arc(t.center.x,t.center.y,n,0,Math.PI*2),t.fillColor&&e.fill(),e.stroke()},ad=(e,t)=>{switch(e.save(),Qu(e,t),t.kind){case`path`:td(e,t);break;case`line`:nd(e,t);break;case`rectangle`:rd(e,t);break;case`circle`:id(e,t)}e.restore()},od=(e,t,n,r,i,a)=>{let o=-t.offsetX/t.zoom,s=-t.offsetY/t.zoom,c=(n.width-t.offsetX)/t.zoom,l=(n.height-t.offsetY)/t.zoom,u=Math.floor(Math.max(o,0)/i)*i,d=Math.min(r.width,Math.ceil(c/i)*i),f=Math.floor(Math.max(s,0)/i)*i,p=Math.min(r.height,Math.ceil(l/i)*i);e.save(),e.strokeStyle=a,e.lineWidth=1/t.zoom,e.beginPath();for(let t=u;t<=d;t+=i)e.moveTo(t,Math.max(0,s)),e.lineTo(t,Math.min(r.height,l));for(let t=f;t<=p;t+=i)e.moveTo(Math.max(0,o),t),e.lineTo(Math.min(r.width,c),t);e.stroke(),e.restore()},sd=(e,t)=>{let n={id:qu(),strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,createdAt:Date.now(),authorId:void 0,compositeOperation:t.tool===`eraser`?`destination-out`:`source-over`};switch(t.tool){case`line`:return{...n,kind:`line`,tool:t.tool,start:e,end:e};case`rectangle`:return{...n,kind:`rectangle`,tool:t.tool,start:e,end:e};case`circle`:return{...n,kind:`circle`,tool:t.tool,center:e,edge:e};default:return{...n,kind:`path`,tool:t.tool===`eraser`?`eraser`:`pen`,points:[e]}}},cd=(e,t)=>{switch(e.kind){case`path`:{let n=e.points[e.points.length-1];return n&&Ju(n,t)<1.5?e:{...e,points:[...e.points,t]}}case`line`:case`rectangle`:return{...e,end:t};case`circle`:return{...e,edge:t};default:return e}},ld=e=>{switch(e.kind){case`path`:return e.points.length>0;case`line`:return Ju(e.start,e.end)>0;case`rectangle`:{let t=Zu(e.start,e.end);return t.width>0||t.height>0}case`circle`:return Ju(e.center,e.edge)>0;default:return!1}},ud=(e=[])=>{let t=(0,Y.useRef)(e),n=(0,Y.useRef)([]),[r,i]=(0,Y.useState)(e),[a,o]=(0,Y.useState)([]),s=(0,Y.useCallback)(e=>(t.current=e,i(e),e),[]),c=(0,Y.useCallback)(e=>(n.current=e,o(e),e),[]);return{operations:r,redoStack:a,append:(0,Y.useCallback)(e=>{if(t.current.some(t=>t.id===e.id))return t.current;let n=[...t.current,e];return c([]),s(n)},[s,c]),clear:(0,Y.useCallback)(()=>(c([]),s([])),[s,c]),load:(0,Y.useCallback)(e=>(c([]),s(e)),[s,c]),undo:(0,Y.useCallback)(()=>{if(t.current.length===0)return t.current;let e=t.current.slice(0,-1),r=t.current[t.current.length-1];return c([...n.current,r]),s(e)},[s,c]),redo:(0,Y.useCallback)(()=>
6{if(n.current.length===0)return t.current;let e=n.current[n.current.length-1],r=n.current.slice(0,-1);return c(r),s([...t.current,e])},[s,c]),replaceOperations:s}},dd=(e,t,n)=>{let r=e.current;return r?(t.current?t.current.resize(n.width,n.height):t.current=new Ei(r,{width:n.width,height:n.height,enableHighDPI:!0,backgroundColor:`rgba(0,0,0,0)`}),t.current):null},fd=({width:e,height:t})=>{let n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.useRef)(null),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null),s=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{dd(n,a,{width:e,height:t}),dd(r,o,{width:e,height:t}),dd(i,s,{width:e,height:t})},[t,e]),{backgroundCanvasRef:n,drawingCanvasRef:r,previewCanvasRef:i,backgroundEngineRef:a,drawingEngineRef:o,previewEngineRef:s}},pd=(e,t)=>{let n=Ku(e.zoom,e.minZoom,e.maxZoom),r=t.worldWidth*n,i=t.worldHeight*n,a=Math.min(0,t.viewWidth-r),o=Math.min(0,t.viewHeight-i),s=r<=t.viewWidth?(t.viewWidth-r)/2:0,c=i<=t.viewHeight?(t.viewHeight-i)/2:0;return{...e,zoom:n,offsetX:Ku(e.offsetX,a,s),offsetY:Ku(e.offsetY,o,c)}},md=(e,t=1)=>pd({offsetX:(e.viewWidth-e.worldWidth*t)/2,offsetY:(e.viewHeight-e.worldHeight*t)/2,zoom:t,minZoom:e.minZoom,maxZoom:e.maxZoom},e),hd=e=>{let t=(0,Y.useRef)(e);t.current=e;let[n,r]=(0,Y.useState)(()=>md(e,e.initialZoom)),i=(0,Y.useCallback)(e=>{let n=pd(e,t.current);return r(n),n},[]),a=(0,Y.useCallback)((e=n)=>{let r=t.current,i=(r.viewWidth/2-e.offsetX)/e.zoom,a=(r.viewHeight/2-e.offsetY)/e.zoom;return{centerXRatio:Ku(i/Math.max(r.worldWidth,1),0,1),centerYRatio:Ku(a/Math.max(r.worldHeight,1),0,1),zoom:e.zoom}},[n]),o=(0,Y.useCallback)((e,r=n)=>{if(`offsetX`in e||`offsetY`in e){let n=e;return pd({...r,offsetX:n.offsetX,offsetY:n.offsetY,zoom:n.zoom},t.current)}let i=t.current,a=e,o=Ku(a.zoom,r.minZoom,r.maxZoom),s=Ku(a.centerXRatio,0,1)*i.worldWidth,c=Ku(a.centerYRatio,0,1)*i.worldHeight;return pd({...r,zoom:o,offsetX:i.viewWidth/2-s*o,offsetY:i.viewHeight/2-c*o},i)},[n]),s=(0,Y.useCallback)(e=>{let t=o(e,n);return r(t),t},[o,n]),c=(0,Y.useCallback)(()=>i(md(t.current,t.current.initialZoom)),[i]),l=(0,Y.useCallback)((e,t)=>i({...n,offsetX:n.offsetX+e,offsetY:n.offsetY+t}),[i,n]),u=(0,Y.useCallback)((e,t)=>{let r=Ku(e,n.minZoom,n.maxZoom),a=(t.x-n.offsetX)/n.zoom,o=(t.y-n.offsetY)/n.zoom;return i({...n,zoom:r,offsetX:t.x-a*r,offsetY:t.y-o*r})},[i,n]),d=(0,Y.useCallback)(e=>{let r=e??{x:t.current.viewWidth/2,y:t.current.viewHeight/2};return u(n.zoom+t.current.zoomStep,r)},[n.zoom,u]),f=(0,Y.useCallback)(e=>{let r=e??{x:t.current.viewWidth/2,y:t.current.viewHeight/2};return u(n.zoom-t.current.zoomStep,r)},[n.zoom,u]),p=(0,Y.useCallback)(e=>({x:(e.x-n.offsetX)/n.zoom,y:(e.y-n.offsetY)/n.zoom}),[n.offsetX,n.offsetY,n.zoom]);return(0,Y.useEffect)(()=>{r(t=>pd({...t,minZoom:e.minZoom,maxZoom:e.maxZoom},e))},[e.maxZoom,e.minZoom,e.viewHeight,e.viewWidth,e.worldHeight,e.worldWidth]),(0,Y.useEffect)(()=>{e.onViewportChange?.(n)},[e.onViewportChange,n]),{viewport:n,fromSyncState:o,panBy:l,resetView:c,screenToWorld:p,toSyncState:a,updateViewport:i,updateViewportFromSyncState:s,zoomAt:u,zoomIn:d,zoomOut:f}},gd=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),_d=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),vd=()=>({serializeSnapshot:zu,deserializeSnapshot:Bu,serializeOperation:Vu,deserializeOperation:Hu,serializeViewport:Uu,deserializeViewport:Wu,createMessage:Gu}),yd=(e,t,n)=>{let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.click(),URL.revokeObjectURL(i)},bd=(e,t)=>{let n=document.createElement(`a`);n.href=e,n.download=t,n.click()},xd=({backgroundColor:e=Eu,disabled:t=!1,gridColor:n=Du,gridSize:r=40,hideGrid:i=!1,initialFillColor:a=ju.fillColor,initialSnapshot:o=null,initialStrokeColor:s=ju.strokeColor,initialStrokeWidth:c=ju.strokeWidth,initialTool:l=ju.tool,initialZoom:u=1,maxZoom:d=ku,minZoom:f=Ou,onChange:p,onOperationCommit:m,onSnapshotCommit:h,onRemoteOperationApplied:g,onRemoteSnapshotApplied:_,onRemoteViewportApplied:v,onViewportChange:y,onViewportCommit:b,remoteOperation:x,remoteSnapshot:S,remoteViewport:C,viewHeight:w,viewWidth:T,worldHeight:E=Tu,worldWidth:D=wu,zoomStep:O=Au})=>{let k=(0,Y.useMemo)(()=>vd(),[]),A=(0,Y.useMemo)(()=>o?Bu(o):null,[o]),[j,M]=(0,Y.useState)({tool:l,fillColor:a,strokeColor:s,strokeWidth:c}),N=(0,Y.useRef)(A?.backgroundColor??e),[P,F]=(0,Y.useState)(A?.backgroundColor??e),[I,L]=(0,Y.useState)(!i),[ee,R]=(0,Y.useState)(null),te=(0,Y.useRef)(null),z=(0,Y.useRef)(null),B=(0,Y.useRef)(new Map),ne=(0,Y.useRef)(null),re=(0,Y.useRef)(null),ie=(0,Y.useRef)(null),ae=(0,Y.useRef)(null),oe=(0,Y.useRef)(!1),se=(0,Y.useRef)(!1),ce=(0,Y.useRef)(A?.backgroundColor??e),le=(0,Y.useRef)(!1),ue=(0,Y.useRef)(!1),de=(0,Y.useRef)(null),V=ud(A?.operations??[]),fe=fd({width:T,height:w}),H=hd({worldWidth:D,worldHeight:E,viewWidth:T,viewHeight:w,initialZoom:u,minZoom:f,maxZoom:d,zoomStep:O,onViewportChange:y}),U=(0,Y.useCallback)((e=V.operations,t=H.viewport)=>({version:1,worldWidth:D,worldHeight:E,backgroundColor:N.current,operations:e,viewport:{offsetX:t.offsetX,offsetY:t.offsetY,zoom:t.zoom}}
6),[V.operations,H.viewport,E,D]),W=(0,Y.useCallback)(e=>{p?.(e,k)},[p,k]),pe=(0,Y.useCallback)(e=>{h?.(e,k)},[h,k]),me=(0,Y.useCallback)((e=H.viewport)=>H.toSyncState(e),[H]),he=(0,Y.useCallback)(e=>{let t=fe.previewCanvasRef.current;if(!t)return{x:0,y:0};let n=t.getBoundingClientRect();return{x:e.x-n.left,y:e.y-n.top}},[fe.previewCanvasRef]),ge=(0,Y.useCallback)(e=>{let t=fe.drawingCanvasRef.current,n=fe.drawingEngineRef.current;if(!t||!n)return H.screenToWorld(he(e));let r=t.getBoundingClientRect(),i=e.x-r.left,a=e.y-r.top,o=t.width/Math.max(r.width,1),s=t.height/Math.max(r.height,1),c=n.context.getTransform().inverse(),l=new DOMPoint(i*o,a*s).matrixTransform(c);return{x:l.x,y:l.y}},[he,fe.drawingCanvasRef,fe.drawingEngineRef,H]),_e=(0,Y.useCallback)(e=>{let t=typeof e==`function`?e(te.current):e;return te.current=t,R(t),t},[]),ve=(0,Y.useCallback)(e=>{let t=B.current.get(e[0]),n=B.current.get(e[1]);if(!t||!n)return null;let r=he(_d(t,n)),i=H.viewport;return{type:`pinch`,pointerIds:e,startDistance:Math.max(gd(t,n),1),startViewport:i,anchorWorld:{x:(r.x-i.offsetX)/i.zoom,y:(r.y-i.offsetY)/i.zoom}}},[he,H.viewport]),ye=(0,Y.useCallback)(e=>{let t=V.append(e),n=U(t);return W(n),m?.(e,n,k),e},[U,V,W,m,k]),be=(0,Y.useCallback)(()=>{R(null);let e=V.clear(),t=U(e);W(t),pe(t)},[U,V,W,pe]),xe=(0,Y.useCallback)(()=>{R(null);let e=V.undo(),t=U(e);W(t),pe(t)},[U,V,W,pe]),Se=(0,Y.useCallback)(()=>{R(null);let e=V.redo(),t=U(e);W(t),pe(t)},[U,V,W,pe]),Ce=(0,Y.useCallback)((t,{isRemote:n=!1,preserveViewport:r=!1}={})=>{let i=Bu(t),a=V.load(i.operations),o=H.viewport;r||(ue.current=!0,o=H.updateViewport({...H.viewport,offsetX:i.viewport.offsetX,offsetY:i.viewport.offsetY,zoom:i.viewport.zoom}),ae.current=Uu(H.toSyncState(o)));let s=i.backgroundColor||e;N.current=s,ce.current=s,le.current=!0,F(s),R(null);let c=U(a,o);return W(c),n||pe(c),n&&_?.(c,k),c},[U,V,W,pe,_,k,H]),we=(0,Y.useCallback)(e=>Ce(e),[Ce]),Te=(0,Y.useCallback)(e=>Ce(e,{isRemote:!0,preserveViewport:!0}),[Ce]),Ee=(0,Y.useCallback)(e=>{let t=Hu(e),n=V.append(t),r=U(n);return W(r),g?.(t,r,k),t},[U,V,W,g,k]),De=(0,Y.useCallback)(e=>{let t=Wu(e);ue.current=!0;let n=H.updateViewportFromSyncState(t),r=me(n);ae.current=Uu(r);let i=U(V.operations,n);return W(i),v?.(r,i,k),r},[U,me,V.operations,W,v,k,H]),Oe=(0,Y.useCallback)(()=>U(),[U]),ke=(0,Y.useCallback)(()=>me(),[me]),Ae=(0,Y.useCallback)(()=>Uu(me()),[me]),je=(0,Y.useCallback)(()=>zu(U()),[U]),Me=(0,Y.useCallback)((e=`image/png`,t)=>{let n=fe.backgroundCanvasRef.current,r=fe.drawingCanvasRef.current,i=fe.previewCanvasRef.current;if(!n||!r||!i)return``;let a=document.createElement(`canvas`);a.width=r.width,a.height=r.height;let o=a.getContext(`2d`);return o?(o.drawImage(n,0,0),o.drawImage(r,0,0),o.drawImage(i,0,0),a.toDataURL(e,t)):``},[fe.backgroundCanvasRef,fe.drawingCanvasRef,fe.previewCanvasRef]),Ne=(0,Y.useCallback)(()=>{fe.previewCanvasRef.current?.focus()},[fe.previewCanvasRef]),Pe=(0,Y.useCallback)(()=>{L(e=>!e)},[]),Fe=(0,Y.useCallback)(e=>{if(t)return;if(e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),e.currentTarget.focus(),B.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),e.pointerType===`touch`&&B.current.size>=2){let e=Array.from(B.current.keys()).slice(0,2),t=ve(e);t&&(z.current=t,_e(null));return}if(j.tool===`pan`){z.current={type:`pan`,lastClientPoint:{x:e.clientX,y:e.clientY},pointerId:e.pointerId};return}let n=ge({x:e.clientX,y:e.clientY});_e(sd(n,j)),z.current={type:`draw`,pointerId:e.pointerId}},[j,ve,t,ge,_e]),G=(0,Y.useCallback)(e=>{if(B.current.has(e.pointerId)&&B.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),!z.current||t)return;if(e.preventDefault(),e.stopPropagation(),z.current.type===`pinch`){let[e,t]=z.current.pointerIds,n=B.current.get(e),r=B.current.get(t);if(!n||!r)return;let i=Math.max(gd(n,r),1),a=he(_d(n,r)),o=Ku(z.current.startViewport.zoom*(i/z.current.startDistance),z.current.startViewport.minZoom,z.current.startViewport.maxZoom);H.updateViewport({...z.current.startViewport,zoom:o,offsetX:a.x-z.current.anchorWorld.x*o,offsetY:a.y-z.current.anchorWorld.y*o});return}if(z.current.type===`pan`){let t=e.clientX-z.current.lastClientPoint.x,n=e.clientY-z.current.lastClientPoint.y;z.current={...z.current,lastClientPoint:{x:e.clientX,y:e.clientY}},H.panBy(t,n);return}let n=e.nativeEvent.getCoalescedEvents?.()??[e.nativeEvent];_e(e=>{if(!e)return e;let t=e;for(let e of n){let n=ge({x:e.clientX,y:e.clientY});t=cd(t,n)}return t})},[t,ge,_e,H]),Ie=(0,Y.useCallback)(e=>{if(B.current.delete(e.pointerId),!z.current){e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId);return}if(e.preventDefault(),e.stopPropagation(),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),z.current.type===`pinch`){if(B.current.size>=2){let e=Array.from(B.current.keys()).slice(0,2);z.current=ve(e)}else z.current=null;_e(null);return}if(z.current.type===`draw`){let t=ge({x:e.clientX,y:e.clientY}),n=_e(e=>e&&cd(e,t));n&&ld(n)&&ye(n)}z.current=null,_e(null)},[ye,ve,ge,_e]),Le=(0,Y.useCallback)(e=>{B.current.delete(e.pointerId),z.current&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),z.current=null,_e(null))},[_e]),Re=(0,Y.useCallback)(e=>{e.preventDefault();let t=he({x:e.clientX,y:e.clientY});if(e.deltaY<0){H.zoomIn(t);return}H.zoomOut(t)},[he,H]),ze=(0,Y.useCallback)(e=>{M(t=>({...t,tool:e}))},[]),K=(0,Y.useCallback)(e=>{M(t=>({...t,strokeColor:e}))},[]),Be=(0,Y.useCallback)(e=>{M(t=>({...t,fillColor:e}))},[]),Ve=(0,Y.useCallback)(e=>{N.current=e,F(e)},[]),He=(0,Y.useCallback)(e=>{M(t=>({...t,strokeWidth:Math.max(1,Math.min(150,e))}))},[]),q=(0,Y.useCallback)(()=>{de.current?.click()},[]),Ue=(0,Y.useCallback)(e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>{typeof n.result==`string`&&we(n.result)},n.readAsText(t),e.target.value=``},[we]),We=(0,Y.useCallback)(()=>{yd(je(),`canvas-draw-${Date.now()}.json`,`application/json`)},[je]),Ge=(0,Y.useCallback)(()=>{let e=Me();e&&bd(e,`canvas-draw-${Date.now()}.png`)},[Me]);return(0,Y.useEffect)(()=>{N.current=e,ce.current=e,le.current=!0,F(e)},[e]),(0,Y.useEffect)(()=>
6{if(N.current=P,!se.current){se.current=!0;return}if(le.current){le.current=!1;return}if(P===ce.current)return;ce.current=P;let e=U(V.operations,H.viewport);W(e),pe(e)},[U,P,V.operations,W,pe,H.viewport]),(0,Y.useEffect)(()=>{L(!i)},[i]),(0,Y.useEffect)(()=>{if(!x)return;let e=typeof x==`string`?x:Vu(x);e!==ne.current&&(ne.current=e,Ee(x))},[Ee,x]),(0,Y.useEffect)(()=>{if(!S)return;let e=typeof S==`string`?S:zu(S);e!==re.current&&(re.current=e,Te(S))},[Te,S]),(0,Y.useEffect)(()=>{if(!C)return;let e=typeof C==`string`?C:Uu(C);e!==ie.current&&(ie.current=e,De(C))},[De,C]),(0,Y.useEffect)(()=>{if(!oe.current){oe.current=!0;return}if(ue.current){ue.current=!1;return}if(!b)return;let e=me(H.viewport),t=Uu(e);t!==ae.current&&(ae.current=t,b(e,U(V.operations,H.viewport),k))},[U,me,V.operations,b,k,H.viewport]),(0,Y.useLayoutEffect)(()=>{let e=fe.backgroundEngineRef.current;if(!e||T<=0||w<=0)return;let t=e.context,i=e.canvas;Yu(t,i),t.fillStyle=P,t.fillRect(0,0,i.width,i.height),Xu(t,i,T,H.viewport),I&&od(t,H.viewport,{width:T,height:w},{width:D,height:E},r,n),t.save(),t.strokeStyle=`rgba(15, 23, 42, 0.15)`,t.lineWidth=1/H.viewport.zoom,t.strokeRect(0,0,D,E),t.restore()},[P,n,r,I,fe.backgroundEngineRef,w,T,H.viewport,E,D]),(0,Y.useLayoutEffect)(()=>{let e=fe.drawingEngineRef.current;if(!e||T<=0||w<=0)return;let t=e.context,n=e.canvas;Yu(t,n),Xu(t,n,T,H.viewport);for(let e of V.operations)ad(t,e);ee?.tool===`eraser`&&ad(t,ee)},[ee,V.operations,fe.drawingEngineRef,w,T,H.viewport]),(0,Y.useLayoutEffect)(()=>{let e=fe.previewEngineRef.current;if(!e||T<=0||w<=0)return;let t=e.context,n=e.canvas;Yu(t,n),!(!ee||ee.tool===`eraser`)&&(Xu(t,n,T,H.viewport),ad(t,ee))},[ee,fe.previewEngineRef,w,T,H.viewport]),{activeOperation:ee,brush:j,canRedo:V.redoStack.length>0,canUndo:V.operations.length>0,clear:be,currentBackgroundColor:P,downloadPngImage:Ge,downloadSnapshotJson:We,exportImage:Me,exportSnapshot:Oe,exportSnapshotString:je,exportViewport:ke,exportViewportString:Ae,fileInputRef:de,focusCanvas:Ne,history:V,importSnapshot:we,isGridVisible:I,onImportFile:Ue,onPointerCancel:Le,onPointerDown:Fe,onPointerMove:G,onPointerUp:Ie,onWheel:Re,setFillColor:Be,setBackgroundColor:Ve,setStrokeColor:K,setStrokeWidth:He,setTool:ze,surfaces:fe,syncHelpers:k,toggleGrid:Pe,triggerImport:q,undo:xe,redo:Se,viewportApi:H,applyRemoteOperation:Ee,applyRemoteSnapshot:Te,applyRemoteViewport:De}},Sd=e=>{let[t,n]=(0,Y.useState)({width:0,height:0});return(0,Y.useLayoutEffect)(()=>{if(!e)return;let t=()=>{let t=e.getBoundingClientRect();n({width:t.width,height:t.height})};t();let r=new ResizeObserver(()=>t());return r.observe(e),()=>{r.disconnect()}},[e]),t},Cd=e=>{switch(e){case`pan`:return`cursor-grab active:cursor-grabbing`;default:return``}},wd=(e,t,n)=>{if(e!==`eraser`)return;let r=Math.max(1,t*n),i=Math.max(12,Math.min(96,Math.round(r))),a=i+8,o=Math.round(a/2),s=Math.max(i/2,1),c=Math.max(2,Math.min(5,Math.round(i/5)));return{cursor:`url("data:image/svg+xml,${encodeURIComponent(`
7    <svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${a}" viewBox="0 0 ${a} ${a}" fill="none">
8      <circle cx="${o}" cy="${o}" r="${s}" fill="white" fill-opacity="0.16" stroke="#ef4444" stroke-width="2"/>
9      <path d="M ${o-c} ${o} H ${o+c}" stroke="#111827" stroke-opacity="0.8" stroke-width="1" stroke-linecap="round"/>
10      <path d="M ${o} ${o-c} V ${o+c}" stroke="#111827" stroke-opacity="0.8" stroke-width="1" stroke-linecap="round"/>
11    </svg>
12  `)}") ${o} ${o}, cell`}},Td=(0,Y.forwardRef)(({className:e,height:t,showToolbar:n=!0,toolbarHiddenControls:r,width:i,...a},o)=>{let s=(0,Y.useRef)(null),c=Sd(s.current),l=Math.max(1,i??c.width??1200),u=Math.max(1,t??c.height??720),d=xd({...a,viewWidth:l,viewHeight:u}),f=(0,Y.useMemo)(()=>wd(d.brush.tool,d.brush.strokeWidth,d.viewportApi.viewport.zoom),[d.brush.strokeWidth,d.brush.tool,d.viewportApi.viewport.zoom]);return(0,Y.useImperativeHandle)(o,()=>({undo:d.undo,redo:d.redo,clear:d.clear,resetView:d.viewportApi.resetView,exportSnapshot:d.exportSnapshot,exportSnapshotString:d.exportSnapshotString,exportViewport:d.exportViewport,exportViewportString:d.exportViewportString,importSnapshot:d.importSnapshot,a
12pplyRemoteOperation:d.applyRemoteOperation,applyRemoteSnapshot:d.applyRemoteSnapshot,applyRemoteViewport:d.applyRemoteViewport,exportImage:d.exportImage,focusCanvas:d.focusCanvas}),[d]),(0,X.jsx)(`div`,{ref:s,className:q(`relative h-screen w-full overflow-hidden bg-slate-50 p-2 md:p-4`,e),style:{minHeight:t??void 0,width:i??void 0},children:(0,X.jsxs)(`div`,{className:`relative flex h-full w-full items-center justify-center`,children:[(0,X.jsx)(Nu,{backgroundCanvasRef:d.surfaces.backgroundCanvasRef,drawingCanvasRef:d.surfaces.drawingCanvasRef,previewCanvasRef:d.surfaces.previewCanvasRef,disabled:a.disabled,height:u,onPointerCancel:d.onPointerCancel,onPointerDown:d.onPointerDown,onPointerMove:d.onPointerMove,onPointerUp:d.onPointerUp,onWheel:d.onWheel,toolCursorClassName:Cd(d.brush.tool),toolCursorStyle:f,width:l}),n&&(0,X.jsx)(Lu,{brush:d.brush,canRedo:d.canRedo,canUndo:d.canUndo,currentBackgroundColor:d.currentBackgroundColor,hiddenControls:r,isGridVisible:d.isGridVisible,onClear:d.clear,onDownloadImage:d.downloadPngImage,onDownloadJson:d.downloadSnapshotJson,onRedo:d.redo,onResetView:d.viewportApi.resetView,onSetBackgroundColor:d.setBackgroundColor,onSetFillColor:d.setFillColor,onSetStrokeColor:d.setStrokeColor,onSetStrokeWidth:d.setStrokeWidth,onSetTool:d.setTool,onToggleGrid:d.toggleGrid,onTriggerImport:d.triggerImport,onUndo:d.undo,onZoomIn:()=>d.viewportApi.zoomIn(),onZoomOut:()=>d.viewportApi.zoomOut(),zoom:d.viewportApi.viewport.zoom}),(0,X.jsx)(Pu,{operationCount:d.history.operations.length,tool:d.brush.tool,zoom:d.viewportApi.viewport.zoom}),(0,X.jsx)(`input`,{ref:d.fileInputRef,type:`file`,accept:`application/json`,className:`hidden`,onChange:d.onImportFile})]})})});Td.displayName=`CanvasDraw`;var Ed=({imageUrl:e,onClose:t})=>(0,X.jsx)(he,{images:[e],isOpen:!0,onClose:t,showThumbnails:!1,showIndex:!1,showRotation:!1,showFullscreen:!1,closeOnBackdropClick:!0,overlayClassName:`z-[1200]`}),Dd=20,Od=100,kd={flat:new Di(Di.flat,new Li(Od,Od),new Li(0,0)),pointy:new Di(Di.pointy,new Li(Od,Od),new Li(0,0))};function Ad(e){let t=kd.flat.hexToPixel(e);return{x:t.x,y:t.y,transform:`translate(${t.x.toFixed(0)},${t.y.toFixed(0)})`}}var jd=kd.flat.polygonCorners(new Fi(0,0,0)).map(e=>`${e.x.toFixed(0)},${e.y.toFixed(0)}`).join(` `),Md=`أ.ب.ت.ث.ج.ح.خ.د.ذ.ر.ز.س.ش.ص.ض.ط.ظ.ع.غ.ف.ق.ك.ل.م.ن.هـ.و.ي`.split(`.`).reverse(),Nd=[`ا`,`أ`,`إ`,`آ`],Pd=({letter:e,className:t,style:n})=>{let[r,i]=(0,Y.useState)([]);(0,Y.useEffect)(()=>{let e=Ai.qoffsetToCube.bind(null,Ai.ODD),t=ki(0,9,0,7,e);i(t)},[]);let a=(0,Y.useMemo)(()=>r.find(e=>e.col===4&&e.row===3),[r]),o=(e,t)=>e===a,s=()=>{let e=r.filter((e,t)=>{let n=c(e,t);return o(e,t)||n});if(e.length===0)return[0,0,100,100];let t=Oi(kd.flat,e);return[t.left-Dd,t.top-Dd,t.right-t.left+40,t.bottom-t.top+40]},c=(e,t)=>{let n=r.findIndex(e=>e===a);if(o(e,n))return``;let i=[];r.forEach((e,t)=>{if(t===n)return;let r=Math.max(Math.abs(e.q-a.q),Math.abs(e.r-a.r),Math.abs(e.s-a.s)),o=e.q-a.q,s=e.r-a.r,c=Math.atan2(s,o)*180/Math.PI;c=(c+260-20)%360,i[r]||(i[r]=[]),i[r].push({index:t,hex:e,angle:c})}
12),i.forEach(e=>{e&&e.sort((e,t)=>e.angle-t.angle)});let s=[];i.forEach(e=>{e&&e.forEach(e=>s.push(e.index))});let c=s.indexOf(t);return c<Md.length?Md[c]:``};return(0,X.jsx)(`figure`,{className:q(`select-none pointer-events-none`,t),onContextMenu:e=>e.preventDefault(),onDragStart:e=>e.preventDefault(),children:(0,X.jsx)(`svg`,{viewBox:s().join(` `),style:n,children:(0,X.jsx)(`g`,{fill:`white`,stroke:`black`,children:(0,X.jsx)(`g`,{className:`grid`,children:r.map((t,n)=>{let r=c(t,n),i=o(t,n);if(!i&&!r)return null;let a=!!e&&(e===`ه`?r===`هـ`:Nd.includes(e)?r===`أ`:e===r);return(0,X.jsxs)(`g`,{transform:Ad(t).transform,style:{userSelect:`none`},children:[(0,X.jsx)(`polygon`,{points:jd,fill:a?`#10B981`:`white`,stroke:a?`#059669`:`black`,strokeWidth:a?`3`:`1`}),i?(0,X.jsx)(`image`,{href:`/images/favicon.png`,x:`-45`,y:`-45`,width:`90`,height:`90`}):(0,X.jsx)(`text`,{textAnchor:`middle`,dominantBaseline:`middle`,fill:a?`white`:`black`,className:`text-6xl font-bold select-none pointer-events-none`,children:r})]},n)})})})})})},Fd=({questionId:e,teamId:t,question:n,hardcore:r,category:i,action:a,teamIndex:o,isPlayerHost:s,isSpectator:c,contentHeight:l,roomId:u,onImageClick:d,onQuestionVideoEnded:f,onQuestionAudioEnded:p,hideQuestionVideo:m,hideQuestionAudio:h,onMediaPlaybackChange:g,mediaReloadKey:_,onRetryMedia:v})=>{let{t:y}=W(),b=(0,Y.useMemo)(()=>i.guess?n.answers?.[o]:n.answers?.find(e=>e.correct),[n.answers,o,i.guess]),x=a===`showAnswer`&&b!==void 0&&!i.guess||a===`hideAnswer`&&i.guess===!0&&!c&&(r||!s),S=a===`hideAnswer`&&!i.guess,[C,w]=(0,Y.useState)({isLoading:!1,hasError:!1}),[T,E]=(0,Y.useState)({isLoading:!1,hasError:!1}),[O,k]=(0,Y.useState)({isLoading:!1,hasError:!1}),[A,j]=(0,Y.useState)({isLoading:!1,hasError:!1}),[M,N]=(0,Y.useState)({isLoading:!1,hasError:!1}),[P,I]=(0,Y.useState)({isLoading:!1,hasError:!1});return(0,Y.useEffect)(()=>{w({isLoading:!!b?.image&&x,hasError:!1})},[b?.image,x,_]),(0,Y.useEffect)(()=>{E({isLoading:!!b?.video&&x,hasError:!1})},[b?.video,x,_]),(0,Y.useEffect)(()=>{k({isLoading:!!b?.audio&&x,hasError:!1})},[b?.audio,x,_]),(0,Y.useEffect)(()=>{j({isLoading:!!n?.image&&S,hasError:!1})},[n?.image,S,_]),(0,Y.useEffect)(()=>{N({isLoading:!!n?.video&&S&&!m,hasError:!1})},[n?.video,S,m,_]),(0,Y.useEffect)(()=>{I({isLoading:!!n?.audio&&S&&!h,hasError:!1})},[n?.audio,S,h,_]),(0,Y.useEffect)(()=>{g?.(!1)},[a,b?.video,n.video,g]),(0,X.jsxs)(`div`,{className:`w-full h-auto flex items-center justify-center`,children:[x&&(0,X.jsxs)(`div`,{className:`w-full flex flex-col items-center justify-center gap-2 sm:gap-4 p-2 screen-resize [@media(orientation:landscape)_and_(max-width:1024px)]:gap-1 [@media(orientation:landscape)_and_(max-width:1024px)]:p-1`,children:[i.guess&&!c&&(r||!s)&&b?.answer&&(0,X.jsx)(`span`,{className:`flex-1 min-w-0 break-words [@media(orientation:landscape)_and_(max-width:1024px)]:leading-tight`,children:b.answer}),b?.image&&(0,X.jsx)(`div`,{className:`w-full flex flex-col items-center justify-center gap-2`,children:C.hasError?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-4 py-3 text-center text-sm`,children:[(0,X.jsx)(`span`,{children:y(`Failed to load media. Please try again.`)}),(0,X.jsx)(F,{size:`sm`,variant:`outline`,onClick:()=>{w({isLoading:!0,hasError:!1}),v()},children:y(`Try Again`)})]}):(0,X.jsxs)(X.Fragment,{children:[C.isLoading&&(0,X.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,X.jsx)(ar,{className:`h-4 w-4 animate-spin`}),(0,X.jsx)(`span`,{children:y(`Loading...`)})]}),(0,X.jsx)(`img`,{src:b?.image,alt:b.answer,loading:`lazy`,className:`max-w-full h-full object-contain rounded-md cursor-pointer border-2 border-[#69bbcf] shadow-md hover:border-[#69bbcf]/70 hover:shadow-lg hover:opacity-95 transition-all`,style:{maxHeight:l?`${l-20}px`:`30vh`},onLoad:()=>w({isLoading:!1,hasError:!1}),onError:()=>w({isLoading:!1,hasError:!0}),onClick:()=>d(b.image)},`${_}-${e}-answer-image`)]})}),b?.video&&(0,X.jsx)(`div`,{className:`w-full max-w-3xl [@media(orientation:landscape)_and_(max-width:1024px)]:max-w-2xl`,children:T.hasError?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-4 py-3 text-center text-sm`,children:[(0,X.jsx)(`span`,{children:y(`Failed to load media. Please try again.`)}),(0,X.jsx)(F,{size:`sm`,variant:`outline`,onClick:()=>{E({isLoading:!0,hasError:!1}),v()},children:y(`Try Again`)})]}):(0,X.jsxs)(X.Fragment,{children:[T.isLoading&&(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,X.jsx)(ar,{className:`h-4 w-4 animate-spin`}),(0,X.jsx)(`span`,{children:y(`Loading...`)})]}),(0,X.jsx)(`video`,{src:b.video,controls:!0,className:`w-full rounded-md`,controlsList:`nodownload`,onLoadStart:()=>E({isLoading:!0,hasError:!1}),onLoadedData:()=>E({isLoading:!1,hasError:!1}),onError:()=>E({isLoading:!1,hasError:!0}),onPlay:()=>g?.(!0),onPause:()=>g?.(!1),onEnded:()=>g?.(!1),style:{maxHeight:l?`${l-20}px`:`30vh`},children:y(`Your browser does not support video playback`)},`${_}-${e}-answer-video`)]})}),b?.audio&&(0,X.jsx)(`div`,{className:`w-full max-w-xl [@media(orientation:landscape)_and_(max-width:1024px)]:max-w-lg`,children:O.hasError?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-4 py-3 text-center text-sm`,children:[(0,X.jsx)(`span`,{children:y(`Failed to load media. Please try again.`)}),(0,X.jsx)(F,{size:`sm`,variant:`outline`,onClick:()=>{k({isLoading:!0,hasError:!1}),v()},children:y(`Try Again`)})]}):(0,X.jsxs)(X.Fragment,{children:[O.isLoading&&(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,X.jsx)(ar,{className:`h-4 w-4 animate-spin`}),(0,X.jsx)(`span`,{children:y(`Loading...`)})]}),(0,X.jsx)(`audio`,{src:b.audio,controls:!0,className:`w-full`,controlsList:`nodownload`,onLoadStart:()=>k({isLoading:!0,hasError:!1}),onLoadedData:()=>k({isLoading:!1,hasError:!1}),onError:()=>k({isLoading:!1,hasError:!0}),children:y(`Your browser does not support audio playback`)},`${_}-${e}-answer-audio`)]})})]}),S&&(0,X.jsxs)(`div`,{className:`w-full flex flex-col items-center justify-center gap-2 sm:gap-4 p-2 screen-resize [@media(orientation:landscape)_and_(max-width:1024px)]:gap-1 [@media(orientation:landscape)_and_(max-width:1024px)]:p-1`,children:[n.letters&&(0,X.jsx)(`div`,{className:`flex justify-center`,children:(0,X.jsx)(Pd,{className:`w-64 [@media(orientation:landscape)_and_(max-width:1024px)]:w-40`,letter:n.letter,style:{maxHeight:l?`${l-20}px`:`30vh`}})}),s&&n?.preview&&(0,X.jsx)(`div`,{className:`flex flex-col items-center justify-center gap-2 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-1 [@media(orientation:landscape)_and_(max-width:1024px)]:w-[140px] [@media(orientation:landscape)_and_(max-width:1024px)]:h-[140px]`,children:(0,X.jsx)(di,{size:200,className:`w-full h-full`,style:{maxHeight:l?`${l-20}px`:`30vh`},value:`${D.url}/q/${u}/preview?q=${e}&t=${t}`,viewBox:`0 0 200 200`})}),n?.image&&(0,X.jsx)(`div`,{className:`flex items-center justify-center w-full`,children:A.hasError?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-4 py-3 text-center text-sm`,children:[(0,X.jsx)(`span`,{children:y(`Failed to load media. Please try again.`)}),(0,X.jsx)(F,{size:`sm`,variant:`outline`,onClick:()=>{j({isLoading:!0,hasError:!1}),v()},children:y(`Try Again`)})]}):(0,X.jsxs)(X.Fragment,{children:[A.isLoading&&(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,X.jsx)(ar,{className:`h-4 w-4 animate-spin`}),(0,X.jsx)(`span`,{children:y(`Loading...`)})]}),(0,X.jsx)(`img`,{src:n?.image,alt:n?.question,loading:`lazy`,className:`max-w-full h-full object-contain rounded-md cursor-pointer border-2 border-[#69bbcf] shadow-md hover:border-[#69bbcf]/70 hover:shadow-lg hover:opacity-95 transition-all`,style:{maxHeight:l?`${l-20}px`:`30vh`},onLoad:()=>j({isLoading:!1,hasError:!1}),onError:()=>j({isLoading:!1,hasError:!0}),onClick:()=>d(n.image)},`${_}-${e}-question-image`)]})}),n?.video&&!m&&(0,X.jsx)(`div`,{className:`w-full max-w-3xl [@media(orientation:landscape)_and_(max-width:1024px)]:max-w-2xl`,children:M.hasError?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-4 py-3 text-center text-sm`,children:[(0,X.jsx)(`span`,{children:y(`Failed to load media. Please try again.`)}),(0,X.jsx)(F,{size:`sm`,variant:`outline`,onClick:()=>{N({isLoading:!0,hasError:!1}),v()},children:y(`Try Again`)})]}):(0,X.jsxs)(X.Fragment,{children:[M.isLoading&&(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,X.jsx)(ar,{className:`h-4 w-4 animate-spin`}),(0,X.jsx)(`span`,{children:y(`Loading...`)})]}),(0,X.jsx)(`video`,{src:n.video,controls:!0,className:`w-full rounded-lg`,controlsList:`nodownload`,onLoadStart:()=>N({isLoading:!0,hasError:!1}),onLoadedData:()=>N({isLoading:!1,hasError:!1}),onError:()=>N({isLoading:!1,hasError:!0}),onPlay:()=>g?.(!0),onPause:()=>g?.(!1),onEnded:()=>{g?.(!1),f?.()},style:{maxHeight:l?`${l-20}px`:`30vh`},children:y(`Your browser does not support video playback`)},`${_}-${e}
12-question-video`)]})}),n?.audio&&!h&&(0,X.jsx)(`div`,{className:`w-full max-w-xl [@media(orientation:landscape)_and_(max-width:1024px)]:max-w-lg`,children:P.hasError?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-4 py-3 text-center text-sm`,children:[(0,X.jsx)(`span`,{children:y(`Failed to load media. Please try again.`)}),(0,X.jsx)(F,{size:`sm`,variant:`outline`,onClick:()=>{I({isLoading:!0,hasError:!1}),v()},children:y(`Try Again`)})]}):(0,X.jsxs)(X.Fragment,{children:[P.isLoading&&(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,X.jsx)(ar,{className:`h-4 w-4 animate-spin`}),(0,X.jsx)(`span`,{children:y(`Loading...`)})]}),(0,X.jsx)(`audio`,{src:n.audio,controls:!0,className:`w-full`,controlsList:`nodownload`,onLoadStart:()=>I({isLoading:!0,hasError:!1}),onLoadedData:()=>I({isLoading:!1,hasError:!1}),onError:()=>I({isLoading:!1,hasError:!0}),onEnded:p,children:y(`Your browser does not support audio playback`)},`${_}-${e}-question-audio`)]})})]})]})},Id=120,Ld=.4,Rd=e=>JSON.stringify({version:e.version,worldWidth:e.worldWidth,worldHeight:e.worldHeight,backgroundColor:e.backgroundColor,operations:e.operations}),zd=(e,t)=>{try{return Rd(t?t.deserializeSnapshot(e):JSON.parse(e))}catch{return e}},Bd=({questionId:e,question:t,category:n,roomId:r,teamId:i,teamIndex:a,mediaReloadKey:o,onRetryMedia:s,selectedPlayerNames:c,canDraw:l,initialSnapshot:u,initialViewport:d})=>{let{t:f}=W(),{player:p,subscriptionClient:m}=J(),{sendEvent:h}=ru(),g=(0,Y.useRef)(null),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(d??null),C=(0,Y.useRef)(0),w=(0,Y.useRef)(!1),T=(0,Y.useRef)(u??void 0),E=(0,Y.useRef)(u??null),D=(0,Y.useRef)(u?zd(u):null),O=(0,Y.useRef)(d??null),k=(0,Y.useRef)(null),j=(0,Y.useRef)(null),M=(0,Y.useRef)(null),[N,P]=(0,Y.useState)(null),[I,L]=(0,Y.useState)(null),ee=(0,Y.useMemo)(()=>n.guess?t.answers?.[a]?.answer:t.answers?.find(e=>e.correct)?.answer,[n.guess,t.answers,a]);(0,Y.useEffect)(()=>{b(null),S(d??null),C.current=0,w.current=!1,T.current=u??void 0,E.current=u??null,D.current=u?zd(u):null,O.current=d??null,k.current=null,j.current=null,M.current!==null&&(window.clearTimeout(M.current),M.current=null)},[u,d,e]),(0,Y.useEffect)(()=>()=>{M.current!==null&&window.clearTimeout(M.current)},[]),(0,Y.useEffect)(()=>{let e=()=>{typeof window>`u`||L(Math.max(240,Math.round(window.innerHeight*.55)))};return e(),window.addEventListener(`resize`,e),window.addEventListener(`orientationchange`,e),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`orientationchange`,e)}},[]);let R=(0,Y.useCallback)(()=>{j.current=null,M.current!==null&&(window.clearTimeout(M.current),M.current=null)},[]),te=(0,Y.useCallback)(e=>{e&&e!==O.current&&(R(),O.current=e,S(e))},[R]),z=(0,Y.useCallback)(t=>{let n=t;if(n.playerId!==p?.id&&!(n.questionId&&n.questionId!==e))switch(n.type){case`DRAW_OPERATION`:n.drawOperation&&b(n.drawOperation),te(n.drawViewport);break;case`DRAW_SNAPSHOT`:n.drawSnapshot&&(w.current=!0,E.current=n.drawSnapshot,D.current=zd(n.drawSnapshot),g.current?.applyRemoteSnapshot(n.drawSnapshot)),te(n.drawViewport);break;case`DRAW_VIEWPORT`:te(n.drawViewport)}},[te,p?.id,e]);(0,Y.useEffect)(()=>(m.on([`DRAW_OPERATION`,`DRAW_SNAPSHOT`,`DRAW_VIEWPORT`],z),()=>{m.off([`DRAW_OPERATION`,`DRAW_SNAPSHOT`,`DRAW_VIEWPORT`],z)}),[z,m]);let B=(0,Y.useCallback)(t=>{j.current=t,M.current!==null&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{let t=j.current;M.current=null,t&&t!==k.current&&t!==O.current&&(k.current=t,j.current=null,h(`DRAW_VIEWPORT`,{questionId:e,drawViewport:t}))},Id)},[e,h]);return(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-2xl border border-primary/15 bg-card/70 px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(ln,{className:`h-4 w-4 text-primary`}),c?.length?c.join(`، `):f(`Select a player to start drawing.`)]})}),(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:l&&(0,X.jsxs)(F,{size:`sm`,variant:`outline`,onClick:()=>v(e=>!e),children:[_?(0,X.jsx)(Mt,{className:`h-4 w-4`}):(0,X.jsx)(Pt,{className:`h-4 w-4`}),f(_?`Hide Answer`:`Show Answer`)]})})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-3xl border border-card/60`,children:(0,X.jsx)(Td,{ref:g,className:q(`h-full min-h-[320px] bg-slate-50 p-0 md:p-0`,!l&&`pointer-events-none`),disabled:!l,showToolbar:l,initialZoom:Ld,initialSnapshot:T.current,toolbarHiddenControl
12s:{exportJson:!0,exportImage:!0,import:!0},remoteOperation:y,remoteViewport:x,onRemoteOperationApplied:(e,t,n)=>{C.current=t.operations.length,E.current=n.serializeSnapshot(t),D.current=Rd(t)},onRemoteSnapshotApplied:(e,t)=>{C.current=e.operations.length,E.current=t.serializeSnapshot(e),D.current=Rd(e)},onChange:e=>{C.current=e.operations.length,w.current&&=!1},onSnapshotCommit:(t,n)=>{let r=n.serializeSnapshot(t);E.current=r,D.current=Rd(t),h(`DRAW_SNAPSHOT`,{questionId:e,drawSnapshot:r,drawViewport:n.serializeViewport(t.viewport)})},onOperationCommit:(t,n,r)=>{if(!l)return;let i=r.serializeSnapshot(n);E.current=i,D.current=Rd(n),h(`DRAW_OPERATION`,{questionId:e,drawOperation:r.serializeOperation(t),drawSnapshot:i,drawViewport:r.serializeViewport(n.viewport)})},onViewportCommit:(e,t,n)=>{let r=n.serializeViewport(e);B(r)}},e)}),(0,X.jsx)(_e,{open:l&&_,onOpenChange:e=>{!e&&N||v(e)},children:(0,X.jsxs)(A,{side:`bottom`,className:`h-[78dvh] max-h-[78dvh] rounded-t-3xl px-4 pb-4 pt-8 sm:h-[70dvh] sm:max-h-[70dvh]`,onPointerDownOutside:e=>{N&&e.preventDefault()},onInteractOutside:e=>{N&&e.preventDefault()},children:[(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[ee?(0,X.jsx)(`div`,{className:`mb-3 flex-shrink-0 rounded-2xl border border-success/20 bg-success/10 px-4 py-3 text-center text-base font-bold text-success`,children:ee}):null,(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto styled-scrollbar`,children:(0,X.jsx)(Fd,{questionId:e,question:t,category:n,teamId:i,action:`showAnswer`,hardcore:!1,teamIndex:a,isPlayerHost:!1,isSpectator:!1,roomId:r,contentHeight:I,onImageClick:P,mediaReloadKey:o,onRetryMedia:s})})]}),N&&(0,X.jsx)(Ed,{imageUrl:N,onClose:()=>P(null)})]})})]})},Vd=e=>[`أ`,`ب`,`ج`,`د`,`هـ`,`و`,`ز`,`ح`,`ط`,`ي`][e]||(e+1).toString(),Hd=({questionId:e,question:t,category:n,hardcore:r,roomId:i,teams:a,action:o,isPlayerHost:s,isSpectator:c,onImageClick:l})=>{if(o!==`showAnswer`&&o!==`hideAnswer`||!t.answers||t.answers.length<=1)return null;let u=n.guess&&s&&!r&&o===`hideAnswer`,d=n.guess&&c&&o===`hideAnswer`;if(n.guess&&o===`hideAnswer`&&!u&&!d)return null;let f=t.answers?.map((e,t)=>({answer:e,index:t}))??[];return(0,X.jsx)(`div`,{className:q(`grid grid-cols-1 sm:grid-cols-2 gap-2 sm:gap-3 w-full px-2 sm:px-4 mt-2 sm:mt-4 flex-shrink-0 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-1.5 [@media(orientation:landscape)_and_(max-width:1024px)]:px-1 [@media(orientation:landscape)_and_(max-width:1024px)]:mt-1`,n.guess&&`grid-cols-2`),children:f.map(({answer:r,index:c})=>(0,X.jsxs)(K,{className:q(`relative flex flex-col items-center gap-3 rounded-xl border-2 transition-all duration-200`,`text-sm sm:text-lg font-medium`,`[@media(orientation:landscape)_and_(max-width:1024px)]:gap-1.5 [@media(orientation:landscape)_and_(max-width:1024px)]:rounded-lg [@media(orientation:landscape)_and_(max-width:1024px)]:border [@media(orientation:landscape)_and_(max-width:1024px)]:text-xs`,o===`showAnswer`&&r.correct&&!n.guess?`bg-success text-white border-success shadow-md scale-[1.02]`:`bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700 hover:border-primary/50 hover:shadow-sm`),children:[n.guess&&(0,X.jsx)(w,{children:a[c].name}),r?.image&&(0,X.jsx)(`div`,{className:`w-full aspect-[16/10] sm:aspect-auto sm:h-[191px] border-b border-gray-200 dark:border-gray-700 overflow-hidden rounded-t-md [@media(orientation:landscape)_and_(max-width:1024px)]:h-[110px]`,children:u?(0,X.jsx)(di,{size:128,className:`w-full h-full`,value:`${D.url}/q/${i}/preview?q=${e}&t=${a[c].id}`,viewBox:`0 0 128 128`}):(0,X.jsx)(`img`,{src:r?.image,alt:r.answer,loading:`lazy`,className:`w-full h-full object-contain cursor-pointer`,onClick:()=>l(r.image)})}),(0,X.jsxs)(L,{className:`w-full flex items-center gap-2 sm:gap-3 p-2 sm:p-4 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-2 [@media(orientation:landscape)_and_(max-width:1024px)]:p-2`,children:[!n.guess&&(0,X.jsx)(`div`,{className:q(`flex items-center justify-center w-7 h-7 sm:w-10 sm:h-10 rounded-full font-bold shrink-0 transition-colors`,`[@media(orientation:landscape)_and_(max-width:1024px)]:w-6 [@media(orientation:landscape)_and_(max-width:1024px)]:h-6`,o===`showAnswer`&&r.correct?`bg-white text-success`:`bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300`),children:Vd(c)}),(0,X.jsx)(`span`,{className:`flex-1 min-w-0 break-words [@media(orientation:landscape)_and_(max-width:1024px)]:leading-tight`,children:r.answer}),o===`showAnswer`&&r.correct&&!n.guess&&(0,X.jsx)(mn,{className:`w-6 h-6 shrink-0 [@media(orientation:landscape)_and_(max-width:1024px)]:w-4 [@media(orientation:landscape)_and_(max-width:1024px)]:h-4`}),o===`hideAnswer`&&s&&n.guess&&(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:(0,X.jsx)(Su,{question:t,category:n,indexAnswer:c})})]})]},c))})};async function Ud(e,t,n,r){return st.call(`QuestionReportEndpoint`,`create`,{questionId:e,type:t,description:n},r)}var Wd=({questionId:e})=>{let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(Lc.WRONG_QUESTION),[l,u]=(0,Y.useState)(``),{t:d}=W(),f=(0,Y.useMemo)(()=>[{value:Lc.WRONG_QUESTION,label:d(`Wrong question`)},{value:Lc.WRONG_ANSWER,label:d(`Wrong answer`)},{value:Lc.LANGUAGE_MISTAKE,label:d(`Language mistake`)}
12,{value:Lc.DUPLICATE,label:d(`Duplicate`)},{value:Lc.OTHER,label:d(`Other`)}],[d]),p=(0,Y.useCallback)(async()=>{try{i(!0);let t=l.trim()||void 0;await Ud(e,s,t),Te({description:`Your report has been submitted successfully.`,color:`success`,duration:1500}),u(``),o(!0),n(!1)}catch{Te({description:`Failed to submit report`,color:`destructive`,duration:1500})}finally{i(!1)}},[e,s,l]),m=(0,Y.useCallback)(e=>{e||(n(!1),u(``),c(Lc.WRONG_QUESTION))},[]),h=(0,Y.useCallback)(()=>{a||n(!0)},[a]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(F,{size:`icon`,color:`warning`,className:`flex items-center gap-2`,disabled:a,onClick:h,children:r?(0,X.jsx)(ar,{className:`w-6 h-6 animate-spin`}):(0,X.jsx)(vr,{className:`h-5 w-5`})}),(0,X.jsx)(ge,{open:t,onOpenChange:m,children:(0,X.jsxs)(De,{children:[(0,X.jsx)(V,{children:(0,X.jsx)(xe,{children:d(`Report Question`)})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 space-y-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(ue,{htmlFor:`report-type`,children:d(`Report Type`)}),(0,X.jsxs)(P,{value:s,onValueChange:e=>c(e),children:[(0,X.jsx)(z,{children:(0,X.jsx)(E,{placeholder:d(`Report Type`)})}),(0,X.jsx)(He,{children:f.map(({value:e,label:t})=>(0,X.jsx)(y,{value:e,children:t},e))})]})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(ue,{htmlFor:`report-description`,children:d(`Description`)}),(0,X.jsx)(me,{id:`report-description`,value:l,onValueChanged:e=>u(e),rows:3,placeholder:d(`Optional details to help review the report...`),disabled:a})]})]}),(0,X.jsxs)(Ne,{children:[(0,X.jsx)(F,{onClick:()=>n(!1),disabled:a,variant:`ghost`,color:`secondary`,children:d(`Cancel`)}),(0,X.jsx)(F,{onClick:p,disabled:a,children:d(`Submit Report`)})]})]})})]})},Gd=(0,Y.memo)(({hardcore:e,questionId:t,teamId:n,isPlayerHost:r,isSpectator:i,roomId:a,question:o,category:s,action:c,teams:l,teamIndex:u,onShowAnswer:d,mediaReloadKey:f,onRetryMedia:p})=>{let{t:m}=W(),[h,g]=(0,Y.useState)(null),_=(0,Y.useRef)(null),v=(0,Y.useRef)(null),y=(0,Y.useRef)(null),b=(0,Y.useRef)(null),[x,S]=(0,Y.useState)(null),C=(0,Y.useRef)(c),w=(0,Y.useRef)(!1),T=(0,Y.useRef)(()=>{}),E=!!o.focus&&!o.preview&&!!(o.video||o.audio),[D,O]=(0,Y.useState)(()=>!E);(0,Y.useEffect)(()=>{let e=C.current;C.current=c,e===`hideAnswer`&&c!==`hideAnswer`&&S(null)},[c]),(0,Y.useEffect)(()=>{O(!E)},[t,E]);let k=(0,Y.useCallback)(()=>{O(!0)},[]),A=(0,Y.useMemo)(()=>s.guess?o.answers?.[u]:o.answers?.find(e=>e.correct),[s.guess,o.answers,u]);(0,Y.useEffect)(()=>{let e=0,t=0,n=()=>{let e=_.current?.clientHeight??0;if(!e||w.current)return;let t=v.current?.clientHeight??0,n=b.current?.clientHeight??0,r=!!(window.matchMedia?.(`(orientation: landscape)`).matches&&window.innerWidth<=1024),i=r?8:20,a=r?60:100,o=e-t-n-i;g(Math.max(o,a))},r=()=>{let r=Date.now();r-t<100||(t=r,e&&cancelAnimationFrame(e),e=requestAnimationFrame(n))};T.current=r,n();let i=typeof ResizeObserver>`u`?null:new ResizeObserver(r);return i&&(_.current&&i.observe(_.current),v.current&&i.observe(v.current),b.current&&i.observe(b.current)),window.addEventListener(`orientationchange`,r),()=>{e&&cancelAnimationFrame(e),i?.disconnect(),window.removeEventListener(`orientationchange`,r)}},[]);let j=(0,Y.useCallback)(e=>{w.current=e,e||T.current()},[]),M=(0,Y.useCallback)(e=>{S(e)},[]),N=(0,Y.useCallback)(()=>{S(null)},[]),P=!!o.preview&&(!s.guess||!e),I=!E||D,L=o.preview?r&&c===`hideAnswer`?m(`One person from the team who has the role copies the QR code or select the person.`):c===`hideAnswer`&&!s.guess?m(`Wait...`):o.question||``:I&&o.question||``,ee=(P||!o.preview)&&!!L;return(0,X.jsxs)(`div`,{ref:_,className:`flex flex-col w-full h-full`,children:[(0,X.jsxs)(`div`,{ref:v,className:`flex-shrink-0 w-full mb-2 sm:mb-4 [@media(orientation:landscape)_and_(max-width:1024px)]:mb-1 [@media(orientation:landscape)_and_(max-width:1024px)]:max-h-[40vh] [@media(orientation:landscape)_and_(max-width:1024px)]:overflow-auto`,children:[c!==`answered`&&(0,X.jsxs)(`div`,{className:`flex flex-col justify-center items-center w-full`,children:[ee&&(0,X.jsx)(`span`,{className:`leading-[1.3_!important] text-lg sm:text-xl question-content text-center sm:py-2 font-extrabold px-2 sm:px-4 [@media(orientation:landscape)_and_(max-width:1024px)]:text-sm [@media(orientation:landscape)_and_(max-width:1024px)]:leading-tight [@media(orientation:landscape)_and_(max-width:1024px)]:py-1 [@media(orientation:landscape)_and_(max-width:1024px)]:px-1`,children:L}),(!E||D)&&o.content&&(0,X.jsx)(`div`,{className:`max-w-xl mt-4 text-sm prose dark:prose-invert prose-p:mb-2 prose-img:mb-2 prose-li:mb-1 whitespace-pre-wrap break-words`,children:o.content}),(!E||D)&&o.note&&(0,X.jsx)(`div`,{className:`max-w-xl mt-4 text-sm prose dark:prose-invert prose-p:mb-2 prose-img:mb-2 prose-li:mb-1 whitespace-pre-wrap break-words`,children:o.note})]}),c===`answered`&&(0,X.jsx)(Cu,{}),(c===`showAnswer`&&(!o.answers||o.answers?.length<=1)||s.guess&&c===`hideAnswer`&&!i&&(e||!r))&&(0,X.jsx)(`span`,{className:`mt-4 flex justify-center items-center w-full leading-[1.3_!important] text-xl sm:text-2xl answer-content text-success text-center sm:py-2 font-extrabold animate-fade-in [@media(orientation:landscape)_and_(max-width:1024px)]:text-sm [@media(orientation:landscape)_and_(max-width:1024px)]:leading-tight [@media(orientation:landscape)_and_(max-width:1024px)]:py-1`,children:A?.answer})]}),(c===`showAnswer`||c===`hideAnswer`)&&(0,X.jsxs)(`div`,{ref:y,className:`flex-1 min-h-0 w-full overflow-auto styled-scrollbar`,style:{height:h?`${h}px`:`auto`}
12,children:[(0,X.jsx)(Fd,{questionId:t,question:o,category:s,hardcore:e,action:c,teamId:n,isPlayerHost:r,isSpectator:i,teamIndex:u,roomId:a,contentHeight:h,onImageClick:M,onMediaPlaybackChange:j,mediaReloadKey:f,onRetryMedia:p,onQuestionVideoEnded:E&&o.video?k:void 0,onQuestionAudioEnded:E&&!o.video&&o.audio?k:void 0,hideQuestionVideo:E&&D,hideQuestionAudio:E&&D}),(0,X.jsx)(Hd,{questionId:t,question:o,category:s,hardcore:e,roomId:a,action:c,teams:l,isPlayerHost:r,isSpectator:i,onImageClick:M})]}),x&&(0,X.jsx)(Ed,{imageUrl:x,onClose:N}),(0,X.jsx)(`div`,{ref:b,className:`w-full`,children:r&&c===`showAnswer`&&(0,X.jsx)(`div`,{className:`w-full flex items-center justify-center gap-2 sm:gap-4 p-2 screen-resize [@media(orientation:landscape)_and_(max-width:1024px)]:gap-2 [@media(orientation:landscape)_and_(max-width:1024px)]:p-1`,children:(0,X.jsx)(F,{onClick:d,size:`sm`,className:`sm:text-base text-xs font-semibold [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px] [@media(orientation:landscape)_and_(max-width:1024px)]:h-7 [@media(orientation:landscape)_and_(max-width:1024px)]:px-2`,color:`secondary`,children:m(`Show Answer`)})})})]})});Gd.displayName=`QuestionView`;var Kd=()=>{let{selectedQuestion:e,categories:t,team:n,teams:r,sendEvent:i,model:a,teamHelpers:o,mediaReloadKeyByQuestionId:s,reloadQuestionMedia:c}=ru(),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(`hideAnswer`),[p,m]=(0,Y.useState)(Uc.DEFAULT),h=(0,Y.useRef)({reason:null,wasRunning:!1}),g=(0,Y.useRef)(null),_=(0,Y.useRef)(null),{t:v}=W(),y=(0,Y.useRef)({}),b=(0,Y.useRef)(null),x=(0,Y.useRef)(null),{isPlayerHost:S,subscriptionClient:C,players:w,player:T,session:E}=J(),[D,{startTimer:O,stopTimer:k,resetTimer:A,isTimerRunning:j}]=Ti({countStart:0,intervalMs:1e3,isIncrement:!0}),M=(0,Y.useMemo)(()=>Bl(a.availableHelpers,o?.helperKey),[a.availableHelpers,o?.helperKey]),N=(0,Y.useMemo)(()=>!o?.active||!o.helperKey?null:[o.helperKey,o.teamId??``,o.questionId??``,String(o.startedAt??``)].join(`:`),[o]),P=(0,Y.useCallback)(e=>{let t=e;t.type===`HIDE_ANSWER`&&f(`hideAnswer`),t.type===`SELECT_PLAYER`&&(t.selectionMode!==Uc.DRAW&&t.playerId===T?.id?f(e=>e===`hideAnswer`?`showAnswer`:`hideAnswer`):t.selectionMode===Uc.DRAW&&t.playerId===T?.id&&f(`hideAnswer`)),t.type===`SHOW_ANSWER`&&f(`showAnswer`),t.type===`STOP_TIMER`&&k(),t.type===`START_TIMER`&&O(),t.type===`RESET_TIMER`&&A(0)},[S,T?.id,k,O,A]);(0,Y.useEffect)(()=>{x.current=P},[P]);let I=(0,Y.useCallback)(e=>{x.current&&x.current(e)},[]);(0,Y.useEffect)(()=>(C.on([`SHOW_ANSWER`,`HIDE_ANSWER`,`SELECT_PLAYER`,`STOP_TIMER`,`START_TIMER`,`RESET_TIMER`],I),()=>{C.off([`SHOW_ANSWER`,`HIDE_ANSWER`,`SELECT_PLAYER`,`STOP_TIMER`,`START_TIMER`,`RESET_TIMER`],I)}),[I,C]),(0,Y.useEffect)(()=>{if(!N||!M||!o?.active||!e?.id||o.questionId!==e.id||g.current===N)return;g.current=N;let t=ql(M,$.ADD_TIME);if(t&&t>0&&A(Math.max(0,D-t)),Ul(M,$.FREEZE_TIMER)){let e=ql(M,$.FREEZE_TIMER)??5,t=j;k(),_.current&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>{t&&O(),_.current=null},e*1e3)}},[M,N,D,j,A,e?.id,O,k,o?.active,o?.questionId]),(0,Y.useEffect)(()=>()=>{_.current&&window.clearTimeout(_.current)},[]),(0,Y.useEffect)(()=>(O(),()=>{k()}),[O,k]),(0,Y.useEffect)(()=>{if(!S)return;let e=d===`answered`?`answered`:d===`showAnswer`&&a.hardcore?`hardcoreShowAnswer`:null;if(e){if(!h.current.reason){h.current.reason=e,h.current.wasRunning=j,j&&i(`STOP_TIMER`);return}h.current.reason=e;return}h.current.reason&&(h.current.wasRunning&&i(`START_TIMER`),h.current.reason=null,h.current.wasRunning=!1)},[d,S,j,a.hardcore]);let L=(0,Y.useMemo)(()=>!j&&(d===`answered`||d===`showAnswer`&&!!a.hardcore),[d,j,a.hardcore]),ee=(0,Y.useCallback)(()=>{L||i(j?`STOP_TIMER`:`START_TIMER`)},[L,j]),R=(0,Y.useCallback)(()=>{L||i(`RESET_TIMER`)},[L]),z=(0,Y.useMemo)(()=>t.find(t=>t.id===e?.categoryId),[t,e?.categoryId]),B=(0,Y.useMemo)(()=>!!z?.guess,[z?.guess]),ne=(0,Y.useMemo)(()=>!!(e?.question?.preview&&!B),[B,e?.question?.preview]),re=(0,Y.useMemo)(()=>{let e=a.drawState?.selectedPlayerIds??[];return e.length?w.filter(t=>t.id&&e.includes(t.id)):[]},[a.drawState?.selectedPlayerIds,w]),ie=(0,Y.useMemo)(()=>!!(ne&&a.drawState?.enabled&&a.drawState?.questionId===e?.id),[ne,a.drawState?.enabled,a.drawState?.questionId,e?.id]),ae=(0,Y.useMemo)(()=>e?.id?s[e.id]??0:0,[s,e?.id]),oe=(0,Y.useCallback)((e=!0)=>{S&&i(e?`SHOW_ANSWER`:`HIDE_ANSWER`)},[S]),se=(0,Y.useCallback)(()=>{oe(!0)},[oe]),ce=(0,Y.useCallback)(()=>{oe(!1)},[oe]),le=(0,Y.useCallback)(()=>{u(!1),d===`showAnswer`?f(`answered`):(f(`showAnswer`),a.hardcore&&se())},[d,se,a.hardcore]),ue=(0,Y.useCallback)(e=>{S&&(i(`SELECT_PLAYER`,{targetPlayerId:e,selectionMode:p}),u(!1))},[S,p,i]),de=(0,Y.useCallback)(()=>{S&&i(`CANCEL_QUESTION`)},[S]),V=(0,Y.useCallback)(()=>
12{if(!ne){m(Uc.DEFAULT),u(!1);return}m(ie?Uc.DRAW:Uc.DEFAULT),u(e=>!e)},[ie,ne]),fe=(0,Y.useCallback)(()=>{if(S&&(u(!1),d!==`hideAnswer`)){if(d===`showAnswer`){f(`hideAnswer`),a.hardcore&&ce();return}f(`showAnswer`)}},[d,ce,S,a.hardcore]),H=(0,Y.useMemo)(()=>r.findIndex(e=>e.id===T?.teamId),[T?.teamId,r]),U=(0,Y.useMemo)(()=>!!(ne&&(S||T?.id&&(a.drawState?.selectedPlayerIds??[]).includes(T.id))),[S,ne,a.drawState?.selectedPlayerIds,T?.id]);return(0,Y.useEffect)(()=>{ne||(u(!1),m(Uc.DEFAULT))},[ne,e?.id]),(0,Y.useEffect)(()=>{if(n?.id){let e=y.current[n.id];e&&(b.current&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{e.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`center`})},100))}return()=>{b.current&&=(window.clearTimeout(b.current),null)}},[n?.id]),e?(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(`div`,{className:q(`px-4 h-[88dvh] md:h-[88dvh] pb-safe [@media(orientation:landscape)_and_(max-width:1024px)]:px-2 [@media(orientation:landscape)_and_(max-width:1024px)]:h-[75dvh]`),children:(0,X.jsxs)(`div`,{className:`xl:grid flex flex-col-reverse xl:grid-cols-12 gap-x-5 pt-[28px] sm:pt-14 md:pt-14 h-full max-xl:justify-between [@media(orientation:landscape)_and_(max-width:1024px)]:grid [@media(orientation:landscape)_and_(max-width:1024px)]:grid-cols-12 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-x-2 [@media(orientation:landscape)_and_(max-width:1024px)]:pt-[14px]`,children:[(0,X.jsx)(`div`,{className:q(`xl:col-span-3 xl:ltr:col-start-10 xl:rtl:col-start-1 min-h-[16vh] w-full pb-safe`,S&&`min-h-[16vh]`,`[@media(orientation:landscape)_and_(max-width:1024px)]:col-span-3 [@media(orientation:landscape)_and_(max-width:1024px)]:ltr:col-start-10 [@media(orientation:landscape)_and_(max-width:1024px)]:rtl:col-start-1 [@media(orientation:landscape)_and_(max-width:1024px)]:row-start-1 [@media(orientation:landscape)_and_(max-width:1024px)]:h-full [@media(orientation:landscape)_and_(max-width:1024px)]:min-h-0`),children:(0,X.jsx)(mu,{layout:`vertical`,hideIncreaseOrDecrease:!0,scrollToSelected:!0,className:`[@media(orientation:landscape)_and_(max-width:1024px)]:flex-col [@media(orientation:landscape)_and_(max-width:1024px)]:gap-1`,containerClassName:`[@media(orientation:landscape)_and_(max-width:1024px)]:overflow-y-auto [@media(orientation:landscape)_and_(max-width:1024px)]:overflow-x-hidden`,teamClassName:`[@media(orientation:landscape)_and_(max-width:1024px)]:min-w-0 [@media(orientation:landscape)_and_(max-width:1024px)]:w-full [@media(orientation:landscape)_and_(max-width:1024px)]:max-w-none`})}),(0,X.jsxs)(`div`,{className:`xl:col-span-9 xl:ltr:col-start-1 xl:rtl:col-start-4 max-xl:row-start-1 h-full xl:h-[90%] relative max-xl:mb-7 [@media(orientation:landscape)_and_(max-width:1024px)]:col-span-9 [@media(orientation:landscape)_and_(max-width:1024px)]:ltr:col-start-1 [@media(orientation:landscape)_and_(max-width:1024px)]:rtl:col-start-4 [@media(orientation:landscape)_and_(max-width:1024px)]:row-start-1 [@media(orientation:landscape)_and_(max-width:1024px)]:mb-0`,children:[(0,X.jsx)(`div`,{className:`h-full px-3.5 xs:px-6 border-[5px] border-card 2xl:rounded-[78px] xl:rounded-[54px] rounded-3xl py-6 sm:py-[35px] md:py-[40px] lg:py-10 xl:py-12 game-section_wrapper flex justify-center hint-question-wrapper [@media(orientation:landscape)_and_(max-width:1024px)]:px-6 [@media(orientation:landscape)_and_(max-width:1024px)]:py-6 [@media(orientation:landscape)_and_(max-width:1024px)]:border-[3px] [@media(orientation:landscape)_and_(max-width:1024px)]:rounded-2xl`,children:(0,X.jsx)(`div`,{className:`flex justify-center items-center w-full h-full`,children:(0,X.jsx)(`div`,{className:`flex flex-col w-full h-full`,children:l&&ne?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center w-full h-full`,children:[(0,X.jsx)(`h2`,{className:`text-2xl font-bold mb-6 text-center bg-gradient-to-r from-primary to-purple-500 bg-clip-text text-transparent [@media(orientation:landscape)_and_(max-width:1024px)]:text-lg [@media(orientation:landscape)_and_(max-width:1024px)]:mb-2`,children:v(`Select a player`)}),ne&&(0,X.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-full border border-primary/15 bg-card/80 p-1`,children:[(0,X.jsx)(F,{size:`sm`,color:p===Uc.DEFAULT?`primary`:`default`,variant:`ghost`,className:q(p===Uc.DEFAULT&&`bg-primary text-primary-foreground hover:bg-primary/90`),onClick:()=>m(Uc.DEFAULT),children:v(`Normal`)}),(0,X.jsx)(F,{size:`sm`,color:p===Uc.DRAW?`primary`:`default`,variant:`ghost`,className:q(p===Uc.DRAW&&`bg-primary text-primary-foreground hover:bg-primary/90`),onClick:()=>m(Uc.DRAW),children:v(`Drawing`)})]}),(0,X.jsx)(te,{className:`w-full max-w-4xl mx-auto h-[324px] [@media(orientation:landscape)_and_(max-width:1024px)]:h-[170px]`,children:(0,X.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-4 p-2 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-2 [@media(orientation:landscape)_and_(max-width:1024px)]:p-1`,children:w.filter(e=>e.teamId===n?.id).map((e,t)=>{let n=p===Uc.DRAW&&(a.drawState?.selectedPlayerIds??[]).includes(e.id??``);return(0,X.jsx)(F,{onClick:()=>ue(e.id),variant:n?`outline`:`default`,className:q(`h-16 text-lg font-medium transition-all duration-300 transform hover:scale-105 shadow-md [@media(orientation:landscape)_and_(max-width:1024px)]:h-7 [@media(orientation:landscape)_and_(max-width:1024px)]:text-xs [@media(orientation:landscape)_and_(max-width:1024px)]:px-2`,n?`border-primary bg-primary/10 text-primary hover:bg-primary/15`:`bg-gradient-to-r from-primary/80 to-primary hover:from-primary hover:to-primary/80`),children:e.name},t)})})})]}):ie&&d===`hideAnswer`?(0,X.jsx)(Bd,{questionId:e.id,question:e.question,category:z,roomId:E.roomId,teamId:T.teamId,teamIndex:H,mediaReloadKey:ae,onRetryMedia:()=>c(e.id),selectedPlayerNames:re.map(e=>e.name),canDraw:U,initialSnapshot:a.drawState?.snapshot,initialViewport:a.drawState?.viewport}):(0,X.jsx)(Gd,{isPlayerHost:S,isSpectator:!!T?.spectator,onShowAnswer:se,questionId:e.id,question:e.question,teamId:T.teamId,category:z,hardcore:a.hardcore,teams:r,teamIndex:H,roomId:E.roomId,action:d,mediaReloadKey:ae,onRetryMedia:()=>c(e.id)})})})}),(0,X.jsxs)(`div`,{className:`absolute top-0 -translate-y-1/2 left-1/2 -translate-x-1/2 flex justify-between items-center w-full max-w-[90%] [@media(orientation:landscape)_and_(max-width:1024px)]:-translate-y-[40%]`,children:[(0,X.jsx)(F,{size:`xs`,className:`text-lg font-philosopher hover:bg-primary/20 transition-colors [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px] [@media(orientation:landscape)_and_(max-width:1024px)]:h-7 [@media(orientation:landscape)_and_(max-width:1024px)]:px-2`,children:e.points}),(0,X.jsxs)(`div`,{className:q(`items-center gap-2.5 sm:gap-4 max-sm:gap-2 bg-card rounded-full py-1 sm:py-2.5 4xl:py-4 px-4 md:px-7 max-w-full w-36 sm:w-48 lg:w-[384px] 4xl:w-[567px] btn-wrapper mx-auto 
12shadow-md [@media(orientation:landscape)_and_(max-width:1024px)]:py-1 [@media(orientation:landscape)_and_(max-width:1024px)]:px-3 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-2 [@media(orientation:landscape)_and_(max-width:1024px)]:w-32`,S&&`grid grid-flow-col justify-between`,!S&&`flex justify-center`),children:[S&&(0,X.jsx)(F,{size:`icon`,onClick:R,disabled:L,className:`hover:bg-primary/20 transition-colors`,children:(0,X.jsx)(Un,{className:`h-5 w-5 [@media(orientation:landscape)_and_(max-width:1024px)]:h-4 [@media(orientation:landscape)_and_(max-width:1024px)]:w-4`})}),(0,X.jsx)(`div`,{className:`inline-flex items-center justify-center 2xl:text-[43px] xl:text-3xl sm:text-xl text-base font-philosopher [@media(orientation:landscape)_and_(max-width:1024px)]:text-sm`,children:Ur(D)}),S&&(0,X.jsx)(F,{size:`icon`,onClick:ee,disabled:L,className:`hover:bg-primary/20 transition-colors`,children:j?(0,X.jsx)(pn,{className:`h-5 w-5 [@media(orientation:landscape)_and_(max-width:1024px)]:h-4 [@media(orientation:landscape)_and_(max-width:1024px)]:w-4`}):(0,X.jsx)(Ot,{className:`h-5 w-5 [@media(orientation:landscape)_and_(max-width:1024px)]:h-4 [@media(orientation:landscape)_and_(max-width:1024px)]:w-4`})})]}),S&&d===`hideAnswer`&&(0,X.jsx)(F,{size:`icon`,onClick:de,className:`hover:bg-primary/20 transition-colors`,children:(0,X.jsx)(Sn,{className:`h-5 w-5 [@media(orientation:landscape)_and_(max-width:1024px)]:h-4 [@media(orientation:landscape)_and_(max-width:1024px)]:w-4`})})]}),(0,X.jsx)(`div`,{className:`absolute -bottom-2 translate-y-1/4 left-0 right-0 [@media(orientation:landscape)_and_(max-width:1024px)]:bottom-0 [@media(orientation:landscape)_and_(max-width:1024px)]:translate-y-0`,children:(0,X.jsxs)(`div`,{className:q(`flex gap-1 justify-end [@media(orientation:landscape)_and_(max-width:1024px)]:gap-0.5 [@media(orientation:landscape)_and_(max-width:1024px)]:px-1`,S&&`justify-between`),children:[(0,X.jsx)(F,{color:`default`,size:`xs`,className:`sm:text-base text-xs w-fit font-semibold ml-auto mr-[5%] [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px] [@media(orientation:landscape)_and_(max-width:1024px)]:h-7 [@media(orientation:landscape)_and_(max-width:1024px)]:px-2`,onClick:fe,children:S&&d===`showAnswer`?v(`Back to the question`):d===`answered`?v(`Back to answer`):z?.name}),S&&ne&&(0,X.jsx)(F,{size:`xs`,className:`sm:text-base text-xs font-semibold [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px] [@media(orientation:landscape)_and_(max-width:1024px)]:h-7 [@media(orientation:landscape)_and_(max-width:1024px)]:px-2`,color:`default`,onClick:V,children:v(`Select a person`)}),(0,X.jsxs)(`div`,{className:`flex flex-row gap-2`,children:[!a.hardcore&&S&&e?.question&&!e.question.preview&&!e.question?.video&&!e.question?.audio&&(0,X.jsx)(Su,{question:e.question,category:z}),e?.question?.id&&(0,X.jsx)(Wd,{questionId:e.question.id})]}),(d===`answered`||!S)&&(0,X.jsx)(`div`,{className:`w-fit mr-auto ml-[5%]`}),S&&d!==`answered`&&(0,X.jsx)(F,{size:`xs`,onClick:le,className:`go-to-answer mr-auto ml-[5%] sm:text-base w-fit font-semibold [@media(orientation:landscape)_and_(max-width:1024px)]:text-[10px] [@media(orientation:landscape)_and_(max-width:1024px)]:h-7 [@media(orientation:landscape)_and_(max-width:1024px)]:px-2`,color:`success`,children:v(d===`showAnswer`?`Who answered?`:`Go to answer`)})]})})]})]})})}):(0,X.jsx)(`div`,{className:`text-center`,children:v(`No question selected`)})},qd=300,Jd=(e=!1,t,n)=>{let[r,i]=(0,Y.useState)([]),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!0),[d,f]=(0,Y.useState)(null),{t:p}=W(),{isPlayerHost:m,session:h,player:g}=J(),{categories:_,teams:v,sendEvent:y,toggleSpectator:b}=ru(),x=(0,Y.useMemo)(()=>_.map(e=>e.id),[_]);(0,Y.useEffect)(()=>{let e=setTimeout(()=>{c(a)},qd);return()=>clearTimeout(e)},[a]);let S=(0,Y.useCallback)(e=>{let t=[],n=[];return e.forEach(e=>{e.children&&e.children.length>0?t.push(e):n.push(e)}),[...t,...n]},[]),C=(0,Y.useCallback)(async()=>{if(g.id){u(!0);try{await Rl(h.roomId,g.id)}catch{f(p(`Failed to start game. Please try again.`))}finally{u(!1)}}},[g,h.roomId,p]),w=(0,Y.useCallback)(t=>{e||!m||v.length>
122&&t.guess===!0||y(`SELECT_CATEGORY`,{categoryId:t.id})},[e,v,m,y]),T=(0,Y.useCallback)(t=>{e||!m||y(`REMOVE_CATEGORY`,{categoryId:t})},[e,m,y]),E=(0,Y.useCallback)(()=>{if(e||!m)return;let t=r.filter(e=>e.name!==`اطفال`).filter(e=>!e.guess).flatMap(e=>[e,...e.children||[]]).filter(e=>!e.guess).filter(e=>(e.remaining||0)>0).sort(()=>.5-Math.random()).slice(0,6);y(`SELECT_CATEGORIES`,{categoryIds:t.map(e=>e.id)})},[r,e,m,y]),D=(0,Y.useCallback)(async()=>{if(!(e||!m))try{await Nl();let e=await Fl(h.roomId),t=S(e);i(t)}catch{f(p(`Failed to reset questions. Please try again.`))}},[e,m,S,p]),O=(0,Y.useCallback)(async t=>{if(!(e||!m))try{await Pl(t);let e=await Fl(h.roomId),n=S(e);i(n)}catch{f(p(`Failed to reset category questions. Please try again.`))}},[e,m,S,p]),k=(0,Y.useMemo)(()=>{if(!r||r.length===0)return[];let e=[],t=[];if(r.forEach(n=>{n.children&&n.children.length>0?e.push(n):t.push(n)}),t.length===0)return e;let n=t.reduce((e,t)=>e+t.total,0),i=t.reduce((e,t)=>e+(t.remaining??0),0);return[...e,{id:0,name:`Other`,total:n,remaining:i,children:t}]},[r]),A=(0,Y.useMemo)(()=>n==null?null:k.find(e=>e.id===n)??null,[n,k]);(0,Y.useEffect)(()=>{(async()=>{try{u(!0),f(null);let e=await Fl(h.roomId),t=S(e);i(t)}catch(e){f(p(`Failed to load categories. Please try again.`)),console.error(`Error loading categories:`,e)}finally{u(!1)}})()},[S,h.roomId,p]);let j=(0,Y.useMemo)(()=>{let e=[];return r.forEach(t=>{if(t.children&&t.children.length>0){let n=t.children.filter(e=>x?.includes(e.id));e.push(...n)}else x?.includes(t.id)&&e.push(t)}),e},[r,x]),M=(0,Y.useMemo)(()=>{if(A){if(!s.trim())return[A];let e=s.toLowerCase().trim();return!A.children||A.children.length===0?A.name?.toLowerCase().includes(e)?[A]:[]:[{...A,children:A.children.filter(t=>t.name?.toLowerCase().includes(e))}]}if(!s.trim())return r;let e=s.toLowerCase().trim();return r.filter(t=>{let n=t.name.toLowerCase().includes(e),r=t.children?.some(t=>t.name.toLowerCase().includes(e));return n||r}).map(t=>!t.name.toLowerCase().includes(e)&&t.children?{...t,children:t.children.filter(t=>t.name.toLowerCase().includes(e))}:t)},[A,r,s]),N=x.length,P=(0,Y.useMemo)(()=>{let e=0;return r.forEach(t=>{t.children&&t.children.length>0?t.children.forEach(t=>{t.remaining&&t.remaining<t.total&&e++}):t.remaining&&t.remaining<t.total&&e++}),e},[r]);return(0,Y.useEffect)(()=>{t&&t(j)},[j,t]),{rootCategories:k,filteredCategories:M,selectedCategoryIds:x,selectedCategoriesCount:N,usedCategoriesCount:P,getSelectedCategories:j,searchQuery:a,setSearchQuery:o,isLoading:l,error:d,isPlayerHost:m,player:g,teams:v,canFreeSelectCategories:h.data.free,handleStartGame:C,handleSelectCategory:w,handleRemoveCategory:T,handleClearAllQuestions:D,handleClearQuestionsForCategory:O,handleRandomizeCategories:E,toggleSpectator:b}},Yd=({isPlayerHost:e,isLoading:t,usedCategoriesCount:n,disabled:r=!1,showResetOptions:i,onToggleResetOptions:a,onRandomizeCategories:o,showFavoritesOnly:s,onToggleFavoritesOnly:c})=>{let{t:l}=W();return!e||t?null:(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-between items-center mb-4 sm:mb-6 [@media(orientation:landscape)_and_(max-height:600px)]:mb-2 gap-2 [@media(orientation:landscape)_and_(max-height:600px)]:-order-2`,children:[(0,X.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold text-foreground [@media(orientation:landscape)_and_(max-height:600px)]:text-lg`,children:l(`Challenge Setup`)}),(0,X.jsxs)(`div`,{className:`flex flex-row gap-2`,children:[(0,X.jsx)(F,{color:s?`warning`:`primary`,variant:`ghost`,onClick:c,disabled:r,className:`flex items-center gap-2 [@media(orientation:landscape)_and_(max-height:600px)]:h-7`,size:`sm`,children:(0,X.jsx)(Gn,{className:`size-5 [@media(orientation:landscape)_and_(max-height:600px)]:size-4`})}),(0,X.jsx)(F,{onClick:o,disabled:r,variant:`ghost`,className:`flex items-center gap-2 [@media(orientation:landscape)_and_(max-height:600px)]:h-7`,size:`sm`,children:(0,X.jsx)(yr,{className:`size-5 [@media(orientation:landscape)_and_(max-height:600px)]:size-4`})}),(0,X.jsx)(F,{variant:i?`default`:`outline`,onClick:a,disabled:r||n<1,className:`flex items-center gap-2 [@media(orientation:landscape)_and_(max-height:600px)]:h-7`,size:`sm`,children:(0,X.jsx)(Nt,{className:`size-5 [@media(orientation:landscape)_and_(max-height:600px)]:size-4`})})]})]})},Xd=(0,Y.memo)(({category:e,isParent:t=!1,isSelected:n,isDisabled:r,isPlayerHost:i,showReset:a,interactive:o=!0,showTotalQuestions:s=!1,showRemaining:c=!1,isCollapsed:l=!1,onToggleCollapse:u,isFavorite:d=!1,onToggleFavorite:f,onSelect:p,onReset:m})=>{let{t:h}
12=W(),g=e.remaining===0,_=o&&!t&&!r&&!!p,v=t&&!!u,y=!t&&e.parentId!=null&&!!f,[b,x]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{x(!1)},[e.image]);let S=(0,Y.useMemo)(()=>h(e.name),[h,e.name]),w=(0,Y.useMemo)(()=>e.description?h(e.description):``,[h,e.description]),T=(0,Y.useMemo)(()=>{if(t||!e.createdAt)return!1;let n=new Date(e.createdAt),r=Math.abs(new Date().getTime()-n.getTime());return Math.ceil(r/864e5)<=(D.newnessThresholdDays||7)},[e.createdAt,t]);return(0,X.jsxs)(`div`,{role:_?`button`:`presentation`,tabIndex:_?0:-1,"aria-pressed":_?n:void 0,"aria-disabled":_?r:void 0,"aria-label":_?h(`Select category: {{name}}`,{name:S}):void 0,className:q(`group relative flex flex-col h-auto rounded-xl border will-change-transform transition-[transform,box-shadow,border-color,opacity,filter] duration-300 overflow-hidden bg-card`,!t&&`min-h-[200px] sm:min-h-[220px] md:min-h-[240px] lg:min-h-[260px] [@media(orientation:landscape)_and_(max-height:600px)]:min-h-[160px]`,i&&`cursor-pointer select-none hover:-translate-y-1 hover:shadow-lg`,i&&`focus:outline-none focus:ring-2 focus:ring-[#69bbcf] focus:ring-offset-2`,!i&&`border-none focus:outline-none focus:ring-0 focus:ring-offset-0`,n?`border-primary shadow-md ring-1 ring-primary`:r?`border-border opacity-60 grayscale`:`border-border hover:border-primary/50`,_?r?`cursor-not-allowed`:void 0:`cursor-default`,t&&`border-primary/50 shadow-lg`),onClick:()=>{_&&p(e)},onKeyDown:t=>{_&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),p(e))},children:[(0,X.jsxs)(`div`,{className:q(`absolute top-0 left-0 w-full z-20 flex justify-between items-start p-2 pointer-events-none`,`[@media(orientation:landscape)_and_(max-height:600px)]:p-1`),children:[(0,X.jsxs)(`div`,{className:`pointer-events-auto flex items-center gap-2 ltr:mr-auto rtl:ml-auto`,children:[y&&(0,X.jsx)(F,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":h(d?`Remove from favorites: {{name}}`:`Add to favorites: {{name}}`,{name:S}),onClick:t=>{t.stopPropagation(),f?.(e.id)},className:q(`h-7 w-7 rounded-full bg-background/60 backdrop-blur-md hover:bg-background/90 shadow-sm border border-border/20`,`[@media(orientation:landscape)_and_(max-height:600px)]:h-5 [@media(orientation:landscape)_and_(max-height:600px)]:w-5`),children:(0,X.jsx)(Gn,{className:q(`h-4 w-4 transition-colors`,d?`text-yellow-500 fill-yellow-500`:`text-muted-foreground hover:text-foreground`,`[@media(orientation:landscape)_and_(max-height:600px)]:h-3 [@media(orientation:landscape)_and_(max-height:600px)]:w-3`)})}),e.description&&(0,X.jsx)(`div`,{onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(0,X.jsxs)(O,{children:[(0,X.jsx)(ie,{asChild:!0,children:(0,X.jsx)(F,{variant:`ghost`,size:`icon`,className:q(`h-7 w-7 rounded-full bg-background/60 backdrop-blur-md hover:bg-background/90 shadow-sm border border-border/20`,`[@media(orientation:landscape)_and_(max-height:600px)]:h-5 [@media(orientation:landscape)_and_(max-height:600px)]:w-5`),children:(0,X.jsx)(Tn,{className:`h-4 w-4 text-muted-foreground hover:text-foreground transition-colors [@media(orientation:landscape)_and_(max-height:600px)]:h-3 [@media(orientation:landscape)_and_(max-height:600px)]:w-3`})})}),(0,X.jsx)(re,{className:`w-80 p-0 border-primary/20 shadow-xl`,children:(0,X.jsx)(te,{className:`h-40 w-full rounded-md bg-card`,children:(0,X.jsx)(`div`,{className:`p-4 text-sm leading-relaxed`,children:w})})})]})}),T&&(0,X.jsx)(C,{className:q(`bg-blue-600/90 hover:bg-blue-700/90 backdrop-blur-md text-white border-none shadow-sm text-[10px] px-2 py-0.5 animate-in fade-in zoom-in duration-300`,`[@media(orientation:landscape)_and_(max-height:600px)]:text-[8px] [@media(orientation:landscape)_and_(max-height:600px)]:px-1.5 [@media(orientation:landscape)_and_(max-height:600px)]:py-0`),children:h(`New`)})]}),(0,X.jsx)(`div`,{className:`ltr:ml-auto rtl:mr-auto`})]}),!t&&(0,X.jsx)(`div`,{className:q(`relative flex-1 w-full flex items-center justify-center pt-6 px-6 overflow-hidden min-h-[120px] sm:min-h-[140px] md:min-h-[160px] lg:min-h-[180px]`,`bg-gradient-to-br from-[#2b616e]/20 via-[#3d4a4e]/10 to-[#cfb984]/20 dark:from-[#2b616e]/30 dark:via-[#3d4a4e]/20 dark:to-[#cfb984]/30`,`[@media(orientation:landscape)_and_(max-height:600px)]:p-2 [@media(orientation:landscape)_and_(max-height:600px)]:min-h-[80px]`),children:(0,X.jsxs)(X.Fragment,{children:[e.image&&!b?(0,X.jsx)(`img`,{className:q(`object-contain w-full h-auto max-h-[120px] sm:max-h-[140px] md:max-h-[160px] lg:max-h-[180px] transition-transform duration-500 group-hover:scale-110 drop-shadow-sm`,`[@media(orientation:landscape)_and_(max-height:600px)]:max-h-[60px]`),loading:`lazy`,alt:S,src:Wr(e.image),onError:e=>{e.preventDefault(),x(!0)}}):(0,X.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center`,children:(0,X.jsx)(`span`,{className:`text-2xl font-bold text-primary/40`,children:S.charAt(0)})}),n&&(0,X.jsx)(`div`,{className:q(`absolute bottom-2 ltr:right-2 rtl:left-2 z-10`,`animate-in zoom-in duration-200`,`[@media(orientation:landscape)_and_(max-height:600px)]:bottom-1`,`[@media(orientation:landscape)_and_(max-height:600px)]:ltr:right-1`,`[@media(orientation:landscape)_and_(max-height:600px)]:rtl:left-1`),children:(0,X.jsx)(`div`,{className:q(`bg-primary text-primary-foreground rounded-full p-1.5 
12shadow-md`,`[@media(orientation:landscape)_and_(max-height:600px)]:p-1`),children:(0,X.jsx)(un,{className:q(`h-4 w-4`,`[@media(orientation:landscape)_and_(max-height:600px)]:h-3 [@media(orientation:landscape)_and_(max-height:600px)]:w-3`)})})}),s&&(0,X.jsx)(`div`,{className:q(`absolute bottom-2 ltr:left-2 rtl:right-2 z-10 pointer-events-auto`,`[@media(orientation:landscape)_and_(max-height:600px)]:bottom-1`,`[@media(orientation:landscape)_and_(max-height:600px)]:ltr:left-1`,`[@media(orientation:landscape)_and_(max-height:600px)]:rtl:right-1`),children:(0,X.jsx)(`div`,{onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(0,X.jsxs)(O,{children:[(0,X.jsx)(ie,{asChild:!0,children:(0,X.jsx)(`div`,{className:q(`flex items-center gap-1.5 cursor-pointer hover:bg-background/80 transition-all rounded-full px-2 py-1 shadow-sm border border-border/20 backdrop-blur-md`,g?`bg-destructive/10 text-destructive border-destructive/20`:`bg-background/60 text-muted-foreground`,`[@media(orientation:landscape)_and_(max-height:600px)]:rounded-md [@media(orientation:landscape)_and_(max-height:600px)]:px-1.5 [@media(orientation:landscape)_and_(max-height:600px)]:py-0.5`),children:(0,X.jsx)(`span`,{className:q(`text-[10px] font-mono font-medium`,`[@media(orientation:landscape)_and_(max-height:600px)]:text-[8px]`),children:c&&e.guess===!1?`${e.remaining||0} / ${e.total||0}`:e.total||e.total})})}),(0,X.jsx)(re,{className:`w-auto p-2 text-xs`,side:`bottom`,children:c&&e.guess===!1?h(`Remaining questions / Total questions`):h(`Total questions`)})]})})})]})}),(0,X.jsxs)(`div`,{className:q(`w-full p-3 flex flex-col items-center gap-2 z-10`,`[@media(orientation:landscape)_and_(max-height:600px)]:p-2 [@media(orientation:landscape)_and_(max-height:600px)]:gap-1`,t?`h-full justify-center bg-gradient-to-br from-[#2b616e]/10 via-[#3d4a4e]/5 to-[#cfb984]/10 border-none`:`bg-card/80 backdrop-blur-sm border-t border-border/50`),children:[(0,X.jsxs)(`div`,{className:`relative w-full flex items-center justify-center`,children:[(0,X.jsx)(`span`,{className:q(`font-bold text-center leading-tight transition-colors line-clamp-2`,t?`text-lg text-primary`:`text-sm group-hover:text-primary`,`[@media(orientation:landscape)_and_(max-height:600px)]:text-[12px]`),children:S}),v&&(0,X.jsx)(F,{type:`button`,size:`icon`,variant:`ghost`,"aria-label":h(l?`Expand category: {{name}}`:`Collapse category: {{name}}`,{name:S}),onClick:t=>{t.stopPropagation(),u?.(e.id)},className:q(`absolute ltr:right-0 rtl:left-0 top-1/2 -translate-y-1/2 h-8 w-8 rounded-full`,`bg-background/60 backdrop-blur-md hover:bg-background/90 shadow-sm border border-border/20`,`[@media(orientation:landscape)_and_(max-height:600px)]:h-6 [@media(orientation:landscape)_and_(max-height:600px)]:w-6`),children:(0,X.jsx)(_n,{className:q(`h-4 w-4 text-muted-foreground transition-transform duration-300`,l?`ltr:rotate-90 rtl:-rotate-90`:`rotate-0`)})})]}),!t&&i&&a&&(e.remaining||0)!==(e.total||0)&&(0,X.jsx)(`div`,{className:`w-full pt-1`,children:(0,X.jsxs)(F,{size:`xs`,variant:`ghost`,onClick:t=>{t.stopPropagation(),m?.(e.id)},disabled:r,className:`w-full h-6 text-[10px] text-destructive hover:text-destructive hover:bg-destructive/10 flex items-center justify-center gap-1.5 rounded-md`,children:[(0,X.jsx)(It,{className:`h-3 w-3`}),h(`Reset`)]})})]})]})}),Zd=[],Qd=e=>{let{t}=W(),n=e.mode===`view`,[r,i]=Ye(`quiz-categories-collapsed-parents`,[]),a=(0,Y.useMemo)(()=>new Set(r),[r]),o=(0,Y.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),Array.from(n)})},[i]),[s,c]=Ye(`quiz-favorite-category-ids`,[]),l=(0,Y.useMemo)(()=>new Set(s),[s]),u=(0,Y.useCallback)(e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),Array.from(n)})},[c]),d=`selectedCategoryIds`in e?e.selectedCategoryIds??Zd:Zd,f=(0,Y.useMemo)(()=>new Set(d),[d]),p=`maxSelectable`in e?e.maxSelectable??6:6,m=`disabled`in e?e.disabled??!1:!1,h=`teamsCount`in e?e.teamsCount??0:0,g=d.length>=p,{newCategories:_,otherCategories:v}=(0,Y.useMemo)(()=>{let t=[],n=[],r=e=>{if(!e.createdAt)return!1;let t=new Date(e.createdAt),n=Math.abs(new Date().getTime()-t.getTime());return Math.ceil(n/864e5)<=(D.newnessThresholdDays||7)};
12e.categories.forEach(e=>{if(e.children&&e.children.length>0){e.children.forEach(e=>{r(e)&&t.push({category:e,isChild:!0})}),n.push(e);return}r(e)?t.push({category:e,isChild:!1}):n.push(e)}),t.sort((e,t)=>new Date(t.category.createdAt).getTime()-new Date(e.category.createdAt).getTime());let i=t.slice(0,4).map(e=>e.category),a=t.slice(4).filter(e=>!e.isChild).map(e=>e.category);return n.push(...a),{newCategories:i,otherCategories:n}},[e.categories]),y=(t,r,i)=>{if(n)return(0,X.jsx)(Xd,{category:t,isParent:r,isSelected:!1,isDisabled:!1,isPlayerHost:!1,showReset:!1,interactive:!1,showTotalQuestions:e.showTotalQuestions,showRemaining:e.showRemaining,isCollapsed:i?.isCollapsed,onToggleCollapse:i?.onToggleCollapse,isFavorite:i?.isFavorite,onToggleFavorite:i?.onToggleFavorite},t.id);let a=f.has(t.id),o=t.remaining===0,s=m||o||!a&&g||t.guess===!0&&h>2;return(0,X.jsx)(Xd,{category:t,isParent:r,isSelected:a,isDisabled:s,isPlayerHost:e.isPlayerHost,showReset:e.showReset,showTotalQuestions:e.showTotalQuestions,showRemaining:e.showRemaining,isCollapsed:i?.isCollapsed,onToggleCollapse:i?.onToggleCollapse,isFavorite:i?.isFavorite,onToggleFavorite:i?.onToggleFavorite,onSelect:e.onSelect,onReset:e.onReset},t.id)},b=e.parentWrapperClassName??`w-full max-w-md`,x=e.childrenGridClassName??`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 sm:gap-4 mt-3 sm:mt-4 [@media(orientation:landscape)_and_(max-height:600px)]:grid-cols-4 [@media(orientation:landscape)_and_(max-height:600px)]:gap-2`;return(0,X.jsxs)(`div`,{className:q(`flex flex-col gap-6`,e.className),children:[_.length>0&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold px-1`,children:t(`New Categories`)}),(0,X.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 sm:gap-4 [@media(orientation:landscape)_and_(max-height:600px)]:grid-cols-4 [@media(orientation:landscape)_and_(max-height:600px)]:gap-2`,children:_.map(e=>y(e,!1,{isFavorite:l.has(e.id),onToggleFavorite:u}))}),(0,X.jsx)(`hr`,{className:`border-border/50`})]}),(0,X.jsx)(`div`,{className:q(`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 sm:gap-4 [@media(orientation:landscape)_and_(max-height:600px)]:grid-cols-4 [@media(orientation:landscape)_and_(max-height:600px)]:gap-2`),children:v.map(e=>{if(!e.children||e.children.length===0)return y(e,!1,{isFavorite:l.has(e.id),onToggleFavorite:u});let t=a.has(e.id);return(0,X.jsxs)(`div`,{className:`col-span-full`,children:[(0,X.jsx)(`div`,{className:`flex justify-center mb-4 [@media(orientation:landscape)_and_(max-height:600px)]:mb-1`,children:(0,X.jsx)(`div`,{className:b,children:y(e,!0,{isCollapsed:t,onToggleCollapse:o})})}),(0,X.jsx)(`div`,{className:q(`grid overflow-hidden transition-[grid-template-rows] duration-300 ease-in-out`,t?`grid-rows-[0fr]`:`grid-rows-[1fr]`),children:(0,X.jsx)(`div`,{className:`px-2 min-h-0 overflow-hidden`,children:(0,X.jsx)(`div`,{className:q(`transition-opacity duration-200`,t?`opacity-0 pointer-events-none`:`opacity-100`),children:(0,X.jsx)(`div`,{className:x,children:e.children.map(e=>y(e,!1,{isFavorite:l.has(e.id),onToggleFavorite:u}))})})})}),(0,X.jsx)(`hr`,{className:`my-5 sm:my-6 border-gray-200 dark:border-gray-700 [@media(orientation:landscape)_and_(max-height:600px)]:my-2`})]},e.id)})})]})},$d=({onCategoriesChange:e,disabled:t=!1})=>{let{t:n}=W(),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),s=qe(`(max-width: 640px)`),[c,l]=(0,Y.useState)(null),[u]=Ye(`quiz-favorite-category-ids`,[]),d=(0,Y.useMemo)(()=>new Set(u),[u]),{filteredCategories:f,rootCategories:p,selectedCategoryIds:m,selectedCategoriesCount:h,usedCategoriesCount:g,getSelectedCategories:_,searchQuery:v,setSearchQuery:b,isLoading:x,error:S,teams:w,isPlayerHost:T,canFreeSelectCategories:D,handleStartGame:O,handleSelectCategory:k,handleRemoveCategory:A,handleClearAllQuestions:j,handleClearQuestionsForCategory:N,handleRandomizeCategories:I}=Jd(t,e,c),L=(0,Y.useMemo)(()=>a?f.map(e=>{if(!e.children||e.children.length===0)return null;let t=e.children.filter(e=>e.id!=null&&d.has(e.id));return t.length===0?null:{...e,children:t}}).filter(e=>e!==null):f,[d,f,a]),ee=h>0&&h<=6,R=(m??[]).filter(e=>typeof e==`number`),B=(0,Y.useMemo)(()=>q(`w-full h-auto`,h===0?`min-h-0`:`min-h-[260px] [@media(orientation:landscape)_and_(max-height:600px)]:min-h-[150px]`,`max-h-[calc(min(100svh,100dvh)-20rem)]`,h===0&&`max-h-[calc(min(100svh,100dvh)-15rem)]`,`sm:max-h-[calc(min(100svh,100dvh)-25rem)]`,`md:max-h-[calc(min(100svh,100dvh)-24rem)]`,`lg:max-h-[calc(min(100svh,100dvh)-8rem)]`,`[@media(orientation:landscape)_and_(max-height:600px)]:max-h-[calc(min(100svh,100dvh)-7rem)]`),[h]),ne=(0,Y.useMemo)(()=>T&&(h>=6||h>0&&D),[h,D,T]);return(0,X.jsx)(`div`,{className:`container mx-auto py-4 px-3 sm:py-6 sm:px-4 [@media(orientation:landscape)_and_(max-height:600px)]:py-1 [@media(orientation:landscape)_and_(max-height:600px)]:px-2`,children:(0,X.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-12 [@media(orientation:landscape)_and_(max-height:600px)]:grid-cols-12 gap-4 lg:gap-6 [@media(orientation:landscape)_and_(max-height:600px)]:gap-2 w-full h-full`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col w-full lg:col-span-3 lg:order-1 [@media(orientation:landscape)_and_(max-height:600px)]:col-span-4 [@media(orientation:landscape)_and_(max-height:600px)]:order-1`,children:[(0,X.jsx)(Yd,{isPlayerHost:T,isLoading:x,usedCategoriesCount:g,disabled:t,showResetOptions:r,onToggleResetOptions:()=>i(e=>!e),onRandomizeCategories:I,showFavoritesOnly:a,onToggleFavoritesOnly:()=>o(e=>!e)}),x&&(0,X.jsxs)(`div`,{className:`flex items-center justify-center py-8 [@media(orientation:landscape)_and_(max-height:600px)]:py-4`,children:[(0,X.jsx)(ar,{className:`h-6 w-6 animate-spin text-primary [@media(orientation:landscape)_and_(max-height:600px)]:h-5 [@media(orientation:landscape)_and_(max-height:600px)]:w-5`}),(0,X.jsx)(`span`,{className:`ml-2 text-muted-foreground [@media(orientation:landscape)_and_(max-height:600px)]:text-xs`,children:f.length===0?n(`Loading c
12ategories...`):n(`Starting game...`)})]}),S&&(0,X.jsxs)(M,{color:`destructive`,className:`mb-4 [@media(orientation:landscape)_and_(max-height:600px)]:mb-2`,children:[(0,X.jsx)(It,{className:`h-4 w-4`}),(0,X.jsx)(ye,{children:S})]}),!x&&r&&T&&g>=3&&(0,X.jsx)(`div`,{className:`mb-6 flex justify-end [@media(orientation:landscape)_and_(max-height:600px)]:mb-2`,children:(0,X.jsxs)(F,{color:`destructive`,onClick:j,disabled:t,size:`xs`,className:`flex items-center gap-2 [@media(orientation:landscape)_and_(max-height:600px)]:h-7 [@media(orientation:landscape)_and_(max-height:600px)]:px-2 [@media(orientation:landscape)_and_(max-height:600px)]:text-xs`,children:[(0,X.jsx)(It,{className:`size-5 [@media(orientation:landscape)_and_(max-height:600px)]:size-4`}),n(`Reset all category questions`)]})}),!x&&h>0&&(0,X.jsx)(`div`,{className:`space-y-3 mb-4 [@media(orientation:landscape)_and_(max-height:600px)]:mb-2 [@media(orientation:landscape)_and_(max-height:600px)]:space-y-1`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2 [@media(orientation:landscape)_and_(max-height:600px)]:grid [@media(orientation:landscape)_and_(max-height:600px)]:grid-cols-2 [@media(orientation:landscape)_and_(max-height:600px)]:gap-1 [@media(orientation:landscape)_and_(max-height:600px)]:max-h-[140px] [@media(orientation:landscape)_and_(max-height:600px)]:overflow-y-auto [@media(orientation:landscape)_and_(max-height:600px)]:pr-1`,children:[_.map(e=>(0,X.jsxs)(C,{variant:`outline`,className:`flex items-center justify-between w-fit gap-2 px-3 py-1.5 bg-primary/10 hover:bg-primary/20 transition-colors [@media(orientation:landscape)_and_(max-height:600px)]:w-full [@media(orientation:landscape)_and_(max-height:600px)]:px-1.5 [@media(orientation:landscape)_and_(max-height:600px)]:py-0.5`,children:[(0,X.jsx)(`span`,{className:`text-sm truncate max-w-[150px] [@media(orientation:landscape)_and_(max-height:600px)]:text-[9px] [@media(orientation:landscape)_and_(max-height:600px)]:max-w-[80px]`,children:n(e.name)}),!t&&T&&(0,X.jsx)(`button`,{type:`button`,"aria-label":n(`Remove {{name}}`,{name:n(e.name)}),className:`hover:text-destructive transition-colors focus:outline-none focus:ring-1 focus:ring-destructive rounded flex-shrink-0`,onClick:()=>A(e.id),children:(0,X.jsx)(Ut,{className:`h-3 w-3 [@media(orientation:landscape)_and_(max-height:600px)]:h-2.5 [@media(orientation:landscape)_and_(max-height:600px)]:w-2.5`})})]},e.id)),(0,X.jsx)(C,{variant:`outline`,className:q(`text-xs w-fit`,ee?`bg-green-50 text-green-700 border-green-200`:`bg-primary/5 text-primary`,`[@media(orientation:landscape)_and_(max-height:600px)]:w-full [@media(orientation:landscape)_and_(max-height:600px)]:justify-center [@media(orientation:landscape)_and_(max-height:600px)]:text-[9px] [@media(orientation:landscape)_and_(max-height:600px)]:px-1.5 [@media(orientation:landscape)_and_(max-height:600px)]:py-0.5 [@media(orientation:landscape)_and_(max-height:600px)]:col-span-2`),children:n(`{{count}} of {{max}} categories`,{count:h,max:6})})]})}),!x&&h>=6&&(0,X.jsxs)(M,{color:`warning`,className:`mb-4 p-3 [@media(orientation:landscape)_and_(max-height:600px)]:mb-2 [@media(orientation:landscape)_and_(max-height:600px)]:p-1.5`,children:[(0,X.jsx)(It,{className:`h-4 w-4 [@media(orientation:landscape)_and_(max-height:600px)]:h-3 [@media(orientation:landscape)_and_(max-height:600px)]:w-3`}),(0,X.jsx)(ye,{className:`[@media(orientation:landscape)_and_(max-height:600px)]:text-xs`,children:n(`You've reached the maximum number of categories ({{count}})`,{count:6})})]}),!x&&ne&&(0,X.jsx)(`div`,{className:`mb-4 flex items-center justify-end [@media(orientation:landscape)_and_(max-height:600px)]:mb-2`,children:(0,X.jsx)(F,{size:`lg`,onClick:O,disabled:t,className:`bg-[#2094b1] hover:bg-[#1a7a91] text-white font-bold shadow-md hover:shadow-lg shadow-[#2094b1]/20 hover:shadow-[#2094b1]/30 transition-all duration-200 ease-out border-0 h-11 px-6 [@media(orientation:landscape)_and_(max-height:600px)]:h-8 [@media(orientation:landscape)_and_(max-height:600px)]:px-3 [@media(orientation:landscape)_and_(max-height:600px)]:text-xs`,children:(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Sr,{className:`h-4 w-4 [@media(orientation:landscape)_and_(max-height:600px)]:h-3 [@media(orientation:landscape)_and_(max-height:600px)]:w-3`}),n(`Start game`)]})})}),!x&&(0,X.jsxs)(`div`,{className:`mb-6 flex items-center gap-2 [@media(orientation:landscape)_and_(max-height:600px)]:mb-2 [@media(orientation:landscape)_and_(max-height:600px)]:-order-1`,children:[(0,X.jsxs)(`div`,{className:`relative flex-1`,children:[(0,X.jsx)(Vn,{className:`absolute ltr:left-3 rtl:right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground [@media(orientation:landscape)_and_(max-height:600px)]:h-3 [@media(orientation:landscape)_and_(max-height:600px)]:w-3`}),(0,X.jsx)(Pe,{placeholder:n(`Search for a category...`),value:v,onCh
12ange:e=>b(e.target.value),className:`ltr:pl-10 ltr:pr-10 rtl:pr-10 rtl:pl-10 h-11 sm:h-12 [@media(orientation:landscape)_and_(max-height:600px)]:h-8 [@media(orientation:landscape)_and_(max-height:600px)]:text-xs`,"aria-label":n(`Search categories`),disabled:t}),v&&(0,X.jsx)(F,{variant:`ghost`,size:`icon`,className:`absolute ltr:right-2 rtl:left-2 top-1/2 -translate-y-1/2 h-8 w-8 p-0 hover:bg-muted [@media(orientation:landscape)_and_(max-height:600px)]:h-6 [@media(orientation:landscape)_and_(max-height:600px)]:w-6`,onClick:()=>b(``),"aria-label":n(`Clear search`),disabled:t,children:(0,X.jsx)(Ut,{className:`h-4 w-4 [@media(orientation:landscape)_and_(max-height:600px)]:h-3 [@media(orientation:landscape)_and_(max-height:600px)]:w-3`})})]}),!x&&s&&p.length>0&&(0,X.jsx)(`div`,{className:`shrink-0 w-[140px] [@media(orientation:landscape)_and_(max-height:600px)]:w-[120px]`,children:(0,X.jsxs)(P,{value:c==null?`all`:String(c),onValueChange:e=>{l(e===`all`?null:Number(e))},disabled:t,children:[(0,X.jsx)(z,{className:`w-full h-11 sm:h-12 [@media(orientation:landscape)_and_(max-height:600px)]:h-8`,children:(0,X.jsx)(E,{placeholder:n(`All Categories`)})}),(0,X.jsxs)(He,{children:[(0,X.jsx)(y,{value:`all`,children:n(`All Categories`)}),p.map(e=>(0,X.jsx)(y,{value:String(e.id),children:n(e.name)},String(e.id)))]})]})})]}),!x&&!s&&p.length>0&&(0,X.jsx)(`div`,{className:`mb-4 [@media(orientation:landscape)_and_(max-height:600px)]:mb-2`,children:(0,X.jsxs)(P,{value:c==null?`all`:String(c),onValueChange:e=>{l(e===`all`?null:Number(e))},disabled:t,children:[(0,X.jsx)(z,{className:`w-full h-11 [@media(orientation:landscape)_and_(max-height:600px)]:h-8`,children:(0,X.jsx)(E,{placeholder:n(`All Categories`)})}),(0,X.jsxs)(He,{children:[(0,X.jsx)(y,{value:`all`,children:n(`All Categories`)}),p.map(e=>(0,X.jsx)(y,{value:String(e.id),children:n(e.name)},String(e.id)))]})]})})]}),!x&&(0,X.jsx)(`div`,{className:`flex flex-col w-full lg:col-span-9 lg:order-2 [@media(orientation:landscape)_and_(max-height:600px)]:col-span-8 [@media(orientation:landscape)_and_(max-height:600px)]:order-2 h-full`,children:(0,X.jsx)(te,{className:B,children:(0,X.jsx)(Qd,{categories:L,selectedCategoryIds:R,maxSelectable:6,disabled:t,teamsCount:w.length,isPlayerHost:T,showReset:r,onSelect:k,onReset:N,showTotalQuestions:!0,showRemaining:!0,className:`p-2 sm:p-4 [@media(orientation:landscape)_and_(max-height:600px)]:p-1`})})})]})})},ef=({teams:e})=>{let{t}=W(),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{if(e.length>0){let t=[...e].sort((e,t)=>(t.score||0)-(e.score||0)),n=t[0].score||0;t.every(e=>(e.score||0)===n)?(a(!0),r(null)):(a(!1),r(t[0]))}},[e]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(uu,{}),(0,X.jsxs)(`div`,{className:`w-full h-[76vh] lg:h-[73vh] flex flex-col items-center justify-center relative overflow-hidden`,children:[(0,X.jsx)(`div`,{className:`text-4xl font-bold mb-8 z-10`,children:t(`The Game Has Ended`)}),i?(0,X.jsx)(`div`,{className:`text-3xl text-yellow-500 mb-6`,children:t(`It's a tie! All winners!`)}):n?(0,X.jsxs)(`div`,{className:`flex flex-col items-center mb-6`,children:[(0,X.jsx)(`div`,{className:`text-3xl text-primary mb-2`,children:t(`Winner!`)}),(0,X.jsx)(`div`,{className:`text-5xl font-bold text-primary mb-4 animate-pulse`,children:n.name}),(0,X.jsx)(`div`,{className:`text-4xl font-bold bg-gradient-to-r from-yellow-400 via-red-500 to-pink-500 bg-clip-text text-transparent`,children:n.score})]}):null,(0,X.jsx)(`div`,{className:`flex flex-wrap gap-4 md:gap-6 mt-4 justify-center`,children:e.map(t=>(0,X.jsx)(K,{className:`w-[150px] md:w-[300px] transition-all duration-500 transform hover:scale-105 ${n&&n.id===t.id?`border-4 border-primary shadow-lg shadow-primary/50`:i&&t.score===(e[0]?.score||0)?`border-2 border-yellow-500 dark:border-yellow-400 shadow-md`:``}`,children:(0,X.jsxs)(L,{className:`text-2xl text-center font-bold p-6`,children:[(0,X.jsx)(`div`,{className:`mb-2 ${n&&n.id===t.id?`text-primary text-3xl`:i&&t.score===(e[0]?.score||0)?`text-yellow-500 dark:text-yellow-400`:``}`,children:t.name}),(0,X.jsx)(`div`,{className:`text-3xl ${n&&n.id===t.id?`text-primary`:i&&t.score===(e[0]?.score||0)?`text-yellow-500 dark:text-yellow-400`:``}`,children:t.score})]})},t.id))}),(0,X.jsx)(F,{className:`mt-8 px-6 py-3 rounded-lg text-xl font-bold transition-colors animate-pulse`,asChild:!0,children:(0,X.jsx)(d,{to:`/q`,children:t(`Play Again`)})})]})]})}
12,tf=({teams:e,onChangeTeam:t,onToggleSpectator:n})=>{let{t:r}=W();return(0,X.jsx)(`div`,{className:`relative p-4 z-10 w-full h-full flex flex-col items-center justify-center`,children:(0,X.jsxs)(`div`,{className:`max-w-5xl w-full mx-auto`,children:[(0,X.jsx)(`h2`,{className:`text-xl sm:text-3xl font-bold mb-8 text-center bg-gradient-to-r from-primary to-purple-500 bg-clip-text text-transparent`,children:r(`Choose Your Team`)}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-6 justify-items-center`,children:e.map(e=>(0,X.jsx)(K,{className:`transform transition-all duration-300 hover:scale-105 hover:shadow-lg hover:shadow-primary/20 cursor-pointer border-2 hover:border-primary w-full max-w-[250px]`,onClick:()=>t(e.id),children:(0,X.jsxs)(L,{className:`p-0 overflow-hidden`,children:[(0,X.jsx)(`div`,{className:`bg-gradient-to-r from-primary/10 to-primary/20 p-2`,children:(0,X.jsx)(`h3`,{className:`text-2xl text-center font-bold truncate`,children:e.name})}),(0,X.jsx)(`div`,{className:`p-6 flex flex-col items-center justify-center`,children:(0,X.jsx)(F,{className:`w-full mt-2 bg-gradient-to-r from-primary to-purple-500 hover:from-primary/90 hover:to-purple-600 transition-all duration-300`,children:r(`Join Team`)})})]})},e.id))}),(0,X.jsx)(`div`,{className:`flex items-center justify-center mt-6`,children:(0,X.jsx)(K,{className:`transform transition-all duration-300 hover:scale-105 hover:shadow-lg hover:shadow-primary/20 cursor-pointer border-2 hover:border-primary w-full max-w-[250px]`,onClick:n,children:(0,X.jsx)(L,{children:(0,X.jsx)(`div`,{className:`p-6 flex flex-col items-center justify-center`,children:(0,X.jsx)(F,{className:`w-full mt-2 bg-gradient-to-r from-primary to-purple-500 hover:from-primary/90 hover:to-purple-600 transition-all duration-300`,children:r(`Spectator`)})})})})})]})})},nf=[[],[]],rf={[Ic.NONE]:0,[Ic.EASY]:1,[Ic.NORMAL]:2,[Ic.HARD]:3},af=()=>{let{categories:e,questions:t,selectedQuestion:n,teams:r,isGameEnded:i,changeTeam:a,toggleSpectator:o,selectQuestion:s}=ru(),{player:c,isPlayerHost:l,session:u,fullScreenHandle:d}=J(),f=(0,Y.useMemo)(()=>{let e=new Map;for(let n of t){let t=e.get(n.categoryId)??[[],[]];n.teamIndex===0?t[0].push(n):n.teamIndex===1&&t[1].push(n),e.set(n.categoryId,t)}for(let t of e.values())t[0].sort((e,t)=>rf[e.difficulty]-rf[t.difficulty]),t[1].sort((e,t)=>rf[e.difficulty]-rf[t.difficulty]);return e},[t]),p=(0,Y.useMemo)(()=>{let n=[Ic.NONE,Ic.EASY,Ic.NORMAL,Ic.HARD],r=new Set,i=new Map;for(let e of t){if(r.has(e.id)||(r.add(e.id),e.teamIndex!==0&&e.teamIndex!==1))continue;let t=i.get(e.categoryId)??new Map,n=t.get(e.teamIndex)??new Map,a=n.get(e.difficulty)??[];a.push(e),n.set(e.difficulty,a),t.set(e.teamIndex,n),i.set(e.categoryId,t)}let a=new Map,o=(e,t,n,r)=>{let o=i.get(e)?.get(t)?.get(n)??[],s=`${e}:${t}:${n}`,c=a.get(s)??0,l=Math.min(c+r,o.length);return a.set(s,l),o.slice(c,l)};return e.map(e=>{if(!e.id)return nf;let t=[],r=[];for(let i of n)t.push(...o(e.id,0,i,1)),r.push(...o(e.id,1,i,1));if(t.length<3)for(let r of n){if(t.length>=3)break;t.push(...o(e.id,0,r,3-t.length))}if(r.length<3)for(let t of n){if(r.length>=3)break;r.push(...o(e.id,1,t,3-r.length))}return t.sort((e,t)=>rf[e.difficulty]-rf[t.difficulty]),r.sort((e,t)=>rf[e.difficulty]-rf[t.difficulty]),[t,r]})},[e,t]),m=(0,Y.useMemo)(()=>r.map(e=>`${e.id}:${e.name??``}`).join(`|`),[r]),h=(0,Y.useMemo)(()=>{let e=new Map;for(let t of r)t.id&&e.set(t.id,t.name);return e},[m]);return i?(0,X.jsx)(ef,{teams:r}):!c?.teamId&&!c?.spectator?(0,X.jsx)(tf,{teams:r,onChangeTeam:a,onToggleSpectator:o}):u.data?.playing?n?(0,X.jsxs)(Ze,{handle:d,children:[(0,X.jsx)(uu,{}),(0,X.jsx)(Kd,{})]}):(0,X.jsx)(Ze,{handle:d,children:(0,X.jsxs)(`div`,{className:`h-[100dvh] flex flex-col`,children:[(0,X.jsx)(uu,{}),(0,X.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,X.jsx)(te,{className:`h-full w-full`,children:(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-2 p-2 sm:grid-cols-3 sm:gap-4 sm:p-4 pb-safe [@media(orientation:landscape)_and_(max-width:1024px)]:grid-cols-3 [@media(orientation:landscape)_and_(max-width:1024px)]:gap-2 [@media(orientation:landscape)_and_(max-width:1024px)]:p-2`,children:e.map((e,t)=>(0,X.jsx)(su,{category:e,teamQuestions:p[t]??(e.id?f.get(e.id)??nf:nf),teamNameById:h,onSelectQuestion:s,color:u.data.color}
12,`${e.id??`unknown`}-${t}`))})})}),(0,X.jsx)(`div`,{className:`h-[2px] w-full bg-gradient-to-r from-primary/30 via-primary/50 to-primary/30`}),(0,X.jsx)(`div`,{className:q(`bg-gradient-to-r from-card/10 to-card flex flex-wrap justify-between items-center py-2 px-2 pb-safe [@media(orientation:landscape)_and_(max-width:1024px)]:py-0.5 [@media(orientation:landscape)_and_(max-width:1024px)]:px-1`,l?`min-h-[16vh] [@media(orientation:landscape)_and_(max-width:1024px)]:min-h-[8vh]`:`min-h-[12vh] [@media(orientation:landscape)_and_(max-width:1024px)]:min-h-[6vh]`),children:(0,X.jsx)(mu,{layout:`horizontal`,showSeparators:!0,hideIncreaseOrDecrease:!1})})]})}):(0,X.jsxs)(Ze,{handle:d,children:[(0,X.jsx)(uu,{}),(0,X.jsx)($d,{})]})},of=e({config:()=>sf,default:()=>cf}),sf={menu:{order:0,exclude:!0},title:B(`Quiz`)};function cf(){return(0,X.jsx)(Br,{onSendEvent:Ll,gameId:`quiz`,children:(0,X.jsxs)(`main`,{className:`h-full w-full flex flex-col select-none`,children:[(0,X.jsx)(nu,{children:(0,X.jsx)(af,{})}),(0,X.jsx)(zr,{})]})})}var lf=e({config:()=>uf,default:()=>ff}),uf={menu:{order:0,exclude:!0},title:B(`Question Preview`)},df=()=>(0,X.jsxs)(`div`,{className:`container mx-auto py-8 px-4 animate-pulse space-y-8`,children:[(0,X.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,X.jsx)(`div`,{className:`h-10 w-10 bg-gray-200 dark:bg-gray-800 rounded-full`}),(0,X.jsx)(`div`,{className:`h-9 w-32 bg-gray-200 dark:bg-gray-800 rounded`}),(0,X.jsx)(`div`,{className:`h-10 w-10 bg-gray-200 dark:bg-gray-800 rounded-full`})]}),(0,X.jsxs)(`div`,{className:`max-w-4xl mx-auto rounded-lg border shadow-sm bg-card text-card-foreground`,children:[(0,X.jsx)(`div`,{className:`h-16 bg-secondary/50 rounded-t-lg w-full`}),(0,X.jsxs)(`div`,{className:`p-6 flex flex-col items-center gap-6`,children:[(0,X.jsx)(`div`,{className:`w-full aspect-video bg-gray-200 dark:bg-gray-800 rounded-lg max-h-[60vh]`}),(0,X.jsx)(`div`,{className:`w-3/4 h-8 bg-gray-200 dark:bg-gray-800 rounded`})]})]})]}),ff=()=>{let[e,t]=(0,Y.useState)(!0),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(0),[f,p]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(null),{t:_}=W(),{id:v}=m(),[y]=c(),b=(0,Y.useMemo)(()=>i?o?.guess?i.answers?.[l]:i.answers?.find(e=>e.correct):null,[i,o,l]);return(0,Y.useEffect)(()=>{let e=y.get(`q`);if(!e||!v){r(!0),t(!1);return}let n=y.get(`t`);t(!0);let i=new AbortController,{signal:o}=i;return Il(v,{signal:o}).then(t=>{if(o.aborted)return;if(!t){r(!0);return}g(v);let i=t.questions?.find(t=>t.id===e);if(!i){r(!0);return}let c=t.categories?.find(e=>e.id===i.categoryId);if(!c){r(!0);return}if(c.guess){let e=t.teams?.findIndex(e=>e.id===n);e!==-1&&e!==void 0&&u(e)}s(c),a(i.question)}).catch(e=>{o.aborted||e.name!==`AbortError`&&r(!0)}).finally(()=>{o.aborted||t(!1)}),()=>{i.abort()}},[v,y]),e?(0,X.jsx)(df,{}):n?(0,X.jsx)(`div`,{className:`container mx-auto py-8 px-4`,children:(0,X.jsx)(Tr,{})}):!i||!v?(0,X.jsx)(`div`,{className:`container mx-auto py-8 px-4`,children:(0,X.jsx)(Vr,{})}):(0,X.jsxs)(`div`,{className:`container mx-auto py-8 px-4 min-h-screen flex flex-col gap-8`,children:[(0,X.jsxs)(`div`,{className:`flex justify-between items-center px-2`,children:[(0,X.jsx)(`div`,{}),(0,X.jsxs)(d,{to:h?`/q/${h}`:`/`,className:`transition-transform hover:scale-105`,children:[(0,X.jsx)(`img`,{src:`/images/logo.png`,className:`h-10 w-auto object-contain dark:hidden`,alt:D.name}),(0,X.jsx)(`img`,{src:`/images/logo-dark.png`,className:`h-10 w-auto object-contain hidden dark:block`,alt:D.name})]}),(0,X.jsx)(d,{to:h?`/q/${h}`:`/`,children:(0,X.jsx)(F,{variant:`ghost`,size:`icon`,className:`hover:bg-accent hover:text-accent-foreground`,title:_(`Home`),children:h?(0,X.jsx)(Sr,{className:`h-6 w-6`}):(0,X.jsx)(On,{className:`h-6 w-6`})})})]}),(0,X.jsxs)(K,{className:`max-w-4xl w-full mx-auto shadow-xl border-border/50 animate-in fade-in zoom-in-95 duration-300`,children:[(0,X.jsx)(R,{className:`bg-secondary/10 border-b text-center py-6`,children:(0,X.jsx)(w,{className:`text-2xl sm:text-3xl md:text-4xl font-bold bg-gradient-to-r from-primary to-primary/60 bg-clip-text text-transparent`,children:b?.answer})}),(0,X.jsxs)(L,{className:`p-6 flex flex-col items-center gap-8`,children:[b?.image&&(0,X.jsx)(`div`,{className:`w-full flex justify-center items-center bg-muted/20 rounded-lg overflow-hidden min-h-[200px]`,children:f?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-12 text-muted-foreground gap-2`,children:[(0,X.jsx)(mr,{className:`h-12 w-12`}),(0,X.jsx)(`span`,{children:_(`Failed to load image`)})]}):(0,X.jsx)(`img`,{src:b.image,alt:b.answer,className:`max-w-full max-h-[60vh] object-contain transition-all duration-300 hover:scale-[1.02]`,loading:`lazy`,decoding:`async`,onError:()=>p(!0)})}),b?.video&&(0,X.jsxs)(`div`,{className:`w-full max-w-3xl space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,X.jsx)(nn,{className:`h-4 w-4`}),_(`Video Answer`)]}),(0,X.jsx)(`video`,{src:b.video,controls:!0,className:`w-full rounded-lg shadow-lg border bg-black aspect-video`,controlsList:`nodownload`,preload:`metadata`,children:_(`Your browser does not support video playback`)})]}),b?.audio&&(0,X.jsxs)(`div`,{className:`w-full max-w-xl bg-secondary/10 p-6 rounded-xl border shadow-sm`,children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold mb-4 text-center flex items-center justify-center gap-2`,children:_(`Audio Answer`)}),(0,X.jsx)(`audio`,{src:b.audio,controls:!0,className:`w-full`,controlsList:`nodownload`,preload:`metadata`,children:_(`Your browser does not support audio playback`)})]}),!b?.image&&!b?.video&&!b?.audio&&!b?.answer&&(0,X.jsx)(`div`,{className:`text-center text-muted-foreground py-12`,children:_(`No content available for this answer`)})]})]})]})},pf=e({config:()=>mf,default:()=>hf}),mf={menu:{order:0,exclude:!0},title:B(`Quiz Categories`)};function hf(){let[e,t]=(0,Y.useState)([]),[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[,c]=Qe(),[l]=Ye(`quiz-favorite-category-ids`,[]),u=(0,Y.useMemo)(()=>new Set(l),[l]),{t:f}=W(),p=e=>{let t=[],n=[];
12return e.forEach(e=>{e.children&&e.children.length>0?t.push(e):n.push(e)}),[...t,...n]};(0,Y.useEffect)(()=>{Fl().then(e=>{let n=p(e);t(n)})},[]);let m=async()=>{let e=`${D.url}/q/categories`;await c(e),a(!0),setTimeout(()=>a(!1),2e3)},h=(0,Y.useMemo)(()=>{if(!n.trim()){let t=e;return o?t.map(e=>{if(!e.children||e.children.length===0)return null;let t=e.children.filter(e=>e.id!=null&&u.has(e.id));return t.length===0?null:{...e,children:t}}).filter(e=>e!==null):t}let t=n.toLowerCase().trim(),r=e.filter(e=>{let n=e.name.toLowerCase().includes(t),r=e.children?.some(e=>e.name.toLowerCase().includes(t));return n||r}).map(e=>!e.name.toLowerCase().includes(t)&&e.children?{...e,children:e.children.filter(e=>e.name.toLowerCase().includes(t))}:e);return o?r.map(e=>{if(!e.children||e.children.length===0)return null;let t=e.children.filter(e=>e.id!=null&&u.has(e.id));return t.length===0?null:{...e,children:t}}).filter(e=>e!==null):r},[e,u,n,o]);return(0,X.jsx)(`div`,{className:`container mx-auto py-6 px-4 [@media(orientation:landscape)_and_(max-height:600px)]:py-2 [@media(orientation:landscape)_and_(max-height:600px)]:px-2`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-6 [@media(orientation:landscape)_and_(max-height:600px)]:gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col md:flex-row justify-between items-center gap-4 [@media(orientation:landscape)_and_(max-height:600px)]:gap-2`,children:[(0,X.jsx)(`h1`,{className:`text-2xl font-bold [@media(orientation:landscape)_and_(max-height:600px)]:text-lg`,children:f(`Quiz Categories`)}),(0,X.jsxs)(`div`,{className:`flex flex-wrap flex-row items-center gap-2`,children:[(0,X.jsxs)(F,{variant:o?`default`:`outline`,className:`flex items-center gap-2 [@media(orientation:landscape)_and_(max-height:600px)]:h-7 [@media(orientation:landscape)_and_(max-height:600px)]:text-xs`,onClick:()=>s(e=>!e),children:[(0,X.jsx)(Gn,{className:`h-4 w-4 [@media(orientation:landscape)_and_(max-height:600px)]:h-3 [@media(orientation:landscape)_and_(max-height:600px)]:w-3`}),f(`Favorites`)]}),(0,X.jsx)(F,{variant:`outline`,className:`flex items-center gap-2 [@media(orientation:landscape)_and_(max-height:600px)]:h-7 [@media(orientation:landscape)_and_(max-height:600px)]:text-xs`,onClick:m,children:i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(gn,{className:`h-4 w-4 [@media(orientation:landscape)_and_(max-height:600px)]:h-3 [@media(orientation:landscape)_and_(max-height:600px)]:w-3`}),f(`Copied`)]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(cn,{className:`h-4 w-4 [@media(orientation:landscape)_and_(max-height:600px)]:h-3 [@media(orientation:landscape)_and_(max-height:600px)]:w-3`}),f(`Share Categories`)]})}),(0,X.jsx)(F,{variant:`outline`,className:`flex items-center gap-2 [@media(orientation:landscape)_and_(max-height:600px)]:h-7 [@media(orientation:landscape)_and_(max-height:600px)]:text-xs`,asChild:!0,children:(0,X.jsx)(d,{to:`/q`,className:`text-primary`,children:f(`Create Game`)})})]})]}),(0,X.jsx)(K,{className:`mb-6 [@media(orientation:landscape)_and_(max-height:600px)]:mb-2`,children:(0,X.jsxs)(L,{className:`[@media(orientation:landscape)_and_(max-height:600px)]:pb-3`,children:[(0,X.jsxs)(`div`,{className:`mb-4 relative [@media(orientation:landscape)_and_(max-height:600px)]:mb-2`,children:[(0,X.jsx)(Vn,{className:`absolute ltr:left-3 rtl:right-2 top-2.5 h-4 w-4 text-muted-foreground [@media(orientation:landscape)_and_(max-height:600px)]:top-2 [@media(orientation:landscape)_and_(max-height:600px)]:h-3 [@media(orientation:landscape)_and_(max-height:600px)]:w-3`}),(0,X.jsx)(Pe,{placeholder:f(`Search for a category...`),value:n,onChange:e=>r(e.target.value),className:`ltr:pl-9 ltr:pr-4 rtl:pr-9 rtl:pl-4 [@media(orientation:landscape)_and_(max-height:600px)]:h-8 [@media(orientation:landscape)_and_(max-height:600px)]:text-xs`}),n&&(0,X.jsx)(F,{variant:`ghost`,size:`icon`,className:`absolute ltr:right-2 rtl:left-2 top-2 h-5 w-5 p-0 [@media(orientation:landscape)_and_(max-height:600px)]:top-1.5`,onClick:()=>r(``),children:(0,X.jsx)(Ut,{className:`h-3 w-3`})})]}),h.length===0&&(0,X.jsx)(M,{children:(0,X.jsx)(ye,{children:f(`No categories match the search criteria`)})})]})}),(0,X.jsx)(Qd,{mode:`view`,showTotalQuestions:!0,categories:h,className:`grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 [@media(orientation:landscape)_and_(max-height:600px)]:grid-cols-4 [@media(orientation:landscape)_and_(max-height:600px)]:gap-2`})]})})}var gf=e({config:()=>_f,default:()=>vf}),_f={menu:{order:0,exclude:!0},title:B(`Privacy`)};function vf(){return(0,X.jsx)(`div`,{className:`container mx-auto py-8 max-w-4xl`,children:(0,X.jsxs)(K,{className:`shadow-lg border-primary/20`,children:[(0,X.jsx)(R,{className:`bg-primary/5 border-b border-primary/10`,children:(0,X.jsxs)(w,{className:`text-2xl font-bold text-center`,children:[`سياسة الخصوصية لموقع `,D.name]})}),(0,X.jsxs)(L,{className:`p-6 space-y-6`,children:[(0,X.jsxs)(`section`,{className:`bg-card rounded-lg p-4 shadow-sm border border-border`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-bold mb-3 text-primary`,children:`١. مقدمة`}),(0,X.jsxs)(`p`,{children:[`نحن في موقع `,D.name,` نحترم خصوصيتك ونلتزم بحماية بياناتك الشخصية. توضح هذه السياسة كيفية جمع بياناتك واستخدامها وحمايتها عند استخدامك لموقعنا.`]})]}),(0,X.jsxs)(`section`,{className:`bg-card rounded-lg p-4 shadow-sm border border-border`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-bold mb-3 text-primary`,children:`٢. البيانات التي نجمعها`}),(0,X.jsxs)(`ul`,{className:`space-y-2 pr-6 list-disc`,children:[(0,X.jsx)(`li`,{children:`المعلومات التي تقدمها عند التسجيل أو التواصل معنا، مثل الاسم والبريد الإلكتروني.`}),(0,X.jsx)(`li`,{children:`بيانات الاستخدام مثل عنوان IP، ونوع المتصفح، والصفحات التي تزورها.`})]})]}),(0,X.jsxs)(`section`,{className:`bg-card rounded-lg p-4 shadow-sm border border-border`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-bold mb-3 text-primary`,children:`٣. كيفية استخدام البيانات`}),(0,X.jsxs)(`ul`,{className:`space-y-2 pr-6 list-disc`,children:[(0,X.jsx)(`li`,{children:`تحسين تجربتك على الموقع.`}
12),(0,X.jsx)(`li`,{children:`إرسال تحديثات أو إشعارات تتعلق بالمحتوى والخدمات.`}),(0,X.jsx)(`li`,{children:`تحليل أداء الموقع وتطويره.`})]})]}),(0,X.jsxs)(`section`,{className:`bg-card rounded-lg p-4 shadow-sm border border-border`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-bold mb-3 text-primary`,children:`Ù¤. مشاركة البيانات`}),(0,X.jsx)(`p`,{children:`لا نبيع أو نشارك بياناتك الشخصية مع أطراف ثالثة إلا في الحالات التالية:`}),(0,X.jsxs)(`ul`,{className:`space-y-2 pr-6 list-disc mt-2`,children:[(0,X.jsx)(`li`,{children:`الامتثال للأنظمة والقوانين.`}),(0,X.jsx)(`li`,{children:`حماية حقوق الموقع والمستخدمين.`})]})]}),(0,X.jsxs)(`section`,{className:`bg-card rounded-lg p-4 shadow-sm border border-border`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-bold mb-3 text-primary`,children:`Ù¥. حماية البيانات`}),(0,X.jsx)(`p`,{children:`نطبق إجراءات أمنية مناسبة لحماية بياناتك من الوصول غير المصرح به أو التعديل أو الإفصاح.`})]})]})]})})}var yf=e({config:()=>bf,default:()=>xf}),bf={menu:{order:0,exclude:!0},title:B(`Terms`)};function xf(){return(0,X.jsx)(`div`,{className:`container mx-auto py-8 max-w-4xl`,children:(0,X.jsxs)(K,{className:`mb-8 shadow-lg border-primary/20`,children:[(0,X.jsx)(R,{className:`bg-primary/5 border-b border-primary/10`,children:(0,X.jsxs)(w,{className:`text-2xl font-bold text-center`,children:[`الشروط والأحكام وسياسة الاسترجاع لموقع `,D.name]})}),(0,X.jsx)(L,{className:`p-0`,children:(0,X.jsxs)(pe,{defaultValue:`terms`,className:`w-full`,children:[(0,X.jsxs)(Ie,{className:`w-full grid grid-cols-2 rounded-none`,children:[(0,X.jsx)(Be,{value:`terms`,className:`text-lg py-3`,children:`الشروط والأحكام`}),(0,X.jsx)(Be,{value:`refund`,className:`text-lg py-3`,children:`سياسة الاسترجاع`})]}),(0,X.jsx)(ae,{value:`terms`,className:`p-6 space-y-6`,children:(0,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsxs)(`section`,{className:`bg-card rounded-lg p-4 shadow-sm border border-border`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-bold mb-3 text-primary`,children:`Ù¡. التعريفات`}),(0,X.jsxs)(`ul`,{className:`space-y-2 pr-6 list-disc`,children:[(0,X.jsxs)(`li`,{children:[`الموقع: يُقصد به موقع `,(0,X.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:D.name}),`.`]}),(0,X.jsxs)(`li`,{children:[`نحن: إدارة موقع `,D.name,`.`]}),(0,X.jsx)(`li`,{children:`المستخدم: أي شخص يستخدم الموقع أو يقوم بشراء خدماته.`})]})]}),(0,X.jsxs)(`section`,{className:`bg-card rounded-lg p-4 shadow-sm border border-border`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-bold mb-3 text-primary`,children:`Ù¢. قبول الشروط`}),(0,X.jsx)(`p`,{children:`باستخدام هذا الموقع، فإنك توافق على جميع الشروط والأحكام المذكورة هنا. في حال عدم موافقتك، يُرجى عدم استخدام الموقع أو شراء أي من خدماته.`})]}),(0,X.jsxs)(`section`,{className:`bg-card rounded-lg p-4 shadow-sm border border-border`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-bold mb-3 text-primary`,children:`Ù£. الخدمات المتاحة`}),(0,X.jsxs)(`p`,{children:[`موقع `,D.name,` يقدم خدمات تعليمية وترفيهية مرتبطة باللغة العربية، وهي متاحة كما هي دون أي ضمانات صريحة أو ضمنية.`]})]}),(0,X.jsxs)(`section`,{className:`bg-card rounded-lg p-4 shadow-sm border border-border`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-bold mb-3 text-primary`,children:`Ù¤. حدود المسؤولية`}),(0,X.jsxs)(`ul`,{className:`space-y-2 pr-6 list-disc`,children:[(0,X.jsx)(`li`,{children:`نحن غير مسؤولين عن أي خسائر أو أضرار ناتجة عن استخدام الموقع أو عدم القدرة على استخدامه.`}),(0,X.jsx)(`li`,{children:`لا نقدم أي تعويضات أو استرداد نقدي لأي عمليات شراء تمت عبر الموقع.`}),(0,X.jsx)(`li`,{children:`نحتفظ بالحق في تعديل أو إيقاف أي جزء من الموقع دون إشعار مسبق.`})]})]}),(0,X.jsxs)(`section`,{className:`bg-card rounded-lg p-4 shadow-sm border border-border`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-bold mb-3 text-primary`,children:`Ù¥. الدفع والمعاملات المالية`}),(0,X.jsxs)(`ul`,{className:`space-y-2 pr-6 list-disc`,children:[(0,X.jsx)(`li`,{children:`جميع الأسعار موضحة بوضوح في الموقع، والدفع يتم عبر الوسائل المتاحة لدينا.`}),(0,X.jsx)(`li`,{children:`لا يتم استرداد أي مبالغ بعد إتمام عملية الشراء.`})]})]}),(0,X.jsxs)(`section`,{className:`bg-card rounded-lg p-4 shadow-sm border border-border`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-bold mb-3 text-primary`,children:`Ù¦. الملكية الفكرية`}),(0,X.jsxs)(`p`,{children:[`جميع المحتويات المتوفرة في الموقع، بما في ذلك النصوص والصور والتصاميم، هي ملكية حصرية لموقع `,D.name,`، ولا يجوز نسخها أو استخدامها بدون إذن كتابي مسبق.`]})]}),(0,X.jsxs)(`section`,{className:`bg-card rounded-lg p-4 shadow-sm border border-border`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-bold mb-3 text-primary`,children:`Ù§. التعديلات على الشروط`}),(0,X.jsx)(`p`,{children:`نحتفظ بالحق في تعديل هذه الشروط والأحكام في أي وقت، وستكون التعديلات سارية بمجرد نشرها على الموقع.`})]})]})}),(0,X.jsx)(ae,{value:`refund`,className:`p-6 space-y-6`,children:(0,X.jsx)(`div`,{className:`space-y-6`,children:(0,X.jsxs)(`section`,{className:`bg-card rounded-lg p-4 shadow-sm border border-border`,children:[(0,X.jsx)(`h2`,{className:`text-xl font-bold mb-3 text-warning`,children:`سياسة الاسترجاع والإلغاء`}),(0,X.jsxs)(`ul`,{className:`space-y-4 pr-6 list-decimal`,children:[(0,X.jsx)(`li`,{className:`p-2 bg-warning/5 rounded-md`,children:`جميع المشتريات نهائية ولا يحق للعميل طلب اØ
12³ØªØ±Ø¬Ø§Ø¹ أي مبلغ بعد إتمام عملية الشراء.`}),(0,X.jsx)(`li`,{className:`p-2 bg-warning/5 rounded-md`,children:`لا يتم تقديم أي تعويضات أو استرداد نقدي لأي سبب كان، سواء كان ذلك بسبب عدم الرضا عن الخدمة أو لأي سبب آخر.`}),(0,X.jsx)(`li`,{className:`p-2 bg-warning/5 rounded-md`,children:`يحق لنا إلغاء أي طلب في حال وجود خطأ تقني أو اشتباه في عمليات غير مشروعة، وفي هذه الحالة سيتم إشعار العميل بذلك.`})]})]})})})]})})]})})}var Sf=e({config:()=>Cf,default:()=>wf}),Cf={menu:{order:0,exclude:!0},title:B(`Guess Who?`)};function wf(){let{t:e}=W(),t=[{icon:(0,X.jsx)(Sr,{className:`w-8 h-8 text-primary`}),title:e(`Interactive Game`),description:e(`Enjoy an exciting interactive gaming experience with your friends`)},{icon:(0,X.jsx)(Gn,{className:`w-8 h-8 text-yellow-500`}),title:e(`Points System`),description:e(`Earn 100 points for each character revealed. Multiple characters can be guessed at once`)},{icon:(0,X.jsx)(zn,{className:`w-8 h-8 text-amber-500`}),title:e(`Fierce Competition`),description:e(`If your character is revealed, you are eliminated! The last remaining player wins`)},{icon:(0,X.jsx)(pr,{className:`w-8 h-8 text-red-500`}),title:e(`20 Questions Only`),description:e(`You have 20 questions to discover your opponents' characters from 36 available characters`)},{icon:(0,X.jsx)(Pt,{className:`w-8 h-8 text-blue-500`}),title:e(`Smart Elimination`),description:e(`Click the eye to hide characters and filter your options to reach the target`)},{icon:(0,X.jsx)(Tt,{className:`w-8 h-8 text-green-500`}),title:e(`Multiplayer Game`),description:e(`Play with multiple players and enjoy the exciting competition. Requires 2 or more players`)},{icon:(0,X.jsx)(Cn,{className:`w-8 h-8 text-red-600`}),title:e(`Hardcore Mode`),description:e(`Ultimate challenge! Each player gets only ONE question and cannot repeat it. Wrong guess = instant elimination!`)}];return(0,X.jsx)(`div`,{className:`min-h-screen rounded-lg shadow-lg bg-gradient-to-br from-primary/5 via-background to-secondary/5 dark:from-primary/10 dark:via-background dark:to-secondary/10`,children:(0,X.jsxs)(`div`,{className:`container mx-auto px-4 py-8 max-w-6xl`,children:[(0,X.jsxs)(`div`,{className:`text-center mb-12`,children:[(0,X.jsxs)(`div`,{className:`relative inline-block`,children:[(0,X.jsx)(`h1`,{className:`text-5xl md:text-7xl font-bold bg-gradient-to-r from-primary via-purple-500 to-pink-500 bg-clip-text text-transparent mb-4 font-philosopher`,children:e(`Guess Who?`)}),(0,X.jsx)(`div`,{className:`absolute -top-2 -right-2 w-6 h-6 bg-yellow-400 rounded-full animate-pulse`}),(0,X.jsx)(`div`,{className:`absolute -bottom-2 -left-2 w-4 h-4 bg-pink-400 rounded-full animate-bounce`})]}),(0,X.jsx)(`p`,{className:`text-xl md:text-2xl text-muted-foreground mb-8 max-w-3xl mx-auto leading-relaxed`,children:e(`Discover your opponents' identities before they discover yours! An exciting strategic game that requires intelligence and cunning`)}),(0,X.jsx)(`div`,{className:`mb-8`,children:(0,X.jsx)(F,{size:`xl`,color:`primary`,className:`relative bg-gradient-to-r from-primary via-purple-500 to-pink-500 text-white font-bold text-xl px-12 py-6 rounded-full shadow-2xl hover:shadow-purple-500/25 transition-all duration-500 transform hover:scale-110 hover:-translate-y-2 animate-pulse hover:animate-none group overflow-hidden`,asChild:!0,children:(0,X.jsxs)(d,{to:`/guess-who/play`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-r from-pink-500 via-purple-500 to-primary opacity-0 group-hover:opacity-100 transition-opacity duration-500`}),(0,X.jsx)(`div`,{className:`absolute -inset-1 bg-gradient-to-r from-primary via-purple-500 to-pink-500 rounded-full blur opacity-30 group-hover:opacity-60 transition-opacity duration-500`}),(0,X.jsxs)(`div`,{className:`relative flex items-center gap-3`,children:[(0,X.jsx)(Ot,{className:`w-8 h-8 animate-bounce group-hover:animate-spin`}),(0,X.jsx)(`span`,{className:`bg-gradient-to-r from-white to-yellow-200 bg-clip-text text-transparent group-hover:from-yellow-200 group-hover:to-white transition-all duration-300`,children:e(`Play Now`)}),(0,X.jsx)(`div`,{className:`w-2 h-2 bg-yellow-400 rounded-full animate-ping`})]})]})})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-4 mb-8`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 bg-primary/10 dark:bg-primary/20 px-4 py-2 rounded-full`,children:[(0,X.jsx)(qt,{className:`w-5 h-5 text-primary`}),(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`20 Questions`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 bg-secondary/10 dark:bg-secondary/20 px-4 py-2 rounded-full`,children:[(0,X.jsx)(Tt,{className:`w-5 h-5 text-secondary`}),(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`36 Characters`)}
12)]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 bg-yellow-500/10 dark:bg-yellow-500/20 px-4 py-2 rounded-full`,children:[(0,X.jsx)(Gn,{className:`w-5 h-5 text-yellow-500`}),(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`100 Points per Discovery`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 bg-red-600/10 dark:bg-red-600/20 px-4 py-2 rounded-full border border-red-500/30 hover:bg-red-600/20 transition-all duration-300 animate-pulse hover:animate-none`,children:[(0,X.jsx)(Cn,{className:`w-5 h-5 text-red-600 dark:text-red-400`}),(0,X.jsx)(`span`,{className:`text-sm font-bold text-red-600 dark:text-red-400`,children:e(`Hardcore Mode`)})]})]})]}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mb-12`,children:t.map((e,t)=>(0,X.jsxs)(K,{className:`group hover:shadow-xl transition-all duration-300 hover:-translate-y-2 bg-card/80 backdrop-blur-sm border-primary/20 dark:border-primary/30`,children:[(0,X.jsxs)(R,{className:`text-center pb-4`,children:[(0,X.jsx)(`div`,{className:`mx-auto mb-4 p-3 bg-gradient-to-br from-primary/10 to-secondary/10 dark:from-primary/20 dark:to-secondary/20 rounded-full w-fit group-hover:scale-110 transition-transform duration-300`,children:e.icon}),(0,X.jsx)(w,{className:`text-lg font-bold text-foreground group-hover:text-primary transition-colors duration-300`,children:e.title})]}),(0,X.jsx)(L,{className:`text-center`,children:(0,X.jsx)(`p`,{className:`text-muted-foreground leading-relaxed`,children:e.description})})]},t))}),(0,X.jsxs)(K,{className:`mb-12 bg-gradient-to-r from-primary/5 to-secondary/5 dark:from-primary/10 dark:to-secondary/10 border-primary/30 dark:border-primary/40`,children:[(0,X.jsx)(R,{className:`text-center`,children:(0,X.jsx)(w,{className:`text-3xl font-bold text-primary mb-4 font-philosopher`,children:e(`How to Play?`)})}),(0,X.jsx)(L,{children:(0,X.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-8`,children:[(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-4 p-4 bg-card/50 dark:bg-card/70 rounded-lg border border-border/50`,children:[(0,X.jsx)(`div`,{className:`w-8 h-8 bg-primary text-primary-foreground rounded-full flex items-center justify-center font-bold text-sm flex-shrink-0`,children:`1`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`font-semibold text-foreground mb-2`,children:e(`Choose Your Character`)}),(0,X.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e(`Choose a character from 36 available characters and keep it secret`)})]})]}),(0,X.jsxs)(`div`,{className:`flex items-start gap-4 p-4 bg-card/50 dark:bg-card/70 rounded-lg border border-border/50`,children:[(0,X.jsx)(`div`,{className:`w-8 h-8 bg-primary text-primary-foreground rounded-full flex items-center justify-center font-bold text-sm flex-shrink-0`,children:`2`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`font-semibold text-foreground mb-2`,children:e(`Ask Questions`)}),(0,X.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e(`You have 20 questions shared among all players. After each question, turn passes to the next player`)})]})]}),(0,X.jsxs)(`div`,{className:`flex items-start gap-4 p-4 bg-card/50 dark:bg-card/70 rounded-lg border border-border/50`,children:[(0,X.jsx)(`div`,{className:`w-8 h-8 bg-primary text-primary-foreground rounded-full flex items-center justify-center font-bold text-sm flex-shrink-0`,children:`3`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`font-semibold text-foreground mb-2`,children:e(`Eliminate Characters`)}),(0,X.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e(`Click the eye to hide characters that don't match the descriptions`)})]})]})]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-4 p-4 bg-card/50 dark:bg-card/70 rounded-lg border border-border/50`,children:[(0,X.jsx)(`div`,{className:`w-8 h-8 bg-primary text-primary-foreground rounded-full flex items-center justify-center font-bold text-sm flex-shrink-0`,children:`4`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`font-semibold text-foreground mb-2`,children:e(`Guess the Character`)}),(0,X.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e(`When you're confident, guess y
12our opponent's character and earn 100 points. You can only guess when it's your turn`)})]})]}),(0,X.jsxs)(`div`,{className:`flex items-start gap-4 p-4 bg-card/50 dark:bg-card/70 rounded-lg border border-border/50`,children:[(0,X.jsx)(`div`,{className:`w-8 h-8 bg-primary text-primary-foreground rounded-full flex items-center justify-center font-bold text-sm flex-shrink-0`,children:`5`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`font-semibold text-foreground mb-2`,children:e(`Be the Last One`)}),(0,X.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e(`If your character is discovered, you're out of the game. The last player wins!`)})]})]}),(0,X.jsxs)(`div`,{className:`flex items-start gap-4 p-4 bg-gradient-to-r from-yellow-500/10 to-amber-500/10 dark:from-yellow-500/20 dark:to-amber-500/20 rounded-lg border border-yellow-500/30`,children:[(0,X.jsx)(zn,{className:`w-8 h-8 text-yellow-500 flex-shrink-0`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`font-semibold text-yellow-700 dark:text-yellow-400 mb-2`,children:e(`Winning Tip`)}),(0,X.jsx)(`p`,{className:`text-yellow-600 dark:text-yellow-300 text-sm`,children:e(`Ask smart questions and eliminate characters wisely to narrow down the options`)})]})]})]})]})})]}),(0,X.jsxs)(K,{className:`mb-12 bg-gradient-to-r from-red-600/10 via-orange-600/10 to-red-600/10 dark:from-red-700/20 dark:via-orange-700/20 dark:to-red-700/20 border-red-500/30 dark:border-red-400/40 shadow-lg hover:shadow-red-500/25 transition-all duration-300`,children:[(0,X.jsxs)(R,{className:`text-center`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-center gap-3 mb-4`,children:[(0,X.jsx)(Cn,{className:`w-10 h-10 text-red-600 dark:text-red-400 animate-pulse`}),(0,X.jsx)(w,{className:`text-3xl font-bold text-red-600 dark:text-red-400 font-philosopher`,children:e(`Hardcore Mode`)}),(0,X.jsx)(Cn,{className:`w-10 h-10 text-red-600 dark:text-red-400 animate-pulse`})]}),(0,X.jsx)(`p`,{className:`text-red-700 dark:text-red-300 text-lg font-semibold`,children:e(`For the Ultimate Challenge Seekers!`)})]}),(0,X.jsx)(L,{children:(0,X.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-4 p-4 bg-red-50/50 dark:bg-red-900/20 rounded-lg border border-red-200/50 dark:border-red-700/50`,children:[(0,X.jsx)(`div`,{className:`w-8 h-8 bg-red-600 text-white rounded-full flex items-center justify-center font-bold text-sm flex-shrink-0`,children:`⚡`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`font-semibold text-red-700 dark:text-red-300 mb-2`,children:e(`One Question Only`)}),(0,X.jsx)(`p`,{className:`text-red-600 dark:text-red-400 text-sm`,children:e(`Each player gets only ONE question per turn. No repeating questions allowed!`)})]})]}),(0,X.jsxs)(`div`,{className:`flex items-start gap-4 p-4 bg-red-50/50 dark:bg-red-900/20 rounded-lg border border-red-200/50 dark:border-red-700/50`,children:[(0,X.jsx)(`div`,{className:`w-8 h-8 bg-red-600 text-white rounded-full flex items-center justify-center font-bold text-sm flex-shrink-0`,children:`💀`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`font-semibold text-red-700 dark:text-red-300 mb-2`,children:e(`Wrong Guess = Elimination`)}),(0,X.jsx)(`p`,{className:`text-red-600 dark:text-red-400 text-sm`,children:e(`Make a wrong character guess and you're immediately eliminated from the game!`)})]})]})]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-4 p-4 bg-red-50/50 dark:bg-red-900/20 rounded-lg border border-red-200/50 dark:border-red-700/50`,children:[(0,X.jsx)(`div`,{className:`w-8 h-8 bg-red-600 text-white rounded-full flex items-center justify-center font-bold text-sm flex-shrink-0`,children:`🎯`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`font-semibold text-red-700 dark:text-red-300 mb-2`,children:e(`Maximum Pressure`)}),(0,X.jsx)(`p`,{className:`text-red-600 dark:text-red-400 text-sm`,children:e(`Every decision matters! Think carefully before asking or guessing.`)})]})]}),(0,X.jsxs)(`div`,{className:`flex items-start gap-4 p-4 bg-gradient-to-r from-red-600/20 to-orange-600/20 dark:from-red-700/30 dark:to-orange-700/30 rounded-lg border border-red-500/50`,children:[(0,X.jsx)(Cn,{className:`w-8 h-8 text-red-600 dark:text-red-400 flex-shrink-0 animate-bounce`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`font-semibold text-red-700 dark:text-red-300 mb-2`,children:e(`Hardcore Warning`)}),(0,X.jsx)(`p`,{className:`text-red-600 dark:text-red-400 text-sm font-medium`,children:e(`This mode is designed for experienced players who want the ultimate challenge. Are you brave enough?`)})]})]})]})]})})]}),(0,X.jsx)(`div`,{className:`text-center`,children:(0,X.jsxs)(K,{className:`relative inline-block bg-gradient-to-br from-indigo-600 via-purple-600 to-pink-600 dark:from-indigo-700 dark:via-purple-700 dark:to-pink-700 p-8 border-none shadow-2xl hover:shadow-
12purple-500/25 transition-all duration-500 overflow-hidden`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-r from-blue-600/20 via-purple-600/20 to-pink-600/20 animate-pulse`}),(0,X.jsx)(`div`,{className:`absolute -top-4 -right-4 w-24 h-24 bg-yellow-400/20 rounded-full blur-xl animate-bounce`}),(0,X.jsx)(`div`,{className:`absolute -bottom-4 -left-4 w-32 h-32 bg-pink-400/20 rounded-full blur-xl animate-pulse`}),(0,X.jsxs)(L,{className:`relative text-center z-10`,children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(nr,{className:`w-16 h-16 text-yellow-300 mx-auto mb-4 animate-pulse drop-shadow-lg`}),(0,X.jsx)(`div`,{className:`absolute inset-0 w-16 h-16 mx-auto bg-yellow-300/30 rounded-full blur-md animate-ping`})]}),(0,X.jsx)(`h3`,{className:`text-3xl font-bold bg-gradient-to-r from-white via-yellow-200 to-white bg-clip-text text-transparent mb-4 drop-shadow-lg`,children:e(`Are You Ready for the Challenge?`)}),(0,X.jsx)(`p`,{className:`text-white/95 mb-8 max-w-md mx-auto text-lg leading-relaxed drop-shadow-sm`,children:e(`Enter the world of puzzles and strategy and prove your skills in character discovery!`)}),(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-4 mb-6`,children:[(0,X.jsx)(`div`,{className:`bg-gradient-to-r from-white/25 to-white/15 backdrop-blur-md px-6 py-3 rounded-full border border-white/20 hover:bg-white/30 transition-all duration-300 transform hover:scale-105`,children:(0,X.jsxs)(`span`,{className:`text-white font-semibold drop-shadow-sm`,children:[`🎯 `,e(`Mental Challenge`)]})}),(0,X.jsx)(`div`,{className:`bg-gradient-to-r from-yellow-400/25 to-orange-400/15 backdrop-blur-md px-6 py-3 rounded-full border border-yellow-300/20 hover:bg-yellow-400/30 transition-all duration-300 transform hover:scale-105`,children:(0,X.jsxs)(`span`,{className:`text-white font-semibold drop-shadow-sm`,children:[`🏆 `,e(`Fierce Competition`)]})}),(0,X.jsx)(`div`,{className:`bg-gradient-to-r from-pink-400/25 to-purple-400/15 backdrop-blur-md px-6 py-3 rounded-full border border-pink-300/20 hover:bg-pink-400/30 transition-all duration-300 transform hover:scale-105`,children:(0,X.jsxs)(`span`,{className:`text-white font-semibold drop-shadow-sm`,children:[`🎮 `,e(`Endless Fun`)]})})]}),(0,X.jsx)(`div`,{className:`mt-6`,children:(0,X.jsx)(F,{size:`xl`,className:`relative bg-gradient-to-r from-yellow-400 via-orange-400 to-red-400 hover:from-yellow-300 hover:via-orange-300 hover:to-red-300 text-gray-900 font-bold text-lg px-10 py-4 rounded-full shadow-xl hover:shadow-yellow-400/25 transition-all duration-300 transform hover:scale-110 hover:-translate-y-1 border-2 border-yellow-300/50 overflow-hidden group`,asChild:!0,children:(0,X.jsxs)(d,{to:`/guess-who/play`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-r from-white/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300`}),(0,X.jsxs)(`div`,{className:`relative flex items-center gap-3`,children:[(0,X.jsx)(Ot,{className:`w-6 h-6 animate-bounce group-hover:animate-spin transition-all duration-300`}),(0,X.jsx)(`span`,{className:`font-extrabold tracking-wide`,children:e(`Play Now`)}),(0,X.jsx)(`div`,{className:`w-2 h-2 bg-red-500 rounded-full animate-ping`})]})]})})})]})]})})]})})}var Tf=e({config:()=>Ef,default:()=>Df}),Ef={menu:{order:0},title:B(`Games Status`)};function Df(){return(0,X.jsx)(`div`,{className:`md:pt-6 pb-[20px] pt-[15px] md:px-6 px-4`,children:(0,X.jsx)(bc,{})})}var Of=e=>{let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(!1);return{ticket:t,isTicketLoading:r,loadTicket:(0,Y.useCallback)(async t=>{let r=e.find(e=>e.id===t);if(r){n(r);return}i(!0),n(null);try{let e=await Mr(t);n(e||null)}finally{i(!1)}},[e]),setTicket:n}},kf=()=>{let[e,t]=(0,Y.useState)([]),[n,r]=(0,Y.useState)(!0),[i,a]=(0,Y.useState)(1),[o,s]=(0,Y.useState)(1),[c,l]=(0,Y.useState)(50),u=(0,Y.useCallback)(async()=>{r(!0);try{let e=await Or(dt.of(i,c,St.desc(`lastModifiedDate`)),{response:async e=>{let t=parseInt(e.headers.get(`X-Page-Total`)||`0`);s(t||1)}});t(e||[])}finally{r(!1)}},[i,c]);return(0,Y.useEffect)(()=>{u()},[u]),{tickets:e,isTicketsLoading:n,page:i,total:o,perPage:c,loadTickets:u,setPage:a,setPerPage:l}},Af=()=>{let e=kf(),t=Of(e.tickets);return{...e,...t,isLoading:e.isTicketsLoading||t.isTicketLoading}},jf=(0,Y.createContext)(void 0),Mf=e({default:()=>Pf}),Nf=({children:e})=>{let t=Af();return(0,X.jsx)(jf.Provider,{value:t,children:e})};function Pf(){return(0,X.jsx)(Na,{children:(0,X.jsx)(Nf,{children:(0,X.jsx)(Y.Suspense,{children:(0,X.jsx)(p,{})})})})}var Ff=()=>{let e=(0,Y.useContext)(jf);if(e===void 0)throw Error(`useTickets must be used within a TicketProvider`);return e},If={subject:``,contact:``,severity:Lr.MEDIUM,type:jr.OTHER,content:``},Lf=Q.default.object({subject:Q.default.string().trim().min(3).max(120).required().messages({"string.empty":`Subject is required`,"string.min":`Subject must be at least 3 characters`,"string.max":`Subject cannot exceed 120 characters`}),contact:Q.default.string().trim().allow(``).max(200).messages({"string.max":`Contact c
12annot exceed 200 characters`}),severity:Q.default.string().valid(...Object.values(Lr)).required(),type:Q.default.string().valid(...Object.values(jr)).required(),content:Q.default.string().trim().min(10).max(5e3).required().messages({"string.empty":`Message text is required`,"string.min":`Message text must be at least 10 characters`,"string.max":`Message text cannot exceed 5000 characters`})}),Rf={content:``},zf=Q.default.object({content:Q.default.string().trim().min(3).max(5e3).required().messages({"string.empty":`Message text is required`,"string.min":`Message text must be at least 3 characters`,"string.max":`Message text cannot exceed 5000 characters`})}),Bf=({onCreated:e})=>{let{t}=W(),{toast:n}=je(),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(!1),l=ri({defaultValues:If,resolver:si(Lf)}),u=(0,Y.useMemo)(()=>[{value:Lr.LOW,label:t(`Low`)},{value:Lr.MEDIUM,label:t(`Medium`)},{value:Lr.HIGH,label:t(`High`)},{value:Lr.CRITICAL,label:t(`Critical`)}],[t]),d=(0,Y.useMemo)(()=>[{value:jr.UI,label:t(`UI Issue`)},{value:jr.FUNCTIONALITY,label:t(`Functionality Bug`)},{value:jr.PERFORMANCE,label:t(`Performance Issue`)},{value:jr.CONTENT,label:t(`Content Issue`)},{value:jr.BILLING,label:t(`Billing`)},{value:jr.SUBSCRIPTION,label:t(`Subscription`)},{value:jr.OTHER,label:t(`Other`)}],[t]),f=async r=>{c(!0),o(null);try{let a={subject:r.subject,contact:r.contact||void 0,severity:r.severity,type:r.type,content:r.content,...Pr()};await Fr(a),n({title:t(`Ticket created successfully`),color:`success`}),i(!1),l.reset(If),await e()}catch(e){Jr(e,l,o,t,{subject:`subject`,content:`content`,contact:`contact`,severity:`severity`,type:`type`})}finally{c(!1)}};return(0,X.jsxs)(ge,{open:r,onOpenChange:i,children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsx)(F,{className:`w-full sm:w-auto`,children:t(`Create Ticket`)})}),(0,X.jsxs)(De,{className:`sm:max-w-lg`,children:[(0,X.jsx)(V,{children:(0,X.jsx)(xe,{children:t(`Create Ticket`)})}),a&&(0,X.jsx)(`div`,{className:`bg-destructive/10 text-destructive p-3 rounded-md text-sm`,children:a}),(0,X.jsx)(Ya,{...l,children:(0,X.jsxs)(`form`,{onSubmit:l.handleSubmit(f),className:`space-y-3`,children:[(0,X.jsx)(so,{control:l.control,name:`subject`,label:t(`Subject`),placeholder:t(`Enter a short subject`),error:l.formState.errors.subject,disabled:s,required:!0}),(0,X.jsx)(so,{control:l.control,name:`contact`,label:t(`Contact`),placeholder:t(`Email or phone (optional)`),error:l.formState.errors.contact,disabled:s}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,X.jsx)(uo,{control:l.control,name:`severity`,label:t(`Severity`),items:u,error:l.formState.errors.severity,required:!0,isDisabled:s}),(0,X.jsx)(uo,{control:l.control,name:`type`,label:t(`Type`),items:d,error:l.formState.errors.type,required:!0,isDisabled:s})]}),(0,X.jsx)(co,{control:l.control,name:`content`,label:t(`Message text`),placeholder:t(`Describe your issue in detail`),error:l.formState.errors.content,disabled:s,required:!0}),(0,X.jsxs)(Ne,{children:[(0,X.jsx)(ce,{asChild:!0,children:(0,X.jsx)(F,{type:`button`,variant:`outline`,disabled:s,children:t(`Cancel`)})}),(0,X.jsx)(F,{type:`submit`,disabled:s,children:t(`Submit`)})]})]})})]})]})},Vf=({value:e,onChange:t,options:n=[10,25,50],disabled:r})=>{let{t:i}=W();return(0,X.jsxs)(P,{value:String(e),onValueChange:e=>t(Number(e)),children:[(0,X.jsx)(z,{disabled:r,className:`w-[70px]`,children:(0,X.jsx)(E,{placeholder:i(`Per page`)})}),(0,X.jsx)(He,{children:n.map(e=>(0,X.jsx)(y,{value:String(e),children:e},e))})]})},Hf=e=>{switch(e?.toUpperCase()){case`CRITICAL`:case`HIGH`:return`destructive`;case`MEDIUM`:return`warning`;case`LOW`:return`success`;default:return`secondary`}},Uf=e=>{switch(e?.toUpperCase()){case`BUG`:return`destructive`;case`FEATURE`:return`success`;case`SUPPORT`:return`info`;default:return`secondary`}},Wf=({tickets:e,isAdmin:t,isLoading:n,page:r,total:i,perPage:a,setPage:o,setPerPage:s})=>{let{t:c}=W();return(0,X.jsxs)(K,{children:[(0,X.jsx)(R,{className:`pb-2`,children:(0,X.jsxs)(w,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsx)(`span`,{children:c(`Tickets`)}),(0,X.jsxs)(`div`,{className:`flex flex-row items-center justify-end gap-2`,children:[(0,X.jsx)(N,{disabled:n,page:r,limit:1,total:i,onPageChange:o,className:`mx-0 w-auto justify-end`}),(0,X.jsx)(Vf,{disabled:n,value:a,onChange:e=>s(e)})]})]})}),(0,X.jsx)(L,{children:n?(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(`div`,{className:`hidden md:block`,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(v,{className:`h-10 w-full`}),(0,X.jsx)(v,{className:`h-12 w-full`}),(0,X.jsx)(v,{className:`h-12 w-full`}),(0,X.jsx)(v,{className:`h-12 w-full`})]})}),(0,X.jsxs)(`div`,{className:`space-y-3 md:hidden`,children:[(0,X.jsx)(v,{className:`h-32 w-full rounded-xl`}),(0,X.jsx)(v,{className:`h-32 w-full rounded-xl`}),(0,X.jsx)(v,{className:`h-32 w-full rounded-xl`})]})]}):e.length===0?(0,X.jsx)(`div`,{className:`py-8 text-center text-sm text-muted-foreground`,children:c(`No tickets yet`)}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`hidden md:block`,children:(0,X.jsxs)(le,{children:[(0,X.jsx)(Le,{children:(0,X.jsxs)(ee,{children:[(0,X.jsx)(x,{children:c(`Category`)}),t&&(0,X.jsx)(x,{children:c(`Severity`)}),t&&(0,X.jsx)(x,{children:c(`Type`)}),(0,X.jsx)(x,{children:c(`Subject`)}),(0,X.jsx)(x,{children:c(`Last Reply`)}),(0,X.jsx)(x,{children:c(`Last Reply At`)})]})}),(0,X.jsx)(ze,{children:e.map(e=>(0,X.jsxs)(ee,{children:[(0,X.jsx)(I,{children:(0,X.jsx)(C,{variant:`outline`,color:`secondary`,children:c(e.category?.capitalize()||`No Category`)})}),t&&(0,X.jsx)(I,{children:(0,X.jsx)(C,{variant:`soft`,color:Hf(e.severity),children:c(e.severity?.capitalize()||`No Severity`)})}),t&&(0,X.jsx)(I,{children:(0,X.jsx)(C,{variant:`soft`,color:Uf(e.type),children:c(e.type?.capitalize()||`No Type`)})}),(0,X.jsx)(I,{className:`max-w-[260px] sm:max-w-none`,children:(0,X.jsx)(d,{className:`font-medium hover:underline hover:text-primary break-words`,to:`/tickets/${e.id}`,children:e.subject?e.subject:c(`No Subject`)})}),(0,X.jsx)(I,{className:`max-w-[220px] break-words text-xs text-muted-foreground`,children:e.lastComment?e.lastComment.user?.name?e.lastComment.user.name:c(`Anonymous`):`-`}),(0,X.jsx)(I,{children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,X.jsx)(tn,{className:`h-3.5 w-3.5`}
12),(0,X.jsx)(Ee,{timestamp:e.lastComment?.createdAt||e.createdAt,format:`DD/MM/YYYY (HH:mm)`})]})})]},e.id))})]})}),(0,X.jsx)(`div`,{className:`flex flex-col gap-4 md:hidden`,children:e.map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg border bg-card p-4 text-card-foreground shadow-sm transition-colors hover:bg-muted/50`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:[(0,X.jsx)(d,{to:`/tickets/${e.id}`,className:`line-clamp-2 font-semibold leading-tight hover:underline hover:text-primary`,children:e.subject?e.subject:c(`No Subject`)}),(0,X.jsx)(`div`,{className:`shrink-0 text-xs text-muted-foreground flex flex-col items-end gap-1`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(tn,{className:`h-3 w-3`}),(0,X.jsx)(Ee,{timestamp:e.lastComment?.createdAt||e.createdAt,format:`DD/MM/YYYY (HH:mm)`})]})})]}),(0,X.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:[(0,X.jsxs)(C,{variant:`outline`,className:`text-[10px] px-2 h-5`,children:[(0,X.jsx)(Dn,{className:`ltr:mr-1 rtl:ml-1 h-3 w-3`}),c(e.category?.capitalize()||`No Category`)]}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(C,{variant:`soft`,color:Hf(e.severity),className:`text-[10px] px-2 h-5`,children:[(0,X.jsx)(xn,{className:`ltr:mr-1 rtl:ml-1 h-3 w-3`}),c(e.severity?.capitalize()||`No Severity`)]}),(0,X.jsxs)(C,{variant:`soft`,color:Uf(e.type),className:`text-[10px] px-2 h-5`,children:[(0,X.jsx)(Tn,{className:`ltr:mr-1 rtl:ml-1 h-3 w-3`}),c(e.type?.capitalize()||`No Type`)]})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-t pt-3 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(en,{className:`h-3.5 w-3.5`}),(0,X.jsxs)(`span`,{children:[c(`Last Reply`),`:`]})]}),(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e.lastComment?e.lastComment.user?.name||c(`Anonymous`):c(`No reply`)})]})]},e.id))})]})})]})},Gf=e({config:()=>Kf,default:()=>qf}),Kf={menu:{order:0,exclude:!0},title:B(`Support`),loginRequired:!0};function qf(){let{isAdmin:e}=pt(),{tickets:t,isTicketsLoading:n,page:r,total:i,perPage:a,setPage:o,setPerPage:s,loadTickets:c}=Ff(),{t:l}=W();return(0,X.jsxs)(`div`,{className:`space-y-4 md:pt-6 pb-[20px] pt-[15px] md:px-6 px-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsx)(`h1`,{className:`text-2xl font-bold`,children:l(`Support`)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(F,{variant:`outline`,size:`icon`,onClick:()=>c(),disabled:n,title:l(`Refresh`),children:(0,X.jsx)(Et,{className:`h-4 w-4 ${n?`animate-spin`:``}`})}),(0,X.jsx)(Bf,{onCreated:async()=>{if(r!==1){o(1);return}await c()}})]})]}),(0,X.jsx)(Wf,{tickets:t,isAdmin:e,isLoading:n,page:r,total:i,perPage:a,setPage:o,setPerPage:s})]})}var Jf=({ticket:e,isAdmin:t})=>{let{t:n}=W(),r=e.lastComment?e.lastComment.user?.name?e.lastComment.user.name:n(`Anonymous`):n(`No reply yet`),i=e.lastComment?.updatedAt||e.lastComment?.createdAt;return(0,X.jsxs)(K,{children:[(0,X.jsx)(R,{className:`pb-2`,children:(0,X.jsxs)(w,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsx)(`span`,{children:n(`Details`)}),(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:(0,X.jsx)(Ee,{timestamp:e.updatedAt||e.createdAt,format:`DD/MM/YYYY (HH:mm)`})})]})}),(0,X.jsxs)(L,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-2 text-sm`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`Category`)}),(0,X.jsx)(`div`,{children:n(e.category?.capitalize()||`No Category`)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`Severity`)}),(0,X.jsx)(`div`,{children:n(e.severity?.capitalize()||`No Severity`)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`Type`)}),(0,X.jsx)(`div`,{children:n(e.type?.capitalize()||`No Type`)})]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-2 text-sm`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`Last Reply`)}),(0,X.jsx)(`div`,{className:`break-words`,children:r})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`Last Reply At`)}),(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:i?(0,X.jsx)(Ee,{timestamp:i,format:`DD/MM/YYYY (HH:mm)`}):`-`})]}),t&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`IP Address`)}),(0,X.jsx)(`div`,{className:`break-words text-xs text-muted-foreground`,children:e.ipAddress||`-`})]})]}),t&&e.userAgent&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`User Agent`)}),(0,X.jsx)(`div`,{className:`break-words text-xs text-muted-foreground`,children:e.userAgent})]})]})]})},Yf=({authorName:e,timestamp:t,content:n,isAdmin:r,meta:i,className:a,owner:o,screenshot:s})=>{let{t:c}=W(),[l,u]=(0,Y.useState)(!1);return(0,X.jsxs)(K,{className:q(a,o&&`bg-card/30`),children:[(0,X.jsxs)(R,{className:`pb-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium break-words`,children:e}),(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground flex flex-row gap-2 sm:flex-col sm:gap-0 sm:text-right`,children:(0,X.jsx)(Ee,{timestamp:t,format:`DD/MM/YYYY (HH:mm)`})})]}),(0,X.jsxs)(L,{children:[(0,X.jsx)(`div`,{className:`text-sm whitespace-pre-wrap break-words`,children:n}),s?.url&&(0,X.jsxs)(`div`,{className:`mt-4`,children:[(0,X.jsxs)(`div`,{className:`mb-2 text-xs font-medium flex items-center gap-2 text-muted-foreground`,children:[(0,X.jsx)(Wn,{className:`h-3.5 w-3.5`}),c(`Attached Screenshot`)]}),(0,X.jsx)(`a`,{href:s.url,target:`_blank`,rel:`noopener noreferrer`,className:`block w-fit`,children:(0,X.jsx)(`img`,{src:s.url,alt:`Screenshot`,className:`max-h-[300px] w-auto rounded-lg border bg-muted/50 object-contain transition-all hover:opacity-90`})})]}),r&&i&&(i.ipAddress||i.userAgent)&&(0,X.jsxs)(`div`,{className:`mt-3 flex flex-col items-end`,children:[(0,X.jsxs)(F,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs flex items-center gap-1`,onClick:()=>u(!l),children:[(0,X.jsx)(Tn,{className:`h-3 w-3`}),c(`Details`)]}),l&&(0,X.jsxs)(`div`,{className:`mt-2 w-full rounded-md bg-background/60 p-2 text-xs text-muted-foreground break-words space-y-1 text-left ltr`,children:[i.ipAddress&&(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`span`,{className:`font-semibold`,children:[c(`IP Address`),`:`]}),` `,i.ipAddress]}),i.userAgent&&(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`span`,{className:`font-semibold`,children:[c(`User Agent`),`:`]}),` `,i.userAgent]})]})]})]})]})},Xf=({comments:e,isAdmin:t,isLoading:n,ticket:r,page:i,total:a,perPage:o,onPerPageChange:s,onPageChange:c})=>{let{t:l}=W(),u=e.length>0;return(0,X.jsxs)(X.Fragment,{children:[n&&u&&(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:l(`Loading...`)}),!u&&(0,X.jsx)(`div`,{className:`text-sm text-muted-foreground py-6 text-center`,children:l(n?`Loading...`:`No reply yet`)}),u&&(0,X.jsx)(`div`,{className:`space-y-3`,children:e.map((e,n)=>(0,X.jsx)(Yf,{authorName:e.user?.name?e.user.name:l(`Anonymous`),owner:e.user?.id===r?.user?.id,timestamp:e.updatedAt||e.createdAt,content:e.content||``,isAdmin:t,meta:{ipAddress:e.ipAddress,userAgent:e.userAgent}},e.id??`${e.createdAt??`comment`}-${n}`))}),r&&(0,X.jsx)(Yf,{authorName:r.user?.name?r.user.name:l(`Anonymous`),timestamp:r.createdAt,content:r.content?r.content:l(`No Content`),owner:!0,isAdmin:t,meta:{ipAddress:r.ipAddress,userAgent:r.userAgent},screenshot:r.screenshot}),(0,X.jsx)(K,{children:(0,X.jsx)(R,{children:(0,X.jsx)(w,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:(0,X.jsxs)(`div`,{className:`flex flex-row gap-2 items-center justify-end`,children:[(0,X.jsx)(N,{disabled:n,page:i,limit:1,total:a,onPageChange:c,className:`mx-0 w-auto justify-end`}),(0,X.jsx)(Vf,{disabled:n,value:o,onChange:s})]})})})})]})},Zf=({ticketId:e,enabled:t,onAdded:n})=>{let{t:r}=W(),{toast:i}=je(),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),d=ri({defaultValues:Rf,resolver:si(zf)}),f=async a=>{if(t){c(!0),o(null);try{let t={content:a.content,userAgent:typeof navigator<`u`?navigator.userAgent:void 0};await Er(e,t),i({title:r(`Reply added successfully`),color:`success`}),d.reset(Rf),await n()}catch(e){Jr(e,d,o,r,{content:`content`})}finally{c(!1)}}};return(0,X.jsxs)(K,{children:[(0,X.jsx)(R,{className:`pb-2`,children:(0,X.jsxs)(w,{onClick:()=>u(!l),className:`flex cursor-pointer items-center justify-between select-none`,children:[(0,X.jsx)(`span`,{children:r(`Add Reply`)}),(0,X.jsx)(_n,{className:`h-5 w-5 transition-transform duration-200 ${l?`rotate-180`:``}`})]})}),(0,X.jsx)(`div`,{className:`grid transition-[grid-template-rows,opacity] duration-300 ease-in-out ${l?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`}`,children:(0,X.jsx)(`div`,{className:`overflow-hidden`,children:(0,X.jsxs)(L,{children:[a&&(0,X.jsx)(`div`,{className:`bg-destructive/10 text-destructive mb-3 rounded-md p-3 text-sm`,children:a}),(0,X.jsx)(Ya,{...d,children:(0,X.jsxs)(`form`,{onSubmit:d.handleSubmit(f),className:`space-y-3`,children:[(0,X.jsx)(co,{control:d.control,name:`content`,label:r(`Message text`),placeholder:r(`Write a reply`),error:d.formState.errors.content,disabled:s||!t,required:!0,rows:4}),(0,X.jsx)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,children:(0,X.jsx)(F,{type:`submit`,disabled:s||!t,children:r(`Submit`)})})]})})]})})})]})},Qf=({ticketId:e,enabled:t})=>{let[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(1),[c,l]=(0,Y.useState)(1),[u,d]=(0,Y.useState)(25),f=(0,Y.useRef)(null),p=(0,Y.useRef)(null),m=(0,Y.useRef)(null),h=(0,Y.useRef)(0),g=(0,Y.useRef)(!1),_=(0,Y.useRef)(!0),v=(0,Y.useMemo)(()=>t&&Number.isFinite(e)&&e>0,[t,e]),y=(0,Y.useCallback)(async(t=!1)=>
12{if(!(!v||g.current)){g.current=!0,t||a(!0);try{let n=await Rr(e,dt.of(o,u,St.desc(`id`)),p.current?p.current:void 0,{response:async e=>{let t=parseInt(e.headers.get(`X-Page-Total`)||`0`);l(t||1)}});n&&n.length>0?(p.current=n[0].id,h.current=0,r(e=>{let t=n.filter(t=>!e.some(e=>e.id===t.id));return t.length===0?e:[...t,...e]})):t&&(h.current+=1)}catch(e){console.error(`Error fetching comments:`,e),t||(r([]),l(1)),t&&(h.current+=1)}finally{g.current=!1,t||a(!1)}}},[v,o,u,e]),b=(0,Y.useCallback)(()=>{m.current&&=(clearTimeout(m.current),null)},[]),x=(0,Y.useCallback)(()=>{b();let e=()=>{let t=Math.min(5e3+h.current*2e3,3e4);m.current=setTimeout(async()=>{_.current&&await y(!0),e()},t)};e()},[y,b]);return(0,Y.useEffect)(()=>{let e=()=>{_.current=!document.hidden,_.current&&v&&(h.current=0,y(!0))};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[y,v]),(0,Y.useEffect)(()=>{if(!v){b(),f.current=null,p.current=null,h.current=0,r([]),l(1);return}if(f.current!==e&&(f.current=e,r([]),p.current=null,h.current=0,o!==1)){s(1);return}return y().then(()=>{x()}),()=>b()},[v,e,o,u]),{comments:n,isCommentsLoading:i,page:o,total:c,perPage:u,setPage:s,setPerPage:d,reload:(0,Y.useCallback)(async()=>{h.current=0,await y(!1),b(),x()},[y,b,x])}},$f=e({config:()=>ep,default:()=>tp}),ep={menu:{order:0,exclude:!0},title:B(`Ticket`),loginRequired:!0};function tp(){let{isTicketLoading:e,loadTicket:t,ticket:n}=Ff(),{isAdmin:r}=pt(),{id:i}=m(),{t:a}=W(),o=(0,Y.useMemo)(()=>Number(i),[i]),s=Number.isFinite(o)&&o>0,c=Qf({ticketId:o,enabled:s});return(0,Y.useEffect)(()=>{s&&t(o)},[s,t,o]),(0,X.jsxs)(`div`,{className:`space-y-4 md:pt-6 pb-[20px] pt-[15px] md:px-6 px-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsx)(`div`,{className:`space-y-1`,children:(0,X.jsx)(`h1`,{className:`text-2xl font-bold`,children:n?.subject?n.subject:a(`No Subject`)})}),(0,X.jsx)(d,{className:`underline text-sm`,to:`/tickets`,children:a(`Back`)})]}),e&&(0,X.jsx)(we,{simple:!0}),!e&&(!s||!n)&&(0,X.jsx)(`div`,{className:`text-sm text-muted-foreground py-8 text-center`,children:a(`Ticket not found`)}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-4`,children:[(0,X.jsxs)(`div`,{className:`lg:col-span-2 lg:order-1 space-y-4`,children:[(0,X.jsx)(Zf,{ticketId:o,enabled:s,onAdded:async()=>{if(await t(o),c.page!==1){c.setPage(1);return}await c.reload()}}),(0,X.jsx)(Xf,{comments:c.comments,isAdmin:r,isLoading:c.isCommentsLoading,ticket:n,page:c.page,total:c.total,perPage:c.perPage,onPerPageChange:e=>{c.setPerPage(e),c.setPage(1)},onPageChange:c.setPage})]}),(0,X.jsx)(`div`,{className:`lg:col-span-1 lg:order-2`,children:n&&(0,X.jsx)(Jf,{ticket:n,isAdmin:r})})]})]})}var np=e({config:()=>rp,default:()=>ip}),rp={menu:{order:0,exclude:!0},title:B(`Nard`),rolesAllowed:[`ADMIN`]};function ip(){let[e,t]=(0,Y.useState)([]),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(-1),[c,l]=(0,Y.useState)(()=>`-1`),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(`all`),[m,h]=(0,Y.useState)(`all`),[g,_]=(0,Y.useState)(``),[v,b]=(0,Y.useState)(``),[x,S]=(0,Y.useState)(!1),[T,D]=(0,Y.useState)(`default`);(0,Y.useEffect)(()=>{let e=!1;return(async()=>{r(!0),a(null);try{let n=await Pi(o===-1?void 0:o);if(e)return;t(n)}catch(t){if(e)return;a(t instanceof Error?t.message:`Unknown error`)}finally{if(e)return;r(!1)}})(),()=>{e=!0}},[o]);let O=(0,Y.useMemo)(()=>[{value:`all`,label:`All rarities`},{value:ji.GOLD_RARE,label:`Gold Rare`},{value:ji.GOLD,label:`Gold`},{value:ji.SILVER_RARE,label:`Silver Rare`},{value:ji.SILVER,label:`Silver`},{value:ji.BRONZE,label:`Bronze`}],[]),k=(0,Y.useMemo)(()=>{let t=u.trim().toLowerCase(),n=m===`all`?null:Number(m),r=g.trim()===``?null:Number(g),i=v.trim()===``?null:Number(v);return e.filter(e=>f!==`all`&&e.category!==f||Number.isFinite(n)&&n!==null&&e.dices!==n||Number.isFinite(r)&&r!==null&&e.points<r||Number.isFinite(i)&&i!==null&&e.points>i?!1:!t||`${e.id} ${e.category} ${e.dices} ${e.points}`.toLowerCase().includes(t))},[e,m,v,g,f,u]),A=(0,Y.useMemo)(()=>
12{if(T==="default")return k;let e=T.endsWith(`_desc`)?-1:1,t=T.startsWith(`action`)?`action`:T.startsWith(`points`)?`points`:T.startsWith(`numbers`)?`numbers`:`dices`,n=(e,t)=>{let n=e.slice().sort((e,t)=>e-t),r=t.slice().sort((e,t)=>e-t),i=Math.min(n.length,r.length);for(let e=0;e<i;e++){let t=n[e]-r[e];if(t!==0)return t}return n.length-r.length};return k.slice().sort((r,i)=>{if(t===`numbers`){let t=n(r.numbers,i.numbers)*e;if(t!==0)return t;let a=(r.dices-i.dices)*e;return a===0?(r.points-i.points)*e:a}if(t===`dices`){let t=(r.dices-i.dices)*e;return t===0?(r.points-i.points)*e:t}if(t===`action`){let t=r.action??``,n=i.action??``,a=t.localeCompare(n)*e;return a===0?(r.points-i.points)*e:a}let a=(r.points-i.points)*e;return a===0?(r.dices-i.dices)*e:a})},[k,T]),j=(0,Y.useMemo)(()=>{let e={[ji.GOLD_RARE]:`Gold Rare`,[ji.GOLD]:`Gold`,[ji.SILVER_RARE]:`Silver Rare`,[ji.SILVER]:`Silver`,[ji.BRONZE]:`Bronze`},t=[ji.GOLD_RARE,ji.GOLD,ji.SILVER_RARE,ji.SILVER,ji.BRONZE],n=new Map;for(let e of A){let t=n.get(e.category)??[];t.push(e),n.set(e.category,t)}return t.map(t=>{let r=n.get(t)??[];return{category:t,label:e[t],cards:r}}).filter(e=>e.cards.length>0)},[A]),M=(0,Y.useMemo)(()=>A.reduce((e,t)=>e+(t.points??0),0),[A]);return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`h1`,{className:`text-2xl font-extrabold tracking-tight`,children:`Nard Cards`}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(C,{color:`info`,children:[`Total: `,e.length]}),(0,X.jsxs)(C,{color:`secondary`,children:[`Visible: `,A.length]}),n?(0,X.jsx)(C,{color:`warning`,children:`Loading…`}):null]})]})}),(0,X.jsxs)(K,{children:[(0,X.jsx)(R,{className:`pb-2`,children:(0,X.jsx)(w,{className:`text-base`,children:`Filters`})}),(0,X.jsx)(L,{children:(0,X.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 lg:grid-cols-7`,children:[(0,X.jsxs)(`div`,{className:`space-y-1 lg:col-span-2`,children:[(0,X.jsx)(ue,{children:`Search`}),(0,X.jsx)(Pe,{value:u,onChange:e=>d(e.target.value),placeholder:`Search by id / rarity / dices / points`})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(ue,{children:`Rarity`}),(0,X.jsxs)(P,{value:f,onValueChange:e=>p(e),children:[(0,X.jsx)(z,{children:(0,X.jsx)(E,{placeholder:`Select`})}),(0,X.jsx)(He,{children:O.map(e=>(0,X.jsx)(y,{value:e.value,children:e.label},e.value))})]})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(ue,{children:`Dices`}),(0,X.jsxs)(P,{value:m,onValueChange:e=>h(e),children:[(0,X.jsx)(z,{children:(0,X.jsx)(E,{placeholder:`Select`})}),(0,X.jsxs)(He,{children:[(0,X.jsx)(y,{value:`all`,children:`All`}),[1,2,3,4,5,6].map(e=>(0,X.jsx)(y,{value:String(e),children:e},e))]})]})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(ue,{children:`Min points`}),(0,X.jsx)(Pe,{type:`number`,value:g,onChange:e=>_(e.target.value),placeholder:`0`})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(ue,{children:`Max points`}),(0,X.jsx)(Pe,{type:`number`,value:v,onChange:e=>b(e.target.value),placeholder:`999`})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(ue,{children:`Sort`}),(0,X.jsxs)(P,{value:T,onValueChange:e=>D(e),children:[(0,X.jsx)(z,{children:(0,X.jsx)(E,{placeholder:`Select`})}),(0,X.jsxs)(He,{children:[(0,X.jsx)(y,{value:`default`,children:`Default (no sort)`}),(0,X.jsx)(y,{value:`action_asc`,children:`Action ↑, Points ↑`}),(0,X.jsx)(y,{value:`action_desc`,children:`Action ↓, Points ↓`}),(0,X.jsx)(y,{value:`dices_asc`,children:`Dices ↑, Points ↑`}),(0,X.jsx)(y,{value:`dices_desc`,children:`Dices ↓, Points ↓`}),(0,X.jsx)(y,{value:`points_asc`,children:`Points ↑, Dices ↑`}),(0,X.jsx)(y,{value:`points_desc`,children:`Points ↓, Dices ↓`}),(0,X.jsx)(y,{value:`numbers_asc`,children:`Numbers ↑`}),(0,X.jsx)(y,{value:`numbers_desc`,children:`Numbers ↓`})]})]})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(ue,{children:`Grouping`}),(0,X.jsxs)(P,{value:x?`grouped`:`flat`,onValueChange:e=>S(e===`grouped`),children:[(0,X.jsx)(z,{children:(0,X.jsx)(E,{placeholder:`Select`})}),(0,X.jsxs)(He,{children:[(0,X.jsx)(y,{value:`grouped`,children:`Group by category`}),(0,X.jsx)(y,{value:`flat`,children:`No grouping`})]})]})]})]})})]}),(0,X.jsxs)(K,{children:[(0,X.jsx)(R,{className:`pb-2`,children:(0,X.jsx)(w,{className:`text-base`,children:`Cards count`})}),(0,X.jsx)(L,{children:(0,X.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 lg:grid-cols-6`,children:[(0,X.jsxs)(`div`,{className:`space-y-1 lg:col-span-2`,children:[(0,X.jsx)(ue,{children:`Total number of cards`}),(0,X.jsx)(Pe,{type:`number`,min:-1,max:255,step:`1`,value:c,onChange:e=>l(e.target.value),placeholder:`-1`}),(0,X.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Current: `,o===-1?`All`:o]})]}),(0,X.jsx)(`div`,{className:`flex flex-col justify-end gap-2 lg:col-span-2`,children:(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(F,{type:`button`,onClick:()=>{let e=Number(c);if(!Number.isFinite(e)){s(-1),l(`-1`);return}if(e<0){s(-1),l(`-1`);return}s(Math.floor(e)),l(String(Math.floor(e)))},disabled:n,className:`w-full`,children:`Apply`}),(0,X.jsx)(F,{type:`button`,variant:`outline`,onClick:()=>{s(-1),l(`-1`)},disabled:n,className:`w-full`,children:`Reset`})]})})]})})]}),i?(0,X.jsx)(K,{className:`border-destructive/40`,children:(0,X.jsx)(L,{className:`pt-6 text-sm text-destructive`,children:i})}):null,x?(0,X.jsx)(`div`,{className:`space-y-4`,children:j.map(e=>(0,X.jsxs)(K,{children:[(0,X.jsx)(R,{className:`pb-2`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(w,{className:`text-base`,children:e.label}),(0,X.jsx)(C,{color:`secondary`,children:e.cards.length}),(0,X.jsx)(C,{color:`warning`,children:e.cards.reduce((e,t)=>
12e+(t.points??0),0)})]})}),(0,X.jsx)(L,{children:(0,X.jsx)(`div`,{className:`grid grid-cols-3 sm:grid-cols-6 gap-2`,children:e.cards.map(e=>(0,X.jsx)(Ii,{card:e},e.id))})})]},e.category))}):(0,X.jsxs)(K,{children:[(0,X.jsx)(R,{className:`pb-2`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(w,{className:`text-base`,children:`Cards`}),(0,X.jsx)(C,{color:`secondary`,children:A.length}),(0,X.jsx)(C,{color:`warning`,children:M})]})}),(0,X.jsx)(L,{children:(0,X.jsx)(`div`,{className:`grid grid-cols-3 sm:grid-cols-6 gap-2`,children:A.map(e=>(0,X.jsx)(Ii,{card:e},e.id))})})]})]})}function ap({children:e,onClick:t,primary:n=!1,disabled:r=!1}){return(0,X.jsx)(`button`,{type:`button`,onClick:t,disabled:r,className:q(`rounded-2xl px-4 py-3 text-sm font-black transition outline-none focus-visible:ring-4 focus-visible:ring-slate-300/60 disabled:cursor-not-allowed disabled:opacity-40`,{"bg-slate-900 text-white shadow-lg hover:bg-slate-700":n,"border border-slate-200 bg-white text-slate-900 hover:border-slate-400 hover:bg-slate-50":!n}),children:e})}function op({onRegenerate:e,onReset:t,onPrint:n,onHide:r,hide:i=!1,hasSelections:a,selectedIds:o,board:s,enabledDirection:c=!1,onEnabledDirectionChange:l}){function u(){console.log(s.flat().filter(e=>o.has(e.id)).sort((e,t)=>e.row===t.row?e.column-t.column:e.row-t.row).map(e=>`[${e.row}, ${e.column}]`).join(`, `))}return(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,X.jsx)(ap,{primary:!0,onClick:e,children:`↻ لوحة جديدة`}),(0,X.jsx)(ap,{onClick:t,disabled:!a,children:`× مسح التحديد`}),(0,X.jsx)(ap,{onClick:n,children:`⎙ طباعة`}),(0,X.jsx)(ap,{onClick:u,children:`Print points`}),(0,X.jsx)(ap,{onClick:r,children:i?`Show`:`Hide`}),(0,X.jsx)(ap,{onClick:()=>l?.(!c),children:c?`Disable direction`:`Enable direction`})]})}function sp({selectedCount:e,completedLines:t,availablePatterns:n,completedPatterns:r,activePatternId:i,lettersNumbersOptionId:a,onPatternSelect:o,onLettersNumbersOptionChange:s}){let c=t>0,l=new Map(r.map(e=>[e.id,e])),u=r.reduce((e,t)=>e+t.score,0);return(0,X.jsxs)(`div`,{className:q(`rounded-2xl border p-4 transition`,{"border-emerald-300 bg-emerald-50 text-emerald-950":c,"border-slate-200 bg-slate-50 text-slate-900":!c}),role:`status`,"aria-live":`polite`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-sm font-black`,children:c?`🎉 BINGO!`:`حالة الجولة`}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-slate-500`,children:c?`Completed ${t} winning patterns`:`حدّد الأرقام عند ظهورها`})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl bg-white px-3 py-2 text-center shadow-sm`,children:[(0,X.jsx)(`span`,{className:`block text-xl font-black text-slate-900`,children:e}),(0,X.jsx)(`span`,{className:`text-[0.65rem] text-slate-500`,children:`محدّد`})]}),(0,X.jsxs)(`div`,{className:`rounded-xl bg-white px-3 py-2 text-center shadow-sm`,children:[(0,X.jsx)(`span`,{className:`block text-xl font-black text-slate-900`,children:u}),(0,X.jsx)(`span`,{className:`text-[0.65rem] text-slate-500`,children:`Score`})]})]})]}),(0,X.jsx)(`div`,{className:`mt-4 grid grid-cols-1 gap-2 sm:grid-cols-2`,children:n.map(e=>{let t=l.get(e.id),n=i===e.id,r=e.id===`letters-numbers`,c=t?.matchedOptionLabel??`Not detected`,u=n&&r?a??`__detected__`:`__detected__`;return(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:()=>o(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o(e.id))},className:q(`rounded-xl border px-3 py-2 transition cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-sky-400/50`,t?`border-emerald-300 bg-white text-emerald-800 shadow-sm`:`border-slate-200 bg-white/70 text-slate-500`,n&&`ring-2 ring-sky-400/70 ring-offset-1`),"aria-pressed":n,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-bold`,children:e.label}),(0,X.jsxs)(`div`,{className:`mt-1 text-[0.65rem] opacity-80`,children:[e.requiredMarks,` marks`]})]}),(0,X.jsxs)(`div`,{className:`text-right`,children:[(0,X.jsxs)(`div`,{className:`text-xs font-black`,children:[e.score,` pts`]}),(0,X.jsx)(`div`,{className:`mt-1 text-[0.65rem] opacity-80`,children:t?`Completed`:n?`Previewing`:`Pending`})]})]}),r&&(0,X.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,X.jsxs)(`div`,{className:`text-[0.65rem] opacity-80`,children:[`Detected shape: `,c]}),(0,X.jsxs)(`select`,{value:u,className:`w-full rounded-lg border border-slate-200 bg-white px-2 py-1.5 text-xs font-semibold text-slate-700 outline-none transition focus:border-sky-400`,onClick:e=>e.stopPropagation(),onChange:e=>{s(e.target.value===`__detected__`?null:e.target.value)},children:[(0,X.jsx)(`option`,{value:`__detected__`,children:`Use detected shape`}),e.options?.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.label,` (`,e.requiredMarks,` marks)`]},e.id))]})]})]},e.id)})})]})}
12function cp({value:e,onChange:t}){return(0,X.jsx)(`div`,{children:(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:vi.map(n=>{let r=e===n;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>t(n),className:q(`rounded-2xl border p-2.5 text-center text-xs font-bold transition outline-none hover:-translate-y-0.5 focus-visible:ring-4 focus-visible:ring-slate-300/60`,{"border-slate-900 bg-slate-900 text-white shadow-lg":r,"border-slate-200 bg-white text-slate-600 hover:border-slate-300":!r}),"aria-pressed":r,children:[(0,X.jsx)(`span`,{className:q(bi({theme:n}))}),n]},n)})})})}var lp=e({default:()=>dp}),up=[`top`,`right`,`bottom`,`left`];function dp(){let[e,t]=(0,Y.useState)(`violet`),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(()=>new Set),c=(0,Y.useMemo)(()=>yi(gi.length),[]),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(),[h,g]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{if(!l||!h){if(!l){m(void 0);return}return}let e=window.setInterval(()=>{m(e=>up[(up.indexOf(e??`top`)+1)%up.length])},1e3);return()=>{window.clearInterval(e)}},[l,h]);let _=(0,Y.useMemo)(()=>pi(n,o),[n,o]),v=(0,Y.useMemo)(()=>Si(_),[_]),y=(0,Y.useMemo)(()=>c.find(e=>e.id===l)??null,[l,c]),b=(0,Y.useMemo)(()=>{if(!y)return new Set;let e=_.find(e=>e.id===y.id);return e&&(y.id!==`letters-numbers`||!d||e.matchedOptionId===d)?new Set(e.cells.map(e=>e.id)):_i(n,y,y.id===`letters-numbers`?d:null,p)},[y,n,_,d,p]);async function x(e){s(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})}async function S(){r(fi()),s(new Set),u(null),f(null)}function C(){s(new Set),u(null),f(null)}function w(e){u(t=>t===e?null:e)}function T(e){f(e),u(`letters-numbers`)}return(0,X.jsx)(`div`,{className:`p-5`,children:(0,X.jsxs)(`div`,{className:`grid items-start gap-7 lg:grid-cols-[minmax(0,1fr)_340px] lg:gap-10`,children:[(0,X.jsx)(`div`,{className:`flex flex-col items-center gap-5`,children:(0,X.jsx)(xi,{theme:e,board:n,columns:gi,selectedIds:o,winningIds:v,previewIds:b,onToggle:x,hide:i})}),(0,X.jsxs)(`div`,{className:`no-print w-full max-w-[560px] space-y-5`,children:[(0,X.jsx)(op,{onRegenerate:S,onReset:C,onPrint:()=>window.print(),hasSelections:o.size>0,selectedIds:o,board:n,hide:i,onHide:()=>a(e=>!e),enabledDirection:h,onEnabledDirectionChange:e=>{m(void 0),g(e)}}),(0,X.jsx)(cp,{value:e,onChange:t}),(0,X.jsx)(sp,{selectedCount:o.size,completedLines:_.length,availablePatterns:c,completedPatterns:_,activePatternId:l,lettersNumbersOptionId:d,onPatternSelect:w,onLettersNumbersOptionChange:T})]})]})})}function fp(e,t){return{lazy:async()=>await e(),config:t}}var pp={menu:{order:0,exclude:!0},title:`Nard`},mp={...pp,loginRequired:!0},hp={menu:{order:0,exclude:!0},title:`Memory`},gp={...hp,loginRequired:!0},_p={menu:{order:0,exclude:!0},title:`Guess Who?`},vp={..._p,loginRequired:!0},yp={menu:{order:0,exclude:!0},title:`Spyfall`},bp={...yp,loginRequired:!0},xp={menu:{order:0,exclude:!0},title:`Bingo`},Sp={...xp,loginRequired:!0},Cp={title:`Qr Code`}
12,wp=ei.filter(e=>e.external).map(e=>Z(e.link,{config:{menu:{order:0,exclude:!0},title:e.title},default:()=>(0,X.jsx)(ti,{gameId:e.id})})),Tp=[Z(``,Aa,[Z(``,Ka),Z(`games`,Ra),Z(`pricing`,xc),Z(`plans`,xc),Z(`privacy`,gf),Z(`terms`,yf),Z(`terms.php`,yf),Z(`status`,Tf),Z(`account`,wo),Z(`payment`,[Z(`success`,[Z(``,wc),Z(`:id`,wc)]),Z(`cancel`,[Z(``,Dc),Z(`:id`,Dc)]),Z(`error`,[Z(``,Ac),Z(`:id`,Ac)])]),Z(`guess-who`,Sf),Z(`/q`,Nc),Z(`q/categories`,pf),Z(`/d`,Io),Z(`/w`,ic),Z(`/j`,Vs),Z(`/n`,fp(()=>o(()=>import(`./@index-B4u4R3iw.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),pp)),Z(`/m`,fp(()=>o(()=>import(`./@index-B21-r5oT.js`),__vite__mapDeps([10,1,2,3,4,5,6,7,8,9])),hp)),Z(`/s`,fp(()=>o(()=>import(`./@index-B0bAt4sM.js`),__vite__mapDeps([11,1,2,3,4,5,6,7,8,9])),yp)),Z(`/b`,fp(()=>o(()=>import(`./@index-DGHUHSE7.js`),__vite__mapDeps([12,1,2,3,4,5,6,7,8,9])),xp)),...wp,Z(`/n/cards`,np),Z(`qr-code`,fp(()=>o(()=>import(`./@index-C2iiBtHZ.js`),__vite__mapDeps([13,2,1,3,4,5,6,14])),Cp)),Z(`*`,Ar)]),Z(`tickets`,Mf,[Z(``,Gf),Z(`:id`,$f)]),Z(`b`,Pa,[Z(`play`,fp(()=>o(()=>import(`./BingoPlay-CzQiik0f.js`),__vite__mapDeps([15,2,1,3,4,5,6,8,9,16,17,18,14])),Sp)),Z(`demo`,lp),Z(`:id`,fp(()=>o(()=>import(`./_id_-DlwyZS_r.js`),__vite__mapDeps([19,2,1,5,3,4,6,8,20,16,17,21,22])),xp))]),Z(`guess-who`,Pa,[Z(`play`,fp(()=>o(()=>import(`./play-jh-Hp_m2.js`),__vite__mapDeps([23,2,1,3,4,5,6,8,9,18,16,17,14])),vp)),Z(`:id`,fp(()=>o(()=>import(`./_id_-FR7yixvS.js`),__vite__mapDeps([24,2,1,5,3,4,6,8,20,16,17,25,26])),_p))]),Z(`m`,Pa,[Z(`play`,fp(()=>o(()=>import(`./play-DstXqw20.js`),__vite__mapDeps([27,1,2,3,4,5,6,18,8,9,16,17,14])),gp)),Z(`:id`,fp(()=>o(()=>import(`./_id_-DnN9gvGH.js`),__vite__mapDeps([28,2,1,5,3,4,6,8,20,16,17,22,26,29])),hp))]),Z(`d`,Pa,[Z(`play`,Bo),Z(`:id`,Fs)]),Z(`q`,Pa,[Z(`play`,Yc
12),Z(`:id`,[Z(``,of),Z(`preview`,lf)])]),Z(`w`,Pa,[Z(`play`,tc),Z(`:id`,_c)]),Z(`n`,Pa,[Z(`play`,fp(()=>o(()=>import(`./play-DnaCkO_n.js`),__vite__mapDeps([30,2,1,3,4,5,6,16,8,17,18,9,14])),mp)),Z(`:id`,fp(()=>o(()=>import(`./_id_-18cHhfaU.js`),__vite__mapDeps([31,2,1,5,3,4,6,20,8,16,17,22,25,26,32])),pp))]),Z(`j`,Pa,[Z(`play`,Rs),Z(`:id`,Qs)]),Z(`s`,Pa,[Z(`play`,fp(()=>o(()=>import(`./play-CsWnHFJW.js`),__vite__mapDeps([33,2,1,3,4,5,6,8,9,16,17,18,14])),bp)),Z(`:id`,fp(()=>o(()=>import(`./_id_-BKV8C5Lx.js`),__vite__mapDeps([34,2,1,5,3,4,6,8,20,16,17])),yp))]),Z(`login`,Pa,[Z(``,po)]),Z(`forgot-password`,Pa,[Z(``,Do)]),Z(`signup`,Pa,[Z(``,Mo)])],{router:Ep,routes:Dp}=new Zi().withFileRoutes(Tp).protect().build(),Op=typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(display-mode: standalone)`).matches||typeof navigator<`u`&&!!navigator.standalone;if(D.pwa&&Op&&typeof window<`u`){let e=window.location.pathname.split(`/`).filter(Boolean)[0]??``;new Set([``,`games`,`pricing`,`plans`,`privacy`,`terms`,`status`,`account`,`payment`,`q`,`guess-who`,`m`,`d`,`w`,`n`,`j`,`s`,`b`,`login`,`forgot-password`,`signup`]).has(e)||window.location.replace(`/`)}function kp(){return(0,X.jsx)(ft,{children:(0,X.jsx)(f,{router:Ep})})}D.pwa&&o(async()=>{let{registerSW:e}=await import(`./virtual_pwa-register-Bwd3fRWr.js`);return{registerSW:e}},[]).then(({registerSW:e})=>{let t=!1,n=e({immediate:!0,onRegistered(e){if(!e)return;if(e.addEventListener(`updatefound`,()=>{let t=e.installing;t&&t.addEventListener(`statechange`,()=>{t.state===`installed`&&navigator.serviceWorker.controller&&n(!0)})}),!t&&`serviceWorker`in navigator){t=!0;let e=!1;navigator.serviceWorker.addEventListener(`controllerchange`,()=>{e||(e=!0,window.location.reload())})}let r=async()=>{try{await e.update()}catch{return}};r(),window.setInterval(r,6e5),window.addEventListener(`focus`,r),window.addEventListener(`online`,r),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&r()})},onNeedRefresh(){n(!0)}})}),(0,Ri.createRoot)(document.getElementById(`root`)).render((0,Y.createElement)(kp));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.