diff --git "a/assets/PaperDetailView-BBf2E08f.js" "b/assets/PaperDetailView-BBf2E08f.js" new file mode 100644--- /dev/null +++ "b/assets/PaperDetailView-BBf2E08f.js" @@ -0,0 +1,51 @@ +import{c as Se,r as i,j as e,P as Le,a as J,b as Nt,d as Re,e as ee,f as zr,g as wt,C as ce,h as Y,i as ke,k as oe,l as bs,m as _s,R as Ns,n as ws,F as ks,D as Cs,o as Qr,X as kt,p as xe,q as ve,s as Vr,A as Es,t as Ss,v as Wr,w as Gr,H as Xr,x as rt,y as Ct,z as Rs,B as Ps,E as Jr,G as Yr,L as De,I as Zr,J as ea,K as ta,M as sa,N as ra}from"./index-C6O8_a1-.js";import{u as le}from"./useQuery-Cvv958Kx.js";import{I as re,T as aa,M as na}from"./components-CMH89RDy.js";import{L as cs,a as ia}from"./LatexTitle-CcMIi9G1.js";import{g as oa,s as Pe,u as la,b as As,c as ca,d as da,e as ua,f as ma,h as pa,i as ds,j as fa,k as ha,l as ga,m as xa,n as va,a as tt,o as ya}from"./api-DLAvdHPg.js";import{e as ja}from"./transform-D_Izdf89.js";import{b as ba}from"./usePapers-CwnyeI7c.js";import{S as qe}from"./skeleton-D8Wtx_Nu.js";import{A as _a,a as Na}from"./alert-MNWNJkBv.js";import{I as ie,B as W}from"./input-BMdkOI2Z.js";import{u as ye}from"./useMutation-DLRmDXLC.js";import{L as ae}from"./loader-circle-DK8Ui2RE.js";import{B as Is,D as wa}from"./badge-CcpUgrz3.js";import"./adminAuth-PI_XkM8E.js";import"./useInfiniteQuery-Dd12EyZd.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 ka=Se("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 us=Se("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @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 ms=Se("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 at=Se("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @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 Be=Se("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 Ds=Se("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 nt=Se("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 Ca(t,s=!0){return le({queryKey:["evaluations","paper",t],queryFn:()=>{if(!t)throw new Error("Paper ID is required");return oa(t)},enabled:s&&!!t,staleTime:5*60*1e3})}const mt=async(t,s)=>{try{const r=await fetch(`https://huggingface.co/api/arxiv/${s}/repos`);if(!r.ok)return console.warn(`Failed to fetch repos for arXiv:${s}, status: ${r.status}`),{count:0,isLimited:!1};const n=((await r.json())[t]||[]).length;return console.log(`${t} count for arXiv:${s}: ${n}`),n<100?{count:n,isLimited:!1}:{count:n,isLimited:!0}}catch(r){return console.warn(`Failed to fetch ${t} count for arXiv:${s}:`,r),{count:0,isLimited:!1}}},Ea=async t=>{const[s,r,c]=await Promise.all([mt("models",t),mt("datasets",t),mt("spaces",t)]);return{models:s.count,datasets:r.count,spaces:c.count,isLimited:s.isLimited||r.isLimited||c.isLimited}},Sa=t=>le({queryKey:["huggingface-repos",t],queryFn:()=>Ea(t),enabled:!!t,staleTime:10*60*1e3,retry:1});function Ra(){const[t,s]=i.useState(!1),[r,c]=i.useState(!1),[n,o]=i.useState(!1),[l,a]=i.useState(!1),[p,m]=i.useState(!1),[b,v]=i.useState(!1),[S,w]=i.useState(!1);return{isEditingTasks:t,openTasksDialog:()=>s(!0),closeTasksDialog:()=>s(!1),setIsEditingTasks:s,isEditingMethods:r,openMethodsDialog:()=>c(!0),closeMethodsDialog:()=>c(!1),setIsEditingMethods:c,isEditingRepositories:n,openRepositoriesDialog:()=>o(!0),closeRepositoriesDialog:()=>o(!1),setIsEditingRepositories:o,isEditingProjectPages:l,openProjectPagesDialog:()=>a(!0),closeProjectPagesDialog:()=>a(!1),setIsEditingProjectPages:a,isEditingEvaluations:p,openEvaluationsDialog:()=>m(!0),closeEvaluationsDialog:()=>m(!1),setIsEditingEvaluations:m,isEditingSourceUrl:b,openSourceUrlDialog:()=>v(!0),closeSourceUrlDialog:()=>v(!1),setIsEditingSourceUrl:v,isEditingHfArtifacts:S,openHfArtifactsDialog:()=>w(!0),closeHfArtifactsDialog:()=>w(!1),setIsEditingHfArtifacts:w}}function Pa(t){const s=i.useRef({value:t,previous:t});return i.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var it="Checkbox",[Aa]=wt(it),[Ia,Et]=Aa(it);function Da(t){const{__scopeCheckbox:s,checked:r,children:c,defaultChecked:n,disabled:o,form:l,name:a,onCheckedChange:p,required:m,value:b="on",internal_do_not_use_render:v}=t,[S,w]=Nt({prop:r,defaultProp:n??!1,onChange:p,caller:it}),[F,I]=i.useState(null),[O,k]=i.useState(null),A=i.useRef(!1),U=F?!!l||!!F.closest("form"):!0,T={checked:S,disabled:o,setChecked:w,control:F,setControl:I,name:a,form:l,value:b,hasConsumerStoppedPropagationRef:A,required:m,defaultChecked:he(n)?!1:n,isFormControl:U,bubbleInput:O,setBubbleInput:k};return e.jsx(Ia,{scope:s,...T,children:Fa(v)?v(T):c})}var Fs="CheckboxTrigger",Ts=i.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...c},n)=>{const{control:o,value:l,disabled:a,checked:p,required:m,setControl:b,setChecked:v,hasConsumerStoppedPropagationRef:S,isFormControl:w,bubbleInput:F}=Et(Fs,t),I=Re(n,b),O=i.useRef(p);return i.useEffect(()=>{const k=o==null?void 0:o.form;if(k){const A=()=>v(O.current);return k.addEventListener("reset",A),()=>k.removeEventListener("reset",A)}},[o,v]),e.jsx(J.button,{type:"button",role:"checkbox","aria-checked":he(p)?"mixed":p,"aria-required":m,"data-state":Us(p),"data-disabled":a?"":void 0,disabled:a,value:l,...c,ref:I,onKeyDown:ee(s,k=>{k.key==="Enter"&&k.preventDefault()}),onClick:ee(r,k=>{v(A=>he(A)?!0:!A),F&&w&&(S.current=k.isPropagationStopped(),S.current||k.stopPropagation())})})});Ts.displayName=Fs;var St=i.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:c,checked:n,defaultChecked:o,required:l,disabled:a,value:p,onCheckedChange:m,form:b,...v}=t;return e.jsx(Da,{__scopeCheckbox:r,checked:n,defaultChecked:o,disabled:a,required:l,onCheckedChange:m,name:c,form:b,value:p,internal_do_not_use_render:({isFormControl:S})=>e.jsxs(e.Fragment,{children:[e.jsx(Ts,{...v,ref:s,__scopeCheckbox:r}),S&&e.jsx(Os,{__scopeCheckbox:r})]})})});St.displayName=it;var $s="CheckboxIndicator",Ms=i.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:c,...n}=t,o=Et($s,r);return e.jsx(Le,{present:c||he(o.checked)||o.checked===!0,children:e.jsx(J.span,{"data-state":Us(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:s,style:{pointerEvents:"none",...t.style}})})});Ms.displayName=$s;var Ls="CheckboxBubbleInput",Os=i.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:c,hasConsumerStoppedPropagationRef:n,checked:o,defaultChecked:l,required:a,disabled:p,name:m,value:b,form:v,bubbleInput:S,setBubbleInput:w}=Et(Ls,t),F=Re(r,w),I=Pa(o),O=zr(c);i.useEffect(()=>{const A=S;if(!A)return;const U=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(U,"checked").set,d=!n.current;if(I!==o&&_){const g=new Event("click",{bubbles:d});A.indeterminate=he(o),_.call(A,he(o)?!1:o),A.dispatchEvent(g)}},[S,I,o,n]);const k=i.useRef(he(o)?!1:o);return e.jsx(J.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??k.current,required:a,disabled:p,name:m,value:b,form:v,...s,tabIndex:-1,ref:F,style:{...s.style,...O,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Os.displayName=Ls;function Fa(t){return typeof t=="function"}function he(t){return t==="indeterminate"}function Us(t){return he(t)?"indeterminate":t?"checked":"unchecked"}const Rt=i.forwardRef(({className:t,style:s,...r},c)=>e.jsx(St,{ref:c,className:Y("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},...r,children:e.jsx(Ms,{className:Y("flex items-center justify-center text-current"),children:e.jsx(ce,{className:"h-4 w-4"})})}));Rt.displayName=St.displayName;function Ta(t){const s=$a(t),r=i.forwardRef((c,n)=>{const{children:o,...l}=c,a=i.Children.toArray(o),p=a.find(La);if(p){const m=p.props.children,b=a.map(v=>v===p?i.Children.count(m)>1?i.Children.only(null):i.isValidElement(m)?m.props.children:null:v);return e.jsx(s,{...l,ref:n,children:i.isValidElement(m)?i.cloneElement(m,void 0,b):null})}return e.jsx(s,{...l,ref:n,children:o})});return r.displayName=`${t}.Slot`,r}function $a(t){const s=i.forwardRef((r,c)=>{const{children:n,...o}=r;if(i.isValidElement(n)){const l=Ua(n),a=Oa(o,n.props);return n.type!==i.Fragment&&(a.ref=c?ke(c,l):l),i.cloneElement(n,a)}return i.Children.count(n)>1?i.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var Ma=Symbol("radix.slottable");function La(t){return i.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Ma}function Oa(t,s){const r={...s};for(const c in s){const n=t[c],o=s[c];/^on[A-Z]/.test(c)?n&&o?r[c]=(...a)=>{const p=o(...a);return n(...a),p}:n&&(r[c]=n):c==="style"?r[c]={...n,...o}:c==="className"&&(r[c]=[n,o].filter(Boolean).join(" "))}return{...t,...r}}function Ua(t){var c,n;let s=(c=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:c.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?t.ref:(s=(n=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:n.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var ot="Dialog",[Hs]=wt(ot),[Ha,ne]=Hs(ot),qs=t=>{const{__scopeDialog:s,children:r,open:c,defaultOpen:n,onOpenChange:o,modal:l=!0}=t,a=i.useRef(null),p=i.useRef(null),[m,b]=Nt({prop:c,defaultProp:n??!1,onChange:o,caller:ot});return e.jsx(Ha,{scope:s,triggerRef:a,contentRef:p,contentId:oe(),titleId:oe(),descriptionId:oe(),open:m,onOpenChange:b,onOpenToggle:i.useCallback(()=>b(v=>!v),[b]),modal:l,children:r})};qs.displayName=ot;var Bs="DialogTrigger",qa=i.forwardRef((t,s)=>{const{__scopeDialog:r,...c}=t,n=ne(Bs,r),o=Re(s,n.triggerRef);return e.jsx(J.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":It(n.open),...c,ref:o,onClick:ee(t.onClick,n.onOpenToggle)})});qa.displayName=Bs;var Pt="DialogPortal",[Ba,Ks]=Hs(Pt,{forceMount:void 0}),zs=t=>{const{__scopeDialog:s,forceMount:r,children:c,container:n}=t,o=ne(Pt,s);return e.jsx(Ba,{scope:s,forceMount:r,children:i.Children.map(c,l=>e.jsx(Le,{present:r||o.open,children:e.jsx(bs,{asChild:!0,container:n,children:l})}))})};zs.displayName=Pt;var st="DialogOverlay",Qs=i.forwardRef((t,s)=>{const r=Ks(st,t.__scopeDialog),{forceMount:c=r.forceMount,...n}=t,o=ne(st,t.__scopeDialog);return o.modal?e.jsx(Le,{present:c||o.open,children:e.jsx(za,{...n,ref:s})}):null});Qs.displayName=st;var Ka=Ta("DialogOverlay.RemoveScroll"),za=i.forwardRef((t,s)=>{const{__scopeDialog:r,...c}=t,n=ne(st,r);return e.jsx(Ns,{as:Ka,allowPinchZoom:!0,shards:[n.contentRef],children:e.jsx(J.div,{"data-state":It(n.open),...c,ref:s,style:{pointerEvents:"auto",...c.style}})})}),Ce="DialogContent",Vs=i.forwardRef((t,s)=>{const r=Ks(Ce,t.__scopeDialog),{forceMount:c=r.forceMount,...n}=t,o=ne(Ce,t.__scopeDialog);return e.jsx(Le,{present:c||o.open,children:o.modal?e.jsx(Qa,{...n,ref:s}):e.jsx(Va,{...n,ref:s})})});Vs.displayName=Ce;var Qa=i.forwardRef((t,s)=>{const r=ne(Ce,t.__scopeDialog),c=i.useRef(null),n=Re(s,r.contentRef,c);return i.useEffect(()=>{const o=c.current;if(o)return _s(o)},[]),e.jsx(Ws,{...t,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ee(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:ee(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,a=l.button===0&&l.ctrlKey===!0;(l.button===2||a)&&o.preventDefault()}),onFocusOutside:ee(t.onFocusOutside,o=>o.preventDefault())})}),Va=i.forwardRef((t,s)=>{const r=ne(Ce,t.__scopeDialog),c=i.useRef(!1),n=i.useRef(!1);return e.jsx(Ws,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,a;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(c.current||(a=r.triggerRef.current)==null||a.focus(),o.preventDefault()),c.current=!1,n.current=!1},onInteractOutside:o=>{var p,m;(p=t.onInteractOutside)==null||p.call(t,o),o.defaultPrevented||(c.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const l=o.target;((m=r.triggerRef.current)==null?void 0:m.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),Ws=i.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:c,onOpenAutoFocus:n,onCloseAutoFocus:o,...l}=t,a=ne(Ce,r),p=i.useRef(null),m=Re(s,p);return ws(),e.jsxs(e.Fragment,{children:[e.jsx(ks,{asChild:!0,loop:!0,trapped:c,onMountAutoFocus:n,onUnmountAutoFocus:o,children:e.jsx(Cs,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":It(a.open),...l,ref:m,onDismiss:()=>a.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(Wa,{titleId:a.titleId}),e.jsx(Xa,{contentRef:p,descriptionId:a.descriptionId})]})]})}),At="DialogTitle",Gs=i.forwardRef((t,s)=>{const{__scopeDialog:r,...c}=t,n=ne(At,r);return e.jsx(J.h2,{id:n.titleId,...c,ref:s})});Gs.displayName=At;var Xs="DialogDescription",Js=i.forwardRef((t,s)=>{const{__scopeDialog:r,...c}=t,n=ne(Xs,r);return e.jsx(J.p,{id:n.descriptionId,...c,ref:s})});Js.displayName=Xs;var Ys="DialogClose",Zs=i.forwardRef((t,s)=>{const{__scopeDialog:r,...c}=t,n=ne(Ys,r);return e.jsx(J.button,{type:"button",...c,ref:s,onClick:ee(t.onClick,()=>n.onOpenChange(!1))})});Zs.displayName=Ys;function It(t){return t?"open":"closed"}var er="DialogTitleWarning",[Ai,tr]=Qr(er,{contentName:Ce,titleName:At,docsSlug:"dialog"}),Wa=({titleId:t})=>{const s=tr(er),r=`\`${s.contentName}\` requires a \`${s.titleName}\` for the component to be accessible for screen reader users. + +If you want to hide the \`${s.titleName}\`, you can wrap it with our VisuallyHidden component. + +For more information, see https://radix-ui.com/primitives/docs/components/${s.docsSlug}`;return i.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},Ga="DialogDescriptionWarning",Xa=({contentRef:t,descriptionId:s})=>{const c=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${tr(Ga).contentName}}.`;return i.useEffect(()=>{var o;const n=(o=t.current)==null?void 0:o.getAttribute("aria-describedby");s&&n&&(document.getElementById(s)||console.warn(c))},[c,t,s]),null},sr=qs,rr=zs,Dt=Qs,Ft=Vs,ar=Gs,nr=Js,Ja=Zs;const je=sr,Ya=rr,ir=i.forwardRef(({className:t,...s},r)=>e.jsx(Dt,{ref:r,className:Y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));ir.displayName=Dt.displayName;const de=i.forwardRef(({className:t,children:s,...r},c)=>e.jsxs(Ya,{children:[e.jsx(ir,{}),e.jsxs(Ft,{ref:c,className:Y("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...r,children:[s,e.jsxs(Ja,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(kt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));de.displayName=Ft.displayName;const ue=({className:t,...s})=>e.jsx("div",{className:Y("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});ue.displayName="DialogHeader";const be=({className:t,...s})=>e.jsx("div",{className:Y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});be.displayName="DialogFooter";const me=i.forwardRef(({className:t,...s},r)=>e.jsx(ar,{ref:r,className:Y("text-lg font-semibold leading-none tracking-tight",t),...s}));me.displayName=ar.displayName;const pe=i.forwardRef(({className:t,...s},r)=>e.jsx(nr,{ref:r,className:Y("text-sm text-muted-foreground",t),...s}));pe.displayName=nr.displayName;function Za(t,s,r){if(!t)return t;const c=n=>n.paper_id!==s||n.paper_title===r?n:{...n,paper_title:r};if(Array.isArray(t)){const n=t.map(c);return n.some((l,a)=>l!==t[a])?n:t}if(Array.isArray(t.results)){const n=t.results.map(c);return n.some((l,a)=>l!==t.results[a])?{...t,results:n}:t}return t}function Oe(t,s,r){new Set([...r,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),o=l=>Za(l,n,s.title);t.setQueriesData({queryKey:["evaluations"]},o),t.setQueriesData({queryKey:["dataset-evals"]},o),t.invalidateQueries({queryKey:["evaluations"],refetchType:"none"}),t.invalidateQueries({queryKey:["dataset-evals"],refetchType:"none"})}function Ae({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 en=250,tn=100;function sn({open:t,onOpenChange:s,paperId:r,arxivId:c,initialTaskIds:n,initialTasks:o,onSuccess:l,submitMode:a="direct",isAuthor:p=!1}){const[m,b]=i.useState(n),[v,S]=i.useState(""),[w,F]=i.useState(""),[I,O]=i.useState(new Map),k=xe(),{toast:A}=ve(),U=i.useRef(!1);i.useEffect(()=>{if(!t){U.current=!1;return}if(U.current)return;U.current=!0,b(n),S(""),F("");const j=new Map;(o||[]).forEach(C=>{const R=parseInt(C.id);Number.isNaN(R)||j.set(R,C)}),O(j)},[t,n,o]),i.useEffect(()=>{const j=window.setTimeout(()=>{F(v.trim())},en);return()=>window.clearTimeout(j)},[v]);const{data:T,isFetching:_}=le({queryKey:["tasks-search",w],queryFn:()=>As({page_size:tn,visible_only:!0,...w?{q:w}:{}}),enabled:t});i.useEffect(()=>{var j;(j=T==null?void 0:T.results)!=null&&j.length&&O(C=>{const R=new Map(C);return T.results.forEach(f=>{const h=parseInt(f.id);Number.isNaN(h)||R.set(h,f)}),R})},[T]);const d=i.useMemo(()=>{const j=(T==null?void 0:T.results)||[],C=new Set,R=[];return m.forEach(f=>{if(C.has(f))return;const h=I.get(f);h&&(R.push(h),C.add(f))}),j.forEach(f=>{const h=parseInt(f.id);Number.isNaN(h)||C.has(h)||(R.push(f),C.add(h))}),R},[T,m,I]),g=ye({mutationFn:async({paperId:j,taskIds:C})=>a==="pending"?(await Pe({paper_id:parseInt(j),edit_type:"tasks",proposed_payload:{task_ids:C}}),null):la(j,C),onMutate:async({taskIds:j})=>{if(a==="pending")return{snapshots:[]};const C=j.map(h=>I.get(h)).filter(h=>!!h).map(h=>({id:h.id,name:h.name,slug:h.slug})).sort((h,E)=>h.name.localeCompare(E.name)),R=Array.from(new Set([r,c].filter(h=>!!h)));await Promise.all(R.flatMap(h=>[k.cancelQueries({queryKey:["paper",h]}),k.cancelQueries({queryKey:["paper-arxiv",h]})]));const f=[];return R.forEach(h=>{["paper","paper-arxiv"].forEach(E=>{const N=[E,h],y=k.getQueryData(N);f.push({key:N,data:y}),y&&k.setQueryData(N,{...y,tasks:C})})}),A({title:"Tasks updated",description:`Saved ${j.length} task${j.length===1?"":"s"} for this paper.`}),l==null||l(),s(!1),{snapshots:f}},onSuccess:j=>{if(a==="pending"){A({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed task changes shortly."}),l==null||l(),s(!1);return}j&&Oe(k,j,[r,c])},onError:(j,C,R)=>{var E,N;(E=R==null?void 0:R.snapshots)==null||E.forEach(({key:y,data:z})=>{k.setQueryData(y,z)});const f=j;let h=f.message||(a==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper tasks.");if(f.response)try{const y=JSON.parse(f.response);typeof(y==null?void 0:y.detail)=="string"?h=y.detail:Array.isArray(y==null?void 0:y.detail)&&((N=y.detail[0])!=null&&N.msg)&&(h=y.detail[0].msg)}catch{h=f.response}A({title:a==="pending"?"Could not submit edit":"Could not save tasks",description:h,variant:"destructive"})}}),$=()=>{g.mutate({paperId:r,taskIds:m})},L=i.useMemo(()=>{if(m.length!==n.length)return!0;const j=new Set(n);return m.some(C=>!j.has(C))},[m,n]),H=(j,C)=>{b(R=>C?R.includes(j)?R:[...R,j]:R.filter(f=>f!==j))},te=()=>S("");return e.jsx(je,{open:t,onOpenChange:s,children:e.jsxs(de,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ue,{children:[e.jsx(me,{children:"Edit Paper Tasks"}),e.jsx(pe,{children:"Select the tasks that this paper addresses. You can select multiple tasks."})]}),a==="pending"&&e.jsx(Ae,{isAuthor:p}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Be,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ie,{type:"text",placeholder:"Search tasks...",value:v,onChange:j=>S(j.target.value),className:"pl-9 pr-9"}),v&&e.jsx("button",{type:"button",onClick:te,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(kt,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[400px]",children:d.length>0?e.jsx("div",{className:"space-y-2",children:d.map(j=>{const C=parseInt(j.id),R=m.includes(C);return e.jsxs("div",{className:"flex items-center space-x-2 p-2 hover:bg-muted/50 rounded-md",children:[e.jsx(Rt,{id:`task-${j.id}`,checked:R,onCheckedChange:f=>H(C,f===!0),className:"!border !border-black data-[state=checked]:!bg-black data-[state=checked]:!text-white"}),e.jsxs("label",{htmlFor:`task-${j.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[j.name,j.description&&e.jsxs("span",{className:"block text-xs text-muted-foreground font-normal mt-1",children:[j.description.substring(0,100),j.description.length>100?"...":""]})]})]},j.id)})}):_?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ae,{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(Be,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:w?`No tasks found matching "${w}"`:"No tasks available"})]})}),e.jsxs(be,{children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(W,{onClick:$,disabled:g.isPending||!L,children:g.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-2 animate-spin"}),a==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2"}),a==="pending"?"Submit for review":"Save Changes"]})})]})]})})}const rn=250,an=100;function nn({open:t,onOpenChange:s,paperId:r,arxivId:c,initialMethodIds:n,initialMethods:o,onSuccess:l,submitMode:a="direct",isAuthor:p=!1}){const[m,b]=i.useState(n),[v,S]=i.useState(""),[w,F]=i.useState(""),[I,O]=i.useState(new Map),k=xe(),{toast:A}=ve(),U=i.useRef(!1);i.useEffect(()=>{if(!t){U.current=!1;return}if(U.current)return;U.current=!0,b(n),S(""),F("");const j=new Map;(o||[]).forEach(C=>{const R=parseInt(C.id);Number.isNaN(R)||j.set(R,C)}),O(j)},[t,n,o]),i.useEffect(()=>{const j=window.setTimeout(()=>{F(v.trim())},rn);return()=>window.clearTimeout(j)},[v]);const{data:T,isFetching:_}=le({queryKey:["methods-search",w],queryFn:()=>da({page_size:an,...w?{q:w}:{}}),enabled:t});i.useEffect(()=>{var j;(j=T==null?void 0:T.results)!=null&&j.length&&O(C=>{const R=new Map(C);return T.results.forEach(f=>{const h=parseInt(f.id);Number.isNaN(h)||R.set(h,f)}),R})},[T]);const d=i.useMemo(()=>{const j=(T==null?void 0:T.results)||[],C=new Set,R=[];return m.forEach(f=>{if(C.has(f))return;const h=I.get(f);h&&(R.push(h),C.add(f))}),j.forEach(f=>{const h=parseInt(f.id);Number.isNaN(h)||C.has(h)||(R.push(f),C.add(h))}),R},[T,m,I]),g=ye({mutationFn:async({paperId:j,methodIds:C})=>a==="pending"?(await Pe({paper_id:parseInt(j),edit_type:"methods",proposed_payload:{method_ids:C}}),null):ca(j,C),onSuccess:j=>{if(a==="pending"){A({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed method changes shortly."}),l==null||l(),s(!1);return}j&&Oe(k,j,[r,c]),A({title:"Methods updated",description:`Saved ${m.length} method${m.length===1?"":"s"} for this paper.`}),l==null||l(),s(!1)},onError:j=>{var f;const C=j;let R=C.message||(a==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper methods.");if(C.response)try{const h=JSON.parse(C.response);typeof(h==null?void 0:h.detail)=="string"?R=h.detail:Array.isArray(h==null?void 0:h.detail)&&((f=h.detail[0])!=null&&f.msg)&&(R=h.detail[0].msg)}catch{R=C.response}A({title:a==="pending"?"Could not submit edit":"Could not save methods",description:R,variant:"destructive"})}}),$=()=>{g.mutate({paperId:r,methodIds:m})},L=i.useMemo(()=>{if(m.length!==n.length)return!0;const j=new Set(n);return m.some(C=>!j.has(C))},[m,n]),H=(j,C)=>{b(R=>C?R.includes(j)?R:[...R,j]:R.filter(f=>f!==j))},te=()=>S("");return e.jsx(je,{open:t,onOpenChange:s,children:e.jsxs(de,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ue,{children:[e.jsx(me,{children:"Edit Paper Methods"}),e.jsx(pe,{children:"Select the methods and techniques used in this paper. You can select multiple methods."})]}),a==="pending"&&e.jsx(Ae,{isAuthor:p}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Be,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ie,{type:"text",placeholder:"Search methods...",value:v,onChange:j=>S(j.target.value),className:"pl-9 pr-9"}),v&&e.jsx("button",{type:"button",onClick:te,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(kt,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[400px]",children:d.length>0?e.jsx("div",{className:"space-y-2",children:d.map(j=>{const C=parseInt(j.id),R=m.includes(C);return e.jsxs("div",{className:"flex items-center space-x-2 p-2 hover:bg-muted/50 rounded-md",children:[e.jsx(Rt,{id:`method-${j.id}`,checked:R,onCheckedChange:f=>H(C,f===!0),className:"!border !border-black data-[state=checked]:!bg-black data-[state=checked]:!text-white"}),e.jsxs("label",{htmlFor:`method-${j.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[j.name,j.full_name&&j.full_name!==j.name&&e.jsx("span",{className:"block text-xs text-muted-foreground font-normal",children:j.full_name}),j.description&&e.jsxs("span",{className:"block text-xs text-muted-foreground font-normal mt-1",children:[j.description.substring(0,100),j.description.length>100?"...":""]})]})]},j.id)})}):_?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ae,{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(Be,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:w?`No methods found matching "${w}"`:"No methods available"})]})}),e.jsxs(be,{children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(W,{onClick:$,disabled:g.isPending||!L,children:g.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-2 animate-spin"}),a==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2"}),a==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function on({open:t,onOpenChange:s,paperId:r,arxivId:c,initialRepositories:n,onSuccess:o,submitMode:l="direct",isAuthor:a=!1}){const[p,m]=i.useState(n),[b,v]=i.useState(""),S=xe(),{toast:w}=ve(),F=i.useRef(!1);i.useEffect(()=>{if(!t){F.current=!1;return}F.current||(F.current=!0,m(n),v(""))},[t,n]);const I=ye({mutationFn:async({paperId:d,repositories:g})=>l==="pending"?(await Pe({paper_id:parseInt(d),edit_type:"repositories",proposed_payload:{repositories:g}}),null):ua(d,g),onSuccess:d=>{if(l==="pending"){w({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed repository changes shortly."}),o==null||o(),s(!1),v("");return}d&&Oe(S,d,[r,c]),o==null||o(),s(!1),v("")},onError:d=>{var L;const g=d;let $=g.message||(l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper repositories.");if(g.response)try{const H=JSON.parse(g.response);typeof(H==null?void 0:H.detail)=="string"?$=H.detail:Array.isArray(H==null?void 0:H.detail)&&((L=H.detail[0])!=null&&L.msg)&&($=H.detail[0].msg)}catch{$=g.response}w({title:l==="pending"?"Could not submit edit":"Could not save repositories",description:$,variant:"destructive"})}}),O=()=>{const d=b.trim();return d?p.some(g=>g.url===d)?(alert("This repository URL is already added"),null):[...p,{url:d,is_official:!1}]:p},k=()=>{const d=O();d!==null&&d.length!==p.length&&(m(d),v(""))},A=d=>{m(p.filter(g=>g.url!==d))},U=d=>{m(p.map(g=>g.url===d?{...g,is_official:!g.is_official}:g))},T=()=>{const d=O();d!==null&&I.mutate({paperId:r,repositories:d})},_=i.useMemo(()=>{const d=b.trim(),g=d?[...p,{url:d,is_official:!1}]:p;if(g.length!==n.length)return!0;const $=new Map(n.map(L=>[L.url.trim(),!!L.is_official]));return g.some(L=>{const H=$.get(L.url.trim());return H===void 0||H!==!!L.is_official})},[p,b,n]);return e.jsx(je,{open:t,onOpenChange:s,children:e.jsxs(de,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ue,{children:[e.jsx(me,{children:"Edit Paper Repositories"}),e.jsx(pe,{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(Ae,{isAuthor:a}),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(ie,{type:"url",placeholder:"https://github.com/owner/repo",value:b,onChange:d=>v(d.target.value),onKeyPress:d=>{d.key==="Enter"&&(d.preventDefault(),k())},className:"flex-1"}),e.jsxs(W,{onClick:k,size:"sm",disabled:!b.trim(),children:[e.jsx(at,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[350px]",children:p.length>0?e.jsx("div",{className:"space-y-2",children:p.map((d,g)=>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(us,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("span",{className:"text-sm font-medium text-paper-blue truncate",children:d.url}),d.is_official&&e.jsx(Is,{variant:"secondary",className:"text-xs",children:"Official"})]})}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs(W,{variant:d.is_official?"default":"outline",size:"sm",onClick:()=>U(d.url),className:"h-8 px-2 text-xs",title:d.is_official?"Click to unmark as official (created by paper authors)":"Click to mark as official (created by paper authors)",children:[e.jsx(Ds,{className:`w-3.5 h-3.5 mr-1 ${d.is_official?"fill-current":""}`}),d.is_official?"Official":"Mark official"]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>A(d.url),className:"h-8 px-2 text-destructive hover:text-destructive",title:"Remove repository",children:e.jsx(nt,{className:"w-4 h-4"})})]})]},g))}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(us,{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(be,{children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(W,{onClick:T,disabled:I.isPending||!_,children:I.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function ln({open:t,onOpenChange:s,paperId:r,arxivId:c,initialProjectPages:n,onSuccess:o,submitMode:l="direct",isAuthor:a=!1}){const[p,m]=i.useState(n),[b,v]=i.useState(""),S=xe(),{toast:w}=ve(),F=i.useRef(!1);i.useEffect(()=>{if(!t){F.current=!1;return}F.current||(F.current=!0,m(n),v(""))},[t,n]);const I=ye({mutationFn:async({paperId:d,projectPages:g})=>l==="pending"?(await Pe({paper_id:parseInt(d),edit_type:"project_pages",proposed_payload:{project_pages:g}}),null):ma(d,g),onSuccess:d=>{if(l==="pending"){w({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed project page changes shortly."}),o==null||o(),s(!1),v("");return}d&&Oe(S,d,[r,c]),o==null||o(),s(!1),v("")},onError:d=>{var L;const g=d;let $=g.message||(l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update project pages.");if(g.response)try{const H=JSON.parse(g.response);typeof(H==null?void 0:H.detail)=="string"?$=H.detail:Array.isArray(H==null?void 0:H.detail)&&((L=H.detail[0])!=null&&L.msg)&&($=H.detail[0].msg)}catch{$=g.response}w({title:l==="pending"?"Could not submit edit":"Could not save project pages",description:$,variant:"destructive"})}}),O=()=>{const d=b.trim();return d?p.some(g=>g.url===d)?(alert("This project page URL is already added"),null):[...p,{url:d,is_official:!1}]:p},k=()=>{const d=O();d!==null&&d.length!==p.length&&(m(d),v(""))},A=d=>{m(p.filter(g=>g.url!==d))},U=d=>{m(p.map(g=>g.url===d?{...g,is_official:!g.is_official}:g))},T=()=>{const d=O();d!==null&&I.mutate({paperId:r,projectPages:d})},_=i.useMemo(()=>{const d=b.trim(),g=d?[...p,{url:d,is_official:!1}]:p;if(g.length!==n.length)return!0;const $=new Map(n.map(L=>[L.url.trim(),!!L.is_official]));return g.some(L=>{const H=$.get(L.url.trim());return H===void 0||H!==!!L.is_official})},[p,b,n]);return e.jsx(je,{open:t,onOpenChange:s,children:e.jsxs(de,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ue,{children:[e.jsx(me,{children:"Edit Paper Project Pages"}),e.jsx(pe,{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(Ae,{isAuthor:a}),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(ie,{type:"url",placeholder:"https://example.com/project",value:b,onChange:d=>v(d.target.value),onKeyPress:d=>{d.key==="Enter"&&(d.preventDefault(),k())},className:"flex-1"}),e.jsxs(W,{onClick:k,size:"sm",disabled:!b.trim(),children:[e.jsx(at,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[350px]",children:p.length>0?e.jsx("div",{className:"space-y-2",children:p.map((d,g)=>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(ms,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("span",{className:"text-sm font-medium text-paper-blue truncate",children:d.url}),d.is_official&&e.jsx(Is,{variant:"secondary",className:"text-xs",children:"Official"})]})}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs(W,{variant:d.is_official?"default":"outline",size:"sm",onClick:()=>U(d.url),className:"h-8 px-2 text-xs",title:d.is_official?"Click to unmark as official (created by paper authors)":"Click to mark as official (created by paper authors)",children:[e.jsx(Ds,{className:`w-3.5 h-3.5 mr-1 ${d.is_official?"fill-current":""}`}),d.is_official?"Official":"Mark official"]}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>A(d.url),className:"h-8 px-2 text-destructive hover:text-destructive",title:"Remove project page",children:e.jsx(nt,{className:"w-4 h-4"})})]})]},g))}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ms,{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(be,{children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(W,{onClick:T,disabled:I.isPending||!_,children:I.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function cn({open:t,onOpenChange:s,paperId:r,arxivId:c,initialUrl:n,onSuccess:o,submitMode:l="direct",isAuthor:a=!1}){const[p,m]=i.useState(n),b=xe(),{toast:v}=ve(),S=i.useRef(!1);i.useEffect(()=>{if(!t){S.current=!1;return}S.current||(S.current=!0,m(n))},[t,n]);const w=ye({mutationFn:async({paperId:A,sourceUrl:U})=>l==="pending"?(await Pe({paper_id:parseInt(A),edit_type:"source_url",proposed_payload:{source_url:U}}),null):pa(A,U),onSuccess:A=>{if(l==="pending"){v({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed source URL change shortly."}),o==null||o(),s(!1);return}A&&Oe(b,A,[r,c]),o==null||o(),s(!1)},onError:A=>{var _;const U=A;let T=U.message||(l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update source URL.");if(U.response)try{const d=JSON.parse(U.response);typeof(d==null?void 0:d.detail)=="string"?T=d.detail:Array.isArray(d==null?void 0:d.detail)&&((_=d.detail[0])!=null&&_.msg)&&(T=d.detail[0].msg)}catch{T=U.response}v({title:l==="pending"?"Could not submit edit":"Could not save source URL",description:T,variant:"destructive"})}}),F=p.trim(),I=/^https?:\/\//i.test(F),O=F!==(n||"").trim(),k=()=>{I&&w.mutate({paperId:r,sourceUrl:F})};return e.jsx(je,{open:t,onOpenChange:s,children:e.jsxs(de,{className:"max-w-2xl",children:[e.jsxs(ue,{children:[e.jsx(me,{children:"Edit Source URL"}),e.jsxs(pe,{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(Ae,{isAuthor:a}),e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Source URL"}),e.jsx(ie,{type:"url",placeholder:"https://example.com/paper",value:p,onChange:A=>m(A.target.value),onKeyPress:A=>{A.key==="Enter"&&I&&O&&(A.preventDefault(),k())}}),!I&&F.length>0&&e.jsx("p",{className:"text-xs text-destructive",children:"URL must start with http:// or https://"})]}),e.jsxs(be,{children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(W,{onClick:k,disabled:w.isPending||!I||!O,children:w.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function dn(t){const s=un(t),r=i.forwardRef((c,n)=>{const{children:o,...l}=c,a=i.Children.toArray(o),p=a.find(pn);if(p){const m=p.props.children,b=a.map(v=>v===p?i.Children.count(m)>1?i.Children.only(null):i.isValidElement(m)?m.props.children:null:v);return e.jsx(s,{...l,ref:n,children:i.isValidElement(m)?i.cloneElement(m,void 0,b):null})}return e.jsx(s,{...l,ref:n,children:o})});return r.displayName=`${t}.Slot`,r}function un(t){const s=i.forwardRef((r,c)=>{const{children:n,...o}=r;if(i.isValidElement(n)){const l=hn(n),a=fn(o,n.props);return n.type!==i.Fragment&&(a.ref=c?ke(c,l):l),i.cloneElement(n,a)}return i.Children.count(n)>1?i.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var mn=Symbol("radix.slottable");function pn(t){return i.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===mn}function fn(t,s){const r={...s};for(const c in s){const n=t[c],o=s[c];/^on[A-Z]/.test(c)?n&&o?r[c]=(...a)=>{const p=o(...a);return n(...a),p}:n&&(r[c]=n):c==="style"?r[c]={...n,...o}:c==="className"&&(r[c]=[n,o].filter(Boolean).join(" "))}return{...t,...r}}function hn(t){var c,n;let s=(c=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:c.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?t.ref:(s=(n=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:n.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var lt="Popover",[or]=wt(lt,[Ss]),Ke=Ss(),[gn,_e]=or(lt),lr=t=>{const{__scopePopover:s,children:r,open:c,defaultOpen:n,onOpenChange:o,modal:l=!1}=t,a=Ke(s),p=i.useRef(null),[m,b]=i.useState(!1),[v,S]=Nt({prop:c,defaultProp:n??!1,onChange:o,caller:lt});return e.jsx(Vr,{...a,children:e.jsx(gn,{scope:s,contentId:oe(),triggerRef:p,open:v,onOpenChange:S,onOpenToggle:i.useCallback(()=>S(w=>!w),[S]),hasCustomAnchor:m,onCustomAnchorAdd:i.useCallback(()=>b(!0),[]),onCustomAnchorRemove:i.useCallback(()=>b(!1),[]),modal:l,children:r})})};lr.displayName=lt;var cr="PopoverAnchor",xn=i.forwardRef((t,s)=>{const{__scopePopover:r,...c}=t,n=_e(cr,r),o=Ke(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:a}=n;return i.useEffect(()=>(l(),()=>a()),[l,a]),e.jsx(Es,{...o,...c,ref:s})});xn.displayName=cr;var dr="PopoverTrigger",ur=i.forwardRef((t,s)=>{const{__scopePopover:r,...c}=t,n=_e(dr,r),o=Ke(r),l=Re(s,n.triggerRef),a=e.jsx(J.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":gr(n.open),...c,ref:l,onClick:ee(t.onClick,n.onOpenToggle)});return n.hasCustomAnchor?a:e.jsx(Es,{asChild:!0,...o,children:a})});ur.displayName=dr;var Tt="PopoverPortal",[vn,yn]=or(Tt,{forceMount:void 0}),mr=t=>{const{__scopePopover:s,forceMount:r,children:c,container:n}=t,o=_e(Tt,s);return e.jsx(vn,{scope:s,forceMount:r,children:e.jsx(Le,{present:r||o.open,children:e.jsx(bs,{asChild:!0,container:n,children:c})})})};mr.displayName=Tt;var Me="PopoverContent",pr=i.forwardRef((t,s)=>{const r=yn(Me,t.__scopePopover),{forceMount:c=r.forceMount,...n}=t,o=_e(Me,t.__scopePopover);return e.jsx(Le,{present:c||o.open,children:o.modal?e.jsx(bn,{...n,ref:s}):e.jsx(_n,{...n,ref:s})})});pr.displayName=Me;var jn=dn("PopoverContent.RemoveScroll"),bn=i.forwardRef((t,s)=>{const r=_e(Me,t.__scopePopover),c=i.useRef(null),n=Re(s,c),o=i.useRef(!1);return i.useEffect(()=>{const l=c.current;if(l)return _s(l)},[]),e.jsx(Ns,{as:jn,allowPinchZoom:!0,children:e.jsx(fr,{...t,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ee(t.onCloseAutoFocus,l=>{var a;l.preventDefault(),o.current||(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:ee(t.onPointerDownOutside,l=>{const a=l.detail.originalEvent,p=a.button===0&&a.ctrlKey===!0,m=a.button===2||p;o.current=m},{checkForDefaultPrevented:!1}),onFocusOutside:ee(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),_n=i.forwardRef((t,s)=>{const r=_e(Me,t.__scopePopover),c=i.useRef(!1),n=i.useRef(!1);return e.jsx(fr,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,a;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(c.current||(a=r.triggerRef.current)==null||a.focus(),o.preventDefault()),c.current=!1,n.current=!1},onInteractOutside:o=>{var p,m;(p=t.onInteractOutside)==null||p.call(t,o),o.defaultPrevented||(c.current=!0,o.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const l=o.target;((m=r.triggerRef.current)==null?void 0:m.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&n.current&&o.preventDefault()}})}),fr=i.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:c,onOpenAutoFocus:n,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:a,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:b,...v}=t,S=_e(Me,r),w=Ke(r);return ws(),e.jsx(ks,{asChild:!0,loop:!0,trapped:c,onMountAutoFocus:n,onUnmountAutoFocus:o,children:e.jsx(Cs,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:b,onEscapeKeyDown:a,onPointerDownOutside:p,onFocusOutside:m,onDismiss:()=>S.onOpenChange(!1),children:e.jsx(Wr,{"data-state":gr(S.open),role:"dialog",id:S.contentId,...w,...v,ref:s,style:{...v.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)"}})})})}),hr="PopoverClose",Nn=i.forwardRef((t,s)=>{const{__scopePopover:r,...c}=t,n=_e(hr,r);return e.jsx(J.button,{type:"button",...c,ref:s,onClick:ee(t.onClick,()=>n.onOpenChange(!1))})});Nn.displayName=hr;var wn="PopoverArrow",kn=i.forwardRef((t,s)=>{const{__scopePopover:r,...c}=t,n=Ke(r);return e.jsx(Gr,{...n,...c,ref:s})});kn.displayName=wn;function gr(t){return t?"open":"closed"}var Cn=lr,En=ur,Sn=mr,xr=pr;const Rn=Cn,Pn=En,vr=i.forwardRef(({className:t,align:s="center",sideOffset:r=4,...c},n)=>e.jsx(Sn,{children:e.jsx(xr,{ref:n,align:s,sideOffset:r,className:Y("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})}));vr.displayName=xr.displayName;var ps=1,An=.9,In=.8,Dn=.17,pt=.1,ft=.999,Fn=.9999,Tn=.99,$n=/[\\\/_+.#"@\[\(\{&]/,Mn=/[\\\/_+.#"@\[\(\{&]/g,Ln=/[\s-]/,yr=/[\s-]/g;function bt(t,s,r,c,n,o,l){if(o===s.length)return n===t.length?ps:Tn;var a=`${n},${o}`;if(l[a]!==void 0)return l[a];for(var p=c.charAt(o),m=r.indexOf(p,n),b=0,v,S,w,F;m>=0;)v=bt(t,s,r,c,m+1,o+1,l),v>b&&(m===n?v*=ps:$n.test(t.charAt(m-1))?(v*=In,w=t.slice(n,m-1).match(Mn),w&&n>0&&(v*=Math.pow(ft,w.length))):Ln.test(t.charAt(m-1))?(v*=An,F=t.slice(n,m-1).match(yr),F&&n>0&&(v*=Math.pow(ft,F.length))):(v*=Dn,n>0&&(v*=Math.pow(ft,m-n))),t.charAt(m)!==s.charAt(o)&&(v*=Fn)),(vv&&(v=S*pt)),v>b&&(b=v),m=r.indexOf(p,m+1);return l[a]=b,b}function fs(t){return t.toLowerCase().replace(yr," ")}function On(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,bt(t,s,fs(t),fs(s),0,0,{})}var He='[cmdk-group=""]',ht='[cmdk-group-items=""]',Un='[cmdk-group-heading=""]',jr='[cmdk-item=""]',hs=`${jr}:not([aria-disabled="true"])`,_t="cmdk-item-select",Fe="data-value",Hn=(t,s,r)=>On(t,s,r),br=i.createContext(void 0),ze=()=>i.useContext(br),_r=i.createContext(void 0),$t=()=>i.useContext(_r),Nr=i.createContext(void 0),wr=i.forwardRef((t,s)=>{let r=Te(()=>{var x,M;return{search:"",value:(M=(x=t.value)!=null?x:t.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),c=Te(()=>new Set),n=Te(()=>new Map),o=Te(()=>new Map),l=Te(()=>new Set),a=kr(t),{label:p,children:m,value:b,onValueChange:v,filter:S,shouldFilter:w,loop:F,disablePointerSelection:I=!1,vimBindings:O=!0,...k}=t,A=oe(),U=oe(),T=oe(),_=i.useRef(null),d=Yn();Ee(()=>{if(b!==void 0){let x=b.trim();r.current.value=x,g.emit()}},[b]),Ee(()=>{d(6,C)},[]);let g=i.useMemo(()=>({subscribe:x=>(l.current.add(x),()=>l.current.delete(x)),snapshot:()=>r.current,setState:(x,M,q)=>{var P,Q,K,G;if(!Object.is(r.current[x],M)){if(r.current[x]=M,x==="search")j(),H(),d(1,te);else if(x==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let V=document.getElementById(T);V?V.focus():(P=document.getElementById(A))==null||P.focus()}if(d(7,()=>{var V;r.current.selectedItemId=(V=R())==null?void 0:V.id,g.emit()}),q||d(5,C),((Q=a.current)==null?void 0:Q.value)!==void 0){let V=M??"";(G=(K=a.current).onValueChange)==null||G.call(K,V);return}}g.emit()}},emit:()=>{l.current.forEach(x=>x())}}),[]),$=i.useMemo(()=>({value:(x,M,q)=>{var P;M!==((P=o.current.get(x))==null?void 0:P.value)&&(o.current.set(x,{value:M,keywords:q}),r.current.filtered.items.set(x,L(M,q)),d(2,()=>{H(),g.emit()}))},item:(x,M)=>(c.current.add(x),M&&(n.current.has(M)?n.current.get(M).add(x):n.current.set(M,new Set([x]))),d(3,()=>{j(),H(),r.current.value||te(),g.emit()}),()=>{o.current.delete(x),c.current.delete(x),r.current.filtered.items.delete(x);let q=R();d(4,()=>{j(),(q==null?void 0:q.getAttribute("id"))===x&&te(),g.emit()})}),group:x=>(n.current.has(x)||n.current.set(x,new Set),()=>{o.current.delete(x),n.current.delete(x)}),filter:()=>a.current.shouldFilter,label:p||t["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:A,inputId:T,labelId:U,listInnerRef:_}),[]);function L(x,M){var q,P;let Q=(P=(q=a.current)==null?void 0:q.filter)!=null?P:Hn;return x?Q(x,r.current.search,M):0}function H(){if(!r.current.search||a.current.shouldFilter===!1)return;let x=r.current.filtered.items,M=[];r.current.filtered.groups.forEach(P=>{let Q=n.current.get(P),K=0;Q.forEach(G=>{let V=x.get(G);K=Math.max(V,K)}),M.push([P,K])});let q=_.current;f().sort((P,Q)=>{var K,G;let V=P.getAttribute("id"),Ne=Q.getAttribute("id");return((K=x.get(Ne))!=null?K:0)-((G=x.get(V))!=null?G:0)}).forEach(P=>{let Q=P.closest(ht);Q?Q.appendChild(P.parentElement===Q?P:P.closest(`${ht} > *`)):q.appendChild(P.parentElement===q?P:P.closest(`${ht} > *`))}),M.sort((P,Q)=>Q[1]-P[1]).forEach(P=>{var Q;let K=(Q=_.current)==null?void 0:Q.querySelector(`${He}[${Fe}="${encodeURIComponent(P[0])}"]`);K==null||K.parentElement.appendChild(K)})}function te(){let x=f().find(q=>q.getAttribute("aria-disabled")!=="true"),M=x==null?void 0:x.getAttribute(Fe);g.setState("value",M||void 0)}function j(){var x,M,q,P;if(!r.current.search||a.current.shouldFilter===!1){r.current.filtered.count=c.current.size;return}r.current.filtered.groups=new Set;let Q=0;for(let K of c.current){let G=(M=(x=o.current.get(K))==null?void 0:x.value)!=null?M:"",V=(P=(q=o.current.get(K))==null?void 0:q.keywords)!=null?P:[],Ne=L(G,V);r.current.filtered.items.set(K,Ne),Ne>0&&Q++}for(let[K,G]of n.current)for(let V of G)if(r.current.filtered.items.get(V)>0){r.current.filtered.groups.add(K);break}r.current.filtered.count=Q}function C(){var x,M,q;let P=R();P&&(((x=P.parentElement)==null?void 0:x.firstChild)===P&&((q=(M=P.closest(He))==null?void 0:M.querySelector(Un))==null||q.scrollIntoView({block:"nearest"})),P.scrollIntoView({block:"nearest"}))}function R(){var x;return(x=_.current)==null?void 0:x.querySelector(`${jr}[aria-selected="true"]`)}function f(){var x;return Array.from(((x=_.current)==null?void 0:x.querySelectorAll(hs))||[])}function h(x){let M=f()[x];M&&g.setState("value",M.getAttribute(Fe))}function E(x){var M;let q=R(),P=f(),Q=P.findIndex(G=>G===q),K=P[Q+x];(M=a.current)!=null&&M.loop&&(K=Q+x<0?P[P.length-1]:Q+x===P.length?P[0]:P[Q+x]),K&&g.setState("value",K.getAttribute(Fe))}function N(x){let M=R(),q=M==null?void 0:M.closest(He),P;for(;q&&!P;)q=x>0?Xn(q,He):Jn(q,He),P=q==null?void 0:q.querySelector(hs);P?g.setState("value",P.getAttribute(Fe)):E(x)}let y=()=>h(f().length-1),z=x=>{x.preventDefault(),x.metaKey?y():x.altKey?N(1):E(1)},B=x=>{x.preventDefault(),x.metaKey?h(0):x.altKey?N(-1):E(-1)};return i.createElement(J.div,{ref:s,tabIndex:-1,...k,"cmdk-root":"",onKeyDown:x=>{var M;(M=k.onKeyDown)==null||M.call(k,x);let q=x.nativeEvent.isComposing||x.keyCode===229;if(!(x.defaultPrevented||q))switch(x.key){case"n":case"j":{O&&x.ctrlKey&&z(x);break}case"ArrowDown":{z(x);break}case"p":case"k":{O&&x.ctrlKey&&B(x);break}case"ArrowUp":{B(x);break}case"Home":{x.preventDefault(),h(0);break}case"End":{x.preventDefault(),y();break}case"Enter":{x.preventDefault();let P=R();if(P){let Q=new Event(_t);P.dispatchEvent(Q)}}}}},i.createElement("label",{"cmdk-label":"",htmlFor:$.inputId,id:$.labelId,style:ei},p),ct(t,x=>i.createElement(_r.Provider,{value:g},i.createElement(br.Provider,{value:$},x))))}),qn=i.forwardRef((t,s)=>{var r,c;let n=oe(),o=i.useRef(null),l=i.useContext(Nr),a=ze(),p=kr(t),m=(c=(r=p.current)==null?void 0:r.forceMount)!=null?c:l==null?void 0:l.forceMount;Ee(()=>{if(!m)return a.item(n,l==null?void 0:l.id)},[m]);let b=Cr(n,o,[t.value,t.children,o],t.keywords),v=$t(),S=ge(d=>d.value&&d.value===b.current),w=ge(d=>m||a.filter()===!1?!0:d.search?d.filtered.items.get(n)>0:!0);i.useEffect(()=>{let d=o.current;if(!(!d||t.disabled))return d.addEventListener(_t,F),()=>d.removeEventListener(_t,F)},[w,t.onSelect,t.disabled]);function F(){var d,g;I(),(g=(d=p.current).onSelect)==null||g.call(d,b.current)}function I(){v.setState("value",b.current,!0)}if(!w)return null;let{disabled:O,value:k,onSelect:A,forceMount:U,keywords:T,..._}=t;return i.createElement(J.div,{ref:ke(o,s),..._,id:n,"cmdk-item":"",role:"option","aria-disabled":!!O,"aria-selected":!!S,"data-disabled":!!O,"data-selected":!!S,onPointerMove:O||a.getDisablePointerSelection()?void 0:I,onClick:O?void 0:F},t.children)}),Bn=i.forwardRef((t,s)=>{let{heading:r,children:c,forceMount:n,...o}=t,l=oe(),a=i.useRef(null),p=i.useRef(null),m=oe(),b=ze(),v=ge(w=>n||b.filter()===!1?!0:w.search?w.filtered.groups.has(l):!0);Ee(()=>b.group(l),[]),Cr(l,a,[t.value,t.heading,p]);let S=i.useMemo(()=>({id:l,forceMount:n}),[n]);return i.createElement(J.div,{ref:ke(a,s),...o,"cmdk-group":"",role:"presentation",hidden:v?void 0:!0},r&&i.createElement("div",{ref:p,"cmdk-group-heading":"","aria-hidden":!0,id:m},r),ct(t,w=>i.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?m:void 0},i.createElement(Nr.Provider,{value:S},w))))}),Kn=i.forwardRef((t,s)=>{let{alwaysRender:r,...c}=t,n=i.useRef(null),o=ge(l=>!l.search);return!r&&!o?null:i.createElement(J.div,{ref:ke(n,s),...c,"cmdk-separator":"",role:"separator"})}),zn=i.forwardRef((t,s)=>{let{onValueChange:r,...c}=t,n=t.value!=null,o=$t(),l=ge(m=>m.search),a=ge(m=>m.selectedItemId),p=ze();return i.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),i.createElement(J.input,{ref:s,...c,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":p.listId,"aria-labelledby":p.labelId,"aria-activedescendant":a,id:p.inputId,type:"text",value:n?t.value:l,onChange:m=>{n||o.setState("search",m.target.value),r==null||r(m.target.value)}})}),Qn=i.forwardRef((t,s)=>{let{children:r,label:c="Suggestions",...n}=t,o=i.useRef(null),l=i.useRef(null),a=ge(m=>m.selectedItemId),p=ze();return i.useEffect(()=>{if(l.current&&o.current){let m=l.current,b=o.current,v,S=new ResizeObserver(()=>{v=requestAnimationFrame(()=>{let w=m.offsetHeight;b.style.setProperty("--cmdk-list-height",w.toFixed(1)+"px")})});return S.observe(m),()=>{cancelAnimationFrame(v),S.unobserve(m)}}},[]),i.createElement(J.div,{ref:ke(o,s),...n,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":c,id:p.listId},ct(t,m=>i.createElement("div",{ref:ke(l,p.listInnerRef),"cmdk-list-sizer":""},m)))}),Vn=i.forwardRef((t,s)=>{let{open:r,onOpenChange:c,overlayClassName:n,contentClassName:o,container:l,...a}=t;return i.createElement(sr,{open:r,onOpenChange:c},i.createElement(rr,{container:l},i.createElement(Dt,{"cmdk-overlay":"",className:n}),i.createElement(Ft,{"aria-label":t.label,"cmdk-dialog":"",className:o},i.createElement(wr,{ref:s,...a}))))}),Wn=i.forwardRef((t,s)=>ge(r=>r.filtered.count===0)?i.createElement(J.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),Gn=i.forwardRef((t,s)=>{let{progress:r,children:c,label:n="Loading...",...o}=t;return i.createElement(J.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":n},ct(t,l=>i.createElement("div",{"aria-hidden":!0},l)))}),Z=Object.assign(wr,{List:Qn,Item:qn,Input:zn,Group:Bn,Separator:Kn,Dialog:Vn,Empty:Wn,Loading:Gn});function Xn(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function Jn(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function kr(t){let s=i.useRef(t);return Ee(()=>{s.current=t}),s}var Ee=typeof window>"u"?i.useEffect:i.useLayoutEffect;function Te(t){let s=i.useRef();return s.current===void 0&&(s.current=t()),s}function ge(t){let s=$t(),r=()=>t(s.snapshot());return i.useSyncExternalStore(s.subscribe,r,r)}function Cr(t,s,r,c=[]){let n=i.useRef(),o=ze();return Ee(()=>{var l;let a=(()=>{var m;for(let b of r){if(typeof b=="string")return b.trim();if(typeof b=="object"&&"current"in b)return b.current?(m=b.current.textContent)==null?void 0:m.trim():n.current}})(),p=c.map(m=>m.trim());o.value(t,a,p),(l=s.current)==null||l.setAttribute(Fe,a),n.current=a}),n}var Yn=()=>{let[t,s]=i.useState(),r=Te(()=>new Map);return Ee(()=>{r.current.forEach(c=>c()),r.current=new Map},[t]),(c,n)=>{r.current.set(c,n),s({})}};function Zn(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function ct({asChild:t,children:s},r){return t&&i.isValidElement(s)?i.cloneElement(Zn(s),{ref:s.ref},r(s.props.children)):r(s)}var ei={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Er=i.forwardRef(({className:t,...s},r)=>e.jsx(Z,{ref:r,className:Y("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));Er.displayName=Z.displayName;const Sr=i.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(Be,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Z.Input,{ref:r,className:Y("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})]}));Sr.displayName=Z.Input.displayName;const Rr=i.forwardRef(({className:t,...s},r)=>e.jsx(Z.List,{ref:r,className:Y("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));Rr.displayName=Z.List.displayName;const Pr=i.forwardRef((t,s)=>e.jsx(Z.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Pr.displayName=Z.Empty.displayName;const Ar=i.forwardRef(({className:t,...s},r)=>e.jsx(Z.Group,{ref:r,className:Y("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}));Ar.displayName=Z.Group.displayName;const ti=i.forwardRef(({className:t,...s},r)=>e.jsx(Z.Separator,{ref:r,className:Y("-mx-1 h-px bg-border",t),...s}));ti.displayName=Z.Separator.displayName;const Ir=i.forwardRef(({className:t,...s},r)=>e.jsx(Z.Item,{ref:r,className:Y("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}));Ir.displayName=Z.Item.displayName;const si=250;function gs({value:t,onChange:s,placeholder:r="Select...",searchPlaceholder:c="Search...",emptyMessage:n="No results found.",disabled:o=!1,selectedOption:l,queryKey:a,queryFn:p,enabled:m=!0,className:b}){const[v,S]=i.useState(!1),[w,F]=i.useState(""),[I,O]=i.useState("");i.useEffect(()=>{const _=window.setTimeout(()=>{O(w.trim())},si);return()=>window.clearTimeout(_)},[w]),i.useEffect(()=>{v||(F(""),O(""))},[v]);const{data:k=[],isFetching:A}=le({queryKey:[...a,I],queryFn:()=>p(I),enabled:m&&v}),U=i.useMemo(()=>!t||k.some(_=>_.value===t)?k:(l==null?void 0:l.value)===t?[l,...k]:k,[k,l,t]),T=i.useMemo(()=>{if(!t)return r;const _=U.find(d=>d.value===t)??((l==null?void 0:l.value)===t?l:null);return(_==null?void 0:_.label)??r},[U,r,l,t]);return e.jsxs(Rn,{open:v,onOpenChange:S,children:[e.jsx(Pn,{asChild:!0,children:e.jsxs(W,{type:"button",variant:"outline",role:"combobox","aria-expanded":v,disabled:o,className:Y("h-8 w-full justify-between px-2 text-sm font-normal",!t&&"text-muted-foreground",b),children:[e.jsx("span",{className:"truncate",children:T}),e.jsx(ka,{className:"ml-1 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(vr,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:e.jsxs(Er,{shouldFilter:!1,children:[e.jsx(Sr,{placeholder:c,value:w,onValueChange:F}),e.jsx(Rr,{children:A?e.jsxs("div",{className:"flex items-center justify-center py-6 text-sm text-muted-foreground",children:[e.jsx(ae,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading..."]}):U.length===0?e.jsx(Pr,{children:n}):e.jsx(Ar,{children:U.map(_=>e.jsxs(Ir,{value:_.value,onSelect:()=>{s(_.value),S(!1)},children:[e.jsx(ce,{className:Y("mr-2 h-4 w-4",t===_.value?"opacity-100":"opacity-0")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate",children:_.label}),_.description?e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:_.description}):null]})]},_.value))})})]})})]})}const gt=100;function ri(t){return t.map(s=>{const r=s.best_metric||Object.keys(s.metrics)[0],c=s.metrics[r];return{id:s.id,task_id:s.task_id,dataset_id:s.dataset_id,model_name:s.model_name||"",harness:s.harness||"",metric_name:r||"",metric_value:String(c||""),best_rank:s.best_rank?String(s.best_rank):"",num_parameters:s.num_parameters!=null?String(s.num_parameters):"",operation:"unchanged"}})}function ai(t){const s=new Map;return t.forEach(r=>{r.task_id&&r.task_name&&s.set(r.task_id,{id:r.task_id,name:r.task_name,slug:r.task_slug,level:0})}),s}function ni(t){const s=new Map;return t.forEach(r=>{r.dataset_id&&r.dataset_name&&s.set(r.dataset_id,{id:r.dataset_id,name:r.dataset_name,slug:r.dataset_slug})}),s}function xs(t,s){return`${t}:${s}`}function Ye(t){const s=t.trim();if(s==="")return null;const r=Number(s);return!Number.isFinite(r)||r<0?null:Math.trunc(r)}function ii({open:t,onOpenChange:s,paperId:r,arxivId:c,initialEvaluations:n,onSuccess:o,submitMode:l="direct",isAuthor:a=!1}){const[p,m]=i.useState([]),[b,v]=i.useState(new Map),[S,w]=i.useState(new Map),F=xe(),{toast:I}=ve(),O=i.useRef(!1),k=i.useRef(!1);i.useEffect(()=>{if(!t){O.current=!1,k.current=!1;return}O.current||k.current||n.length!==0&&(O.current=!0,m(ri(n)),v(ai(n)),w(ni(n)))},[t,n]);const A=i.useMemo(()=>Array.from(new Set(p.map(f=>f.task_id).filter(f=>f&&f!==""))),[p]),U=i.useMemo(()=>{const f=new Set;return p.forEach(h=>{h.task_id&&h.dataset_id&&f.add(xs(h.task_id,h.dataset_id))}),Array.from(f)},[p]),T=le({queryKey:["datasets-by-tasks-for-eval-edit",A,t],queryFn:async()=>{const f={};return await Promise.all(A.map(async h=>{try{const E=await ds({task_id:parseInt(h),page_size:gt});f[h]=E.results}catch(E){console.error(`Error fetching datasets for task ${h}:`,E),f[h]=[]}})),f},enabled:t&&A.length>0});i.useEffect(()=>{T.data&&w(f=>{const h=new Map(f);return Object.values(T.data).forEach(E=>{E.forEach(N=>{h.set(N.id,N)})}),h})},[T.data]);const _=le({queryKey:["leaderboard-metrics-for-eval-edit",U,t],queryFn:async()=>{const f={};return await Promise.all(U.map(async h=>{const[E,N]=h.split(":");try{f[h]=await xa(N,E)}catch(y){console.error(`Error fetching metrics for leaderboard ${h}:`,y),f[h]=[]}})),f},enabled:t&&U.length>0}),d=async f=>{const h=await As({page_size:gt,visible_only:!0,...f?{q:f}:{}});return v(E=>{const N=new Map(E);return h.results.forEach(y=>N.set(y.id,y)),N}),h.results.map(E=>{var N;return{value:E.id,label:E.name,description:(N=E.description)==null?void 0:N.slice(0,100)}})},g=f=>async h=>{const E=await ds({task_id:parseInt(f),page_size:gt,...h?{q:h}:{}});return w(N=>{const y=new Map(N);return E.results.forEach(z=>y.set(z.id,z)),y}),E.results.map(N=>({value:N.id,label:N.name,description:N.full_name}))},$=(f,h)=>{if(!f||!h)return!1;const E=S.get(h);return!!(E!=null&&E.supports_harness)},L=(f,h,E)=>{var z;if(!f||!h)return[];const y=(((z=_.data)==null?void 0:z[xs(f,h)])||[]).map(B=>({value:B.metric_name,label:B.metric_name,description:B.metric_direction==="higher_is_better"?"Higher is better":"Lower is better"}));return E&&!y.some(B=>B.value===E)&&y.unshift({value:E,label:`${E} (legacy)`,description:void 0}),y},H=ye({mutationFn:async({paperId:f,evaluations:h})=>{if(l==="pending"){const N=[];for(const y of h){if(y.operation==="delete"&&y.id){N.push({op:"delete",evaluation_id:parseInt(y.id)});continue}const z=$(y.task_id,y.dataset_id);if(y.operation==="create"){const B=Ye(y.num_parameters),x={task_id:parseInt(y.task_id),dataset_id:parseInt(y.dataset_id),metrics:{[y.metric_name]:y.metric_value},best_metric:y.metric_name};y.model_name&&(x.model_name=y.model_name),z&&y.harness&&(x.harness=y.harness),y.best_rank&&(x.best_rank=parseInt(y.best_rank)),B!=null&&(x.num_parameters=B),N.push({op:"create",data:x})}else if(y.operation==="update"&&y.id){const B={task_id:parseInt(y.task_id),dataset_id:parseInt(y.dataset_id),model_name:y.model_name||void 0,harness:z&&y.harness||null,metrics:{[y.metric_name]:y.metric_value},best_metric:y.metric_name,best_rank:y.best_rank?parseInt(y.best_rank):void 0,num_parameters:Ye(y.num_parameters)};N.push({op:"update",evaluation_id:parseInt(y.id),data:B})}}return N.length===0?{submitted:!1}:(await Pe({paper_id:parseInt(f),edit_type:"evaluations",proposed_payload:{operations:N}}),{submitted:!0})}let E=!1;for(const N of h)if(N.operation==="delete"&&N.id){E=!0;try{await fa(N.id)}catch(y){if((typeof y=="object"&&y!==null&&"status"in y?y.status:void 0)!==404)throw y;console.log(`Evaluation ${N.id} already deleted or not found`)}}else if(N.operation==="create"){E=!0;const y=$(N.task_id,N.dataset_id),z=Ye(N.num_parameters);await ha({paper_id:parseInt(f),task_id:parseInt(N.task_id),dataset_id:parseInt(N.dataset_id),model_name:N.model_name||void 0,harness:y&&N.harness||void 0,metrics:{[N.metric_name]:N.metric_value},best_metric:N.metric_name,best_rank:N.best_rank?parseInt(N.best_rank):void 0,num_parameters:z??void 0})}else if(N.operation==="update"&&N.id){E=!0;const y=$(N.task_id,N.dataset_id);await ga(N.id,{task_id:parseInt(N.task_id),dataset_id:parseInt(N.dataset_id),model_name:N.model_name||void 0,harness:y&&N.harness||null,metrics:{[N.metric_name]:N.metric_value},best_metric:N.metric_name,best_rank:N.best_rank?parseInt(N.best_rank):void 0,num_parameters:Ye(N.num_parameters)})}return{submitted:E}},onSuccess:f=>{if(l==="pending"){f!=null&&f.submitted?I({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed evaluation changes shortly."}):I({title:"No changes to submit",description:"Your evaluation list matches the existing data."}),o==null||o(),s(!1);return}F.invalidateQueries({queryKey:["paper-arxiv",c]}),F.invalidateQueries({queryKey:["evaluations","paper",r]}),o==null||o(),s(!1)},onError:f=>{var N;const h=f;let E=h.message||(l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update evaluations.");if(h.response)try{const y=JSON.parse(h.response);typeof(y==null?void 0:y.detail)=="string"?E=y.detail:Array.isArray(y==null?void 0:y.detail)&&((N=y.detail[0])!=null&&N.msg)&&(E=y.detail[0].msg)}catch{E=h.response}I({title:l==="pending"?"Could not submit edit":"Could not save evaluations",description:E,variant:"destructive"})}}),te=()=>{k.current=!0,m([...p,{task_id:"",dataset_id:"",model_name:"",harness:"",metric_name:"",metric_value:"",best_rank:"",num_parameters:"",operation:"create"}])},j=f=>{k.current=!0,p[f].id?m(p.map((E,N)=>N===f?{...E,operation:"delete"}:E)):m(p.filter((E,N)=>N!==f))},C=(f,h,E)=>{k.current=!0,m(p.map((N,y)=>{if(y!==f)return N;const z={...N,[h]:E};return h==="task_id"&&(z.dataset_id="",z.metric_name="",z.harness=""),h==="dataset_id"&&(z.metric_name="",E&&!$(z.task_id,E)&&(z.harness="")),N.operation==="unchanged"&&(z.operation="update"),z}))},R=()=>{const f=p.filter(h=>h.operation!=="delete"||h.id);H.mutate({paperId:r,evaluations:f})};return e.jsx(je,{open:t,onOpenChange:s,children:e.jsxs(de,{className:"max-w-6xl max-h-[800px]",children:[e.jsxs(ue,{children:[e.jsx(me,{children:"Edit Evaluation Results"}),e.jsx(pe,{children:"Add, edit, or remove evaluation results for this paper. Each row represents a benchmark result."})]}),l==="pending"&&e.jsx(Ae,{isAuthor:a}),e.jsxs("div",{className:"py-4 overflow-y-auto max-h-[600px]",children:[p.filter(f=>f.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",children:"Model"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm",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 w-16",children:"Action"})]})}),e.jsx("tbody",{children:p.map((f,h)=>{if(f.operation==="delete")return null;const E=b.get(f.task_id),N=S.get(f.dataset_id),y=L(f.task_id,f.dataset_id,f.metric_name),z=!!(f.task_id&&f.dataset_id)&&_.isFetching;return e.jsxs("tr",{className:"border-b border-border",children:[e.jsx("td",{className:"py-2 px-2",children:e.jsx(gs,{value:f.task_id,onChange:B=>C(h,"task_id",B),placeholder:"Select task",searchPlaceholder:"Search tasks...",emptyMessage:"No tasks found.",selectedOption:E?{value:E.id,label:E.name}:null,queryKey:["eval-edit-task-search"],queryFn:d,enabled:t})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(gs,{value:f.dataset_id,onChange:B=>C(h,"dataset_id",B),placeholder:f.task_id?"Select dataset":"Select task first",searchPlaceholder:"Search datasets...",emptyMessage:f.task_id?"No datasets found for this task.":"Select a task first.",disabled:!f.task_id,selectedOption:N?{value:N.id,label:N.name}:null,queryKey:["eval-edit-dataset-search",f.task_id],queryFn:g(f.task_id),enabled:t&&!!f.task_id})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(ie,{type:"text",className:"w-full text-sm",placeholder:"Model name",value:f.model_name,onChange:B=>C(h,"model_name",B.target.value)})}),e.jsx("td",{className:"py-2 px-2",children:$(f.task_id,f.dataset_id)?e.jsx(ie,{type:"text",className:"w-full text-sm",placeholder:"Claude Code, Terminus, ...",value:f.harness,onChange:B=>C(h,"harness",B.target.value)}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not supported"})}),e.jsx("td",{className:"py-2 px-2",children:!f.task_id||!f.dataset_id?e.jsx("span",{className:"text-xs text-muted-foreground",children:"Select task + dataset"}):z?e.jsxs("span",{className:"inline-flex items-center text-xs text-muted-foreground",children:[e.jsx(ae,{className:"mr-1 h-3 w-3 animate-spin"}),"Loading metrics..."]}):y.length>0?e.jsxs("select",{className:"w-full rounded-md border border-border bg-background px-2 py-1 text-sm",value:f.metric_name,onChange:B=>C(h,"metric_name",B.target.value),children:[e.jsx("option",{value:"",children:"Select metric"}),y.map(B=>e.jsx("option",{value:B.value,children:B.label},B.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(ie,{type:"text",className:"w-full text-sm",placeholder:"44.9",value:f.metric_value,onChange:B=>C(h,"metric_value",B.target.value)})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(ie,{type:"number",min:0,step:1,className:"w-full text-sm",placeholder:"e.g. 7000000000",value:f.num_parameters,onChange:B=>C(h,"num_parameters",B.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(W,{variant:"ghost",size:"sm",onClick:()=>j(h),className:"h-8 w-8 p-0 text-destructive hover:text-destructive",title:"Delete row",children:e.jsx(nt,{className:"w-4 h-4"})})})]},h)})})]})}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(wa,{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(W,{variant:"outline",size:"sm",onClick:te,className:"flex items-center space-x-2",children:[e.jsx(at,{className:"w-4 h-4"}),e.jsx("span",{children:"Add Row"})]})})]}),e.jsxs(be,{children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(W,{onClick:R,disabled:H.isPending,children:H.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}const xt=[{key:"hf_models",label:"Models",placeholder:"https://huggingface.co/org/model"},{key:"hf_datasets",label:"Datasets",placeholder:"https://huggingface.co/datasets/org/data"},{key:"hf_spaces",label:"Spaces",placeholder:"https://huggingface.co/spaces/org/demo"}];function vs(t){return t.map(s=>s.trim()).filter(Boolean)}function vt(t,s){const r=vs(t).sort(),c=vs(s).sort();return r.length!==c.length?!1:r.every((n,o)=>n===c[o])}function oi(t,s){return vt(t.hf_models,s.hf_models)&&vt(t.hf_datasets,s.hf_datasets)&&vt(t.hf_spaces,s.hf_spaces)}function li({open:t,onOpenChange:s,paperId:r,arxivId:c,initialArtifacts:n,onSuccess:o,submitMode:l="direct",isAuthor:a=!1}){const[p,m]=i.useState(n),[b,v]=i.useState({hf_models:"",hf_datasets:"",hf_spaces:""}),S=xe(),{toast:w}=ve(),F=i.useRef(!1);i.useEffect(()=>{if(!t){F.current=!1;return}F.current||(F.current=!0,m(n),v({hf_models:"",hf_datasets:"",hf_spaces:""}))},[t,n]);const I=ye({mutationFn:async({paperId:_,artifacts:d})=>l==="pending"?(await Pe({paper_id:parseInt(_),edit_type:"hf_artifacts",proposed_payload:d}),null):va(_,d),onSuccess:_=>{if(l==="pending"){w({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed Hugging Face artifact changes shortly."}),o==null||o(),s(!1),v({hf_models:"",hf_datasets:"",hf_spaces:""});return}_&&Oe(S,_,[r,c]),o==null||o(),s(!1),v({hf_models:"",hf_datasets:"",hf_spaces:""})},onError:_=>{var $;const d=_;let g=d.message||(l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update Hugging Face artifacts.");if(d.response)try{const L=JSON.parse(d.response);typeof(L==null?void 0:L.detail)=="string"?g=L.detail:Array.isArray(L==null?void 0:L.detail)&&(($=L.detail[0])!=null&&$.msg)&&(g=L.detail[0].msg)}catch{g=d.response}w({title:l==="pending"?"Could not submit edit":"Could not save Hugging Face artifacts",description:g,variant:"destructive"})}}),O=()=>{const _={hf_models:[...p.hf_models],hf_datasets:[...p.hf_datasets],hf_spaces:[...p.hf_spaces]};for(const{key:d}of xt){const g=b[d].trim();if(g){if(_[d].some($=>$.trim()===g))return alert(`This ${d.replace("hf_","")} URL is already added`),null;_[d]=[..._[d],g]}}return _},k=_=>{const d=b[_].trim();if(d){if(p[_].some(g=>g.trim()===d)){alert(`This ${_.replace("hf_","")} URL is already added`);return}m(g=>({...g,[_]:[...g[_],d]})),v(g=>({...g,[_]:""}))}},A=(_,d)=>{m(g=>({...g,[_]:g[_].filter($=>$!==d)}))},U=()=>{const _=O();_!==null&&I.mutate({paperId:r,artifacts:_})},T=i.useMemo(()=>{const _={hf_models:[...p.hf_models],hf_datasets:[...p.hf_datasets],hf_spaces:[...p.hf_spaces]};for(const{key:d}of xt){const g=b[d].trim();if(g){if(_[d].some($=>$.trim()===g))return!1;_[d]=[..._[d],g]}}return!oi(_,n)},[p,b,n]);return e.jsx(je,{open:t,onOpenChange:s,children:e.jsxs(de,{className:"max-w-2xl max-h-[700px]",children:[e.jsxs(ue,{children:[e.jsx(me,{children:"Edit Hugging Face Artifacts"}),e.jsx(pe,{children:"Add or remove linked Hugging Face models, datasets, and Spaces for this paper."})]}),l==="pending"&&e.jsx(Ae,{isAuthor:a}),e.jsx("div",{className:"space-y-6 py-2 overflow-y-auto max-h-[460px]",children:xt.map(({key:_,label:d,placeholder:g})=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:d}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(ie,{type:"url",placeholder:g,value:b[_],onChange:$=>v(L=>({...L,[_]:$.target.value})),onKeyPress:$=>{$.key==="Enter"&&($.preventDefault(),k(_))},className:"flex-1"}),e.jsxs(W,{onClick:()=>k(_),size:"sm",disabled:!b[_].trim(),children:[e.jsx(at,{className:"w-4 h-4 mr-1"}),"Add"]})]}),p[_].length>0?e.jsx("div",{className:"space-y-2",children:p[_].map($=>e.jsxs("div",{className:"flex items-center space-x-2 p-3 bg-muted/30 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-paper-blue truncate flex-1",children:$}),e.jsx(W,{variant:"ghost",size:"sm",onClick:()=>A(_,$),className:"h-8 px-2 text-destructive hover:text-destructive",title:`Remove ${d.toLowerCase()} URL`,children:e.jsx(nt,{className:"w-4 h-4"})})]},$))}):e.jsxs("div",{className:"text-xs text-muted-foreground",children:["No ",d.toLowerCase()," linked yet."]})]},_))}),e.jsxs(be,{children:[e.jsx(W,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(W,{onClick:U,disabled:I.isPending||!T,children:I.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function ci({open:t,onOpenChange:s,sectionLabel:r,returnTo:c}){return e.jsx(je,{open:t,onOpenChange:s,children:e.jsxs(de,{className:"max-w-md",children:[e.jsxs(ue,{children:[e.jsxs(me,{children:["Sign in to edit ",r]}),e.jsx(pe,{children:"Anyone can suggest edits to a paper page. Sign in with your Hugging Face account first so an admin can review your submission."})]}),e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(Xr,{returnTo:c})})]})})}const $e=["my-bookmark-ids"];function di(){var c,n;const{user:t}=rt(),s=le({queryKey:$e,queryFn:()=>tt.getMyBookmarkIds(),enabled:!!t,staleTime:60*1e3,refetchOnWindowFocus:!1}),r=Ct.useMemo(()=>{var o;return new Set(((o=s.data)==null?void 0:o.paper_ids)??[])},[(c=s.data)==null?void 0:c.paper_ids]);return{ids:((n=s.data)==null?void 0:n.paper_ids)??[],idSet:r,isLoading:s.isLoading,isError:s.isError}}function ui(){const{user:t}=rt(),s=xe(),r=ye({mutationFn:async({paperId:n,isBookmarked:o})=>{o?await tt.removeBookmark(n):await tt.addBookmark(n)},onMutate:async({paperId:n,isBookmarked:o})=>{await s.cancelQueries({queryKey:$e});const l=s.getQueryData($e),a=typeof n=="string"?Number(n):n,p=(l==null?void 0:l.paper_ids)??[],m=o?p.filter(b=>b!==a):[a,...p.filter(b=>b!==a)];return s.setQueryData($e,{paper_ids:m}),{previous:l}},onError:(n,o,l)=>{l!=null&&l.previous&&s.setQueryData($e,l.previous)},onSettled:()=>{s.invalidateQueries({queryKey:$e}),s.invalidateQueries({queryKey:["my-bookmarks"]})}});return{toggle:Ct.useCallback((n,o)=>{if(!t){if(Rs())return;const l=typeof window<"u"?window.location.pathname+window.location.search:"/";window.location.href=Ps(`/api/v1/auth/hf/login?return_to=${encodeURIComponent(l)}`);return}r.mutate({paperId:n,isBookmarked:o})},[r,t]),isPending:r.isPending}}const mi=({paperId:t})=>{const{user:s}=rt(),{idSet:r}=di(),{toggle:c,isPending:n}=ui();if(Rs())return null;const o=Number(t),l=!!s&&r.has(o),a=()=>{Number.isFinite(o)&&c(o,l)},p=s&&l?"Saved":"Save",m=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:a,disabled:n,"aria-pressed":l,"aria-label":m,title:m,children:[e.jsx(re,{name:"bookmark",size:12}),p]})};function Ze({children:t,showEdit:s=!1,onEdit:r,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:r,"aria-label":c,children:"edit"})]}):t}const pi={tasks:"tasks",methods:"methods",results:"evaluation results",repositories:"GitHub repositories","project-pages":"project pages","source-url":"source URL","hf-artifacts":"Hugging Face artifacts"},et=360,yt=3;function ys(t){if(!t)return"—";try{return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return"—"}}function js(t){return t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function we(t,s){try{const r=new URL(t),n=r.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);return n?n.replace(/[-_]+/g," "):r.hostname.replace(/^www\./,"")}catch{return s}}const Ii=()=>{var Wt,Gt,Xt,Jt,Yt,Zt,es,ts,ss,rs,as,ns;const{arxivId:t}=Jr(),s=Yr(),{toast:r}=ve(),{user:c}=rt(),n=(c==null?void 0:c.is_admin)??!1,o=!!c,l=!0,{data:a,isLoading:p,error:m,refetch:b}=ba(t||"",!!t),[v,S]=i.useState(!1);i.useEffect(()=>{if(S(!1),!(a!=null&&a.id))return;const u=window.setTimeout(()=>S(!0),0);return()=>window.clearTimeout(u)},[a==null?void 0:a.id]);const{data:w,isLoading:F}=Sa(v?a==null?void 0:a.arxiv_id:void 0),{data:I,isLoading:O}=Ca(a==null?void 0:a.id,v&&!!(a!=null&&a.id)),k=i.useMemo(()=>({models:(a==null?void 0:a.hf_models)??[],datasets:(a==null?void 0:a.hf_datasets)??[],spaces:(a==null?void 0:a.hf_spaces)??[]}),[a==null?void 0:a.hf_models,a==null?void 0:a.hf_datasets,a==null?void 0:a.hf_spaces]),A=i.useMemo(()=>{if(!I)return[];const u=new Map;for(const D of I){const X=D.task_id,se=u.get(X);se?se.rows.push(D):u.set(X,{taskId:X,taskName:D.task_name||"—",taskSlug:D.task_slug,rows:[D]})}return Array.from(u.values())},[I]),U=le({queryKey:["paper-versions",a==null?void 0:a.arxiv_id],queryFn:async()=>{const u=a.arxiv_id.replace(/v\d+$/,""),D=await fetch(Ps(`/api/v1/papers/arxiv/${u}/versions`));return D.ok?await D.json():[]},enabled:v&&!!(a!=null&&a.arxiv_id),staleTime:10*60*1e3}),T=le({queryKey:["related-papers",(Gt=(Wt=a==null?void 0:a.tasks)==null?void 0:Wt[0])==null?void 0:Gt.id],queryFn:()=>tt.getTaskPapers(a.tasks[0].id,{page:1,page_size:5,order_by:"citation_count",order_dir:"desc",include_resources:!1}),enabled:v&&!!((Jt=(Xt=a==null?void 0:a.tasks)==null?void 0:Xt[0])!=null&&Jt.id),staleTime:10*60*1e3,select:u=>u.results.filter(D=>D.id!==(a==null?void 0:a.id)).slice(0,4)}),[_,d]=i.useState(!1),[g,$]=i.useState(!1),[L,H]=i.useState(!1),{isEditingTasks:te,setIsEditingTasks:j,isEditingMethods:C,setIsEditingMethods:R,isEditingRepositories:f,setIsEditingRepositories:h,isEditingProjectPages:E,setIsEditingProjectPages:N,isEditingEvaluations:y,setIsEditingEvaluations:z,isEditingSourceUrl:B,setIsEditingSourceUrl:x,isEditingHfArtifacts:M,setIsEditingHfArtifacts:q}=Ra(),[P,Q]=i.useState(null),K=i.useMemo(()=>{if(!c||!(a!=null&&a.author_links))return!1;const u=c.username.toLowerCase();return a.author_links.some(D=>!!D.hf_username&&D.hf_username.toLowerCase()===u)},[c,a==null?void 0:a.author_links]),G=n?"direct":"pending",V=u=>{if(!o){Q(u);return}switch(u){case"tasks":j(!0);return;case"methods":R(!0);return;case"results":z(!0);return;case"repositories":h(!0);return;case"project-pages":N(!0);return;case"source-url":x(!0);return;case"hf-artifacts":q(!0);return}},[Ne,dt]=i.useState("idle"),[Mt,Lt]=i.useState(null),[Ot,Ut]=i.useState(null),Dr=async()=>{if(t){dt("indexing"),Lt(null),Ut(null);try{await ya(t),r({title:"Indexed",description:"Paper added to database."}),setTimeout(()=>b(),1200),dt("idle")}catch(u){const D=u;let X=D.message||"Failed to index paper";if(D.response)try{X=JSON.parse(D.response).detail||X}catch{X=D.response}Lt(X),(D.status===429||D.status===503)&&Ut("Try again later after arXiv has lifted the temporary limit."),dt("idle")}}},{citationDisplay:Fr,citationCopy:Ht}=i.useMemo(()=>{if(!a)return{citationDisplay:"",citationCopy:""};const u=`${a.title.slice(0,60)}${a.title.length>60?"…":""}`,D=`${a.authors[0]||""}${a.authors.length>1?" et al.":""}`,X=a.authors.join(" and "),se=(a.published||"").slice(0,4)||"—",is=(os,ls)=>a.arxiv_id?`@article{${a.arxiv_id.replace(".","")}, + title={{${os}}}, + author=${ls}, + year={{${se}}}, + eprint={{${a.arxiv_id}}}, + archivePrefix={{arXiv}} +}`:`@misc{paper${a.id}, + title={{${os}}}, + author=${ls}, + year={{${se}}}, + url={{${a.source_url||a.url_abs||""}}} +}`;return{citationDisplay:is(u,`{{${D}}}`),citationCopy:is(a.title,`{${X}}`)}},[a]),[Tr,qt]=i.useState(!1),$r=async()=>{if(Ht)try{await navigator.clipboard.writeText(Ht),qt(!0),r({title:"Citation copied",description:"BibTeX entry copied to clipboard."}),window.setTimeout(()=>qt(!1),1500)}catch{r({title:"Copy failed",description:"Could not access the clipboard. Please copy manually.",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(m||!a)return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"breadcrumb",children:[e.jsx(De,{to:"/papers",children:"Papers"}),e.jsx("span",{className:"sep",children:"/"}),e.jsxs("span",{style:{color:"var(--ink)"},children:["arXiv:",t]})]}),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:",t]})," in the database. You can index it from arXiv right now."]}),Mt&&e.jsx(_a,{variant:"destructive",className:"mt-4 max-w-xl",children:e.jsxs(Na,{children:[e.jsx("div",{children:Mt}),Ot&&e.jsx("div",{className:"mt-2",children:Ot})]})}),e.jsxs("div",{className:"action-row",children:[n&&e.jsxs("button",{className:"action-btn",onClick:Dr,disabled:Ne==="indexing",children:[e.jsx(re,{name:"sparkle",size:12}),Ne==="indexing"?"Indexing…":"Index from arXiv"]}),e.jsx(W,{variant:"outline",onClick:()=>s("/papers"),children:"Browse Papers"})]})]});const Bt=U.data||[],Qe=ja(a.repositories),fe=[...a.repositories??[]].sort((u,D)=>{const X=u.is_official?1:0,se=D.is_official?1:0;return X!==se?se-X:(D.num_stars||0)-(u.num_stars||0)}),Mr=L?fe:fe.slice(0,yt),Lr=a.arxiv_id?{isLoading:F,paperHref:`https://huggingface.co/papers/${a.arxiv_id.replace(/v\d+$/,"")}`,rows:[{label:"Models",href:`https://huggingface.co/models?other=arxiv:${a.arxiv_id}`,count:w==null?void 0:w.models,isLimited:w==null?void 0:w.isLimited,links:k.models.map(u=>({href:u,label:we(u,"Model")}))},{label:"Datasets",href:`https://huggingface.co/datasets?other=arxiv:${a.arxiv_id}`,count:w==null?void 0:w.datasets,isLimited:w==null?void 0:w.isLimited,links:k.datasets.map(u=>({href:u,label:we(u,"Dataset")}))},{label:"Spaces",href:`https://huggingface.co/spaces?arxivIds=${a.arxiv_id.replace(/v\d+$/,"")}`,count:w==null?void 0:w.spaces,isLimited:w==null?void 0:w.isLimited,links:k.spaces.map(u=>({href:u,label:we(u,"Space")}))}],footer:`Cite arxiv.org/abs/${a.arxiv_id} in a HF README to link it here.`}:{isLoading:!1,paperHref:null,rows:[{label:"Models",href:jt(k.models),count:k.models.length,links:k.models.map(u=>({href:u,label:we(u,"Model")}))},{label:"Datasets",href:jt(k.datasets),count:k.datasets.length,links:k.datasets.map(u=>({href:u,label:we(u,"Dataset")}))},{label:"Spaces",href:jt(k.spaces),count:k.spaces.length,links:k.spaces.map(u=>({href:u,label:we(u,"Space")}))}],footer:null},Kt=a.tldr||null,zt=a.num_pages||null,Ie=a.abstract||"",Or=Ie.length>et?Ie.slice(0,et)+"…":Ie,Ur=_||Ie.length<=et?Ie:Or,Ve=(a.methods||[]).filter(u=>u.source_paper_id===a.id),We=a.introduced_benchmarks||[],Hr=Ve.length>0||We.length>0,Qt=a.arxiv_id?`arXiv:${a.arxiv_id}`:"External resource",qr=a.source==="external"?"Source page":"arXiv page",Ue=((Yt=a.project_pages)==null?void 0:Yt.filter(u=>u.url))??[],Br=(()=>{const u=[];return Ve.length>0&&u.push(Ve.length===1?"this method":"these methods"),We.length>0&&u.push(We.length===1?"this benchmark":"these benchmarks"),u.length===0?"":u.length===1?u[0]:u.join(" and ")})(),Ge=a.predecessor_papers||[],Xe=a.successor_papers||[],Kr=Ge.length>0||Xe.length>0,Je=12,ut=a.authors.map((u,D)=>{var X,se;return{name:u,hf_username:((se=(X=a.author_links)==null?void 0:X[D])==null?void 0:se.hf_username)??null}}),Vt=g||ut.length<=Je?ut:ut.slice(0,Je);return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"breadcrumb",children:[e.jsx(De,{to:"/",children:"Trending"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("span",{children:Qt})]}),e.jsxs("div",{className:"detail-grid",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"detail-title",children:e.jsx(cs,{title:a.title})}),e.jsxs("div",{className:"detail-meta",children:[e.jsx("span",{children:Qt}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:["Submitted ",ys(a.published)]}),zt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[zt," pages"]})]}),a.citation_count!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[a.citation_count.toLocaleString()," citations"]})]}),a.proceeding&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:a.proceeding.replace(/\s+\d{1,2}$/,"")})]}),Bt.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("select",{className:"version-select",value:a.version,onChange:u=>{const D=u.target.value;a.arxiv_id&&s(`/paper/${a.arxiv_id.replace(/v\d+$/,"")}${D?`?version=${D}`:""}`)},children:Bt.map(u=>e.jsxs("option",{value:u.version,children:[u.version," — ",ys(u.published)]},u.version))})]})]}),e.jsxs("div",{className:"detail-authors",children:[Vt.map((u,D)=>e.jsxs(Ct.Fragment,{children:[u.hf_username?e.jsx("a",{href:`https://huggingface.co/${u.hf_username}`,target:"_blank",rel:"noopener noreferrer",title:`@${u.hf_username} on Hugging Face`,children:u.name}):e.jsx("a",{children:u.name}),DJe&&e.jsx("button",{className:"show-more-authors",onClick:()=>$(u=>!u),style:{marginLeft:8,background:"none",border:"none",cursor:"pointer",color:"var(--accent-text)",fontFamily:"var(--mono)",fontSize:12},children:g?"show fewer":`+${a.authors.length-Je} more`})]}),e.jsxs("div",{className:"action-row",children:[a.url_pdf&&e.jsxs("a",{className:"action-btn",href:a.url_pdf,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(re,{name:"pdf",size:12})," View PDF"]}),a.url_abs&&e.jsx(Ze,{showEdit:a.source==="external"&&l,onEdit:()=>V("source-url"),editAriaLabel:"Edit source URL",children:e.jsxs("a",{className:a.source==="external"&&l?"action-btn-segment action-btn-main":"action-btn",href:a.url_abs,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(re,{name:"external",size:12})," ",qr]})}),Qe.githubUrl&&e.jsx(Ze,{showEdit:l,onEdit:()=>V("repositories"),editAriaLabel:"Edit code repositories",children:e.jsxs("a",{className:"action-btn-segment action-btn-main",href:Qe.githubUrl,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(re,{name:"github",size:12})," Code",Qe.github!=null&&e.jsxs("span",{style:{opacity:.7,marginLeft:4},children:["· ",js(Qe.github)," ★"]})]})}),Ue.length===1?e.jsx(Ze,{showEdit:l,onEdit:()=>V("project-pages"),editAriaLabel:"Edit project pages",children:e.jsxs("a",{className:"action-btn-segment action-btn-main",href:Ue[0].url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(re,{name:"globe",size:12})," Project page"]})}):null,Ue.length>1?e.jsx(Ze,{showEdit:l,onEdit:()=>V("project-pages"),editAriaLabel:"Edit project pages",children:e.jsxs(Zr,{children:[e.jsx(ea,{asChild:!0,children:e.jsxs("button",{type:"button",className:"action-btn-segment action-btn-main",children:[e.jsx(re,{name:"globe",size:12})," Project page"]})}),e.jsx(ta,{align:"start",className:"project-page-menu",children:Ue.map((u,D)=>e.jsx(sa,{asChild:!0,children:e.jsx("a",{href:u.url,target:"_blank",rel:"noopener noreferrer",children:we(u.url,`Project page ${D+1}`)})},u.url))})]})}):null,Ue.length===0&&o?e.jsxs("button",{type:"button",className:"action-btn",onClick:()=>V("project-pages"),title:"Add project page",children:[e.jsx(re,{name:"globe",size:12})," Add project page"]}):null,a.conference_url_abs&&e.jsxs("a",{className:"action-btn",href:a.conference_url_abs,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(re,{name:"external",size:12})," Conference"]}),e.jsx(mi,{paperId:a.id})]}),Hr&&e.jsxs("div",{className:"introduced-banner",children:[e.jsx("span",{className:"introduced-label",children:"Introduced"}),e.jsxs("div",{className:"introduced-methods",children:[Ve.map(u=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>s(`/methods/${u.slug||u.id}`),children:[u.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`method-${u.id}`)),We.map(u=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>s(`/benchmark/${u.slug||u.id}`),children:[u.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`benchmark-${u.id}`))]}),e.jsxs("span",{className:"introduced-note",children:["This paper is the canonical source for ",Br,"."]})]}),Kr&&e.jsxs("div",{className:"introduced-banner lineage-banner",children:[Xe.length>0&&e.jsxs("div",{className:"lineage-row",children:[e.jsx("span",{className:"introduced-label lineage-label",children:Xe.length===1?"Follow-up paper":"Follow-up papers"}),e.jsx("div",{className:"introduced-methods",children:Xe.map(u=>e.jsxs("button",{type:"button",className:"introduced-pill lineage-pill",onClick:()=>s(`/paper/${u.route_identifier}`),children:[u.title,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`successor-${u.id}`))})]}),Ge.length>0&&e.jsxs("div",{className:"lineage-row",children:[e.jsx("span",{className:"introduced-label lineage-label",children:Ge.length===1?"Predecessor paper":"Predecessor papers"}),e.jsx("div",{className:"introduced-methods",children:Ge.map(u=>e.jsxs("button",{type:"button",className:"introduced-pill lineage-pill",onClick:()=>s(`/paper/${u.route_identifier}`),children:[e.jsx("span",{className:"introduced-arrow lineage-arrow-back",children:"←"}),u.title]},`predecessor-${u.id}`))})]})]}),Kt&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section-rule",children:e.jsx("span",{children:"TL;DR · AI-generated"})}),e.jsx("div",{className:"tldr-box",children:Kt})]}),e.jsx("div",{className:"section-rule",children:e.jsx("span",{children:"Abstract"})}),e.jsx("p",{className:"abstract-text",style:{marginBottom:8},children:e.jsx(ia,{text:Ur})}),Ie.length>et&&e.jsx("div",{className:"read-full",onClick:()=>d(u=>!u),children:_?"− collapse abstract":"+ read full abstract"}),e.jsxs("div",{className:"section-rule",children:[e.jsx("span",{children:"Tasks"}),e.jsxs("span",{className:"accent",children:[((Zt=a.tasks)==null?void 0:Zt.length)||0," tagged",e.jsx("button",{type:"button",onClick:()=>V("tasks"),className:"edit-link",children:"edit"})]})]}),e.jsx("div",{className:"paper-tags",style:{marginBottom:8},children:(a.tasks||[]).map(u=>e.jsx(aa,{slug:u.slug||"",label:u.name},u.id))}),e.jsxs("div",{className:"section-rule",children:[e.jsx("span",{children:"Methods"}),e.jsxs("span",{className:"accent",children:[((es=a.methods)==null?void 0:es.length)||0," used",e.jsx("button",{type:"button",onClick:()=>V("methods"),className:"edit-link",children:"edit"})]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:8},children:(a.methods||[]).map(u=>e.jsx(na,{method:u},u.id))}),e.jsxs("div",{className:"section-rule",children:[e.jsx("span",{children:"Results"}),e.jsxs("span",{className:"accent",children:[(I==null?void 0:I.length)||0," benchmarks",e.jsx("button",{type:"button",onClick:()=>V("results"),className:"edit-link",children:"edit"})]})]}),O?e.jsx(qe,{className:"h-32 w-full"}):A.length>0?A.map(u=>e.jsxs("div",{children:[e.jsxs("div",{className:"section-rule",children:[e.jsx("span",{children:u.taskSlug?e.jsx(De,{to:`/tasks/${u.taskSlug}`,children:u.taskName}):u.taskName}),e.jsxs("span",{className:"accent",children:[u.rows.length," ",u.rows.length===1?"result":"results"]})]}),e.jsxs("table",{className:"results-table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"30%"}}),e.jsx("col",{style:{width:"30%"}}),e.jsx("col",{style:{width:"15%"}}),e.jsx("col",{style:{width:"15%"}}),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",{})]})}),e.jsx("tbody",{children:u.rows.map(D=>{var X;return e.jsxs("tr",{children:[e.jsx("td",{className:"benchmark",children:D.dataset_slug?e.jsx(De,{to:`/benchmark/${D.dataset_slug}`,children:D.dataset_name||"—"}):D.dataset_name||"—"}),e.jsx("td",{className:"model",title:D.model_name||void 0,children:D.model_name||"—"}),e.jsx("td",{className:"metric",children:D.best_metric}),e.jsx("td",{className:"value",children:ra((X=D.metrics)==null?void 0:X[D.best_metric||""])}),e.jsx("td",{className:"compare",children:D.dataset_slug&&e.jsx(De,{to:`/benchmark/${D.dataset_slug}?eval=${encodeURIComponent(D.id)}`,children:"Compare →"})})]},D.id)})})]})]},u.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:[(fe.length>0||o)&&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:[fe.length," repo",fe.length===1?"":"s",e.jsx("button",{type:"button",onClick:()=>V("repositories"),className:"edit-link",children:"edit"})]})]}),Mr.map(u=>e.jsxs("a",{href:u.url,target:"_blank",rel:"noopener noreferrer",className:"code-line",style:{textDecoration:"none"},children:[e.jsxs("span",{className:"code-line-repo",children:[e.jsx(re,{name:"github",size:12}),e.jsxs("span",{className:"code-line-repo-name",children:[u.owner,"/",u.name]}),u.is_official&&e.jsx("span",{className:"code-line-official",children:"· Official"})]}),e.jsxs("span",{className:"code-line-stars",children:["★ ",js(u.num_stars)]})]},u.id)),fe.length===0&&o&&e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--ink-faint)",padding:"6px 0"},children:"No GitHub repositories linked yet."}),fe.length>yt&&e.jsx("button",{type:"button",className:"bench-show-more",onClick:()=>H(u=>!u),children:L?"− show top 3":`+ show ${fe.length-yt} more repos`})]}),e.jsx(fi,{viewer:Lr,canEdit:l,onEdit:()=>V("hf-artifacts")}),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:$r,"aria-label":"Copy citation to clipboard",title:"Copy citation to clipboard",children:[e.jsx(re,{name:"copy",size:11}),Tr?"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:Fr})]}),(((ts=T.data)==null?void 0:ts.length)??0)>0&&e.jsxs("div",{className:"sidebar-card",children:[e.jsx("div",{className:"sidebar-card-title",children:"Related papers"}),T.data.map(u=>e.jsxs(De,{to:`/paper/${u.arxiv_id||u.id}`,target:"_blank",rel:"noopener noreferrer",className:"related-paper",style:{textDecoration:"none",color:"inherit"},children:[e.jsx("div",{className:"related-title",children:e.jsx(cs,{title:u.title})}),e.jsxs("div",{className:"related-meta",children:[e.jsx("span",{children:u.arxiv_id?`arXiv:${u.arxiv_id}`:"External resource"}),u.citation_count!=null&&e.jsxs("span",{children:[u.citation_count.toLocaleString()," cites"]})]})]},u.id))]})]})]}),e.jsx(sn,{open:te,onOpenChange:j,paperId:a.id,arxivId:t,initialTaskIds:((ss=a.tasks)==null?void 0:ss.map(u=>parseInt(u.id)))||[],initialTasks:a.tasks||[],submitMode:G,isAuthor:K}),e.jsx(nn,{open:C,onOpenChange:R,paperId:a.id,arxivId:t,initialMethodIds:((rs=a.methods)==null?void 0:rs.map(u=>parseInt(u.id)))||[],initialMethods:a.methods||[],submitMode:G,isAuthor:K}),e.jsx(on,{open:f,onOpenChange:h,paperId:a.id,arxivId:t,initialRepositories:((as=a.repositories)==null?void 0:as.map(u=>({url:u.url,is_official:u.is_official||!1})))||[],submitMode:G,isAuthor:K}),e.jsx(ln,{open:E,onOpenChange:N,paperId:a.id,arxivId:t,initialProjectPages:((ns=a.project_pages)==null?void 0:ns.map(u=>({url:u.url,is_official:u.is_official||!1})))||[],submitMode:G,isAuthor:K}),e.jsx(ii,{open:y,onOpenChange:z,paperId:a.id,arxivId:t,initialEvaluations:I||[],submitMode:G,isAuthor:K}),e.jsx(cn,{open:B,onOpenChange:x,paperId:a.id,arxivId:t,initialUrl:a.source_url??a.url_abs??"",submitMode:G,isAuthor:K}),e.jsx(li,{open:M,onOpenChange:q,paperId:a.id,arxivId:t,initialArtifacts:{hf_models:a.hf_models??[],hf_datasets:a.hf_datasets??[],hf_spaces:a.hf_spaces??[]},submitMode:G,isAuthor:K}),e.jsx(ci,{open:P!==null,onOpenChange:u=>{u||Q(null)},sectionLabel:P?pi[P]:"this paper",returnTo:typeof window<"u"?window.location.pathname:"/"})]})},fi=({viewer:t,canEdit:s=!1,onEdit:r})=>e.jsxs("div",{className:"sidebar-card",children:[e.jsxs("div",{className:"sidebar-card-title",children:[t.paperHref?e.jsx("a",{href:t.paperHref,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:"🤗 Hugging Face"}):e.jsx("span",{children:"🤗 Hugging Face"}),s&&r&&e.jsx("button",{type:"button",onClick:r,className:"edit-link",children:"edit"})]}),t.isLoading?e.jsx(qe,{className:"h-16 w-full"}):e.jsxs(e.Fragment,{children:[t.rows.map(c=>e.jsx(hi,{...c},c.label)),t.footer&&e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink-faint)",marginTop:12},children:t.footer})]})]}),hi=({label:t,href:s,count:r,isLimited:c,links:n})=>{const o=((n==null?void 0:n.length)??0)>0,l=e.jsxs("div",{className:"hf-artifact-row-header",children:[e.jsx("span",{children:t}),e.jsx("span",{style:{fontWeight:600,color:r?"var(--ink)":"var(--ink-faint)"},children:r!=null?`${r}${c?"+":""}`:"—"})]});return o?e.jsxs("div",{className:"hf-artifact-row",children:[l,e.jsx("div",{className:"hf-artifact-links",children:n.map(a=>e.jsx("a",{href:a.href,target:"_blank",rel:"noopener noreferrer",children:a.label},a.href))})]}):e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"hf-artifact-row",children:l})};function jt(t){return t[0]??"https://huggingface.co"}export{Ii as default};