import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{bi as t,ri as n}from"./vendor-DU4C2Mru.js";import{i as r,n as i,r as a,t as o}from"./tooltip-DjAjb2WT.js";var s=e(t(),1),c=n();function l({text:e}){return(0,c.jsx)(a,{children:(0,c.jsxs)(o,{children:[(0,c.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,c.jsx)(i,{side:`top`,children:e})]})})}function u({className:e}){return(0,c.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,className:e,"aria-hidden":`true`,children:[(0,c.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,c.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,c.jsx)(`path`,{d:`M8.5 11.5L11 14.5L15.5 9`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function d(){return(0,c.jsx)(a,{children:(0,c.jsxs)(o,{children:[(0,c.jsx)(r,{className:`inline-flex cursor-default`,children:(0,c.jsx)(u,{className:`h-[18px] w-[18px] text-amber-500`})}),(0,c.jsx)(i,{children:`VCT Database Verified`})]})})}function f(e,t={}){let n=t.threshold??30;return Number.isFinite(e)?e>=n?`up`:e<=-n?`down`:`flat`:`flat`}function p(e){return e===`up`?`Rating up`:e===`down`?`Rating down`:`Rating flat`}function m({history:e,currentRank:t}){let n=(0,s.useRef)(null),[r,i]=(0,s.useState)(null),{points:a,width:o,height:u,linePath:d,confidencePath:m,labels:h,milestones:g}=(0,s.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]),_=a[a.length-1],v=a[0],y=_.rating-v.rating,b=y>=0?`text-emerald-500 dark:text-emerald-400`:`text-rose-500 dark:text-rose-400`,x=f(y),S=p(x),C=x===`up`?`text-emerald-500 dark:text-emerald-400`:x===`down`?`text-rose-500 dark:text-rose-400`:`text-zinc-500 dark:text-zinc-400`,w=(0,s.useCallback)(e=>{let t=n.current;if(!t||a.length===0)return;let r=t.getBoundingClientRect(),s=(e.clientX-r.left)/r.width*o,c=a[0],l=Math.abs(a[0].x-s);for(let e of a){let t=Math.abs(e.x-s);t<l&&(l=t,c=e)}i({x:c.x/o,y:c.y/u,rating:c.rating,rd:c.rd,date:c.date,svgX:c.x})},[a,o,u]),T=(0,s.useCallback)(()=>{i(null)},[]);return(0,c.jsxs)(`div`,{children:[(0,c.jsxs)(`div`,{className:`mb-3 flex items-baseline gap-3`,children:[(0,c.jsx)(`span`,{className:`glk-metric glk-metric-lg text-zinc-900 dark:text-zinc-50`,children:Math.round(_.rating)}),(0,c.jsxs)(`span`,{className:`glk-tabular text-xs text-zinc-500 dark:text-zinc-400`,children:[`±`,Math.round(_.rd),(0,c.jsx)(l,{text:`Rating deviation — how uncertain the rating is. Lower = more confident. The shaded band shows this uncertainty range.`})]}),(0,c.jsxs)(`span`,{className:`glk-tabular text-xs font-bold ${b}`,children:[y>=0?`+`:``,Math.round(y)]}),(0,c.jsx)(`span`,{className:`text-2xs font-bold uppercase tracking-wider ${C}`,children:S}),t!=null&&(0,c.jsxs)(`span`,{className:`ml-auto flex items-baseline gap-1 text-xs text-zinc-500 dark:text-zinc-400`,children:[(0,c.jsx)(`span`,{className:`glk-eyebrow mr-1`,children:`Rank `}),(0,c.jsxs)(`span`,{className:`glk-tabular font-bold text-zinc-800 dark:text-zinc-100`,children:[`#`,t]}),(0,c.jsx)(`span`,{className:`text-2xs text-zinc-400`,children:`Global`})]})]}),(0,c.jsxs)(`div`,{className:`relative`,children:[(0,c.jsxs)(`svg`,{ref:n,viewBox:`0 0 ${o} ${u}`,className:`w-full`,preserveAspectRatio:`xMidYMid meet`,onMouseMove:w,onMouseLeave:T,style:{cursor:`crosshair`},children:[(0,c.jsx)(`defs`,{children:(0,c.jsxs)(`linearGradient`,{id:`ratingConfGrad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,c.jsx)(`stop`,{offset:`0%`,stopColor:`var(--glk-brand)`,stopOpacity:`0.12`}),(0,c.jsx)(`stop`,{offset:`50%`,stopColor:`var(--glk-brand)`,stopOpacity:`0.06`}),(0,c.jsx)(`stop`,{offset:`100%`,stopColor:`var(--glk-brand)`,stopOpacity:`0.12`})]})}),h.map((e,t)=>(0,c.jsxs)(`g`,{children:[(0,c.jsx)(`line`,{x1:36,y1:e.y,x2:o-36,y2:e.y,stroke:`currentColor`,strokeOpacity:`0.06`,strokeWidth:`1`}),(0,c.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,c.jsx)(`path`,{d:m,fill:`url(#ratingConfGrad)`}),(0,c.jsx)(`path`,{d,fill:`none`,stroke:`var(--glk-brand)`,strokeWidth:`2`,strokeLinecap:`round`}),g.map((e,t)=>(0,c.jsxs)(`g`,{children:[(0,c.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,c.jsx)(`circle`,{cx:e.x,cy:e.y,r:`3`,fill:e.isPositive?`var(--glk-win)`:`var(--glk-loss)`,opacity:`0.7`}),(0,c.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)),r&&(0,c.jsxs)(`g`,{children:[(0,c.jsx)(`line`,{x1:r.svgX,y1:16,x2:r.svgX,y2:u-24,stroke:`currentColor`,strokeOpacity:`0.15`,strokeWidth:`1`,strokeDasharray:`3 3`}),(0,c.jsx)(`circle`,{cx:r.svgX,cy:r.y*u,r:`4`,fill:`var(--glk-brand)`,stroke:`white`,strokeWidth:`2`,className:`dark:stroke-zinc-900`})]}),!r&&(0,c.jsx)(`circle`,{cx:_.x,cy:_.y,r:`4`,fill:`var(--glk-brand)`,stroke:`white`,strokeWidth:`2`,className:`dark:stroke-zinc-900`}),[a[0],a[Math.floor(a.length/2)],a[a.length-1]].map((e,t)=>(0,c.jsx)(`text`,{x:e.x,y:u-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))]}),r&&(0,c.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:`${r.x*100}%`,top:`${r.y*100}%`},children:[(0,c.jsx)(`div`,{className:`text-xs font-medium text-zinc-500 dark:text-zinc-400`,children:r.date}),(0,c.jsx)(`div`,{className:`glk-tabular text-sm font-bold text-zinc-900 dark:text-zinc-50`,children:Math.round(r.rating)}),(0,c.jsxs)(`div`,{className:`text-2xs text-zinc-400 dark:text-zinc-500`,children:[`±`,Math.round(r.rd),` RD`]})]})]})]})}export{d as n,l as r,m as t};