1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/js/QuizReportModal.Dipy04yX.js","assets/js/index.CskpvDEf.js","assets/js/ui-vendor.C-Hyu-r2.js","assets/js/react-vendor.DkNVG-am.js","assets/js/utils-vendor.Cwt67yDr.js","assets/js/redux-vendor.D6yGEbAP.js","assets/js/i18n-vendor.D76Wczy_.js","assets/js/SubmittedQuizInterface.boSIYlxy.js","assets/js/house.C8fWM0b1.js","assets/js/file-text.UOSZKSBo.js","assets/js/articleDifficulty.D7-50ywm.js","assets/js/StarIcon.CuUNe4IX.js","assets/js/award.DSN9HPHS.js","assets/js/user.BjsJmJMf.js","assets/js/quiz.utils.CsZ4Kp9J.js","assets/js/target.BvFB54Lb.js","assets/js/log-in.Bh3fWm4a.js","assets/js/charts-vendor.31-4Brea.js","assets/js/star.Dy5GBqrR.js","assets/js/eye.BBbEJco4.js","assets/js/App.Elvl86sq.js","assets/js/SocketContext.ClkKi9Gd.js","assets/js/socket-vendor.Ba10ZAmw.js","assets/js/gift.BL9S7D-_.js","assets/js/tournamentRewards.BLeiFXAY.js","assets/js/Categories.BR8c7hW3.js","assets/js/QuizGivenSummary.Bn4KoLNJ.js","assets/js/Loading.ewp_8f_8.js","assets/js/useSafeSound.DaYsVQEP.js","assets/js/tabs.X8Yz7_gJ.js","assets/js/index.D9IU3wDr.js","assets/js/index.IlqsbdIh.js","assets/js/shield.onzNGnDR.js","assets/js/activity.CbGtUMEw.js","assets/js/battery.CK-XOlbC.js","assets/js/timer.C6fck_dB.js","assets/js/badge.BtweE04F.js","assets/js/collapsible.DZIQm50z.js","assets/js/copy.C_F3ze9E.js","assets/js/lightbulb.BhUO-jQX.js","assets/js/StreakIncreasedPopup.DP0nvuaF.js","assets/js/quizAudioService.CV_x7kKi.js","assets/js/howler.CI4Vl_qx.js","assets/js/haptics.Bn5mb-Dv.js","assets/js/calendar.BuS6LG8I.js","assets/js/chevron-right.s5wnJeop.js","assets/js/user-plus.DpuCwEa8.js","assets/js/PostSessionRewardScreen.BOiYLlF4.js","assets/js/confetti.module.DEdVObze.js","assets/js/hammer.Dn4EhgQ4.js","assets/js/share-2.CekD9FAE.js","assets/js/TeamInvitePromptModal.b5oNw_fg.js","assets/js/link-2.Cf55b2OB.js","assets/js/search.CQTAWJhV.js"])))=>i.map(i=>d[i]); 2import{n as e,o as t,at as a,aY as i,aK as s,ai as r,cU as l,as as n,ar as o,b2 as c,R as d,a_ as m,a9 as p,au as h,F as u,aJ as x,bR as b,_ as f}from"./index.CskpvDEf.js";import{a as w,n as g,b as y,u as N,i as v}from"./react-vendor.DkNVG-am.js";import{l as k,k as S,j as C,a as j,o as I}from"./App.Elvl86sq.js";import{u as B}from"./useQuickClashTeamBattle.DkcwiOmK.js";import{A as T,a as A,b as P}from"./avatar.C8E_smiP.js";import{g as _}from"./categoryUtils.DDrNi_VJ.js";import{h as E}from"./haptics.Bn5mb-Dv.js";import{q as O}from"./quizAudioService.CV_x7kKi.js";import{B as M}from"./badge.BtweE04F.js";import{u as R,b as D}from"./redux-vendor.D6yGEbAP.js";import{a as L,h as q}from"./utils-vendor.Cwt67yDr.js";import{b as G,C as U}from"./ClaimRewardsModal.CFs_Im6T.js";import{m as z,A as $}from"./ui-vendor.C-Hyu-r2.js";import{G as Y}from"./gift.BL9S7D-_.js";import{P as F}from"./package.BF_Xw567.js";import{c as W,b as V}from"./user.BjsJmJMf.js";import{L as H}from"./loader-circle._EcacpEo.js";import{B as J}from"./bolt.atMrqpe8.js";import{S as Q}from"./shield.onzNGnDR.js";import{u as K}from"./i18n-vendor.D76Wczy_.js";import{T as X}from"./target.BvFB54Lb.js";import{C as Z}from"./calendar.BuS6LG8I.js";import{M as ee}from"./medal.sX7MpWNj.js";import{S as te}from"./star.Dy5GBqrR.js";import{G as ae}from"./gem.WTGYwioA.js";import{S as ie}from"./SlotInviteModal.BrHG1Ygh.js";import{I as se}from"./InviteUserModal.D7Rco4Kp.js";import{A as re}from"./arrow-left.DZ1CvgHW.js";import{L as le}from"./lock.Dl5OrVha.js";import{P as ne}from"./play.oofGZ7CE.js";import{F as oe}from"./file-text.UOSZKSBo.js";import{C as ce}from"./chevron-right.s5wnJeop.js";import{A as de}from"./award.DSN9HPHS.js";import{n as me,g as pe,f as he,h as ue,i as xe,d as be}from"./differenceInSeconds.D2J41lUk.js";import"./SocketContext.ClkKi9Gd.js";import"./socket-vendor.Ba10ZAmw.js";import"./quiz.utils.CsZ4Kp9J.js";import"./tournamentRewards.BLeiFXAY.js";import"./Categories.BR8c7hW3.js";import"./charts-vendor.31-4Brea.js";import"./index.D9IU3wDr.js";import"./utensils-crossed.Bafr2f4M.js";import"./sword.pdtj1F4I.js";import"./flask-conical.CTkiK0_J.js";import"./howler.CI4Vl_qx.js";import"./refresh-cw.B_7Or0SB.js";import"./hammer.Dn4EhgQ4.js";import"./eye.BBbEJco4.js";import"./check.BSVRhpMO.js";import"./lodash.CJLgYig_.js";import"./quickClashColors.CcLkX7oM.js";import"./dialog.Bi0FRuuy.js";import"./user-plus.DpuCwEa8.js";import"./search.CQTAWJhV.js";import"./plus.DmpdjbH5.js";function fe(e,t,a){const[i,s]=me(a?.in,e,t),r=(+i-+s)/he;return pe(a?.roundingMethod)(r)}function we(e,t,a){const i=ue(e,t)/xe;return pe(a?.roundingMethod)(i)}const ge=80,ye=({isOpen:l,onClose:n,battleId:o,teamId:c})=>{const{activeTutorial:d,stepIndex:m,goToStep:p}=k(),[h,u]=w.useState([]),[x,b]=w.useState(!1),[f,y]=w.useState(null),[N,v]=w.useState(null),C=R(),{currentBattle:j}=D(e=>e.quickClashTeamBattle),{user:I}=D(e=>e.auth),B=j?.teamA?._id===c||j?.teamA===c?j?.teamAPool:j?.teamBPool,T=B?.housingUsed||0,A=T/ge*100,P=B?.items?.filter(e=>e.donatedBy&&e.donatedBy===I?._id)?.reduce((e,t)=>
2e+t.cost,0)||0;w.useEffect(()=>{l&&(_(),v(null))},[l]);const _=async()=>{try{b(!0);const e=await L.get("/api/quickClash/powerups/inventory");e.data.success&&u(e.data.inventory)}catch(e){v({type:"error",text:"Failed to fetch inventory"})}finally{b(!1)}};return l?g.createPortal(e($,{children:l&&e(z.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/80 backdrop-blur-sm z-[100] flex items-center justify-center p-4",onClick:n,children:t(z.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},transition:{type:"spring",damping:25,stiffness:300},className:"bg-slate-900/95 backdrop-blur-xl rounded-2xl max-w-md w-full border border-white/10 max-h-[85vh] overflow-hidden",onClick:e=>e.stopPropagation(),children:[t("div",{className:"flex items-center justify-between p-5 border-b border-white/[0.06]",children:[t("div",{className:"flex items-center gap-3",children:[e(z.div,{animate:{rotate:[0,10,-10,0]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},className:"w-10 h-10 rounded-xl bg-gradient-to-br from-purple-500 to-indigo-500 flex items-center justify-center",children:e(Y,{className:"w-5 h-5 text-white"})}),t("div",{children:[e("h3",{className:"text-lg font-bold text-white",children:"Donate Powerups"}),e("p",{className:"text-xs text-white/40",children:"Share with your team"})]})]}),e(z.button,{onClick:()=>{O.playDismiss(),n()},whileHover:{scale:1.1},whileTap:{scale:.9},className:"w-8 h-8 rounded-lg bg-white/5 hover:bg-white/10 flex items-center justify-center transition-colors",children:e(a,{className:"w-4 h-4 text-white/60"})})]}),t("div",{className:"p-5 space-y-4 max-h-[calc(85vh-80px)] overflow-y-auto scrollbar-hide",children:[t("div",{className:"p-4 rounded-xl bg-white/[0.03] border border-white/[0.06]",children:[t("div",{className:"flex justify-between items-center mb-2",children:[t("div",{className:"flex items-center gap-2",children:[e(F,{className:"w-4 h-4 text-purple-400"}),e("span",{className:"font-semibold text-sm text-white",children:"Team Pool"})]}),t("span",{className:S("text-sm font-mono font-bold",T>=ge?"text-red-400":"text-emerald-400"),children:[T,"/",ge]})]}),e("div",{className:"h-2 bg-white/10 rounded-full overflow-hidden",children:e(z.div,{initial:{width:0},animate:{width:`${A}%`},transition:{duration:.5,ease:"easeOut"},className:S("h-full rounded-full",T>=ge?"bg-gradient-to-r from-red-500 to-red-400":"bg-gradient-to-r from-purple-500 to-indigo-400")})}),t("div",{className:"flex justify-between mt-2 text-xs",children:[t("span",{className:"text-white/40",children:[B?.items?.length||0," items"]}),t("span",{className:S("font-medium",P>=20?"text-red-400":"text-purple-300"),children:["Your: ",P,"/",20]})]})]}),e($,{children:N&&t(z.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:S("flex items-center gap-2 p-3 rounded-xl border text-sm font-medium","error"===N.type?"bg-red-500/10 border-red-500/30 text-red-300":"bg-emerald-500/10 border-emerald-500/30 text-emerald-300"),children:["error"===N.type?e(i,{className:"w-4 h-4"}):e(W,{className:"w-4 h-4"}),N.text]})}),t("div",{children:[t("div",{className:"flex items-center gap-2 mb-3",children:[e(s,{className:"w-4 h-4 text-purple-400"}),e("span",{className:"font-bold text-sm text-white",children:"Your Inventory"})]}),x?t("div",{className:"flex flex-col items-center justify-center py-10",children:[e(z.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:e(H,{className:"w-6 h-6 text-purple-400"})}),e("p",{className:"text-white/40 text-sm mt-2",children:"Loading..."})]}):0===h.length?t("div",{className:"p-6 rounded-xl bg-white/[0.02] border border-dashed border-white/10 text-center",children:[e(F,{className:"w-8 h-8 text-white/20 mx-auto mb-2"}),e("p",{className:"text-white/40 text-sm",children:"Inventory empty"})]}):e("div",{className:"space-y-2",children:h.map((a,i)=>t(z.div,{initial:{opacity:0,y:10},animate:"battle"===d&&1===m?{opacity:1,y:0,scale:[1,1.05,1]}:{opacity:1,y:0},transition:"battle"===d&&1===m?{delay:.05*i,scale:{duration:1,repeat:1/0,delay:.1*i,ease:"easeInOut"}}:{delay:.05*i},className:"relative",children:[e(G,{powerup:a,onClick:()=>(async e=>{if(v(null),T+e.cost>ge)v({type:"error",text:"Team Pool is full!"});else if(P+e.cost>20)v({type:"error",text:"Donation limit reached (Max 20)"});else try{y(e.powerupId),await L.post(`/api/quickClash/team-battle/${o}/powerup/donate`,{teamId:c,powerupId:e.powerupId}),v({type:"success",text:"Donation Successful! ð"}),O.playDonate(),C(r(o)),u(t=>t.map(t=>t.powerupId===e.powerupId?{...t,count:t.count-1}:t).filter(e=>e.count>0)),"battle"===d&&1===m&&setTimeout(()=>{n(),p(2)},800)}catch(t){v({type:"error",text:t.response?.data?.message||"Donation Failed"})}finally{y(null)}})(a),isDisabled:f||T+a.cost>ge||P+a.cost>20,className:"battle"===d&&1===m?"ring-2 ring-purple-400 ring-offset-2 ring-offset-slate-900 shadow-[0_0_20px_rgba(168,85,247,0.5)] z-10":""}),e(M,{className:"absolute -top-2 -right-2 w-6 h-6 flex items-center justify-center rounded-full bg-gradient-to-br from-purple-500 to-indigo-500 text-white text-xs font-bold border-2 border-slate-900",children:a.count}),f===a.powerupId&&e(z.div,{className:"absolute inset-0 bg-slate-900/60 backdrop-blur-sm rounded-2xl flex items-center justify-center",children:e(H,{className:"w-5 h-5 text-purple-400 animate-spin"})})]},a.powerupId))})]})]})]})})}),document.body):null},Ne=({isOpen:s,onClose:l,battleId:n,teamId:o})=>{const{activeTutorial:c,stepIndex:d,goToStep:m}=k(),[p,h]=w.useState(null),[u,x]=w.useState(null),b=R(),{currentBattle:f}=D(e=>e.quickClashTeamBattle),{user:y}=D(e=>e.auth),N=f?.teamA?._id===o||f?.teamA===o,v=N?f?.teamAPool:f?.teamBPool,C=N?f?.teamAMembers:f?.teamBMembers,j=C?.find(e=>e?.user?._id===y?._id||e.user===y?._id),I=j?.loadout||{items:[],housingUsed:0},B=I.housingUsed||0,T=B/30*100,A=I.items.reduce((e,t)=>
2(e[t.powerupId]||(e[t.powerupId]={...t,count:0}),e[t.powerupId].count++,e),{}),P=Object.values(A),_=v?.items?.reduce((e,t)=>(e[t.powerupId]||(e[t.powerupId]={...t,count:0}),e[t.powerupId].count++,e),{}),E=Object.values(_||{}),q=e=>!!["PRECISION_PROTOCOL","STREAK_SHIELD","SCORE_SURGE"].includes(e)&&I.items.some(t=>t.powerupId===e);return s?g.createPortal(e($,{children:s&&e(z.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/80 backdrop-blur-sm z-[100] flex items-center justify-center p-4",onClick:l,children:t(z.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},transition:{type:"spring",damping:25,stiffness:300},className:"bg-slate-900/95 backdrop-blur-xl rounded-2xl max-w-md w-full border border-white/10 max-h-[85vh] overflow-hidden",onClick:e=>e.stopPropagation(),children:[t("div",{className:"flex items-center justify-between p-5 border-b border-white/[0.06]",children:[t("div",{className:"flex items-center gap-3",children:[e(z.div,{animate:{scale:[1,1.1,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},className:"w-10 h-10 rounded-xl bg-gradient-to-br from-cyan-500 to-blue-500 flex items-center justify-center",children:e(J,{className:"w-5 h-5 text-white"})}),t("div",{children:[e("h3",{className:"text-lg font-bold text-white",children:"Select Loadout"}),e("p",{className:"text-xs text-white/40",children:"Equip powerups for battle"})]})]}),e(z.button,{onClick:()=>{O.playDismiss(),l()},whileHover:{scale:1.1},whileTap:{scale:.9},className:"w-8 h-8 rounded-lg bg-white/5 hover:bg-white/10 flex items-center justify-center transition-colors",children:e(a,{className:"w-4 h-4 text-white/60"})})]}),t("div",{className:"p-5 space-y-4 max-h-[calc(85vh-80px)] overflow-y-auto scrollbar-hide",children:[t("div",{className:"p-4 rounded-xl bg-gradient-to-br from-cyan-500/10 to-blue-500/10 border border-cyan-500/20",children:[t("div",{className:"flex justify-between items-center mb-3",children:[t("div",{className:"flex items-center gap-2",children:[e(Q,{className:"w-4 h-4 text-cyan-400"}),e("span",{className:"font-semibold text-sm text-white",children:"Your Loadout"})]}),t("span",{className:S("text-sm font-mono font-bold",B>=30?"text-red-400":"text-emerald-400"),children:[B,"/",30]})]}),t("div",{className:"flex items-center gap-4 mb-3",children:[t("div",{className:"relative w-14 h-14",children:[t("svg",{className:"w-full h-full transform -rotate-90",children:[e("circle",{cx:"28",cy:"28",r:"24",stroke:"currentColor",strokeWidth:"4",fill:"transparent",className:"text-white/10"}),e(z.circle,{cx:"28",cy:"28",r:"24",stroke:"url(#loadoutGrad)",strokeWidth:"4",fill:"transparent",strokeLinecap:"round",initial:{strokeDashoffset:151},animate:{strokeDashoffset:151-T/100*151},transition:{duration:.5},strokeDasharray:"151"}),e("defs",{children:t("linearGradient",{id:"loadoutGrad",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e("stop",{offset:"0%",stopColor:"#06B6D4"}),e("stop",{offset:"100%",stopColor:"#3B82F6"})]})})]}),e("div",{className:"absolute inset-0 flex items-center justify-center",children:t("span",{className:"text-xs font-bold text-cyan-400",children:[Math.round(T),"%"]})})]}),e("div",{className:"flex-1",children:e("p",{className:"text-white/50 text-sm",children:0===I.items.length?"No powerups equipped":"Tap to unequip"})})]}),I.items.length>0&&e("div",{className:"space-y-2",children:P.map((a,i)=>t(z.div,{className:"relative",children:[e(G,{powerup:a,onClick:()=>(async e=>{x(null);try{h(e.powerupId),await L.post(`/api/quickClash/team-battle/${n}/powerup/unequip`,{teamId:o,powerupType:e.powerupId}),x({type:"success",text:"Unequipped!"}),O.playUnequip(),b(r(n))}catch(t){x({type:"error",text:t.response?.data?.message||"Unequip Failed"})}finally{h(null)}})(a),isDisabled:p,isSelected:!0,showPhase:!0}),a.count>1&&e(M,{className:"absolute -top-2 -right-2 w-6 h-6 flex items-center justify-center rounded-full bg-gradient-to-br from-blue-500 to-cyan-500 text-white text-xs font-bold border-2 border-slate-900 z-10",children:a.count}),p===a.powerupId&&e("div",{className:"absolute inset-0 bg-slate-900/60 backdrop-blur-sm rounded-2xl flex items-center justify-center",children:e(H,{className:"w-5 h-5 text-cyan-400 animate-spin"})})]},`${a.powerupId}-${i}`))})]}),e($,{children:u&&t(z.div,{initial:{opacity:0,y:-10}
2,animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:S("flex items-center gap-2 p-3 rounded-xl border text-sm font-medium","error"===u.type?"bg-red-500/10 border-red-500/30 text-red-300":"bg-emerald-500/10 border-emerald-500/30 text-emerald-300"),children:["error"===u.type?e(i,{className:"w-4 h-4"}):e(W,{className:"w-4 h-4"}),u.text]})}),t("div",{children:[t("div",{className:"flex items-center justify-between mb-3",children:[t("div",{className:"flex items-center gap-2",children:[e(F,{className:"w-4 h-4 text-blue-400"}),e("span",{className:"font-bold text-sm text-white",children:"Team Pool"})]}),t(M,{className:"text-xs px-2 py-0.5 bg-blue-500/10 text-blue-300 border-blue-500/30",children:[E.length," available"]})]}),0===E.length?t("div",{className:"p-6 rounded-xl bg-white/[0.02] border border-dashed border-white/10 text-center",children:[e(F,{className:"w-8 h-8 text-white/20 mx-auto mb-2"}),e("p",{className:"text-white/40 text-sm",children:"Pool empty - Donate first!"})]}):e("div",{className:"space-y-2",children:E.map((a,i)=>t(z.div,{initial:{opacity:0,y:10},animate:"battle"===c&&3===d?{opacity:1,y:0,scale:[1,1.05,1]}:{opacity:1,y:0},transition:"battle"===c&&3===d?{delay:.05*i,scale:{duration:1,repeat:1/0,delay:.1*i,ease:"easeInOut"}}:{delay:.05*i},className:"relative",children:[e(G,{powerup:a,onClick:()=>(async e=>{if(x(null),B+e.cost>30)x({type:"error",text:"Loadout Full (Max 30)"});else try{h(e.powerupId),await L.post(`/api/quickClash/team-battle/${n}/powerup/equip`,{teamId:o,powerupType:e.powerupId}),x({type:"success",text:"Equipped! â¡"}),O.playEquip(),O.playEquip(),b(r(n)),"battle"===c&&3===d&&setTimeout(()=>{l(),m(4)},800)}catch(t){x({type:"error",text:t.response?.data?.message||"Equip Failed"})}finally{h(null)}})(a),isDisabled:p||B+a.cost>30||q(a.powerupId),showPhase:!0,showType:!0,className:"battle"===c&&3===d?"ring-2 ring-blue-400 ring-offset-2 ring-offset-slate-900 shadow-[0_0_20px_rgba(56,189,248,0.5)] z-10":""}),q(a.powerupId)&&e("div",{className:"absolute inset-0 bg-slate-900/60 backdrop-blur-[2px] rounded-2xl flex items-center justify-center",children:e("span",{className:"text-xs font-semibold text-emerald-400 bg-emerald-500/20 px-3 py-1.5 rounded-full border border-emerald-500/30",children:"â Already Equipped"})}),e(M,{className:"absolute -top-2 -right-2 w-6 h-6 flex items-center justify-center rounded-full bg-gradient-to-br from-blue-500 to-cyan-500 text-white text-xs font-bold border-2 border-slate-900",children:a.count}),p===a.powerupId&&e("div",{className:"absolute inset-0 bg-slate-900/60 backdrop-blur-sm rounded-2xl flex items-center justify-center",children:e(H,{className:"w-5 h-5 text-cyan-400 animate-spin"})})]},a.powerupId))})]})]})]})})}),document.body):null},ve=({userId:i,isOpen:s,onClose:r})=>{const{t:p}
2=K("QuickClash"),h=R(),u=D(e=>e.quickClashProfile.profiles[i]),x=D(e=>e.quickClashProfile.profileLoading[i]),b=D(e=>e.quickClashProfile.profileError[i]);w.useEffect(()=>{s&&i&&!u&&h(l({userId:i}))},[s,i,u,h]);const f=e=>e<=1?"#FFD700":e<=3?"#E5E7EB":e<=10?"#CD7F32":e<=50?"#A855F7":e<=100?"#3B82F6":e<=500?"#10B981":"#6B7280";return s?g.createPortal(e($,{children:s&&e(z.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/80 backdrop-blur-sm z-[100] flex items-center justify-center p-4",onClick:r,children:t(z.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},transition:{type:"spring",damping:25,stiffness:300},className:"bg-slate-900/95 backdrop-blur-xl rounded-2xl max-w-sm w-full border border-white/10 overflow-hidden",onClick:e=>e.stopPropagation(),children:[t("div",{className:"flex items-center justify-between p-5 border-b border-white/[0.06]",children:[t("div",{className:"flex items-center gap-3",children:[e("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-cyan-500 to-pink-500 flex items-center justify-center",children:e(n,{className:"w-5 h-5 text-white"})}),e("h3",{className:"text-lg font-bold text-white",children:x?p("Loading..."):u?u.user.inGameName||u.user.name:p("Profile")})]}),e(z.button,{onClick:r,whileHover:{scale:1.1},whileTap:{scale:.9},className:"w-8 h-8 rounded-lg bg-white/5 hover:bg-white/10 flex items-center justify-center transition-colors",children:e(a,{className:"w-4 h-4 text-white/60"})})]}),e("div",{className:"p-5 max-h-[70vh] overflow-y-auto scrollbar-hide",children:e($,{mode:"wait",children:x?t(z.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"flex flex-col items-center justify-center py-12",children:[e(z.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:e(H,{className:"w-8 h-8 text-cyan-400"})}),e("p",{className:"text-white/40 text-sm mt-3",children:p("Fetching stats...")})]},"loading"):b?t(z.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex flex-col items-center justify-center py-8",children:[e("div",{className:"w-14 h-14 rounded-2xl bg-red-500/10 border border-red-500/30 flex items-center justify-center mb-3",children:e(X,{className:"w-7 h-7 text-red-400"})}),e("p",{className:"text-red-300 font-medium",children:p("Failed to load profile")}),e("p",{className:"text-xs text-white/40 mt-1",children:b})]},"error"):u?t(z.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0},className:"space-y-4",children:[t("div",{className:"flex items-center gap-4",children:[t("div",{className:"relative",children:[e("div",{className:"absolute -inset-1 rounded-full bg-gradient-to-br from-cyan-500 to-pink-500 opacity-50 blur-sm"}),t(T,{className:"relative w-16 h-16 border-2 border-slate-900",children:[e(A,{src:u.user.picture}),e(P,{className:"bg-slate-800 text-white/70 text-lg font-bold",children:(u.user.name||"U")[0].toUpperCase()})]}),t("div",{className:"absolute -bottom-1 -right-1 px-1.5 py-0.5 rounded-full bg-gradient-to-r from-purple-500 to-pink-500 text-white text-[9px] font-bold border border-slate-900",children:["Lv",u.user.level||0]})]}),t("div",{className:"flex-1 space-y-1.5",children:[t("div",{className:"flex items-center gap-1.5 text-xs text-white/40",children:[e(Z,{className:"w-3 h-3"}),t("span",{children:[p("Joined")," ",q(u.user.joinedAt).format("MMM YYYY")]})]}),t("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg border",style:{borderColor:`${f(u.trophies.rank)}40`,backgroundColor:`${f(u.trophies.rank)}15`},children:[y.createElement((N=u.trophies.rank,1===N?m:N<=3?o:N<=10?ee:N<=50?te:N<=100?ae:X),{size:12,color:f(u.trophies.rank)}),t("span",{className:"text-xs font-bold",style:{color:f(u.trophies.rank)},children:["#",u.trophies.rank," Global"]})]})]})]}),t("div",{className:"grid grid-cols-2 gap-2",children:[t("div",{className:"p-3 rounded-xl bg-white/[0.03] border border-white/[0.06]",children:[t("div",{className:"flex items-center gap-1.5 mb-1",children:[e(
2o,{className:"w-3.5 h-3.5 text-amber-400"}),e("span",{className:"text-[10px] font-semibold text-white/50",children:p("Trophies")})]}),e("p",{className:"text-xl font-bold text-white",children:u.trophies?.current?.toLocaleString()||0}),t("div",{className:"text-[10px] text-white/30 flex items-center gap-1 mt-0.5",children:[e(c,{className:"w-2.5 h-2.5"}),"Peak: ",u.trophies?.peak?.toLocaleString()||0]})]}),t("div",{className:"p-3 rounded-xl bg-white/[0.03] border border-white/[0.06]",children:[t("div",{className:"flex items-center gap-1.5 mb-1",children:[e(X,{className:"w-3.5 h-3.5 text-emerald-400"}),e("span",{className:"text-[10px] font-semibold text-white/50",children:p("Win Rate")})]}),t("p",{className:"text-xl font-bold text-white",children:[u.statistics?.overall?.winRate||0,"%"]}),t("p",{className:"text-[10px] text-white/30",children:[u.statistics?.overall?.totalMatches||0," battles"]})]})]}),t("div",{children:[t("div",{className:"flex items-center gap-2 mb-2",children:[e(d,{className:"w-3.5 h-3.5 text-cyan-400"}),e("span",{className:"text-xs font-bold text-white",children:p("Battle Performance")})]}),t("div",{className:"grid grid-cols-2 gap-2",children:[t("div",{className:"p-2.5 rounded-xl bg-cyan-500/5 border border-cyan-500/10",children:[t("div",{className:"flex items-center gap-1 mb-1.5",children:[e("div",{className:"w-1.5 h-1.5 rounded-full bg-cyan-400"}),e("span",{className:"text-[10px] font-semibold text-cyan-400",children:p("Avg Score")})]}),t("div",{className:"flex justify-between items-end",children:[t("div",{children:[e("p",{className:"text-lg font-bold text-white",children:u.statistics?.teamBattle?.avgScoreLast10||0}),e("p",{className:"text-[9px] text-white/30",children:p("Points")})]}),t("div",{className:"text-right",children:[e("p",{className:"text-sm font-semibold text-white/70",children:u.statistics?.teamBattle?.matchesForAvg||0}),e("p",{className:"text-[9px] text-white/30",children:p("Last Matches")})]})]})]}),t("div",{className:"p-2.5 rounded-xl bg-pink-500/5 border border-pink-500/10",children:[t("div",{className:"flex items-center gap-1 mb-1.5",children:[e("div",{className:"w-1.5 h-1.5 rounded-full bg-pink-400"}),e("span",{className:"text-[10px] font-semibold text-pink-400",children:"Team Battles"})]}),t("div",{className:"flex justify-between items-end",children:[t("div",{children:[t("p",{className:"text-lg font-bold text-white",children:[u.statistics?.teamBattle?.winRate||0,"%"]}),e("p",{className:"text-[9px] text-white/30",children:"Win Rate"})]}),t("div",{className:"text-right",children:[e("p",{className:"text-sm font-semibold text-white/70",children:u.statistics?.teamBattle?.totalMatches||0}),e("p",{className:"text-[9px] text-white/30",children:"Matches"})]})]})]})]})]})]},"profile"):null})})]})})}),document.body):null;var N},ke="qc_team_invite_popup",Se=()=>{try{const e=localStorage.getItem(ke);return e?JSON.parse(e):{}}catch(e){return{}}},Ce=e=>{try{localStorage.setItem(ke,JSON.stringify(e))}catch(t){}},je=(e,t)=>{if(t)return{show:!1,team:null};const a=e?.find(e=>(e?.members?.length||0)<4);if(!a)return{show:!1,team:null};const i=Se(),s=i.lastShown?new Date(i.lastShown):null,r=new Date;if(s){if((r-s)/864e5<3)return{show:!1,team:null}}const l=(()=>{const e=Se().dismissCount||0;return 0===e?.6:1===e?.4:2===e?.25:.15})();return Math.random()>l?{show:!1,team:null}:{show:!0,team:a}},Ie=()=>{const e=Se();Ce({...e,dismissCount:0,lastInviteClicked:(new Date).toISOString()})},Be=y.lazy(()=>f(()=>import("./QuizReportModal.Dipy04yX.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39]))),Te=y.lazy(()=>f(()=>import("./StreakIncreasedPopup.DP0nvuaF.js"),__vite__mapDeps([40,1,2,3,4,5,6,41,42,43,44,45,46]))),Ae=y.lazy(()=>f(()=>import("./PostSessionRewardScreen.BOiYLlF4.js"),__vite__mapDeps([47,1,2,3,4,5,6,48,41,42,43,49,13,18,45,50]))),Pe=y.lazy(()=>f(()=>import("./TeamInvitePromptModal.b5oNw_fg.js"),__vite__mapDeps([51,1,2,3,4,5,6,43,41,42,52,53]))),_e=({children:a,className:i="",accent:s=null})=>t("div",{className:`relative backdrop-blur-2xl bg-white/[0.04] border border-white/[0.1] rounded-2xl overflow-hidden ${i}`,children:[s&&e("div",{className:`absolute inset-0 bg-gradient-to-br ${s} opacity-10 pointer-events-none`}),e("div",{className:"relative",children:a})]}),Ee=({battle:a,onGoBack:i,t:s,onExpiredChange:r})=>{const[l,n]=w.useState(null);w.useEffect(()=>{if(!a?.expiresAt)return;const e=()=>{const e=new Date,t=new Date(a.expiresAt),i=be(t,e);n(i<=0?{expired:!0}:{h:fe(t,e),m:we(t,e)%60,s:i%60,sec:i})};e();const t=setInterval(e,1e3);return()=>clearInterval(t)},[a?.expiresAt]),w.useEffect(()=>{r&&r(l?.expired&&"active"===a.status)},[l?.expired,a.status,r]);const o=l?.sec<300,c=l?.sec<1800,d=l?.expired&&"active"===a.status;return t("div",{className:"px-5 pt-5 pb-2",children:[t("div",{className:"flex items-center justify-between",children:[t(z.button,{onClick:()=>{O.playButtonClick(),i()},whileTap:{scale:.95},className:"flex items-center gap-1.5 text-white/50 hover:text-white transition-colors text-sm px-2 py-1 -ml-2 roun
2ded-lg hover:bg-white/5",children:[e(re,{className:"w-4 h-4"}),e("span",{className:"hidden sm:inline",children:s("Back")})]}),l&&!l.expired&&t(z.div,{className:"flex items-center gap-2 px-3 py-1.5 rounded-full border "+(o?"bg-red-500/20 border-red-500/30":c?"bg-amber-500/20 border-amber-500/30":"bg-cyan-500/10 border-cyan-500/20"),animate:o?{scale:[1,1.02,1]}:{},transition:{duration:.5,repeat:1/0},children:[e(V,{className:"w-3.5 h-3.5 "+(o?"text-red-400":c?"text-amber-400":"text-cyan-400")}),t("span",{className:"text-sm font-mono font-semibold "+(o?"text-red-400":c?"text-amber-400":"text-cyan-400"),children:[l.h>0&&`${l.h}:`,String(l.m).padStart(2,"0"),":",String(l.s).padStart(2,"0")]})]}),d&&t(z.div,{className:"flex items-center gap-2 px-3 py-1.5 rounded-full bg-purple-500/20 border border-purple-500/30",animate:{opacity:[1,.7,1]},transition:{duration:1,repeat:1/0},children:[e(z.div,{className:"w-3 h-3 border-2 border-purple-400 border-t-transparent rounded-full",animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"}}),e("span",{className:"text-sm font-semibold text-purple-400",children:s("Calculating...")})]}),"active"!==a.status||d?"completed"===a.status?e("div",{className:"px-2.5 py-1 rounded-full bg-white/10 text-white/50 text-xs font-medium",children:"Ended"}):null:t("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-emerald-500/20 border border-emerald-500/30",children:[e(z.div,{className:"w-2 h-2 rounded-full bg-emerald-400",animate:{opacity:[1,.4,1]},transition:{duration:1.5,repeat:1/0}}),e("span",{className:"text-xs font-semibold text-emerald-400",children:"LIVE"})]})]}),e("div",{className:"text-center mt-4 mb-2",children:e("h1",{className:"text-xl font-bold text-white",children:"âï¸ Team Battle"})})]})},Oe=({left:a,right:i,leftName:s,rightName:r,isUserLeft:l})=>e("div",{className:"px-5 py-4",children:t(_e,{className:"p-5",accent:"from-cyan-500 via-purple-500 to-pink-500",children:[t("div",{className:"flex items-center justify-center gap-4 sm:gap-8",children:[t("div",{className:"flex-1 text-right",children:[e(z.div,{className:"text-5xl sm:text-6xl font-bold "+(l?"text-cyan-400":"text-white/60"),initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},transition:{type:"spring",stiffness:200},children:a}),t("p",{className:"text-xs mt-1 truncate "+(l?"text-cyan-400/60":"text-white/30"),children:[l&&"ð¤ ",s]})]}),e(z.div,{className:"relative",animate:{rotate:[0,5,-5,0]},transition:{duration:4,repeat:1/0,ease:"easeInOut"},children:e("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-purple-500/30 to-pink-500/30 border border-white/20 flex items-center justify-center",children:e("span",{className:"text-white/80 font-bold text-sm",children:"VS"})})}),t("div",{className:"flex-1 text-left",children:[e(z.div,{className:"text-5xl sm:text-6xl font-bold "+(l?"text-white/60":"text-pink-400"),initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},transition:{type:"spring",stiffness:200,delay:.1},children:i}),t("p",{className:"text-xs mt-1 truncate "+(l?"text-white/30":"text-pink-400/60"),children:[!l&&"ð¤ ",r]})]})]}),t("div",{className:"flex justify-center gap-6 mt-4 text-xs",children:[t("span",{className:"text-cyan-400/80",children:["â ",l?"Your pts":"Opp pts"]}),t("span",{className:"text-pink-400/80",children:["â ",l?"Opp pts":"Your pts"]})]})]})}),Me=({members:a,userId:i,isUserTeam:s,teamScore:r,onMemberClick:l,t:n})=>e("div",{className:"px-5 mb-3",children:t(_e,{className:"p-4",accent:s?"from-cyan-500 to-blue-500":"from-pink-500 to-red-500",children:[t("div",{className:"flex items-center justify-between mb-3",children:[t("div",{className:"flex items-center gap-2",children:[e("div",{className:"w-2 h-2 rounded-full "+(s?"bg-cyan-400":"bg-pink-400")}),e("span",{className:"text-sm font-semibold "+(s?"text-cyan-400":"text-pink-400"),children:s?"ð Your Team":"âï¸ Opponents"})]}),t("div",{className:"flex items-center gap-2",children:[e(te,{className:"w-3.5 h-3.5 "+(s?"text-cyan-400":"text-pink-400")}),e("span",{className:"text-sm font-bold "+(s?"text-cyan-400":"text-pink-400"),children:r||0})]})]}),e("div",{className:"flex gap-3 overflow-x-auto pb-1 scrollbar-hide",children:a.map((a,s)=>{const r=(e=>e?.user?{id:e.user._id,name:e.user.name,inGameName:e.user.inGameName,pic:e.user.pic}:e?.sessionPlayer?{id:e.sessionPlayer._id,name:e.sessionPlayer.inGameName,inGameName:e.sessionPlayer.inGameName,pic:null}:{id:null,name:"Player",inGameName:"Player",pic:null})(a),n=r.id===i;return t(z.div,{initial:{opacity:0,y:10}
2,animate:{opacity:1,y:0},transition:{delay:.05*s},whileHover:{scale:1.08,y:-2},whileTap:{scale:.95},onClick:()=>{O.playButtonClick(),l(r.id)},className:"flex-shrink-0 cursor-pointer",children:[t("div",{className:"relative p-0.5 rounded-xl "+(n?"bg-gradient-to-br from-cyan-400 to-blue-500":a.completed?"bg-gradient-to-br from-emerald-400 to-green-500":a.participated?"bg-gradient-to-br from-amber-400 to-orange-500":"bg-white/20"),children:[t(T,{className:"w-12 h-12 border-2 border-slate-900",children:[e(A,{src:r.pic}),e(P,{className:"bg-slate-800 text-white/70 text-sm font-bold",children:(r.inGameName||r.name||"U")[0]})]}),a.completed&&e(z.div,{className:"absolute -bottom-1 -right-1 w-5 h-5 bg-emerald-500 rounded-full flex items-center justify-center border-2 border-slate-900",initial:{scale:0},animate:{scale:1},transition:{type:"spring"},children:e(W,{className:"w-3 h-3 text-white"})}),a.participated&&!a.completed&&e(z.div,{className:"absolute -bottom-1 -right-1 w-5 h-5 bg-amber-500 rounded-full flex items-center justify-center border-2 border-slate-900",animate:{scale:[1,1.1,1]},transition:{duration:1,repeat:1/0},children:e(x,{className:"w-3 h-3 text-white"})})]}),e("p",{className:"text-[10px] text-white/40 text-center mt-1.5 w-12 truncate",children:n?"ð¤ You":r.inGameName||r.name?.split(" ")[0]||"Player"}),a.score>0&&t("p",{className:"text-[10px] text-emerald-400 text-center font-semibold",children:["+",a.score]})]},r.id||s)})}),t("div",{className:"mt-3",children:[e("div",{className:"flex justify-between text-xs text-white/30 mb-1",children:t("span",{children:[a.filter(e=>e?.completed).length,"/",a.length," finished"]})}),e("div",{className:"h-1.5 bg-white/10 rounded-full overflow-hidden",children:e(z.div,{className:"h-full "+(s?"bg-gradient-to-r from-cyan-500 to-blue-500":"bg-gradient-to-r from-pink-500 to-red-500"),initial:{width:0},animate:{width:a.filter(e=>e.completed).length/a.length*100+"%"},transition:{duration:.5,ease:"easeOut"}})})]})]})}),Re=({challenge:i,onSelect:s,onDeselect:r,onBegin:l,onReport:o,loading:c,t:d})=>{const m=_(i.category),p=i.isCompleted?"done":i.isSelectedButNotStarted?"selected":i.isCompletedByTeammate||i.isSelectedByTeammate?"teammate":i.isLocked?"locked":i.isAvailable?"available":"locked";return t(z.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},whileHover:"available"===p?{scale:1.02,y:-2}:{},whileTap:"available"===p?{scale:.98}:{},onClick:()=>{"available"!==p||i.isDisabled||i.isLoading||(O.playEquip(),s(i.category))},className:"relative overflow-hidden rounded-xl transition-all cursor-pointer "+("locked"===p?"opacity-40":""),style:{background:"done"===p?`linear-gradient(135deg, ${m.primaryColor}15, ${m.secondaryColor}15)`:"selected"===p?`linear-gradient(135deg, ${m.primaryColor}25, ${m.secondaryColor}25)`:"rgba(255,255,255,0.04)"},children:[e("div",{className:"absolute inset-0 rounded-xl border-2 "+("selected"===p?"border-cyan-400/50":"done"===p?"border-emerald-400/30":"teammate"===p?"border-purple-400/30":"border-white/[0.08]")}),i.isLoading&&t(z.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 z-20 flex flex-col items-center justify-center bg-slate-900/60 backdrop-blur-sm rounded-xl overflow-hidden",children:[e(z.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent shadow-sm",animate:{x:["-100%","100%"]},transition:{duration:1,repeat:1/0,ease:"linear"}}),e(z.div,{animate:{scale:[1,1.15,1],opacity:[.8,1,.8]},transition:{duration:1,repeat:1/0},className:"relative z-10",children:e("div",{className:"bg-cyan-500/20 p-3 rounded-full ring-1 ring-cyan-500/30",children:e(X,{className:"w-5 h-5 text-cyan-300"})})})]}),e("div",{className:"relative p-3.5",children:t("div",{className:"flex items-center gap-3",children:[e(z.div,{className:"w-11 h-11 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:`linear-gradient(135deg, ${m.primaryColor}, ${m.secondaryColor})`},whileHover:{rotate:[0,-5,5,0]},transition:{duration:.3},children:y.createElement(m.iconComponent,{className:"w-5 h-5 text-white"})}),t("div",{className:"flex-1 min-w-0",children:[e("p",{className:"text-sm font-semibold text-white capitalize truncate",children:i.category}),i.teammateInfo?.name&&t("p",{className:"text-xs text-purple-400 truncate flex items-center gap-1",children:[e(n,{className:"w-3 h-3"}),i.teammateInfo.inGameName||i.teammateInfo.name]}),(i.isCompleted||i.isCompletedByTeammate)&&t("div",{className:"flex items-center gap-2 mt-0.5",children:[e("span",{className:"text-xs font-bold text-emerald-400",children:i.userScore??"?"}),e("span",{className:"text-xs text-white/30",children:"vs"}),i.opponentCompleted?t(u,{children:[e("span",{className:"text-xs font-bold text-red-400",children:i.opponentScore??"?"}),i.userScore>i.opponentScore&&e("span",{className:"text-xs",children:"ð"})]}):e("span",{className:"text-xs text-amber-400/70 italic",children:"â³ Waiting..."})]})]}),t("div",{className:"flex-shrink-0",onClick:e=>e.stopPropagation(),children:["done"===p&&e(z.button,{onClick:()=>{O.playButtonClick(),o(i.challenge?._id||i.challenge)},disabled:c,whileTap:{scale:.9},className:"p-2.5 rounded-xl bg-emerald-500/20 hover:bg-emerald-500/30 transition-colors",children:e(oe,{className:"w-4 h-4 text-emerald-400"})}),"selected"===p&&t("div",{className:"flex items-center gap-2",children:[e(z.button,{onClick:()=>{O.playDismiss(),r()},whileTap:{scale:.9},className:"p-2 rounded-lg hover:bg-white/10",children:e(a,{className:"w-4 h-4 text-white/40"})}),t(z.button,{onClick:()=>{O.playGoButton(),l()},whileTap:{scale:.95},className:"px-4 py-2 rounded-xl bg-gradient-to-r from-emerald-500 to-green-500 hover:from-emerald-400 hover:to-green-400 text-white text-sm font-bold flex items-center gap-1.5 shadow-lg shadow-emerald-500/25",children:[e(ne,{className:"w-4 h-4"})," GO!"]})]}),"available"===p&&e(ce,{className:"w-5 h-5 text-white/30"}),"teammate"===p&&e("div",{className:"px-2 py-1 rounded-lg bg-purple-500/20",children:e("span",{className:"text-xs text-purple-400",children:"Ally"})}),"locked"===p&&e(le,{className:"w-4 h-4 text-white/20"})]})]})})]})},De=({battle:a,userTeam:i,powerupReward:s,onClaimRewards:r,onViewReport:l,navigate:n,user:d,t:p,isSession:h=!1})=>{const[u,x]=w.useState("overview"),b=a.winner===i,f="tie"===a.winner,g="teamA"===i?a.teamAWins:a.teamBWins,N="teamA"===i?a.teamBWins:a.teamAWins,v="teamA"===i?a.teamATotalScore:a.teamBTotalScore,k="teamA"===i?a.teamBTotalScore:a.teamATotalScore,S=s&&s.housingSpaceEarned>0&&!s.claimed,C="teamA"===i?a.teamAMembers:a.teamBMembers,j="teamA"===i?a.teamBMembers:a.teamAMembers,I=C.find(e=>e?.user?._id===d?._id)||C[0],B=I?.trophyChange??0,E=I?.score||0,M=[...C].sort((e,t)=>(t.score||0)-(e.score||0)).findIndex(e=>e?.user?._id===I?.user?._id)+1,R=a.challenges.find(e=>("teamA"===i?e.teamAPlayer:e.teamBPlayer)===I?.user?._id);C.filter(e=>e.completed).length;const D=I?.betAmount||0,L=I?.betResult,q=I?.betTrophyChange||0,G=a.trophyExchange?.bonuses||{},U=Object.entries(G).filter(([e,t])=>t?.applied&&t?.amount>0).map(([e,t])=>({key:e,amount:Math.round(t.amount/4)})),F=B-(D||0),V=D>0&&"won"===L?q-D:0;a.trophyUpdates,a.teamAMembers.some(e=>(e.user?._id||e.user)===d?._id);const H=!b&&!f&&0===F&&v<k,J=F-V;return e("div",{className:"px-5 mb-4",children:t(_e,{className:"overflow-hidden",accent:b?"from-amber-500 via-yellow-500 to-orange-500":f?"from-purple-500 to-pink-500":"from-slate-500 to-slate-600",children:[e("div",{className:"flex border-b border-white/10",children:[{id:"overview",label:"ð Overview",icon:o},{id:"categories",label:"ð Categories",icon:X},{id:"report",label:"ð Report",icon:oe}].map(a=>t(z.button,{onClick:()=>{O.playButtonClick(),x(a.id)},className:"flex-1 py-3 px-2 text-xs sm:text-sm font-medium transition-all relative "+(u===a.id?"text-white":"text-white/40 hover:text-white/60"),whileTap:{scale:.98},children:[a.label,u===a.id&&e(z.div,{layoutId:"activeTabIndicator",className:"absolute bottom-0 left-0 right-0 h-0.5 bg-gradient-to-r from-cyan-400 to-purple-400"})]},a.id))}),t($,{mode:"wait",children:["overview"===u&&t(z.div,{initial:{opacity:0,x:-20}
2,animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.2},className:"p-4",children:[t("div",{className:"flex items-center justify-center gap-2 mb-4",children:[e(z.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",damping:15},className:"p-2 rounded-xl "+(b?"bg-amber-500/20":f?"bg-purple-500/20":"bg-slate-500/20"),children:b?e(m,{className:"w-6 h-6 text-amber-400"}):f?e(de,{className:"w-6 h-6 text-purple-400"}):e(X,{className:"w-6 h-6 text-white/40"})}),e("h2",{className:"text-xl font-bold "+(b?"text-amber-400":f?"text-purple-400":"text-white/50"),children:b?"Victory!":f?"Draw!":"Defeat"}),t("div",{className:"ml-2 px-3 py-1 rounded-full flex items-center gap-1.5 text-sm font-bold "+(B-(D||0)>=0?"bg-emerald-500/15 text-emerald-400 border border-emerald-500/20":"bg-red-500/15 text-red-400 border border-red-500/20"),children:[e(o,{className:"w-3.5 h-3.5"}),B-(D||0)>=0?"+":"",B-(D||0)]})]}),t(z.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1},className:"flex items-center justify-center gap-4 mb-4 py-3 px-4 rounded-xl bg-white/5 border border-white/5",children:[t("div",{className:"flex items-center gap-2",children:[e("div",{className:"w-2 h-2 rounded-full bg-cyan-400"}),e("span",{className:"text-xs text-white/50",children:"You"}),e("span",{className:"text-2xl font-bold text-cyan-400",children:g})]}),e("div",{className:"flex flex-col items-center",children:e("span",{className:"text-xs text-white/30 font-medium",children:"VS"})}),t("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-2xl font-bold text-pink-400",children:N}),e("span",{className:"text-xs text-white/50",children:"Opp"}),e("div",{className:"w-2 h-2 rounded-full bg-pink-400"})]}),e("div",{className:"h-6 w-px bg-white/10"}),t("div",{className:"text-center",children:[t("div",{className:"flex items-baseline gap-1",children:[e("span",{className:"text-lg font-semibold text-cyan-400",children:v}),e("span",{className:"text-white/20",children:"-"}),e("span",{className:"text-lg font-semibold text-pink-400",children:k})]}),e("span",{className:"text-[10px] text-white/40",children:"points"})]})]}),D>0&&e(z.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.15},className:"mb-4 overflow-hidden rounded-xl border "+("won"===L?"bg-emerald-500/10 border-emerald-500/20":"lost"===L?"bg-red-500/10 border-red-500/20":"bg-white/5 border-white/10"),children:t("div",{className:"flex items-center justify-between px-4 py-3",children:[t("div",{className:"flex items-center gap-3",children:[e("div",{className:"p-2 rounded-lg "+("won"===L?"bg-emerald-500/20":"lost"===L?"bg-red-500/20":"bg-white/10"),children:e(X,{className:"w-4 h-4 "+("won"===L?"text-emerald-400":"lost"===L?"text-red-400":"text-white/60")})}),t("div",{children:[e("p",{className:"text-sm font-bold "+("won"===L?"text-emerald-400":"lost"===L?"text-red-400":"text-white/60"),children:"won"===L?"Bet Won!":"lost"===L?"Bet Lost":"Bet Returned"}),t("p",{className:"text-[10px] text-white/40",children:["Result from your ",D," trophy wager"]})]})]}),e("div",{className:"text-lg font-bold "+(q>0?"text-emerald-400":q<0?"text-red-400":"text-white/60"),children:"won"===L?"+"+(q-D):q>0?"+"+q:q}),e("div",{className:"text-[9px] text-white/30 text-right mt-0.5 font-medium tracking-wide uppercase",children:"(Included in Total)"})]})}),t(z.div,{initial:{opacity:0}
2,animate:{opacity:1},transition:{delay:.2},className:"mb-4 text-xs",children:[t("div",{className:"flex justify-between items-center px-4 py-2 bg-white/5 rounded-t-lg",children:[e("span",{className:"text-white/60 font-medium",children:"Net Trophy Change"}),t("span",{className:"font-bold "+(B-(D||0)>=0?"text-emerald-400":"text-red-400"),children:[B-(D||0)>=0?"+":"",B-(D||0)," Net"]})]}),t("div",{className:"px-4 py-3 bg-white/[0.02] rounded-b-lg space-y-2 border border-white/5 border-t-0",children:[t("div",{className:"flex justify-between "+(J>=0?"text-white/40":"text-red-400/60"),children:[e("span",{children:J>=0?"Base Team Reward":"Base Team Loss"}),t("span",{children:[J>0?"+":"",J]})]}),J>=0&&U.map(a=>t("div",{className:"flex justify-between text-purple-400/80",children:[e("span",{children:"strongerTeam"===a.key?"Stronger Team Bonus":"allWins"===a.key?"Perfect Sweep Bonus":"Performance Bonus"}),t("span",{children:["+",a.amount]})]},a.key)),D>0&&"won"===L&&t("div",{className:"flex justify-between text-emerald-400/80",children:[e("span",{children:"Bet Profit"}),t("span",{children:["+",q-D]})]}),D>0&&"lost"===L&&t("div",{className:"flex justify-between text-red-400/80",children:[e("span",{children:"Bet Loss (Stake)"}),t("span",{children:["-",D]})]}),e("div",{className:"border-t border-white/5 my-1"}),t("div",{className:"flex justify-between text-white/60 text-[10px] pt-1 font-medium",children:[e("span",{children:"Total Net Change"}),t("span",{children:[B-(D||0)>0?"+":"",B-(D||0)]})]}),H&&t("div",{className:"flex justify-between items-center text-cyan-400/80 bg-cyan-950/30 p-1.5 rounded-lg border border-cyan-500/20 mt-2",children:[t("div",{className:"flex items-center gap-1.5",children:[e(Shield,{className:"w-3.5 h-3.5 fill-cyan-400/20"}),e("span",{children:"Streak Protection"})]}),e("span",{className:"font-bold text-[10px] bg-cyan-500/20 px-1.5 py-0.5 rounded border border-cyan-500/30",children:"SAVED"})]})]})]}),t("div",{className:"space-y-2",children:[h&&t(z.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.2},className:"w-full py-3 px-4 rounded-xl bg-white/5 border border-white/10 flex items-center justify-center gap-2 text-sm text-white/50",children:[e(le,{className:"w-4 h-4"}),e("span",{children:"Create an account to earn powerup rewards"})]}),!h&&S&&t(z.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.2},onClick:()=>{O.playButtonClick(),r()},whileHover:{scale:1.01},whileTap:{scale:.99},className:"w-full py-3 rounded-xl font-semibold text-white bg-gradient-to-r from-yellow-500 to-orange-500 shadow-md shadow-orange-500/20 flex items-center justify-center gap-2 text-sm",children:[e(Y,{className:"w-4 h-4"}),"Claim ",s.housingSpaceEarned," Housing Space"]}),!h&&s?.claimed&&t(z.div,{initial:{opacity:0}
2,animate:{opacity:1},className:"flex items-center justify-center gap-2 py-2 text-emerald-400 text-sm",children:[e(W,{className:"w-4 h-4"}),e("span",{children:"Rewards Claimed"})]}),t(z.button,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},onClick:()=>{O.playButtonClick(),n(`/battle-analysis/${a._id}`)},className:"w-full py-2.5 rounded-xl text-sm text-white/60 hover:text-white bg-white/5 hover:bg-white/10 border border-white/10 transition-all flex items-center justify-center gap-2",children:[e(oe,{className:"w-4 h-4"}),"View Details",e(ce,{className:"w-4 h-4"})]})]})]},"overview"),"categories"===u&&t(z.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.2},className:"p-4",children:[e("div",{className:"mb-3 text-center",children:t("p",{className:"text-xs text-white/50",children:[a.challenges.length," Categories ⢠",g," Won ⢠",N," Lost"]})}),e("div",{className:"space-y-2 max-h-64 overflow-y-auto scrollbar-hide",children:a.challenges.map((a,s)=>{const r=_(a.category),l="teamA"===i?a.teamAScore:a.teamBScore,n="teamA"===i?a.teamBScore:a.teamAScore,o=a.winner===i,c="tie"===a.winner,d=("teamA"===i?a.teamAPlayer:a.teamBPlayer)===I?.user?._id,m=C.find(e=>e?.user?._id===("teamA"===i?a.teamAPlayer:a.teamBPlayer)),p=j.find(e=>e?.user?._id===("teamA"===i?a.teamBPlayer:a.teamAPlayer));return t(z.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.05*s},className:"p-3 rounded-xl border "+(d?"bg-purple-500/10 border-purple-500/30":"bg-white/[0.02] border-white/[0.06]"),children:[t("div",{className:"flex items-center justify-between mb-2",children:[t("div",{className:"flex items-center gap-2",children:[e("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:`linear-gradient(135deg, ${r.primaryColor}, ${r.secondaryColor})`},children:y.createElement(r.iconComponent,{className:"w-4 h-4 text-white"})}),t("div",{children:[e("span",{className:"text-sm font-medium text-white capitalize",children:a.category}),d&&e("span",{className:"text-[10px] text-purple-400 ml-2",children:"Your Category"})]})]}),e("div",{className:"px-2 py-0.5 rounded-full text-xs font-bold "+(o?"bg-emerald-500/20 text-emerald-400":c?"bg-amber-500/20 text-amber-400":"bg-red-500/20 text-red-400"),children:o?"Won":c?"Tie":"Lost"})]}),t("div",{className:"flex items-center justify-between",children:[t("div",{className:"flex items-center gap-2",children:[m&&t(T,{className:"w-5 h-5 border border-cyan-500/50",children:[e(A,{src:m?.user?.pic}),e(P,{className:"text-[8px] bg-cyan-900",children:(m?.user?.name||"U")[0]})]}),e("span",{className:"text-sm font-bold text-cyan-400",children:l})]}),e("span",{className:"text-xs text-white/30",children:"vs"}),t("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-sm font-bold text-pink-400",children:n}),p&&t(T,{className:"w-5 h-5 border border-pink-500/50",children:[e(A,{src:p?.user?.pic}),e(P,{className:"text-[8px] bg-pink-900",children:(p?.user?.name||"U")[0]})]})]})]})]},a._id||s)})})]},"categories"),"report"===u&&t(z.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.2},className:"p-4",children:[e("div",{className:"text-center mb-4",children:t("div",{className:"flex items-center justify-center gap-2 mb-1",children:[t(T,{className:"w-10 h-10 border-2 border-cyan-500/50",children:[e(A,{src:I?.user?.pic}),e(P,{className:"bg-cyan-900 text-white",children:(I?.user?.name||"U")[0]})]}),t("div",{className:"text-left",children:[e("p",{className:"text-sm font-semibold text-white",children:I?.user?.inGameName||I?.user?.name||"You"}),e("p",{className:"text-xs text-white/40",children:"Personal Stats"})]})]})}),t("div",{className:"grid grid-cols-2 gap-3",children:[t("div",{className:"p-3 rounded-xl bg-white/[0.03] border border-white/[0.06]",children:[t("div",{className:"flex items-center gap-2 mb-1",children:[e(te,{className:"w-4 h-4 text-amber-400"}),e("span",{className:"text-xs text-white/50",children:"Your Score"})]}),e("span",{className:"text-xl font-bold text-amber-400",children:E})]}),t("div",{className:"p-3 rounded-xl bg-white/[0.03] border border-white/[0.06]",children:[t("div",{className:"flex items-center gap-2 mb-1",children:[e(c,{className:"w-4 h-4 text-cyan-400"}),e("span",{className:"text-xs text-white/50",children:"Team Rank"})]}),t("div",{className:"flex items-baseline gap-1",children:[t("span",{className:"text-xl font-bold text-cyan-400",children:["#",M]}),t("span",{className:"text-xs text-white/30",children:["of ",C.length]})]})]}),e("div",{className:"col-span-2 p-3 rounded-xl bg-white/[0.03] border border-white/[0.06]",children:t("div",{className:"flex items-center justify-between",children:[t("div",{className:"flex items-center gap-2",children:[e(X,{className:"w-4 h-4 text-purple-400"}),e("span",{className:"text-xs text-white/50",children:"Your Category"})]}),R?t("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-sm font-medium text-purple-400 capitalize",children:R.category}),e("span",{className:"text-xs px-1.5 py-0.5 rounded "+(R.winner===i?"bg-emerald-500/20 text-emerald-400":"tie"===R.winner?"bg-amber-500/20 text-amber-400":"bg-red-500/20 text-red-400"),children:R.winner===i?"Won":"tie"===R.winner?"Tie":"Lost"})]}):e("span",{className:"text-sm text-white/30",children:"â"})]})})]}),R?.challenge?._id&&t(z.button,{initial:{opacity:0}
2,animate:{opacity:1},transition:{delay:.4},onClick:()=>{O.playButtonClick(),l(R.challenge._id)},className:"mt-4 w-full py-2.5 rounded-xl text-sm text-purple-400 hover:text-purple-300 border border-purple-500/30 hover:border-purple-500/50 transition-all flex items-center justify-center gap-2",children:[e(oe,{className:"w-4 h-4"}),"View Quiz Report"]})]},"report")]})]})})},Le=y.memo(()=>{const{t:a}=K(),{t:r}=K("teamBattle"),l=N(),{battleId:n}=v(),{activeTutorial:o,stepIndex:c,nextStep:d,goToStep:m,completeTutorial:f}=k(),g=y.useRef(null),S=y.useRef(null),{currentBattle:T,battleDetailsLoading:A,battleDetailsError:P,categoryOperationLoading:_,categoryOperationError:M,selectedCategoryForOperation:R,getBattleDetails:D,selectCategory:q,deselectCategory:G,beginChallenge:F,resetOperationState:W,setupTeamBattleSocketListeners:V,cleanupSocketListeners:Q,clearOperationError:Z}=B(),{player:ee,playerId:te,isSession:ae}=C(),oe=w.useCallback(e=>{if(!e||!te)return!1;if(e.sessionPlayer){const t=e.sessionPlayer;return!(!t.sessionId||t.sessionId!==te)||!(!t._id||String(t._id)!==String(te))}if(e.user){const t=e.user._id||e.user;return String(t)===String(te)}return!1},[te]),ce=w.useMemo(()=>T&&te?T.teamAMembers.some(e=>oe(e))?"teamA":T.teamBMembers.some(e=>oe(e))?"teamB":null:null,[T,te,oe]),de=w.useMemo(()=>{if(!T||!ce||!te)return{};const e=("teamA"===ce?T.teamAMembers:T.teamBMembers).find(e=>oe(e));return e?{participated:e.participated||e.completed,completed:e.completed,exited:e.participated&&!e.completed,selected:!!e.category,category:e.category}:{}},[T,ce,te,oe]);w.useEffect(()=>{if("battle"===o){const e=(t=0)=>{if(ae||0!==c&&2!==c){if(ae&&0===c)if(g.current){const e=g.current.getBoundingClientRect(),t=window.pageYOffset||document.documentElement.scrollTop,a=.15*window.innerHeight,i=t+e.top-a;window.scrollTo({top:Math.max(0,i),behavior:"smooth"})}else t<5&&setTimeout(()=>e(t+1),100);else if(!ae&&4===c)if(g.current){const e=g.current.getBoundingClientRect(),t=window.pageYOffset||document.documentElement.scrollTop,a=.15*window.innerHeight,i=t+e.top-a;window.scrollTo({top:Math.max(0,i),behavior:"smooth"})}else t<5&&setTimeout(()=>e(t+1),100)}else if(S.current){const e=S.current.getBoundingClientRect(),t=window.pageYOffset||document.documentElement.scrollTop,a=window.innerHeight/2-e.height/2,i=t+e.top-a;window.scrollTo({top:Math.max(0,i),behavior:"smooth"})}else t<5&&setTimeout(()=>e(t+1),100)};setTimeout(()=>e(),50)}},[o,c,ae]),w.useEffect(()=>{if("battle"===o){if("completed"===T?.status||"cancelled"===T?.status)return void f("battle");if(de?.participated||de?.completed||de?.exited)return void f("battle");de?.selected&&(!ae&&c<=4?m(5):ae&&0===c&&m(1))}},[o,c,de,T,m,f,ae]),y.useRef(0);const me=ee,{getSocket:pe}=j(),[he,ue]=w.useState(null),[xe,be]=w.useState(!1),[fe,we]=w.useState(!1),[ge,ke]=w.useState(!1),[Le,qe]=w.useState(!1),[Ge,Ue]=w.useState(!1),[ze,$e]=w.useState(null),[Ye,Fe]=w.useState(!1),[We,Ve]=w.useState(!1),[He,Je]=w.useState(!1),[Qe,Ke]=w.useState(!1),[Xe,Ze]=w.useState(null),[et,tt]=w.useState(!1),[at,it]=w.useState(null),[st,rt]=w.useState(!1),[lt,nt]=w.useState(null),[ot,ct]=w.useState(!1),[dt,mt]=w.useState(!1),[pt,ht]=w.useState([]),[ut,xt]=w.useState(null);w.useEffect(()=>{M&&Z()},[T?._id,M,Z]),w.useEffect(()=>{T&&!ae&&(async()=>{if(!ae)try{const e=await fetch("/api/quickClash/teams",{credentials:"include"});if(e.ok){const t=await e.json();ht(t.teams||[])}}catch(e){}})()},[T?._id,ae]),w.useCallback(e=>e?e.sessionPlayer?._id?e.sessionPlayer._id:e.user?._id?e.user._id:"string"==typeof e.sessionPlayer?e.sessionPlayer:"string"==typeof e.user?e.user:null:null,[]);const bt=w.useMemo(()=>{if(!T)return null;const e={members:T.teamAMembers,wins:T.teamAWins,name:T.teamA?.name,score:T.teamATotalScore},t={members:T.teamBMembers,wins:T.teamBWins,name:T.teamB?.name,score:T.teamBTotalScore};return"teamB"===ce?{user:t,opp:e,userIsLeft:!0}:{user:e,opp:t,userIsLeft:!0}},[T,ce]),ft=w.useMemo(()=>{if(!T)return{done:0,total:0};const e=T.challenges.length;return{done:T.challenges.filter(e=>e.teamACompleted&&e.teamBCompleted).length,total:e}},[T]),wt=w.useMemo(()=>
2{if(!T||!ce||!te)return null;const e=("teamA"===ce?T.teamAMembers:T.teamBMembers).find(e=>oe(e));return e?.powerupReward||null},[T,ce,te,oe]),gt=w.useMemo(()=>{if(!T||!ce)return null;const e="teamA"===ce?T.teamA:T.teamB,t="teamA"===ce?T.teamAMembers:T.teamBMembers;return e?{...e,members:t}:null},[T,ce]),yt=w.useMemo(()=>T&&ce&&te?T.challenges.map(e=>{const t="teamA"===ce?"teamAPlayer":"teamBPlayer",a="teamA"===ce?"teamACompleted":"teamBCompleted",i="teamA"===ce?T.teamAMembers:T.teamBMembers,s=i.find(e=>oe(e)),r=null!==e[t],l=s?.challenge&&(String(s.challenge)===String(e.challenge)||String(s.challenge)===String(e.challenge?._id)),n=s?.category===e.category,o=l&&(s?.completed||e[a]),c=i.find(t=>!oe(t)&&t.category===e.category),d=!!c&&!r,m=!!i.find(t=>!oe(t)&&t.category===e.category&&t.completed)&&!l&&!o,p=!(n||d||r||de.participated||de.exited||de.selected||m),h=de.selected&&e.category!==de.category||de.exited,u=_&&(R===e.category||n)||ut===e.category,x=_||null!==ut;return{...e,isAvailable:p,isCompleted:o,isSelectedButNotStarted:n&&!r&&!(l&&s?.participated),isSelectedByTeammate:d,isCompletedByTeammate:m,isLocked:h,isLoading:u,isDisabled:x,userScore:"teamA"===ce?e.teamAScore:e.teamBScore,opponentScore:"teamA"===ce?e.teamBScore:e.teamAScore,opponentCompleted:"teamA"===ce?e.teamBCompleted:e.teamACompleted,teammateInfo:c?{name:c?.user?.name||c?.sessionPlayer?.inGameName,inGameName:c?.user?.inGameName||c?.sessionPlayer?.inGameName}:null}}):[],[T,ce,me,_,R,de,ut,te,oe]);w.useEffect(()=>{const e=pe();e&&e.emit("quickClash:viewTeamBattles")},[pe]),w.useEffect(()=>{n&&D(n)},[n,D]),w.useEffect(()=>Q,[V,Q]),w.useEffect(()=>()=>W(),[W]),w.useEffect(()=>{"completed"===T?.status&&localStorage.removeItem("sparkActiveBattleId")},[T?.status]),w.useEffect(()=>{const e=localStorage.getItem("pendingRewardScreen"),t=localStorage.getItem("pendingStreakPopup");if(e)try{const i=JSON.parse(e);if(it(i),localStorage.removeItem("pendingRewardScreen"),t)try{const e=JSON.parse(t);Ze(e)}catch(a){localStorage.removeItem("pendingStreakPopup")}setTimeout(()=>{tt(!0)},800)}catch(a){localStorage.removeItem("pendingRewardScreen")}else if(t)try{const e=JSON.parse(t);Ze(e),setTimeout(()=>{Ke(!0)},800),localStorage.removeItem("pendingStreakPopup")}catch(a){localStorage.removeItem("pendingStreakPopup")}},[]),w.useEffect(()=>{if(!T?.expiresAt||"completed"===T?.status)return void("completed"===T?.status&&We&&Ve(!1));const e=new Date(T.expiresAt).getTime(),t=Date.now();if(e<=t)return void(We||Ve(!0));const a=setTimeout(()=>{Ve(!0)},e-t);return()=>clearTimeout(a)},[T?.expiresAt,T?.status,We]),w.useEffect(()=>{if(!We||"completed"===T?.status||!n)return;let e=!1;const t=[1e4,15e3,2e4],a=async i=>{if(!(e||i>=3||(await new Promise(e=>setTimeout(e,t[i])),e))){try{await D(n)}catch(s){}e||a(i+1)}};return a(0),()=>{e=!0}},[We,T?.status,n,D,ae]);const Nt=w.useCallback(()=>{E.light(),l("/quickclash")},[l]),vt=w.useCallback(async e=>{if(T&&!ut){E.selection(),O.playSubmit(),xt(e);try{"battle"===o&&0===c&&d(),await q(T._id,e)}catch(t){xt(null)}xt(null)}},[T,q,ut,o,c,d]),kt=w.useCallback(async()=>{if(T&&!ut&&de.category){O.playUnequip(),xt(de.category);try{await G(T._id)}catch(e){xt(null)}xt(null)}},[T,G,ut,de.category]),St=w.useCallback(()=>{E.impact(),O.playQuizStart(),T&&F(T._id)},[T,F]),Ct=w.useCallback(async e=>{if(e){be(!0);try{const t="undefined"!=typeof window?localStorage.getItem("playSessionId"):null,a=t?{headers:{"X-Session-Id":t}}:void 0,i=await L.get(`/api/quickClash/challenge/${e}/sessions`,a),s=i.data?.sessionId;if(!s)return void p.error("Report unavailable","Could not find a completed session report for this category.");ue(s),we(!0)}catch(t){p.error("Failed to load report",t.response?.data?.message||"Unable to open report right now.")}finally{be(!1)}}},[]);if(A&&!T)return e("div",{className:"min-h-screen flex items-center justify-center",children:t("div",{className:"text-center",children:[e(z.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},children:e(H,{className:"w-10 h-10 text-cyan-400 mx-auto"})}),t("p",{className:"text-white/40 text-sm mt-3",children:["âï¸ ",a("Entering arena...")]})]})});if((P||!T)&&!A)return e("div",{className:"min-h-screen flex items-center justify-center p-6",children:t("div",{className:"text-center",children:[e("div",{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-red-500/20 flex items-center justify-center",children:e(i,{className:"w-8 h-8 text-red-400"})}),e("p",{className:"text-white/50 mb-4",children:P||a("Battle not found")}),t(I,{onClick:()=>{O.playButtonClick(),Nt()},className:"bg-gradient-to-r from-cyan-500 to-blue-500 text-white",children:[e(re,{className:"w-4 h-4 mr-2"}),a("Back")]})]})});const jt="teamA"===ce?T.teamA?._id:T.teamB?._id,It=bt?.user?.members?.find(e=>e?.user?._id===me?._id)?.loadout||{housingUsed:0};return t("div",{className:"min-h-screen relative "+("battle"===o?"pb-96":"pb-24 md:pb-8"),children:[e($,{children:We&&e(z.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 bg-slate-950/90 backdrop-blur-md flex items-center justify-center",children:t("div",{className:"text-center",children:[e(z.div,{className:"w-20 h-20 mx-auto mb-6 rounded-2xl bg-gradient-to-br from-purple-500/30 to-pink-500/30 border border-purple-500/30 flex items-center justify-center",animate:{scale:[1,1.05,1],rotate:[0,5,-5,0]},transition:{duration:2,repeat:1/0},children:e(z.div,{className:"w-10 h-10 border-4 border-purple-400 border-t-transparent rounded-full",animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"}})}),t("h2",{className:"text-xl font-bold text-white mb-2",children:["ð¯ ",a("Calculating Results...")]}),e("p",{className:"text-sm text-white/50",children:a("Please wait while we tally the scores")})]})})}),e(Ee,{battle:T,onGoBack:Nt,t:a,onExpiredChange:Ve}),e(Oe,{left:bt?.user?.wins||0,right:bt?.opp?.wins||0,leftName:bt?.user?.name||"Your Team",rightName:bt?.opp?.name||"Opponents",isUserLeft:!0}),e(Me,{members:bt?.user?.members||[],userId:me?._id,isUserTeam:!0,teamScore:bt?.user?.score,onMemberClick:e=>{$e(e),Fe(!0)},t:a}),e(Me,{members:bt?.opp?.members||[],userId:me?._id,isUserTeam:!1,teamScore:bt?.opp?.score,onMemberClick:e=>{$e(e),Fe(!0)},t:a}),"active"===T.status&&ce&&e("div",{ref:S,className:"px-5 mb-4",children:e(_e,{className:"p-3",accent:"from-purple-500 to-indigo-500",children:t("div",{className:"flex items-center justify-between",children:[t("div",{className:"flex items-center gap-2",children:[e("div",{className:"w-8 h-8 rounded-lg bg-purple-500/30 flex items-center justify-center",children:e(h,{className:"w-4 h-4 text-purple-400"})}),t("div",{children:[e("span",{className:"text-sm font-semibold text-white",children:a("Powerups")}),!de.participated&&!ae&&t("span",{className:"text-xs text-white/40 ml-2",children:[It.housingUsed,"/30"]})]})]}),e("div",{className:"flex gap-2",children:ae?t(z.button,{whileTap:{scale:.9},onClick:()=>{O.playButtonClick(),p.info("Create Account to Use Powerups","Powerups are available for registered users. Create an account to equip and use powerups in battles!")},className:"px-3 py-2 rounded-xl text-white/70 text-sm font-semibold flex items-center gap-1.5 bg-gray-500/30 border border-white/10",children:[e(le,{className:"w-4 h-4"}),e("span",{children:"Login to Use"})]}):t(u,{children:[t(z.button,{whileTap:{scale:.9},animate:"battle"===o&&0===c?{scale:[1,1.15,1]}:{},transition:"battle"===o&&0===c?{duration:1,repeat:1/0}:{},onClick:()=>{O.playButtonClick(),ke(!0),"battle"===o&&0===c&&m(1)},className:"p-2.5 rounded-xl transition-colors relative "+("battle"===o&&0===c?"bg-purple-500/40 ring-2 ring-purple-400 ring-offset-2 ring-offset-slate-900":"bg-white/10 hover:bg-white/15"),children:[e(Y,{className:"w-4 h-4 "+("battle"===o&&0===c?"text-purple-200":"text-purple-300")}),"battle"===o&&0===c&&e("span",{className:"absolute inset-0 rounded-xl animate-ping bg-purple-400/30"})]}),t(z.button,{whileTap:de.participated?{}:{scale:.9},animate:"battle"===o&&2===c?{scale:[1,1.05,1]}:{},transition:"battle"===o&&2===c?{duration:1,repeat:1/0}:{},onClick:()=>{O.playButtonClick(),de.participated?p.info("Already Participated","You have already played in this battle. Powerups cannot be changed."):(qe(!0),"battle"===o&&2===c&&m(3))},className:"px-3 py-2 rounded-xl text-white text-sm font-semibold flex items-center gap-1.5 relative transition-all "+(de.participated?"bg-gray-500/50 cursor-not-allowed opacity-60":"battle"===o&&2===c?"bg-purple-500 ring-2 ring-purple-400 ring-offset-2 ring-offset-slate-900 shadow-[0_0_15px_rgba(168,85,247,0.5)]":"bg-purple-500 hover:bg-purple-400"),children:[e(J,{className:"w-4 h-4 "+("battle"===o&&2===c?"animate-pulse":"")})," Equip","battle"===o&&2===c&&e("span",{className:"absolute inset-0 rounded-xl bg-white/20 animate-pulse"})]})]})})]})})}),"active"===T.status&&ce&&t("div",{className:"px-5 mb-4",children:[t("div",{className:"flex items-center justify-between mb-3",children:[t("div",{className:"flex items-center gap-2",children:[e(X,{className:"w-4 h-4 text-cyan-400"}),e("span",{className:"text-sm font-semibold text-white",children:a("Pick a Category")})]}),t("div",{className:"flex items-center gap-1 px-2 py-1 rounded-lg bg-white/10",children:[e("span",{className:"text-xs font-bold text-emerald-400",children:ft.done}),e("span",{className:"text-xs text-white/30",children:"/"}),e("span",{className:"text-xs text-white/50",children:ft.total})]})]}),e("div",{ref:g,className:"space-y-2",children:yt.map((t,i)=>e(Re,{challenge:t,onSelect:vt,onDeselect:kt,onBegin:()=>Ue(!0),onReport:Ct,loading:xe,t:a},`${t.category}-${i}`))}),de.selected&&!de.participated&&e(z.div,{initial:{opacity:0,y:10}
2,animate:{opacity:1,y:0},className:"mt-3 p-3 rounded-xl bg-gradient-to-r from-cyan-500/20 to-blue-500/20 border border-cyan-500/30",children:t("p",{className:"text-sm text-cyan-400 flex items-center gap-2",children:[e(s,{className:"w-4 h-4"})," Ready for ",e("strong",{children:de.category}),"! Tap GO to start ð"]})})]}),"completed"===T.status&&e(De,{battle:T,userTeam:ce,powerupReward:wt,onClaimRewards:()=>Je(!0),onViewReport:Ct,navigate:l,user:me,t:a,isSession:ae}),e(z.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},className:"fixed bottom-4 left-4 right-4 md:static md:px-5 md:pt-4 z-20",children:t(I,{onClick:()=>{O.playButtonClick(),Nt()},className:"w-full md:w-auto bg-white/10 hover:bg-white/15 backdrop-blur-xl border border-white/10 text-white",children:[e(re,{className:"w-4 h-4 mr-2"}),a("Back to Battles")]})}),e($,{children:Ge&&e("div",{className:"fixed inset-0 bg-black/80 backdrop-blur-sm z-50 flex items-center justify-center p-4",onClick:()=>Ue(!1),children:t(z.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"bg-slate-900/95 backdrop-blur-xl rounded-2xl p-6 max-w-sm w-full border border-white/10",onClick:e=>e.stopPropagation(),children:[t("div",{className:"text-center mb-5",children:[e(z.div,{className:"w-16 h-16 mx-auto mb-4 rounded-2xl bg-gradient-to-br from-amber-500/20 to-orange-500/20 flex items-center justify-center",animate:{scale:[1,1.05,1]},transition:{duration:1.5,repeat:1/0},children:e(x,{className:"w-8 h-8 text-amber-400"})}),e("h2",{className:"text-xl font-bold text-white mb-2",children:"Select a Category"}),e("p",{className:"text-sm text-white/50",children:"Choose wisely to maximize your score"})]}),t("div",{className:"flex gap-3",children:[e(I,{onClick:()=>{O.playDismiss(),Ue(!1)},variant:"outline",className:"flex-1 border-white/20 text-white/70",children:a("Wait")}),t(z.button,{onClick:()=>{O.playGoButton(),Ue(!1),St()},whileTap:{scale:.95},className:"flex-1 px-4 py-2.5 rounded-xl bg-gradient-to-r from-emerald-500 to-green-500 hover:from-emerald-400 hover:to-green-400 text-white font-bold flex items-center justify-center gap-2 shadow-lg shadow-emerald-500/25",children:[e(ne,{className:"w-4 h-4"})," Let's Go!"]})]})]})})}),e($,{children:fe&&he&&e(y.Suspense,{fallback:e("div",{className:"fixed inset-0 flex items-center justify-center bg-black/50 z-50",children:e(H,{className:"w-6 h-6 text-cyan-400 animate-spin"})}),children:e(Be,{isOpen:fe,onClose:()=>we(!1),sessionId:he})})}),T&&ce&&jt&&t(u,{children:[e(ye,{isOpen:ge,onClose:()=>{ke(!1),"battle"===o&&1===c&&m(2)},battleId:T._id,teamId:jt}),e(Ne,{isOpen:Le,onClose:()=>{qe(!1),"battle"===o&&3===c&&m(4)},battleId:T._id,teamId:jt})]}),e(ve,{userId:ze,isOpen:Ye,onClose:()=>{Fe(!1),$e(null)}}),T&&wt&&e(U,{isOpen:He,onClose:()=>{Je(!1),D(T._id)},battleResult:{_id:T._id,teamWon:T.winner===ce,trophyChange:T.trophyExchange?Math.round(T.trophyExchange.finalAmount*(T.winner===ce?1.25:"tie"===T.winner?.1:-.75)/4):0,powerupReward:wt,userTeamKey:ce},onClaim:async e=>{const t=b(),a=await fetch("/api/quickClash/powerup/claim-reward",{method:"POST",headers:{"Content-Type":"application/json",...t&&{"X-CSRF-Token":t}},credentials:"include",body:JSON.stringify({battleId:e})});if(!a.ok)throw new Error("Failed to claim rewards");const i=await a.json();if(!i.success)throw new Error(i.message||"Failed to claim rewards");return i}}),e(y.Suspense,{fallback:null,children:e(Ae,{isOpen:et,onClose:()=>{tt(!1);if(Xe&&Xe.isFirstPlayToday&&Xe.newStreak>0)localStorage.removeItem("pendingStreakPopup"),setTimeout(()=>{Ke(!0)},300);else{const{show:e,team:t}=je(pt,ae);e&&t&&((e=>{const t=Se();Ce({...t,lastShown:(new Date).toISOString(),lastTeamId:e})})(t._id),nt(t),setTimeout(()=>{rt(!0)},500))}},onPlayAgain:()=>{if(tt(!1),Xe&&Xe.newStreak>0)return localStorage.removeItem("pendingStreakPopup"),void setTimeout(()=>{Ke(!0)},300);ae&&l("/quickclash",{state:{showWelcome:!0,autoMatchmaking:!0}})},onShare:()=>{},rewardData:at,isSessionPlayer:ae,battleExpiresAt:T?.expiresAt,userTeams:gt?[gt]:[]})}),e(y.Suspense,{fallback:null,children:e(Te,{isOpen:Qe,onClose:()=>Ke(!1),streakResult:Xe,isSessionPlayer:ae,onCreateAccount:()=>{l("/quickclash",{state:{showSignup:!0}})}})}),e(y.Suspense,{fallback:null,children:e(Pe,{isOpen:st,onClose:()=>{(()=>{const e=Se();Ce({...e,dismissCount:(e.dismissCount||0)+1,lastDismissed:(new Date).toISOString()})})(),rt(!1),nt(null)},onInviteViaLink:()=>{Ie(),rt(!1),ct(!0)},onInviteInApp:()=>{Ie(),rt(!1),mt(!0)},team:lt})}),ot&<&&e(ie,{inviteUrl:`${window.location.origin}/play/join/${lt.teamCode}`,teamCode:lt.teamCode,onClose:()=>{ct(!1),nt(null)}}),dt&<&&e(se,{isOpen:dt,onClose:()=>{mt(!1),nt(null)}
2,teamId:lt._id,teamName:lt.name,onInvite:async e=>{try{await L.post(`/api/quickClash/team/${lt._id}/invite`,{inviteeId:e})}catch(t){throw t}}})]})});Le.displayName="TeamBattlePageV2";export{Le as default};
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.