import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{Ci as t,oi as n}from"./vendor-DlcENO3s.js";import{i as r,n as i,r as a,t as o}from"./tooltip-BzcyWQct.js";var s={igl:`bg-purple-500/15 text-purple-700 border-purple-500/20 dark:text-purple-400`,controller:`bg-blue-500/15 text-blue-700 border-blue-500/20 dark:text-blue-400`,initiator:`bg-amber-500/15 text-amber-700 border-amber-500/20 dark:text-amber-400`,duelist:`bg-red-500/15 text-red-700 border-red-500/20 dark:text-red-400`,sentinel:`bg-green-500/15 text-green-700 border-green-500/20 dark:text-green-400`,flex:`bg-cyan-500/15 text-cyan-700 border-cyan-500/20 dark:text-cyan-400`},c={igl:`bg-purple-500/10 text-purple-700 dark:text-purple-400`,duelist:`bg-red-500/10 text-red-700 dark:text-red-400`,controller:`bg-blue-500/10 text-blue-700 dark:text-blue-400`,sentinel:`bg-green-500/10 text-green-700 dark:text-green-400`,initiator:`bg-amber-500/10 text-amber-700 dark:text-amber-400`,flex:`bg-cyan-500/10 text-cyan-700 dark:text-cyan-400`},l=`bg-zinc-500/10 text-zinc-600 border-zinc-500/20 dark:text-zinc-400`,u=`bg-zinc-500/10 text-zinc-500`;function d(e){return e?s[e.toLowerCase()]??l:l}function f(e){return e?c[e.toLowerCase()]??u:u}var p=e(t(),1),m=n();function h({text:e}){return(0,m.jsx)(a,{children:(0,m.jsxs)(o,{children:[(0,m.jsx)(r,{className:`ml-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full border border-zinc-300 text-[8px] font-bold leading-none text-zinc-400 transition-colors hover:border-zinc-400 hover:text-zinc-500 dark:border-zinc-600 dark:text-zinc-500 dark:hover:border-zinc-500 dark:hover:text-zinc-400`,children:`?`}),(0,m.jsx)(i,{side:`top`,children:e})]})})}function g({className:e}){return(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,className:e,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M12 2L3 7v5c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V7L12 2z`,fill:`currentColor`,opacity:`0.15`}),(0,m.jsx)(`path`,{d:`M12 2L3 7v5c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V7L12 2z`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`,fill:`none`}),(0,m.jsx)(`path`,{d:`M8.5 11.5L11 14.5L15.5 9`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function _(){return(0,m.jsx)(a,{children:(0,m.jsxs)(o,{children:[(0,m.jsx)(r,{className:`inline-flex cursor-default`,children:(0,m.jsx)(g,{className:`h-[18px] w-[18px] text-amber-500`})}),(0,m.jsx)(i,{children:`VCT Database Verified`})]})})}function v(e,t={}){let n=t.threshold??30;return Number.isFinite(e)?e>=n?`up`:e<=-n?`down`:`flat`:`flat`}function y(e){return e===`up`?`Rating up`:e===`down`?`Rating down`:`Rating flat`}function b({history:e,currentRank:t,rankTotal:n,rankSubLabel:r}){let i=(0,p.useRef)(null),[a,o]=(0,p.useState)(null),{points:s,width:c,height:l,linePath:u,confidencePath:d,labels:f,milestones:g}=(0,p.useMemo)(()=>{let t=e.map(e=>e.rating),n=e.flatMap(e=>[e.rating+e.rd,e.rating-e.rd]),r=Math.floor(Math.min(...n)/25)*25-10,i=Math.ceil(Math.max(...n)/25)*25+10-r||1,a=e.length>1?e.length-1:1,o=e.map((e,t)=>({x:36+t/a*328,y:156-(e.rating-r)/i*140,yTop:156-(e.rating+e.rd-r)/i*140,yBot:156-(e.rating-e.rd-r)/i*140,rating:e.rating,rd:e.rd,date:new Date(e.snapshotDate).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})})),s=`M${o[0].x},${o[0].y}`;for(let e=1;e<o.length;e++){let t=(o[e-1].x+o[e].x)/2;s+=` C${t},${o[e-1].y} ${t},${o[e].y} ${o[e].x},${o[e].y}`}let c=`M${o[0].x},${o[0].yTop}`;for(let e=1;e<o.length;e++){let t=(o[e-1].x+o[e].x)/2;c+=` C${t},${o[e-1].yTop} ${t},${o[e].yTop} ${o[e].x},${o[e].yTop}`}c+=` L${o[o.length-1].x},${o[o.length-1].yBot}`;for(let e=o.length-2;e>=0;e--){let t=(o[e+1].x+o[e].x)/2;c+=` C${t},${o[e+1].yBot} ${t},${o[e].yBot} ${o[e].x},${o[e].yBot}`}c+=` Z`;let l=i/4,u=Array.from({length:5},(e,t)=>({val:Math.round(r+t*l),y:156-t*l/i*140})),d=t.indexOf(Math.max(...t)),f=t.indexOf(Math.min(...t)),p=[];return o.length>=5&&d!==o.length-1&&d!==0&&p.push({x:o[d].x,y:o[d].y,label:`Peak`,rating:Math.round(o[d].rating),isPositive:!0}),o.length>=5&&f!==o.length-1&&f!==0&&f!==d&&p.push({x:o[f].x,y:o[f].y,label:`Low`,rating:Math.round(o[f].rating),isPositive:!1}),{points:o,width:400,height:180,linePath:s,confidencePath:c,labels:u,milestones:p}},[e]),_=s[s.length-1],b=s[0],x=_.rating-b.rating,S=x>=0?`text-emerald-500 dark:text-emerald-400`:`text-rose-500 dark:text-rose-400`,C=v(x),w=y(C),T=C===`up`?`text-emerald-500 dark:text-emerald-400`:C===`down`?`text-rose-500 dark:text-rose-400`:`text-zinc-500 dark:text-zinc-400`,E=(0,p.useCallback)(e=>{let t=i.current;if(!t||s.length===0)return;let n=t.getBoundingClientRect(),r=(e.clientX-n.left)/n.width*c,a=s[0],u=Math.abs(s[0].x-r);for(let e of s){let t=Math.abs(e.x-r);t<u&&(u=t,a=e)}o({x:a.x/c,y:a.y/l,rating:a.rating,rd:a.rd,date:a.date,svgX:a.x})},[s,c,l]),D=(0,p.useCallback)(()=>{o(null)},[]);return(0,m.jsxs)(`div`,{children:[(0,m.jsxs)(`div`,{className:`mb-3 flex items-baseline gap-3`,children:[(0,m.jsx)(`span`,{className:`glk-metric glk-metric-lg text-zinc-900 dark:text-zinc-50`,children:Math.round(_.rating)}),(0,m.jsxs)(`span`,{className:`glk-tabular text-xs text-zinc-500 dark:text-zinc-400`,children:[`±`,Math.round(_.rd),(0,m.jsx)(h,{text:`Rating deviation — how uncertain the rating is. Lower = more confident. The shaded band shows this uncertainty range.`})]}),(0,m.jsxs)(`span`,{className:`glk-tabular text-xs font-bold ${S}`,children:[x>=0?`+`:``,Math.round(x)]}),(0,m.jsx)(`span`,{className:`text-2xs font-bold uppercase tracking-wider ${T}`,children:w}),t!=null&&(0,m.jsxs)(`span`,{className:`ml-auto flex items-baseline gap-1 text-xs text-zinc-500 dark:text-zinc-400`,children:[(0,m.jsx)(`span`,{className:`glk-eyebrow mr-1`,children:`Rank `}),(0,m.jsxs)(`span`,{className:`glk-tabular font-bold text-zinc-800 dark:text-zinc-100`,children:[`#`,t.toLocaleString()]}),(0,m.jsx)(`span`,{className:`text-2xs text-zinc-400`,children:r??(n==null?`Global`:`of ${n.toLocaleString()}`)})]})]}),(0,m.jsxs)(`div`,{className:`relative`,children:[(0,m.jsxs)(`svg`,{ref:i,viewBox:`0 0 ${c} ${l}`,className:`w-full`,preserveAspectRatio:`xMidYMid meet`,onMouseMove:E,onMouseLeave:D,style:{cursor:`crosshair`},children:[(0,m.jsx)(`defs`,{children:(0,m.jsxs)(`linearGradient`,{id:`ratingConfGrad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,m.jsx)(`stop`,{offset:`0%`,stopColor:`var(--glk-brand)`,stopOpacity:`0.12`}),(0,m.jsx)(`stop`,{offset:`50%`,stopColor:`var(--glk-brand)`,stopOpacity:`0.06`}),(0,m.jsx)(`stop`,{offset:`100%`,stopColor:`var(--glk-brand)`,stopOpacity:`0.12`})]})}),f.map((e,t)=>(0,m.jsxs)(`g`,{children:[(0,m.jsx)(`line`,{x1:36,y1:e.y,x2:c-36,y2:e.y,stroke:`currentColor`,strokeOpacity:`0.06`,strokeWidth:`1`}),(0,m.jsx)(`text`,{x:30,y:e.y+3,textAnchor:`end`,className:`fill-zinc-400 dark:fill-zinc-500`,fontSize:`9`,fontFamily:`var(--font-mono)`,children:e.val})]},t)),(0,m.jsx)(`path`,{d,fill:`url(#ratingConfGrad)`}),(0,m.jsx)(`path`,{d:u,fill:`none`,stroke:`var(--glk-brand)`,strokeWidth:`2`,strokeLinecap:`round`}),g.map((e,t)=>(0,m.jsxs)(`g`,{children:[(0,m.jsx)(`line`,{x1:e.x,y1:e.y-6,x2:e.x,y2:e.y+6,stroke:e.isPositive?`var(--glk-win)`:`var(--glk-loss)`,strokeWidth:`1`,strokeOpacity:`0.5`}),(0,m.jsx)(`circle`,{cx:e.x,cy:e.y,r:`3`,fill:e.isPositive?`var(--glk-win)`:`var(--glk-loss)`,opacity:`0.7`}),(0,m.jsxs)(`text`,{x:e.x,y:e.isPositive?e.y-10:e.y+14,textAnchor:`middle`,className:`fill-zinc-500 dark:fill-zinc-400`,fontSize:`8`,fontFamily:`var(--font-mono)`,children:[e.label,` `,e.rating]})]},t)),a&&(0,m.jsxs)(`g`,{children:[(0,m.jsx)(`line`,{x1:a.svgX,y1:16,x2:a.svgX,y2:l-24,stroke:`currentColor`,strokeOpacity:`0.15`,strokeWidth:`1`,strokeDasharray:`3 3`}),(0,m.jsx)(`circle`,{cx:a.svgX,cy:a.y*l,r:`4`,fill:`var(--glk-brand)`,stroke:`white`,strokeWidth:`2`,className:`dark:stroke-zinc-900`})]}),!a&&(0,m.jsx)(`circle`,{cx:_.x,cy:_.y,r:`4`,fill:`var(--glk-brand)`,stroke:`white`,strokeWidth:`2`,className:`dark:stroke-zinc-900`}),[s[0],s[Math.floor(s.length/2)],s[s.length-1]].map((e,t)=>(0,m.jsx)(`text`,{x:e.x,y:l-4,textAnchor:t===0?`start`:t===2?`end`:`middle`,className:`fill-zinc-400 dark:fill-zinc-500`,fontSize:`9`,fontFamily:`var(--font-mono)`,children:e.date},t))]}),a&&(0,m.jsxs)(`div`,{className:`pointer-events-none absolute z-10 -translate-y-full -translate-x-1/2 rounded border border-zinc-200/80 bg-white px-2.5 py-1.5 shadow-md dark:border-zinc-700/80 dark:bg-zinc-900`,style:{left:`${a.x*100}%`,top:`${a.y*100}%`},children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-zinc-500 dark:text-zinc-400`,children:a.date}),(0,m.jsx)(`div`,{className:`glk-tabular text-sm font-bold text-zinc-900 dark:text-zinc-50`,children:Math.round(a.rating)}),(0,m.jsxs)(`div`,{className:`text-2xs text-zinc-400 dark:text-zinc-500`,children:[`±`,Math.round(a.rd),` RD`]})]})]})]})}export{d as a,f as i,_ as n,h as r,b as t};