diff --git "a/assets/PaperDetailView-DEVQpo7C.js" "b/assets/PaperDetailView-DEVQpo7C.js" deleted file mode 100644--- "a/assets/PaperDetailView-DEVQpo7C.js" +++ /dev/null @@ -1,29 +0,0 @@ -import{d as Nt,m as la,r as h,j as e,P as fs,n as _e,o as gs,p as Ue,q as Te,s as xs,t as Ct,C as je,v as Je,k as he,h as pe,X as Et,w as ve,x as ca,y as bs,z as da,B as ua,D as ma,E as ha,F as pa,G as ss,H as fa,I as ga,J as xa,K as ba,M as ja,g as We,R as Xe,A as jt,c as re,N as js,e as vs,O as va,Q as ya,S as _a,T as ys,U as ka,V as wa,W as Na,Y as Ca,f as Ea,Z as Sa,u as Ia,_ as Pa,L as xe,$ as $a,a0 as Aa,a1 as Ra,a2 as Fa,a3 as Ta,a4 as La,a5 as Ua}from"./index-D9_nPZtO.js";import{u as ne}from"./useQuery-cycUreG-.js";import{I as J,S as Da,a as Ba,T as Ha,M as Ma}from"./components-DrTew0nD.js";import{C as za,E as qa}from"./ExternalSourceEvalBadge-Cu4mN0M9.js";import{L as qe,a as Oa}from"./LatexTitle-BtRWGRIx.js";import{s as Ka}from"./transform-BObV5jzB.js";import{f as Ga,D as Qa}from"./latexPlainText-DI8YEXVe.js";import{a as Va}from"./usePapers-B3J6SKWU.js";import{S as Re}from"./skeleton-CQ2CM4l9.js";import{A as Ja,a as Xa}from"./alert-B0bcMmNw.js";import{B as H}from"./button-B859643f.js";import{u as _s}from"./index-BGBxtSYH.js";import{I as Z}from"./textarea-BVF3ykiv.js";import{D as oe,a as le,b as ce,c as de,d as ue,e as me}from"./dialog-DnjY6ZOM.js";import{u as fe}from"./useMutation-CJCfaNMQ.js";import{S as St,P as Ye,L as ae,a as Wa}from"./SignInToEditDialog-NNf7Zp6R.js";import{S as Le,a as as}from"./searchable-select-Css_GGu3.js";import{L as ie}from"./loader-circle-CrVj12oC.js";import{B as ks,D as Ya,c as Za,g as er,s as tr,a as sr,b as ar,d as rr,i as nr,e as ir}from"./codexAddEvals-Xch_LMp1.js";import{n as ot,g as rs}from"./github-DYxu-4Fs.js";import{G as ns}from"./github-DngRIean.js";import{S as is,s as or}from"./savedPapersAuth-DSXf00GL.js";import{M as lr,r as cr}from"./index-XzA0bTLC.js";import{s as Ne}from"./safeExternalHref-CkBrsh84.js";import"./hover-card-DVeX2fQl.js";import"./katex.min-BSBacQyE.js";import"./useInfiniteQuery-CQNVzwuX.js";/** - * @license lucide-react v0.462.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const os=Nt("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** - * @license lucide-react v0.462.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ws=Nt("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/** - * @license lucide-react v0.462.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ze=Nt("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);function dr(t){return t!=null&&t.can_directly_edit_catalog?"direct":"pending"}function ur(t){return(t??[]).filter(a=>!!(a.dataset_slug&&a.task_slug))}function mr(t,a,n="https://paperswithcode.co"){return a.map(l=>{const i=encodeURIComponent(l.evaluation_id),c=`${n}/api/v1/papers/${encodeURIComponent(t)}/leaderboard-badge.svg?eval=${i}&live=1`,o=`${n}/api/v1/papers/${encodeURIComponent(t)}/leaderboard-badge-link?eval=${i}`;return`[![${`Papers with Code: ${l.best_rank===1?"SOTA":`#${l.best_rank}`} on ${l.dataset_name}`}](${c})](${o})`}).join(` -`)}function hr(t,a=!0){return ne({queryKey:["evaluations","paper",t],queryFn:()=>{if(!t)throw new Error("Paper ID is required");return la(t)},enabled:a&&!!t,staleTime:0,refetchOnMount:"always"})}const Ns=t=>t.replace(/v\d+$/,""),pr={models:"https://huggingface.co/",datasets:"https://huggingface.co/datasets/",spaces:"https://huggingface.co/spaces/"},lt=(t,a)=>{const n=(t[a]||[]).length;return n<100?{count:n,isLimited:!1}:{count:n,isLimited:!0}},ct=(t,a)=>{const n=t[a];return Array.isArray(n)?n.map(l=>{if(typeof l=="string")return l;if(l&&typeof l=="object"){const i=l;return i.id||i.repoId||null}return null}).filter(l=>!!l).map(l=>`${pr[a]}${l}`):[]},fr=async t=>{try{return(await fetch(`https://huggingface.co/api/papers/${Ns(t)}`)).ok}catch{return!1}},gr=async t=>{const a=Ns(t),[n,l]=await Promise.all([fetch(`https://huggingface.co/api/arxiv/${a}/repos`).then(async x=>x.ok?x.json():(console.warn(`Failed to fetch repos for arXiv:${a}, status: ${x.status}`),null)).catch(x=>(console.warn(`Failed to fetch repos for arXiv:${a}:`,x),null)),fr(a)]);if(!n)return{models:0,datasets:0,spaces:0,modelUrls:[],datasetUrls:[],spaceUrls:[],isLimited:!1,paperExists:l};const i=lt(n,"models"),c=lt(n,"datasets"),o=lt(n,"spaces");return{models:i.count,datasets:c.count,spaces:o.count,modelUrls:ct(n,"models"),datasetUrls:ct(n,"datasets"),spaceUrls:ct(n,"spaces"),isLimited:i.isLimited||c.isLimited||o.isLimited,paperExists:l}},xr=t=>ne({queryKey:["huggingface-repos",t],queryFn:()=>gr(t),enabled:!!t,staleTime:10*60*1e3,retry:1}),br={tasks:"tasks",methods:"methods",evaluations:"results",repositories:"repositories",project_pages:"project-pages",hf_artifacts:"hf-artifacts",organizations:"organizations",source_url:"source-url"};function jr(t){return br[t]??null}function vr(){const[t,a]=h.useState(null),n=h.useCallback(i=>{a(i)},[]),l=h.useCallback((i,c)=>{a(o=>c?i:o===i?null:o)},[]);return{activeEditor:t,openEditor:n,setEditorOpen:l}}var et="Checkbox",[yr]=Ct(et),[_r,It]=yr(et);function kr(t){const{__scopeCheckbox:a,checked:n,children:l,defaultChecked:i,disabled:c,form:o,name:x,onCheckedChange:u,required:s,value:w="on",internal_do_not_use_render:k}=t,[I,N]=gs({prop:n,defaultProp:i??!1,onChange:u,caller:et}),[$,p]=h.useState(null),[T,L]=h.useState(null),R=h.useRef(!1),B=$?!!o||!!$.closest("form"):!0,D={checked:I,disabled:c,setChecked:N,control:$,setControl:p,name:x,form:o,value:w,hasConsumerStoppedPropagationRef:R,required:s,defaultChecked:be(i)?!1:i,isFormControl:B,bubbleInput:T,setBubbleInput:L};return e.jsx(_r,{scope:a,...D,children:wr(k)?k(D):l})}var Cs="CheckboxTrigger",Es=h.forwardRef(({__scopeCheckbox:t,onKeyDown:a,onClick:n,...l},i)=>{const{control:c,value:o,disabled:x,checked:u,required:s,setControl:w,setChecked:k,hasConsumerStoppedPropagationRef:I,isFormControl:N,bubbleInput:$}=It(Cs,t),p=Ue(i,w),T=h.useRef(u);return h.useEffect(()=>{const L=c==null?void 0:c.form;if(L){const R=()=>k(T.current);return L.addEventListener("reset",R),()=>L.removeEventListener("reset",R)}},[c,k]),e.jsx(_e.button,{type:"button",role:"checkbox","aria-checked":be(u)?"mixed":u,"aria-required":s,"data-state":As(u),"data-disabled":x?"":void 0,disabled:x,value:o,...l,ref:p,onKeyDown:Te(a,L=>{L.key==="Enter"&&L.preventDefault()}),onClick:Te(n,L=>{k(R=>be(R)?!0:!R),$&&N&&(I.current=L.isPropagationStopped(),I.current||L.stopPropagation())})})});Es.displayName=Cs;var Pt=h.forwardRef((t,a)=>{const{__scopeCheckbox:n,name:l,checked:i,defaultChecked:c,required:o,disabled:x,value:u,onCheckedChange:s,form:w,...k}=t;return e.jsx(kr,{__scopeCheckbox:n,checked:i,defaultChecked:c,disabled:x,required:o,onCheckedChange:s,name:l,form:w,value:u,internal_do_not_use_render:({isFormControl:I})=>e.jsxs(e.Fragment,{children:[e.jsx(Es,{...k,ref:a,__scopeCheckbox:n}),I&&e.jsx($s,{__scopeCheckbox:n})]})})});Pt.displayName=et;var Ss="CheckboxIndicator",Is=h.forwardRef((t,a)=>{const{__scopeCheckbox:n,forceMount:l,...i}=t,c=It(Ss,n);return e.jsx(fs,{present:l||be(c.checked)||c.checked===!0,children:e.jsx(_e.span,{"data-state":As(c.checked),"data-disabled":c.disabled?"":void 0,...i,ref:a,style:{pointerEvents:"none",...t.style}})})});Is.displayName=Ss;var Ps="CheckboxBubbleInput",$s=h.forwardRef(({__scopeCheckbox:t,...a},n)=>{const{control:l,hasConsumerStoppedPropagationRef:i,checked:c,defaultChecked:o,required:x,disabled:u,name:s,value:w,form:k,bubbleInput:I,setBubbleInput:N}=It(Ps,t),$=Ue(n,N),p=_s(c),T=xs(l);h.useEffect(()=>{const R=I;if(!R)return;const B=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(B,"checked").set,d=!i.current;if(p!==c&&_){const f=new Event("click",{bubbles:d});R.indeterminate=be(c),_.call(R,be(c)?!1:c),R.dispatchEvent(f)}},[I,p,c,i]);const L=h.useRef(be(c)?!1:c);return e.jsx(_e.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??L.current,required:x,disabled:u,name:s,value:w,form:k,...a,tabIndex:-1,ref:$,style:{...a.style,...T,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});$s.displayName=Ps;function wr(t){return typeof t=="function"}function be(t){return t==="indeterminate"}function As(t){return be(t)?"indeterminate":t?"checked":"unchecked"}const tt=h.forwardRef(({className:t,style:a,...n},l)=>e.jsx(Pt,{ref:l,className:Je("peer h-4 w-4 shrink-0 rounded-sm ring-offset-background data-[state=checked]:!bg-black data-[state=checked]:!text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),style:{border:"1px solid #000",...a},...n,children:e.jsx(Is,{className:Je("flex items-center justify-center text-current"),children:e.jsx(je,{className:"h-4 w-4"})})}));tt.displayName=Pt.displayName;function Nr(t,a,n){if(!t)return t;const l=i=>i.paper_id!==a||i.paper_title===n?i:{...i,paper_title:n};if(Array.isArray(t)){const i=t.map(l);return i.some((o,x)=>o!==t[x])?i:t}if(Array.isArray(t.results)){const i=t.results.map(l);return i.some((o,x)=>o!==t.results[x])?{...t,results:i}:t}return t}function Ee(t,a,n){new Set([...n,a.id,a.arxiv_id].filter(o=>!!o)).forEach(o=>{t.setQueryData(["paper",o],a),t.setQueryData(["paper-arxiv",o],a)}),t.invalidateQueries({queryKey:["papers"],refetchType:"none"}),t.invalidateQueries({queryKey:["papers-infinite"],refetchType:"none"}),t.invalidateQueries({queryKey:["task-papers-infinite"],refetchType:"none"});const i=String(a.id),c=o=>Nr(o,i,a.title);t.setQueriesData({queryKey:["evaluations"]},c),t.setQueriesData({queryKey:["dataset-evals"]},c),t.invalidateQueries({queryKey:["evaluations"],refetchType:"none"}),t.invalidateQueries({queryKey:["dataset-evals"],refetchType:"none"})}function ye({isAuthor:t=!1}){const a=typeof window<"u"&&window.location.hostname==="staging.paperswithcode.co";return e.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-100",children:[e.jsx("p",{className:"font-medium",children:a?"Test-only: this change stays on staging.":"Your changes will be reviewed by an admin."}),e.jsx("p",{className:"mt-1 leading-snug",children:a?"This exercises staging-local pending behavior and is not queued for production review.":t?"We can see this paper is yours. While we're in early access an admin still reviews each edit; this will become automatic for authors soon.":"Submissions are queued for review and don't change the paper page until an admin approves them."})]})}const Cr=250,Er=100;function Sr({open:t,onOpenChange:a,paperId:n,arxivId:l,initialTaskIds:i,initialTasks:c,onSuccess:o,submitMode:x="direct",isAuthor:u=!1}){const[s,w]=h.useState(i),[k,I]=h.useState(!1),[N,$]=h.useState(""),[p,T]=h.useState(""),[L,R]=h.useState(new Map),B=he(),{toast:D}=pe(),_=h.useRef(!1);h.useEffect(()=>{if(!t){_.current=!1;return}if(_.current)return;_.current=!0,w(i),$(""),T("");const m=new Map;(c||[]).forEach(C=>{const P=parseInt(C.id);Number.isNaN(P)||m.set(P,C)}),R(m)},[t,i,c]),h.useEffect(()=>{const m=window.setTimeout(()=>{T(N.trim())},Cr);return()=>window.clearTimeout(m)},[N]);const{data:d,isFetching:f}=ne({queryKey:["tasks-search",p],queryFn:()=>bs({page_size:Er,...p?{q:p}:{}}),enabled:t});h.useEffect(()=>{var m;(m=d==null?void 0:d.results)!=null&&m.length&&R(C=>{const P=new Map(C);return d.results.forEach(U=>{const E=parseInt(U.id);Number.isNaN(E)||P.set(E,U)}),P})},[d]);const v=h.useMemo(()=>{const m=(d==null?void 0:d.results)||[],C=new Set,P=[];return s.forEach(U=>{if(C.has(U))return;const E=L.get(U);E&&(P.push(E),C.add(U))}),m.forEach(U=>{const E=parseInt(U.id);Number.isNaN(E)||C.has(E)||(P.push(U),C.add(E))}),P},[d,s,L]),F=fe({mutationFn:async({paperId:m,taskIds:C})=>x==="pending"?(await ve({paper_id:parseInt(m),edit_type:"tasks",proposed_payload:{task_ids:C}}),null):ca(m,C),onMutate:async({taskIds:m})=>{if(x==="pending")return{snapshots:[]};const C=m.map(E=>L.get(E)).filter(E=>!!E).map(E=>({id:E.id,name:E.name,slug:E.slug})).sort((E,z)=>E.name.localeCompare(z.name)),P=Array.from(new Set([n,l].filter(E=>!!E)));await Promise.all(P.flatMap(E=>[B.cancelQueries({queryKey:["paper",E]}),B.cancelQueries({queryKey:["paper-arxiv",E]})]));const U=[];return P.forEach(E=>{["paper","paper-arxiv"].forEach(z=>{const W=[z,E],g=B.getQueryData(W);U.push({key:W,data:g}),g&&B.setQueryData(W,{...g,tasks:C})})}),D({title:"Tasks updated",description:`Saved ${m.length} task${m.length===1?"":"s"} for this paper.`}),o==null||o(),a(!1),{snapshots:U}},onSuccess:m=>{if(x==="pending"){D({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed task changes shortly."}),o==null||o(),a(!1);return}m&&Ee(B,m,[n,l])},onError:(m,C,P)=>{var z,W;(z=P==null?void 0:P.snapshots)==null||z.forEach(({key:g,data:S})=>{B.setQueryData(g,S)});const U=m;let E=U.message||(x==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper tasks.");if(U.response)try{const g=JSON.parse(U.response);typeof(g==null?void 0:g.detail)=="string"?E=g.detail:Array.isArray(g==null?void 0:g.detail)&&((W=g.detail[0])!=null&&W.msg)&&(E=g.detail[0].msg)}catch{E=U.response}D({title:x==="pending"?"Could not submit edit":"Could not save tasks",description:E,variant:"destructive"})}}),O=()=>{x==="direct"&&i.some(m=>!s.includes(m))&&!window.confirm("Remove one or more task links from this paper?")||F.mutate({paperId:n,taskIds:s})},K=h.useMemo(()=>{if(s.length!==i.length)return!0;const m=new Set(i);return s.some(C=>!m.has(C))},[s,i]),Q=(m,C)=>{w(P=>C?P.includes(m)?P:[...P,m]:P.filter(U=>U!==m))},X=()=>$("");return e.jsxs(oe,{open:t,onOpenChange:a,children:[e.jsxs(le,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Paper Tasks"}),e.jsx(ue,{children:"Select the tasks that this paper addresses. You can select multiple tasks."})]}),x==="pending"&&e.jsx(ye,{isAuthor:u}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Le,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Z,{type:"text",placeholder:"Search tasks...",value:N,onChange:m=>$(m.target.value),className:"pl-9 pr-9"}),N&&e.jsx("button",{type:"button",onClick:X,className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground","aria-label":"Clear search",children:e.jsx(Et,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[400px]",children:v.length>0?e.jsx("div",{className:"space-y-2",children:v.map(m=>{const C=parseInt(m.id),P=s.includes(C);return e.jsxs("div",{className:"flex items-center space-x-2 p-2 hover:bg-muted/50 rounded-md",children:[e.jsx(tt,{id:`task-${m.id}`,checked:P,onCheckedChange:U=>Q(C,U===!0),className:"!border !border-black data-[state=checked]:!bg-black data-[state=checked]:!text-white"}),e.jsxs("label",{htmlFor:`task-${m.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[m.name,m.description&&e.jsxs("span",{className:"block text-xs text-muted-foreground font-normal mt-1",children:[m.description.substring(0,100),m.description.length>100?"...":""]})]})]},m.id)})}):f?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ie,{className:"w-8 h-8 mx-auto mb-2 animate-spin"}),e.jsx("p",{children:"Loading tasks..."})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Le,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:p?`No tasks found matching "${p}"`:"No tasks available"})]})}),e.jsxs(me,{children:[e.jsx(H,{variant:"ghost",className:"sm:mr-auto",onClick:()=>I(!0),children:"Suggest a new task"}),e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{onClick:O,disabled:F.isPending||!K,children:F.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),x==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-4 h-4 mr-2"}),x==="pending"?"Submit for review":"Save Changes"]})})]})]}),e.jsx(St,{open:k,onOpenChange:I,paperId:n,kind:"task"})]})}const Ir=250,Pr=100;function $r({open:t,onOpenChange:a,paperId:n,arxivId:l,initialMethodIds:i,initialMethods:c,onSuccess:o,submitMode:x="direct",isAuthor:u=!1}){const[s,w]=h.useState(i),[k,I]=h.useState(!1),[N,$]=h.useState(""),[p,T]=h.useState(""),[L,R]=h.useState(new Map),B=he(),{toast:D}=pe(),_=h.useRef(!1);h.useEffect(()=>{if(!t){_.current=!1;return}if(_.current)return;_.current=!0,w(i),$(""),T("");const m=new Map;(c||[]).forEach(C=>{const P=parseInt(C.id);Number.isNaN(P)||m.set(P,C)}),R(m)},[t,i,c]),h.useEffect(()=>{const m=window.setTimeout(()=>{T(N.trim())},Ir);return()=>window.clearTimeout(m)},[N]);const{data:d,isFetching:f}=ne({queryKey:["methods-search",p],queryFn:()=>ua({page_size:Pr,...p?{q:p}:{}}),enabled:t});h.useEffect(()=>{var m;(m=d==null?void 0:d.results)!=null&&m.length&&R(C=>{const P=new Map(C);return d.results.forEach(U=>{const E=parseInt(U.id);Number.isNaN(E)||P.set(E,U)}),P})},[d]);const v=h.useMemo(()=>{const m=(d==null?void 0:d.results)||[],C=new Set,P=[];return s.forEach(U=>{if(C.has(U))return;const E=L.get(U);E&&(P.push(E),C.add(U))}),m.forEach(U=>{const E=parseInt(U.id);Number.isNaN(E)||C.has(E)||(P.push(U),C.add(E))}),P},[d,s,L]),F=fe({mutationFn:async({paperId:m,methodIds:C})=>x==="pending"?(await ve({paper_id:parseInt(m),edit_type:"methods",proposed_payload:{method_ids:C}}),null):da(m,C),onSuccess:m=>{if(x==="pending"){D({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed method changes shortly."}),o==null||o(),a(!1);return}m&&Ee(B,m,[n,l]),D({title:"Methods updated",description:`Saved ${s.length} method${s.length===1?"":"s"} for this paper.`}),o==null||o(),a(!1)},onError:m=>{var U;const C=m;let P=C.message||(x==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper methods.");if(C.response)try{const E=JSON.parse(C.response);typeof(E==null?void 0:E.detail)=="string"?P=E.detail:Array.isArray(E==null?void 0:E.detail)&&((U=E.detail[0])!=null&&U.msg)&&(P=E.detail[0].msg)}catch{P=C.response}D({title:x==="pending"?"Could not submit edit":"Could not save methods",description:P,variant:"destructive"})}}),O=()=>{x==="direct"&&i.some(m=>!s.includes(m))&&!window.confirm("Remove one or more method links from this paper?")||F.mutate({paperId:n,methodIds:s})},K=h.useMemo(()=>{if(s.length!==i.length)return!0;const m=new Set(i);return s.some(C=>!m.has(C))},[s,i]),Q=(m,C)=>{w(P=>C?P.includes(m)?P:[...P,m]:P.filter(U=>U!==m))},X=()=>$("");return e.jsxs(oe,{open:t,onOpenChange:a,children:[e.jsxs(le,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Paper Methods"}),e.jsx(ue,{children:"Select the methods and techniques used in this paper. You can select multiple methods."})]}),x==="pending"&&e.jsx(ye,{isAuthor:u}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Le,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Z,{type:"text",placeholder:"Search methods...",value:N,onChange:m=>$(m.target.value),className:"pl-9 pr-9"}),N&&e.jsx("button",{type:"button",onClick:X,className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground","aria-label":"Clear search",children:e.jsx(Et,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[400px]",children:v.length>0?e.jsx("div",{className:"space-y-2",children:v.map(m=>{const C=parseInt(m.id),P=s.includes(C);return e.jsxs("div",{className:"flex items-center space-x-2 p-2 hover:bg-muted/50 rounded-md",children:[e.jsx(tt,{id:`method-${m.id}`,checked:P,onCheckedChange:U=>Q(C,U===!0),className:"!border !border-black data-[state=checked]:!bg-black data-[state=checked]:!text-white"}),e.jsxs("label",{htmlFor:`method-${m.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[m.name,m.full_name&&m.full_name!==m.name&&e.jsx("span",{className:"block text-xs text-muted-foreground font-normal",children:m.full_name}),m.description&&e.jsxs("span",{className:"block text-xs text-muted-foreground font-normal mt-1",children:[m.description.substring(0,100),m.description.length>100?"...":""]})]})]},m.id)})}):f?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ie,{className:"w-8 h-8 mx-auto mb-2 animate-spin"}),e.jsx("p",{children:"Loading methods..."})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Le,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:p?`No methods found matching "${p}"`:"No methods available"})]})}),e.jsxs(me,{children:[e.jsx(H,{variant:"ghost",className:"sm:mr-auto",onClick:()=>I(!0),children:"Suggest a new method"}),e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{onClick:O,disabled:F.isPending||!K,children:F.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),x==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-4 h-4 mr-2"}),x==="pending"?"Submit for review":"Save Changes"]})})]})]}),e.jsx(St,{open:k,onOpenChange:I,paperId:n,kind:"method"})]})}function Ar({open:t,onOpenChange:a,paperId:n,arxivId:l,initialRepositories:i,onSuccess:c,submitMode:o="direct",isAuthor:x=!1}){const[u,s]=h.useState(i),[w,k]=h.useState(""),I=he(),{toast:N}=pe(),$=h.useRef(!1);h.useEffect(()=>{if(!t){$.current=!1;return}$.current||($.current=!0,s(i),k(""))},[t,i]);const p=fe({mutationFn:async({paperId:f,repositories:v})=>o==="pending"?(await ve({paper_id:parseInt(f),edit_type:"repositories",proposed_payload:{repositories:v}}),null):ma(f,v),onSuccess:f=>{if(o==="pending"){N({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed repository changes shortly."}),c==null||c(),a(!1),k("");return}f&&Ee(I,f,[n,l]),c==null||c(),a(!1),k("")},onError:f=>{var O;const v=f;let F=v.message||(o==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper repositories.");if(v.response)try{const K=JSON.parse(v.response);typeof(K==null?void 0:K.detail)=="string"?F=K.detail:Array.isArray(K==null?void 0:K.detail)&&((O=K.detail[0])!=null&&O.msg)&&(F=K.detail[0].msg)}catch{F=v.response}N({title:o==="pending"?"Could not submit edit":"Could not save repositories",description:F,variant:"destructive"})}}),T=f=>{const v=[];for(const F of f){const O=v.find(K=>rs(K.url,F.url));if(O)O.is_official=O.is_official||F.is_official;else{const K=ot(F.url);v.push({url:K??F.url.trim(),is_official:F.is_official})}}return v},L=()=>{const f=w.trim(),v=f?[...u,{url:f,is_official:!1}]:u;return f&&u.some(F=>rs(F.url,f))?(alert("This repository URL is already added"),null):T(v)},R=()=>{const f=L();f!==null&&f.length!==u.length&&(s(f),k(""))},B=f=>{s(u.filter(v=>v.url!==f))},D=f=>{s(u.map(v=>v.url===f?{...v,is_official:!v.is_official}:v))},_=()=>{const f=L();f!==null&&(o==="direct"&&i.some(v=>!f.some(F=>F.url===v.url))&&!window.confirm("Remove one or more repositories from this paper?")||p.mutate({paperId:n,repositories:f}))},d=h.useMemo(()=>{const f=w.trim(),v=f?[...u,{url:f,is_official:!1}]:u;if(v.length!==i.length)return!0;const F=T(i),O=T(v);if(O.length!==F.length)return!0;const K=new Map(F.map(Q=>[ot(Q.url)??Q.url.trim(),!!Q.is_official]));return O.some(Q=>{const X=ot(Q.url)??Q.url.trim(),m=K.get(X);return m===void 0||m!==!!Q.is_official})},[u,w,i]);return e.jsx(oe,{open:t,onOpenChange:a,children:e.jsxs(le,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Paper Repositories"}),e.jsx(ue,{children:"Add or remove GitHub repository URLs associated with this paper. Mark repositories as official if they are created by the paper authors."})]}),o==="pending"&&e.jsx(ye,{isAuthor:x}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Add Repository URL"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(Z,{type:"url",placeholder:"https://github.com/owner/repo",value:w,onChange:f=>k(f.target.value),onKeyPress:f=>{f.key==="Enter"&&(f.preventDefault(),R())},className:"flex-1"}),e.jsxs(H,{onClick:R,size:"sm",disabled:!w.trim(),children:[e.jsx(Ye,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[350px]",children:u.length>0?e.jsx("div",{className:"space-y-2",children:u.map((f,v)=>e.jsxs("div",{className:"flex items-center space-x-2 p-3 bg-muted/30 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsx(ns,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("span",{className:"text-sm font-medium text-paper-blue truncate",children:f.url}),f.is_official&&e.jsx(ks,{variant:"secondary",className:"text-xs",children:"Official"})]})}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs(H,{variant:f.is_official?"default":"outline",size:"sm",onClick:()=>D(f.url),className:"h-8 px-2 text-xs",title:f.is_official?"Click to unmark as official (created by paper authors)":"Click to mark as official (created by paper authors)",children:[e.jsx(ws,{className:`w-3.5 h-3.5 mr-1 ${f.is_official?"fill-current":""}`}),f.is_official?"Official":"Mark official"]}),e.jsx(H,{variant:"ghost",size:"sm",onClick:()=>B(f.url),className:"h-8 px-2 text-destructive hover:text-destructive",title:"Remove repository",children:e.jsx(Ze,{className:"w-4 h-4"})})]})]},v))}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ns,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No repositories added yet"}),e.jsx("p",{className:"text-xs mt-1",children:"Add a repository URL above to get started"})]})}),e.jsxs(me,{children:[e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{onClick:_,disabled:p.isPending||!d,children:p.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),o==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-4 h-4 mr-2"}),o==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function Rr({open:t,onOpenChange:a,paperId:n,arxivId:l,initialProjectPages:i,onSuccess:c,submitMode:o="direct",isAuthor:x=!1}){const[u,s]=h.useState(i),[w,k]=h.useState(""),I=he(),{toast:N}=pe(),$=h.useRef(!1);h.useEffect(()=>{if(!t){$.current=!1;return}$.current||($.current=!0,s(i),k(""))},[t,i]);const p=fe({mutationFn:async({paperId:d,projectPages:f})=>o==="pending"?(await ve({paper_id:parseInt(d),edit_type:"project_pages",proposed_payload:{project_pages:f}}),null):ha(d,f),onSuccess:d=>{if(o==="pending"){N({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed project page changes shortly."}),c==null||c(),a(!1),k("");return}d&&Ee(I,d,[n,l]),c==null||c(),a(!1),k("")},onError:d=>{var F;const f=d;let v=f.message||(o==="pending"?"Failed to submit your edit. Please try again.":"Failed to update project pages.");if(f.response)try{const O=JSON.parse(f.response);typeof(O==null?void 0:O.detail)=="string"?v=O.detail:Array.isArray(O==null?void 0:O.detail)&&((F=O.detail[0])!=null&&F.msg)&&(v=O.detail[0].msg)}catch{v=f.response}N({title:o==="pending"?"Could not submit edit":"Could not save project pages",description:v,variant:"destructive"})}}),T=()=>{const d=w.trim();return d?u.some(f=>f.url===d)?(alert("This project page URL is already added"),null):[...u,{url:d,is_official:!1}]:u},L=()=>{const d=T();d!==null&&d.length!==u.length&&(s(d),k(""))},R=d=>{s(u.filter(f=>f.url!==d))},B=d=>{s(u.map(f=>f.url===d?{...f,is_official:!f.is_official}:f))},D=()=>{const d=T();d!==null&&(o==="direct"&&i.some(f=>!d.some(v=>v.url===f.url))&&!window.confirm("Remove one or more project pages from this paper?")||p.mutate({paperId:n,projectPages:d}))},_=h.useMemo(()=>{const d=w.trim(),f=d?[...u,{url:d,is_official:!1}]:u;if(f.length!==i.length)return!0;const v=new Map(i.map(F=>[F.url.trim(),!!F.is_official]));return f.some(F=>{const O=v.get(F.url.trim());return O===void 0||O!==!!F.is_official})},[u,w,i]);return e.jsx(oe,{open:t,onOpenChange:a,children:e.jsxs(le,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Paper Project Pages"}),e.jsx(ue,{children:"Add or remove project page URLs (e.g. authors' demo or landing pages) associated with this paper. Mark pages as official if they are created by the paper authors."})]}),o==="pending"&&e.jsx(ye,{isAuthor:x}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Add Project Page URL"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(Z,{type:"url",placeholder:"https://example.com/project",value:w,onChange:d=>k(d.target.value),onKeyPress:d=>{d.key==="Enter"&&(d.preventDefault(),L())},className:"flex-1"}),e.jsxs(H,{onClick:L,size:"sm",disabled:!w.trim(),children:[e.jsx(Ye,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[350px]",children:u.length>0?e.jsx("div",{className:"space-y-2",children:u.map((d,f)=>e.jsxs("div",{className:"flex items-center space-x-2 p-3 bg-muted/30 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsx(os,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("span",{className:"text-sm font-medium text-paper-blue truncate",children:d.url}),d.is_official&&e.jsx(ks,{variant:"secondary",className:"text-xs",children:"Official"})]})}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs(H,{variant:d.is_official?"default":"outline",size:"sm",onClick:()=>B(d.url),className:"h-8 px-2 text-xs",title:d.is_official?"Click to unmark as official (created by paper authors)":"Click to mark as official (created by paper authors)",children:[e.jsx(ws,{className:`w-3.5 h-3.5 mr-1 ${d.is_official?"fill-current":""}`}),d.is_official?"Official":"Mark official"]}),e.jsx(H,{variant:"ghost",size:"sm",onClick:()=>R(d.url),className:"h-8 px-2 text-destructive hover:text-destructive",title:"Remove project page",children:e.jsx(Ze,{className:"w-4 h-4"})})]})]},f))}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(os,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No project pages added yet"}),e.jsx("p",{className:"text-xs mt-1",children:"Add a project page URL above to get started"})]})}),e.jsxs(me,{children:[e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{onClick:D,disabled:p.isPending||!_,children:p.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),o==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-4 h-4 mr-2"}),o==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function Fr({open:t,onOpenChange:a,paperId:n,arxivId:l,initialUrl:i,onSuccess:c,submitMode:o="direct",isAuthor:x=!1}){const[u,s]=h.useState(i),w=he(),{toast:k}=pe(),I=h.useRef(!1);h.useEffect(()=>{if(!t){I.current=!1;return}I.current||(I.current=!0,s(i))},[t,i]);const N=fe({mutationFn:async({paperId:R,sourceUrl:B})=>o==="pending"?(await ve({paper_id:parseInt(R),edit_type:"source_url",proposed_payload:{source_url:B}}),null):pa(R,B),onSuccess:R=>{if(o==="pending"){k({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed source URL change shortly."}),c==null||c(),a(!1);return}R&&Ee(w,R,[n,l]),c==null||c(),a(!1)},onError:R=>{var _;const B=R;let D=B.message||(o==="pending"?"Failed to submit your edit. Please try again.":"Failed to update source URL.");if(B.response)try{const d=JSON.parse(B.response);typeof(d==null?void 0:d.detail)=="string"?D=d.detail:Array.isArray(d==null?void 0:d.detail)&&((_=d.detail[0])!=null&&_.msg)&&(D=d.detail[0].msg)}catch{D=B.response}k({title:o==="pending"?"Could not submit edit":"Could not save source URL",description:D,variant:"destructive"})}}),$=u.trim(),p=/^https?:\/\//i.test($),T=$!==(i||"").trim(),L=()=>{p&&N.mutate({paperId:n,sourceUrl:$})};return e.jsx(oe,{open:t,onOpenChange:a,children:e.jsxs(le,{className:"max-w-2xl",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Source URL"}),e.jsxs(ue,{children:["Update the canonical URL for this external paper. This is the page the ",'"Source page"'," button links to. ArXiv papers cannot edit this field."]})]}),o==="pending"&&e.jsx(ye,{isAuthor:x}),e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Source URL"}),e.jsx(Z,{type:"url",placeholder:"https://example.com/paper",value:u,onChange:R=>s(R.target.value),onKeyPress:R=>{R.key==="Enter"&&p&&T&&(R.preventDefault(),L())}}),!p&&$.length>0&&e.jsx("p",{className:"text-xs text-destructive",children:"URL must start with http:// or https://"})]}),e.jsxs(me,{children:[e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{onClick:L,disabled:N.isPending||!p||!T,children:N.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),o==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-4 h-4 mr-2"}),o==="pending"?"Submit for review":"Save Changes"]})})]})]})})}const dt=100;function Tr(t){return(t??[]).some(a=>a.slug==="coding-agents"||a.name.trim().toLowerCase()==="coding agents")}function ls(t){const a=parseInt(t.task_id,10),n=parseInt(t.dataset_id,10);return!(!Number.isFinite(a)||!Number.isFinite(n)||!t.metric_name.trim()||!t.metric_value.trim())}function Lr(t){return t.map(a=>{const n=a.best_metric||Object.keys(a.metrics)[0],l=a.metrics[n];return{id:a.id,task_id:a.task_id,dataset_id:a.dataset_id,model_name:a.model_name||"",harness:a.harness||"",metric_name:n||"",metric_value:String(l||""),best_rank:a.best_rank?String(a.best_rank):"",num_parameters:a.num_parameters!=null?String(a.num_parameters):"",hf_model_url:a.hf_model_url||"",is_open:a.is_open!==!1,operation:"unchanged"}})}function Ur(t){const a=new Map;return t.forEach(n=>{n.task_id&&n.task_name&&a.set(n.task_id,{id:n.task_id,name:n.task_name,slug:n.task_slug,level:0})}),a}function Dr(t){const a=new Map;return t.forEach(n=>{n.dataset_id&&n.dataset_name&&a.set(n.dataset_id,{id:n.dataset_id,name:n.dataset_name,slug:n.dataset_slug})}),a}function cs(t,a){return`${t}:${a}`}function Oe(t){const a=t.trim();if(a==="")return null;const n=Number(a);return!Number.isFinite(n)||n<0?null:Math.trunc(n)}function Ke(t){const a=t.trim();return a===""?null:a}function Br({open:t,onOpenChange:a,paperId:n,arxivId:l,initialEvaluations:i,paperTasks:c,onSuccess:o,submitMode:x="direct",isAdmin:u=!1,isAuthor:s=!1}){const w=Tr(c),[k,I]=h.useState([]),[N,$]=h.useState(null),[p,T]=h.useState(new Map),[L,R]=h.useState(new Map),B=he(),{toast:D}=pe(),_=h.useRef(!1),d=h.useRef(!1);h.useEffect(()=>{if(!t){_.current=!1,d.current=!1;return}_.current||d.current||i.length!==0&&(_.current=!0,I(Lr(i)),T(Ur(i)),R(Dr(i)))},[t,i]);const f=h.useMemo(()=>Array.from(new Set(k.map(g=>g.task_id).filter(g=>g&&g!==""))),[k]),v=h.useMemo(()=>{const g=new Set;return k.forEach(S=>{S.task_id&&S.dataset_id&&g.add(cs(S.task_id,S.dataset_id))}),Array.from(g)},[k]),F=ne({queryKey:["datasets-by-tasks-for-eval-edit",f,t],queryFn:async()=>{const g={};return await Promise.all(f.map(async S=>{try{const A=await ss({task_id:parseInt(S),page_size:dt});g[S]=A.results}catch(A){console.error(`Error fetching datasets for task ${S}:`,A),g[S]=[]}})),g},enabled:t&&f.length>0});h.useEffect(()=>{F.data&&R(g=>{const S=new Map(g);return Object.values(F.data).forEach(A=>{A.forEach(b=>{S.set(b.id,b)})}),S})},[F.data]);const O=ne({queryKey:["leaderboard-metrics-for-eval-edit",v,t],queryFn:async()=>{const g={};return await Promise.all(v.map(async S=>{const[A,b]=S.split(":");try{g[S]=await ga(b,A)}catch(j){console.error(`Error fetching metrics for leaderboard ${S}:`,j),g[S]=[]}})),g},enabled:t&&v.length>0}),K=async g=>{const S=await bs({page_size:dt,...g?{q:g}:{}});return T(A=>{const b=new Map(A);return S.results.forEach(j=>b.set(j.id,j)),b}),S.results.map(A=>{var b;return{value:A.id,label:A.name,description:(b=A.description)==null?void 0:b.slice(0,100)}})},Q=g=>async S=>{const A=await ss({task_id:parseInt(g),page_size:dt,...S?{q:S}:{}});return R(b=>{const j=new Map(b);return A.results.forEach(q=>j.set(q.id,q)),j}),A.results.map(b=>({value:b.id,label:b.name,description:b.full_name}))},X=(g,S)=>{if(!g||!S)return!1;const A=L.get(S);return!!(A!=null&&A.supports_harness)},m=(g,S,A)=>{var q;if(!g||!S)return[];const j=(((q=O.data)==null?void 0:q[cs(g,S)])||[]).map(M=>({value:M.metric_name,label:M.metric_name,description:M.metric_direction==="higher_is_better"?"Higher is better":"Lower is better"}));return A&&!j.some(M=>M.value===A)&&j.unshift({value:A,label:`${A} (legacy)`}),j},C=fe({mutationFn:async({paperId:g,evaluations:S})=>{if(x==="pending"){const b=[];for(const j of S){if(j.operation==="delete"&&j.id){b.push({op:"delete",evaluation_id:parseInt(j.id)});continue}const q=X(j.task_id,j.dataset_id);if(j.operation==="create"){if(!ls(j))continue;const M=Oe(j.num_parameters),ee={task_id:parseInt(j.task_id),dataset_id:parseInt(j.dataset_id),metrics:{[j.metric_name]:j.metric_value},best_metric:j.metric_name},Se=Ke(j.hf_model_url);j.model_name&&(ee.model_name=j.model_name),q&&j.harness&&(ee.harness=j.harness),j.best_rank&&(ee.best_rank=parseInt(j.best_rank)),M!=null&&(ee.num_parameters=M),Se!=null&&(ee.hf_model_url=Se),ee.is_open=j.is_open,b.push({op:"create",data:ee})}else if(j.operation==="update"&&j.id){const M={task_id:parseInt(j.task_id),dataset_id:parseInt(j.dataset_id),model_name:j.model_name||void 0,harness:q&&j.harness||null,metrics:{[j.metric_name]:j.metric_value},best_metric:j.metric_name,best_rank:j.best_rank?parseInt(j.best_rank):void 0,num_parameters:Oe(j.num_parameters),hf_model_url:Ke(j.hf_model_url),is_open:j.is_open};b.push({op:"update",evaluation_id:parseInt(j.id),data:M})}}return b.length===0?{submitted:!1}:(await ve({paper_id:parseInt(g),edit_type:"evaluations",proposed_payload:{operations:b}}),{submitted:!0})}const A=[];for(const b of S)if(b.operation==="delete"&&b.id)A.push({operation:"delete",evaluation_id:parseInt(b.id)});else if(b.operation==="create"){if(!ls(b))continue;const j=X(b.task_id,b.dataset_id),q=Oe(b.num_parameters);A.push({operation:"create",payload:{paper_id:parseInt(g),task_id:parseInt(b.task_id),dataset_id:parseInt(b.dataset_id),model_name:b.model_name||void 0,harness:j&&b.harness||void 0,metrics:{[b.metric_name]:b.metric_value},best_metric:b.metric_name,best_rank:b.best_rank?parseInt(b.best_rank):void 0,num_parameters:q??void 0,hf_model_url:Ke(b.hf_model_url)??void 0,is_open:b.is_open}})}else if(b.operation==="update"&&b.id){const j=X(b.task_id,b.dataset_id);A.push({operation:"update",evaluation_id:parseInt(b.id),payload:{task_id:parseInt(b.task_id),dataset_id:parseInt(b.dataset_id),model_name:b.model_name||void 0,harness:j&&b.harness||null,metrics:{[b.metric_name]:b.metric_value},best_metric:b.metric_name,best_rank:b.best_rank?parseInt(b.best_rank):void 0,num_parameters:Oe(b.num_parameters),hf_model_url:Ke(b.hf_model_url),is_open:b.is_open,harness_set:!0,num_parameters_set:!0,hf_model_url_set:!0}})}if(!u&&A.length>50)throw new Error("Contributor evaluation batches are limited to 50 operations; contact an admin.");return A.length>0&&await fa(parseInt(g),A),{submitted:A.length>0}},onSuccess:g=>{if(x==="pending"){g!=null&&g.submitted?D({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed evaluation changes shortly."}):D({title:"No changes to submit",description:"Your evaluation list matches the existing data."}),o==null||o(),a(!1);return}B.invalidateQueries({queryKey:["paper-arxiv",l]}),B.invalidateQueries({queryKey:["evaluations","paper",n]}),o==null||o(),a(!1)},onError:g=>{var b;const S=g;let A=S.message||(x==="pending"?"Failed to submit your edit. Please try again.":"Failed to update evaluations.");if(S.response)try{const j=JSON.parse(S.response);typeof(j==null?void 0:j.detail)=="string"?A=j.detail:Array.isArray(j==null?void 0:j.detail)&&((b=j.detail[0])!=null&&b.msg)&&(A=j.detail[0].msg)}catch{A=S.response}D({title:x==="pending"?"Could not submit edit":"Could not save evaluations",description:A,variant:"destructive"})}}),P=()=>{d.current=!0,I([...k,{task_id:"",dataset_id:"",model_name:"",harness:"",metric_name:"",metric_value:"",best_rank:"",num_parameters:"",hf_model_url:"",is_open:!0,operation:"create"}])},U=g=>{if(d.current=!0,k[g].id){if(!window.confirm("Delete this evaluation? You will be asked to sign in again if your session is older than 15 minutes."))return;I(k.map((A,b)=>b===g?{...A,operation:"delete"}:A))}else I(k.filter((A,b)=>b!==g))},E=(g,S,A)=>{d.current=!0,I(k.map((b,j)=>{if(j!==g)return b;const q={...b,[S]:A};return S==="task_id"&&(q.dataset_id="",q.metric_name="",q.harness=""),S==="dataset_id"&&(q.metric_name="",A&&!X(q.task_id,A)&&(q.harness="")),b.operation==="unchanged"&&(q.operation="update"),q}))},z=(g,S)=>{d.current=!0,I(k.map((A,b)=>{if(b!==g)return A;const j={...A,is_open:S};return A.operation==="unchanged"&&(j.operation="update"),j}))},W=()=>{const g=k.filter(S=>S.operation!=="delete"||S.id);C.mutate({paperId:n,evaluations:g})};return e.jsxs(oe,{open:t,onOpenChange:a,children:[e.jsxs(le,{className:"max-w-6xl max-h-[800px]",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Evaluation Results"}),e.jsx(ue,{children:"Add, edit, or remove evaluation results for this paper. Each row represents a benchmark result."})]}),x==="pending"&&e.jsx(ye,{isAuthor:s}),e.jsxs("div",{className:"py-4 overflow-y-auto max-h-[600px]",children:[k.filter(g=>g.operation!=="delete").length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border",children:[e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm min-w-[180px]",children:"Task"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm min-w-[180px]",children:"Dataset"}),e.jsx("th",{className:`text-left py-2 px-2 font-medium text-sm ${w?"min-w-[140px]":"min-w-[240px]"}`,children:"Model"}),w&&e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm min-w-[140px]",children:"Harness"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm min-w-[140px]",children:"Metric"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm",children:"Value"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm",children:"Parameters"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm min-w-[200px]",children:"HF model URL"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm w-20",children:"Open source"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm w-16",children:"Action"})]})}),e.jsx("tbody",{children:k.map((g,S)=>{if(g.operation==="delete")return null;const A=p.get(g.task_id),b=L.get(g.dataset_id),j=m(g.task_id,g.dataset_id,g.metric_name),q=!!(g.task_id&&g.dataset_id)&&O.isFetching;return e.jsxs("tr",{className:"border-b border-border",children:[e.jsx("td",{className:"py-2 px-2",children:e.jsx(as,{value:g.task_id,onChange:M=>E(S,"task_id",M),placeholder:"Select task",searchPlaceholder:"Search tasks...",emptyMessage:"No tasks found.",selectedOption:A?{value:A.id,label:A.name}:null,queryKey:["eval-edit-task-search"],queryFn:K,enabled:t})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(as,{value:g.dataset_id,onChange:M=>E(S,"dataset_id",M),placeholder:g.task_id?"Select dataset":"Select task first",searchPlaceholder:"Search datasets...",emptyMessage:g.task_id?"No datasets found for this task.":"Select a task first.",disabled:!g.task_id,selectedOption:b?{value:b.id,label:b.name}:null,queryKey:["eval-edit-dataset-search",g.task_id],queryFn:Q(g.task_id),enabled:t&&!!g.task_id})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(Z,{type:"text",className:"w-full text-sm",placeholder:"Model name",value:g.model_name,onChange:M=>E(S,"model_name",M.target.value)})}),w&&e.jsx("td",{className:"py-2 px-2",children:X(g.task_id,g.dataset_id)?e.jsx(Z,{type:"text",className:"w-full text-sm",placeholder:"Claude Code, Terminus, ...",value:g.harness,onChange:M=>E(S,"harness",M.target.value)}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not supported"})}),e.jsx("td",{className:"py-2 px-2",children:!g.task_id||!g.dataset_id?e.jsx("span",{className:"text-xs text-muted-foreground",children:"Select task + dataset"}):q?e.jsxs("span",{className:"inline-flex items-center text-xs text-muted-foreground",children:[e.jsx(ie,{className:"mr-1 h-3 w-3 animate-spin"}),"Loading metrics..."]}):j.length>0?e.jsxs("select",{className:"w-full rounded-md border border-border bg-background px-2 py-1 text-sm",value:g.metric_name,onChange:M=>E(S,"metric_name",M.target.value),children:[e.jsx("option",{value:"",children:"Select metric"}),j.map(M=>e.jsx("option",{value:M.value,children:M.label},M.value))]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"No configured metrics"})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(Z,{type:"text",className:"w-full text-sm",placeholder:"44.9",value:g.metric_value,onChange:M=>E(S,"metric_value",M.target.value)})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(Z,{type:"number",min:0,step:1,className:"w-full text-sm",placeholder:"e.g. 7000000000",value:g.num_parameters,onChange:M=>E(S,"num_parameters",M.target.value),title:"Raw model parameter count (e.g. 7000000000 for a 7B model). Leave blank if unknown."})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(Z,{type:"url",className:"w-full text-sm",placeholder:"https://huggingface.co/org/model",value:g.hf_model_url,onChange:M=>E(S,"hf_model_url",M.target.value),title:"Hugging Face model page for this row (must start with https://huggingface.co/). Leave blank if none."})}),e.jsx("td",{className:"py-2 px-2 text-center",children:e.jsx("input",{type:"checkbox",className:"h-4 w-4 align-middle",checked:g.is_open,onChange:M=>z(S,M.target.checked),title:"Whether the evaluated model is open-source. Uncheck for closed-source models."})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(H,{variant:"ghost",size:"sm",onClick:()=>U(S),className:"h-8 w-8 p-0 text-destructive hover:text-destructive",title:"Delete row",children:e.jsx(Ze,{className:"w-4 h-4"})})})]},S)})})]})}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ya,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"No evaluation results yet"}),e.jsx("p",{className:"text-sm mt-2",children:'Click "Add Row" below to add a new evaluation'})]}),e.jsx("div",{className:"mt-4",children:e.jsxs(H,{variant:"outline",size:"sm",onClick:P,className:"flex items-center space-x-2",children:[e.jsx(Ye,{className:"w-4 h-4"}),e.jsx("span",{children:"Add Row"})]})})]}),e.jsxs(me,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2 sm:mr-auto",children:[e.jsx(H,{variant:"ghost",onClick:()=>$("benchmark"),children:"Suggest a new benchmark"}),e.jsx(H,{variant:"ghost",onClick:()=>$("metric"),children:"Suggest a new metric"})]}),e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{onClick:W,disabled:C.isPending,children:C.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),x==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-4 h-4 mr-2"}),x==="pending"?"Submit for review":"Save Changes"]})})]})]}),e.jsx(St,{open:N!==null,onOpenChange:g=>{g||$(null)},paperId:n,kind:N??"benchmark"})]})}const ut=[{key:"hf_models",label:"Models",placeholder:"https://huggingface.co/org/model"},{key:"hf_datasets",label:"Datasets",placeholder:"https://huggingface.co/datasets/org/data"},{key:"hf_spaces",label:"Spaces",placeholder:"https://huggingface.co/spaces/org/demo"}];function ds(t){return t.map(a=>a.trim()).filter(Boolean)}function mt(t,a){const n=ds(t).sort(),l=ds(a).sort();return n.length!==l.length?!1:n.every((i,c)=>i===l[c])}function Hr(t,a){return mt(t.hf_models,a.hf_models)&&mt(t.hf_datasets,a.hf_datasets)&&mt(t.hf_spaces,a.hf_spaces)}function Mr({open:t,onOpenChange:a,paperId:n,arxivId:l,initialArtifacts:i,onSuccess:c,submitMode:o="direct",isAuthor:x=!1}){const[u,s]=h.useState(i),[w,k]=h.useState({hf_models:"",hf_datasets:"",hf_spaces:""}),I=he(),{toast:N}=pe(),$=h.useRef(!1);h.useEffect(()=>{if(!t){$.current=!1;return}$.current||($.current=!0,s(i),k({hf_models:"",hf_datasets:"",hf_spaces:""}))},[t,i]);const p=fe({mutationFn:async({paperId:_,artifacts:d})=>o==="pending"?(await ve({paper_id:parseInt(_),edit_type:"hf_artifacts",proposed_payload:d}),null):xa(_,d),onSuccess:_=>{if(o==="pending"){N({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed Hugging Face artifact changes shortly."}),c==null||c(),a(!1),k({hf_models:"",hf_datasets:"",hf_spaces:""});return}_&&Ee(I,_,[n,l]),c==null||c(),a(!1),k({hf_models:"",hf_datasets:"",hf_spaces:""})},onError:_=>{var v;const d=_;let f=d.message||(o==="pending"?"Failed to submit your edit. Please try again.":"Failed to update Hugging Face artifacts.");if(d.response)try{const F=JSON.parse(d.response);typeof(F==null?void 0:F.detail)=="string"?f=F.detail:Array.isArray(F==null?void 0:F.detail)&&((v=F.detail[0])!=null&&v.msg)&&(f=F.detail[0].msg)}catch{f=d.response}N({title:o==="pending"?"Could not submit edit":"Could not save Hugging Face artifacts",description:f,variant:"destructive"})}}),T=()=>{const _={hf_models:[...u.hf_models],hf_datasets:[...u.hf_datasets],hf_spaces:[...u.hf_spaces]};for(const{key:d}of ut){const f=w[d].trim();if(f){if(_[d].some(v=>v.trim()===f))return alert(`This ${d.replace("hf_","")} URL is already added`),null;_[d]=[..._[d],f]}}return _},L=_=>{const d=w[_].trim();if(d){if(u[_].some(f=>f.trim()===d)){alert(`This ${_.replace("hf_","")} URL is already added`);return}s(f=>({...f,[_]:[...f[_],d]})),k(f=>({...f,[_]:""}))}},R=(_,d)=>{s(f=>({...f,[_]:f[_].filter(v=>v!==d)}))},B=()=>{const _=T();if(_===null)return;const d=Object.keys(i).some(f=>i[f].some(v=>!_[f].includes(v)));o==="direct"&&d&&!window.confirm("Remove one or more Hugging Face artifact links?")||p.mutate({paperId:n,artifacts:_})},D=h.useMemo(()=>{const _={hf_models:[...u.hf_models],hf_datasets:[...u.hf_datasets],hf_spaces:[...u.hf_spaces]};for(const{key:d}of ut){const f=w[d].trim();if(f){if(_[d].some(v=>v.trim()===f))return!1;_[d]=[..._[d],f]}}return!Hr(_,i)},[u,w,i]);return e.jsx(oe,{open:t,onOpenChange:a,children:e.jsxs(le,{className:"max-w-2xl max-h-[700px]",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Hugging Face Artifacts"}),e.jsx(ue,{children:"Add or remove linked Hugging Face models, datasets, and Spaces for this paper."})]}),o==="pending"&&e.jsx(ye,{isAuthor:x}),e.jsx("div",{className:"space-y-6 py-2 overflow-y-auto max-h-[460px]",children:ut.map(({key:_,label:d,placeholder:f})=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:d}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(Z,{type:"url",placeholder:f,value:w[_],onChange:v=>k(F=>({...F,[_]:v.target.value})),onKeyPress:v=>{v.key==="Enter"&&(v.preventDefault(),L(_))},className:"flex-1"}),e.jsxs(H,{onClick:()=>L(_),size:"sm",disabled:!w[_].trim(),children:[e.jsx(Ye,{className:"w-4 h-4 mr-1"}),"Add"]})]}),u[_].length>0?e.jsx("div",{className:"space-y-2",children:u[_].map(v=>e.jsxs("div",{className:"flex items-center space-x-2 p-3 bg-muted/30 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-paper-blue truncate flex-1",children:v}),e.jsx(H,{variant:"ghost",size:"sm",onClick:()=>R(_,v),className:"h-8 px-2 text-destructive hover:text-destructive",title:`Remove ${d.toLowerCase()} URL`,children:e.jsx(Ze,{className:"w-4 h-4"})})]},v))}):e.jsxs("div",{className:"text-xs text-muted-foreground",children:["No ",d.toLowerCase()," linked yet."]})]},_))}),e.jsxs(me,{children:[e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{onClick:B,disabled:p.isPending||!D,children:p.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),o==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"w-4 h-4 mr-2"}),o==="pending"?"Submit for review":"Save Changes"]})})]})]})})}const zr=({open:t,onOpenChange:a,paperId:n,initialOrganizationIds:l,submitMode:i,isAuthor:c})=>{var $;const[o,x]=h.useState(l),[u,s]=h.useState(""),w=he();h.useEffect(()=>{t&&(x(l),s(""))},[l,t]);const k=ne({queryKey:["organizations","curation"],queryFn:()=>ja(!1),enabled:t}),I=h.useMemo(()=>{var T,L;const p=u.trim().toLocaleLowerCase();return p?(((L=k.data)==null?void 0:L.results)??[]).filter(R=>R.name.toLocaleLowerCase().includes(p)):((T=k.data)==null?void 0:T.results)??[]},[($=k.data)==null?void 0:$.results,u]),N=fe({mutationFn:async()=>{l.some(T=>!o.includes(T))&&!window.confirm("Remove one or more organizations from this paper? Destructive edits may require a fresh sign-in.")||(i==="pending"?await ve({paper_id:Number(n),edit_type:"organizations",proposed_payload:{organization_ids:o}}):await ba(n,o))},onSuccess:()=>{w.invalidateQueries({queryKey:["paper-arxiv"]}),a(!1)}});return e.jsx(oe,{open:t,onOpenChange:a,children:e.jsxs(le,{children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit organizations"}),e.jsx(ue,{children:"Associate existing organizations with this paper. Organization creation remains admin-only."})]}),i==="pending"&&e.jsx(ye,{isAuthor:c}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Z,{type:"search","aria-label":"Search organizations",placeholder:"Search organizations...",value:u,onChange:p=>s(p.target.value),className:"pl-9 pr-9"}),u&&e.jsx("button",{type:"button",onClick:()=>s(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground","aria-label":"Clear organization search",children:e.jsx(Et,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"max-h-80 space-y-2 overflow-auto",children:[I.map(p=>{const T=Number(p.id);return e.jsxs("label",{className:"flex items-center gap-2 rounded border p-2",children:[e.jsx("input",{type:"checkbox",checked:o.includes(T),onChange:L=>x(R=>L.target.checked?[...R,T]:R.filter(B=>B!==T))}),p.name]},p.id)}),!k.isLoading&&I.length===0&&e.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:u.trim()?`No organizations found matching "${u.trim()}"`:"No organizations available"})]}),e.jsxs(me,{children:[e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{onClick:()=>N.mutate(),disabled:N.isPending,children:i==="pending"?"Submit test edit":"Save changes"})]})]})})},Ce=["my-bookmark-ids"],vt="pwc:pending-bookmark";function qr(t){window.sessionStorage.setItem(vt,JSON.stringify(t)),window.location.assign(or(!0))}function Or(){var l,i;const{user:t}=We(),a=ne({queryKey:Ce,queryFn:()=>re.getMyBookmarkIds(),enabled:!!t,staleTime:60*1e3,refetchOnWindowFocus:!1}),n=Xe.useMemo(()=>{var c;return new Set(((c=a.data)==null?void 0:c.paper_ids)??[])},[(l=a.data)==null?void 0:l.paper_ids]);return{ids:((i=a.data)==null?void 0:i.paper_ids)??[],idSet:n,isLoading:a.isLoading,isError:a.isError}}function Kr(){const{user:t}=We(),a=he(),n=fe({mutationFn:async({paperId:i,isBookmarked:c})=>{c?await re.removeBookmark(i):await re.addBookmark(i)},onMutate:async({paperId:i,isBookmarked:c})=>{await a.cancelQueries({queryKey:Ce});const o=a.getQueryData(Ce),x=typeof i=="string"?Number(i):i,u=(o==null?void 0:o.paper_ids)??[],s=c?u.filter(w=>w!==x):[x,...u.filter(w=>w!==x)];return a.setQueryData(Ce,{paper_ids:s}),{previous:o}},onError:(i,c,o)=>{o!=null&&o.previous&&a.setQueryData(Ce,o.previous),i instanceof jt&&i.code==="saved_papers_bucket_authorization_required"&&qr(c)},onSettled:()=>{a.invalidateQueries({queryKey:Ce}),a.invalidateQueries({queryKey:["my-bookmarks"]})}});return Xe.useEffect(()=>{if(!t||n.isPending)return;const i=new URL(window.location.href);if(i.searchParams.get(is)!=="1")return;i.searchParams.delete(is),window.history.replaceState({},"",`${i.pathname}${i.search}${i.hash}`);const c=window.sessionStorage.getItem(vt);if(c){window.sessionStorage.removeItem(vt);try{const o=JSON.parse(c);(typeof o.paperId=="number"||typeof o.paperId=="string")&&typeof o.isBookmarked=="boolean"&&n.mutate(o)}catch{}}},[n,t]),{toggle:Xe.useCallback((i,c)=>{if(!t){if(js())return;const o=typeof window<"u"?window.location.pathname+window.location.search:"/";window.location.href=vs(`/api/v1/auth/hf/login?return_to=${encodeURIComponent(o)}`);return}n.mutate({paperId:i,isBookmarked:c})},[n,t]),isPending:n.isPending}}const Gr=({paperId:t})=>{const{user:a}=We(),{idSet:n}=Or(),{toggle:l,isPending:i}=Kr();if(js())return null;const c=Number(t),o=!!a&&n.has(c),x=()=>{Number.isFinite(c)&&l(c,o)},u=a&&o?"Saved":"Save",s=a?o?"Remove from saved papers":"Save this paper":"Sign in with Hugging Face to save this paper";return e.jsxs("button",{type:"button",className:`action-btn${o?" is-saved":""}`,onClick:x,disabled:i,"aria-pressed":o,"aria-label":s,title:s,children:[e.jsx(J,{name:"bookmark",size:12}),u]})};function Ge({children:t,showEdit:a=!1,onEdit:n,editAriaLabel:l}){return a?e.jsxs("span",{className:"action-btn-composite",children:[t,e.jsx("button",{type:"button",className:"action-btn-segment action-btn-edit",onClick:n,"aria-label":l,children:"edit"})]}):t}const Qr={"add-evals":{trigger:"add evals",running:"adding evals…",complete:"add evals ✓",title:"Add evaluations with Codex",description:t=>e.jsxs(e.Fragment,{children:["Codex will run the repository’s add-evals skill for “",t,"”. It will import only paper-native results onto existing, metric-compatible leaderboards. Accepted rows are written directly to the live database."]}),notice:"Comparator rows, unknown benchmarks, and unconfigured metrics will be skipped. Jobs run one at a time in submission order.",progress:"Codex is researching the paper and validating results against the configured leaderboards.",action:"Run add-evals",start:rr,get:ar,cancel:sr},"enrich-paper":{trigger:"enrich paper",running:"enriching…",complete:"enriched ✓",title:"Enrich paper with Codex",description:t=>e.jsxs(e.Fragment,{children:["Codex will run the repository’s enrich-paper skill for “",t,"”. It will validate official code and project links, merge high-confidence taxonomy tags, and check the paper thumbnail. Accepted changes are written directly to the live database."]}),notice:"Uncertain URLs and missing taxonomy concepts will be reported rather than guessed. Jobs run one at a time in submission order.",progress:"Codex is validating artifacts, taxonomy tags, and thumbnail quality for this paper.",action:"Run enrich-paper",start:tr,get:er,cancel:Za}};function Vr({report:t}){return e.jsx("div",{className:"min-w-0 max-h-[50vh] overflow-y-auto overflow-x-hidden rounded-md border bg-muted/40 p-4 text-sm leading-relaxed",children:e.jsx(lr,{remarkPlugins:[cr],components:{a:({children:a,...n})=>e.jsx("a",{...n,className:"break-all underline underline-offset-2",target:"_blank",rel:"noreferrer",children:a}),p:({children:a})=>e.jsx("p",{className:"mb-3 break-words last:mb-0",children:a}),ul:({children:a})=>e.jsx("ul",{className:"mb-3 list-disc space-y-1 pl-5 last:mb-0",children:a}),ol:({children:a})=>e.jsx("ol",{className:"mb-3 list-decimal space-y-1 pl-5 last:mb-0",children:a}),h1:({children:a})=>e.jsx("h3",{className:"mb-2 font-semibold",children:a}),h2:({children:a})=>e.jsx("h3",{className:"mb-2 font-semibold",children:a}),h3:({children:a})=>e.jsx("h3",{className:"mb-2 font-semibold",children:a}),code:({children:a})=>e.jsx("code",{className:"break-all rounded bg-background/80 px-1 py-0.5 font-mono text-xs",children:a}),pre:({children:a})=>e.jsx("pre",{className:"mb-3 max-w-full overflow-x-auto whitespace-pre-wrap break-words rounded bg-background/80 p-3 font-mono text-xs last:mb-0",children:a})},children:t})})}function Rs({kind:t,paperId:a,paperTitle:n,triggerClassName:l,onComplete:i}){const c=Qr[t],[o,x]=h.useState(!1),[u,s]=h.useState(null),[w,k]=h.useState(!1),[I,N]=h.useState(null),$=h.useRef(null),p=(u==null?void 0:u.status)==="queued"||(u==null?void 0:u.status)==="dispatching"||(u==null?void 0:u.status)==="running",T=u==null?void 0:u.id;h.useEffect(()=>{if(!p||!T)return;let D=!1;const _=window.setInterval(async()=>{try{const d=await c.get(T);D||(s(d),N(null))}catch(d){D||N(d instanceof Error?d.message:"Could not check job status.")}},2e3);return()=>{D=!0,window.clearInterval(_)}},[p,c,T]),h.useEffect(()=>{(u==null?void 0:u.status)!=="completed"||$.current===u.id||($.current=u.id,i())},[u,i]);const L=async()=>{k(!0),N(null);try{s(await c.start(a))}catch(D){N(D instanceof Error?D.message:"Could not start Codex.")}finally{k(!1)}},R=()=>{s(null),N(null),$.current=null},B=async()=>{if(u){N(null);try{s(await c.cancel(u.id))}catch(D){N(D instanceof Error?D.message:"Could not cancel Codex.")}}};return e.jsxs(oe,{open:o,onOpenChange:x,children:[e.jsx("button",{type:"button",className:l,onClick:()=>x(!0),children:p?c.running:(u==null?void 0:u.status)==="completed"?c.complete:c.trigger}),e.jsxs(le,{className:"max-h-[90vh] w-[calc(100vw-2rem)] min-w-0 max-w-2xl overflow-hidden",children:[e.jsxs(ce,{className:"min-w-0",children:[e.jsx(de,{children:c.title}),e.jsx(ue,{children:c.description(n)})]}),u?e.jsxs("div",{className:"min-w-0 space-y-3 overflow-hidden",children:[e.jsxs("div",{className:"font-mono text-xs uppercase tracking-wide text-muted-foreground",children:["Status: ",u.status]}),u.hf_job_url&&e.jsx("a",{className:"text-sm underline",href:u.hf_job_url,target:"_blank",rel:"noreferrer",children:"View Hugging Face Job"}),p&&e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3 text-sm",children:[u.status==="queued"?"This job is queued and will start after the current Codex job finishes.":c.progress," ","This can take several minutes; you can close this window and return."]}),u.report&&e.jsx(Vr,{report:u.report}),u.error&&e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:u.error})]}):e.jsx("div",{className:"rounded-md border bg-muted/40 p-3 text-sm text-muted-foreground",children:c.notice}),I&&e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:I}),e.jsxs(me,{children:[e.jsx(H,{variant:"outline",onClick:()=>x(!1),children:p?"Close":"Cancel"}),p&&e.jsx(H,{variant:"outline",onClick:()=>void B(),children:"Cancel job"}),!u&&e.jsx(H,{onClick:L,disabled:w,children:w?"Starting…":c.action}),u&&!p&&e.jsx(H,{variant:"outline",onClick:R,children:"Run again"})]})]})]})}function Jr(t){return e.jsx(Rs,{...t,kind:"add-evals",triggerClassName:"edit-link"})}function Xr(t){return e.jsx(Rs,{...t,kind:"enrich-paper",triggerClassName:"action-btn"})}var $t="Radio",[Wr,Fs]=Ct($t),[Yr,Zr]=Wr($t),Ts=h.forwardRef((t,a)=>{const{__scopeRadio:n,name:l,checked:i=!1,required:c,disabled:o,value:x="on",onCheck:u,form:s,...w}=t,[k,I]=h.useState(null),N=Ue(a,T=>I(T)),$=h.useRef(!1),p=k?s||!!k.closest("form"):!0;return e.jsxs(Yr,{scope:n,checked:i,disabled:o,children:[e.jsx(_e.button,{type:"button",role:"radio","aria-checked":i,"data-state":Bs(i),"data-disabled":o?"":void 0,disabled:o,value:x,...w,ref:N,onClick:Te(t.onClick,T=>{i||u==null||u(),p&&($.current=T.isPropagationStopped(),$.current||T.stopPropagation())})}),p&&e.jsx(Ds,{control:k,bubbles:!$.current,name:l,value:x,checked:i,required:c,disabled:o,form:s,style:{transform:"translateX(-100%)"}})]})});Ts.displayName=$t;var Ls="RadioIndicator",Us=h.forwardRef((t,a)=>{const{__scopeRadio:n,forceMount:l,...i}=t,c=Zr(Ls,n);return e.jsx(fs,{present:l||c.checked,children:e.jsx(_e.span,{"data-state":Bs(c.checked),"data-disabled":c.disabled?"":void 0,...i,ref:a})})});Us.displayName=Ls;var en="RadioBubbleInput",Ds=h.forwardRef(({__scopeRadio:t,control:a,checked:n,bubbles:l=!0,...i},c)=>{const o=h.useRef(null),x=Ue(o,c),u=_s(n),s=xs(a);return h.useEffect(()=>{const w=o.current;if(!w)return;const k=window.HTMLInputElement.prototype,N=Object.getOwnPropertyDescriptor(k,"checked").set;if(u!==n&&N){const $=new Event("click",{bubbles:l});N.call(w,n),w.dispatchEvent($)}},[u,n,l]),e.jsx(_e.input,{type:"radio","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:x,style:{...i.style,...s,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Ds.displayName=en;function Bs(t){return t?"checked":"unchecked"}var tn=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],st="RadioGroup",[sn]=Ct(st,[ys,Fs]),Hs=ys(),Ms=Fs(),[an,rn]=sn(st),zs=h.forwardRef((t,a)=>{const{__scopeRadioGroup:n,name:l,defaultValue:i,value:c,required:o=!1,disabled:x=!1,orientation:u,dir:s,loop:w=!0,onValueChange:k,...I}=t,N=Hs(n),$=va(s),[p,T]=gs({prop:c,defaultProp:i??null,onChange:k,caller:st});return e.jsx(an,{scope:n,name:l,required:o,disabled:x,value:p,onValueChange:T,children:e.jsx(ya,{asChild:!0,...N,orientation:u,dir:$,loop:w,children:e.jsx(_e.div,{role:"radiogroup","aria-required":o,"aria-orientation":u,"data-disabled":x?"":void 0,dir:$,...I,ref:a})})})});zs.displayName=st;var qs="RadioGroupItem",Os=h.forwardRef((t,a)=>{const{__scopeRadioGroup:n,disabled:l,...i}=t,c=rn(qs,n),o=c.disabled||l,x=Hs(n),u=Ms(n),s=h.useRef(null),w=Ue(a,s),k=c.value===i.value,I=h.useRef(!1);return h.useEffect(()=>{const N=p=>{tn.includes(p.key)&&(I.current=!0)},$=()=>I.current=!1;return document.addEventListener("keydown",N),document.addEventListener("keyup",$),()=>{document.removeEventListener("keydown",N),document.removeEventListener("keyup",$)}},[]),e.jsx(_a,{asChild:!0,...x,focusable:!o,active:k,children:e.jsx(Ts,{disabled:o,required:c.required,checked:k,...u,...i,name:c.name,ref:w,onCheck:()=>c.onValueChange(i.value),onKeyDown:Te(N=>{N.key==="Enter"&&N.preventDefault()}),onFocus:Te(i.onFocus,()=>{var N;I.current&&((N=s.current)==null||N.click())})})})});Os.displayName=qs;var nn="RadioGroupIndicator",Ks=h.forwardRef((t,a)=>{const{__scopeRadioGroup:n,...l}=t,i=Ms(n);return e.jsx(Us,{...i,...l,ref:a})});Ks.displayName=nn;var Gs=zs,Qs=Os,on=Ks;const yt=h.forwardRef(({className:t,...a},n)=>e.jsx(Gs,{className:Je("grid gap-2",t),...a,ref:n}));yt.displayName=Gs.displayName;const Fe=h.forwardRef(({className:t,...a},n)=>e.jsx(Qs,{ref:n,className:Je("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...a,children:e.jsx(on,{className:"flex items-center justify-center",children:e.jsx(ka,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Fe.displayName=Qs.displayName;const ln={pdf:"PDF",model:"Model",dataset:"Dataset",space:"Space",github:"GitHub"},_t=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,cn=/^[A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*$/,dn=20,kt="copy_to_bucket";function un(t){const a=t.trim();if(!cn.test(a))return null;const[n,l]=a.split("/");return`https://huggingface.co/buckets/${encodeURIComponent(n)}/${encodeURIComponent(l)}`}function wt(t){return`pwc:bucket-copy:${t}`}function mn(t){if(typeof window>"u"||new URL(window.location.href).searchParams.get(kt)!==t)return null;try{const n=window.sessionStorage.getItem(wt(t));if(!n)return null;const l=JSON.parse(n);return l.paperId!==t||typeof l.bucketId!="string"||!["new","existing"].includes(l.destinationMode)||!["public","private"].includes(l.visibility)||!Array.isArray(l.selectedIds)||l.selectedIds.some(i=>typeof i!="string")?null:l}catch{return null}}function hn(t,a=dn){if(a<1)throw new Error("Bucket copy batch size must be positive");const n=[];for(let l=0;l!_t.test(u)))return null;const o=c.join("/"),x=a==="model"?"":`${a}s/`;return{id:`${a}:${o}`,kind:a,label:o,url:`https://huggingface.co/${x}${o}`,source:`hf://${x}${o}/`,destination:`${a}s/${o}/`,repoId:o}}catch{return null}}function pn(t){try{const a=new URL(t);if(a.hostname!=="github.com"&&a.hostname!=="www.github.com")return null;const n=a.pathname.split("/").filter(Boolean);if(n.length<2)return null;const l=n[0],i=n[1].replace(/\.git$/,"");if(!_t.test(l)||!_t.test(i))return null;const c=`${l}/${i}`;return{id:`github:${c}`,kind:"github",label:c,url:`https://github.com/${c}`,source:`https://github.com/${c}.git`,destination:`github/${c}/`}}catch{return null}}function fn({githubUrls:t,hfModelUrls:a,hfDatasetUrls:n,hfSpaceUrls:l,paperId:i,pdfName:c,pdfUrl:o}){const x=[o?{id:"pdf",kind:"pdf",label:"Paper PDF",url:o,source:o,destination:`paper/${c||i}.pdf`}:null,...a.map(s=>ht(s,"model")),...n.map(s=>ht(s,"dataset")),...l.map(s=>ht(s,"space")),...t.map(pn)],u=new Set;return x.filter(s=>!s||u.has(s.id)?!1:(u.add(s.id),!0))}function gn(t,a,n){const l=["# Requires the Hugging Face CLI: https://huggingface.co/docs/huggingface_hub/guides/cli",`HF_BUCKET=${Qe(t.trim())}`];n.create&&l.push(`hf buckets create "$HF_BUCKET" --exist-ok${n.isPrivate?" --private":""}`);for(const o of a.filter(x=>x.kind!=="github"&&x.kind!=="pdf"))l.push(`hf cp ${Qe(o.source)} "hf://buckets/$HF_BUCKET/${o.destination}"`);const i=a.find(o=>o.kind==="pdf");i&&l.push('PWC_PDF="$(mktemp)"',`trap 'rm -f "$PWC_PDF"' EXIT`,`curl --fail --location ${Qe(i.source)} --output "$PWC_PDF"`,`hf cp "$PWC_PDF" "hf://buckets/$HF_BUCKET/${i.destination}"`);const c=a.filter(o=>o.kind==="github");if(c.length){l.push('PWC_COPY_DIR="$(mktemp -d)"',`trap 'rm -rf "$PWC_COPY_DIR"' EXIT`);for(const o of c){const x=`$PWC_COPY_DIR/${o.destination.replace(/\/$/,"")}`;l.push(`git clone --depth 1 -- ${Qe(o.source)} "${x}"`,`hf sync "${x}" "hf://buckets/$HF_BUCKET/${o.destination}" --exclude '.git/**'`)}}return l.join(` -`)}function xn(t){return`${(t.split(/[:|–—]/,1)[0]||t).normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48).replace(/-+$/g,"")||"paper"}-artifacts`}function bn(t){const{toast:a}=pe(),n=h.useMemo(()=>fn({githubUrls:t.githubUrls,hfDatasetUrls:t.hfDatasetUrls,hfModelUrls:t.hfModelUrls,hfSpaceUrls:t.hfSpaceUrls,paperId:t.paperId,pdfName:t.pdfName,pdfUrl:t.pdfUrl}),[t.githubUrls,t.hfDatasetUrls,t.hfModelUrls,t.hfSpaceUrls,t.paperId,t.pdfName,t.pdfUrl]),l=h.useMemo(()=>mn(t.paperId),[t.paperId]),[i,c]=h.useState(!!l),[o,x]=h.useState((l==null?void 0:l.destinationMode)??"new"),[u,s]=h.useState((l==null?void 0:l.bucketId)??""),[w,k]=h.useState((l==null?void 0:l.visibility)??"public"),[I,N]=h.useState(()=>new Set((l==null?void 0:l.selectedIds)??n.map(m=>m.id))),[$,p]=h.useState(!1),[T,L]=h.useState(null),[R,B]=h.useState(!!l),D=n.filter(m=>I.has(m.id)),_=D.length===n.length,d=un(u),f=d!==null,v=gn(u,D,{create:o==="new",isPrivate:w==="private"}),F=(m,C)=>{N(P=>{const U=new Set(P);return C?U.add(m):U.delete(m),U})},O=async()=>{try{await navigator.clipboard.writeText(v),a({title:"Bucket copy commands copied",description:"Run them in a terminal where the Hugging Face CLI is signed in."})}catch{a({title:"Copy failed",description:"Could not access the clipboard. Select and copy the commands manually.",variant:"destructive"})}},K=h.useCallback(()=>{const m=wa("/api/v1/auth/hf/login"),C=new URL(window.location.href);C.searchParams.set(kt,t.paperId),window.sessionStorage.setItem(wt(t.paperId),JSON.stringify({paperId:t.paperId,bucketId:u.trim(),destinationMode:o,visibility:w,selectedIds:Array.from(I)}));const P=new URLSearchParams({return_to:C.toString(),authorize_bucket:"true"});o==="new"&&P.set("bucket_create","true"),window.location.assign(`${m}?${P.toString()}`)},[u,o,t.paperId,I,w]),Q=h.useCallback(async()=>{if(!t.isSignedIn){K();return}p(!0);let m=0,C=0;try{const P=D.filter(z=>z.kind!=="pdf"&&z.kind!=="github"&&!!z.repoId).map(z=>({kind:z.kind,repo_id:z.repoId})),U=hn(P);U.length||U.push([]);for(const[z,W]of U.entries()){L({current:z+1,total:U.length});const g=await Na(t.paperId,{bucket_id:u.trim(),create:z===0&&o==="new",private:w==="private",include_pdf:z===0&&D.some(S=>S.kind==="pdf"),artifacts:W});m+=g.copied.length,C+=g.errors.length}const E=D.filter(z=>z.kind==="github").length;a({title:C?"Bucket copy partially completed":"Copied to bucket",description:[`${m} item${m===1?"":"s"} copied.`,C?`${C} item${C===1?"":"s"} failed.`:"",E?"Use the generated commands below to copy GitHub repositories.":""].filter(Boolean).join(" "),variant:C?"destructive":void 0,action:d?e.jsx(Ca,{altText:"Open destination bucket",asChild:!0,children:e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",children:"Open bucket"})}):void 0}),!C&&!E&&c(!1)}catch(P){if(P instanceof jt&&P.code==="bucket_authorization_required"){K();return}a({title:m?"Bucket copy partially completed":"Bucket copy failed",description:m?`${m} item${m===1?"":"s"} copied before the request failed. You can retry or use the CLI commands below.`:P instanceof jt&&typeof P.detail=="string"?P.detail:"Hugging Face could not complete the copy. You can still use the CLI commands below.",variant:"destructive"})}finally{p(!1),L(null)}},[K,u,d,o,t.isSignedIn,t.paperId,D,a,w]);h.useEffect(()=>{if(!R||!t.isSignedIn)return;B(!1),window.sessionStorage.removeItem(wt(t.paperId));const m=new URL(window.location.href);m.searchParams.delete(kt),window.history.replaceState({},"",`${m.pathname}${m.search}${m.hash}`),Q()},[Q,t.isSignedIn,t.paperId,R]);const X=()=>{N(new Set(n.map(m=>m.id))),!u&&t.suggestedBucketId&&s(t.suggestedBucketId),c(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sidebar-card copy-to-bucket-card",children:[e.jsxs("button",{type:"button",className:"copy-to-bucket-trigger",onClick:X,children:[e.jsx("span",{className:"copy-to-bucket-arrow","aria-hidden":"true",children:"→"}),e.jsx("span",{className:"copy-to-bucket-title",children:"Copy to bucket"}),e.jsx("span",{className:"copy-to-bucket-new",children:"New"})]}),e.jsx("div",{className:"copy-to-bucket-meta",children:n.length?`${n.length} linked artifact${n.length===1?"":"s"}`:"No linked artifacts yet"})]}),e.jsx(oe,{open:i,onOpenChange:c,children:e.jsxs(le,{className:"max-h-[90vh] max-w-2xl grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden",children:[e.jsxs(ce,{children:[e.jsxs(de,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"copy-to-bucket-dialog-arrow","aria-hidden":"true",children:"→"}),"Copy to bucket"]}),e.jsx(ue,{children:"Keep your own copy of this paper's PDF, linked code, and Hugging Face artifacts. Hub repositories use Xet's server-side copy; GitHub repositories use the generated CLI fallback."})]}),e.jsx("div",{className:"-mx-6 min-h-0 overflow-y-auto px-6",children:n.length?e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ae,{children:"Choose your destination"}),e.jsxs(yt,{value:o,onValueChange:m=>x(m),className:"grid grid-cols-2 gap-2",children:[e.jsxs(ae,{className:"bucket-choice",children:[e.jsx(Fe,{value:"new"}),"New bucket"]}),e.jsxs(ae,{className:"bucket-choice",children:[e.jsx(Fe,{value:"existing"}),"Existing bucket"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ae,{htmlFor:"bucket-id",children:"Bucket name"}),e.jsx(Z,{id:"bucket-id",value:u,onChange:m=>s(m.target.value),placeholder:t.suggestedBucketId||"username/paper-artifacts","aria-invalid":u.length>0&&!f}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[e.jsx("p",{className:"text-muted-foreground",children:"Use the full Hugging Face bucket ID: namespace/name."}),d&&e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"inline-flex shrink-0 items-center gap-1 underline underline-offset-4",children:["View bucket",e.jsx(J,{name:"external",size:10})]})]})]}),o==="new"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ae,{children:"Bucket visibility"}),e.jsxs(yt,{value:w,onValueChange:m=>k(m),className:"flex gap-5",children:[e.jsxs(ae,{className:"flex items-center gap-2 font-normal",children:[e.jsx(Fe,{value:"public"}),"Public"]}),e.jsxs(ae,{className:"flex items-center gap-2 font-normal",children:[e.jsx(Fe,{value:"private"}),"Private"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(ae,{children:"Artifacts"}),e.jsx(H,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>N(_?new Set:new Set(n.map(m=>m.id))),children:_?"Deselect all":"Select all"})]}),e.jsx("div",{className:"bucket-artifact-list",children:n.map(m=>e.jsxs("div",{className:"bucket-artifact-row",children:[e.jsx(tt,{id:`bucket-artifact-${m.id}`,checked:I.has(m.id),onCheckedChange:C=>F(m.id,C===!0)}),e.jsxs(ae,{htmlFor:`bucket-artifact-${m.id}`,className:"min-w-0 flex-1 cursor-pointer font-normal",children:[e.jsx("span",{className:"bucket-artifact-kind",children:ln[m.kind]}),e.jsx("span",{className:"bucket-artifact-name",children:m.label})]}),e.jsxs("a",{href:Ne(m.url)??void 0,target:"_blank",rel:"noopener noreferrer",className:"bucket-artifact-open",children:["Open",e.jsx(J,{name:"external",size:10})]})]},m.id))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The PDF and Hugging Face artifacts can be copied directly. GitHub repositories require the CLI workflow below."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ae,{htmlFor:"bucket-copy-commands",children:"CLI fallback"}),e.jsx("pre",{id:"bucket-copy-commands",className:"bucket-copy-commands h-[190px]",children:f?v:"Enter a bucket name above to prepare the copy commands."})]})]}):e.jsx("p",{className:"py-5 text-sm text-muted-foreground",children:"This paper does not have a linked GitHub repository or Hugging Face artifact to copy yet."})}),e.jsxs(me,{children:[e.jsx("a",{href:"https://huggingface.co/docs/huggingface_hub/en/guides/buckets",target:"_blank",rel:"noopener noreferrer",className:"mr-auto text-sm text-muted-foreground underline underline-offset-4",children:"About Hugging Face Buckets"}),e.jsxs(H,{type:"button",onClick:O,variant:"outline",disabled:!f||D.length===0,children:[e.jsx(J,{name:"copy",size:12}),"Copy commands"]}),e.jsx(H,{type:"button",onClick:Q,disabled:$||t.isSignedIn&&(!f||!D.some(m=>m.kind!=="github")),children:$?T&&T.total>1?`Copying ${T.current}/${T.total}…`:"Copying…":t.isSignedIn?"Copy now":"Sign in & copy"})]})]})})]})}const jn={tasks:"tasks",methods:"methods",results:"evaluation results",repositories:"GitHub repositories","project-pages":"project pages","hf-artifacts":"Hugging Face artifacts",organizations:"organizations","source-url":"source URL"},Ve=360,pt=3,us=3,vn=["tldr","abstract","tasks","methods","results"];function yn(t){if(!t)return{section:null,resultsTaskSlug:null};const[a,n]=t.split("?",2);if(!vn.includes(a))return{section:null,resultsTaskSlug:null};const l=a;return l!=="results"||!n?{section:l,resultsTaskSlug:null}:{section:l,resultsTaskSlug:new URLSearchParams(n).get("task")}}function ms(t){return`results-task-${t}`}function _n(t){return`#results?task=${encodeURIComponent(t)}`}function Ae({id:t,label:a,accent:n}){return e.jsxs("div",{className:"section-rule paper-section-anchor",id:t,children:[e.jsx("span",{children:e.jsx("a",{href:`#${t}`,className:"section-anchor-link",children:a})}),n]})}function hs(t){if(!t)return"—";try{return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return"—"}}function ps(t){return t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function ft(t,a){try{const n=new URL(t),i=n.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);return i?i.replace(/[-_]+/g," "):n.hostname.replace(/^www\./,"")}catch{return a}}const Zn=()=>{var Gt,Qt,Vt,Jt,Xt,Wt,Yt,Zt,es,ts;const{arxivId:t}=Ea(),a=t?Sa(t):"",n=Ia(),{toast:l}=pe(),{user:i}=We(),c=(i==null?void 0:i.is_admin)??!1,o=!!i,x=dr(i),u=!0,{data:s,isLoading:w,error:k,refetch:I}=Va(a||"",!!a),[N,$]=h.useState(!1);h.useEffect(()=>{if(!t||t===a)return;const r=window.location.search+window.location.hash;n(`/paper/${a}${r}`,{replace:!0})},[a,n,t]),h.useEffect(()=>{if(s!=null&&s.title)return document.title=Ga(s.title),()=>{document.title=Qa}},[s==null?void 0:s.title]),h.useEffect(()=>{if($(!1),!(s!=null&&s.id))return;const r=window.setTimeout(()=>$(!0),0);return()=>window.clearTimeout(r)},[s==null?void 0:s.id]);const{data:p,isLoading:T}=xr(N?s==null?void 0:s.arxiv_id:void 0),{data:L,isLoading:R,refetch:B}=hr(s==null?void 0:s.id,N&&!!(s!=null&&s.id));h.useEffect(()=>{const r=()=>{I(),B(),x==="direct"&&(s!=null&&s.id)&&(re.primePaperCurationState(s.id,!0).catch(()=>{}),re.primeEvaluationCurationState(s.id,!0).catch(()=>{})),l({title:"This section changed",description:"The latest state has been reloaded. Review your changes before submitting again.",variant:"destructive"})};return window.addEventListener("pwc:catalog-conflict",r),()=>window.removeEventListener("pwc:catalog-conflict",r)},[x,s==null?void 0:s.id,I,B,l]);const{preferences:D}=Pa(),_=h.useMemo(()=>!L||!D.hide_closed_source_evals?L:L.filter(r=>r.is_open!==!1),[L,D.hide_closed_source_evals]),d=h.useMemo(()=>({models:(s==null?void 0:s.hf_models)??[],datasets:(s==null?void 0:s.hf_datasets)??[],spaces:(s==null?void 0:s.hf_spaces)??[]}),[s==null?void 0:s.hf_models,s==null?void 0:s.hf_datasets,s==null?void 0:s.hf_spaces]),f=h.useMemo(()=>{const r=(y,G,V)=>{const se=new Set,Y=[];for(const te of[...y,...G??[]])se.has(te)||(se.add(te),Y.push({href:te,label:ft(te,V)}));return Y};return{models:r(d.models,p==null?void 0:p.modelUrls,"Model"),datasets:r(d.datasets,p==null?void 0:p.datasetUrls,"Dataset"),spaces:r(d.spaces,p==null?void 0:p.spaceUrls,"Space")}},[d.models,d.datasets,d.spaces,p==null?void 0:p.modelUrls,p==null?void 0:p.datasetUrls,p==null?void 0:p.spaceUrls]),v=h.useMemo(()=>{if(!_)return[];const r=new Map;for(const y of _){const G=y.task_id,V=r.get(G);V?V.rows.push(y):r.set(G,{taskId:G,taskName:y.task_name||"—",taskSlug:y.task_slug,rows:[y]})}return Array.from(r.values())},[_]),F=h.useMemo(()=>v.map(r=>r.taskSlug??"").join("|"),[v]),O=ne({queryKey:["paper-versions",s==null?void 0:s.arxiv_id],queryFn:async()=>{const r=s.arxiv_id.replace(/v\d+$/,""),y=await fetch(vs(`/api/v1/papers/arxiv/${r}/versions`));return y.ok?await y.json():[]},enabled:N&&!!(s!=null&&s.arxiv_id),staleTime:10*60*1e3}),K=ne({queryKey:["related-papers",s==null?void 0:s.id],queryFn:()=>re.getRelatedPapers(s.arxiv_id||s.id,4),enabled:N&&!!(s!=null&&s.id),staleTime:10*60*1e3}),[Q,X]=h.useState(!1),[m,C]=h.useState(!1),[P,U]=h.useState(!1),E=h.useRef(!1);h.useEffect(()=>{E.current=!1},[a]),h.useEffect(()=>{let r=0;const y=(V=!1,se=!1)=>{const{section:Y,resultsTaskSlug:te}=yn(window.location.hash.slice(1));if(!Y||!s||Y==="tldr"&&!s.tldr||Y==="results"&&(!N||R)||!V&&E.current)return;let we=null;if(Y==="results"&&te){if(we=document.getElementById(ms(te)),!we){if(v.find(oa=>oa.taskSlug===te))return;we=document.getElementById("results")}}else we=document.getElementById(Y);if(!we)return;const ia=we;r=window.requestAnimationFrame(()=>{E.current=!0,ia.scrollIntoView({block:"start",behavior:se?"smooth":"auto"})})};y();const G=()=>{E.current=!1,y(!0,!0)};return window.addEventListener("hashchange",G),()=>{window.removeEventListener("hashchange",G),r&&window.cancelAnimationFrame(r)}},[s,s==null?void 0:s.tldr,N,R,F,v]);const{activeEditor:z,openEditor:W,setEditorOpen:g}=vr();h.useEffect(()=>{x!=="direct"||!(s!=null&&s.id)||(z&&z!=="results"&&re.primePaperCurationState(s.id).catch(()=>{}),z==="results"&&re.primeEvaluationCurationState(s.id).catch(()=>{}))},[z,x,s==null?void 0:s.id]);const[S,A]=h.useState(null),b=h.useRef(!1);h.useEffect(()=>{if(!i||!s||b.current)return;const r=sessionStorage.getItem("pwc:fresh-auth-edit");if(!r)return;b.current=!0;const y=jr(r);if(!re.freshAuthMutationDraft()){sessionStorage.removeItem("pwc:fresh-auth-edit"),y&&W(y);return}if(!window.confirm("You signed in again. Apply the saved destructive catalog edit now? The server will recheck the current catalog version before changing anything.")){l({title:"Edit kept locally",description:"Nothing was changed. Reload this paper when you are ready to confirm the saved edit."});return}re.resumeFreshAuthMutation().then(()=>{l({title:"Edit applied",description:"The restored catalog edit was applied."}),window.location.reload()}).catch(V=>{l({variant:"destructive",title:"Could not apply the saved edit",description:V instanceof Error?V.message:"Please reload and review the edit again."})})},[W,s,l,i]);const j=h.useMemo(()=>{if(!i||!(s!=null&&s.author_links))return!1;const r=i.username.toLowerCase();return s.author_links.some(y=>!!y.hf_username&&y.hf_username.toLowerCase()===r)},[i,s==null?void 0:s.author_links]),q=r=>{if(!o){A(r);return}W(r)},[M,ee]=h.useState("idle"),[Se,At]=h.useState(null),[Rt,Ft]=h.useState(null),Vs=async()=>{if(a){ee("indexing"),At(null),Ft(null);try{await Ua(a),l({title:"Indexed",description:"Paper added to database."}),setTimeout(()=>I(),1200),ee("idle")}catch(r){const y=r;let G=y.message||"Failed to index paper";if(y.response)try{G=JSON.parse(y.response).detail||G}catch{G=y.response}At(G),(y.status===429||y.status===503)&&Ft("Try again later after arXiv has lifted the temporary limit."),ee("idle")}}},{citationDisplay:Js,citationCopy:Tt}=h.useMemo(()=>{if(!s)return{citationDisplay:"",citationCopy:""};const r=`${s.title.slice(0,60)}${s.title.length>60?"…":""}`,y=`${s.authors[0]||""}${s.authors.length>1?" et al.":""}`,G=s.authors.join(" and "),V=(s.published||"").slice(0,4)||"—",se=(Y,te)=>s.arxiv_id?`@article{${s.arxiv_id.replace(".","")}, - title={{${Y}}}, - author=${te}, - year={{${V}}}, - eprint={{${s.arxiv_id}}}, - archivePrefix={{arXiv}} -}`:`@misc{paper${s.id}, - title={{${Y}}}, - author=${te}, - year={{${V}}}, - url={{${s.source_url||s.url_abs||""}}} -}`;return{citationDisplay:se(r,`{{${y}}}`),citationCopy:se(s.title,`{${G}}`)}},[s]),Lt=h.useMemo(()=>ur(s==null?void 0:s.leaderboard_ranks),[s==null?void 0:s.leaderboard_ranks]),[Xs,Ut]=h.useState(!1),Ws=async()=>{if(Tt)try{await navigator.clipboard.writeText(Tt),Ut(!0),l({title:"Citation copied",description:"BibTeX entry copied to clipboard."}),window.setTimeout(()=>Ut(!1),1500)}catch{l({title:"Copy failed",description:"Could not access the clipboard. Please copy manually.",variant:"destructive"})}},Ys=async()=>{if(!s)return;const r=s.arxiv_id||s.id,y=mr(r,Lt);if(y)try{await navigator.clipboard.writeText(y),l({title:"PwC badges copied",description:"Each badge follows its current leaderboard result."})}catch{l({title:"Copy failed",description:"Could not access the clipboard. Please try again.",variant:"destructive"})}};if(w)return e.jsxs("div",{className:"page",children:[e.jsx(Re,{className:"h-12 w-3/4 mb-4"}),e.jsx(Re,{className:"h-6 w-1/3 mb-8"}),e.jsx(Re,{className:"h-64 w-full"})]});if(k||!s)return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"breadcrumb",children:[e.jsx(xe,{to:"/papers",children:"Papers"}),e.jsx("span",{className:"sep",children:"/"}),e.jsxs("span",{style:{color:"var(--ink)"},children:["arXiv:",a]})]}),e.jsx("h1",{className:"detail-title",children:"Paper not indexed yet"}),e.jsxs("p",{style:{fontFamily:"var(--serif)",color:"var(--ink-soft)",marginTop:16,maxWidth:640},children:["We don't have ",e.jsxs("span",{style:{fontFamily:"var(--mono)"},children:["arXiv:",a]})," in the database. You can index it from arXiv right now."]}),Se&&e.jsx(Ja,{variant:"destructive",className:"mt-4 max-w-xl",children:e.jsxs(Xa,{children:[e.jsx("div",{children:Se}),Rt&&e.jsx("div",{className:"mt-2",children:Rt})]})}),e.jsxs("div",{className:"action-row",children:[c&&e.jsxs("button",{className:"action-btn",onClick:Vs,disabled:M==="indexing",children:[e.jsx(J,{name:"sparkle",size:12}),M==="indexing"?"Indexing…":"Index from arXiv"]}),e.jsx(H,{variant:"outline",onClick:()=>n("/papers"),children:"Browse Papers"})]})]});const Dt=O.data||[],Ie=Ka(s.repositories),ge=[...s.repositories??[]].sort((r,y)=>{const G=r.is_official?1:0,V=y.is_official?1:0;return G!==V?V-G:(y.num_stars||0)-(r.num_stars||0)}),Zs=(P?ge:ge.slice(0,pt)).map(r=>({...r,safeHref:Ne(r.url)})),at={models:[...new Set([...d.models,...(p==null?void 0:p.modelUrls)??[]])],datasets:[...new Set([...d.datasets,...(p==null?void 0:p.datasetUrls)??[]])],spaces:[...new Set([...d.spaces,...(p==null?void 0:p.spaceUrls)??[]])]},rt=((Gt=s.arxiv_id)==null?void 0:Gt.replace(/v\d+$/,""))??null,nt=s.arxiv_id?{isLoading:T,paperHref:`https://huggingface.co/papers/${rt}`,rows:[{label:"Models",href:xt(`https://huggingface.co/models?other=arxiv:${s.arxiv_id}`,d.models),count:bt(d.models,p==null?void 0:p.modelUrls,p==null?void 0:p.models),isLimited:p==null?void 0:p.isLimited,links:f.models},{label:"Datasets",href:xt(`https://huggingface.co/datasets?other=arxiv:${s.arxiv_id}`,d.datasets),count:bt(d.datasets,p==null?void 0:p.datasetUrls,p==null?void 0:p.datasets),isLimited:p==null?void 0:p.isLimited,links:f.datasets},{label:"Spaces",href:xt(`https://huggingface.co/papers/${rt}`,d.spaces),count:bt(d.spaces,p==null?void 0:p.spaceUrls,p==null?void 0:p.spaces),isLimited:p==null?void 0:p.isLimited,links:f.spaces}],footer:`Cite arxiv.org/abs/${rt} in a HF README to link it here.`}:{isLoading:!1,paperHref:null,rows:[{label:"Models",href:gt(d.models),count:d.models.length,links:f.models},{label:"Datasets",href:gt(d.datasets),count:d.datasets.length,links:f.datasets},{label:"Spaces",href:gt(d.spaces),count:d.spaces.length,links:f.spaces}],footer:null},Bt=s.tldr||null,Ht=s.num_pages||null,ke=s.abstract||"",ea=ke.length>Ve?ke.slice(0,Ve)+"…":ke,ta=Q||ke.length<=Ve?ke:ea,De=(s.methods||[]).filter(r=>r.source_paper_id===s.id),Be=s.introduced_benchmarks||[],Pe=s.introduced_frameworks||[],sa=De.length>0||Be.length>0||Pe.length>0,Mt=s.arxiv_id?`arXiv:${s.arxiv_id}`:"External resource",aa=s.source==="external"?"Source page":"arXiv page",zt=Ne(s.url_pdf),qt=Ne(s.url_abs),Ot=Ne(s.conference_url_abs),$e=((Qt=s.project_pages)==null?void 0:Qt.filter(r=>r.url).map(r=>({...r,safeHref:Ne(r.url)})))??[],ra=(()=>{const r=[];return De.length>0&&r.push(De.length===1?"this method":"these methods"),Be.length>0&&r.push(Be.length===1?"this benchmark":"these benchmarks"),Pe.length>0&&r.push(Pe.length===1?"this framework":"these frameworks"),r.length===0?"":r.length===1?r[0]:r.join(" and ")})(),He=s.predecessor_papers||[],Me=s.successor_papers||[],na=He.length>0||Me.length>0,ze=12,it=s.authors.map((r,y)=>{var G,V,se,Y;return{name:r,id:((V=(G=s.author_links)==null?void 0:G[y])==null?void 0:V.id)??null,hf_username:((Y=(se=s.author_links)==null?void 0:se[y])==null?void 0:Y.hf_username)??null}}),Kt=m||it.length<=ze?it:it.slice(0,ze);return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"breadcrumb",children:[e.jsx(xe,{to:"/",children:"Trending"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("span",{children:Mt})]}),e.jsxs("div",{className:"detail-grid",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"detail-hero",children:[e.jsxs("div",{className:"detail-hero-main",children:[e.jsx("h1",{className:"detail-title",children:e.jsx(qe,{title:s.title})}),e.jsxs("div",{className:"detail-meta",children:[e.jsx("span",{children:Mt}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:["Submitted ",hs(s.published)]}),Ht&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[Ht," pages"]})]}),s.citation_count!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[s.citation_count.toLocaleString()," citations"]})]}),(s.proceeding||s.conference_slug)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),s.conference_slug?e.jsx("a",{href:`/conferences/${s.conference_slug}`,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent-text)"},children:(s.proceeding||s.conference_name||"").replace(/\s+\d{1,2}$/,"")}):e.jsx("span",{children:s.proceeding.replace(/\s+\d{1,2}$/,"")})]}),Dt.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("select",{className:"version-select",value:s.version,onChange:r=>{const y=r.target.value;s.arxiv_id&&n(`/paper/${s.arxiv_id.replace(/v\d+$/,"")}${y?`?version=${y}`:""}`)},children:Dt.map(r=>e.jsxs("option",{value:r.version,children:[r.version," — ",hs(r.published)]},r.version))})]})]}),e.jsxs("div",{className:"detail-authors",children:[Kt.map((r,y)=>e.jsxs(Xe.Fragment,{children:[r.id?e.jsx(xe,{to:`/authors/${r.id}`,children:r.name}):r.hf_username?e.jsx("a",{href:`https://huggingface.co/${r.hf_username}`,target:"_blank",rel:"noopener noreferrer",title:`@${r.hf_username} on Hugging Face`,children:r.name}):e.jsx("a",{children:r.name}),yze&&e.jsx("button",{className:"show-more-authors",onClick:()=>C(r=>!r),style:{marginLeft:8,background:"none",border:"none",cursor:"pointer",color:"var(--accent-text)",fontFamily:"var(--mono)",fontSize:12},children:m?"show fewer":`+${s.authors.length-ze} more`})]}),e.jsxs("div",{className:"action-row",children:[zt&&e.jsxs("a",{className:"action-btn",href:zt,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(J,{name:"pdf",size:12})," View PDF"]}),qt&&e.jsx(Ge,{showEdit:s.source==="external"&&u,onEdit:()=>q("source-url"),editAriaLabel:"Edit source URL",children:e.jsxs("a",{className:s.source==="external"&&u?"action-btn-segment action-btn-main":"action-btn",href:qt,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(J,{name:"external",size:12})," ",aa]})}),nt.paperHref&&(p==null?void 0:p.paperExists)&&e.jsxs("a",{className:"bm-action-btn",href:nt.paperHref,target:"_blank",rel:"noopener noreferrer","aria-label":"View on Hugging Face",children:["View on ",e.jsx("span",{"aria-hidden":"true",children:"🤗"})]}),Ie.githubUrl&&e.jsx(Ge,{showEdit:u,onEdit:()=>q("repositories"),editAriaLabel:"Edit code repositories",children:e.jsxs("a",{className:"action-btn-segment action-btn-main",href:Ie.githubUrl,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(J,{name:"github",size:12})," Code",Ie.github!=null&&e.jsxs("span",{style:{opacity:.7,marginLeft:4},children:["· ",ps(Ie.github)," ★"]})]})}),Ie.githubUrl?null:e.jsxs("button",{type:"button",className:"action-btn",onClick:()=>q("repositories"),title:"Add GitHub repository",children:[e.jsx(J,{name:"github",size:12})," Add code"]}),$e.length===1?e.jsx(Ge,{showEdit:u,onEdit:()=>q("project-pages"),editAriaLabel:"Edit project pages",children:e.jsxs("a",{className:"action-btn-segment action-btn-main",href:$e[0].safeHref??void 0,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(J,{name:"globe",size:12})," Project page"]})}):null,$e.length>1?e.jsx(Ge,{showEdit:u,onEdit:()=>q("project-pages"),editAriaLabel:"Edit project pages",children:e.jsxs($a,{children:[e.jsx(Aa,{asChild:!0,children:e.jsxs("button",{type:"button",className:"action-btn-segment action-btn-main",children:[e.jsx(J,{name:"globe",size:12})," Project page"]})}),e.jsx(Ra,{align:"start",className:"project-page-menu",children:$e.map((r,y)=>e.jsx(Fa,{asChild:!0,children:r.safeHref?e.jsx("a",{href:r.safeHref,target:"_blank",rel:"noopener noreferrer",children:ft(r.url,`Project page ${y+1}`)}):e.jsx("span",{children:ft(r.url,`Project page ${y+1}`)})},r.url))})]})}):null,$e.length===0&&o?e.jsxs("button",{type:"button",className:"action-btn",onClick:()=>q("project-pages"),title:"Add project page",children:[e.jsx(J,{name:"globe",size:12})," Add project page"]}):null,Ot&&e.jsxs("a",{className:"action-btn",href:Ot,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(J,{name:"external",size:12})," Conference"]}),(s.organizations||[]).map(r=>e.jsxs(xe,{to:`/orgs/${r.slug}`,className:"action-btn",title:r.name,"aria-label":r.name,children:[r.logo_url&&e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:16,width:16,borderRadius:3,overflow:"hidden"},children:e.jsx("img",{src:r.logo_url,alt:"",style:{height:"150%",width:"150%",objectFit:"contain"},onError:y=>{y.currentTarget.style.display="none"}})}),r.name]},r.id)),e.jsx("button",{type:"button",className:"action-btn",onClick:()=>q("organizations"),children:"Edit organizations"}),c&&nr()&&e.jsx(Xr,{paperId:Number(s.id),paperTitle:s.title,onComplete:()=>void I()}),e.jsx(Gr,{paperId:s.id})]}),s.leaderboard_ranks&&s.leaderboard_ranks.length>0&&e.jsx(Da,{wrap:!0,paperHref:`/paper/${s.arxiv_id||s.id}`,ranks:s.leaderboard_ranks.filter(r=>r.best_rank>=1&&r.best_rank<=3).map(r=>({name:r.dataset_name,slug:r.dataset_slug||null,rank:r.best_rank}))})]}),e.jsx("div",{className:"detail-hero-thumb detail-thumb-wrap",children:e.jsx(Ba,{paperId:s.arxiv_id||s.id,title:s.title,thumbnailUrl:Ta(s.thumbnail_url),priority:!0})})]}),sa&&e.jsxs("div",{className:`introduced-banner${Pe.length>0?" introduced-banner--framework":""}`,children:[e.jsx("span",{className:"introduced-label",children:"Introduced"}),e.jsxs("div",{className:"introduced-methods",children:[De.map(r=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>n(`/methods/${r.slug||r.id}`),children:[r.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`method-${r.id}`)),Be.map(r=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>n(`/benchmark/${r.slug||r.id}`),children:[r.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`benchmark-${r.id}`)),Pe.map(r=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>n(`/frameworks#framework-${r.slug}`),children:[r.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`framework-${r.slug}`))]}),e.jsxs("span",{className:"introduced-note",children:["This paper is the canonical source for ",ra,"."]})]}),na&&e.jsxs("div",{className:"introduced-banner lineage-banner",children:[Me.length>0&&e.jsxs("div",{className:"lineage-row",children:[e.jsx("span",{className:"introduced-label lineage-label",children:Me.length===1?"Follow-up paper":"Follow-up papers"}),e.jsx("div",{className:"introduced-methods",children:Me.map(r=>e.jsxs("button",{type:"button",className:"introduced-pill lineage-pill",onClick:()=>n(`/paper/${r.route_identifier}`),children:[e.jsx(qe,{title:r.title}),e.jsx("span",{className:"introduced-arrow",children:"→"})]},`successor-${r.id}`))})]}),He.length>0&&e.jsxs("div",{className:"lineage-row",children:[e.jsx("span",{className:"introduced-label lineage-label",children:He.length===1?"Predecessor paper":"Predecessor papers"}),e.jsx("div",{className:"introduced-methods",children:He.map(r=>e.jsxs("button",{type:"button",className:"introduced-pill lineage-pill",onClick:()=>n(`/paper/${r.route_identifier}`),children:[e.jsx("span",{className:"introduced-arrow lineage-arrow-back",children:"←"}),e.jsx(qe,{title:r.title})]},`predecessor-${r.id}`))})]})]}),Bt&&e.jsxs(e.Fragment,{children:[e.jsx(Ae,{id:"tldr",label:"TL;DR · AI-generated"}),e.jsx("div",{className:"tldr-box",children:Bt})]}),e.jsx(Ae,{id:"abstract",label:"Abstract"}),e.jsx("p",{className:"abstract-text",style:{marginBottom:8},children:e.jsx(Oa,{text:ta})}),ke.length>Ve&&e.jsx("div",{className:"read-full",onClick:()=>X(r=>!r),children:Q?"− collapse abstract":"+ read full abstract"}),e.jsx(Ae,{id:"tasks",label:"Tasks",accent:e.jsxs("span",{className:"accent",children:[((Vt=s.tasks)==null?void 0:Vt.length)||0," tagged",e.jsx("button",{type:"button",onClick:()=>q("tasks"),className:"edit-link",children:"edit"})]})}),e.jsx("div",{className:"paper-tags",style:{marginBottom:8},children:(s.tasks||[]).map(r=>e.jsx(Ha,{slug:r.slug||"",label:r.name},r.id))}),e.jsx(Ae,{id:"methods",label:"Methods",accent:e.jsxs("span",{className:"accent",children:[((Jt=s.methods)==null?void 0:Jt.length)||0," used",e.jsx("button",{type:"button",onClick:()=>q("methods"),className:"edit-link",children:"edit"})]})}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:8},children:(s.methods||[]).map(r=>e.jsx(Ma,{method:r},r.id))}),e.jsx(Ae,{id:"results",label:"Results",accent:e.jsxs("span",{className:"accent",children:[(_==null?void 0:_.length)||0," benchmarks",Lt.length>0&&e.jsxs("button",{type:"button",className:"edit-link results-badge-copy",onClick:Ys,title:"Copy live leaderboard badges for your repository README",children:[e.jsx(J,{name:"copy",size:10})," Copy PwC badge"]}),c&&ir()&&e.jsx(Jr,{paperId:Number(s.id),paperTitle:s.title,onComplete:()=>void B()}),e.jsx("button",{type:"button",onClick:()=>q("results"),className:"edit-link",children:"edit"})]})}),R?e.jsx(Re,{className:"h-32 w-full"}):v.length>0?v.map(r=>e.jsxs("div",{className:r.taskSlug?"paper-section-anchor":void 0,id:r.taskSlug?ms(r.taskSlug):void 0,children:[e.jsxs("div",{className:"section-rule",children:[e.jsx("span",{children:r.taskSlug?e.jsxs(e.Fragment,{children:[e.jsx(xe,{to:`/tasks/${r.taskSlug}`,children:r.taskName}),e.jsx("a",{href:_n(r.taskSlug),className:"section-anchor-link results-task-permalink","aria-label":`Permalink to ${r.taskName} results on this paper`,title:"Link to this task's results",children:"#"})]}):r.taskName}),e.jsxs("span",{className:"accent",children:[r.rows.length," ",r.rows.length===1?"result":"results"]})]}),e.jsxs("table",{className:"results-table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"28%"}}),e.jsx("col",{style:{width:"28%"}}),e.jsx("col",{style:{width:"14%"}}),e.jsx("col",{style:{width:"12%"}}),e.jsx("col",{style:{width:"8%"}}),e.jsx("col",{style:{width:"10%"}})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Benchmark"}),e.jsx("th",{children:"Model"}),e.jsx("th",{children:"Metric"}),e.jsx("th",{children:"Value"}),e.jsx("th",{children:"Rank"}),e.jsx("th",{children:"Compare"})]})}),e.jsx("tbody",{children:r.rows.map(y=>{var G;return e.jsxs("tr",{children:[e.jsx("td",{className:"benchmark",children:y.dataset_slug?e.jsx(xe,{to:`/benchmark/${y.dataset_slug}`,children:y.dataset_name||"—"}):y.dataset_name||"—"}),e.jsxs("td",{className:"model",title:y.model_name||void 0,children:[y.hf_model_url?e.jsx("a",{href:y.hf_model_url,target:"_blank",rel:"noopener noreferrer",className:"model-hf-link",title:`Open ${y.model_name||"model"} on Hugging Face`,children:y.model_name||"—"}):y.model_name||"—",y.is_open===!1&&e.jsx(za,{}),(y.external??y.is_external)&&e.jsx(qa,{sourceUrl:y.source_url||y.external_source_url||y.result_url})]}),e.jsx("td",{className:"metric",children:y.best_metric}),e.jsx("td",{className:"value",children:La((G=y.metrics)==null?void 0:G[y.best_metric||""])}),e.jsx("td",{className:"rank",children:y.best_rank!=null?`#${y.best_rank}`:"—"}),e.jsx("td",{className:"compare",children:y.dataset_slug&&e.jsx(xe,{to:`/benchmark/${y.dataset_slug}?${[y.task_slug?`task=${encodeURIComponent(y.task_slug)}`:"",`eval=${encodeURIComponent(y.id)}`].filter(Boolean).join("&")}`,children:"Compare →"})})]},y.id)})})]})]},r.taskId)):e.jsx("p",{style:{fontFamily:"var(--mono)",fontSize:12,color:"var(--ink-faint)"},children:"No benchmark results recorded yet."})]}),e.jsxs("aside",{className:"detail-sidebar",children:[e.jsxs("div",{className:"sidebar-card",children:[e.jsxs("div",{className:"sidebar-card-title",children:[e.jsx("span",{children:"GitHub"}),e.jsxs("span",{className:"badge",children:[ge.length," repo",ge.length===1?"":"s",e.jsx("button",{type:"button",onClick:()=>q("repositories"),className:"edit-link",children:"edit"})]})]}),Zs.filter(r=>r.safeHref).map(r=>e.jsxs("a",{href:r.safeHref??void 0,target:"_blank",rel:"noopener noreferrer",className:"code-line",style:{textDecoration:"none"},children:[e.jsxs("span",{className:"code-line-repo",children:[e.jsx(J,{name:"github",size:12}),e.jsxs("span",{className:"code-line-repo-name",children:[r.owner,"/",r.name]}),r.is_official&&e.jsx("span",{className:"code-line-official",children:"· Official"})]}),e.jsxs("span",{className:"code-line-stars",children:["★ ",ps(r.num_stars)]})]},r.id)),ge.length===0&&e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--ink-faint)",padding:"6px 0"},children:"No GitHub repositories linked yet."}),ge.length>pt&&e.jsx("button",{type:"button",className:"bench-show-more",onClick:()=>U(r=>!r),children:P?"− show top 3":`+ show ${ge.length-pt} more repos`})]}),e.jsx(kn,{viewer:nt,onEdit:()=>q("hf-artifacts")}),e.jsx(bn,{githubUrls:ge.map(r=>r.url),hfModelUrls:at.models,hfDatasetUrls:at.datasets,hfSpaceUrls:at.spaces,paperId:s.id,pdfName:((Xt=s.arxiv_id)==null?void 0:Xt.replace("/","-"))||s.id,pdfUrl:s.url_pdf,isSignedIn:!!i,suggestedBucketId:i?`${i.username}/${xn(s.title)}`:void 0}),K.isLoading&&e.jsxs("div",{className:"sidebar-card","aria-busy":"true",children:[e.jsx("div",{className:"sidebar-card-title",children:"Related papers"}),e.jsx("div",{className:"related-meta",children:"Finding related work…"})]}),!K.isLoading&&(((Wt=K.data)==null?void 0:Wt.length)??0)>0&&e.jsxs("div",{className:"sidebar-card",children:[e.jsx("div",{className:"sidebar-card-title",children:"Related papers"}),K.data.map(r=>e.jsxs(xe,{to:`/paper/${r.arxiv_id||r.id}`,target:"_blank",rel:"noopener noreferrer",className:"related-paper",style:{textDecoration:"none",color:"inherit"},children:[e.jsx("div",{className:"related-title",children:e.jsx(qe,{title:r.title})}),e.jsxs("div",{className:"related-meta",children:[e.jsx("span",{children:r.arxiv_id?`arXiv:${r.arxiv_id}`:"External resource"}),r.citation_count!=null&&e.jsxs("span",{children:[r.citation_count.toLocaleString()," cites"]})]})]},r.id))]}),e.jsxs("div",{className:"sidebar-card",children:[e.jsxs("div",{className:"sidebar-card-title",children:[e.jsx("span",{children:"Citation"}),e.jsxs("button",{type:"button",className:"citation-copy-btn",onClick:Ws,"aria-label":"Copy citation to clipboard",title:"Copy citation to clipboard",children:[e.jsx(J,{name:"copy",size:11}),Xs?"Copied":"Copy"]})]}),e.jsx("pre",{style:{fontFamily:"var(--mono)",fontSize:10.5,lineHeight:1.5,color:"var(--ink-soft)",whiteSpace:"pre-wrap",wordBreak:"break-word",margin:0},children:Js})]})]})]}),e.jsx(Sr,{open:z==="tasks",onOpenChange:r=>g("tasks",r),paperId:s.id,arxivId:a,initialTaskIds:((Yt=s.tasks)==null?void 0:Yt.map(r=>parseInt(r.id)))||[],initialTasks:s.tasks||[],submitMode:x,isAuthor:j}),e.jsx($r,{open:z==="methods",onOpenChange:r=>g("methods",r),paperId:s.id,arxivId:a,initialMethodIds:((Zt=s.methods)==null?void 0:Zt.map(r=>parseInt(r.id)))||[],initialMethods:s.methods||[],submitMode:x,isAuthor:j}),e.jsx(Ar,{open:z==="repositories",onOpenChange:r=>g("repositories",r),paperId:s.id,arxivId:a,initialRepositories:((es=s.repositories)==null?void 0:es.map(r=>({url:r.url,is_official:r.is_official||!1})))||[],submitMode:x,isAuthor:j}),e.jsx(Rr,{open:z==="project-pages",onOpenChange:r=>g("project-pages",r),paperId:s.id,arxivId:a,initialProjectPages:((ts=s.project_pages)==null?void 0:ts.map(r=>({url:r.url,is_official:r.is_official||!1})))||[],submitMode:x,isAuthor:j}),e.jsx(Br,{open:z==="results",onOpenChange:r=>g("results",r),paperId:s.id,arxivId:a,initialEvaluations:L||[],paperTasks:s.tasks||[],submitMode:x,isAdmin:c,isAuthor:j}),e.jsx(Fr,{open:z==="source-url",onOpenChange:r=>g("source-url",r),paperId:s.id,arxivId:a,initialUrl:s.source_url??s.url_abs??"",submitMode:x,isAuthor:j}),e.jsx(Mr,{open:z==="hf-artifacts",onOpenChange:r=>g("hf-artifacts",r),paperId:s.id,arxivId:a,initialArtifacts:{hf_models:d.models,hf_datasets:d.datasets,hf_spaces:d.spaces},submitMode:x,isAuthor:j}),e.jsx(zr,{open:z==="organizations",onOpenChange:r=>g("organizations",r),paperId:s.id,initialOrganizationIds:(s.organizations||[]).map(r=>Number(r.id)),submitMode:x,isAuthor:j}),e.jsx(Wa,{open:S!==null,onOpenChange:r=>{r||A(null)},sectionLabel:S?jn[S]:"this paper",returnTo:typeof window<"u"?window.location.pathname:"/"})]})},kn=({viewer:t,onEdit:a})=>e.jsxs("div",{className:"sidebar-card",children:[e.jsxs("div",{className:"sidebar-card-title",children:[t.paperHref?e.jsx("a",{href:t.paperHref,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:"🤗 Hugging Face"}):e.jsx("span",{children:"🤗 Hugging Face"}),e.jsx("button",{type:"button",onClick:a,className:"edit-link",children:"edit"})]}),t.isLoading?e.jsx(Re,{className:"h-16 w-full"}):e.jsxs(e.Fragment,{children:[t.rows.map(n=>e.jsx(wn,{...n},n.label)),t.footer&&e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink-faint)",marginTop:12},children:t.footer})]})]}),wn=({label:t,href:a,count:n,isLimited:l,links:i})=>{const[c,o]=h.useState(!1),x=((i==null?void 0:i.length)??0)>0,u=((i==null?void 0:i.length)??0)>us,s=c?i:i==null?void 0:i.slice(0,us),w=n!=null?`${n}${l?"+":""}`:"—",k=n?e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"hf-artifact-count",children:w}):e.jsx("span",{className:"hf-artifact-count hf-artifact-count--empty",children:w});return e.jsxs("div",{className:"hf-artifact-row",children:[e.jsxs("div",{className:"hf-artifact-row-header",children:[e.jsx("span",{children:t}),k]}),x&&e.jsxs("div",{className:"hf-artifact-links",children:[s.map(I=>e.jsx("a",{href:I.href,target:"_blank",rel:"noopener noreferrer",children:I.label},I.href)),u&&e.jsx("button",{type:"button",className:"hf-artifact-toggle","aria-expanded":c,onClick:()=>o(I=>!I),children:c?"Show fewer":`View all ${i.length}`})]})]})};function gt(t){return t[0]??"https://huggingface.co"}function xt(t,a){return a[0]??t}function bt(t,a,n){if(n==null&&t.length===0&&!(a!=null&&a.length))return;const l=new Set([...t,...a??[]]);return Math.max(n??0,l.size)}export{Zn as default};