1import{r as h,j as e}from"./vendor-react-DIA7vK4g.js";import{e9 as he,ea as J,eb as X,ec as me,ed as Q,ee as ue,ef as Z,eg as xe,eh as pe,ei as P,b7 as I,ba as k,ej as m,cs as V,R as fe,$ as ve,aX as ye,aU as ge,ek as B,aa as K,u as we,v as be}from"./index-DtUVjOr4.js";import{T as ee}from"./trophy-BCwqMM8W.js";import{G as je}from"./gamepad-2-BqbYLyW0.js";import{C as Ne}from"./calendar-n1wfbzNV.js";import{G as _e}from"./gift-DmImHfm3.js";import{P as Se}from"./play-VbpcOJIM.js";import"./vendor-docs-BA9xu9ak.js";import"./vendor-utils-DWHjTIse.js";import"./vendor-supabase-_bOAMmkC.js";function ze(...a){const r=!Array.isArray(a[0]),o=r?0:-1,s=a[0+o],i=a[1+o],n=a[2+o],l=a[3+o],u=he(i,n,l);return r?u(s):u}function Ce(a,r,o={}){const s=a.get();let i=null,n=s,l;const u=typeof s=="string"?s.replace(/[\d.-]/g,""):void 0,c=()=>{i&&(i.stop(),i=null)},f=()=>{c();const t=W(a.get()),d=W(n);t!==d&&(i=new me({keyframes:[t,d],velocity:a.getVelocity(),type:"spring",restDelta:.001,restSpeed:.01,...o,onUpdate:l}))};if(a.attach((t,d)=>{n=t,l=g=>d(G(g,u)),J.postRender(()=>{var g;f(),(g=a.events.animationStart)==null||g.notify(),i==null||i.then(()=>{var x;(x=a.events.animationComplete)==null||x.notify()})})},c),X(r)){const t=r.on("change",g=>a.set(G(g,u))),d=a.on("destroy",t);return()=>{t(),d()}}return c}function G(a,r){return r?a+r:a}function W(a){return typeof a=="number"?a:parseFloat(a)}function te(a){const r=Q(()=>ue(a)),{isStatic:o}=h.useContext(Z);if(o){const[,s]=h.useState(a);h.useEffect(()=>r.on("change",s),[])}return r}function ae(a,r){const o=te(r()),s=()=>o.set(r());return s(),xe(()=>{const i=()=>
1J.preRender(s,!1,!0),n=a.map(l=>l.on("change",i));return()=>{n.forEach(l=>l()),pe(s)}}),o}function ke(a){P.current=[],a();const r=ae(P.current,a);return P.current=void 0,r}function se(a,r,o,s){if(typeof a=="function")return ke(a);const n=typeof r=="function"?r:ze(r,o,s);return Array.isArray(a)?Y(a,n):Y([a],([l])=>n(l))}function Y(a,r){const o=Q(()=>[]);return ae(a,()=>{o.length=0;const s=a.length;for(let i=0;i<s;i++)o[i]=a[i].get();return r(o)})}function Re(a,r={}){const{isStatic:o}=h.useContext(Z),s=()=>X(a)?a.get():a;if(o)return se(s);const i=te(s());return h.useInsertionEffect(()=>Ce(i,a,r),[i,JSON.stringify(r)]),i}function Te(a,r={}){return Re(a,{type:"spring",...r})}const De=[3e4,25e3,25e3,35e3,2e4],Ie=3e4,E=6e4,Me=36e5;function $e(){const[a,r]=h.useState(0),[o,s]=h.useState(!1),[i,n]=h.useState(null),l=h.useRef(null),u=h.useRef(!1),c=new Date().getMonth()+1,f=new Date().getFullYear(),{data:t}=I({queryKey:["tv-campaign"],queryFn:async()=>{const{data:p,error:y}=await k.from("gamification_campaigns").select("*").eq("status","ativa").order("data_inicio",{ascending:!1}).limit(1).maybeSingle();if(y)throw y;return p},refetchInterval:E}),{data:d}=I({queryKey:["tv-consultants"],queryFn:async()=>{const{data:p,error:y}=await k.from("gamification_consultants").select("*").eq("ativo",!0);if(y)throw y;const C=p.filter(b=>b.user_id).map(b=>b.user_id);let S=new Map;if(C.length>0){const{data:b}=await k.from("profiles").select("id, full_name, email, avatar_url").in("id",C);S=new Map((b==null?void 0:b.map(j=>[j.id,j]))||[])}return p.map(b=>{const j=b.user_id?S.get(b.user_id):null;return{...b,user_name:(j==null?void 0:j.full_name)||null,display_name:(j==null?void 0:j.full_name)||b.nome||"Sem nome",avatar:b.avatar||(j==null?void 0:j.avatar_url)||null}})},refetchInterval:E}),{data:g}=I({queryKey:["tv-ranking",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:p,error:y}=await k.from("gamification_ranking_cache").select("*").eq("campaign_id",t.id).order("posicao",{ascending:!0});if(y)throw y;const C=new Map((d||[]).map(S=>[S.id,S]));return(p||[]).map(S=>({...S,consultant:C.get(S.consultant_id)}))},enabled:!!(t!=null&&t.id)&&!!d,refetchInterval:E}),{data:x}=I({queryKey:["tv-monthly-podium",t==null?void 0:t.id,c,f],queryFn:async()=>{if(!(t!=null&&t.id)||!d)return[];const{data:p,error:y}=await k.from("gamification_weekly_sales").select("consultant_id, realizado, realizado_mrr, realizado_valor_unico, pontos").eq("campaign_id",t.id).eq("mes",c).eq("ano",f);if(y)throw y;const{data:C,error:S}=await k.from("gamification_goals").select("consultant_id, meta_hubspot_mensal").eq("campaign_id",t.id).eq("mes",c).eq("ano",f);if(S)throw S;const b=new Map;for(const w of p||[]){const _=b.get(w.consultant_id)||{realizado:0,pontos:0,mrr:0,valorUnico:0};_.realizado+=Number(w.realizado)||0,_.pontos+=Number(w.pontos)||0,_.mrr+=Number(w.realizado_mrr)||0,_.valorUnico+=Number(w.realizado_valor_unico)||0,b.set(w.consultant_id,_)}const j=new Map;for(const w of C||[])j.set(w.consultant_id,Number(w.meta_hubspot_mensal)||0);const oe=new Map((d||[]).map(w=>[w.id,w])),ce=new Set([...b.keys(),...j.keys()]),q=[];for(const w of ce){const _=b.get(w)||{realizado:0,pontos:0,mrr:0,valorUnico:0},O=j.get(w)||0,de=O>0?_.mrr/O*100:0;q.push({consultant_id:w,consultant:oe.get(w),realizado_mes:_.realizado,realizado_mrr:_.mrr,realizado_valor_unico:_.valorUnico,meta_mes:O,pct_meta:de,pontos_total:_.pontos})}return q.sort((w,_)=>_.pct_meta-w.pct_meta),q},enabled:!!(t!=null&&t.id)&&!!d,refetchInterval:E}),{data:v}=I({queryKey:["tv-deals",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:p,error:y}=await k.from("gamification_weekly_deals").select("*").eq("campaign_id",t.id).order("synced_at",{ascending:!1}).limit(5);if(y)throw y;return p||[]},enabled:!!(t!=null&&t.id),refetchInterval:Ie}),{data:N}=I({queryKey:["tv-monthly-deals-count",t==null?void 0:t.id,c,f],queryFn:async()=>{if(!(t!=null&&t.id))return 0;const{data:p,error:y}=await k.from("gamification_weekly_deals").select("id").eq("campaign_id",t.id).eq("mes",c).eq("ano",f);if(y)throw y;return(p||[]).length},enabled:!!(t!=null&&t.id),refetchInterval:E});h.useEffect(()=>{if(!v||v.length===0)return;const p=v[0];if(!u.current){l.current=p.id,u.current=!0;return}if(p.id!==l.current){l.current=p.id;const y=d==null?void 0:d.find(C=>C.id===p.consultant_id);
1n({deal:p,consultant:y}),s(!0),setTimeout(()=>{s(!1),n(null)},1e4)}},[v,d]),h.useEffect(()=>{if(o)return;const p=setTimeout(()=>{r(y=>(y+1)%5)},De[a]);return()=>clearTimeout(p)},[a,o]),h.useEffect(()=>{const p=setInterval(()=>window.location.reload(),Me);return()=>clearInterval(p)},[]);const D=(x||[]).slice(0,3),z=g||[],A=(x||[]).reduce((p,y)=>p+y.realizado_mrr,0),M=(x||[]).reduce((p,y)=>p+y.realizado_valor_unico,0),$=N||0,F=x&&x.length>0?x.reduce((p,y)=>p+y.pct_meta,0)/x.length:0,T=new Date(f,c,0).getDate(),R=new Date().getDate(),ne=T-R,re=h.useCallback(p=>{r(p)},[]),ie=h.useCallback(()=>{if(!v||v.length===0)return;const p=v[0],y=d==null?void 0:d.find(C=>C.id===p.consultant_id);n({deal:p,consultant:y}),s(!0),setTimeout(()=>{s(!1),n(null)},1e4)},[v,d]);return{campaign:t,consultants:d||[],ranking:z,topThreeMonthly:D,currentScreen:a,celebrating:o,celebrationDeal:i,totalMRR:A,totalTreinamento:M,totalDeals:$,avgMeta:F,daysRemaining:ne,goToScreen:re,triggerDemoCelebration:ie,isLoading:!t||!d||!g}}const Ee="/assets/wallpaper_gameficacao-B8wec9XK.png",Ve=Array.from({length:20},(a,r)=>({x:`${5+Math.random()*90}%`,y:`${5+Math.random()*90}%`,delay:Math.random()*4,duration:2+Math.random()*2}));function le(){return e.jsxs("div",{className:"fixed inset-0 overflow-hidden",style:{background:"linear-gradient(to bottom, hsl(260,80%,5%), hsl(260,70%,14%), hsl(260,50%,22%))"},children:[e.jsx("div",{className:"absolute inset-0 bg-center bg-cover opacity-[0.07]",style:{backgroundImage:`url(${Ee})`}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.12]",style:{backgroundImage:` 2 linear-gradient(hsla(240,100%,60%,0.25) 1px, transparent 1px), 3 linear-gradient(90deg, hsla(240,100%,60%,0.25) 1px, transparent 1px) 4 `,backgroundSize:"60px 60px"}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.06]",style:{backgroundImage:` 5 linear-gradient(hsla(186,100%,50%,0.4) 2px, transparent 2px), 6 linear-gradient(90deg, hsla(186,100%,50%,0.4) 2px, transparent 2px) 7 `,backgroundSize:"180px 180px"}}),Ve.map((a,r)=>e.jsx(m.div,{className:"absolute w-2 h-2 rounded-full",style:{left:a.x,top:a.y,background:"hsla(43,96%,56%,0.6)",boxShadow:"0 0 6px hsla(43,96%,56%,0.4)"},animate:{opacity:[.2,.8,.2]},transition:{duration:a.duration,delay:a.delay,repeat:1/0,ease:"easeInOut"}},r)),e.jsx("div",{className:"absolute inset-0 pointer-events-none z-10",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, hsla(0,0%,0%,0.03) 2px, hsla(0,0%,0%,0.03) 4px)"}})]})}const Le=[{label:"2º",height:"h-[22vh]",border:"border-[hsla(186,100%,50%,0.6)]",medal:"ð¥",textColor:"text-[hsl(186,100%,50%)]",glow:"shadow-[0_0_25px_hsla(186,100%,50%,0.3)]",barDelay:2.5,bg:"linear-gradient(to top, hsla(186,80%,20%,0.5), hsla(186,60%,30%,0.15))"},{label:"1º",height:"h-[40vh]",border:"border-[hsla(43,96%,56%,0.7)]",medal:"ð¥",textColor:"text-[hsl(43,96%,56%)]",glow:"shadow-[0_0_35px_hsla(43,96%,56%,0.4)]",barDelay:4,bg:"linear-gradient(to top, hsla(43,80%,20%,0.55), hsla(43,60%,30%,0.2))"},{label:"3º",height:"h-[10vh]",border:"border-[hsla(160,70%,45%,0.5)]",medal:"ð¥",textColor:"text-[hsl(160,70%,45%)]",glow:"shadow-[0_0_20px_hsla(160,70%,45%,0.3)]",barDelay:1,bg:"linear-gradient(to top, hsla(160,60%,18%,0.45), hsla(160,40%,25%,0.15))"}],Be=[1,0,2];function Ae({topThree:a}){const r=new Date().toLocaleString("pt-BR",{month:"long"}),o=h.useRef(!1);return h.useEffect(()=>{if(o.current||a.length===0)return;const s=setTimeout(()=>{o.current=!0;const i=["#FFD700","#FF6B9D","#00E5FF","#A855F7"],n=l=>{V({particleCount:l,angle:60,spread:55,origin:{x:0,y:.7},colors:i}),V({particleCount:l,angle:120,spread:55,origin:{x:1,y:.7},colors:i})};n(50),setTimeout(()=>n(30),400),setTimeout(()=>n(20),800)},4800);return()=>clearTimeout(s)},[a]),e.jsxs("div",{className:"h-full flex flex-col items-center justify-center",style:{padding:"0 4vw"},children:[e.jsxs(m.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},className:"flex items-center mb-[3vh]",style:{gap:"1vw"},children:[e.jsx(ee,{className:"text-[hsl(186,100%,50%)]",style:{width:"2.5vmin",height:"2.5vmin",filter:"drop-shadow(0 0 8px hsla(186,100%,50%,0.6))"}}),e.jsxs("h1",{className:"font-bold text-white tracking-tight",style:{fontSize:"clamp(1.5rem, 3.5vw, 3.5rem)",textShadow:"0 0 20px hsla(186,100%,50%,0.4), 0 0 40px hsla(330,100%,71%,0.2)"},children:["Pódio de ",r.charAt(0).toUpperCase()+r.slice(1)]})]}),e.jsx("div",{className:"flex items-end justify-center w-full",style:{gap:"2vw",maxWidth:"90vw"},children:Be.map((s,i)=>{var c,f,t,d;const n=a[s],l=Le[i];if(!n)return null;const u=s===0;return e.jsxs("div",{className:"flex flex-col items-center flex-1 relative",children:[u&&e.jsx(m.div,{className:"absolute -inset-[2vmin] rounded-3xl pointer-events-none",style:{background:"radial-gradient(ellipse at center bottom, hsla(43,96%,56%,0.2) 0%, hsla(330,100%,71%,0.08) 50%, transparent 70%)"},initial:{opacity:0}
7,animate:{opacity:[.2,.5,.2]},transition:{delay:l.barDelay+.8,duration:2,repeat:1/0,ease:"easeInOut"}}),e.jsxs(m.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:l.barDelay+.6,duration:.5},className:"flex flex-col items-center",children:[e.jsxs("div",{className:`relative mb-[1vh] ${u?"scale-110":""}`,children:[e.jsx("div",{className:`rounded-full border-2 ${l.border} overflow-hidden bg-[hsla(260,70%,14%,0.8)] backdrop-blur-sm ${l.glow}`,style:{width:"6vmin",height:"6vmin"},children:(c=n.consultant)!=null&&c.avatar?e.jsx("img",{src:n.consultant.avatar,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",style:{fontSize:"2vmin"},children:((t=(f=n.consultant)==null?void 0:f.display_name)==null?void 0:t[0])||"?"})}),e.jsx("span",{className:"absolute -top-1 -right-1",style:{fontSize:"2vmin"},children:l.medal})]}),e.jsx("p",{className:"text-white font-semibold text-center truncate",style:{fontSize:"clamp(0.75rem, 1.2vw, 1.2rem)",maxWidth:"14vw",marginBottom:"0.3vh"},children:((d=n.consultant)==null?void 0:d.display_name)||"Consultor"}),e.jsxs("p",{className:`${l.textColor} font-medium`,style:{fontSize:"clamp(0.6rem, 0.9vw, 0.9rem)",textShadow:"0 0 10px currentColor",marginBottom:"1vh"},children:[n.pct_meta.toFixed(0),"% da meta"]})]}),e.jsxs(m.div,{initial:{scaleY:0},animate:{scaleY:1},transition:{delay:l.barDelay,duration:.8,ease:[.34,1.56,.64,1]},style:{originY:1,transformOrigin:"bottom",background:l.bg},className:`w-full ${l.height} rounded-t-2xl border ${l.border} backdrop-blur-xl flex flex-col items-center justify-center ${l.glow} relative overflow-hidden`,children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, hsla(0,0%,0%,0.04) 2px, hsla(0,0%,0%,0.04) 4px)"}}),e.jsx("span",{className:`font-black ${l.textColor} relative z-10`,style:{fontSize:"clamp(1.2rem, 2.5vw, 2.5rem)",textShadow:"0 0 15px currentColor"},children:l.label}),e.jsxs("span",{className:"text-white/70 mt-0.5 relative z-10",style:{fontSize:"clamp(0.55rem, 0.85vw, 0.85rem)"},children:["MRR: ",(n.realizado_mrr||0).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})]}),(n.realizado_valor_unico||0)>0&&e.jsxs("span",{className:"text-white/50 mt-0.5 relative z-10",style:{fontSize:"clamp(0.5rem, 0.7vw, 0.75rem)"},children:["Trein.: ",(n.realizado_valor_unico||0).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})]}),e.jsxs("span",{className:"text-white/50 mt-0.5 relative z-10",style:{fontSize:"clamp(0.5rem, 0.7vw, 0.75rem)"},children:["Meta: ",(n.meta_mes||0).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})]})]})]},n.consultant_id)})})]})}const Fe=[{label:"2º",height:"h-[22vh]",border:"border-[hsla(186,100%,50%,0.6)]",medal:"ð¥",textColor:"text-[hsl(186,100%,50%)]",glow:"shadow-[0_0_25px_hsla(186,100%,50%,0.3)]",barDelay:2.5,bg:"linear-gradient(to top, hsla(186,80%,20%,0.5), hsla(186,60%,30%,0.15))"},{label:"1º",height:"h-[40vh]",border:"border-[hsla(43,96%,56%,0.7)]",medal:"ð¥",textColor:"text-[hsl(43,96%,56%)]",glow:"shadow-[0_0_35px_hsla(43,96%,56%,0.4)]",barDelay:4,bg:"linear-gradient(to top, hsla(43,80%,20%,0.55), hsla(43,60%,30%,0.2))"},{label:"3º",height:"h-[10vh]",border:"border-[hsla(160,70%,45%,0.5)]",medal:"ð¥",textColor:"text-[hsl(160,70%,45%)]",glow:"shadow-[0_0_20px_hsla(160,70%,45%,0.3)]",barDelay:1,bg:"linear-gradient(to top, hsla(160,60%,18%,0.45), hsla(160,40%,25%,0.15))"}],qe=[1,0,2];function Oe({ranking:a}){const r=h.useRef(!1),o=a.slice(0,3);return h.useEffect(()=>{r.current=!1;const s=setTimeout(()=>{r.current||(r.current=!0,V({particleCount:150,spread:100,origin:{y:.5,x:.5},colors:["#ff4500","#00e5ff","#ff69b4","#fbbf24","#ffffff"],gravity:.8}))},4800);return()=>clearTimeout(s)},[a]),e.jsxs("div",{className:"h-full flex flex-col items-center justify-center relative",style:{padding:"0 4vw"},children:[e.jsx(m.div,{className:"absolute inset-0 bg-white pointer-events-none z-50",initial:{opacity:0}
7,animate:{opacity:[0,0,.2,0]},transition:{delay:4.6,duration:.5,times:[0,.1,.3,1]}}),e.jsxs(m.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},className:"flex items-center mb-[3vh]",style:{gap:"1vw"},children:[e.jsx(ee,{className:"text-[hsl(43,96%,56%)]",style:{width:"2.5vmin",height:"2.5vmin",filter:"drop-shadow(0 0 10px hsla(43,96%,56%,0.6))"}}),e.jsx("h1",{className:"font-bold text-white tracking-tight",style:{fontSize:"clamp(1.5rem, 3.5vw, 3.5rem)",textShadow:"0 0 20px hsla(43,96%,56%,0.4), 0 0 40px hsla(16,100%,50%,0.2)"},children:"Pódio da Campanha"})]}),e.jsx("div",{className:"flex items-end justify-center w-full",style:{gap:"2vw",maxWidth:"90vw"},children:qe.map((s,i)=>{var c,f,t,d;const n=o[s],l=Fe[i];if(!n)return null;const u=s===0;return e.jsxs("div",{className:"flex flex-col items-center flex-1 relative",children:[u&&e.jsx(m.div,{className:"absolute -inset-[2vmin] rounded-3xl pointer-events-none",style:{background:"radial-gradient(ellipse at center bottom, hsla(43,96%,56%,0.25) 0%, hsla(16,100%,50%,0.1) 50%, transparent 70%)"},initial:{opacity:0}
7,animate:{opacity:[.2,.6,.2]},transition:{delay:l.barDelay+.8,duration:2,repeat:1/0,ease:"easeInOut"}}),e.jsxs(m.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:l.barDelay+.6,duration:.5},className:"flex flex-col items-center",children:[e.jsxs("div",{className:`relative mb-[1vh] ${u?"scale-110":""}`,children:[e.jsx("div",{className:`rounded-full border-2 ${l.border} overflow-hidden bg-[hsla(260,70%,14%,0.8)] backdrop-blur-sm ${l.glow}`,style:{width:"6vmin",height:"6vmin"},children:(c=n.consultant)!=null&&c.avatar?e.jsx("img",{src:n.consultant.avatar,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",style:{fontSize:"2vmin"},children:((t=(f=n.consultant)==null?void 0:f.display_name)==null?void 0:t[0])||"?"})}),e.jsx("span",{className:"absolute -top-1 -right-1",style:{fontSize:"2vmin"},children:l.medal})]}),e.jsx("p",{className:"text-white font-semibold text-center truncate",style:{fontSize:"clamp(0.75rem, 1.2vw, 1.2rem)",maxWidth:"14vw",marginBottom:"0.3vh"},children:((d=n.consultant)==null?void 0:d.display_name)||"Consultor"}),e.jsxs("p",{className:`${l.textColor} font-medium`,style:{fontSize:"clamp(0.6rem, 0.9vw, 0.9rem)",textShadow:"0 0 10px currentColor"},children:[n.pontos_total," pontos"]}),e.jsxs("p",{className:"text-white/50",style:{fontSize:"clamp(0.5rem, 0.7vw, 0.75rem)",marginBottom:"1vh"},children:[n.pct_meta.toFixed(0),"% da meta"]})]}),e.jsxs(m.div,{initial:{scaleY:0},animate:{scaleY:1},transition:{delay:l.barDelay,duration:.8,ease:[.34,1.56,.64,1]},style:{originY:1,transformOrigin:"bottom",background:l.bg},className:`w-full ${l.height} rounded-t-2xl border ${l.border} backdrop-blur-xl flex flex-col items-center justify-center ${l.glow} relative overflow-hidden`,children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, hsla(0,0%,0%,0.04) 2px, hsla(0,0%,0%,0.04) 4px)"}}),e.jsx("span",{className:`font-black ${l.textColor} relative z-10`,style:{fontSize:"clamp(1.2rem, 2.5vw, 2.5rem)",textShadow:"0 0 15px currentColor"},children:l.label}),e.jsxs("span",{className:"text-white/70 mt-0.5 relative z-10",style:{fontSize:"clamp(0.55rem, 0.85vw, 0.85rem)"},children:["MRR: ",(n.total_realizado_mrr||0).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})]}),(n.total_realizado_valor_unico||0)>0&&e.jsxs("span",{className:"text-white/50 mt-0.5 relative z-10",style:{fontSize:"clamp(0.5rem, 0.7vw, 0.75rem)"},children:["Trein.: ",(n.total_realizado_valor_unico||0).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})]})]})]},n.id)})})]})}const Pe={1:{bar:"linear-gradient(90deg, hsla(43,96%,56%,0.3), hsla(43,96%,56%,0.7))",glow:"0 0 20px hsla(43,96%,56%,0.5)",dot:"hsl(43,96%,56%)"},2:{bar:"linear-gradient(90deg, hsla(186,100%,50%,0.25), hsla(186,100%,50%,0.6))",glow:"0 0 18px hsla(186,100%,50%,0.4)",dot:"hsl(186,100%,50%)"},3:{bar:"linear-gradient(90deg, hsla(330,100%,71%,0.25), hsla(330,100%,71%,0.6))",glow:"0 0 15px hsla(330,100%,71%,0.4)",dot:"hsl(330,100%,71%)"}},Ue={bar:"linear-gradient(90deg, hsla(16,100%,50%,0.2), hsla(16,100%,50%,0.5))",glow:"0 0 10px hsla(16,100%,50%,0.3)",dot:"hsl(16,100%,50%)"};function Ke({ranking:a}){const r=h.useMemo(()=>Math.max(...a.map(s=>s.pontos_total||0),1),[a]),o=h.useMemo(()=>[...a].sort((s,i)=>(i.pontos_total||0)-(s.pontos_total||0)),[a]);return e.jsxs("div",{className:"h-full flex flex-col relative overflow-hidden",style:{padding:"2vh 4vw"},children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(90deg, transparent, transparent 58px, hsla(240,100%,60%,0.08) 58px, hsla(240,100%,60%,0.08) 60px)"}}),e.jsxs(m.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:.8},className:"flex items-center relative z-10",style:{gap:"1vw",marginBottom:"2vh"},children:[e.jsx(m.div,{animate:{rotate:[0,10,-10,0]},transition:{duration:1.5,repeat:1/0,repeatDelay:2},children:e.jsx(je,{className:"text-[hsl(16,100%,50%)]",style:{width:"2.8vmin",height:"2.8vmin",filter:"drop-shadow(0 0 8px hsla(16,100%,50%,0.6))"}})}),e.jsx("h1",{className:"font-bold text-white",style:{fontSize:"clamp(1.5rem, 3.5vw, 3.5rem)",textShadow:"0 0 20px hsla(16,100%,50%,0.4), 0 0 40px hsla(186,100%,50%,0.2)"},children:"Ranking da Campanha"})]}),e.jsx("div",{className:"flex-1 flex flex-col justify-center relative z-10",style:{gap:"1.2vh"},children:o.map((s,i)=>{var f,t,d,g;const n=Pe[s.posicao]||Ue,l=Math.max(5,(s.pontos_total||0)/r*100),u=.5+i*.3,c=s.posicao<=3;return e.jsxs(m.div,{initial:{opacity:0,x:-40}
7,animate:{opacity:1,x:0},transition:{delay:u,duration:.4,ease:"easeOut"},className:"flex items-center",style:{gap:"1vw",height:"7vh"},children:[e.jsxs("span",{className:"font-black text-center flex-shrink-0",style:{color:n.dot,textShadow:`0 0 10px ${n.dot}`,fontSize:"clamp(0.8rem, 1.3vw, 1.3rem)",width:"3vw"},children:["#",s.posicao]}),e.jsxs("div",{className:"flex items-center flex-shrink-0",style:{gap:"0.6vw",width:"16vw"},children:[e.jsx("div",{className:`rounded-full overflow-hidden flex-shrink-0 border ${c?"border-white/40":"border-white/15"} bg-[hsla(260,70%,14%,0.8)]`,style:{width:"3.5vmin",height:"3.5vmin"},children:(f=s.consultant)!=null&&f.avatar?e.jsx("img",{src:s.consultant.avatar,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-white/70",style:{fontSize:"1.2vmin"},children:((d=(t=s.consultant)==null?void 0:t.display_name)==null?void 0:d[0])||"?"})}),e.jsx("span",{className:"text-white font-medium truncate",style:{fontSize:"clamp(0.7rem, 1.1vw, 1.1rem)"},children:((g=s.consultant)==null?void 0:g.display_name)||"Consultor"})]}),e.jsxs("div",{className:"flex-1 relative rounded-full bg-[hsla(260,70%,14%,0.4)] border border-[hsla(240,100%,60%,0.1)] overflow-visible",style:{height:"4vh"},children:[e.jsx("div",{className:"absolute inset-0 flex items-center px-4 gap-4 pointer-events-none",children:Array.from({length:12}).map((x,v)=>e.jsx("div",{className:"w-1 h-1 rounded-full bg-[hsla(240,100%,60%,0.15)]"},v))}),e.jsx(m.div,{className:"absolute inset-y-0 left-0 rounded-full flex items-center justify-end",style:{background:n.bar,boxShadow:n.glow},initial:{width:0},animate:{width:`${l}%`},transition:{delay:u+.3,duration:1.2,ease:[.25,.46,.45,.94]},children:e.jsx(m.div,{className:"absolute -right-3 rounded-full flex items-center justify-center",style:{width:"3vmin",height:"3vmin",backgroundColor:n.dot,boxShadow:`0 0 12px ${n.dot}, 0 0 24px ${n.dot}`},initial:{scale:0},animate:{scale:1},transition:{delay:u+1.4,type:"spring",stiffness:300,damping:15},children:e.jsx("div",{className:"w-0 h-0 border-t-[5px] border-b-[5px] border-r-[6px] border-t-transparent border-b-transparent",style:{borderRightColor:"hsla(260,70%,14%,0.9)"}})})})]}),e.jsxs(m.span,{className:"text-right font-bold flex-shrink-0",style:{color:n.dot,textShadow:`0 0 10px ${n.dot}`,fontSize:"clamp(0.8rem, 1.3vw, 1.3rem)",width:"6vw"},initial:{opacity:0}
7,animate:{opacity:1},transition:{delay:u+1.5,duration:.3},children:[s.pontos_total," pts"]})]},s.id)})})]})}const Ge=5,We=3.5;function U(a,r){switch(r){case"currency":return a.toLocaleString("pt-BR",{style:"currency",currency:"BRL"});case"percent":return`${a.toFixed(1)}%`;case"integer":default:return Math.round(a).toString()}}function Ye({rawValue:a,format:r,active:o}){const s=Te(0,{stiffness:40,damping:20,duration:We*1e3}),i=se(s,n=>U(n,r));return h.useEffect(()=>{o&&s.set(a)},[o,a,s]),e.jsx(m.span,{children:i})}function He({totalMRR:a,totalTreinamento:r,totalDeals:o,avgMeta:s,daysRemaining:i,campaignName:n}){const[l,u]=h.useState(0),c=[{label:"MRR Total",rawValue:a,format:"currency",icon:fe,borderColor:"border-[hsla(186,100%,50%,0.5)]",iconColor:"text-[hsl(186,100%,50%)]",glow:"shadow-[0_0_25px_hsla(186,100%,50%,0.2)]",valueShadow:"0 0 15px hsla(186,100%,50%,0.5)"},{label:"Treinamento",rawValue:r,format:"currency",icon:ve,borderColor:"border-[hsla(43,96%,56%,0.5)]",iconColor:"text-[hsl(43,96%,56%)]",glow:"shadow-[0_0_25px_hsla(43,96%,56%,0.2)]",valueShadow:"0 0 15px hsla(43,96%,56%,0.5)"},{label:"Deals Fechados",rawValue:o,format:"integer",icon:ye,borderColor:"border-[hsla(330,100%,71%,0.5)]",iconColor:"text-[hsl(330,100%,71%)]",glow:"shadow-[0_0_25px_hsla(330,100%,71%,0.2)]",valueShadow:"0 0 15px hsla(330,100%,71%,0.5)"},{label:"% Meta Geral",rawValue:s,format:"percent",icon:ge,borderColor:"border-[hsla(160,70%,45%,0.5)]",iconColor:"text-[hsl(160,70%,45%)]",glow:"shadow-[0_0_25px_hsla(160,70%,45%,0.2)]",valueShadow:"0 0 15px hsla(160,70%,45%,0.5)"},{label:"Dias Restantes",rawValue:i,format:"integer",icon:Ne,borderColor:"border-[hsla(16,100%,50%,0.4)]",
7iconColor:"text-[hsl(16,100%,50%)]",glow:"shadow-[0_0_20px_hsla(16,100%,50%,0.15)]",valueShadow:"0 0 10px hsla(16,100%,50%,0.4)"}];h.useEffect(()=>{if(l<c.length){const t=setTimeout(()=>{u(d=>d+1)},Ge*1e3);return()=>clearTimeout(t)}},[l,c.length]);const f=t=>t>l?"waiting":t===l?"featured":"settled";return e.jsxs("div",{className:"h-full flex flex-col items-center justify-center relative",style:{padding:"0 4vw"},children:[e.jsxs(m.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},className:"text-center",style:{marginBottom:"3vh"},children:[e.jsx(m.p,{className:"text-[hsl(16,100%,50%)] font-bold tracking-[0.3em] uppercase",style:{fontSize:"clamp(0.7rem, 1.1vw, 1.1rem)",textShadow:"0 0 15px hsla(16,100%,50%,0.6)",marginBottom:"0.5vh"},animate:{opacity:[.6,1,.6]},transition:{duration:2,repeat:1/0},children:"â
HIGH SCORE â
"}),e.jsx("h1",{className:"font-bold text-white",style:{fontSize:"clamp(1.2rem, 2.8vw, 2.8rem)",textShadow:"0 0 20px hsla(186,100%,50%,0.3)"},children:"Métricas do Mês"}),n&&e.jsx("p",{className:"text-white/50",style:{fontSize:"clamp(0.7rem, 1.1vw, 1.1rem)",marginTop:"0.5vh"},children:n})]}),e.jsxs("div",{className:"flex flex-col w-full items-center",style:{gap:"2vh",maxWidth:"85vw"},children:[e.jsx("div",{className:"grid grid-cols-3 w-full",style:{gap:"1.5vw"},children:c.slice(0,3).map((t,d)=>{const g=f(d);return e.jsx("div",{className:"relative",children:e.jsxs(m.div,{initial:{opacity:0,scale:.8},animate:{opacity:g==="settled"?1:0,scale:g==="settled"?1:.8},transition:{duration:.5,ease:"easeOut"},className:`rounded-2xl bg-[hsla(260,70%,14%,0.8)] border ${t.borderColor} backdrop-blur-xl flex flex-col items-center justify-center ${t.glow} relative overflow-hidden`,style:{padding:"2vh 1.5vw"},children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, hsla(0,0%,0%,0.03) 2px, hsla(0,0%,0%,0.03) 4px)"}}),e.jsx(t.icon,{className:`${t.iconColor} relative z-10`,style:{width:"2.5vmin",height:"2.5vmin",marginBottom:"1vh",filter:"drop-shadow(0 0 8px currentColor)"}}),e.jsx("p",{className:"text-white/60 font-medium relative z-10",style:{fontSize:"clamp(0.6rem, 0.9vw, 0.9rem)",marginBottom:"0.5vh"},children:t.label}),e.jsx("p",{className:"text-white font-black relative z-10",style:{fontSize:"clamp(1.2rem, 2.5vw, 2.5rem)",textShadow:t.valueShadow},children:U(t.rawValue,t.format)})]})},t.label)})}),e.jsx("div",{className:"grid grid-cols-2 w-full",style:{gap:"1.5vw",maxWidth:"60vw"},children:c.slice(3).map((t,d)=>{const g=f(d+3);return e.jsx("div",{className:"relative",children:e.jsxs(m.div,{initial:{opacity:0,scale:.8},animate:{opacity:g==="settled"?1:0,scale:g==="settled"?1:.8},transition:{duration:.5,ease:"easeOut"},className:`rounded-2xl bg-[hsla(260,70%,14%,0.8)] border ${t.borderColor} backdrop-blur-xl flex flex-col items-center justify-center ${t.glow} relative overflow-hidden`,style:{padding:"2vh 1.5vw"},children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, hsla(0,0%,0%,0.03) 2px, hsla(0,0%,0%,0.03) 4px)"}}),e.jsx(t.icon,{className:`${t.iconColor} relative z-10`,style:{width:"2.5vmin",height:"2.5vmin",marginBottom:"1vh",filter:"drop-shadow(0 0 8px currentColor)"}}),e.jsx("p",{className:"text-white/60 font-medium relative z-10",style:{fontSize:"clamp(0.6rem, 0.9vw, 0.9rem)",marginBottom:"0.5vh"},children:t.label}),e.jsx("p",{className:"text-white font-black relative z-10",style:{fontSize:"clamp(1.2rem, 2.5vw, 2.5rem)",textShadow:t.valueShadow},children:U(t.rawValue,t.format)})]})},t.label)})})]}),e.jsx(B,{children:l<c.length&&e.jsxs(e.Fragment,{children:[e.jsx(m.div,{className:"fixed inset-0 z-40 bg-black/60",initial:{opacity:0}
7,animate:{opacity:1},exit:{opacity:0}},`backdrop-${l}`),e.jsx(m.div,{initial:{opacity:0,scale:.6},animate:{opacity:1,scale:1.2},exit:{opacity:0,scale:.5,transition:{duration:.3}},transition:{duration:.5,ease:"easeOut"},className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:e.jsxs("div",{className:`rounded-2xl bg-[hsla(260,70%,14%,0.95)] border-2 ${c[l].borderColor} backdrop-blur-xl flex flex-col items-center justify-center ${c[l].glow} relative overflow-hidden`,style:{padding:"4vh 4vw",minWidth:"30vw",boxShadow:`0 0 60px hsla(260,70%,50%,0.3), ${c[l].valueShadow}`},children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, hsla(0,0%,0%,0.03) 2px, hsla(0,0%,0%,0.03) 4px)"}}),(()=>{const t=c[l].icon;return e.jsx(t,{className:`${c[l].iconColor} relative z-10`,style:{width:"4vmin",height:"4vmin",marginBottom:"2vh",filter:"drop-shadow(0 0 12px currentColor)"}})})(),e.jsx("p",{className:"text-white/60 font-medium relative z-10",style:{fontSize:"clamp(0.8rem, 1.3vw, 1.3rem)",marginBottom:"1vh"},children:c[l].label}),e.jsx("p",{className:"text-white font-black relative z-10",style:{fontSize:"clamp(2rem, 5vw, 5rem)",textShadow:c[l].valueShadow},children:e.jsx(Ye,{rawValue:c[l].rawValue,format:c[l].format,active:!0})})]})},l)]})})]})}const Je={1:"ð¥",2:"ð¥",3:"ð¥"},Xe={1:"border-[hsla(43,96%,56%,0.5)] shadow-[0_0_20px_hsla(43,96%,56%,0.2)]",2:"border-[hsla(186,100%,50%,0.4)] shadow-[0_0_15px_hsla(186,100%,50%,0.2)]",3:"border-[hsla(330,100%,71%,0.4)] shadow-[0_0_15px_hsla(330,100%,71%,0.2)]"};function Qe({campaign:a,ranking:r}){const o=(a==null?void 0:a.premios)||[];return e.jsxs("div",{className:"h-full flex flex-col items-center justify-center",style:{padding:"0 4vw"},children:[e.jsxs(m.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},className:"flex items-center",style:{gap:"1vw",marginBottom:"3vh"},children:[e.jsx(_e,{className:"text-[hsl(330,100%,71%)]",style:{width:"2.5vmin",height:"2.5vmin",filter:"drop-shadow(0 0 8px hsla(330,100%,71%,0.6))"}}),e.jsx("h1",{className:"font-bold text-white",style:{fontSize:"clamp(1.5rem, 3vw, 3rem)",textShadow:"0 0 20px hsla(330,100%,71%,0.3), 0 0 40px hsla(186,100%,50%,0.2)"},children:"Prêmios da Campanha"})]}),e.jsxs("div",{className:"grid grid-cols-1 w-full",style:{gap:"1.5vh",maxWidth:"70vw"},children:[o.map((s,i)=>{var u,c,f,t;const n=r.find(d=>d.posicao===s.posicao),l=Xe[s.posicao]||"border-[hsla(240,100%,60%,0.2)]";return e.jsxs(m.div,{initial:{opacity:0,x:-30},animate:{opacity:1,x:0},transition:{delay:i*.15},className:`flex items-center rounded-2xl bg-[hsla(260,70%,14%,0.8)] backdrop-blur-xl border ${l} relative overflow-hidden`,style:{gap:"1.5vw",padding:"2vh 2vw"},children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:"repeating-linear-gradient(0deg, transparent, transparent 2px, hsla(0,0%,0%,0.03) 2px, hsla(0,0%,0%,0.03) 4px)"}}),e.jsx("span",{className:"relative z-10",style:{fontSize:"2.5vmin"},children:Je[s.posicao]||"ð
"}),e.jsxs("div",{className:"flex-1 relative z-10",children:[e.jsxs("p",{className:"text-white/50",style:{fontSize:"clamp(0.6rem, 0.85vw, 0.85rem)"},children:[s.posicao,"º lugar"]}),e.jsx("p",{className:"text-white font-bold",style:{fontSize:"clamp(0.9rem, 1.4vw, 1.4rem)"},children:s.premio}),s.valor&&e.jsx("p",{className:"text-[hsl(43,96%,56%)] font-medium",style:{fontSize:"clamp(0.6rem, 0.85vw, 0.85rem)",textShadow:"0 0 8px hsla(43,96%,56%,0.4)"},children:s.valor.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})})]}),n&&e.jsxs("div",{className:"flex items-center bg-[hsla(260,70%,14%,0.8)] rounded-xl border border-[hsla(186,100%,50%,0.2)] relative z-10",style:{gap:"0.6vw",padding:"0.8vh 1vw"},children:[e.jsx("div",{className:"rounded-full bg-[hsla(260,70%,14%,0.8)] overflow-hidden",style:{width:"2.5vmin",height:"2.5vmin"},children:(u=n.consultant)!=null&&u.avatar?e.jsx("img",{src:n.consultant.avatar,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-white/70",style:{fontSize:"1vmin"},children:(f=(c=n.consultant)==null?void 0:c.display_name)==null?void 0:f[0]})}),e.jsx("span",{className:"text-white font-medium",style:{fontSize:"clamp(0.6rem, 0.9vw, 0.9rem)"},children:(t=n.consultant)==null?void 0:t.display_name})]})]},i)}),o.length===0&&e.jsx("div",{className:"text-center text-white/40",style:{padding:"10vh 0",fontSize:"clamp(0.9rem, 1.3vw, 1.3rem)"},children:"Nenhum prêmio configurado para esta campanha"})]})]})}function H({target:a,duration:r=2e3}){const[o,s]=h.useState(0);return h.useEffect(()=>{const i=Date.now(),n=()=>{const l=Date.now()-i,u=Math.min(l/r,1);s(Math.floor(a*u)),u<1&&requestAnimationFrame(n)};n()}
7,[a,r]),e.jsx(e.Fragment,{children:o.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})})}function Ze({celebration:a}){var i;const r=h.useRef(!1);h.useEffect(()=>{if(r.current)return;r.current=!0;const n=()=>{V({particleCount:100,spread:70,origin:{x:.2,y:.5},colors:["#ff4500","#00e5ff","#ff69b4","#fbbf24"]}),V({particleCount:100,spread:70,origin:{x:.8,y:.5},colors:["#ff4500","#00e5ff","#ff69b4","#fbbf24"]})};n();const l=setInterval(n,1500);return setTimeout(()=>clearInterval(l),6e3),()=>clearInterval(l)},[]);const{deal:o,consultant:s}=a;return e.jsx(m.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"radial-gradient(ellipse at center, hsla(260,70%,14%,0.97), hsl(260,80%,5%))"},children:e.jsxs(m.div,{initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},transition:{type:"spring",damping:15},className:"flex flex-col items-center gap-8",children:[e.jsx(m.p,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},className:"text-[hsl(16,100%,50%)] text-2xl font-bold tracking-widest uppercase",style:{textShadow:"0 0 20px hsla(16,100%,50%,0.6), 0 0 40px hsla(16,100%,50%,0.3)"},children:"ð Nova Venda! ð"}),e.jsx(m.p,{initial:{opacity:0,scale:0},animate:{opacity:[0,1,1,.8],scale:[.5,1.2,1,1]},transition:{delay:.5,duration:1},className:"text-[hsl(186,100%,50%)] text-4xl font-black tracking-[0.2em]",style:{textShadow:"0 0 30px hsla(186,100%,50%,0.7), 0 0 60px hsla(186,100%,50%,0.3)"},children:"LEVEL UP!"}),e.jsxs(m.div,{className:"flex flex-col items-center gap-4 bg-[hsla(260,70%,14%,0.9)] backdrop-blur-2xl rounded-3xl px-16 py-10 relative overflow-hidden",style:{boxShadow:"0 0 40px hsla(186,100%,50%,0.15), 0 0 80px hsla(330,100%,71%,0.1)",border:"2px solid hsla(186,100%,50%,0.3)"},children:[e.jsx("div",{className:"w-28 h-28 rounded-full border-4 border-[hsla(186,100%,50%,0.5)] overflow-hidden bg-[hsla(260,70%,14%,0.8)] relative z-10 shadow-[0_0_25px_hsla(186,100%,50%,0.3)]",children:s!=null&&s.avatar?e.jsx("img",{src:s.avatar,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-4xl text-white/70",children:((i=s==null?void 0:s.display_name)==null?void 0:i[0])||"?"})}),e.jsx("h2",{className:"text-white text-4xl font-black relative z-10",children:(s==null?void 0:s.display_name)||"Consultor"}),e.jsx("p",{className:"text-white/60 text-lg relative z-10",children:o.deal_name}),e.jsxs(m.div,{initial:{scale:0},animate:{scale:1},transition:{delay:.3,type:"spring"},className:"flex flex-col items-center mt-2 relative z-10",children:[e.jsx("p",{className:"text-white/50 text-sm mb-1",children:"MRR"}),e.jsx("span",{className:"text-[hsl(186,100%,50%)] text-6xl font-black",style:{textShadow:"0 0 30px hsla(186,100%,50%,0.6)"},children:e.jsx(H,{target:o.hs_mrr||0})}),(o.valor_unico||0)>0&&e.jsxs("div",{className:"mt-3 flex flex-col items-center",children:[e.jsx("p",{className:"text-white/50 text-sm mb-1",children:"Treinamento"}),e.jsx("span",{className:"text-[hsl(43,96%,56%)] text-3xl font-bold",style:{textShadow:"0 0 20px hsla(43,96%,56%,0.5)"},children:e.jsx(H,{target:o.valor_unico||0,duration:1500})})]})]})]})]})})}function et({onUnlock:a}){const[r,o]=h.useState(["","","",""]),[s,i]=h.useState("idle"),[n,l]=h.useState(!1),u=h.useRef([]);h.useEffect(()=>{var x;(x=u.current[0])==null||x.focus()},[]);const c=h.useCallback(async x=>{if(!n){l(!0);try{const{data:v,error:N}=await k.functions.invoke("tv-validate-pin",{body:{pin:x}});if(N||!(v!=null&&v.valid))throw new Error("PIN inválido");i("success"),setTimeout(a,600)}catch{i("error"),setTimeout(()=>{var N;o(["","","",""]),i("idle"),(N=u.current[0])==null||N.focus()},600)}finally{l(!1)}}},[n,a]),f=(x,v)=>{var D;if(!/^\d?$/.test(v))return;const N=[...r];if(N[x]=v,o(N),v&&x<3&&((D=u.current[x+1])==null||D.focus()),v&&x===3){const z=N.join("");z.length===4&&c(z)}},t=(x,v)=>{var N;v.key==="Backspace"&&!r[x]&&x>0&&((N=u.current[x-1])==null||N.focus())},d=s==="success"?"hsla(120,100%,50%,0.8)":s==="error"?"hsla(0,100%,50%,0.8)":"hsla(270,100%,70%,0.5)",g=s==="success"?"0 0 20px hsla(120,100%,50%,0.5)":s==="error"?"0 0 20px hsla(0,100%,50%,0.5)":"0 0 12px hsla(270,100%,70%,0.3)";return e.jsxs("div",{className:"h-screen w-screen overflow-hidden relative",children:[e.jsx(le,{}),e.jsxs("div",{className:"relative z-10 h-full flex flex-col items-center justify-center",style:{gap:"4vh"},children:[e.jsxs(m.div,{initial:{opacity:0,y:-30}
7,animate:{opacity:1,y:0},transition:{duration:.8},className:"text-center",children:[e.jsx("h1",{className:"font-black tracking-widest",style:{fontSize:"clamp(2rem, 5vw, 5rem)",color:"hsl(16,100%,50%)",textShadow:"0 0 30px hsla(16,100%,50%,0.6), 0 0 60px hsla(16,100%,50%,0.3)"},children:"PONTUA TV"}),e.jsx("p",{className:"tracking-[0.3em] uppercase",style:{marginTop:"1vh",fontSize:"clamp(0.6rem, 1vw, 1rem)",color:"hsla(0,0%,100%,0.5)"},children:"Digite o código de acesso"})]}),e.jsx(m.div,{className:"flex",style:{gap:"1.5vw"},animate:s==="error"?{x:[0,-12,12,-8,8,0]}:{},transition:{duration:.4},children:[0,1,2,3].map(x=>e.jsx(m.input,{ref:v=>{u.current[x]=v},type:"text",inputMode:"numeric",maxLength:1,value:r[x],onChange:v=>f(x,v.target.value),onKeyDown:v=>t(x,v),disabled:s!=="idle",className:"text-center font-bold rounded-xl bg-transparent outline-none",style:{width:"5vmin",height:"7vmin",fontSize:"clamp(1.2rem, 2.5vw, 2.5rem)",color:"white",border:`2px solid ${d}`,boxShadow:g,caretColor:"hsl(270,100%,70%)",transition:"border-color 0.3s, box-shadow 0.3s"},initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{delay:x*.1,duration:.3}},x))}),e.jsx(B,{children:s==="error"&&e.jsx(m.p,{initial:{opacity:0}
7,animate:{opacity:1},exit:{opacity:0},className:"tracking-wider",style:{fontSize:"clamp(0.6rem, 0.9vw, 0.9rem)",color:"hsl(0,100%,60%)"},children:"Código incorreto"})})]})]})}const L=5;function ht(){const[a,r]=h.useState(()=>sessionStorage.getItem("tv_unlocked")==="true"),[o,s]=h.useState(!0),i=h.useCallback(()=>{sessionStorage.setItem("tv_unlocked","true"),r(!0)},[]);h.useEffect(()=>{k.auth.getSession().then(({data:T})=>{T.session&&i(),s(!1)})},[i]);const{campaign:n,ranking:l,topThreeMonthly:u,currentScreen:c,celebrating:f,celebrationDeal:t,totalMRR:d,totalTreinamento:g,totalDeals:x,avgMeta:v,daysRemaining:N,isLoading:D,goToScreen:z,triggerDemoCelebration:A}=$e(),M=h.useCallback(()=>{z((c+1)%L)},[c,z]),$=h.useCallback(()=>{z((c-1+L)%L)},[c,z]);if(h.useEffect(()=>{const T=R=>{f||(R.key==="ArrowRight"&&M(),R.key==="ArrowLeft"&&$())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[M,$,f]),o)return e.jsx("div",{className:"h-screen w-screen flex items-center justify-center",style:{background:"hsl(260,80%,5%)"},children:e.jsx(K,{className:"w-12 h-12 text-[hsl(16,100%,50%)]/40 animate-spin"})});if(!a)return e.jsx(et,{onUnlock:i});if(D)return e.jsx("div",{className:"h-screen w-screen flex items-center justify-center",style:{background:"hsl(260,80%,5%)"},children:e.jsx(K,{className:"w-12 h-12 text-[hsl(16,100%,50%)]/40 animate-spin"})});const F=[e.jsx(Ae,{topThree:u},"podio"),e.jsx(Oe,{ranking:l},"podio-campanha"),e.jsx(Ke,{ranking:l},"ranking"),e.jsx(He,{totalMRR:d,totalTreinamento:g,totalDeals:x,avgMeta:v,daysRemaining:N,campaignName:n==null?void 0:n.nome},"metricas"),e.jsx(Qe,{campaign:n,ranking:l},"premios")];return e.jsxs("div",{className:"h-screen w-screen overflow-hidden relative",children:[e.jsx(le,{}),e.jsxs("div",{className:"relative z-10 h-full",children:[e.jsx(B,{mode:"wait",children:!f&&e.jsx(m.div,{initial:{opacity:0}
7,animate:{opacity:1},exit:{opacity:0},transition:{duration:.6},className:"h-full",children:F[c]},c)}),e.jsx(B,{children:f&&t&&e.jsx(Ze,{celebration:t})})]}),!f&&e.jsxs("div",{className:"absolute bottom-6 left-0 right-0 flex items-center justify-center z-20",children:[e.jsx("button",{onClick:$,className:"absolute left-8 text-white/30 hover:text-white/70 transition-colors cursor-pointer",children:e.jsx(we,{className:"w-8 h-8"})}),e.jsx("div",{className:"flex gap-2",children:Array.from({length:L}).map((T,R)=>e.jsx("button",{onClick:()=>z(R),className:`w-2.5 h-2.5 rounded-full transition-all duration-300 cursor-pointer ${R===c?"bg-[hsl(16,100%,50%)] scale-125 shadow-[0_0_10px_hsla(16,100%,50%,0.6)]":"bg-white/30 hover:bg-white/50"}`},R))}),e.jsx("button",{onClick:M,className:"absolute right-8 text-white/30 hover:text-white/70 transition-colors cursor-pointer",children:e.jsx(be,{className:"w-8 h-8"})}),e.jsx("button",{onClick:A,className:"absolute bottom-0 right-20 text-white/20 hover:text-white/60 transition-colors cursor-pointer",title:"Demo: última venda",children:e.jsx(Se,{className:"w-5 h-5"})})]})]})}export{ht 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.