import{x as Xe,u as Ye,r as k,j as s,L as G,H as W,q as Je,y as Ze}from"./index-RvrzVxyQ.js";import{u as K}from"./useQuery-DBPiiCZh.js";import{a as Q}from"./api-5i4Mf2ca.js";import{S as ce}from"./skeleton-vJLXL7dU.js";import{A as et,a as tt}from"./alert-B6WjabOu.js";import{L as oe}from"./LatexTitle-CbOP0isa.js";import{I as rt}from"./components-vAXr5Yrz.js";import"./adminAuth-PI_XkM8E.js";import"./transform-C19D-_iA.js";function nt(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const r=document.implementation.createHTMLDocument(),n=r.createElement("base"),i=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(i),t&&(n.href=t),i.href=e,i.href}const st=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function B(e){const t=[];for(let r=0,n=e.length;rN||e.height>N)&&(e.width>N&&e.height>N?e.width>e.height?(e.height*=N/e.width,e.width=N):(e.width*=N/e.height,e.height=N):e.width>N?(e.height*=N/e.width,e.width=N):(e.width*=N/e.height,e.height=N))}function ot(e,t={}){return e.toBlob?new Promise(r=>{e.toBlob(r,t.type?t.type:"image/png",t.quality?t.quality:1)}):new Promise(r=>{const n=window.atob(e.toDataURL(t.type?t.type:void 0,t.quality?t.quality:void 0).split(",")[1]),i=n.length,a=new Uint8Array(i);for(let l=0;l{const n=new Image;n.onload=()=>{n.decode().then(()=>{requestAnimationFrame(()=>t(n))})},n.onerror=r,n.crossOrigin="anonymous",n.decoding="async",n.src=e})}async function ut(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function dt(e,t,r){const n="http://www.w3.org/2000/svg",i=document.createElementNS(n,"svg"),a=document.createElementNS(n,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${r}`),i.setAttribute("viewBox",`0 0 ${t} ${r}`),a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("x","0"),a.setAttribute("y","0"),a.setAttribute("externalResourcesRequired","true"),i.appendChild(a),a.appendChild(e),ut(i)}const T=(e,t)=>{if(e instanceof t)return!0;const r=Object.getPrototypeOf(e);return r===null?!1:r.constructor.name===t.name||T(r,t)};function ht(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function mt(e,t){return Be(t).map(r=>{const n=e.getPropertyValue(r),i=e.getPropertyPriority(r);return`${r}: ${n}${i?" !important":""};`}).join(" ")}function ft(e,t,r,n){const i=`.${e}:${t}`,a=r.cssText?ht(r):mt(r,n);return document.createTextNode(`${i}{${a}}`)}function Te(e,t,r,n){const i=window.getComputedStyle(e,r),a=i.getPropertyValue("content");if(a===""||a==="none")return;const l=st();try{t.className=`${t.className} ${l}`}catch{return}const c=document.createElement("style");c.appendChild(ft(l,r,i,n)),t.appendChild(c)}function pt(e,t,r){Te(e,t,":before",r),Te(e,t,":after",r)}const Le="application/font-woff",Fe="image/jpeg",gt={woff:Le,woff2:Le,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Fe,jpeg:Fe,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function yt(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function me(e){const t=yt(e).toLowerCase();return gt[t]||""}function xt(e){return e.split(/,/)[1]}function he(e){return e.search(/^(data:)/)!==-1}function bt(e,t){return`data:${t};base64,${e}`}async function Ve(e,t,r){const n=await fetch(e,t);if(n.status===404)throw new Error(`Resource "${n.url}" not found`);const i=await n.blob();return new Promise((a,l)=>{const c=new FileReader;c.onerror=l,c.onloadend=()=>{try{a(r({res:n,result:c.result}))}catch(d){l(d)}},c.readAsDataURL(i)})}const ue={};function wt(e,t,r){let n=e.replace(/\?.*/,"");return r&&(n=e),/ttf|otf|eot|woff2?/i.test(n)&&(n=n.replace(/.*\//,"")),t?`[${t}]${n}`:n}async function fe(e,t,r){const n=wt(e,t,r.includeQueryParams);if(ue[n]!=null)return ue[n];r.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{const a=await Ve(e,r.fetchRequestInit,({res:l,result:c})=>(t||(t=l.headers.get("Content-Type")||""),xt(c)));i=bt(a,t)}catch(a){i=r.imagePlaceholder||"";let l=`Failed to fetch resource: ${e}`;a&&(l=typeof a=="string"?a:a.message),l&&console.warn(l)}return ue[n]=i,i}async function vt(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):te(t)}async function jt(e,t){if(e.currentSrc){const a=document.createElement("canvas"),l=a.getContext("2d");a.width=e.clientWidth,a.height=e.clientHeight,l==null||l.drawImage(e,0,0,a.width,a.height);const c=a.toDataURL();return te(c)}const r=e.poster,n=me(r),i=await fe(r,n,t);return te(i)}async function St(e,t){var r;try{if(!((r=e==null?void 0:e.contentDocument)===null||r===void 0)&&r.body)return await re(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function kt(e,t){return T(e,HTMLCanvasElement)?vt(e):T(e,HTMLVideoElement)?jt(e,t):T(e,HTMLIFrameElement)?St(e,t):e.cloneNode(Ue(e))}const Ct=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",Ue=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function Et(e,t,r){var n,i;if(Ue(t))return t;let a=[];return Ct(e)&&e.assignedNodes?a=B(e.assignedNodes()):T(e,HTMLIFrameElement)&&(!((n=e.contentDocument)===null||n===void 0)&&n.body)?a=B(e.contentDocument.body.childNodes):a=B(((i=e.shadowRoot)!==null&&i!==void 0?i:e).childNodes),a.length===0||T(e,HTMLVideoElement)||await a.reduce((l,c)=>l.then(()=>re(c,r)).then(d=>{d&&t.appendChild(d)}),Promise.resolve()),t}function Rt(e,t,r){const n=t.style;if(!n)return;const i=window.getComputedStyle(e);i.cssText?(n.cssText=i.cssText,n.transformOrigin=i.transformOrigin):Be(r).forEach(a=>{let l=i.getPropertyValue(a);a==="font-size"&&l.endsWith("px")&&(l=`${Math.floor(parseFloat(l.substring(0,l.length-2)))-.1}px`),T(e,HTMLIFrameElement)&&a==="display"&&l==="inline"&&(l="block"),a==="d"&&t.getAttribute("d")&&(l=`path(${t.getAttribute("d")})`),n.setProperty(a,l,i.getPropertyPriority(a))})}function _t(e,t){T(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),T(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function $t(e,t){if(T(e,HTMLSelectElement)){const r=t,n=Array.from(r.children).find(i=>e.value===i.getAttribute("value"));n&&n.setAttribute("selected","")}}function Tt(e,t,r){return T(t,Element)&&(Rt(e,t,r),pt(e,t,r),_t(e,t),$t(e,t)),t}async function Lt(e,t){const r=e.querySelectorAll?e.querySelectorAll("use"):[];if(r.length===0)return e;const n={};for(let a=0;akt(n,t)).then(n=>Et(e,n,t)).then(n=>Tt(e,n,t)).then(n=>Lt(n,t))}const qe=/url\((['"]?)([^'"]+?)\1\)/g,Ft=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Nt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Mt(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function It(e){const t=[];return e.replace(qe,(r,n,i)=>(t.push(i),r)),t.filter(r=>!he(r))}async function At(e,t,r,n,i){try{const a=r?nt(t,r):t,l=me(t);let c;return i||(c=await fe(a,l,n)),e.replace(Mt(t),`$1${c}$3`)}catch{}return e}function Pt(e,{preferredFontFormat:t}){return t?e.replace(Nt,r=>{for(;;){const[n,,i]=Ft.exec(r)||[];if(!i)return"";if(i===t)return`src: ${n};`}}):e}function We(e){return e.search(qe)!==-1}async function Oe(e,t,r){if(!We(e))return e;const n=Pt(e,r);return It(n).reduce((a,l)=>a.then(c=>At(c,l,t,r)),Promise.resolve(n))}async function q(e,t,r){var n;const i=(n=t.style)===null||n===void 0?void 0:n.getPropertyValue(e);if(i){const a=await Oe(i,null,r);return t.style.setProperty(e,a,t.style.getPropertyPriority(e)),!0}return!1}async function Dt(e,t){await q("background",e,t)||await q("background-image",e,t),await q("mask",e,t)||await q("-webkit-mask",e,t)||await q("mask-image",e,t)||await q("-webkit-mask-image",e,t)}async function Bt(e,t){const r=T(e,HTMLImageElement);if(!(r&&!he(e.src))&&!(T(e,SVGImageElement)&&!he(e.href.baseVal)))return;const n=r?e.src:e.href.baseVal,i=await fe(n,me(n),t);await new Promise((a,l)=>{e.onload=a,e.onerror=t.onImageErrorHandler?(...d)=>{try{a(t.onImageErrorHandler(...d))}catch(p){l(p)}}:l;const c=e;c.decode&&(c.decode=a),c.loading==="lazy"&&(c.loading="eager"),r?(e.srcset="",e.src=i):e.href.baseVal=i})}async function Ht(e,t){const n=B(e.childNodes).map(i=>ze(i,t));await Promise.all(n).then(()=>e)}async function ze(e,t){T(e,Element)&&(await Dt(e,t),await Bt(e,t),await Ht(e,t))}function Vt(e,t){const{style:r}=e;t.backgroundColor&&(r.backgroundColor=t.backgroundColor),t.width&&(r.width=`${t.width}px`),t.height&&(r.height=`${t.height}px`);const n=t.style;return n!=null&&Object.keys(n).forEach(i=>{r[i]=n[i]}),e}const Ne={};async function Me(e){let t=Ne[e];if(t!=null)return t;const n=await(await fetch(e)).text();return t={url:e,cssText:n},Ne[e]=t,t}async function Ie(e,t){let r=e.cssText;const n=/url\(["']?([^"')]+)["']?\)/g,a=(r.match(/url\([^)]+\)/g)||[]).map(async l=>{let c=l.replace(n,"$1");return c.startsWith("https://")||(c=new URL(c,e.url).href),Ve(c,t.fetchRequestInit,({result:d})=>(r=r.replace(l,`url(${d})`),[l,d]))});return Promise.all(a).then(()=>r)}function Ae(e){if(e==null)return[];const t=[],r=/(\/\*[\s\S]*?\*\/)/gi;let n=e.replace(r,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const d=i.exec(n);if(d===null)break;t.push(d[0])}n=n.replace(i,"");const a=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,l="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",c=new RegExp(l,"gi");for(;;){let d=a.exec(n);if(d===null){if(d=c.exec(n),d===null)break;a.lastIndex=c.lastIndex}else c.lastIndex=a.lastIndex;t.push(d[0])}return t}async function Ut(e,t){const r=[],n=[];return e.forEach(i=>{if("cssRules"in i)try{B(i.cssRules||[]).forEach((a,l)=>{if(a.type===CSSRule.IMPORT_RULE){let c=l+1;const d=a.href,p=Me(d).then(u=>Ie(u,t)).then(u=>Ae(u).forEach(g=>{try{i.insertRule(g,g.startsWith("@import")?c+=1:i.cssRules.length)}catch(M){console.error("Error inserting rule from remote css",{rule:g,error:M})}})).catch(u=>{console.error("Error loading remote css",u.toString())});n.push(p)}})}catch(a){const l=e.find(c=>c.href==null)||document.styleSheets[0];i.href!=null&&n.push(Me(i.href).then(c=>Ie(c,t)).then(c=>Ae(c).forEach(d=>{l.insertRule(d,l.cssRules.length)})).catch(c=>{console.error("Error loading remote stylesheet",c)})),console.error("Error inlining remote css file",a)}}),Promise.all(n).then(()=>(e.forEach(i=>{if("cssRules"in i)try{B(i.cssRules||[]).forEach(a=>{r.push(a)})}catch(a){console.error(`Error while reading CSS rules from ${i.href}`,a)}}),r))}function qt(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>We(t.style.getPropertyValue("src")))}async function Wt(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=B(e.ownerDocument.styleSheets),n=await Ut(r,t);return qt(n)}function Ge(e){return e.trim().replace(/["']/g,"")}function Ot(e){const t=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(a=>{t.add(Ge(a))}),Array.from(n.children).forEach(a=>{a instanceof HTMLElement&&r(a)})}return r(e),t}async function zt(e,t){const r=await Wt(e,t),n=Ot(e);return(await Promise.all(r.filter(a=>n.has(Ge(a.style.fontFamily))).map(a=>{const l=a.parentStyleSheet?a.parentStyleSheet.href:null;return Oe(a.cssText,l,t)}))).join(` `)}async function Gt(e,t){const r=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await zt(e,t);if(r){const n=document.createElement("style"),i=document.createTextNode(r);n.appendChild(i),e.firstChild?e.insertBefore(n,e.firstChild):e.appendChild(n)}}async function Kt(e,t={}){const{width:r,height:n}=He(e,t),i=await re(e,t,!0);return await Gt(i,t),await ze(i,t),Vt(i,t),await dt(i,r,n)}async function Qt(e,t={}){const{width:r,height:n}=He(e,t),i=await Kt(e,t),a=await te(i),l=document.createElement("canvas"),c=l.getContext("2d"),d=t.pixelRatio||lt(),p=t.canvasWidth||r,u=t.canvasHeight||n;return l.width=p*d,l.height=u*d,t.skipAutoScale||ct(l),l.style.width=`${p}`,l.style.height=`${u}`,t.backgroundColor&&(c.fillStyle=t.backgroundColor,c.fillRect(0,0,l.width,l.height)),c.drawImage(a,0,0,l.width,l.height),l}async function Xt(e,t={}){const r=await Qt(e,t);return await ot(r)}const Pe="#ffffff";function Yt(e){if(typeof window>"u")return Pe;const t=window.getComputedStyle(e).backgroundColor;return!t||t==="rgba(0, 0, 0, 0)"||t==="transparent"?Pe:t}async function Jt(e){var r,n;if(typeof window>"u"||!((n=(r=window.navigator)==null?void 0:r.clipboard)!=null&&n.write))throw new Error("Clipboard image copy is not supported in this browser.");if(typeof window.ClipboardItem>"u")throw new Error("Clipboard image copy is not supported in this browser.");const t=await Xt(e,{pixelRatio:2,cacheBust:!0,backgroundColor:Yt(e)});if(!t)throw new Error("Failed to render screenshot.");await window.navigator.clipboard.write([new window.ClipboardItem({"image/png":t})])}const de=5;function Zt(e){if(!e)return null;const t=e.trim(),r=t.match(/^https?:\/\/(?:www\.)?arxiv\.org\/(?:abs|pdf)\/([^/?#]+)/i);if(r!=null&&r[1])return r[1].replace(/\.pdf$/i,"");const n=t.match(/^(?:https?:\/\/(?:www\.)?paperswithcode\.co)?\/paper\/([^/?#]+)/i);return(n==null?void 0:n[1])??null}const er=({points:e,metric:t})=>{const r=Ze(),[n,i]=k.useState(null),a=880,l=320,c=60,d=30,p=24,u=50,g=e.map(h=>h.value),M=Math.min(...g),I=Math.max(...g)-M||1,Y=a-c-d,_=l-p-u,ne=Y/Math.max(1,e.length-1),L=e.map((h,y)=>{const C=c+y*ne,$=(h.value-M)/I,P=p+_*(1-$);return{x:C,y:P,data:h}});let S=`M${L[0].x},${L[0].y}`;for(let h=1;hi(y=>y===h?null:y),se=h=>{h&&r(`/paper/${h}`)};return s.jsxs("svg",{width:"100%",viewBox:`0 0 ${a} ${l}`,style:{display:"block"},children:[s.jsx("text",{x:c-38,y:p+_/2,fontSize:"11",fontFamily:"var(--mono)",fill:"var(--ink-faint)",textAnchor:"middle",transform:`rotate(-90 ${c-38} ${p+_/2})`,children:t}),Array.from({length:J}).map((h,y)=>{const C=y/(J-1),$=p+_*(1-C),P=M+I*C;return s.jsxs("g",{children:[s.jsx("line",{x1:c,y1:$,x2:a-d,y2:$,stroke:"var(--hairline)",strokeWidth:"1"}),s.jsx("text",{x:c-10,y:$+4,fontSize:"11",fontFamily:"var(--mono)",fill:"var(--ink-faint)",textAnchor:"end",children:W(P)})]},y)}),L.map((h,y)=>s.jsx("text",{x:h.x,y:l-u+18,fontSize:"11",fontFamily:"var(--mono)",fill:"var(--ink-soft)",textAnchor:"middle",children:h.data.dateLabel},y)),s.jsx("path",{d:S,stroke:"var(--accent)",strokeWidth:"2",fill:"none",strokeLinejoin:"round",strokeLinecap:"round"}),L.map((h,y)=>{const C=n===y,P=`${h.data.modelName||h.data.paperTitle||"Unknown model"}: ${W(h.data.value)} on ${h.data.dateLabel}`,F=!!h.data.paperRouteId;return s.jsxs("g",{children:[s.jsx("circle",{cx:h.x,cy:h.y,r:C?6:4.5,fill:C?"var(--accent)":"var(--bg-elevated)",stroke:"var(--accent)",strokeWidth:"2",style:{transition:"r 0.12s ease, fill 0.12s ease"}}),s.jsx("circle",{cx:h.x,cy:h.y,r:"14",fill:"transparent",style:{cursor:F?"pointer":"default",outline:"none"},tabIndex:0,role:F?"link":"img","aria-label":P,onMouseEnter:()=>i(y),onMouseLeave:()=>x(y),onFocus:()=>i(y),onBlur:()=>x(y),onClick:()=>se(h.data.paperRouteId),onKeyDown:b=>{F&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),se(h.data.paperRouteId))},children:s.jsx("title",{children:P})})]},y)}),n!==null&&(()=>{const h=L[n],y=h.data.modelName||h.data.paperTitle||"Unknown model",C=y.length>40?y.slice(0,39)+"…":y,$=`${W(h.data.value)} · ${h.data.dateLabel}`,F=Math.max(140,Math.min(320,Math.max(C.length,$.length)*6.6+24)),b=46;let A=h.x-F/2;Aa-d&&(A=a-d-F);const E=h.y-b-14>=p?h.y-b-12:h.y+12;return s.jsxs("g",{pointerEvents:"none",children:[s.jsx("rect",{x:A,y:E,width:F,height:b,rx:"6",ry:"6",fill:"var(--bg-elevated)",stroke:"var(--hairline-strong)",strokeWidth:"1",style:{filter:"drop-shadow(0 2px 6px rgba(0,0,0,0.08))"}}),s.jsx("text",{x:A+12,y:E+19,fontSize:"12",fontFamily:"var(--sans)",fill:"var(--ink)",fontWeight:500,children:C}),s.jsx("text",{x:A+12,y:E+36,fontSize:"11",fontFamily:"var(--mono)",fill:"var(--ink-soft)",children:$})]})})()]})};function X(e){if(e==null)return null;if(typeof e=="number")return Number.isFinite(e)?e:null;const t=e.includes("±")?e.split("±")[0].trim():e.trim(),r=parseFloat(t);return Number.isFinite(r)?r:null}function tr(e,t,r){if(e.length===0)return{points:[],sota:0,sotaModel:""};const n=e.map(u=>{var O;const g=X((O=u.metrics)==null?void 0:O[t]),M=u.paper_published_date||"";return{eval:u,value:g,date:M}}).filter(u=>u.value!==null&&!!u.date).sort((u,g)=>u.date.localeCompare(g.date)),i=[];let a=null;for(const u of n)(a==null?!0:r==="↓"?u.valuea)&&(a=u.value,i.push({value:u.value,dateLabel:u.date.slice(0,7),modelName:u.eval.model_name||"",paperTitle:u.eval.paper_title||"",paperRouteId:u.eval.paper_arxiv_id||u.eval.paper_id||null}));const c=e.map(u=>{var g;return{eval:u,value:X((g=u.metrics)==null?void 0:g[t])}}).filter(u=>u.value!==null).sort((u,g)=>r==="↓"?u.value-g.value:g.value-u.value)[0],d=(c==null?void 0:c.value)??0,p=(c==null?void 0:c.eval.model_name)||(c==null?void 0:c.eval.paper_title)||"";return{points:i,sota:d,sotaModel:p}}const De=({targetRef:e,label:t})=>{const{toast:r}=Je(),[n,i]=k.useState("idle"),a=k.useRef(null);k.useEffect(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);const l=k.useCallback(async()=>{const d=e.current;if(d){i("copying"),d.classList.add("is-capturing"),d.offsetHeight,await new Promise(p=>window.requestAnimationFrame(()=>p()));try{await Jt(d),i("copied"),r({title:"Screenshot copied",description:`Image of the ${t} copied to your clipboard.`}),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>i("idle"),1500)}catch(p){i("idle"),r({title:"Copy failed",description:p instanceof Error&&p.message?p.message:"Could not copy the screenshot to your clipboard.",variant:"destructive"})}finally{d.classList.remove("is-capturing")}}},[e,t,r]),c=n==="copied"?"Copied":n==="copying"?"Copying…":"Copy image";return s.jsxs("button",{type:"button",className:"bm-copy-btn",onClick:l,disabled:n==="copying","aria-label":`Copy ${t} screenshot to clipboard`,title:`Copy ${t} screenshot to clipboard`,children:[s.jsx(rt,{name:"copy",size:11}),c]})},dr=()=>{var pe,ge,ye,xe,be,we,ve,je,Se,ke;const{datasetSlug:e}=Xe(),[t]=Ye(),r=t.get("task")||void 0,n=t.get("eval")||void 0,[i,a]=k.useState(void 0),l=k.useRef(null),c=k.useRef(!1),d=k.useRef(null),p=k.useRef(null),u=K({queryKey:["dataset",e,"with-paper"],queryFn:()=>Q.getDatasetBySlug(e,{include_paper:!0}),enabled:!!e,staleTime:10*60*1e3}),g=K({queryKey:["dataset-evals",(pe=u.data)==null?void 0:pe.id],queryFn:()=>Q.getEvaluationsByDataset(u.data.id),enabled:!!((ge=u.data)!=null&&ge.id),staleTime:5*60*1e3}),M=K({queryKey:["dataset-tasks",(ye=u.data)==null?void 0:ye.id],queryFn:()=>Q.getDatasetTasks(u.data.id),enabled:!!((xe=u.data)!=null&&xe.id),staleTime:10*60*1e3}),O=K({queryKey:["metric-directions"],queryFn:()=>Q.getMetricDirections(),staleTime:60*60*1e3}),I=k.useMemo(()=>{const o=M.data||[];if(o.length===0)return null;if(r){const f=o.find(v=>v.slug===r);if(f)return f.id}if(o.length===1)return o[0].id;const m=g.data||[];if(m.length>0){const f=new Map;for(const j of m)f.set(j.task_id,(f.get(j.task_id)||0)+1);let v=null,w=-1;for(const j of o){const D=f.get(j.id)||0;D>w&&(w=D,v=j.id)}if(v)return v}return o[0].id},[M.data,g.data,r]),Y=K({queryKey:["leaderboard-metrics",(be=u.data)==null?void 0:be.id,I],queryFn:()=>Q.getLeaderboardMetrics(u.data.id,I),enabled:!!((we=u.data)!=null&&we.id)&&!!I,staleTime:10*60*1e3}),_=k.useMemo(()=>{const o=g.data||[];return I?o.filter(m=>m.task_id===I):o},[g.data,I]),ne=k.useMemo(()=>{const o=new Set;return _.forEach(m=>{m.best_metric&&o.add(m.best_metric),Object.keys(m.metrics||{}).forEach(f=>o.add(f))}),Array.from(o)},[_]),L=k.useMemo(()=>(Y.data||[]).map(o=>o.metric_name),[Y.data]),S=L.length?L:ne,J=k.useMemo(()=>{var v;if(_.length===0)return S[0]||"";const o=new Map;for(const w of _)w.best_metric&&(L.length&&!S.includes(w.best_metric)||o.set(w.best_metric,(o.get(w.best_metric)||0)+1));let m=null,f=0;for(const[w,j]of o)j>f&&(f=j,m=w);return m||S[0]||((v=_[0])==null?void 0:v.best_metric)||""},[_,S,L]),x=i||J,h=(((je=(ve=O.data)==null?void 0:ve.directions)==null?void 0:je[x])||"higher_is_better")==="lower_is_better"?"↓":"↑",y=k.useMemo(()=>{if(S.length===0)return x?[x]:[];if(S.length<=de)return S;const o=[],m=x&&S.includes(x),f=m?de-1:de;let v=0;for(const w of S)w!==x&&(v>=f||(o.push(w),v++));if(m){const w=S.findIndex(D=>D===x),j=S.slice(0,w).filter(D=>o.includes(D)).length;o.splice(j,0,x)}return o},[S,x]),{points:C,sota:$,sotaModel:P}=k.useMemo(()=>tr(_,x,h),[_,x,h]);k.useEffect(()=>{if(c.current||!n||!g.data||g.data.length===0)return;const o=l.current;o&&(c.current=!0,o.scrollIntoView({behavior:"smooth",block:"start"}))},[n,g.data]);const F=k.useMemo(()=>{const o=M.data||[];return I?o.find(m=>m.id===I)||o[0]||null:o[0]||null},[M.data,I]);if(u.isLoading)return s.jsxs("div",{className:"page",children:[s.jsx(ce,{className:"h-12 w-1/2 mb-6"}),s.jsx(ce,{className:"h-64 w-full"})]});if(u.error||!u.data)return s.jsx("div",{className:"page",children:s.jsx(et,{variant:"destructive",children:s.jsx(tt,{children:"Benchmark not found."})})});const b=u.data,A=_.slice().sort((o,m)=>{var w,j;const f=X((w=o.metrics)==null?void 0:w[x]),v=X((j=m.metrics)==null?void 0:j[x]);return f!==null&&v!==null?h==="↓"?f-v:v-f:f!==null?-1:v!==null?1:(o.best_rank??9999)-(m.best_rank??9999)}),ae=!!b.supports_harness,E=n&&A.find(o=>o.id===n)||null,R=b.introducing_paper??void 0,z=(R==null?void 0:R.arxiv_id)||(R==null?void 0:R.id)||Zt(b.paper_url),H=(R==null?void 0:R.title)||b.introducing_paper_title||null,V=((Se=R==null?void 0:R.published)==null?void 0:Se.slice(0,4))||b.introduced_year||null,Ke=!!z||!!b.paper_url||!!H,Qe=R!=null&&R.arxiv_id||(ke=b.paper_url)!=null&&ke.match(/^https?:\/\/(?:www\.)?arxiv\.org\//i)?`arXiv:${z}`:`Paper ${z}`;return s.jsx("div",{className:"page",children:s.jsxs("div",{className:"bm-page",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx(G,{to:"/tasks",children:"Tasks"}),F&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"sep",children:"/"}),s.jsx(G,{to:`/tasks/${F.slug||F.id}`,children:F.name})]}),s.jsx("span",{className:"sep",children:"/"}),s.jsx("span",{style:{color:"var(--accent-text)"},children:b.name})]}),s.jsx("h1",{className:"bm-title",children:b.name}),s.jsxs("div",{className:"bm-subtitle",children:[x&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"metric-tag",children:x}),s.jsx("span",{style:{color:"var(--hairline-strong)",margin:"0 8px"},children:"·"})]}),P?s.jsxs("span",{children:["Best: ",s.jsx("span",{className:"best-name",children:W($)})," by ",s.jsx("span",{className:"best-name",style:{fontStyle:"normal"},children:P})]}):s.jsxs("span",{children:[A.length," evaluations"]})]}),b.description&&s.jsx("p",{style:{fontFamily:"var(--serif)",color:"var(--ink-soft)",maxWidth:760,marginBottom:16},children:b.description}),Ke&&s.jsxs("div",{className:"method-source",style:{marginTop:0,marginBottom:18},children:[s.jsx("span",{className:"method-source-label",children:"Source"}),z?s.jsxs(G,{to:`/paper/${z}`,target:"_blank",rel:"noopener noreferrer",className:"method-source-link",children:[s.jsx("span",{className:"method-source-title",children:H?s.jsx(oe,{title:H}):Qe}),V&&s.jsx("span",{className:"method-source-meta",children:V})]}):b.paper_url?s.jsxs("a",{href:b.paper_url,target:"_blank",rel:"noopener noreferrer",className:"method-source-link",children:[s.jsx("span",{className:"method-source-title",children:H?s.jsx(oe,{title:H}):b.paper_url}),V&&s.jsx("span",{className:"method-source-meta",children:V})]}):s.jsxs("div",{className:"method-source-link is-static",children:[s.jsx("span",{className:"method-source-title",children:H?s.jsx(oe,{title:H}):null}),V&&s.jsx("span",{className:"method-source-meta",children:V})]})]}),C.length>=2&&s.jsxs("div",{className:"bm-card",ref:d,children:[s.jsxs("div",{className:"bm-card-screenshot-title","aria-hidden":"true",children:[s.jsx("span",{className:"bm-card-screenshot-eyebrow",children:"Benchmark"}),s.jsx("span",{className:"bm-card-screenshot-name",children:b.name})]}),s.jsxs("div",{className:"bm-card-head",children:[s.jsx("div",{className:"bm-card-title",children:"SOTA progression"}),s.jsxs("div",{className:"bm-card-actions",children:[S.length>1&&s.jsxs("label",{className:"bm-view-select",children:[s.jsx("span",{className:"bm-view-select-label",children:"View"}),s.jsx("select",{value:x,onChange:o=>a(o.target.value),children:S.map(o=>s.jsx("option",{value:o,children:o},o))})]}),s.jsx(De,{targetRef:d,label:"SOTA chart"})]})]}),s.jsx("div",{className:"bm-chart-wrap",children:s.jsx(er,{points:C,metric:x})}),s.jsxs("div",{className:"bm-chart-foot",children:[s.jsx("span",{className:"legend-dot"}),"Best result over time · hover a point to see the model · click to open the paper"]})]}),E&&(()=>{var w,j;const o=E.paper_arxiv_id||E.paper_id,m=E.paper_title||(E.paper_arxiv_id?`arXiv:${E.paper_arxiv_id}`:null),f=E.best_metric&&((w=E.metrics)==null?void 0:w[E.best_metric])!==void 0?E.best_metric:x,v=(j=E.metrics)==null?void 0:j[f];return s.jsxs("div",{className:"bm-highlight-banner",role:"status",children:[s.jsx("span",{className:"bm-highlight-dot","aria-hidden":"true"}),s.jsxs("div",{className:"bm-highlight-text",children:[s.jsx("span",{className:"bm-highlight-label",children:"Comparing result"}),s.jsxs("span",{className:"bm-highlight-paper",children:[E.model_name||m||"—",E.harness?` · ${E.harness}`:""]}),s.jsxs("span",{className:"bm-highlight-meta",children:[v!==void 0&&f?s.jsxs(s.Fragment,{children:[f,": ",W(v),m?" · ":""]}):null,m&&o?s.jsx(G,{to:`/paper/${o}`,children:m}):m||null]})]})]})})(),s.jsxs("div",{className:"bm-card",ref:p,children:[s.jsxs("div",{className:"bm-card-screenshot-title","aria-hidden":"true",children:[s.jsx("span",{className:"bm-card-screenshot-eyebrow",children:"Benchmark"}),s.jsx("span",{className:"bm-card-screenshot-name",children:b.name})]}),s.jsxs("div",{className:"bm-card-head",children:[s.jsx("div",{className:"bm-card-title",children:"Leaderboard"}),s.jsxs("div",{className:"bm-card-actions",children:[S.length>1&&s.jsxs("label",{className:"bm-view-select",children:[s.jsx("span",{className:"bm-view-select-label",children:"View"}),s.jsx("select",{value:x,onChange:o=>a(o.target.value),children:S.map(o=>s.jsx("option",{value:o,children:o},o))})]}),s.jsx(De,{targetRef:p,label:"leaderboard"})]})]}),g.isLoading?s.jsx("div",{style:{padding:16},children:Array.from({length:5}).map((o,m)=>s.jsx(ce,{className:"h-10 w-full mb-2"},m))}):A.length===0?s.jsx("div",{className:"no-results",children:"No evaluations submitted yet."}):s.jsxs("table",{className:"bm-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"col-rank",children:"Rank"}),s.jsx("th",{className:"col-model",children:"Model"}),ae&&s.jsx("th",{className:"col-harness",children:"Harness"}),y.map(o=>{const m=o===x;return s.jsx("th",{className:`col-value ${m?"is-active":""}`,"aria-sort":m?h==="↓"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"bm-metric-header",onClick:()=>a(o),"aria-pressed":m,title:`Sort by ${o}`,children:[o,m?` ${h}`:""]})},o)}),s.jsx("th",{className:"col-paper",children:"Paper"}),s.jsx("th",{className:"col-year",children:"Year"})]})}),s.jsx("tbody",{children:(()=>{let o=null,m=0;return A.map((f,v)=>{var Ee,Re;const w=X((Ee=f.metrics)==null?void 0:Ee[x]);let j=null;w!==null&&((o===null||w!==o)&&(m=v+1,o=w),j=m);const D=f.paper_arxiv_id||f.paper_id,Ce=f.paper_title||(f.paper_arxiv_id?`arXiv:${f.paper_arxiv_id}`:null),ie=n===f.id;return s.jsxs("tr",{ref:ie?l:void 0,className:ie?"is-highlighted":void 0,children:[s.jsx("td",{className:"col-rank",children:j??"—"}),s.jsxs("td",{className:"col-model",children:[ie&&s.jsx("span",{className:"bm-row-marker","aria-hidden":"true"}),f.model_name||"—"]}),ae&&s.jsx("td",{className:"col-harness",children:f.harness||"—"}),y.map(le=>{var $e;const _e=le===x,Z=($e=f.metrics)==null?void 0:$e[le];return s.jsx("td",{className:`col-value${_e?" is-active":""}${_e&&j===1?" is-best":""}`,children:Z!=null&&Z!==""?W(Z):"—"},le)}),s.jsx("td",{className:"col-paper",children:D?s.jsx(G,{to:`/paper/${D}`,children:Ce||"—"}):Ce||"—"}),s.jsx("td",{className:"col-year",children:((Re=f.paper_published_date)==null?void 0:Re.slice(0,4))||"—"})]},f.id)})})()})]})]})]})})};export{dr as default};