diff --git "a/assets/PaperDetailView-BJ7A3ffV.js" "b/assets/PaperDetailView-BJ7A3ffV.js" new file mode 100644--- /dev/null +++ "b/assets/PaperDetailView-BJ7A3ffV.js" @@ -0,0 +1,39 @@ +import{c as Je,h as ea,r as o,j as e,P as mt,k as X,l as Ot,m as Se,n as ce,o as Fs,p as pt,C as xe,q as re,s as Pe,g as ve,X as Ts,t as Be,v as ta,w as Ls,x as sa,y as ra,z as aa,A as na,B as ia,D as De,E as oa,F as Ce,G as Ms,H as Ds,I as la,J as ca,K as da,M as ua,N as ma,O as pa,Q as ha,S as fa,T as js,U as ga,V as xa,W as va,Y as ba,f as ht,R as Ht,b as ut,Z as Us,d as Bs,_ as ja,$ as ya,a0 as ka,a1 as Os,a2 as wa,e as _a,a3 as Na,a as Ca,a4 as Ea,L as he,a5 as Sa,a6 as Pa,a7 as Ra,a8 as Ia,a9 as Aa,aa as $a,ab as Fa}from"./index-U8P_Jmx7.js";import{u as de}from"./useQuery-CxuBqoO0.js";import{I as Z,S as Ta,a as La,T as Ma,M as Da}from"./components-DGsOT32P.js";import{C as Ua,E as Ba}from"./ExternalSourceEvalBadge-BmFhuFao.js";import{L as it,a as Oa}from"./LatexTitle-nsVaQ9Pe.js";import{c as Ha}from"./transform-DkrbYO_4.js";import{f as qa,D as Ka}from"./latexPlainText-ChVkH0gY.js";import{a as za}from"./usePapers-E5pF9Qwf.js";import{S as Qe}from"./skeleton-wFxL9VJg.js";import{A as Ga,a as Qa}from"./alert-CFglZUt-.js";import{B as K}from"./button-JRLe7Vgd.js";import{u as Hs}from"./index-BDmswtao.js";import{I as ne}from"./textarea-Bmk1r5fm.js";import{D as be,a as je,b as ye,c as ke,d as we,e as _e,R as Va,P as Wa,O as Xa,C as Ja}from"./dialog-DjN0-xPy.js";import{u as Re}from"./useMutation-C_71h1XG.js";import{S as qt,P as Kt,L as le,a as Ya}from"./SignInToEditDialog-Bjfbut08.js";import{L as ue}from"./loader-circle-DjZQHyOk.js";import{B as qs,D as Za,c as en,g as tn,s as sn,a as rn,b as an,d as nn,i as on,e as ln}from"./codexAddEvals-wdPl1bgQ.js";import{G as ys}from"./github-aUaFVMam.js";import{M as cn,r as dn}from"./index-CE_UfasX.js";import"./hover-card-CwELy5Vb.js";import"./katex.min-BSBacQyE.js";import"./useInfiniteQuery-Dd-K76kF.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 un=Je("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/** + * @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 ks=Je("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 Xe=Je("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @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 Ks=Je("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 zt=Je("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 mn(t){return(t??[]).filter(s=>!!(s.dataset_slug&&s.task_slug))}function pn(t,s,a="https://paperswithcode.co"){return s.map(c=>{const n=encodeURIComponent(c.evaluation_id),i=`${a}/api/v1/papers/${encodeURIComponent(t)}/leaderboard-badge.svg?eval=${n}&live=1`,l=new URLSearchParams({task:c.task_slug,eval:c.evaluation_id}),u=`${a}/benchmark/${encodeURIComponent(c.dataset_slug)}?${l.toString()}`;return`[![${`Papers with Code: ${c.best_rank===1?"SOTA":`#${c.best_rank}`} on ${c.dataset_name}`}](${i})](${u})`}).join(` +`)}function hn(t,s=!0){return de({queryKey:["evaluations","paper",t],queryFn:()=>{if(!t)throw new Error("Paper ID is required");return ea(t)},enabled:s&&!!t,staleTime:0,refetchOnMount:"always"})}const zs=t=>t.replace(/v\d+$/,""),fn={models:"https://huggingface.co/",datasets:"https://huggingface.co/datasets/",spaces:"https://huggingface.co/spaces/"},Nt=(t,s)=>{const a=(t[s]||[]).length;return a<100?{count:a,isLimited:!1}:{count:a,isLimited:!0}},Ct=(t,s)=>{const a=t[s];return Array.isArray(a)?a.map(c=>{if(typeof c=="string")return c;if(c&&typeof c=="object"){const n=c;return n.id||n.repoId||null}return null}).filter(c=>!!c).map(c=>`${fn[s]}${c}`):[]},gn=async t=>{try{return(await fetch(`https://huggingface.co/api/papers/${zs(t)}`)).ok}catch{return!1}},xn=async t=>{const s=zs(t),[a,c]=await Promise.all([fetch(`https://huggingface.co/api/arxiv/${s}/repos`).then(async u=>u.ok?u.json():(console.warn(`Failed to fetch repos for arXiv:${s}, status: ${u.status}`),null)).catch(u=>(console.warn(`Failed to fetch repos for arXiv:${s}:`,u),null)),gn(s)]);if(!a)return{models:0,datasets:0,spaces:0,modelUrls:[],datasetUrls:[],spaceUrls:[],isLimited:!1,paperExists:c};const n=Nt(a,"models"),i=Nt(a,"datasets"),l=Nt(a,"spaces");return{models:n.count,datasets:i.count,spaces:l.count,modelUrls:Ct(a,"models"),datasetUrls:Ct(a,"datasets"),spaceUrls:Ct(a,"spaces"),isLimited:n.isLimited||i.isLimited||l.isLimited,paperExists:c}},vn=t=>de({queryKey:["huggingface-repos",t],queryFn:()=>xn(t),enabled:!!t,staleTime:10*60*1e3,retry:1});function bn(){const[t,s]=o.useState(!1),[a,c]=o.useState(!1),[n,i]=o.useState(!1),[l,u]=o.useState(!1),[r,p]=o.useState(!1),[v,b]=o.useState(!1);return{isEditingTasks:t,openTasksDialog:()=>s(!0),closeTasksDialog:()=>s(!1),setIsEditingTasks:s,isEditingMethods:a,openMethodsDialog:()=>c(!0),closeMethodsDialog:()=>c(!1),setIsEditingMethods:c,isEditingRepositories:n,openRepositoriesDialog:()=>i(!0),closeRepositoriesDialog:()=>i(!1),setIsEditingRepositories:i,isEditingProjectPages:l,openProjectPagesDialog:()=>u(!0),closeProjectPagesDialog:()=>u(!1),setIsEditingProjectPages:u,isEditingEvaluations:r,openEvaluationsDialog:()=>p(!0),closeEvaluationsDialog:()=>p(!1),setIsEditingEvaluations:p,isEditingSourceUrl:v,openSourceUrlDialog:()=>b(!0),closeSourceUrlDialog:()=>b(!1),setIsEditingSourceUrl:b}}var ft="Checkbox",[jn]=pt(ft),[yn,Gt]=jn(ft);function kn(t){const{__scopeCheckbox:s,checked:a,children:c,defaultChecked:n,disabled:i,form:l,name:u,onCheckedChange:r,required:p,value:v="on",internal_do_not_use_render:b}=t,[E,w]=Ot({prop:a,defaultProp:n??!1,onChange:r,caller:ft}),[f,I]=o.useState(null),[T,L]=o.useState(null),D=o.useRef(!1),P=f?!!l||!!f.closest("form"):!0,U={checked:E,disabled:i,setChecked:w,control:f,setControl:I,name:u,form:l,value:v,hasConsumerStoppedPropagationRef:D,required:p,defaultChecked:fe(n)?!1:n,isFormControl:P,bubbleInput:T,setBubbleInput:L};return e.jsx(yn,{scope:s,...U,children:wn(b)?b(U):c})}var Gs="CheckboxTrigger",Qs=o.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:a,...c},n)=>{const{control:i,value:l,disabled:u,checked:r,required:p,setControl:v,setChecked:b,hasConsumerStoppedPropagationRef:E,isFormControl:w,bubbleInput:f}=Gt(Gs,t),I=Se(n,v),T=o.useRef(r);return o.useEffect(()=>{const L=i==null?void 0:i.form;if(L){const D=()=>b(T.current);return L.addEventListener("reset",D),()=>L.removeEventListener("reset",D)}},[i,b]),e.jsx(X.button,{type:"button",role:"checkbox","aria-checked":fe(r)?"mixed":r,"aria-required":p,"data-state":Ys(r),"data-disabled":u?"":void 0,disabled:u,value:l,...c,ref:I,onKeyDown:ce(s,L=>{L.key==="Enter"&&L.preventDefault()}),onClick:ce(a,L=>{b(D=>fe(D)?!0:!D),f&&w&&(E.current=L.isPropagationStopped(),E.current||L.stopPropagation())})})});Qs.displayName=Gs;var Qt=o.forwardRef((t,s)=>{const{__scopeCheckbox:a,name:c,checked:n,defaultChecked:i,required:l,disabled:u,value:r,onCheckedChange:p,form:v,...b}=t;return e.jsx(kn,{__scopeCheckbox:a,checked:n,defaultChecked:i,disabled:u,required:l,onCheckedChange:p,name:c,form:v,value:r,internal_do_not_use_render:({isFormControl:E})=>e.jsxs(e.Fragment,{children:[e.jsx(Qs,{...b,ref:s,__scopeCheckbox:a}),E&&e.jsx(Js,{__scopeCheckbox:a})]})})});Qt.displayName=ft;var Vs="CheckboxIndicator",Ws=o.forwardRef((t,s)=>{const{__scopeCheckbox:a,forceMount:c,...n}=t,i=Gt(Vs,a);return e.jsx(mt,{present:c||fe(i.checked)||i.checked===!0,children:e.jsx(X.span,{"data-state":Ys(i.checked),"data-disabled":i.disabled?"":void 0,...n,ref:s,style:{pointerEvents:"none",...t.style}})})});Ws.displayName=Vs;var Xs="CheckboxBubbleInput",Js=o.forwardRef(({__scopeCheckbox:t,...s},a)=>{const{control:c,hasConsumerStoppedPropagationRef:n,checked:i,defaultChecked:l,required:u,disabled:r,name:p,value:v,form:b,bubbleInput:E,setBubbleInput:w}=Gt(Xs,t),f=Se(a,w),I=Hs(i),T=Fs(c);o.useEffect(()=>{const D=E;if(!D)return;const P=window.HTMLInputElement.prototype,N=Object.getOwnPropertyDescriptor(P,"checked").set,g=!n.current;if(I!==i&&N){const j=new Event("click",{bubbles:g});D.indeterminate=fe(i),N.call(D,fe(i)?!1:i),D.dispatchEvent(j)}},[E,I,i,n]);const L=o.useRef(fe(i)?!1:i);return e.jsx(X.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??L.current,required:u,disabled:r,name:p,value:v,form:b,...s,tabIndex:-1,ref:f,style:{...s.style,...T,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Js.displayName=Xs;function wn(t){return typeof t=="function"}function fe(t){return t==="indeterminate"}function Ys(t){return fe(t)?"indeterminate":t?"checked":"unchecked"}const gt=o.forwardRef(({className:t,style:s,...a},c)=>e.jsx(Qt,{ref:c,className:re("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",...s},...a,children:e.jsx(Ws,{className:re("flex items-center justify-center text-current"),children:e.jsx(xe,{className:"h-4 w-4"})})}));gt.displayName=Qt.displayName;function _n(t,s,a){if(!t)return t;const c=n=>n.paper_id!==s||n.paper_title===a?n:{...n,paper_title:a};if(Array.isArray(t)){const n=t.map(c);return n.some((l,u)=>l!==t[u])?n:t}if(Array.isArray(t.results)){const n=t.results.map(c);return n.some((l,u)=>l!==t.results[u])?{...t,results:n}:t}return t}function Ye(t,s,a){new Set([...a,s.id,s.arxiv_id].filter(l=>!!l)).forEach(l=>{t.setQueryData(["paper",l],s),t.setQueryData(["paper-arxiv",l],s)}),t.invalidateQueries({queryKey:["papers"],refetchType:"none"}),t.invalidateQueries({queryKey:["papers-infinite"],refetchType:"none"}),t.invalidateQueries({queryKey:["task-papers-infinite"],refetchType:"none"});const n=String(s.id),i=l=>_n(l,n,s.title);t.setQueriesData({queryKey:["evaluations"]},i),t.setQueriesData({queryKey:["dataset-evals"]},i),t.invalidateQueries({queryKey:["evaluations"],refetchType:"none"}),t.invalidateQueries({queryKey:["dataset-evals"],refetchType:"none"})}function Oe({isAuthor:t=!1}){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:"Your changes will be reviewed by an admin."}),e.jsx("p",{className:"mt-1 leading-snug",children: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 Nn=250,Cn=100;function En({open:t,onOpenChange:s,paperId:a,arxivId:c,initialTaskIds:n,initialTasks:i,onSuccess:l,submitMode:u="direct",isAuthor:r=!1}){const[p,v]=o.useState(n),[b,E]=o.useState(!1),[w,f]=o.useState(""),[I,T]=o.useState(""),[L,D]=o.useState(new Map),P=Pe(),{toast:U}=ve(),N=o.useRef(!1);o.useEffect(()=>{if(!t){N.current=!1;return}if(N.current)return;N.current=!0,v(n),f(""),T("");const y=new Map;(i||[]).forEach(A=>{const M=parseInt(A.id);Number.isNaN(M)||y.set(M,A)}),D(y)},[t,n,i]),o.useEffect(()=>{const y=window.setTimeout(()=>{T(w.trim())},Nn);return()=>window.clearTimeout(y)},[w]);const{data:g,isFetching:j}=de({queryKey:["tasks-search",I],queryFn:()=>Ls({page_size:Cn,...I?{q:I}:{}}),enabled:t});o.useEffect(()=>{var y;(y=g==null?void 0:g.results)!=null&&y.length&&D(A=>{const M=new Map(A);return g.results.forEach(F=>{const $=parseInt(F.id);Number.isNaN($)||M.set($,F)}),M})},[g]);const B=o.useMemo(()=>{const y=(g==null?void 0:g.results)||[],A=new Set,M=[];return p.forEach(F=>{if(A.has(F))return;const $=L.get(F);$&&(M.push($),A.add(F))}),y.forEach(F=>{const $=parseInt(F.id);Number.isNaN($)||A.has($)||(M.push(F),A.add($))}),M},[g,p,L]),O=Re({mutationFn:async({paperId:y,taskIds:A})=>u==="pending"?(await Be({paper_id:parseInt(y),edit_type:"tasks",proposed_payload:{task_ids:A}}),null):ta(y,A),onMutate:async({taskIds:y})=>{if(u==="pending")return{snapshots:[]};const A=y.map($=>L.get($)).filter($=>!!$).map($=>({id:$.id,name:$.name,slug:$.slug})).sort(($,ee)=>$.name.localeCompare(ee.name)),M=Array.from(new Set([a,c].filter($=>!!$)));await Promise.all(M.flatMap($=>[P.cancelQueries({queryKey:["paper",$]}),P.cancelQueries({queryKey:["paper-arxiv",$]})]));const F=[];return M.forEach($=>{["paper","paper-arxiv"].forEach(ee=>{const k=[ee,$],_=P.getQueryData(k);F.push({key:k,data:_}),_&&P.setQueryData(k,{..._,tasks:A})})}),U({title:"Tasks updated",description:`Saved ${y.length} task${y.length===1?"":"s"} for this paper.`}),l==null||l(),s(!1),{snapshots:F}},onSuccess:y=>{if(u==="pending"){U({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed task changes shortly."}),l==null||l(),s(!1);return}y&&Ye(P,y,[a,c])},onError:(y,A,M)=>{var ee,k;(ee=M==null?void 0:M.snapshots)==null||ee.forEach(({key:_,data:m})=>{P.setQueryData(_,m)});const F=y;let $=F.message||(u==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper tasks.");if(F.response)try{const _=JSON.parse(F.response);typeof(_==null?void 0:_.detail)=="string"?$=_.detail:Array.isArray(_==null?void 0:_.detail)&&((k=_.detail[0])!=null&&k.msg)&&($=_.detail[0].msg)}catch{$=F.response}U({title:u==="pending"?"Could not submit edit":"Could not save tasks",description:$,variant:"destructive"})}}),H=()=>{O.mutate({paperId:a,taskIds:p})},z=o.useMemo(()=>{if(p.length!==n.length)return!0;const y=new Set(n);return p.some(A=>!y.has(A))},[p,n]),Q=(y,A)=>{v(M=>A?M.includes(y)?M:[...M,y]:M.filter(F=>F!==y))},se=()=>f("");return e.jsxs(be,{open:t,onOpenChange:s,children:[e.jsxs(je,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ye,{children:[e.jsx(ke,{children:"Edit Paper Tasks"}),e.jsx(we,{children:"Select the tasks that this paper addresses. You can select multiple tasks."})]}),u==="pending"&&e.jsx(Oe,{isAuthor:r}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Xe,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ne,{type:"text",placeholder:"Search tasks...",value:w,onChange:y=>f(y.target.value),className:"pl-9 pr-9"}),w&&e.jsx("button",{type:"button",onClick:se,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(Ts,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[400px]",children:B.length>0?e.jsx("div",{className:"space-y-2",children:B.map(y=>{const A=parseInt(y.id),M=p.includes(A);return e.jsxs("div",{className:"flex items-center space-x-2 p-2 hover:bg-muted/50 rounded-md",children:[e.jsx(gt,{id:`task-${y.id}`,checked:M,onCheckedChange:F=>Q(A,F===!0),className:"!border !border-black data-[state=checked]:!bg-black data-[state=checked]:!text-white"}),e.jsxs("label",{htmlFor:`task-${y.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[y.name,y.description&&e.jsxs("span",{className:"block text-xs text-muted-foreground font-normal mt-1",children:[y.description.substring(0,100),y.description.length>100?"...":""]})]})]},y.id)})}):j?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ue,{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(Xe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:I?`No tasks found matching "${I}"`:"No tasks available"})]})}),e.jsxs(_e,{children:[e.jsx(K,{variant:"ghost",className:"sm:mr-auto",onClick:()=>E(!0),children:"Suggest a new task"}),e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:H,disabled:O.isPending||!z,children:O.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2 animate-spin"}),u==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),u==="pending"?"Submit for review":"Save Changes"]})})]})]}),e.jsx(qt,{open:b,onOpenChange:E,paperId:a,kind:"task"})]})}const Sn=250,Pn=100;function Rn({open:t,onOpenChange:s,paperId:a,arxivId:c,initialMethodIds:n,initialMethods:i,onSuccess:l,submitMode:u="direct",isAuthor:r=!1}){const[p,v]=o.useState(n),[b,E]=o.useState(!1),[w,f]=o.useState(""),[I,T]=o.useState(""),[L,D]=o.useState(new Map),P=Pe(),{toast:U}=ve(),N=o.useRef(!1);o.useEffect(()=>{if(!t){N.current=!1;return}if(N.current)return;N.current=!0,v(n),f(""),T("");const y=new Map;(i||[]).forEach(A=>{const M=parseInt(A.id);Number.isNaN(M)||y.set(M,A)}),D(y)},[t,n,i]),o.useEffect(()=>{const y=window.setTimeout(()=>{T(w.trim())},Sn);return()=>window.clearTimeout(y)},[w]);const{data:g,isFetching:j}=de({queryKey:["methods-search",I],queryFn:()=>ra({page_size:Pn,...I?{q:I}:{}}),enabled:t});o.useEffect(()=>{var y;(y=g==null?void 0:g.results)!=null&&y.length&&D(A=>{const M=new Map(A);return g.results.forEach(F=>{const $=parseInt(F.id);Number.isNaN($)||M.set($,F)}),M})},[g]);const B=o.useMemo(()=>{const y=(g==null?void 0:g.results)||[],A=new Set,M=[];return p.forEach(F=>{if(A.has(F))return;const $=L.get(F);$&&(M.push($),A.add(F))}),y.forEach(F=>{const $=parseInt(F.id);Number.isNaN($)||A.has($)||(M.push(F),A.add($))}),M},[g,p,L]),O=Re({mutationFn:async({paperId:y,methodIds:A})=>u==="pending"?(await Be({paper_id:parseInt(y),edit_type:"methods",proposed_payload:{method_ids:A}}),null):sa(y,A),onSuccess:y=>{if(u==="pending"){U({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed method changes shortly."}),l==null||l(),s(!1);return}y&&Ye(P,y,[a,c]),U({title:"Methods updated",description:`Saved ${p.length} method${p.length===1?"":"s"} for this paper.`}),l==null||l(),s(!1)},onError:y=>{var F;const A=y;let M=A.message||(u==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper methods.");if(A.response)try{const $=JSON.parse(A.response);typeof($==null?void 0:$.detail)=="string"?M=$.detail:Array.isArray($==null?void 0:$.detail)&&((F=$.detail[0])!=null&&F.msg)&&(M=$.detail[0].msg)}catch{M=A.response}U({title:u==="pending"?"Could not submit edit":"Could not save methods",description:M,variant:"destructive"})}}),H=()=>{O.mutate({paperId:a,methodIds:p})},z=o.useMemo(()=>{if(p.length!==n.length)return!0;const y=new Set(n);return p.some(A=>!y.has(A))},[p,n]),Q=(y,A)=>{v(M=>A?M.includes(y)?M:[...M,y]:M.filter(F=>F!==y))},se=()=>f("");return e.jsxs(be,{open:t,onOpenChange:s,children:[e.jsxs(je,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ye,{children:[e.jsx(ke,{children:"Edit Paper Methods"}),e.jsx(we,{children:"Select the methods and techniques used in this paper. You can select multiple methods."})]}),u==="pending"&&e.jsx(Oe,{isAuthor:r}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Xe,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ne,{type:"text",placeholder:"Search methods...",value:w,onChange:y=>f(y.target.value),className:"pl-9 pr-9"}),w&&e.jsx("button",{type:"button",onClick:se,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(Ts,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[400px]",children:B.length>0?e.jsx("div",{className:"space-y-2",children:B.map(y=>{const A=parseInt(y.id),M=p.includes(A);return e.jsxs("div",{className:"flex items-center space-x-2 p-2 hover:bg-muted/50 rounded-md",children:[e.jsx(gt,{id:`method-${y.id}`,checked:M,onCheckedChange:F=>Q(A,F===!0),className:"!border !border-black data-[state=checked]:!bg-black data-[state=checked]:!text-white"}),e.jsxs("label",{htmlFor:`method-${y.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[y.name,y.full_name&&y.full_name!==y.name&&e.jsx("span",{className:"block text-xs text-muted-foreground font-normal",children:y.full_name}),y.description&&e.jsxs("span",{className:"block text-xs text-muted-foreground font-normal mt-1",children:[y.description.substring(0,100),y.description.length>100?"...":""]})]})]},y.id)})}):j?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ue,{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(Xe,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:I?`No methods found matching "${I}"`:"No methods available"})]})}),e.jsxs(_e,{children:[e.jsx(K,{variant:"ghost",className:"sm:mr-auto",onClick:()=>E(!0),children:"Suggest a new method"}),e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:H,disabled:O.isPending||!z,children:O.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2 animate-spin"}),u==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),u==="pending"?"Submit for review":"Save Changes"]})})]})]}),e.jsx(qt,{open:b,onOpenChange:E,paperId:a,kind:"method"})]})}function We(t){const s=t.trim();if(!s)return null;let a=s;!a.startsWith("http://")&&!a.startsWith("https://")&&(a=`https://${a}`);try{const c=new URL(a);if(c.hostname.toLowerCase()!=="github.com")return null;const n=c.pathname.split("/").filter(Boolean);if(n.length<2)return null;const i=n[0].toLowerCase();let l=n[1].toLowerCase();return l.endsWith(".git")&&(l=l.slice(0,-4)),`https://github.com/${i}/${l}`}catch{return null}}function ws(t,s){const a=We(t),c=We(s);return a&&c?a===c:t.trim()===s.trim()}function In({open:t,onOpenChange:s,paperId:a,arxivId:c,initialRepositories:n,onSuccess:i,submitMode:l="direct",isAuthor:u=!1}){const[r,p]=o.useState(n),[v,b]=o.useState(""),E=Pe(),{toast:w}=ve(),f=o.useRef(!1);o.useEffect(()=>{if(!t){f.current=!1;return}f.current||(f.current=!0,p(n),b(""))},[t,n]);const I=Re({mutationFn:async({paperId:j,repositories:B})=>l==="pending"?(await Be({paper_id:parseInt(j),edit_type:"repositories",proposed_payload:{repositories:B}}),null):aa(j,B),onSuccess:j=>{if(l==="pending"){w({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed repository changes shortly."}),i==null||i(),s(!1),b("");return}j&&Ye(E,j,[a,c]),i==null||i(),s(!1),b("")},onError:j=>{var H;const B=j;let O=B.message||(l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper repositories.");if(B.response)try{const z=JSON.parse(B.response);typeof(z==null?void 0:z.detail)=="string"?O=z.detail:Array.isArray(z==null?void 0:z.detail)&&((H=z.detail[0])!=null&&H.msg)&&(O=z.detail[0].msg)}catch{O=B.response}w({title:l==="pending"?"Could not submit edit":"Could not save repositories",description:O,variant:"destructive"})}}),T=j=>{const B=[];for(const O of j){const H=B.find(z=>ws(z.url,O.url));if(H)H.is_official=H.is_official||O.is_official;else{const z=We(O.url);B.push({url:z??O.url.trim(),is_official:O.is_official})}}return B},L=()=>{const j=v.trim(),B=j?[...r,{url:j,is_official:!1}]:r;return j&&r.some(O=>ws(O.url,j))?(alert("This repository URL is already added"),null):T(B)},D=()=>{const j=L();j!==null&&j.length!==r.length&&(p(j),b(""))},P=j=>{p(r.filter(B=>B.url!==j))},U=j=>{p(r.map(B=>B.url===j?{...B,is_official:!B.is_official}:B))},N=()=>{const j=L();j!==null&&I.mutate({paperId:a,repositories:j})},g=o.useMemo(()=>{const j=v.trim(),B=j?[...r,{url:j,is_official:!1}]:r;if(B.length!==n.length)return!0;const O=T(n),H=T(B);if(H.length!==O.length)return!0;const z=new Map(O.map(Q=>[We(Q.url)??Q.url.trim(),!!Q.is_official]));return H.some(Q=>{const se=We(Q.url)??Q.url.trim(),y=z.get(se);return y===void 0||y!==!!Q.is_official})},[r,v,n]);return e.jsx(be,{open:t,onOpenChange:s,children:e.jsxs(je,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ye,{children:[e.jsx(ke,{children:"Edit Paper Repositories"}),e.jsx(we,{children:"Add or remove GitHub repository URLs associated with this paper. Mark repositories as official if they are created by the paper authors."})]}),l==="pending"&&e.jsx(Oe,{isAuthor:u}),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(ne,{type:"url",placeholder:"https://github.com/owner/repo",value:v,onChange:j=>b(j.target.value),onKeyPress:j=>{j.key==="Enter"&&(j.preventDefault(),D())},className:"flex-1"}),e.jsxs(K,{onClick:D,size:"sm",disabled:!v.trim(),children:[e.jsx(Kt,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[350px]",children:r.length>0?e.jsx("div",{className:"space-y-2",children:r.map((j,B)=>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(ys,{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:j.url}),j.is_official&&e.jsx(qs,{variant:"secondary",className:"text-xs",children:"Official"})]})}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs(K,{variant:j.is_official?"default":"outline",size:"sm",onClick:()=>U(j.url),className:"h-8 px-2 text-xs",title:j.is_official?"Click to unmark as official (created by paper authors)":"Click to mark as official (created by paper authors)",children:[e.jsx(Ks,{className:`w-3.5 h-3.5 mr-1 ${j.is_official?"fill-current":""}`}),j.is_official?"Official":"Mark official"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>P(j.url),className:"h-8 px-2 text-destructive hover:text-destructive",title:"Remove repository",children:e.jsx(zt,{className:"w-4 h-4"})})]})]},B))}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ys,{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(_e,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:N,disabled:I.isPending||!g,children:I.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function An({open:t,onOpenChange:s,paperId:a,arxivId:c,initialProjectPages:n,onSuccess:i,submitMode:l="direct",isAuthor:u=!1}){const[r,p]=o.useState(n),[v,b]=o.useState(""),E=Pe(),{toast:w}=ve(),f=o.useRef(!1);o.useEffect(()=>{if(!t){f.current=!1;return}f.current||(f.current=!0,p(n),b(""))},[t,n]);const I=Re({mutationFn:async({paperId:g,projectPages:j})=>l==="pending"?(await Be({paper_id:parseInt(g),edit_type:"project_pages",proposed_payload:{project_pages:j}}),null):na(g,j),onSuccess:g=>{if(l==="pending"){w({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed project page changes shortly."}),i==null||i(),s(!1),b("");return}g&&Ye(E,g,[a,c]),i==null||i(),s(!1),b("")},onError:g=>{var O;const j=g;let B=j.message||(l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update project pages.");if(j.response)try{const H=JSON.parse(j.response);typeof(H==null?void 0:H.detail)=="string"?B=H.detail:Array.isArray(H==null?void 0:H.detail)&&((O=H.detail[0])!=null&&O.msg)&&(B=H.detail[0].msg)}catch{B=j.response}w({title:l==="pending"?"Could not submit edit":"Could not save project pages",description:B,variant:"destructive"})}}),T=()=>{const g=v.trim();return g?r.some(j=>j.url===g)?(alert("This project page URL is already added"),null):[...r,{url:g,is_official:!1}]:r},L=()=>{const g=T();g!==null&&g.length!==r.length&&(p(g),b(""))},D=g=>{p(r.filter(j=>j.url!==g))},P=g=>{p(r.map(j=>j.url===g?{...j,is_official:!j.is_official}:j))},U=()=>{const g=T();g!==null&&I.mutate({paperId:a,projectPages:g})},N=o.useMemo(()=>{const g=v.trim(),j=g?[...r,{url:g,is_official:!1}]:r;if(j.length!==n.length)return!0;const B=new Map(n.map(O=>[O.url.trim(),!!O.is_official]));return j.some(O=>{const H=B.get(O.url.trim());return H===void 0||H!==!!O.is_official})},[r,v,n]);return e.jsx(be,{open:t,onOpenChange:s,children:e.jsxs(je,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ye,{children:[e.jsx(ke,{children:"Edit Paper Project Pages"}),e.jsx(we,{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."})]}),l==="pending"&&e.jsx(Oe,{isAuthor:u}),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(ne,{type:"url",placeholder:"https://example.com/project",value:v,onChange:g=>b(g.target.value),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),L())},className:"flex-1"}),e.jsxs(K,{onClick:L,size:"sm",disabled:!v.trim(),children:[e.jsx(Kt,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[350px]",children:r.length>0?e.jsx("div",{className:"space-y-2",children:r.map((g,j)=>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(ks,{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:g.url}),g.is_official&&e.jsx(qs,{variant:"secondary",className:"text-xs",children:"Official"})]})}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs(K,{variant:g.is_official?"default":"outline",size:"sm",onClick:()=>P(g.url),className:"h-8 px-2 text-xs",title:g.is_official?"Click to unmark as official (created by paper authors)":"Click to mark as official (created by paper authors)",children:[e.jsx(Ks,{className:`w-3.5 h-3.5 mr-1 ${g.is_official?"fill-current":""}`}),g.is_official?"Official":"Mark official"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>D(g.url),className:"h-8 px-2 text-destructive hover:text-destructive",title:"Remove project page",children:e.jsx(zt,{className:"w-4 h-4"})})]})]},j))}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ks,{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(_e,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:U,disabled:I.isPending||!N,children:I.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function $n({open:t,onOpenChange:s,paperId:a,arxivId:c,initialUrl:n,onSuccess:i,submitMode:l="direct",isAuthor:u=!1}){const[r,p]=o.useState(n),v=Pe(),{toast:b}=ve(),E=o.useRef(!1);o.useEffect(()=>{if(!t){E.current=!1;return}E.current||(E.current=!0,p(n))},[t,n]);const w=Re({mutationFn:async({paperId:D,sourceUrl:P})=>l==="pending"?(await Be({paper_id:parseInt(D),edit_type:"source_url",proposed_payload:{source_url:P}}),null):ia(D,P),onSuccess:D=>{if(l==="pending"){b({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed source URL change shortly."}),i==null||i(),s(!1);return}D&&Ye(v,D,[a,c]),i==null||i(),s(!1)},onError:D=>{var N;const P=D;let U=P.message||(l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update source URL.");if(P.response)try{const g=JSON.parse(P.response);typeof(g==null?void 0:g.detail)=="string"?U=g.detail:Array.isArray(g==null?void 0:g.detail)&&((N=g.detail[0])!=null&&N.msg)&&(U=g.detail[0].msg)}catch{U=P.response}b({title:l==="pending"?"Could not submit edit":"Could not save source URL",description:U,variant:"destructive"})}}),f=r.trim(),I=/^https?:\/\//i.test(f),T=f!==(n||"").trim(),L=()=>{I&&w.mutate({paperId:a,sourceUrl:f})};return e.jsx(be,{open:t,onOpenChange:s,children:e.jsxs(je,{className:"max-w-2xl",children:[e.jsxs(ye,{children:[e.jsx(ke,{children:"Edit Source URL"}),e.jsxs(we,{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."]})]}),l==="pending"&&e.jsx(Oe,{isAuthor:u}),e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Source URL"}),e.jsx(ne,{type:"url",placeholder:"https://example.com/paper",value:r,onChange:D=>p(D.target.value),onKeyPress:D=>{D.key==="Enter"&&I&&T&&(D.preventDefault(),L())}}),!I&&f.length>0&&e.jsx("p",{className:"text-xs text-destructive",children:"URL must start with http:// or https://"})]}),e.jsxs(_e,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:L,disabled:w.isPending||!I||!T,children:w.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function Fn(t){const s=Tn(t),a=o.forwardRef((c,n)=>{const{children:i,...l}=c,u=o.Children.toArray(i),r=u.find(Mn);if(r){const p=r.props.children,v=u.map(b=>b===r?o.Children.count(p)>1?o.Children.only(null):o.isValidElement(p)?p.props.children:null:b);return e.jsx(s,{...l,ref:n,children:o.isValidElement(p)?o.cloneElement(p,void 0,v):null})}return e.jsx(s,{...l,ref:n,children:i})});return a.displayName=`${t}.Slot`,a}function Tn(t){const s=o.forwardRef((a,c)=>{const{children:n,...i}=a;if(o.isValidElement(n)){const l=Un(n),u=Dn(i,n.props);return n.type!==o.Fragment&&(u.ref=c?De(c,l):l),o.cloneElement(n,u)}return o.Children.count(n)>1?o.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var Ln=Symbol("radix.slottable");function Mn(t){return o.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Ln}function Dn(t,s){const a={...s};for(const c in s){const n=t[c],i=s[c];/^on[A-Z]/.test(c)?n&&i?a[c]=(...u)=>{const r=i(...u);return n(...u),r}:n&&(a[c]=n):c==="style"?a[c]={...n,...i}:c==="className"&&(a[c]=[n,i].filter(Boolean).join(" "))}return{...t,...a}}function Un(t){var c,n;let s=(c=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:c.get,a=s&&"isReactWarning"in s&&s.isReactWarning;return a?t.ref:(s=(n=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:n.get,a=s&&"isReactWarning"in s&&s.isReactWarning,a?t.props.ref:t.props.ref||t.ref)}var xt="Popover",[Zs]=pt(xt,[Ds]),Ze=Ds(),[Bn,Ne]=Zs(xt),er=t=>{const{__scopePopover:s,children:a,open:c,defaultOpen:n,onOpenChange:i,modal:l=!1}=t,u=Ze(s),r=o.useRef(null),[p,v]=o.useState(!1),[b,E]=Ot({prop:c,defaultProp:n??!1,onChange:i,caller:xt});return e.jsx(oa,{...u,children:e.jsx(Bn,{scope:s,contentId:Ce(),triggerRef:r,open:b,onOpenChange:E,onOpenToggle:o.useCallback(()=>E(w=>!w),[E]),hasCustomAnchor:p,onCustomAnchorAdd:o.useCallback(()=>v(!0),[]),onCustomAnchorRemove:o.useCallback(()=>v(!1),[]),modal:l,children:a})})};er.displayName=xt;var tr="PopoverAnchor",On=o.forwardRef((t,s)=>{const{__scopePopover:a,...c}=t,n=Ne(tr,a),i=Ze(a),{onCustomAnchorAdd:l,onCustomAnchorRemove:u}=n;return o.useEffect(()=>(l(),()=>u()),[l,u]),e.jsx(Ms,{...i,...c,ref:s})});On.displayName=tr;var sr="PopoverTrigger",rr=o.forwardRef((t,s)=>{const{__scopePopover:a,...c}=t,n=Ne(sr,a),i=Ze(a),l=Se(s,n.triggerRef),u=e.jsx(X.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":lr(n.open),...c,ref:l,onClick:ce(t.onClick,n.onOpenToggle)});return n.hasCustomAnchor?u:e.jsx(Ms,{asChild:!0,...i,children:u})});rr.displayName=sr;var Vt="PopoverPortal",[Hn,qn]=Zs(Vt,{forceMount:void 0}),ar=t=>{const{__scopePopover:s,forceMount:a,children:c,container:n}=t,i=Ne(Vt,s);return e.jsx(Hn,{scope:s,forceMount:a,children:e.jsx(mt,{present:a||i.open,children:e.jsx(la,{asChild:!0,container:n,children:c})})})};ar.displayName=Vt;var Ue="PopoverContent",nr=o.forwardRef((t,s)=>{const a=qn(Ue,t.__scopePopover),{forceMount:c=a.forceMount,...n}=t,i=Ne(Ue,t.__scopePopover);return e.jsx(mt,{present:c||i.open,children:i.modal?e.jsx(zn,{...n,ref:s}):e.jsx(Gn,{...n,ref:s})})});nr.displayName=Ue;var Kn=Fn("PopoverContent.RemoveScroll"),zn=o.forwardRef((t,s)=>{const a=Ne(Ue,t.__scopePopover),c=o.useRef(null),n=Se(s,c),i=o.useRef(!1);return o.useEffect(()=>{const l=c.current;if(l)return ca(l)},[]),e.jsx(da,{as:Kn,allowPinchZoom:!0,children:e.jsx(ir,{...t,ref:n,trapFocus:a.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ce(t.onCloseAutoFocus,l=>{var u;l.preventDefault(),i.current||(u=a.triggerRef.current)==null||u.focus()}),onPointerDownOutside:ce(t.onPointerDownOutside,l=>{const u=l.detail.originalEvent,r=u.button===0&&u.ctrlKey===!0,p=u.button===2||r;i.current=p},{checkForDefaultPrevented:!1}),onFocusOutside:ce(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),Gn=o.forwardRef((t,s)=>{const a=Ne(Ue,t.__scopePopover),c=o.useRef(!1),n=o.useRef(!1);return e.jsx(ir,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var l,u;(l=t.onCloseAutoFocus)==null||l.call(t,i),i.defaultPrevented||(c.current||(u=a.triggerRef.current)==null||u.focus(),i.preventDefault()),c.current=!1,n.current=!1},onInteractOutside:i=>{var r,p;(r=t.onInteractOutside)==null||r.call(t,i),i.defaultPrevented||(c.current=!0,i.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const l=i.target;((p=a.triggerRef.current)==null?void 0:p.contains(l))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&n.current&&i.preventDefault()}})}),ir=o.forwardRef((t,s)=>{const{__scopePopover:a,trapFocus:c,onOpenAutoFocus:n,onCloseAutoFocus:i,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:r,onFocusOutside:p,onInteractOutside:v,...b}=t,E=Ne(Ue,a),w=Ze(a);return ua(),e.jsx(ma,{asChild:!0,loop:!0,trapped:c,onMountAutoFocus:n,onUnmountAutoFocus:i,children:e.jsx(pa,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:v,onEscapeKeyDown:u,onPointerDownOutside:r,onFocusOutside:p,onDismiss:()=>E.onOpenChange(!1),children:e.jsx(ha,{"data-state":lr(E.open),role:"dialog",id:E.contentId,...w,...b,ref:s,style:{...b.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),or="PopoverClose",Qn=o.forwardRef((t,s)=>{const{__scopePopover:a,...c}=t,n=Ne(or,a);return e.jsx(X.button,{type:"button",...c,ref:s,onClick:ce(t.onClick,()=>n.onOpenChange(!1))})});Qn.displayName=or;var Vn="PopoverArrow",Wn=o.forwardRef((t,s)=>{const{__scopePopover:a,...c}=t,n=Ze(a);return e.jsx(fa,{...n,...c,ref:s})});Wn.displayName=Vn;function lr(t){return t?"open":"closed"}var Xn=er,Jn=rr,Yn=ar,cr=nr;const Zn=Xn,ei=Jn,dr=o.forwardRef(({className:t,align:s="center",sideOffset:a=4,...c},n)=>e.jsx(Yn,{children:e.jsx(cr,{ref:n,align:s,sideOffset:a,className:re("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...c})}));dr.displayName=cr.displayName;var _s=1,ti=.9,si=.8,ri=.17,Et=.1,St=.999,ai=.9999,ni=.99,ii=/[\\\/_+.#"@\[\(\{&]/,oi=/[\\\/_+.#"@\[\(\{&]/g,li=/[\s-]/,ur=/[\s-]/g;function Mt(t,s,a,c,n,i,l){if(i===s.length)return n===t.length?_s:ni;var u=`${n},${i}`;if(l[u]!==void 0)return l[u];for(var r=c.charAt(i),p=a.indexOf(r,n),v=0,b,E,w,f;p>=0;)b=Mt(t,s,a,c,p+1,i+1,l),b>v&&(p===n?b*=_s:ii.test(t.charAt(p-1))?(b*=si,w=t.slice(n,p-1).match(oi),w&&n>0&&(b*=Math.pow(St,w.length))):li.test(t.charAt(p-1))?(b*=ti,f=t.slice(n,p-1).match(ur),f&&n>0&&(b*=Math.pow(St,f.length))):(b*=ri,n>0&&(b*=Math.pow(St,p-n))),t.charAt(p)!==s.charAt(i)&&(b*=ai)),(bb&&(b=E*Et)),b>v&&(v=b),p=a.indexOf(r,p+1);return l[u]=v,v}function Ns(t){return t.toLowerCase().replace(ur," ")}function ci(t,s,a){return t=a&&a.length>0?`${t+" "+a.join(" ")}`:t,Mt(t,s,Ns(t),Ns(s),0,0,{})}var ze='[cmdk-group=""]',Pt='[cmdk-group-items=""]',di='[cmdk-group-heading=""]',mr='[cmdk-item=""]',Cs=`${mr}:not([aria-disabled="true"])`,Dt="cmdk-item-select",Te="data-value",ui=(t,s,a)=>ci(t,s,a),pr=o.createContext(void 0),et=()=>o.useContext(pr),hr=o.createContext(void 0),Wt=()=>o.useContext(hr),fr=o.createContext(void 0),gr=o.forwardRef((t,s)=>{let a=Le(()=>{var m,h;return{search:"",value:(h=(m=t.value)!=null?m:t.defaultValue)!=null?h:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),c=Le(()=>new Set),n=Le(()=>new Map),i=Le(()=>new Map),l=Le(()=>new Set),u=xr(t),{label:r,children:p,value:v,onValueChange:b,filter:E,shouldFilter:w,loop:f,disablePointerSelection:I=!1,vimBindings:T=!0,...L}=t,D=Ce(),P=Ce(),U=Ce(),N=o.useRef(null),g=ki();Ee(()=>{if(v!==void 0){let m=v.trim();a.current.value=m,j.emit()}},[v]),Ee(()=>{g(6,se)},[]);let j=o.useMemo(()=>({subscribe:m=>(l.current.add(m),()=>l.current.delete(m)),snapshot:()=>a.current,setState:(m,h,x)=>{var C,R,q,V;if(!Object.is(a.current[m],h)){if(a.current[m]=h,m==="search")Q(),H(),g(1,z);else if(m==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let W=document.getElementById(U);W?W.focus():(C=document.getElementById(D))==null||C.focus()}if(g(7,()=>{var W;a.current.selectedItemId=(W=y())==null?void 0:W.id,j.emit()}),x||g(5,se),((R=u.current)==null?void 0:R.value)!==void 0){let W=h??"";(V=(q=u.current).onValueChange)==null||V.call(q,W);return}}j.emit()}},emit:()=>{l.current.forEach(m=>m())}}),[]),B=o.useMemo(()=>({value:(m,h,x)=>{var C;h!==((C=i.current.get(m))==null?void 0:C.value)&&(i.current.set(m,{value:h,keywords:x}),a.current.filtered.items.set(m,O(h,x)),g(2,()=>{H(),j.emit()}))},item:(m,h)=>(c.current.add(m),h&&(n.current.has(h)?n.current.get(h).add(m):n.current.set(h,new Set([m]))),g(3,()=>{Q(),H(),a.current.value||z(),j.emit()}),()=>{i.current.delete(m),c.current.delete(m),a.current.filtered.items.delete(m);let x=y();g(4,()=>{Q(),(x==null?void 0:x.getAttribute("id"))===m&&z(),j.emit()})}),group:m=>(n.current.has(m)||n.current.set(m,new Set),()=>{i.current.delete(m),n.current.delete(m)}),filter:()=>u.current.shouldFilter,label:r||t["aria-label"],getDisablePointerSelection:()=>u.current.disablePointerSelection,listId:D,inputId:U,labelId:P,listInnerRef:N}),[]);function O(m,h){var x,C;let R=(C=(x=u.current)==null?void 0:x.filter)!=null?C:ui;return m?R(m,a.current.search,h):0}function H(){if(!a.current.search||u.current.shouldFilter===!1)return;let m=a.current.filtered.items,h=[];a.current.filtered.groups.forEach(C=>{let R=n.current.get(C),q=0;R.forEach(V=>{let W=m.get(V);q=Math.max(W,q)}),h.push([C,q])});let x=N.current;A().sort((C,R)=>{var q,V;let W=C.getAttribute("id"),me=R.getAttribute("id");return((q=m.get(me))!=null?q:0)-((V=m.get(W))!=null?V:0)}).forEach(C=>{let R=C.closest(Pt);R?R.appendChild(C.parentElement===R?C:C.closest(`${Pt} > *`)):x.appendChild(C.parentElement===x?C:C.closest(`${Pt} > *`))}),h.sort((C,R)=>R[1]-C[1]).forEach(C=>{var R;let q=(R=N.current)==null?void 0:R.querySelector(`${ze}[${Te}="${encodeURIComponent(C[0])}"]`);q==null||q.parentElement.appendChild(q)})}function z(){let m=A().find(x=>x.getAttribute("aria-disabled")!=="true"),h=m==null?void 0:m.getAttribute(Te);j.setState("value",h||void 0)}function Q(){var m,h,x,C;if(!a.current.search||u.current.shouldFilter===!1){a.current.filtered.count=c.current.size;return}a.current.filtered.groups=new Set;let R=0;for(let q of c.current){let V=(h=(m=i.current.get(q))==null?void 0:m.value)!=null?h:"",W=(C=(x=i.current.get(q))==null?void 0:x.keywords)!=null?C:[],me=O(V,W);a.current.filtered.items.set(q,me),me>0&&R++}for(let[q,V]of n.current)for(let W of V)if(a.current.filtered.items.get(W)>0){a.current.filtered.groups.add(q);break}a.current.filtered.count=R}function se(){var m,h,x;let C=y();C&&(((m=C.parentElement)==null?void 0:m.firstChild)===C&&((x=(h=C.closest(ze))==null?void 0:h.querySelector(di))==null||x.scrollIntoView({block:"nearest"})),C.scrollIntoView({block:"nearest"}))}function y(){var m;return(m=N.current)==null?void 0:m.querySelector(`${mr}[aria-selected="true"]`)}function A(){var m;return Array.from(((m=N.current)==null?void 0:m.querySelectorAll(Cs))||[])}function M(m){let h=A()[m];h&&j.setState("value",h.getAttribute(Te))}function F(m){var h;let x=y(),C=A(),R=C.findIndex(V=>V===x),q=C[R+m];(h=u.current)!=null&&h.loop&&(q=R+m<0?C[C.length-1]:R+m===C.length?C[0]:C[R+m]),q&&j.setState("value",q.getAttribute(Te))}function $(m){let h=y(),x=h==null?void 0:h.closest(ze),C;for(;x&&!C;)x=m>0?ji(x,ze):yi(x,ze),C=x==null?void 0:x.querySelector(Cs);C?j.setState("value",C.getAttribute(Te)):F(m)}let ee=()=>M(A().length-1),k=m=>{m.preventDefault(),m.metaKey?ee():m.altKey?$(1):F(1)},_=m=>{m.preventDefault(),m.metaKey?M(0):m.altKey?$(-1):F(-1)};return o.createElement(X.div,{ref:s,tabIndex:-1,...L,"cmdk-root":"",onKeyDown:m=>{var h;(h=L.onKeyDown)==null||h.call(L,m);let x=m.nativeEvent.isComposing||m.keyCode===229;if(!(m.defaultPrevented||x))switch(m.key){case"n":case"j":{T&&m.ctrlKey&&k(m);break}case"ArrowDown":{k(m);break}case"p":case"k":{T&&m.ctrlKey&&_(m);break}case"ArrowUp":{_(m);break}case"Home":{m.preventDefault(),M(0);break}case"End":{m.preventDefault(),ee();break}case"Enter":{m.preventDefault();let C=y();if(C){let R=new Event(Dt);C.dispatchEvent(R)}}}}},o.createElement("label",{"cmdk-label":"",htmlFor:B.inputId,id:B.labelId,style:_i},r),vt(t,m=>o.createElement(hr.Provider,{value:j},o.createElement(pr.Provider,{value:B},m))))}),mi=o.forwardRef((t,s)=>{var a,c;let n=Ce(),i=o.useRef(null),l=o.useContext(fr),u=et(),r=xr(t),p=(c=(a=r.current)==null?void 0:a.forceMount)!=null?c:l==null?void 0:l.forceMount;Ee(()=>{if(!p)return u.item(n,l==null?void 0:l.id)},[p]);let v=vr(n,i,[t.value,t.children,i],t.keywords),b=Wt(),E=ge(g=>g.value&&g.value===v.current),w=ge(g=>p||u.filter()===!1?!0:g.search?g.filtered.items.get(n)>0:!0);o.useEffect(()=>{let g=i.current;if(!(!g||t.disabled))return g.addEventListener(Dt,f),()=>g.removeEventListener(Dt,f)},[w,t.onSelect,t.disabled]);function f(){var g,j;I(),(j=(g=r.current).onSelect)==null||j.call(g,v.current)}function I(){b.setState("value",v.current,!0)}if(!w)return null;let{disabled:T,value:L,onSelect:D,forceMount:P,keywords:U,...N}=t;return o.createElement(X.div,{ref:De(i,s),...N,id:n,"cmdk-item":"",role:"option","aria-disabled":!!T,"aria-selected":!!E,"data-disabled":!!T,"data-selected":!!E,onPointerMove:T||u.getDisablePointerSelection()?void 0:I,onClick:T?void 0:f},t.children)}),pi=o.forwardRef((t,s)=>{let{heading:a,children:c,forceMount:n,...i}=t,l=Ce(),u=o.useRef(null),r=o.useRef(null),p=Ce(),v=et(),b=ge(w=>n||v.filter()===!1?!0:w.search?w.filtered.groups.has(l):!0);Ee(()=>v.group(l),[]),vr(l,u,[t.value,t.heading,r]);let E=o.useMemo(()=>({id:l,forceMount:n}),[n]);return o.createElement(X.div,{ref:De(u,s),...i,"cmdk-group":"",role:"presentation",hidden:b?void 0:!0},a&&o.createElement("div",{ref:r,"cmdk-group-heading":"","aria-hidden":!0,id:p},a),vt(t,w=>o.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":a?p:void 0},o.createElement(fr.Provider,{value:E},w))))}),hi=o.forwardRef((t,s)=>{let{alwaysRender:a,...c}=t,n=o.useRef(null),i=ge(l=>!l.search);return!a&&!i?null:o.createElement(X.div,{ref:De(n,s),...c,"cmdk-separator":"",role:"separator"})}),fi=o.forwardRef((t,s)=>{let{onValueChange:a,...c}=t,n=t.value!=null,i=Wt(),l=ge(p=>p.search),u=ge(p=>p.selectedItemId),r=et();return o.useEffect(()=>{t.value!=null&&i.setState("search",t.value)},[t.value]),o.createElement(X.input,{ref:s,...c,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":r.listId,"aria-labelledby":r.labelId,"aria-activedescendant":u,id:r.inputId,type:"text",value:n?t.value:l,onChange:p=>{n||i.setState("search",p.target.value),a==null||a(p.target.value)}})}),gi=o.forwardRef((t,s)=>{let{children:a,label:c="Suggestions",...n}=t,i=o.useRef(null),l=o.useRef(null),u=ge(p=>p.selectedItemId),r=et();return o.useEffect(()=>{if(l.current&&i.current){let p=l.current,v=i.current,b,E=new ResizeObserver(()=>{b=requestAnimationFrame(()=>{let w=p.offsetHeight;v.style.setProperty("--cmdk-list-height",w.toFixed(1)+"px")})});return E.observe(p),()=>{cancelAnimationFrame(b),E.unobserve(p)}}},[]),o.createElement(X.div,{ref:De(i,s),...n,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":u,"aria-label":c,id:r.listId},vt(t,p=>o.createElement("div",{ref:De(l,r.listInnerRef),"cmdk-list-sizer":""},p)))}),xi=o.forwardRef((t,s)=>{let{open:a,onOpenChange:c,overlayClassName:n,contentClassName:i,container:l,...u}=t;return o.createElement(Va,{open:a,onOpenChange:c},o.createElement(Wa,{container:l},o.createElement(Xa,{"cmdk-overlay":"",className:n}),o.createElement(Ja,{"aria-label":t.label,"cmdk-dialog":"",className:i},o.createElement(gr,{ref:s,...u}))))}),vi=o.forwardRef((t,s)=>ge(a=>a.filtered.count===0)?o.createElement(X.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),bi=o.forwardRef((t,s)=>{let{progress:a,children:c,label:n="Loading...",...i}=t;return o.createElement(X.div,{ref:s,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,"aria-label":n},vt(t,l=>o.createElement("div",{"aria-hidden":!0},l)))}),te=Object.assign(gr,{List:gi,Item:mi,Input:fi,Group:pi,Separator:hi,Dialog:xi,Empty:vi,Loading:bi});function ji(t,s){let a=t.nextElementSibling;for(;a;){if(a.matches(s))return a;a=a.nextElementSibling}}function yi(t,s){let a=t.previousElementSibling;for(;a;){if(a.matches(s))return a;a=a.previousElementSibling}}function xr(t){let s=o.useRef(t);return Ee(()=>{s.current=t}),s}var Ee=typeof window>"u"?o.useEffect:o.useLayoutEffect;function Le(t){let s=o.useRef();return s.current===void 0&&(s.current=t()),s}function ge(t){let s=Wt(),a=()=>t(s.snapshot());return o.useSyncExternalStore(s.subscribe,a,a)}function vr(t,s,a,c=[]){let n=o.useRef(),i=et();return Ee(()=>{var l;let u=(()=>{var p;for(let v of a){if(typeof v=="string")return v.trim();if(typeof v=="object"&&"current"in v)return v.current?(p=v.current.textContent)==null?void 0:p.trim():n.current}})(),r=c.map(p=>p.trim());i.value(t,u,r),(l=s.current)==null||l.setAttribute(Te,u),n.current=u}),n}var ki=()=>{let[t,s]=o.useState(),a=Le(()=>new Map);return Ee(()=>{a.current.forEach(c=>c()),a.current=new Map},[t]),(c,n)=>{a.current.set(c,n),s({})}};function wi(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function vt({asChild:t,children:s},a){return t&&o.isValidElement(s)?o.cloneElement(wi(s),{ref:s.ref},a(s.props.children)):a(s)}var _i={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const br=o.forwardRef(({className:t,...s},a)=>e.jsx(te,{ref:a,className:re("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));br.displayName=te.displayName;const jr=o.forwardRef(({className:t,...s},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(Xe,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(te.Input,{ref:a,className:re("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));jr.displayName=te.Input.displayName;const yr=o.forwardRef(({className:t,...s},a)=>e.jsx(te.List,{ref:a,className:re("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));yr.displayName=te.List.displayName;const kr=o.forwardRef((t,s)=>e.jsx(te.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));kr.displayName=te.Empty.displayName;const wr=o.forwardRef(({className:t,...s},a)=>e.jsx(te.Group,{ref:a,className:re("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));wr.displayName=te.Group.displayName;const Ni=o.forwardRef(({className:t,...s},a)=>e.jsx(te.Separator,{ref:a,className:re("-mx-1 h-px bg-border",t),...s}));Ni.displayName=te.Separator.displayName;const _r=o.forwardRef(({className:t,...s},a)=>e.jsx(te.Item,{ref:a,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",t),...s}));_r.displayName=te.Item.displayName;const Ci=250;function Es({value:t,onChange:s,placeholder:a="Select...",searchPlaceholder:c="Search...",emptyMessage:n="No results found.",disabled:i=!1,selectedOption:l,queryKey:u,queryFn:r,enabled:p=!0,className:v}){const[b,E]=o.useState(!1),[w,f]=o.useState(""),[I,T]=o.useState("");o.useEffect(()=>{const N=window.setTimeout(()=>{T(w.trim())},Ci);return()=>window.clearTimeout(N)},[w]),o.useEffect(()=>{b||(f(""),T(""))},[b]);const{data:L=[],isFetching:D}=de({queryKey:[...u,I],queryFn:()=>r(I),enabled:p&&b}),P=o.useMemo(()=>!t||L.some(N=>N.value===t)?L:(l==null?void 0:l.value)===t?[l,...L]:L,[L,l,t]),U=o.useMemo(()=>{if(!t)return a;const N=P.find(g=>g.value===t)??((l==null?void 0:l.value)===t?l:null);return(N==null?void 0:N.label)??a},[P,a,l,t]);return e.jsxs(Zn,{open:b,onOpenChange:E,modal:!0,children:[e.jsx(ei,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",role:"combobox","aria-expanded":b,disabled:i,className:re("h-8 w-full justify-between px-2 text-sm font-normal",!t&&"text-muted-foreground",v),children:[e.jsx("span",{className:"truncate",children:U}),e.jsx(un,{className:"ml-1 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(dr,{className:"z-[60] w-[var(--radix-popover-trigger-width)] max-h-[var(--radix-popover-content-available-height)] overflow-hidden p-0",align:"start",collisionPadding:8,onWheel:N=>N.stopPropagation(),children:e.jsxs(br,{shouldFilter:!1,className:"h-full",children:[e.jsx(jr,{placeholder:c,value:w,onValueChange:f}),e.jsx(yr,{className:"max-h-[min(300px,calc(var(--radix-popover-content-available-height)-2.75rem))] min-h-0 overscroll-contain",children:D?e.jsxs("div",{className:"flex items-center justify-center py-6 text-sm text-muted-foreground",children:[e.jsx(ue,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading..."]}):P.length===0?e.jsx(kr,{children:n}):e.jsx(wr,{children:P.map(N=>e.jsxs(_r,{value:N.value,onSelect:()=>{s(N.value),E(!1)},children:[e.jsx(xe,{className:re("mr-2 h-4 w-4",t===N.value?"opacity-100":"opacity-0")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate",children:N.label}),N.description?e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:N.description}):null]})]},N.value))})})]})})]})}const Rt=100;function Ei(t){return(t??[]).some(s=>s.slug==="coding-agents"||s.name.trim().toLowerCase()==="coding agents")}function Ss(t){const s=parseInt(t.task_id,10),a=parseInt(t.dataset_id,10);return!(!Number.isFinite(s)||!Number.isFinite(a)||!t.metric_name.trim()||!t.metric_value.trim())}function Si(t){return t.map(s=>{const a=s.best_metric||Object.keys(s.metrics)[0],c=s.metrics[a];return{id:s.id,task_id:s.task_id,dataset_id:s.dataset_id,model_name:s.model_name||"",harness:s.harness||"",metric_name:a||"",metric_value:String(c||""),best_rank:s.best_rank?String(s.best_rank):"",num_parameters:s.num_parameters!=null?String(s.num_parameters):"",hf_model_url:s.hf_model_url||"",is_open:s.is_open!==!1,operation:"unchanged"}})}function Pi(t){const s=new Map;return t.forEach(a=>{a.task_id&&a.task_name&&s.set(a.task_id,{id:a.task_id,name:a.task_name,slug:a.task_slug,level:0})}),s}function Ri(t){const s=new Map;return t.forEach(a=>{a.dataset_id&&a.dataset_name&&s.set(a.dataset_id,{id:a.dataset_id,name:a.dataset_name,slug:a.dataset_slug})}),s}function Ps(t,s){return`${t}:${s}`}function ot(t){const s=t.trim();if(s==="")return null;const a=Number(s);return!Number.isFinite(a)||a<0?null:Math.trunc(a)}function lt(t){const s=t.trim();return s===""?null:s}function Ii({open:t,onOpenChange:s,paperId:a,arxivId:c,initialEvaluations:n,paperTasks:i,onSuccess:l,submitMode:u="direct",isAuthor:r=!1}){const p=Ei(i),[v,b]=o.useState([]),[E,w]=o.useState(null),[f,I]=o.useState(new Map),[T,L]=o.useState(new Map),D=Pe(),{toast:P}=ve(),U=o.useRef(!1),N=o.useRef(!1);o.useEffect(()=>{if(!t){U.current=!1,N.current=!1;return}U.current||N.current||n.length!==0&&(U.current=!0,b(Si(n)),I(Pi(n)),L(Ri(n)))},[t,n]);const g=o.useMemo(()=>Array.from(new Set(v.map(k=>k.task_id).filter(k=>k&&k!==""))),[v]),j=o.useMemo(()=>{const k=new Set;return v.forEach(_=>{_.task_id&&_.dataset_id&&k.add(Ps(_.task_id,_.dataset_id))}),Array.from(k)},[v]),B=de({queryKey:["datasets-by-tasks-for-eval-edit",g,t],queryFn:async()=>{const k={};return await Promise.all(g.map(async _=>{try{const m=await js({task_id:parseInt(_),page_size:Rt});k[_]=m.results}catch(m){console.error(`Error fetching datasets for task ${_}:`,m),k[_]=[]}})),k},enabled:t&&g.length>0});o.useEffect(()=>{B.data&&L(k=>{const _=new Map(k);return Object.values(B.data).forEach(m=>{m.forEach(h=>{_.set(h.id,h)})}),_})},[B.data]);const O=de({queryKey:["leaderboard-metrics-for-eval-edit",j,t],queryFn:async()=>{const k={};return await Promise.all(j.map(async _=>{const[m,h]=_.split(":");try{k[_]=await ba(h,m)}catch(x){console.error(`Error fetching metrics for leaderboard ${_}:`,x),k[_]=[]}})),k},enabled:t&&j.length>0}),H=async k=>{const _=await Ls({page_size:Rt,...k?{q:k}:{}});return I(m=>{const h=new Map(m);return _.results.forEach(x=>h.set(x.id,x)),h}),_.results.map(m=>{var h;return{value:m.id,label:m.name,description:(h=m.description)==null?void 0:h.slice(0,100)}})},z=k=>async _=>{const m=await js({task_id:parseInt(k),page_size:Rt,..._?{q:_}:{}});return L(h=>{const x=new Map(h);return m.results.forEach(C=>x.set(C.id,C)),x}),m.results.map(h=>({value:h.id,label:h.name,description:h.full_name}))},Q=(k,_)=>{if(!k||!_)return!1;const m=T.get(_);return!!(m!=null&&m.supports_harness)},se=(k,_,m)=>{var C;if(!k||!_)return[];const x=(((C=O.data)==null?void 0:C[Ps(k,_)])||[]).map(R=>({value:R.metric_name,label:R.metric_name,description:R.metric_direction==="higher_is_better"?"Higher is better":"Lower is better"}));return m&&!x.some(R=>R.value===m)&&x.unshift({value:m,label:`${m} (legacy)`,description:void 0}),x},y=Re({mutationFn:async({paperId:k,evaluations:_})=>{if(u==="pending"){const h=[];for(const x of _){if(x.operation==="delete"&&x.id){h.push({op:"delete",evaluation_id:parseInt(x.id)});continue}const C=Q(x.task_id,x.dataset_id);if(x.operation==="create"){if(!Ss(x))continue;const R=ot(x.num_parameters),q={task_id:parseInt(x.task_id),dataset_id:parseInt(x.dataset_id),metrics:{[x.metric_name]:x.metric_value},best_metric:x.metric_name},V=lt(x.hf_model_url);x.model_name&&(q.model_name=x.model_name),C&&x.harness&&(q.harness=x.harness),x.best_rank&&(q.best_rank=parseInt(x.best_rank)),R!=null&&(q.num_parameters=R),V!=null&&(q.hf_model_url=V),q.is_open=x.is_open,h.push({op:"create",data:q})}else if(x.operation==="update"&&x.id){const R={task_id:parseInt(x.task_id),dataset_id:parseInt(x.dataset_id),model_name:x.model_name||void 0,harness:C&&x.harness||null,metrics:{[x.metric_name]:x.metric_value},best_metric:x.metric_name,best_rank:x.best_rank?parseInt(x.best_rank):void 0,num_parameters:ot(x.num_parameters),hf_model_url:lt(x.hf_model_url),is_open:x.is_open};h.push({op:"update",evaluation_id:parseInt(x.id),data:R})}}return h.length===0?{submitted:!1}:(await Be({paper_id:parseInt(k),edit_type:"evaluations",proposed_payload:{operations:h}}),{submitted:!0})}let m=!1;for(const h of _)if(h.operation==="delete"&&h.id){m=!0;try{await ga(h.id)}catch(x){if((typeof x=="object"&&x!==null&&"status"in x?x.status:void 0)!==404)throw x;console.log(`Evaluation ${h.id} already deleted or not found`)}}else if(h.operation==="create"){if(!Ss(h))continue;m=!0;const x=Q(h.task_id,h.dataset_id),C=ot(h.num_parameters);await xa({paper_id:parseInt(k),task_id:parseInt(h.task_id),dataset_id:parseInt(h.dataset_id),model_name:h.model_name||void 0,harness:x&&h.harness||void 0,metrics:{[h.metric_name]:h.metric_value},best_metric:h.metric_name,best_rank:h.best_rank?parseInt(h.best_rank):void 0,num_parameters:C??void 0,hf_model_url:lt(h.hf_model_url)??void 0,is_open:h.is_open})}else if(h.operation==="update"&&h.id){m=!0;const x=Q(h.task_id,h.dataset_id);await va(h.id,{task_id:parseInt(h.task_id),dataset_id:parseInt(h.dataset_id),model_name:h.model_name||void 0,harness:x&&h.harness||null,metrics:{[h.metric_name]:h.metric_value},best_metric:h.metric_name,best_rank:h.best_rank?parseInt(h.best_rank):void 0,num_parameters:ot(h.num_parameters),hf_model_url:lt(h.hf_model_url),is_open:h.is_open})}return{submitted:m}},onSuccess:k=>{if(u==="pending"){k!=null&&k.submitted?P({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed evaluation changes shortly."}):P({title:"No changes to submit",description:"Your evaluation list matches the existing data."}),l==null||l(),s(!1);return}D.invalidateQueries({queryKey:["paper-arxiv",c]}),D.invalidateQueries({queryKey:["evaluations","paper",a]}),l==null||l(),s(!1)},onError:k=>{var h;const _=k;let m=_.message||(u==="pending"?"Failed to submit your edit. Please try again.":"Failed to update evaluations.");if(_.response)try{const x=JSON.parse(_.response);typeof(x==null?void 0:x.detail)=="string"?m=x.detail:Array.isArray(x==null?void 0:x.detail)&&((h=x.detail[0])!=null&&h.msg)&&(m=x.detail[0].msg)}catch{m=_.response}P({title:u==="pending"?"Could not submit edit":"Could not save evaluations",description:m,variant:"destructive"})}}),A=()=>{N.current=!0,b([...v,{task_id:"",dataset_id:"",model_name:"",harness:"",metric_name:"",metric_value:"",best_rank:"",num_parameters:"",hf_model_url:"",is_open:!0,operation:"create"}])},M=k=>{N.current=!0,v[k].id?b(v.map((m,h)=>h===k?{...m,operation:"delete"}:m)):b(v.filter((m,h)=>h!==k))},F=(k,_,m)=>{N.current=!0,b(v.map((h,x)=>{if(x!==k)return h;const C={...h,[_]:m};return _==="task_id"&&(C.dataset_id="",C.metric_name="",C.harness=""),_==="dataset_id"&&(C.metric_name="",m&&!Q(C.task_id,m)&&(C.harness="")),h.operation==="unchanged"&&(C.operation="update"),C}))},$=(k,_)=>{N.current=!0,b(v.map((m,h)=>{if(h!==k)return m;const x={...m,is_open:_};return m.operation==="unchanged"&&(x.operation="update"),x}))},ee=()=>{const k=v.filter(_=>_.operation!=="delete"||_.id);y.mutate({paperId:a,evaluations:k})};return e.jsxs(be,{open:t,onOpenChange:s,children:[e.jsxs(je,{className:"max-w-6xl max-h-[800px]",children:[e.jsxs(ye,{children:[e.jsx(ke,{children:"Edit Evaluation Results"}),e.jsx(we,{children:"Add, edit, or remove evaluation results for this paper. Each row represents a benchmark result."})]}),u==="pending"&&e.jsx(Oe,{isAuthor:r}),e.jsxs("div",{className:"py-4 overflow-y-auto max-h-[600px]",children:[v.filter(k=>k.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 ${p?"min-w-[140px]":"min-w-[240px]"}`,children:"Model"}),p&&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:v.map((k,_)=>{if(k.operation==="delete")return null;const m=f.get(k.task_id),h=T.get(k.dataset_id),x=se(k.task_id,k.dataset_id,k.metric_name),C=!!(k.task_id&&k.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(Es,{value:k.task_id,onChange:R=>F(_,"task_id",R),placeholder:"Select task",searchPlaceholder:"Search tasks...",emptyMessage:"No tasks found.",selectedOption:m?{value:m.id,label:m.name}:null,queryKey:["eval-edit-task-search"],queryFn:H,enabled:t})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(Es,{value:k.dataset_id,onChange:R=>F(_,"dataset_id",R),placeholder:k.task_id?"Select dataset":"Select task first",searchPlaceholder:"Search datasets...",emptyMessage:k.task_id?"No datasets found for this task.":"Select a task first.",disabled:!k.task_id,selectedOption:h?{value:h.id,label:h.name}:null,queryKey:["eval-edit-dataset-search",k.task_id],queryFn:z(k.task_id),enabled:t&&!!k.task_id})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(ne,{type:"text",className:"w-full text-sm",placeholder:"Model name",value:k.model_name,onChange:R=>F(_,"model_name",R.target.value)})}),p&&e.jsx("td",{className:"py-2 px-2",children:Q(k.task_id,k.dataset_id)?e.jsx(ne,{type:"text",className:"w-full text-sm",placeholder:"Claude Code, Terminus, ...",value:k.harness,onChange:R=>F(_,"harness",R.target.value)}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not supported"})}),e.jsx("td",{className:"py-2 px-2",children:!k.task_id||!k.dataset_id?e.jsx("span",{className:"text-xs text-muted-foreground",children:"Select task + dataset"}):C?e.jsxs("span",{className:"inline-flex items-center text-xs text-muted-foreground",children:[e.jsx(ue,{className:"mr-1 h-3 w-3 animate-spin"}),"Loading metrics..."]}):x.length>0?e.jsxs("select",{className:"w-full rounded-md border border-border bg-background px-2 py-1 text-sm",value:k.metric_name,onChange:R=>F(_,"metric_name",R.target.value),children:[e.jsx("option",{value:"",children:"Select metric"}),x.map(R=>e.jsx("option",{value:R.value,children:R.label},R.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(ne,{type:"text",className:"w-full text-sm",placeholder:"44.9",value:k.metric_value,onChange:R=>F(_,"metric_value",R.target.value)})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(ne,{type:"number",min:0,step:1,className:"w-full text-sm",placeholder:"e.g. 7000000000",value:k.num_parameters,onChange:R=>F(_,"num_parameters",R.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(ne,{type:"url",className:"w-full text-sm",placeholder:"https://huggingface.co/org/model",value:k.hf_model_url,onChange:R=>F(_,"hf_model_url",R.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:k.is_open,onChange:R=>$(_,R.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(K,{variant:"ghost",size:"sm",onClick:()=>M(_),className:"h-8 w-8 p-0 text-destructive hover:text-destructive",title:"Delete row",children:e.jsx(zt,{className:"w-4 h-4"})})})]},_)})})]})}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Za,{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(K,{variant:"outline",size:"sm",onClick:A,className:"flex items-center space-x-2",children:[e.jsx(Kt,{className:"w-4 h-4"}),e.jsx("span",{children:"Add Row"})]})})]}),e.jsxs(_e,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2 sm:mr-auto",children:[e.jsx(K,{variant:"ghost",onClick:()=>w("benchmark"),children:"Suggest a new benchmark"}),e.jsx(K,{variant:"ghost",onClick:()=>w("metric"),children:"Suggest a new metric"})]}),e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:ee,disabled:y.isPending,children:y.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2 animate-spin"}),u==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),u==="pending"?"Submit for review":"Save Changes"]})})]})]}),e.jsx(qt,{open:E!==null,onOpenChange:k=>{k||w(null)},paperId:a,kind:E??"benchmark"})]})}const Me=["my-bookmark-ids"];function Ai(){var c,n;const{user:t}=ht(),s=de({queryKey:Me,queryFn:()=>ut.getMyBookmarkIds(),enabled:!!t,staleTime:60*1e3,refetchOnWindowFocus:!1}),a=Ht.useMemo(()=>{var i;return new Set(((i=s.data)==null?void 0:i.paper_ids)??[])},[(c=s.data)==null?void 0:c.paper_ids]);return{ids:((n=s.data)==null?void 0:n.paper_ids)??[],idSet:a,isLoading:s.isLoading,isError:s.isError}}function $i(){const{user:t}=ht(),s=Pe(),a=Re({mutationFn:async({paperId:n,isBookmarked:i})=>{i?await ut.removeBookmark(n):await ut.addBookmark(n)},onMutate:async({paperId:n,isBookmarked:i})=>{await s.cancelQueries({queryKey:Me});const l=s.getQueryData(Me),u=typeof n=="string"?Number(n):n,r=(l==null?void 0:l.paper_ids)??[],p=i?r.filter(v=>v!==u):[u,...r.filter(v=>v!==u)];return s.setQueryData(Me,{paper_ids:p}),{previous:l}},onError:(n,i,l)=>{l!=null&&l.previous&&s.setQueryData(Me,l.previous)},onSettled:()=>{s.invalidateQueries({queryKey:Me}),s.invalidateQueries({queryKey:["my-bookmarks"]})}});return{toggle:Ht.useCallback((n,i)=>{if(!t){if(Us())return;const l=typeof window<"u"?window.location.pathname+window.location.search:"/";window.location.href=Bs(`/api/v1/auth/hf/login?return_to=${encodeURIComponent(l)}`);return}a.mutate({paperId:n,isBookmarked:i})},[a,t]),isPending:a.isPending}}const Fi=({paperId:t})=>{const{user:s}=ht(),{idSet:a}=Ai(),{toggle:c,isPending:n}=$i();if(Us())return null;const i=Number(t),l=!!s&&a.has(i),u=()=>{Number.isFinite(i)&&c(i,l)},r=s&&l?"Saved":"Save",p=s?l?"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${l?" is-saved":""}`,onClick:u,disabled:n,"aria-pressed":l,"aria-label":p,title:p,children:[e.jsx(Z,{name:"bookmark",size:12}),r]})};function ct({children:t,showEdit:s=!1,onEdit:a,editAriaLabel:c}){return s?e.jsxs("span",{className:"action-btn-composite",children:[t,e.jsx("button",{type:"button",className:"action-btn-segment action-btn-edit",onClick:a,"aria-label":c,children:"edit"})]}):t}const Ti={"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:nn,get:an,cancel:rn},"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:sn,get:tn,cancel:en}};function Li({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(cn,{remarkPlugins:[dn],components:{a:({children:s,...a})=>e.jsx("a",{...a,className:"break-all underline underline-offset-2",target:"_blank",rel:"noreferrer",children:s}),p:({children:s})=>e.jsx("p",{className:"mb-3 break-words last:mb-0",children:s}),ul:({children:s})=>e.jsx("ul",{className:"mb-3 list-disc space-y-1 pl-5 last:mb-0",children:s}),ol:({children:s})=>e.jsx("ol",{className:"mb-3 list-decimal space-y-1 pl-5 last:mb-0",children:s}),h1:({children:s})=>e.jsx("h3",{className:"mb-2 font-semibold",children:s}),h2:({children:s})=>e.jsx("h3",{className:"mb-2 font-semibold",children:s}),h3:({children:s})=>e.jsx("h3",{className:"mb-2 font-semibold",children:s}),code:({children:s})=>e.jsx("code",{className:"break-all rounded bg-background/80 px-1 py-0.5 font-mono text-xs",children:s}),pre:({children:s})=>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:s})},children:t})})}function Nr({kind:t,paperId:s,paperTitle:a,triggerClassName:c,onComplete:n}){const i=Ti[t],[l,u]=o.useState(!1),[r,p]=o.useState(null),[v,b]=o.useState(!1),[E,w]=o.useState(null),f=o.useRef(null),I=(r==null?void 0:r.status)==="queued"||(r==null?void 0:r.status)==="dispatching"||(r==null?void 0:r.status)==="running",T=r==null?void 0:r.id;o.useEffect(()=>{if(!I||!T)return;let U=!1;const N=window.setInterval(async()=>{try{const g=await i.get(T);U||(p(g),w(null))}catch(g){U||w(g instanceof Error?g.message:"Could not check job status.")}},2e3);return()=>{U=!0,window.clearInterval(N)}},[I,i,T]),o.useEffect(()=>{(r==null?void 0:r.status)!=="completed"||f.current===r.id||(f.current=r.id,n())},[r,n]);const L=async()=>{b(!0),w(null);try{p(await i.start(s))}catch(U){w(U instanceof Error?U.message:"Could not start Codex.")}finally{b(!1)}},D=()=>{p(null),w(null),f.current=null},P=async()=>{if(r){w(null);try{p(await i.cancel(r.id))}catch(U){w(U instanceof Error?U.message:"Could not cancel Codex.")}}};return e.jsxs(be,{open:l,onOpenChange:u,children:[e.jsx("button",{type:"button",className:c,onClick:()=>u(!0),children:I?i.running:(r==null?void 0:r.status)==="completed"?i.complete:i.trigger}),e.jsxs(je,{className:"max-h-[90vh] w-[calc(100vw-2rem)] min-w-0 max-w-2xl overflow-hidden",children:[e.jsxs(ye,{className:"min-w-0",children:[e.jsx(ke,{children:i.title}),e.jsx(we,{children:i.description(a)})]}),r?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: ",r.status]}),r.hf_job_url&&e.jsx("a",{className:"text-sm underline",href:r.hf_job_url,target:"_blank",rel:"noreferrer",children:"View Hugging Face Job"}),I&&e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3 text-sm",children:[r.status==="queued"?"This job is queued and will start after the current Codex job finishes.":i.progress," ","This can take several minutes; you can close this window and return."]}),r.report&&e.jsx(Li,{report:r.report}),r.error&&e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:r.error})]}):e.jsx("div",{className:"rounded-md border bg-muted/40 p-3 text-sm text-muted-foreground",children:i.notice}),E&&e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:E}),e.jsxs(_e,{children:[e.jsx(K,{variant:"outline",onClick:()=>u(!1),children:I?"Close":"Cancel"}),I&&e.jsx(K,{variant:"outline",onClick:()=>void P(),children:"Cancel job"}),!r&&e.jsx(K,{onClick:L,disabled:v,children:v?"Starting…":i.action}),r&&!I&&e.jsx(K,{variant:"outline",onClick:D,children:"Run again"})]})]})]})}function Mi(t){return e.jsx(Nr,{...t,kind:"add-evals",triggerClassName:"edit-link"})}function Di(t){return e.jsx(Nr,{...t,kind:"enrich-paper",triggerClassName:"action-btn"})}var Xt="Radio",[Ui,Cr]=pt(Xt),[Bi,Oi]=Ui(Xt),Er=o.forwardRef((t,s)=>{const{__scopeRadio:a,name:c,checked:n=!1,required:i,disabled:l,value:u="on",onCheck:r,form:p,...v}=t,[b,E]=o.useState(null),w=Se(s,T=>E(T)),f=o.useRef(!1),I=b?p||!!b.closest("form"):!0;return e.jsxs(Bi,{scope:a,checked:n,disabled:l,children:[e.jsx(X.button,{type:"button",role:"radio","aria-checked":n,"data-state":Ir(n),"data-disabled":l?"":void 0,disabled:l,value:u,...v,ref:w,onClick:ce(t.onClick,T=>{n||r==null||r(),I&&(f.current=T.isPropagationStopped(),f.current||T.stopPropagation())})}),I&&e.jsx(Rr,{control:b,bubbles:!f.current,name:c,value:u,checked:n,required:i,disabled:l,form:p,style:{transform:"translateX(-100%)"}})]})});Er.displayName=Xt;var Sr="RadioIndicator",Pr=o.forwardRef((t,s)=>{const{__scopeRadio:a,forceMount:c,...n}=t,i=Oi(Sr,a);return e.jsx(mt,{present:c||i.checked,children:e.jsx(X.span,{"data-state":Ir(i.checked),"data-disabled":i.disabled?"":void 0,...n,ref:s})})});Pr.displayName=Sr;var Hi="RadioBubbleInput",Rr=o.forwardRef(({__scopeRadio:t,control:s,checked:a,bubbles:c=!0,...n},i)=>{const l=o.useRef(null),u=Se(l,i),r=Hs(a),p=Fs(s);return o.useEffect(()=>{const v=l.current;if(!v)return;const b=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(b,"checked").set;if(r!==a&&w){const f=new Event("click",{bubbles:c});w.call(v,a),v.dispatchEvent(f)}},[r,a,c]),e.jsx(X.input,{type:"radio","aria-hidden":!0,defaultChecked:a,...n,tabIndex:-1,ref:u,style:{...n.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Rr.displayName=Hi;function Ir(t){return t?"checked":"unchecked"}var qi=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],bt="RadioGroup",[Ki]=pt(bt,[Os,Cr]),Ar=Os(),$r=Cr(),[zi,Gi]=Ki(bt),Fr=o.forwardRef((t,s)=>{const{__scopeRadioGroup:a,name:c,defaultValue:n,value:i,required:l=!1,disabled:u=!1,orientation:r,dir:p,loop:v=!0,onValueChange:b,...E}=t,w=Ar(a),f=ja(p),[I,T]=Ot({prop:i,defaultProp:n??null,onChange:b,caller:bt});return e.jsx(zi,{scope:a,name:c,required:l,disabled:u,value:I,onValueChange:T,children:e.jsx(ya,{asChild:!0,...w,orientation:r,dir:f,loop:v,children:e.jsx(X.div,{role:"radiogroup","aria-required":l,"aria-orientation":r,"data-disabled":u?"":void 0,dir:f,...E,ref:s})})})});Fr.displayName=bt;var Tr="RadioGroupItem",Lr=o.forwardRef((t,s)=>{const{__scopeRadioGroup:a,disabled:c,...n}=t,i=Gi(Tr,a),l=i.disabled||c,u=Ar(a),r=$r(a),p=o.useRef(null),v=Se(s,p),b=i.value===n.value,E=o.useRef(!1);return o.useEffect(()=>{const w=I=>{qi.includes(I.key)&&(E.current=!0)},f=()=>E.current=!1;return document.addEventListener("keydown",w),document.addEventListener("keyup",f),()=>{document.removeEventListener("keydown",w),document.removeEventListener("keyup",f)}},[]),e.jsx(ka,{asChild:!0,...u,focusable:!l,active:b,children:e.jsx(Er,{disabled:l,required:i.required,checked:b,...r,...n,name:i.name,ref:v,onCheck:()=>i.onValueChange(n.value),onKeyDown:ce(w=>{w.key==="Enter"&&w.preventDefault()}),onFocus:ce(n.onFocus,()=>{var w;E.current&&((w=p.current)==null||w.click())})})})});Lr.displayName=Tr;var Qi="RadioGroupIndicator",Mr=o.forwardRef((t,s)=>{const{__scopeRadioGroup:a,...c}=t,n=$r(a);return e.jsx(Pr,{...n,...c,ref:s})});Mr.displayName=Qi;var Dr=Fr,Ur=Lr,Vi=Mr;const Ut=o.forwardRef(({className:t,...s},a)=>e.jsx(Dr,{className:re("grid gap-2",t),...s,ref:a}));Ut.displayName=Dr.displayName;const Ve=o.forwardRef(({className:t,...s},a)=>e.jsx(Ur,{ref:a,className:re("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),...s,children:e.jsx(Vi,{className:"flex items-center justify-center",children:e.jsx(wa,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Ve.displayName=Ur.displayName;const Wi={model:"Model",dataset:"Dataset",space:"Space",github:"GitHub"},Bt=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function It(t){return"'"+t.replace(/'/g,`'"'"'`)+"'"}function At(t,s){try{const a=new URL(t);if(a.hostname!=="huggingface.co")return null;const c=a.pathname.split("/").filter(Boolean),n=s==="model"?[]:[`${s}s`];if(n.length&&c[0]!==n[0])return null;const i=c.slice(n.length,n.length+2);if(i.length!==2||i.some(r=>!Bt.test(r)))return null;const l=i.join("/"),u=s==="model"?"":`${s}s/`;return{id:`${s}:${l}`,kind:s,label:l,url:`https://huggingface.co/${u}${l}`,source:`hf://${u}${l}/`,destination:`${s}s/${l}/`}}catch{return null}}function Xi(t){try{const s=new URL(t);if(s.hostname!=="github.com"&&s.hostname!=="www.github.com")return null;const a=s.pathname.split("/").filter(Boolean);if(a.length<2)return null;const c=a[0],n=a[1].replace(/\.git$/,"");if(!Bt.test(c)||!Bt.test(n))return null;const i=`${c}/${n}`;return{id:`github:${i}`,kind:"github",label:i,url:`https://github.com/${i}`,source:`https://github.com/${i}.git`,destination:`github/${i}/`}}catch{return null}}function Ji({githubUrls:t,hfModelUrls:s,hfDatasetUrls:a,hfSpaceUrls:c}){const n=[...s.map(l=>At(l,"model")),...a.map(l=>At(l,"dataset")),...c.map(l=>At(l,"space")),...t.map(Xi)],i=new Set;return n.filter(l=>!l||i.has(l.id)?!1:(i.add(l.id),!0))}function Yi(t,s,a){const c=["# Requires the Hugging Face CLI: https://huggingface.co/docs/huggingface_hub/guides/cli",`HF_BUCKET=${It(t.trim())}`];a.create&&c.push(`hf buckets create "$HF_BUCKET" --exist-ok${a.isPrivate?" --private":""}`);for(const i of s.filter(l=>l.kind!=="github"))c.push(`hf cp ${It(i.source)} "hf://buckets/$HF_BUCKET/${i.destination}"`);const n=s.filter(i=>i.kind==="github");if(n.length){c.push('PWC_COPY_DIR="$(mktemp -d)"',`trap 'rm -rf "$PWC_COPY_DIR"' EXIT`);for(const i of n){const l=`$PWC_COPY_DIR/${i.destination.replace(/\/$/,"")}`;c.push(`git clone --depth 1 -- ${It(i.source)} "${l}"`,`hf sync "${l}" "hf://buckets/$HF_BUCKET/${i.destination}" --exclude '.git/**'`)}}return c.join(` +`)}function Zi(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 eo(t){const{toast:s}=ve(),a=o.useMemo(()=>Ji(t),[t.githubUrls,t.hfDatasetUrls,t.hfModelUrls,t.hfSpaceUrls]),[c,n]=o.useState(!1),[i,l]=o.useState("new"),[u,r]=o.useState(""),[p,v]=o.useState("public"),[b,E]=o.useState(()=>new Set(a.map(P=>P.id))),w=a.filter(P=>b.has(P.id)),f=/^[A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*$/.test(u.trim()),I=Yi(u,w,{create:i==="new",isPrivate:p==="private"}),T=(P,U)=>{E(N=>{const g=new Set(N);return U?g.add(P):g.delete(P),g})},L=async()=>{try{await navigator.clipboard.writeText(I),s({title:"Bucket copy commands copied",description:"Run them in a terminal where the Hugging Face CLI is signed in."})}catch{s({title:"Copy failed",description:"Could not access the clipboard. Select and copy the commands manually.",variant:"destructive"})}},D=()=>{E(new Set(a.map(P=>P.id))),!u&&t.suggestedBucketId&&r(t.suggestedBucketId),n(!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:D,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:a.length?`${a.length} linked artifact${a.length===1?"":"s"}`:"No linked artifacts yet"})]}),e.jsx(be,{open:c,onOpenChange:n,children:e.jsxs(je,{className:"max-h-[90vh] max-w-2xl overflow-y-auto",children:[e.jsxs(ye,{children:[e.jsxs(ke,{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(we,{children:"Keep your own copy of this paper's linked code and Hugging Face artifacts. Hub repositories use Xet's server-side copy; GitHub repositories are cloned into the same destination."})]}),a.length?e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Choose your destination"}),e.jsxs(Ut,{value:i,onValueChange:P=>l(P),className:"grid grid-cols-2 gap-2",children:[e.jsxs(le,{className:"bucket-choice",children:[e.jsx(Ve,{value:"new"}),"New bucket"]}),e.jsxs(le,{className:"bucket-choice",children:[e.jsx(Ve,{value:"existing"}),"Existing bucket"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"bucket-id",children:"Bucket name"}),e.jsx(ne,{id:"bucket-id",value:u,onChange:P=>r(P.target.value),placeholder:t.suggestedBucketId||"username/paper-artifacts","aria-invalid":u.length>0&&!f}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use the full Hugging Face bucket ID: namespace/name."})]}),i==="new"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Bucket visibility"}),e.jsxs(Ut,{value:p,onValueChange:P=>v(P),className:"flex gap-5",children:[e.jsxs(le,{className:"flex items-center gap-2 font-normal",children:[e.jsx(Ve,{value:"public"}),"Public"]}),e.jsxs(le,{className:"flex items-center gap-2 font-normal",children:[e.jsx(Ve,{value:"private"}),"Private"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Artifacts"}),e.jsx("div",{className:"bucket-artifact-list",children:a.map(P=>e.jsxs("div",{className:"bucket-artifact-row",children:[e.jsx(gt,{id:`bucket-artifact-${P.id}`,checked:b.has(P.id),onCheckedChange:U=>T(P.id,U===!0)}),e.jsxs(le,{htmlFor:`bucket-artifact-${P.id}`,className:"min-w-0 flex-1 cursor-pointer font-normal",children:[e.jsx("span",{className:"bucket-artifact-kind",children:Wi[P.kind]}),e.jsx("span",{className:"bucket-artifact-name",children:P.label})]}),e.jsxs("a",{href:P.url,target:"_blank",rel:"noopener noreferrer",className:"bucket-artifact-open",children:[P.kind==="github"?"Open":"Web copy",e.jsx(Z,{name:"external",size:10})]})]},P.id))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"“Web copy” opens the artifact's native Hugging Face page, where its Copy to bucket button is also available."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"bucket-copy-commands",children:"Copy workflow"}),e.jsx("pre",{id:"bucket-copy-commands",className:"bucket-copy-commands",children:f?I:"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(_e,{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(K,{type:"button",onClick:L,disabled:!f||w.length===0,children:[e.jsx(Z,{name:"copy",size:12}),"Copy commands"]})]})]})})]})}const to={tasks:"tasks",methods:"methods",results:"evaluation results",repositories:"GitHub repositories","project-pages":"project pages","source-url":"source URL"},dt=360,$t=3,so=3,ro=["tldr","abstract","tasks","methods","results"];function ao(t){if(!t)return{section:null,resultsTaskSlug:null};const[s,a]=t.split("?",2);if(!ro.includes(s))return{section:null,resultsTaskSlug:null};const c=s;return c!=="results"||!a?{section:c,resultsTaskSlug:null}:{section:c,resultsTaskSlug:new URLSearchParams(a).get("task")}}function Rs(t){return`results-task-${t}`}function no(t){return`#results?task=${encodeURIComponent(t)}`}function Ge({id:t,label:s,accent:a}){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:s})}),a]})}function Is(t){if(!t)return"—";try{return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return"—"}}function As(t){return t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function $s(t,s){try{const a=new URL(t),n=a.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);return n?n.replace(/[-_]+/g," "):a.hostname.replace(/^www\./,"")}catch{return s}}const $o=()=>{var us,ms,ps,hs,fs,gs,xs,vs,bs;const{arxivId:t}=_a(),s=t?Na(t):"",a=Ca(),{toast:c}=ve(),{user:n}=ht(),i=(n==null?void 0:n.is_admin)??!1,l=!!n,u=!0,{data:r,isLoading:p,error:v,refetch:b}=za(s||"",!!s),[E,w]=o.useState(!1);o.useEffect(()=>{if(!t||t===s)return;const d=window.location.search+window.location.hash;a(`/paper/${s}${d}`,{replace:!0})},[s,a,t]),o.useEffect(()=>{if(r!=null&&r.title)return document.title=qa(r.title),()=>{document.title=Ka}},[r==null?void 0:r.title]),o.useEffect(()=>{if(w(!1),!(r!=null&&r.id))return;const d=window.setTimeout(()=>w(!0),0);return()=>window.clearTimeout(d)},[r==null?void 0:r.id]);const{data:f,isLoading:I}=vn(E?r==null?void 0:r.arxiv_id:void 0),{data:T,isLoading:L,refetch:D}=hn(r==null?void 0:r.id,E&&!!(r!=null&&r.id)),{preferences:P}=Ea(),U=o.useMemo(()=>!T||!P.hide_closed_source_evals?T:T.filter(d=>d.is_open!==!1),[T,P.hide_closed_source_evals]),N=o.useMemo(()=>({models:(r==null?void 0:r.hf_models)??[],datasets:(r==null?void 0:r.hf_datasets)??[],spaces:(r==null?void 0:r.hf_spaces)??[]}),[r==null?void 0:r.hf_models,r==null?void 0:r.hf_datasets,r==null?void 0:r.hf_spaces]),g=o.useMemo(()=>{const d=(S,G,J)=>{const oe=new Set,Y=[];for(const ae of[...S,...G??[]])if(!oe.has(ae)&&(oe.add(ae),Y.push({href:ae,label:$s(ae,J)}),Y.length>=so))break;return Y};return{models:d(N.models,f==null?void 0:f.modelUrls,"Model"),datasets:d(N.datasets,f==null?void 0:f.datasetUrls,"Dataset"),spaces:d(N.spaces,f==null?void 0:f.spaceUrls,"Space")}},[N.models,N.datasets,N.spaces,f==null?void 0:f.modelUrls,f==null?void 0:f.datasetUrls,f==null?void 0:f.spaceUrls]),j=o.useMemo(()=>{if(!U)return[];const d=new Map;for(const S of U){const G=S.task_id,J=d.get(G);J?J.rows.push(S):d.set(G,{taskId:G,taskName:S.task_name||"—",taskSlug:S.task_slug,rows:[S]})}return Array.from(d.values())},[U]),B=o.useMemo(()=>j.map(d=>d.taskSlug??"").join("|"),[j]),O=de({queryKey:["paper-versions",r==null?void 0:r.arxiv_id],queryFn:async()=>{const d=r.arxiv_id.replace(/v\d+$/,""),S=await fetch(Bs(`/api/v1/papers/arxiv/${d}/versions`));return S.ok?await S.json():[]},enabled:E&&!!(r!=null&&r.arxiv_id),staleTime:10*60*1e3}),H=de({queryKey:["related-papers",r==null?void 0:r.id],queryFn:()=>ut.getRelatedPapers(r.arxiv_id||r.id,4),enabled:E&&!!(r!=null&&r.id),staleTime:10*60*1e3}),[z,Q]=o.useState(!1),[se,y]=o.useState(!1),[A,M]=o.useState(!1),F=o.useRef(!1);o.useEffect(()=>{F.current=!1},[s]),o.useEffect(()=>{let d=0;const S=(J=!1,oe=!1)=>{const{section:Y,resultsTaskSlug:ae}=ao(window.location.hash.slice(1));if(!Y||!r||Y==="tldr"&&!r.tldr||Y==="results"&&(!E||L)||!J&&F.current)return;let Fe=null;if(Y==="results"&&ae){if(Fe=document.getElementById(Rs(ae)),!Fe){if(j.find(Zr=>Zr.taskSlug===ae))return;Fe=document.getElementById("results")}}else Fe=document.getElementById(Y);if(!Fe)return;const Yr=Fe;d=window.requestAnimationFrame(()=>{F.current=!0,Yr.scrollIntoView({block:"start",behavior:oe?"smooth":"auto"})})};S();const G=()=>{F.current=!1,S(!0,!0)};return window.addEventListener("hashchange",G),()=>{window.removeEventListener("hashchange",G),d&&window.cancelAnimationFrame(d)}},[r,r==null?void 0:r.tldr,E,L,B,j]);const{isEditingTasks:$,setIsEditingTasks:ee,isEditingMethods:k,setIsEditingMethods:_,isEditingRepositories:m,setIsEditingRepositories:h,isEditingProjectPages:x,setIsEditingProjectPages:C,isEditingEvaluations:R,setIsEditingEvaluations:q,isEditingSourceUrl:V,setIsEditingSourceUrl:W}=bn(),[me,Jt]=o.useState(null),Ie=o.useMemo(()=>{if(!n||!(r!=null&&r.author_links))return!1;const d=n.username.toLowerCase();return r.author_links.some(S=>!!S.hf_username&&S.hf_username.toLowerCase()===d)},[n,r==null?void 0:r.author_links]),Ae=i?"direct":"pending",ie=d=>{if(!l){Jt(d);return}switch(d){case"tasks":ee(!0);return;case"methods":_(!0);return;case"results":q(!0);return;case"repositories":h(!0);return;case"project-pages":C(!0);return;case"source-url":W(!0);return}},[Yt,jt]=o.useState("idle"),[Zt,es]=o.useState(null),[ts,ss]=o.useState(null),Br=async()=>{if(s){jt("indexing"),es(null),ss(null);try{await Fa(s),c({title:"Indexed",description:"Paper added to database."}),setTimeout(()=>b(),1200),jt("idle")}catch(d){const S=d;let G=S.message||"Failed to index paper";if(S.response)try{G=JSON.parse(S.response).detail||G}catch{G=S.response}es(G),(S.status===429||S.status===503)&&ss("Try again later after arXiv has lifted the temporary limit."),jt("idle")}}},{citationDisplay:Or,citationCopy:rs}=o.useMemo(()=>{if(!r)return{citationDisplay:"",citationCopy:""};const d=`${r.title.slice(0,60)}${r.title.length>60?"…":""}`,S=`${r.authors[0]||""}${r.authors.length>1?" et al.":""}`,G=r.authors.join(" and "),J=(r.published||"").slice(0,4)||"—",oe=(Y,ae)=>r.arxiv_id?`@article{${r.arxiv_id.replace(".","")}, + title={{${Y}}}, + author=${ae}, + year={{${J}}}, + eprint={{${r.arxiv_id}}}, + archivePrefix={{arXiv}} +}`:`@misc{paper${r.id}, + title={{${Y}}}, + author=${ae}, + year={{${J}}}, + url={{${r.source_url||r.url_abs||""}}} +}`;return{citationDisplay:oe(d,`{{${S}}}`),citationCopy:oe(r.title,`{${G}}`)}},[r]),as=o.useMemo(()=>mn(r==null?void 0:r.leaderboard_ranks),[r==null?void 0:r.leaderboard_ranks]),[Hr,ns]=o.useState(!1),qr=async()=>{if(rs)try{await navigator.clipboard.writeText(rs),ns(!0),c({title:"Citation copied",description:"BibTeX entry copied to clipboard."}),window.setTimeout(()=>ns(!1),1500)}catch{c({title:"Copy failed",description:"Could not access the clipboard. Please copy manually.",variant:"destructive"})}},Kr=async()=>{if(!r)return;const d=r.arxiv_id||r.id,S=pn(d,as);if(S)try{await navigator.clipboard.writeText(S),c({title:"PwC badges copied",description:"Each badge links to its highlighted leaderboard row."})}catch{c({title:"Copy failed",description:"Could not access the clipboard. Please try again.",variant:"destructive"})}};if(p)return e.jsxs("div",{className:"page",children:[e.jsx(Qe,{className:"h-12 w-3/4 mb-4"}),e.jsx(Qe,{className:"h-6 w-1/3 mb-8"}),e.jsx(Qe,{className:"h-64 w-full"})]});if(v||!r)return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"breadcrumb",children:[e.jsx(he,{to:"/papers",children:"Papers"}),e.jsx("span",{className:"sep",children:"/"}),e.jsxs("span",{style:{color:"var(--ink)"},children:["arXiv:",s]})]}),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:",s]})," in the database. You can index it from arXiv right now."]}),Zt&&e.jsx(Ga,{variant:"destructive",className:"mt-4 max-w-xl",children:e.jsxs(Qa,{children:[e.jsx("div",{children:Zt}),ts&&e.jsx("div",{className:"mt-2",children:ts})]})}),e.jsxs("div",{className:"action-row",children:[i&&e.jsxs("button",{className:"action-btn",onClick:Br,disabled:Yt==="indexing",children:[e.jsx(Z,{name:"sparkle",size:12}),Yt==="indexing"?"Indexing…":"Index from arXiv"]}),e.jsx(K,{variant:"outline",onClick:()=>a("/papers"),children:"Browse Papers"})]})]});const is=O.data||[],He=Ha(r.repositories),pe=[...r.repositories??[]].sort((d,S)=>{const G=d.is_official?1:0,J=S.is_official?1:0;return G!==J?J-G:(S.num_stars||0)-(d.num_stars||0)}),zr=A?pe:pe.slice(0,$t),yt={models:[...new Set([...N.models,...(f==null?void 0:f.modelUrls)??[]])],datasets:[...new Set([...N.datasets,...(f==null?void 0:f.datasetUrls)??[]])],spaces:[...new Set([...N.spaces,...(f==null?void 0:f.spaceUrls)??[]])]},kt=((us=r.arxiv_id)==null?void 0:us.replace(/v\d+$/,""))??null,wt=r.arxiv_id?{isLoading:I,paperHref:`https://huggingface.co/papers/${kt}`,rows:[{label:"Models",href:Tt(`https://huggingface.co/models?other=arxiv:${r.arxiv_id}`,N.models),count:Lt(N.models,f==null?void 0:f.modelUrls,f==null?void 0:f.models),isLimited:f==null?void 0:f.isLimited,links:g.models},{label:"Datasets",href:Tt(`https://huggingface.co/datasets?other=arxiv:${r.arxiv_id}`,N.datasets),count:Lt(N.datasets,f==null?void 0:f.datasetUrls,f==null?void 0:f.datasets),isLimited:f==null?void 0:f.isLimited,links:g.datasets},{label:"Spaces",href:Tt(`https://huggingface.co/papers/${kt}`,N.spaces),count:Lt(N.spaces,f==null?void 0:f.spaceUrls,f==null?void 0:f.spaces),isLimited:f==null?void 0:f.isLimited,links:g.spaces}],footer:`Cite arxiv.org/abs/${kt} in a HF README to link it here.`}:{isLoading:!1,paperHref:null,rows:[{label:"Models",href:Ft(N.models),count:N.models.length,links:g.models},{label:"Datasets",href:Ft(N.datasets),count:N.datasets.length,links:g.datasets},{label:"Spaces",href:Ft(N.spaces),count:N.spaces.length,links:g.spaces}],footer:null},os=r.tldr||null,ls=r.num_pages||null,$e=r.abstract||"",Gr=$e.length>dt?$e.slice(0,dt)+"…":$e,Qr=z||$e.length<=dt?$e:Gr,tt=(r.methods||[]).filter(d=>d.source_paper_id===r.id),st=r.introduced_benchmarks||[],qe=r.introduced_frameworks||[],Vr=tt.length>0||st.length>0||qe.length>0,cs=r.arxiv_id?`arXiv:${r.arxiv_id}`:"External resource",Wr=r.source==="external"?"Source page":"arXiv page",Ke=((ms=r.project_pages)==null?void 0:ms.filter(d=>d.url))??[],Xr=(()=>{const d=[];return tt.length>0&&d.push(tt.length===1?"this method":"these methods"),st.length>0&&d.push(st.length===1?"this benchmark":"these benchmarks"),qe.length>0&&d.push(qe.length===1?"this framework":"these frameworks"),d.length===0?"":d.length===1?d[0]:d.join(" and ")})(),rt=r.predecessor_papers||[],at=r.successor_papers||[],Jr=rt.length>0||at.length>0,nt=12,_t=r.authors.map((d,S)=>{var G,J,oe,Y;return{name:d,id:((J=(G=r.author_links)==null?void 0:G[S])==null?void 0:J.id)??null,hf_username:((Y=(oe=r.author_links)==null?void 0:oe[S])==null?void 0:Y.hf_username)??null}}),ds=se||_t.length<=nt?_t:_t.slice(0,nt);return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"breadcrumb",children:[e.jsx(he,{to:"/",children:"Trending"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("span",{children:cs})]}),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(it,{title:r.title})}),e.jsxs("div",{className:"detail-meta",children:[e.jsx("span",{children:cs}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:["Submitted ",Is(r.published)]}),ls&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[ls," pages"]})]}),r.citation_count!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[r.citation_count.toLocaleString()," citations"]})]}),(r.proceeding||r.conference_slug)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),r.conference_slug?e.jsx("a",{href:`/conferences/${r.conference_slug}`,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent-text)"},children:(r.proceeding||r.conference_name||"").replace(/\s+\d{1,2}$/,"")}):e.jsx("span",{children:r.proceeding.replace(/\s+\d{1,2}$/,"")})]}),is.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("select",{className:"version-select",value:r.version,onChange:d=>{const S=d.target.value;r.arxiv_id&&a(`/paper/${r.arxiv_id.replace(/v\d+$/,"")}${S?`?version=${S}`:""}`)},children:is.map(d=>e.jsxs("option",{value:d.version,children:[d.version," — ",Is(d.published)]},d.version))})]})]}),e.jsxs("div",{className:"detail-authors",children:[ds.map((d,S)=>e.jsxs(Ht.Fragment,{children:[d.id?e.jsx(he,{to:`/authors/${d.id}`,children:d.name}):d.hf_username?e.jsx("a",{href:`https://huggingface.co/${d.hf_username}`,target:"_blank",rel:"noopener noreferrer",title:`@${d.hf_username} on Hugging Face`,children:d.name}):e.jsx("a",{children:d.name}),Snt&&e.jsx("button",{className:"show-more-authors",onClick:()=>y(d=>!d),style:{marginLeft:8,background:"none",border:"none",cursor:"pointer",color:"var(--accent-text)",fontFamily:"var(--mono)",fontSize:12},children:se?"show fewer":`+${r.authors.length-nt} more`})]}),e.jsxs("div",{className:"action-row",children:[r.url_pdf&&e.jsxs("a",{className:"action-btn",href:r.url_pdf,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Z,{name:"pdf",size:12})," View PDF"]}),r.url_abs&&e.jsx(ct,{showEdit:r.source==="external"&&u,onEdit:()=>ie("source-url"),editAriaLabel:"Edit source URL",children:e.jsxs("a",{className:r.source==="external"&&u?"action-btn-segment action-btn-main":"action-btn",href:r.url_abs,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Z,{name:"external",size:12})," ",Wr]})}),wt.paperHref&&(f==null?void 0:f.paperExists)&&e.jsxs("a",{className:"bm-action-btn",href:wt.paperHref,target:"_blank",rel:"noopener noreferrer","aria-label":"View on Hugging Face",children:["View on ",e.jsx("span",{"aria-hidden":"true",children:"🤗"})]}),He.githubUrl&&e.jsx(ct,{showEdit:u,onEdit:()=>ie("repositories"),editAriaLabel:"Edit code repositories",children:e.jsxs("a",{className:"action-btn-segment action-btn-main",href:He.githubUrl,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Z,{name:"github",size:12})," Code",He.github!=null&&e.jsxs("span",{style:{opacity:.7,marginLeft:4},children:["· ",As(He.github)," ★"]})]})}),He.githubUrl?null:e.jsxs("button",{type:"button",className:"action-btn",onClick:()=>ie("repositories"),title:"Add GitHub repository",children:[e.jsx(Z,{name:"github",size:12})," Add code"]}),Ke.length===1?e.jsx(ct,{showEdit:u,onEdit:()=>ie("project-pages"),editAriaLabel:"Edit project pages",children:e.jsxs("a",{className:"action-btn-segment action-btn-main",href:Ke[0].url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Z,{name:"globe",size:12})," Project page"]})}):null,Ke.length>1?e.jsx(ct,{showEdit:u,onEdit:()=>ie("project-pages"),editAriaLabel:"Edit project pages",children:e.jsxs(Sa,{children:[e.jsx(Pa,{asChild:!0,children:e.jsxs("button",{type:"button",className:"action-btn-segment action-btn-main",children:[e.jsx(Z,{name:"globe",size:12})," Project page"]})}),e.jsx(Ra,{align:"start",className:"project-page-menu",children:Ke.map((d,S)=>e.jsx(Ia,{asChild:!0,children:e.jsx("a",{href:d.url,target:"_blank",rel:"noopener noreferrer",children:$s(d.url,`Project page ${S+1}`)})},d.url))})]})}):null,Ke.length===0&&l?e.jsxs("button",{type:"button",className:"action-btn",onClick:()=>ie("project-pages"),title:"Add project page",children:[e.jsx(Z,{name:"globe",size:12})," Add project page"]}):null,r.conference_url_abs&&e.jsxs("a",{className:"action-btn",href:r.conference_url_abs,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Z,{name:"external",size:12})," Conference"]}),(r.organizations||[]).map(d=>e.jsxs(he,{to:`/orgs/${d.slug}`,className:"action-btn",title:d.name,"aria-label":d.name,children:[d.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:d.logo_url,alt:"",style:{height:"150%",width:"150%",objectFit:"contain"},onError:S=>{S.currentTarget.style.display="none"}})}),d.name]},d.id)),i&&on()&&e.jsx(Di,{paperId:r.id,paperTitle:r.title,onComplete:()=>void b()}),e.jsx(Fi,{paperId:r.id})]}),r.leaderboard_ranks&&r.leaderboard_ranks.length>0&&e.jsx(Ta,{wrap:!0,paperHref:`/paper/${r.arxiv_id||r.id}`,ranks:r.leaderboard_ranks.filter(d=>d.best_rank>=1&&d.best_rank<=3).map(d=>({name:d.dataset_name,slug:d.dataset_slug||null,rank:d.best_rank}))})]}),e.jsx("div",{className:"detail-hero-thumb detail-thumb-wrap",children:e.jsx(La,{paperId:r.arxiv_id||r.id,title:r.title,thumbnailUrl:Aa(r.thumbnail_url),priority:!0})})]}),Vr&&e.jsxs("div",{className:`introduced-banner${qe.length>0?" introduced-banner--framework":""}`,children:[e.jsx("span",{className:"introduced-label",children:"Introduced"}),e.jsxs("div",{className:"introduced-methods",children:[tt.map(d=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>a(`/methods/${d.slug||d.id}`),children:[d.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`method-${d.id}`)),st.map(d=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>a(`/benchmark/${d.slug||d.id}`),children:[d.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`benchmark-${d.id}`)),qe.map(d=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>a(`/frameworks#framework-${d.slug}`),children:[d.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`framework-${d.slug}`))]}),e.jsxs("span",{className:"introduced-note",children:["This paper is the canonical source for ",Xr,"."]})]}),Jr&&e.jsxs("div",{className:"introduced-banner lineage-banner",children:[at.length>0&&e.jsxs("div",{className:"lineage-row",children:[e.jsx("span",{className:"introduced-label lineage-label",children:at.length===1?"Follow-up paper":"Follow-up papers"}),e.jsx("div",{className:"introduced-methods",children:at.map(d=>e.jsxs("button",{type:"button",className:"introduced-pill lineage-pill",onClick:()=>a(`/paper/${d.route_identifier}`),children:[e.jsx(it,{title:d.title}),e.jsx("span",{className:"introduced-arrow",children:"→"})]},`successor-${d.id}`))})]}),rt.length>0&&e.jsxs("div",{className:"lineage-row",children:[e.jsx("span",{className:"introduced-label lineage-label",children:rt.length===1?"Predecessor paper":"Predecessor papers"}),e.jsx("div",{className:"introduced-methods",children:rt.map(d=>e.jsxs("button",{type:"button",className:"introduced-pill lineage-pill",onClick:()=>a(`/paper/${d.route_identifier}`),children:[e.jsx("span",{className:"introduced-arrow lineage-arrow-back",children:"←"}),e.jsx(it,{title:d.title})]},`predecessor-${d.id}`))})]})]}),os&&e.jsxs(e.Fragment,{children:[e.jsx(Ge,{id:"tldr",label:"TL;DR · AI-generated"}),e.jsx("div",{className:"tldr-box",children:os})]}),e.jsx(Ge,{id:"abstract",label:"Abstract"}),e.jsx("p",{className:"abstract-text",style:{marginBottom:8},children:e.jsx(Oa,{text:Qr})}),$e.length>dt&&e.jsx("div",{className:"read-full",onClick:()=>Q(d=>!d),children:z?"− collapse abstract":"+ read full abstract"}),e.jsx(Ge,{id:"tasks",label:"Tasks",accent:e.jsxs("span",{className:"accent",children:[((ps=r.tasks)==null?void 0:ps.length)||0," tagged",e.jsx("button",{type:"button",onClick:()=>ie("tasks"),className:"edit-link",children:"edit"})]})}),e.jsx("div",{className:"paper-tags",style:{marginBottom:8},children:(r.tasks||[]).map(d=>e.jsx(Ma,{slug:d.slug||"",label:d.name},d.id))}),e.jsx(Ge,{id:"methods",label:"Methods",accent:e.jsxs("span",{className:"accent",children:[((hs=r.methods)==null?void 0:hs.length)||0," used",e.jsx("button",{type:"button",onClick:()=>ie("methods"),className:"edit-link",children:"edit"})]})}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:8},children:(r.methods||[]).map(d=>e.jsx(Da,{method:d},d.id))}),e.jsx(Ge,{id:"results",label:"Results",accent:e.jsxs("span",{className:"accent",children:[(U==null?void 0:U.length)||0," benchmarks",as.length>0&&e.jsxs("button",{type:"button",className:"edit-link results-badge-copy",onClick:Kr,title:"Copy live leaderboard badges for your repository README",children:[e.jsx(Z,{name:"copy",size:10})," Copy PwC badge"]}),i&&ln()&&e.jsx(Mi,{paperId:r.id,paperTitle:r.title,onComplete:()=>void D()}),e.jsx("button",{type:"button",onClick:()=>ie("results"),className:"edit-link",children:"edit"})]})}),L?e.jsx(Qe,{className:"h-32 w-full"}):j.length>0?j.map(d=>e.jsxs("div",{className:d.taskSlug?"paper-section-anchor":void 0,id:d.taskSlug?Rs(d.taskSlug):void 0,children:[e.jsxs("div",{className:"section-rule",children:[e.jsx("span",{children:d.taskSlug?e.jsxs(e.Fragment,{children:[e.jsx(he,{to:`/tasks/${d.taskSlug}`,children:d.taskName}),e.jsx("a",{href:no(d.taskSlug),className:"section-anchor-link results-task-permalink","aria-label":`Permalink to ${d.taskName} results on this paper`,title:"Link to this task's results",children:"#"})]}):d.taskName}),e.jsxs("span",{className:"accent",children:[d.rows.length," ",d.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:d.rows.map(S=>{var G;return e.jsxs("tr",{children:[e.jsx("td",{className:"benchmark",children:S.dataset_slug?e.jsx(he,{to:`/benchmark/${S.dataset_slug}`,children:S.dataset_name||"—"}):S.dataset_name||"—"}),e.jsxs("td",{className:"model",title:S.model_name||void 0,children:[S.hf_model_url?e.jsx("a",{href:S.hf_model_url,target:"_blank",rel:"noopener noreferrer",className:"model-hf-link",title:`Open ${S.model_name||"model"} on Hugging Face`,children:S.model_name||"—"}):S.model_name||"—",S.is_open===!1&&e.jsx(Ua,{}),(S.external??S.is_external)&&e.jsx(Ba,{sourceUrl:S.source_url||S.external_source_url||S.result_url})]}),e.jsx("td",{className:"metric",children:S.best_metric}),e.jsx("td",{className:"value",children:$a((G=S.metrics)==null?void 0:G[S.best_metric||""])}),e.jsx("td",{className:"rank",children:S.best_rank!=null?`#${S.best_rank}`:"—"}),e.jsx("td",{className:"compare",children:S.dataset_slug&&e.jsx(he,{to:`/benchmark/${S.dataset_slug}?${[S.task_slug?`task=${encodeURIComponent(S.task_slug)}`:"",`eval=${encodeURIComponent(S.id)}`].filter(Boolean).join("&")}`,children:"Compare →"})})]},S.id)})})]})]},d.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:[pe.length," repo",pe.length===1?"":"s",e.jsx("button",{type:"button",onClick:()=>ie("repositories"),className:"edit-link",children:"edit"})]})]}),zr.map(d=>e.jsxs("a",{href:d.url,target:"_blank",rel:"noopener noreferrer",className:"code-line",style:{textDecoration:"none"},children:[e.jsxs("span",{className:"code-line-repo",children:[e.jsx(Z,{name:"github",size:12}),e.jsxs("span",{className:"code-line-repo-name",children:[d.owner,"/",d.name]}),d.is_official&&e.jsx("span",{className:"code-line-official",children:"· Official"})]}),e.jsxs("span",{className:"code-line-stars",children:["★ ",As(d.num_stars)]})]},d.id)),pe.length===0&&e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--ink-faint)",padding:"6px 0"},children:"No GitHub repositories linked yet."}),pe.length>$t&&e.jsx("button",{type:"button",className:"bench-show-more",onClick:()=>M(d=>!d),children:A?"− show top 3":`+ show ${pe.length-$t} more repos`})]}),e.jsx(io,{viewer:wt}),e.jsx(eo,{githubUrls:pe.map(d=>d.url),hfModelUrls:yt.models,hfDatasetUrls:yt.datasets,hfSpaceUrls:yt.spaces,suggestedBucketId:n?`${n.username}/${Zi(r.title)}`:void 0}),H.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…"})]}),!H.isLoading&&(((fs=H.data)==null?void 0:fs.length)??0)>0&&e.jsxs("div",{className:"sidebar-card",children:[e.jsx("div",{className:"sidebar-card-title",children:"Related papers"}),H.data.map(d=>e.jsxs(he,{to:`/paper/${d.arxiv_id||d.id}`,target:"_blank",rel:"noopener noreferrer",className:"related-paper",style:{textDecoration:"none",color:"inherit"},children:[e.jsx("div",{className:"related-title",children:e.jsx(it,{title:d.title})}),e.jsxs("div",{className:"related-meta",children:[e.jsx("span",{children:d.arxiv_id?`arXiv:${d.arxiv_id}`:"External resource"}),d.citation_count!=null&&e.jsxs("span",{children:[d.citation_count.toLocaleString()," cites"]})]})]},d.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:qr,"aria-label":"Copy citation to clipboard",title:"Copy citation to clipboard",children:[e.jsx(Z,{name:"copy",size:11}),Hr?"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:Or})]})]})]}),e.jsx(En,{open:$,onOpenChange:ee,paperId:r.id,arxivId:s,initialTaskIds:((gs=r.tasks)==null?void 0:gs.map(d=>parseInt(d.id)))||[],initialTasks:r.tasks||[],submitMode:Ae,isAuthor:Ie}),e.jsx(Rn,{open:k,onOpenChange:_,paperId:r.id,arxivId:s,initialMethodIds:((xs=r.methods)==null?void 0:xs.map(d=>parseInt(d.id)))||[],initialMethods:r.methods||[],submitMode:Ae,isAuthor:Ie}),e.jsx(In,{open:m,onOpenChange:h,paperId:r.id,arxivId:s,initialRepositories:((vs=r.repositories)==null?void 0:vs.map(d=>({url:d.url,is_official:d.is_official||!1})))||[],submitMode:Ae,isAuthor:Ie}),e.jsx(An,{open:x,onOpenChange:C,paperId:r.id,arxivId:s,initialProjectPages:((bs=r.project_pages)==null?void 0:bs.map(d=>({url:d.url,is_official:d.is_official||!1})))||[],submitMode:Ae,isAuthor:Ie}),e.jsx(Ii,{open:R,onOpenChange:q,paperId:r.id,arxivId:s,initialEvaluations:T||[],paperTasks:r.tasks||[],submitMode:Ae,isAuthor:Ie}),e.jsx($n,{open:V,onOpenChange:W,paperId:r.id,arxivId:s,initialUrl:r.source_url??r.url_abs??"",submitMode:Ae,isAuthor:Ie}),e.jsx(Ya,{open:me!==null,onOpenChange:d=>{d||Jt(null)},sectionLabel:me?to[me]:"this paper",returnTo:typeof window<"u"?window.location.pathname:"/"})]})},io=({viewer:t})=>e.jsxs("div",{className:"sidebar-card",children:[e.jsx("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"})}),t.isLoading?e.jsx(Qe,{className:"h-16 w-full"}):e.jsxs(e.Fragment,{children:[t.rows.map(s=>e.jsx(oo,{...s},s.label)),t.footer&&e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink-faint)",marginTop:12},children:t.footer})]})]}),oo=({label:t,href:s,count:a,isLimited:c,links:n})=>{const i=((n==null?void 0:n.length)??0)>0,l=a!=null?`${a}${c?"+":""}`:"—",u=a?e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"hf-artifact-count",children:l}):e.jsx("span",{className:"hf-artifact-count hf-artifact-count--empty",children:l});return e.jsxs("div",{className:"hf-artifact-row",children:[e.jsxs("div",{className:"hf-artifact-row-header",children:[e.jsx("span",{children:t}),u]}),i&&e.jsx("div",{className:"hf-artifact-links",children:n.map(r=>e.jsx("a",{href:r.href,target:"_blank",rel:"noopener noreferrer",children:r.label},r.href))})]})};function Ft(t){return t[0]??"https://huggingface.co"}function Tt(t,s){return s[0]??t}function Lt(t,s,a){if(a==null&&t.length===0&&!(s!=null&&s.length))return;const c=new Set([...t,...s??[]]);return Math.max(a??0,c.size)}export{$o as default};