@leostera/evalkit 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -1
- package/dist/cli.mjs +5186 -10301
- package/dist/dashboard/assets/{index-CTJpd8q8.js → index-BEBo_81Y.js} +4 -4
- package/dist/dashboard/assets/index-C24IquYZ.css +2 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/index.d.mts +111 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -8
- package/dist/runner.d.mts +85 -3
- package/dist/runner.d.mts.map +1 -1
- package/dist/runner.mjs +2 -2
- package/dist/skills/evalkit-evals/SKILL.md +1 -1
- package/dist/skills/evalkit-judges/SKILL.md +3 -2
- package/dist/skills/evalkit-results/SKILL.md +1 -1
- package/dist/{src-CKqOzeBi.mjs → src-DhromKNu.mjs} +175 -29
- package/dist/{src-CZPufWN_.mjs → src-b2Wnmzbb.mjs} +53 -3
- package/package.json +1 -1
- package/dist/dashboard/assets/index-YAabTN3X.css +0 -2
|
@@ -28,7 +28,7 @@ Migration example:
|
|
|
28
28
|
- label prop: <Input label='Email' />
|
|
29
29
|
- aria-label: <Input aria-label='Email address' />
|
|
30
30
|
- aria-labelledby for custom label association`)}let p=(0,Y.jsx)(xh,{ref:t,className:J(wh({size:r,variant:d,focusIndicator:!0}),l&&`keeper-ignore`,n),...l?{"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,"data-lpignore":`true`}:{},...u});return a||c||s?(0,Y.jsx)(yh,{label:a,required:f,labelTooltip:o,description:s,error:_h(c),children:p}):p});Th.displayName=`Input`;var Eh={xs:{inputOuter:`px-1.5`,addonOuterStart:`pl-1.5`,addonOuterEnd:`pr-1.5`,addonButtonOuterStart:`pl-1`,addonButtonOuterEnd:`pr-1`,suffixPad:`pr-1.5`,fontSize:`text-xs`,iconSize:10},sm:{inputOuter:`px-2`,addonOuterStart:`pl-1.5`,addonOuterEnd:`pr-1.5`,addonButtonOuterStart:`pl-1`,addonButtonOuterEnd:`pr-1`,suffixPad:`pr-2`,fontSize:`text-xs`,iconSize:13},base:{inputOuter:`px-3`,addonOuterStart:`pl-2`,addonOuterEnd:`pr-2`,addonButtonOuterStart:`pl-1`,addonButtonOuterEnd:`pr-1`,suffixPad:`pr-3`,fontSize:`text-base`,iconSize:18},lg:{inputOuter:`px-4`,addonOuterStart:`pl-2.5`,addonOuterEnd:`pr-2.5`,addonButtonOuterStart:`pl-1.5`,addonButtonOuterEnd:`pr-0.5`,suffixPad:`pr-4`,fontSize:`text-base`,iconSize:20}},Dh={xs:`has-[[data-slot=input-group-addon-start]]:[&_input]:pl-1 has-[[data-slot=input-group-addon-end]]:[&_input]:pr-1`,sm:`has-[[data-slot=input-group-addon-start]]:[&_input]:pl-1.5 has-[[data-slot=input-group-addon-end]]:[&_input]:pr-1.5`,base:`has-[[data-slot=input-group-addon-start]]:[&_input]:pl-2 has-[[data-slot=input-group-addon-end]]:[&_input]:pr-2`,lg:`has-[[data-slot=input-group-addon-start]]:[&_input]:pl-2.5 has-[[data-slot=input-group-addon-end]]:[&_input]:pr-2.5`},Oh=(0,_.createContext)(null),kh=(0,_.createContext)(!1);function Ah(e){let t=(0,_.useContext)(Oh);return t||console.warn(`<InputGroup.${e}> must be used within <InputGroup>. Falling back to default values.`),t}function jh(e){let t=[],n=[];return _.Children.forEach(e,e=>{(0,_.isValidElement)(e)&&e.type?.displayName===`InputGroup.Button`?n.push(e):t.push(e)}),{containerZone:t,individualZone:n}}function Mh(e){let t=!1,n=!1;return _.Children.forEach(e,e=>{if(!(0,_.isValidElement)(e))return;let r=e.type,i=typeof r==`function`||typeof r==`object`?r.displayName:void 0;if(i===`InputGroup.Addon`){n=!0;return}if(i!==`InputGroup.Button`)return;let a=e.props.variant;a!==void 0&&a!==`ghost`&&(t=!0)}),t&&n?`hybrid`:t?`individual`:`container`}var Nh=(0,_.forwardRef)((e,t)=>{let n=Ah(`Input`);n&&(e.size!==void 0&&console.warn("InputGroup.Input: Set `size` on <InputGroup> instead of <InputGroup.Input>."),e.disabled!==void 0&&console.warn("InputGroup.Input: Set `disabled` on <InputGroup> instead of <InputGroup.Input>."),e.label!==void 0&&console.warn("InputGroup.Input: Use the `label` prop on <InputGroup> instead of <InputGroup.Input>."),e.description!==void 0&&console.warn("InputGroup.Input: Use <InputGroup.Suffix> instead of passing `description` to <InputGroup.Input>."));let r=Eh[n?.size??`base`],i=n?.focusMode===`individual`,a=!!n?.error,o=e.id??n?.inputId;return(0,Y.jsx)(Th,{ref:t,size:n?.size,disabled:n?.disabled||e.disabled,"aria-invalid":a||e[`aria-invalid`],...e,id:o,className:J(`flex h-full min-w-0 grow items-center rounded-none border-0 bg-transparent font-sans`,r.inputOuter,`text-ellipsis`,i?`relative ring-0 focus:ring-0 border border-kumo-line first:rounded-l-[inherit] last:rounded-r-[inherit] not-first:-ml-px hover:z-1 hover:border-kumo-line focus:z-2 focus:border-kumo-focus/50`:`relative z-1 shadow-none ring-0! outline-none focus:ring-0! focus:outline-none`,e.className)})});Nh.displayName=`InputGroup.Input`;var Ph={xs:`xs`,sm:`xs`,base:`sm`,lg:`base`},Fh=(0,_.forwardRef)(({children:e,className:t,variant:n,size:r,disabled:i,tooltip:a,tooltipSide:o=`bottom`,icon:s,...c},l)=>{let u=Ah(`Button`),d=(0,_.useContext)(kh),f=i??u?.disabled,p=u?.focusMode===`individual`||u?.focusMode===`hybrid`;u&&(n??`ghost`)===`ghost`&&!d&&console.warn(`InputGroup.Button: Ghost buttons should be wrapped in <InputGroup.Addon> for correct spacing.`),u&&r!==void 0&&console.warn("InputGroup.Button: Set `size` on <InputGroup> instead of <InputGroup.Button>.");let m=typeof a==`string`&&!c[`aria-label`]?a:void 0,h=u?Eh[u.size??`base`].iconSize:void 0,g=s&&h&&(typeof s==`function`||typeof s==`object`&&s&&!_.isValidElement(s))?_.createElement(s,{size:h}):s,v=(0,Y.jsx)(kp,{ref:l,type:`button`,disabled:f,"aria-label":m,...c,icon:g,variant:n??`ghost`,size:r??(p?u?.size??`sm`:Ph[u?.size??`base`]??`sm`),className:J(`pointer-events-auto`,`shadow-none`,`focus:ring-0`,!p&&`focus-visible:ring-[1.5px] focus-visible:ring-kumo-focus/50`,p&&[`relative h-full! rounded-none border border-kumo-line ring-0 focus-visible:ring-0`,`first:rounded-l-[inherit] last:rounded-r-[inherit]`,`not-first:-ml-px`,`hover:z-1`,`focus:z-2`,`focus-visible:border-kumo-focus/50`,`disabled:bg-kumo-overlay disabled:text-kumo-inactive!`],t),children:e});return a?(0,Y.jsx)(Yd,{content:a,side:o,asChild:!0,children:v}):v});Fh.displayName=`InputGroup.Button`;var Ih=(0,_.forwardRef)(({align:e=`start`,className:t,children:n},r)=>{let i=Eh[Ah(`Addon`)?.size??`base`],a=!1,o=_.Children.map(n,e=>(0,_.isValidElement)(e)?e.type===Fh?(a=!0,e):e.props.size===void 0?(0,_.cloneElement)(e,{size:i.iconSize}):e:e);return(0,Y.jsx)(`div`,{ref:r,"data-slot":e===`start`?`input-group-addon-start`:`input-group-addon-end`,className:J(`pointer-events-none relative z-[1] flex shrink-0 items-center gap-1.5`,`text-kumo-subtle`,i.fontSize,`*:pointer-events-auto`,e===`start`?J(`-order-1`,a?i.addonButtonOuterStart:i.addonOuterStart,`pr-0`):J(`order-1`,`pl-0`,a?i.addonButtonOuterEnd:i.addonOuterEnd),t),children:(0,Y.jsx)(kh.Provider,{value:!0,children:o})})});Ih.displayName=`InputGroup.Addon`;var Lh=(0,_.forwardRef)(({className:e,children:t},n)=>{let r=Eh[Ah(`Suffix`)?.size??`base`];return(0,Y.jsx)(`div`,{ref:n,"data-slot":`input-group-suffix`,className:J(`pointer-events-none flex min-w-0 grow items-center text-kumo-subtle select-none`,r.fontSize,r.suffixPad,e),children:(0,Y.jsx)(`span`,{className:`truncate`,children:t})})});Lh.displayName=`InputGroup.Suffix`;var Rh=(0,_.forwardRef)(({size:e=`base`,children:t,className:n,disabled:r=!1,label:i,description:a,error:o,required:s,labelTooltip:c,...l},u)=>{let d=(0,_.useId)(),f=Mh(t),p=(0,_.useMemo)(()=>({size:e,focusMode:f,disabled:r,error:o,inputId:d}),[e,f,r,o,d]),m=J(`relative w-full cursor-text`,wh({size:e}),`data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,f===`container`?[`overflow-hidden`,`focus-within:ring-[1.5px] focus-within:ring-kumo-focus/50`]:`isolate overflow-visible shadow-none ring-0`,`has-[input[aria-invalid=true]]:ring-kumo-danger`,`px-0`,`flex items-center gap-0`,`has-[[data-slot=input-group-suffix]]:[&_input]:[field-sizing:content]`,`has-[[data-slot=input-group-suffix]]:[&_input]:max-w-full`,`has-[[data-slot=input-group-suffix]]:[&_input]:grow-0`,`has-[[data-slot=input-group-suffix]]:[&_input]:pr-0`,Dh[e],`!mb-0`,n),h={"data-slot":`input-group`,"data-focus-mode":f,"data-disabled":r?``:void 0};if(f===`hybrid`){let{containerZone:n,individualZone:r}=jh(t),f={...p,focusMode:`container`},g=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Oh.Provider,{value:f,children:(0,Y.jsxs)(`div`,{"data-slot":`input-group-container-zone`,className:J(wh({size:e}),`overflow-hidden`,`has-[input[aria-invalid=true]]:ring-kumo-danger`,`px-0`,`flex min-w-0 flex-1 items-center gap-0`,`shadow-none ring-0`,`border border-kumo-line`,`focus-within:border-kumo-focus/50`,`focus-within:z-2`,`not-first:-ml-px`,`rounded-none first:rounded-l-[inherit] last:rounded-r-[inherit]`,Dh[e],`has-data-[slot=input-group-suffix]:[&_input]:field-sizing-content`,`has-data-[slot=input-group-suffix]:[&_input]:max-w-full`,`has-data-[slot=input-group-suffix]:[&_input]:grow-0`,`has-data-[slot=input-group-suffix]:[&_input]:pr-0`),children:[i&&(0,Y.jsx)(`label`,{htmlFor:d,className:`absolute inset-0 z-0 mb-0! cursor-text`,"aria-hidden":`true`}),n]})}),r]}),_=(0,Y.jsx)(Oh.Provider,{value:p,children:(0,Y.jsx)(`div`,{ref:u,...h,className:m,...l,children:g})});return i?(0,Y.jsx)(yh,{label:i,description:a,error:o,required:s,labelTooltip:c,children:_}):_}let g=!i&&f===`container`,v=(0,Y.jsx)(Oh.Provider,{value:p,children:i?(0,Y.jsxs)(`div`,{ref:u,...h,className:m,...l,children:[(0,Y.jsx)(`label`,{htmlFor:d,className:`absolute inset-0 z-0 mb-0!`,"aria-hidden":`true`}),t]}):g?(0,Y.jsx)(`label`,{ref:u,...h,className:J(m,`mb-0!`),...l,children:t}):(0,Y.jsx)(`div`,{ref:u,...h,className:m,...l,children:t})});return i?(0,Y.jsx)(yh,{label:i,description:a,error:o,required:s,labelTooltip:c,children:v}):v});Rh.displayName=`InputGroup`;var zh=(0,_.forwardRef)((e,t)=>(0,Y.jsx)(Ih,{ref:t,align:`start`,...e}));zh.displayName=`InputGroup.Label`;var Bh=(0,_.forwardRef)((e,t)=>(0,Y.jsx)(Lh,{ref:t,...e}));Bh.displayName=`InputGroup.Description`;var Vh=Object.assign(Rh,{Input:Nh,Button:Fh,Addon:Ih,Suffix:Lh,Label:zh,Description:Bh}),Hh={variant:{heading:{classes:`text-lg font-semibold`,description:`Heading text (16px by default, 20px at large size)`},heading1:{classes:`text-3xl font-semibold`,description:`Deprecated large heading for page titles; use heading instead`},heading2:{classes:`text-2xl font-semibold`,description:`Deprecated medium heading for section titles; use heading instead`},heading3:{classes:`text-lg font-semibold`,description:`Deprecated small heading for subsections; use heading instead`},body:{classes:`text-kumo-default`,description:`Default body text`},secondary:{classes:`text-kumo-subtle`,description:`Muted text for secondary information`},success:{classes:`text-kumo-link`,description:`Success state text`},error:{classes:`text-kumo-danger`,description:`Error state text`},mono:{classes:`font-mono`,description:`Monospace text for code`},"mono-secondary":{classes:`font-mono text-kumo-subtle`,description:`Muted monospace text`}},size:{xs:{classes:`text-xs/[inherit]`,description:`Extra small text`},sm:{classes:`text-sm/[inherit]`,description:`Small text`},base:{classes:`text-base/[inherit]`,description:`Default text size`},lg:{classes:`text-lg/[inherit]`,description:`Large text`}}},Uh={variant:`body`,size:`base`},Wh=[`heading1`,`heading2`,`heading3`];function Gh(e){return Wh.includes(e)}function Kh(e,t){return e===`heading`?t===`lg`?`text-xl`:``:Gh(e)?``:[`mono`,`mono-secondary`].includes(e)?t===`lg`?Hh.size.base.classes:Hh.size.sm.classes:yr(Hh.size,t,Uh.size).classes}function qh({variant:e=`body`,bold:t=!1,size:n=`base`,truncate:r=!1,children:i,DANGEROUS_className:a,DANGEROUS_style:o,as:s,...c},l){let u=[`body`,`secondary`,`success`,`error`].includes(e),d=(0,_.useMemo)(()=>s||([`mono`,`mono-secondary`].includes(e)||e===`heading`||Gh(e)?`span`:`p`),[e,s]);return(0,Y.jsx)(d,{ref:l,className:J(`text-kumo-default`,yr(Hh.variant,e,Uh.variant).classes,Kh(e,n),u&&t?`font-medium`:``,r&&`min-w-0 truncate`,a),style:o,...c,children:i})}var Jh=(0,_.forwardRef)(qh),Yh=0;function Xh(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(Yh);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),Kr;let o=requestAnimationFrame(a);return Yh=o,()=>{Yh===o&&(cancelAnimationFrame(o),Yh=0)}}var Zh=`data-base-ui-inert`,Qh=new WeakMap,$h=new WeakSet,eg=new WeakMap,tg=0;function ng(e){return e?Wi(e)?e.host:ng(e.parentNode):null}var rg=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=ng(t);return e.contains(n)?n:null}).filter(e=>e!=null),ig=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},ag=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{Ri(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function og(e,t,n,{mark:r=!0}){let i=rg(t,e),a=r?ag(t,ig(i),new Set(i)):[],o=[],s=[];if(n){let e=rg(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);ag(t,ig(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(Qh.get(e)||0)+1;Qh.set(e,r),o.push(e),r===1&&n&&$h.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=(eg.get(e)||0)+1;eg.set(e,t),s.push(e),t===1&&e.setAttribute(Zh,``)}),tg+=1,()=>{o.forEach(e=>{let t=(Qh.get(e)||0)-1;Qh.set(e,t),t||($h.has(e)||e.removeAttribute(`aria-hidden`),$h.delete(e))}),r&&s.forEach(e=>{let t=(eg.get(e)||0)-1;eg.set(e,t),t||e.removeAttribute(Zh)}),--tg,tg||(Qh=new WeakMap,$h=new WeakSet,eg=new WeakMap)}}function sg(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=Bs(e[0]).body;return og(e,i,n,{mark:r})}function cg(e,t){let n=zi(as(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||($o(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var lg=20,ug=[];function dg(){ug=ug.filter(e=>e.deref()?.isConnected)}function fg(e){dg(),e&&Ri(e)!==`body`&&(ug.push(new WeakRef(e)),ug.length>lg&&(ug=ug.slice(-20)))}function pg(){return dg(),ug[ug.length-1]?.deref()}function mg(e){return e?cc(e)?e:uc(e)[0]||e:null}function hg(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=lc(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return cc(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function gg(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,explicitReturnFocus:o,restoreFocus:s=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:h}=e,g=t.useState(`open`),v=t.useState(`domReferenceElement`),y=t.useState(`floatingElement`),{events:b,dataRef:x}=t.context,S=Q(()=>x.current.floatingContext?.nodeId),C=i===!1,w=Ls(v)&&C,T=Bl(i),E=Bl(a),D=Bl(o),O=Bl(u),k=Bl(g),A=Qc(m),j=bl(),M=_.useRef(!1),N=_.useRef(!1),P=_.useRef(!1),F=_.useRef(null),I=_.useRef(``),L=_.useRef(``),R=_.useRef(null),z=_.useRef(null),B=Nr(R,p,j?.beforeInsideRef),V=Nr(z,j?.afterInsideRef),H=zl(),U=zl(),ee=Kl(),te=j!=null,W=zs(y),ne=Q((e=W)=>e?uc(e):[]),re=Q(()=>h?.().filter(e=>e!=null)??[]);_.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&Z(W,rs(Bs(W)))&&ne().length===0&&!w&&Zo(e)}return Pc(Bs(W),`keydown`,e)},[r,W,c,w,ne]),_.useEffect(()=>{if(r||!g)return;let e=Bs(W);function t(){P.current=!1}function n(e){let t=as(e),n=re(),r=Z(y,t)||Z(v,t)||Z(j?.portalNode,t)||n.some(e=>e===t||Z(e,t));P.current=!r,L.current=e.pointerType||`keyboard`,is(t,`[data-base-ui-click-trigger]`)&&(N.current=!0,U.start(0,()=>{N.current=!1}))}function i(){L.current=`keyboard`}return Fc(Pc(e,`pointerdown`,n,!0),Pc(e,`pointerup`,t,!0),Pc(e,`pointercancel`,t,!0),Pc(e,`keydown`,i,!0),t)},[r,y,v,W,g,j,U,re]),_.useEffect(()=>{if(r||!l)return;let e=Bs(W);function n(){N.current=!0,U.start(0,()=>{N.current=!1})}function i(e){let t=as(e);cc(t)&&(F.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=as(n);c&&r==null&&a!=null&&Z(y,a)&&fg(a),queueMicrotask(()=>{let o=S(),l=t.context.triggerElements,u=re(),p=r?.hasAttribute(ml(`focus-guard`))&&[R.current,z.current,j?.beforeInsideRef.current,j?.afterInsideRef.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,Jl(f),Jl(d)].includes(r),m=!(Z(v,r)||Z(y,r)||Z(r,y)||Z(j?.portalNode,r)||u.some(e=>e===r||Z(e,r))||l.hasMatchingElement(e=>Z(e,r))||p||A&&(eu(A.nodesRef.current,o).find(e=>Z(e.context?.elements.floating,r)||Z(e.context?.elements.domReference,r))||tu(A.nodesRef.current,o).find(e=>[e.context?.elements.floating,zs(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===v&&W&&hg(W),s&&i!==v&&!Js(a)&&rs(e)===e.body){if(Ui(W)&&(W.focus(),s===`popup`)){ee.request(()=>{W.focus()});return}let e=ne(),t=F.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||W;Ui(n)&&n.focus()}x.current.insideReactTree?x.current.insideReactTree=!1:(w||!c)&&r&&m&&!N.current&&(w||r!==pg())&&(M.current=!0,t.setOpen(!1,vc(Tc,n)))})}function o(){P.current||(x.current.insideReactTree=!0,H.start(0,()=>{x.current.insideReactTree=!1}))}let u=Ui(v)?v:null;if(y||u)return Fc(u&&Pc(u,`focusout`,a),u&&Pc(u,`pointerdown`,n),y&&Pc(y,`focusin`,i),y&&Pc(y,`focusout`,a),y&&j&&Pc(y,`focusout`,o,!0))},[r,v,y,W,c,A,j,t,l,s,ne,w,S,x,H,U,ee,d,f,re]),_.useEffect(()=>{if(r||!y||!g)return;let e=Array.from(j?.portalNode?.querySelectorAll(`[${ml(`portal`)}]`)||[]),t=(A?tu(A.nodesRef.current,S()):[]).find(e=>Ls(e.context?.elements.domReference||null))?.context?.elements.domReference,n=sg([y,...e,R.current,z.current,j?.beforeOutsideRef.current,j?.afterOutsideRef.current,...re(),t,Jl(f),Jl(d),w?v:null].filter(e=>e!=null),{ariaHidden:c||w,mark:!1}),i=sg([y,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,v,y,c,j,w,A,S,d,f,re]),X(()=>{if(!g||r||!Ui(W))return;I.current=``,L.current=``;let e=Bs(W),t=rs(e);queueMicrotask(()=>{let n=T.current,r=typeof n==`function`?n(O.current||``):n;if(r===void 0||r===!1||Z(W,t))return;let i=null,a=()=>(i??=ne(W),i[0]||W),o;o=r===!0||r===null?a():Jl(r),o||=a();let s=Z(W,rs(e)),c=x.current.openEvent,l=c?.type===`mousedown`&&$o(c);Xh(o,{sync:l,preventScroll:o===W,shouldFocus(){if(!k.current)return!1;if(s)return!0;let t=rs(e);return!(t!==o&&Z(W,t))}})})},[r,g,W,ne,T,O,k,x]);let ie=_.useRef(null);X(()=>{if(r||!W){ie.current=null;return}ie.current&&=(ie.current.cancelled=!0,null);let e=Bs(W),t=rs(e),n=O.current==null;fg(t);function i(e){if(e.open||(I.current=cg(e.nativeEvent,L.current)),(e.reason===`focus-out`&&e.triggerElement?.hasAttribute(ml(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(M.current=!0),e.reason===`outside-press`){if(e.nested)M.current=!1;else if($o(e.nativeEvent)||es(e.nativeEvent))M.current=!1;else{let e=!1;Bs(W).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?M.current=!1:M.current=!0}}}b.on(`openchange`,i);function a(e){let r=E.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=v?.isConnected?v:null,o=t?.isConnected&&Ri(t)!==`body`?t:null,s=n?o||a:a||o;return s||=pg()||null,typeof i==`boolean`?s:Jl(i)||s||null}return()=>{b.off(`openchange`,i);let t=rs(e),n=re(),r=Z(y,t)||n.some(e=>e===t||Z(e,t))||A&&eu(A.nodesRef.current,S(),!1).some(e=>Z(e.context?.elements.floating,t)),o=E.current,s=I.current,c=a(s),l={cancelled:!1};ie.current=l,queueMicrotask(()=>{ie.current===l&&(ie.current=null);let n=mg(c),i=D.current??typeof o!=`boolean`;if(!l.cancelled&&o&&!M.current&&Ui(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}M.current=!1})}},[r,y,W,E,D,O,b,A,v,S,re]),X(()=>{if(!_c||g||!y)return;let e=rs(Bs(y));Ui(e)&&Fs(e)&&Z(y,e)&&e.blur()},[g,y]),X(()=>{if(!r&&j)return j.setFocusManagerState({modal:c,closeOnFocusOut:l,open:g,onOpenChange:t.setOpen,domReference:v}),()=>{j.setFocusManagerState(null)}},[r,j,c,g,t,l,v]),X(()=>{if(!r&&W)return hg(W),()=>{queueMicrotask(dg)}},[r,W]);let ae=!r&&(!c||!w)&&(te||c);return(0,Y.jsxs)(_.Fragment,{children:[ae&&(0,Y.jsx)(pl,{"data-type":`inside`,ref:B,onFocus:e=>{if(c){let e=ne();Xh(e[e.length-1])}else j?.portalNode&&(M.current=!1,mc(e,j.portalNode)?fc(v)?.focus():Jl(f??j.beforeOutsideRef)?.focus())}}),n,ae&&(0,Y.jsx)(pl,{"data-type":`inside`,ref:V,onFocus:e=>{c?Xh(ne()[0]):j?.portalNode&&(l&&(M.current=!0),mc(e,j.portalNode)?pc(v)?.focus():Jl(d??j.afterOutsideRef)?.focus())}})]})}function _g(e){let t=_.useRef(``),n=_.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:_.useCallback(n=>{n.detail===0?e(n,`keyboard`):(`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``)},[e]),onPointerDown:n}}function vg(e,t){let{onClick:n,onPointerDown:r}=_g(Q((n,r)=>{(typeof e==`function`?e():e)||t(r||(Go?`touch`:``))}));return _.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function yg(e){let[t,n]=_.useState(null),r=vg(e,n);return Am(e,t=>{t&&!e&&n(null)}),_.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}var bg=_.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,Y.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});bg.displayName=`InternalBackdrop`;var xg={},Sg={},Cg=``;function wg(e,t){return Gi(e)?e:t}function Tg(e,t,n){return/hidden|clip/.test(e.getComputedStyle(wg(t,n)).overflowY)}function Eg(e){if(typeof document>`u`)return!1;let t=Bs(e);return zi(t).innerWidth-t.documentElement.clientWidth>0}function Dg(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=Bs(e),n=t.documentElement,r=t.body,i=wg(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function Og(e){let t=Bs(e),n=t.documentElement,r=t.body,i=wg(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function kg(e){let t=Bs(e),n=t.documentElement,r=t.body,i=zi(n),a=0,o=0,s=!1,c=Gl.create();if(_c&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,xg={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Cg=n.style.scrollBehavior,Sg={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=wg(n,r);s=Dg(e),s?(n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`):(Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`)}function u(){Object.assign(n.style,xg),Object.assign(r.style,Sg),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=Cg)}function d(){u(),c.request(l)}l();let f=Pc(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var Ag=new class{lockCount=0;restore=null;timeoutLock=Rl.create();timeoutUnlock=Rl.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=Bs(e),n=t.documentElement,r=t.body,i=zi(n);if(Tg(i,n,r)){let t=new i.MutationObserver(()=>{Tg(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Go||!Eg(e);this.restore=a?Og(e):kg(e)}};function jg(e=!0,t=null){X(()=>{if(e)return Ag.acquire(t)},[e,t])}function Mg(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=bc}=t,l=e.context.dataRef,u=_.useRef(void 0),d=Kl(),f=zl(),p=_.useMemo(()=>{function t(t,n,r,i){let a=vc(c,n,r);t&&i===`touch`&&s>0?f.start(s,()=>{e.setOpen(!0,a)}):e.setOpen(t,a)}function n(t,n,r){let a=l.current.openEvent,s=e.select(`domReferenceElement`)!==n;return t&&s||!t||!i?!0:a&&(typeof o==`function`?o():o)?!r(a.type):!1}return{onPointerDown(e){u.current=ts(e.pointerType,!0)&&es(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||ts(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=as(s),p=Fs(f);if(p||o===`virtual`){t(l,s,p?f:i.currentTarget,o);return}let m=i.currentTarget;d.request(()=>{t(l,s,m,o)})},onClick(i){if(r===`mousedown-only`)return;let o=u.current;r===`mousedown`&&o?u.current=void 0:ts(o,!0)&&a||t(n(e.select(`open`),i.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),i.nativeEvent,i.currentTarget,o)},onKeyDown(){u.current=void 0}}},[l,r,a,c,e,o,i,d,f,s]);return _.useMemo(()=>n?{reference:p}:Jr,[n,p])}function Ng(e){return _c&&e.movementX===0&&e.movementY===0}function Pg(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function Fg(e,t){return Pg(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Ig(e,t,n){return Pg(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Lg(e,t,n){return Pg(t,n?e===cs:e===ls,e===ds)}function Rg(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Pg(t,n?e===ls:e===cs,e===us)}function zg(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,triggerOrientation:v=g,parentOrientation:y,id:b,resetOnPointerLeave:x=!0,externalTree:S,nestedReturnFocusRef:C,grid:w}=t,T=w!=null;s&&(c||console.warn("`useListNavigation` looping must be enabled to allow escaping."),d||console.warn("`useListNavigation` must be virtual to allow escaping.")),g===`vertical`&&T&&console.warn("In grid list navigation mode, the `orientation` should",`be either "horizontal" or "both".`);let E=e.useState(`open`),D=e.useState(`floatingElement`),O=e.useState(`domReferenceElement`),k=e.context.dataRef,A=zs(D),j=Ls(O),M=Bl(A),N=Zc(),P=Qc(S),F=_.useRef(f),I=_.useRef(o??-1),L=_.useRef(null),R=_.useRef(!0),z=Q(e=>{i(I.current===-1?null:I.current,e)}),B=_.useRef(!!D),V=_.useRef(E),H=_.useRef(!1),U=_.useRef(!1),ee=_.useRef(null),te=Bl(h),W=Bl(E),ne=Bl(o),re=Bl(x),ie=Kl(),ae=Kl(),G=Q(()=>{ie.cancel();function e(e){d||(ee.current=Xh(e,{sync:H.current,preventScroll:!0}))}let t=n.current[I.current],r=U.current;t&&e(t),(H.current?e=>e():e=>ie.request(e))(()=>{let i=n.current[I.current]||t;i&&(t||e(i),ue&&(r||!R.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});X(()=>{k.current.orientation=g},[k,g]),X(()=>{E||(L.current=null),E&&f===`auto`||(F.current=f)},[E,f]),X(()=>{a&&(E&&D?(I.current=o??-1,F.current&&o!=null&&(U.current=!0,z())):B.current&&(I.current=-1,z()))},[a,E,D,o,z]),X(()=>{if(a){if(!E)H.current=!1;else if(D){if(r==null){if(H.current=!1,ne.current!=null)return;if(B.current&&(I.current=-1,G()),(!V.current||!B.current)&&F.current&&(L.current!=null||F.current===!0&&L.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ae.request(e):queueMicrotask)(t),e+=1):(I.current=L.current==null||Ig(L.current,v,u)||l?Hs(n):Us(n),L.current=null,z())};t()}}else Vs(n.current,r)||(I.current=r,G(),U.current=!1)}}},[a,E,D,r,ne,l,n,v,u,z,G,ae]),X(()=>{if(!a||D||!P||d||!B.current)return;let e=P.nodesRef.current,t=e.find(e=>e.id===N)?.context?.elements.floating,n=rs(Bs(O??t??null)),r=e.some(e=>e.context&&Z(e.context.elements.floating,n));t&&!r&&R.current&&t.focus({preventScroll:!0})},[a,D,O,P,N,d]),X(()=>{V.current=E,B.current=!!D});let K=r!=null,oe=Q(e=>{if(!W.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(I.current!==t||r!==t)&&(I.current=t,z(e))}),se=Q(()=>y??P?.nodesRef.current.find(e=>e.id===N)?.context?.dataRef?.current.orientation),ce=Q(()=>Hs(n,te.current)),le=Q(t=>{if(R.current=!1,H.current=!0,t.which===229||!W.current&&t.currentTarget===M.current)return;if(l&&Rg(t.key,g,u,T)){Fg(t.key,se())||Zo(t),e.setOpen(!1,vc(Dc,t.nativeEvent));let n=C?.current??O;Ui(n)&&n.focus();return}r!=null&&r!==I.current&&!Vs(n.current,r)&&(I.current=r);let i=I.current,a=Hs(n,h),o=Us(n,h);if(j||(t.key===`Home`&&(Zo(t),I.current=a,z(t)),t.key===`End`&&(Zo(t),I.current=o,z(t))),w!=null){let e=w(t,I.current,n,g,c,u,h,a,o);if(e!=null&&e!==I.current&&(I.current=e,z(t)),g===`both`)return}if(Fg(t.key,g)){Zo(t);let e=rs(t.currentTarget.ownerDocument);if(E&&!d&&Z(t.currentTarget,e)&&!n.current.some(t=>t!=null&&Z(t,e))){I.current=Ig(t.key,g,u)?a:o,z(t),r===I.current&&G();return}let{index:l,wrapped:f}=Ws(n.current,i,{decrement:!Ig(t.key,g,u),loopFocus:c,allowEscape:s,disabledIndices:h,minIndex:a,maxIndex:o});f&&(H.current=!1),I.current=l,z(t)}}),ue=_.useMemo(()=>({onFocus(e){H.current=!0,oe(e)},onClick({currentTarget:e}){d||e.focus({preventScroll:!0})},onMouseMove(e){Ng(e)||(H.current=!0,U.current=!1,p&&oe(e))},onPointerLeave(e){if(!W.current||!R.current||e.pointerType===`touch`)return;H.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&re.current&&(ee.current?.(),ee.current=null,I.current=-1,z(e),!d)){let e=M.current,t=rs(Bs(e));e&&Z(e,t)&&e.focus({preventScroll:!0})}}}),[oe,W,M,p,n,z,re,d]),q=_.useMemo(()=>d&&E&&K&&{"aria-activedescendant":`${b}-${r}`},[d,E,K,b,r]),de=_.useMemo(()=>({...j?{}:q,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&E&&!d){let n=as(t.nativeEvent);if(n&&!Z(M.current,n))return;Zo(t);let r=vc(Tc,t.nativeEvent);e.setOpen(!1,r);let i=C?.current??O;!r.isCanceled&&Ui(i)&&i.focus()}else le(t)},onPointerMove(e){Ng(e)||(R.current=!0)}}),[q,le,M,j,e,E,d,O,C]),fe=_.useMemo(()=>{function t(t){e.setOpen(!0,vc(Dc,t.nativeEvent,t.currentTarget))}function n(e){f===`auto`&&$o(e.nativeEvent)&&(F.current=!d)}function r(e){F.current=f,f===`auto`&&es(e.nativeEvent)&&(F.current=!0)}return{onKeyDown(n){let r=e.select(`open`);R.current=!1;let i=n.key.startsWith(`Arrow`),a=Lg(n.key,se(),u),o=Fg(n.key,r?g:v),s=(l?a:o)||n.key===`Enter`||n.key.trim()===``;if(d&&r&&(!l||Fs(n.currentTarget)))return le(n);if(r||m||!i){if(s){let e=Fg(n.key,se());L.current=l&&e?null:n.key}l?a&&(Zo(n),r?(I.current=ce(),z(n),d&&M.current?.focus()):t(n)):o&&(ne.current!=null&&(I.current=ne.current),Zo(n),!r&&m?t(n):le(n),r&&z(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!d&&(I.current=-1,z(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[le,f,ce,l,z,e,m,g,v,se,u,ne,d,M]),pe=_.useMemo(()=>({...q,...fe}),[q,fe]);return _.useMemo(()=>a?{reference:pe,floating:de,item:ue,trigger:fe}:{},[a,pe,de,fe,ue])}function Bg(e){let t=_.useRef(!0);t.current&&(t.current=!1,e())}var Vg=(e,t)=>Object.is(e,t);function Hg(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Ug(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Nm(e,t,(e,t)=>Hg(e,t,n)):e!==t}function Wg(e,t,n){return e?e.some(e=>e!==void 0&&Hg(t,e,n)):!1}function Gg(e,t,n){return e?e.findIndex(e=>e!==void 0&&Hg(e,t,n)):-1}function Kg(e,t){if(t!==Vg)return n=>Wg(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function qg(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(Kg(t,n)):Gg(e,t,n);return i===-1?null:i}function Jg(e,t,n,r,i,a){return Wg(r,t,i)?a!=null&&e>a&&Wg(r,n[a],i)?a:e:e===a?qg(n,r,i,!0):a}function Yg(e,t,n){return e.filter(e=>!Hg(t,e,n))}function Xg(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function Zg(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function Qg(e){return Zg(e?.[0])}function $g(e){return Qg(e)?e.flatMap(e=>e.items):e}function e_(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(Qg(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function t_(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return Xg(e)}function n_(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?Xg(e.value):Xg(e)}function r_(e,t,n){function r(){return t_(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=$g(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function i_(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,Y.jsx)(_.Fragment,{children:r_(r,t,n)},i)),e),[])}var a_=_.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});a_.displayName=`CompositeListContext`;function o_(){return _.useContext(a_)}function s_(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Q(i),[,o]=_.useState(0),s=Mr(l_).current,c=Mr(c_).current,l=_.useRef(0),u=_.useRef(!0),d=_.useRef(null),f=_.useRef(null),p=Q(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=Q((e,t)=>{c.set(e,t),p()}),h=Q(e=>{c.delete(e),p()}),g=Q(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function v(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!f_(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&p_(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=d_(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let y=Q(()=>{let[e,t]=u_(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});v(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});X(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),X(()=>{u.current&&y()}),X(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let b=Q(e=>(s.add(e),()=>{s.delete(e)})),x=_.useMemo(()=>({register:m,unregister:h,subscribeMapChange:b,nextIndexRef:l}),[m,h,b,l]);return(0,Y.jsx)(a_.Provider,{value:x,children:t})}function c_(){return new Map}function l_(){return new Set}function u_(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>p_(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function d_(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function f_(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function p_(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function m_(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=o_(),u=_.useRef(-1),[d,f]=_.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=_.useRef(null),h=_.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return X(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}function h_(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=Q(s),f=e.useState(`open`),p=zl(),m=_.useRef(``),h=_.useRef(u??i??-1),g=_.useRef(null),v=Q(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!Js(n)||n?.matches(`:disabled`)?!1:o==null||!Ks(qr,e,o)}function c(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&s(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(Zo(e),d?.(!0)),m.current.length>0&&m.current[0]!==` `&&c(_,m.current)===-1&&e.key!==` `&&d?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(Zo(e),d?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&s(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,d?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=c(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,d?.(!1)):(a?.(b,e),g.current=b)}),y=Q(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);Z(r,n)||Z(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});X(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let b=_.useMemo(()=>({onKeyDown:v,onBlur:y}),[v,y]);return _.useMemo(()=>c?{reference:b,floating:b}:{},[c,b])}function g_(e){return e==null?void 0:`${e}-label`}function __(e,t){return e??t}var v_=5;function y_(e,t){let n=b_(t);return e.clientX>=n.left-v_&&e.clientX<=n.right+v_&&e.clientY>=n.top-v_&&e.clientY<=n.bottom+v_}function b_(e){let t=e.getBoundingClientRect(),n=zi(e);if(Xo)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}var x_=_.memo(_.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a,selected:o,...s}=e,c=_.useRef(null),{transitionStatus:l,setMounted:u}=$l(o),d=fi(`span`,e,{ref:[t,c],state:{selected:o,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:gs});return Ql({batch:!0,enabled:!o,open:o,ref:c,onComplete(){o||u(!1)}}),d}));x_.displayName=`ItemIndicator`;var S_=20;function C_(e,t,n,r){let[i,a]=_.useState(!1);X(()=>{if(!e||!t||n==null){a(!1);return}let r=Bs(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-S_)},[e,t,n]),jg(e&&(!t||i),r)}var w_=_.createContext(void 0);w_.displayName=`ToolbarRootContext`;function T_(e){let t=_.useContext(w_);if(t===void 0&&!e)throw Error(`Base UI: ToolbarRootContext is missing. Toolbar parts must be placed within <Toolbar.Root>.`);return t}function E_(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var D_=`ArrowUp`,O_=`ArrowDown`,k_=`ArrowLeft`,A_=`ArrowRight`,j_=new Set([D_,O_,k_,A_,`Home`,`End`]),M_=[`Shift`,`Control`,`Alt`,`Meta`];function N_(e){return Ui(e)&&e.tagName===`INPUT`}function P_(e){return!!(N_(e)&&e.selectionStart!=null||Ui(e)&&e.tagName===`TEXTAREA`)}function F_(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=I_(e,t,`left`),a=L_(e),o=L_(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=I_(e,t,`top`),r=L_(e),i=L_(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function I_(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function L_(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}var R_=`data-composite-item-active`;function z_(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=qr}=e,[p,m]=_.useState(0),h=r!=null,g=_.useRef(null),v=Nr(g,c),y=_.useRef([]),b=_.useRef(!1),x=_.useRef(null),S=o??p,C=Q((e,t=!1)=>{if(x.current=y.current[e]??null,(s??m)(e),t){let t=y.current[e];F_(g.current,t,a,n)}}),w=Q(e=>{if(e.size===0)return;if(b.current){let e=y.current,t=e.indexOf(x.current);if(t===-1){let t=e[S];!t||Ks(e,S,d)?C(B_(e,d)):x.current=t}else t!==S&&C(t);return}b.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)C(i);else if(Ks(t,S,d)){let e=Gs(t,{disabledIndices:d});Vs(t,e)||C(e)}F_(g.current,r,a,n)});X(()=>{if(d==null||o!=null||!b.current)return;let e=y.current;if(Ks(e,S,d)){let t=Gs(e,{disabledIndices:d});Vs(e,t)||C(t)}},[d,o,S,y,C]);let T=Q((e,t,n)=>i?i(e,t,n,y):n),E=Q(e=>{let o=e.key===`Home`||e.key===`End`;if(!j_.has(e.key)||!l&&o||V_(e,f)||!g.current)return;let s=a===`rtl`,c=s?k_:A_,p=s?A_:k_,m=n===`vertical`?O_:c,_=n===`vertical`?D_:p,v=as(e.nativeEvent);if(v!=null&&P_(v)&&!E_(v)){let t=v.selectionStart,n=v.selectionEnd,r=v.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let b=S,x=Hs(y,d),w=Us(y,d);r!=null&&(b=r({disabledIndices:d,elementsRef:y,event:e,highlightedIndex:S,loopFocus:t,maxIndex:w,minIndex:x,onLoop:T,orientation:n,rtl:s}));let E=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,D=n!==`vertical`&&e.key===p||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?b=x:e.key===`End`&&(b=w)),b===S&&(E||D)&&(t&&b===w&&E?(b=x,i&&(b=i(e,S,b,y))):t&&b===x&&D?(b=w,i&&(b=i(e,S,b,y))):b=Gs(y.current,{startingIndex:b,decrement:D,disabledIndices:d})),b!==S&&!Vs(y.current,b)&&(u&&e.stopPropagation(),(h||o||E||D)&&e.preventDefault(),C(b,!0),queueMicrotask(()=>{y.current[b]?.focus()}))});return{props:{ref:v,onFocus(e){let t=g.current,n=as(e.nativeEvent);t&&n!=null&&P_(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:E},highlightedIndex:S,onHighlightedIndexChange:C,elementsRef:y,onMapChange:w,relayKeyboardEvent:E}}function B_(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!Ks(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function V_(e,t){for(let n of M_)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function H_(e){let{render:t,className:n,style:r,refs:i=qr,props:a=qr,state:o=Jr,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:v,disabledIndices:y,modifierKeys:b,highlightItemOnHover:x=!1,tag:S=`div`,...C}=e,{props:w,highlightedIndex:T,onHighlightedIndexChange:E,elementsRef:D,onMapChange:O,relayKeyboardEvent:k}=z_({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:v,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:$u(),disabledIndices:y,modifierKeys:b}),A=fi(S,e,{state:o,ref:i,props:[w,...a,C],stateAttributesMapping:s}),j=_.useMemo(()=>({highlightedIndex:T,onHighlightedIndexChange:E,highlightItemOnHover:x,relayKeyboardEvent:k}),[T,E,x,k]);return(0,Y.jsx)(Hm.Provider,{value:j,children:(0,Y.jsx)(s_,{elementsRef:D,onMapChange:e=>{h?.(e),O(e)},children:A})})}function U_(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Um(),{ref:i,index:a}=m_(e),o=n===a,s=_.useRef(null),c=Nr(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}var W_=`overflow-hidden rounded-lg bg-kumo-base shadow-xs ring ring-kumo-line`,G_=`flex w-full flex-col overflow-hidden rounded-lg bg-kumo-elevated text-base ring ring-kumo-hairline`,K_=`-my-2 flex items-center gap-2 bg-kumo-elevated p-4 text-base font-medium text-kumo-subtle`,q_=`relative flex flex-col gap-2 overflow-hidden rounded-lg bg-kumo-base p-4 pr-3 text-inherit no-underline ring ring-kumo-fill`;function J_(e={}){return J(W_)}function Y_(e){return _.Children.toArray(e).some(e=>(0,_.isValidElement)(e)?e.type===Q_||e.type===Z_||e.type===_.Fragment&&Y_(e.props.children):!1)}var X_=(0,_.forwardRef)(function({children:e,className:t,render:n,...r},i){return Si({defaultTagName:`div`,render:n,ref:i,props:$r({className:J(Y_(e)?G_:J_(),t)},r,{children:e})})});function Z_({children:e,className:t,...n}){return(0,Y.jsx)(`div`,{className:J(K_,t),...n,children:e})}function Q_({children:e,className:t,...n}){return(0,Y.jsx)(`div`,{className:J(q_,t),...n,children:e})}X_.displayName=`LayerCard`,Z_.displayName=`LayerCard.Secondary`,Q_.displayName=`LayerCard.Primary`;var $_=Object.assign(X_,{Primary:Q_,Secondary:Z_});function ev(e=2e3){let[t,n]=(0,_.useState)(!1),r=(0,_.useRef)(null),i=(0,_.useRef)(0);return(0,_.useEffect)(()=>()=>{i.current+=1,r.current!==null&&clearTimeout(r.current)},[]),{copied:t,runCopy:(0,_.useCallback)(async(t,a)=>{let o=++i.current;r.current!==null&&(clearTimeout(r.current),r.current=null);try{return await t(()=>i.current===o),i.current===o&&(n(!0),r.current=setTimeout(()=>{i.current===o&&(n(!1),r.current=null)},e),!0)}catch(e){return i.current===o&&(n(!1),a?.(e)),!1}},[e]),reset:(0,_.useCallback)(()=>{i.current+=1,r.current!==null&&(clearTimeout(r.current),r.current=null),n(!1)},[])}}var tv=(e,t)=>Math.floor(Math.random()*(t-e+1)+e),nv=(e,t)=>(Math.random()*(t-e)+e).toFixed(2),rv=({minWidth:e=30,maxWidth:t=100,minDuration:n=1.3,maxDuration:r=1.7,minDelay:i=0,maxDelay:a=.5,blockHeight:o,className:s})=>{let{width:c,duration:l,delay:u}=(0,_.useMemo)(()=>({width:tv(e,t),duration:nv(n,r),delay:nv(i,a)}),[e,t,n,r,i,a]),d={"--skeleton-width":`${c}%`,"--shimmer-duration":`${l}s`,"--shimmer-delay":`${u}s`},f=(0,Y.jsx)(`div`,{className:J(`skeleton-line`,s),style:d});if(o!==void 0){let e=typeof o==`number`?`${o}px`:o;return(0,Y.jsx)(`div`,{className:`flex items-center`,style:{height:e},children:f})}return f};function iv(e){let[t,n]=_.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}var av=_.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return fi(`div`,e,{state:{orientation:i},ref:t,props:[{role:`presentation`},o]})});av.displayName=`ListboxSeparator`;function ov(e,t){return Math.max(0,e-t)}function sv(e,t){if(t<=0)return 0;let n=fh(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}var cv=`base-ui-disable-scrollbar`,lv={className:cv,getElement(e){return(0,Y.jsx)(`style`,{nonce:e,href:cv,precedence:`base-ui:low`,children:`.${cv}{scrollbar-width:none}.${cv}::-webkit-scrollbar{display:none}`})}};lv.getElement.displayName=`styleDisableScrollbar.getElement`;var uv=_.createContext(void 0);uv.displayName=`CSPContext`;var dv={disableStyleElements:!1};function fv(){return _.useContext(uv)??dv}var pv=_.createContext(void 0);pv.displayName=`SelectRootContext`;var mv=_.createContext(void 0);mv.displayName=`SelectFloatingContext`;function hv(){let e=_.useContext(pv);if(e===void 0)throw Error(`Base UI: SelectRootContext is missing. Select parts must be placed within <Select.Root>.`);return e}function gv(){let e=_.useContext(mv);if(e===void 0)throw Error(`Base UI: SelectFloatingContext is missing. Select parts must be placed within <Select.Root>.`);return e}var _v={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,multiple:e=>e.multiple,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,highlightItemOnHover:e=>e.highlightItemOnHover,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:n_(t,r)!==``},hasNullItemLabel:(e,t)=>t?e_(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>Hg(t,e,n)):Hg(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function vv(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:v,items:y,multiple:b=!1,itemToStringLabel:x,itemToStringValue:S,isItemEqualToValue:C=Vg,highlightItemOnHover:w=!0,children:T}=e,{clearErrors:E}=lm(),{setDirty:D,setTouched:O,setFocused:k,validityData:A,setFilled:j,name:M,disabled:N,validation:P,validationMode:F}=am(),I=Om({id:t}),L=N||d,R=M??c,[z,B]=jm({controlled:n,default:b?r??qr:r,name:`Select`,state:`value`}),[V,H]=jm({controlled:a,default:o,name:`Select`,state:`open`}),U=_.useRef([]),ee=_.useRef([]),te=_.useRef(null),W=_.useRef(null),ne=_.useRef(0),re=_.useRef(null),ie=_.useRef([]),ae=_.useRef(!1),G=_.useRef(null),K=_.useRef(null),oe=_.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),se=_.useRef(!1),ce=_.useRef(z),{openMethod:le,triggerProps:ue}=yg(V),q=Mr(()=>new Nl({id:I,labelId:void 0,modal:m,multiple:b,disabled:L,readOnly:f,required:p,highlightItemOnHover:w,itemToStringLabel:x,itemToStringValue:S,isItemEqualToValue:C,value:z,open:V,mounted:V,transitionStatus:void 0,items:y,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Jr,triggerProps:Jr,itemRoot:{props:Jr,multiple:b,disabled:L,readOnly:f,isItemEqualToValue:C},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:Kr,setOpen:Kr,handleScrollArrowVisibility:Kr,onOpenChangeComplete:Kr,listRef:U,popupRef:te,scrollHandlerRef:W,scrollArrowsMountedCountRef:ne,valueRef:re,valuesRef:ie,labelsRef:ee,typingRef:ae,selectionRef:oe,firstItemTextRef:G,selectedItemTextRef:K,alignItemWithTriggerActiveRef:se,initialValueRef:ce},_v)).current,[de,fe]=_.useState(!1),{mounted:pe,transitionStatus:me,forceUnmount:he}=ou({open:V,ref:te,preventUnmountOnClose:de,setPreventUnmountOnClose:fe,onUnmount(){q.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),v?.(!1)}}),ge=q.useState(`activeIndex`),_e=q.useState(`selectedIndex`),ve=q.useState(`triggerElement`),ye=q.useState(`positionerElement`),be=iv(le),xe=le??be,Se=_.useMemo(()=>b?``:n_(z,S),[b,z,S]),Ce=_.useMemo(()=>b&&Array.isArray(z)?z.map(e=>n_(e,S)):n_(z,S),[b,z,S]);km(Bl(ve),I,z,Q(()=>Ce),!L,c);let we=b?Array.isArray(z)&&z.length>0:z!=null&&Se!==``;X(()=>{j(we)},[we,j]),X(function(){let e=qg(ie.current,z,C,b);e===null&&(K.current=null),!V&&q.set(`selectedIndex`,e)},[b,V,z,C,q]),Am(z,()=>{E(R),D(Ug(z,A.initialValue,C)),P.change(z)});let Te=Q((e,t)=>{let n=t,r=pu(n);s?.(e,n),!t.isCanceled&&(e||fe(r()),H(e),e||t.reason!==`focus-out`&&t.reason!==`outside-press`||(O(!0),k(!1),F===`onBlur`&&P.commit(z)))});_.useImperativeHandle(h,()=>({unmount:he,close:()=>{q.state.open&&Te(!1,vc(Mc))}}),[he,Te,q]);let Ee=Q((e,t)=>{i?.(e,t),!t.isCanceled&&B(e)}),De=Q(e=>{let t=ov(e.scrollHeight,e.clientHeight),n=sv(e.scrollTop,t),r=n>0,i=n<t;q.set(`scrollUpArrowVisible`,r),q.set(`scrollDownArrowVisible`,i)}),Oe=uh({open:V,onOpenChange:Te,elements:{reference:ve,floating:ye}}),ke=Mg(Oe,{enabled:!L,event:`mousedown`}),Ae=iu(Oe),je=zg(Oe,{enabled:!L,listRef:U,activeIndex:ge,selectedIndex:_e,disabledIndices:qr,onNavigate(e){(e!==null||V)&&q.set(`activeIndex`,e)},focusItemOnHover:w}),Me=h_(Oe,{enabled:!L&&(V||!f&&!b),listRef:ee,activeIndex:ge,selectedIndex:_e,disabledIndices:e=>E_(U.current[e]),onMatch(e){V?q.set(`activeIndex`,e):Ee(ie.current[e],vc(yc))},onTyping(e){ae.current=e}}),Ne=_.useMemo(()=>$r(Me.reference,je.reference,Ae.reference,ke.reference,ue),[ke.reference,Me.reference,je.reference,Ae.reference,ue]),Pe=_.useMemo(()=>$r(su,Me.floating,je.floating,Ae.floating),[Me.floating,je.floating,Ae.floating]),Fe=je.item??Jr,Ie=_.useMemo(()=>({props:Fe,multiple:b,disabled:L,readOnly:f,isItemEqualToValue:C}),[Fe,b,L,f,C]);q.useContextCallback(`setValue`,Ee),q.useContextCallback(`setOpen`,Te),q.useContextCallback(`handleScrollArrowVisibility`,De),q.useContextCallback(`onOpenChangeComplete`,v),Bg(()=>{q.update({popupProps:Pe,triggerProps:Ne,itemRoot:Ie})}),q.useSyncedValues({id:I,modal:m,multiple:b,disabled:L,readOnly:f,required:p,highlightItemOnHover:w,value:z,open:V,mounted:pe,transitionStatus:me,popupProps:Pe,triggerProps:Ne,itemRoot:Ie,items:y,itemToStringLabel:x,itemToStringValue:S,isItemEqualToValue:C,openMethod:xe});let Le=Nr(g,P.inputRef),Re=b?void 0:R,ze=_.useMemo(()=>!b||!Array.isArray(z)||!R?null:z.map(e=>{let t=n_(e,S);return(0,Y.jsx)(`input`,{type:`hidden`,form:l,name:R,value:t,disabled:L},t)}),[b,z,l,R,S,L]);return(0,Y.jsxs)(pv.Provider,{value:q,children:[(0,Y.jsx)(mv.Provider,{value:Oe,children:T}),(0,Y.jsx)(`input`,{...P.getValidationProps(L,{onFocus(){q.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||L||f)return;let t=e.currentTarget.value,n=vc(yc,e.nativeEvent);function r(){if(b)return;let e=t.toLowerCase(),r=ie.current.findIndex(t=>n_(t,S).toLowerCase()===e||t_(t,x).toLowerCase()===e);r===-1&&(r=ie.current.findIndex((t,n)=>{let r=ee.current[n];return r!=null&&r.toLowerCase()===e}));let i=ie.current[r];i!=null&&Ee(i,n)}q.set(`forceMount`,!0),queueMicrotask(r)}}),id:I&&Re==null?`${I}-hidden-input`:void 0,form:l,name:Re,autoComplete:u,value:Se,disabled:L,required:p&&!(b&&we),readOnly:f,ref:Le,style:R?Hc:Vc,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),ze]})}var yv=_.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=a;delete o.id;let s=am(),c=hv(),l=c.useState(`triggerElement`),u=c.useState(`id`),d=um({id:g_(u),fallbackControlId:l?.id??u,setLabelId(e){let t=typeof e==`function`?e(c.state.labelId):e;c.set(`labelId`,t)}});return fi(`div`,e,{ref:t,state:s.state,props:[d,a],stateAttributesMapping:nm})});yv.displayName=`SelectLabel`;var bv=`data-popup-side`,xv=400,Sv={...Os,...nm,popupSide:e=>e?{[bv]:e}:null,value:()=>null},Cv=_.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,validationMode:u,validation:d,state:f,disabled:p}=am(),{labelId:m}=sm(),h=hv(),g=h.useState(`readOnly`),v=h.useState(`required`),y=h.useState(`disabled`),b=p||y||a,x=h.useState(`open`),S=h.useState(`mounted`),C=h.useState(`value`),w=h.useState(`triggerProps`),T=h.useState(`positionerElement`),E=h.useState(`listElement`),D=h.useState(`popupSide`),O=h.useState(`id`),k=h.useState(`labelId`),A=h.useState(`hasSelectedValue`),j=S&&T?D:null,M=i??O,N=__(m,k);Om({id:i});let P=Bl(T),F=_.useRef(null),I=Vm(b,F),{getButtonProps:L,buttonRef:R}=Km({disabled:b,native:o}),z=h.useStateSetter(`triggerElement`),B=zl(),V=zl(),H=zl();_.useEffect(()=>{if(x)return H.start(xv,()=>{h.context.selectionRef.current.allowUnselectedMouseUp=!0,h.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{H.clear()};h.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},V.clear()},[x,h,V,H]);let U=$r(w,{id:M,role:`combobox`,"aria-expanded":x,"aria-haspopup":`listbox`,"aria-controls":x?E?.id??zs(T)?.id:void 0,"aria-labelledby":N,"aria-readonly":g||void 0,"aria-required":v||void 0,tabIndex:b?-1:0,onFocus(e){I(!0),x&&h.context.alignItemWithTriggerActiveRef.current&&h.context.setOpen(!1,vc(yc,e.nativeEvent)),B.start(0,()=>{h.set(`forceMount`,!0)})},onBlur(e){Z(T,e.relatedTarget)||(l(!0),I(!1),u===`onBlur`&&d.commit(C))},onMouseDown(e){if(x)return;let t=Bs(e.currentTarget);function n(e){if(!F.current)return;let t=e.target;Z(F.current,t)||Z(P.current,t)||y_(e,F.current)||h.context.setOpen(!1,vc(Oc,e))}V.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,L),ee=d.getValidationProps(b,U);ee.role=`combobox`;let te={...f,open:x,disabled:b,value:C,readOnly:g,popupSide:j,placeholder:!A};return fi(`button`,e,{ref:[t,F,R,z],state:te,stateAttributesMapping:Sv,props:ee})});Cv.displayName=`SelectTrigger`;var wv={value:()=>null},Tv=_.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=hv(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?i_(l,u,d):r_(l,u,d)),fi(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:wv})});Tv.displayName=`SelectValue`;var Ev=_.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return fi(`span`,e,{state:{open:hv().useState(`open`)},ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:Ds})});Ev.displayName=`SelectIcon`;var Dv=_.forwardRef(function(e,t){let n=hv(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,Y.jsx)(Cl,{ref:t,...e}):null});Dv.displayName=`SelectPortal`;var Ov=_.createContext(void 0);Ov.displayName=`SelectPositionerContext`;function kv(){let e=_.useContext(Ov);if(!e)throw Error(`Base UI: SelectPositionerContext is missing. SelectPositioner parts must be placed within <Select.Positioner>.`);return e}function Av(e,t){e&&Object.assign(e.style,t)}var jv={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},Mv={position:`fixed`},Nv=_.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=gl,style:v,...y}=e,b=hv(),x=gv(),S=b.useState(`open`),C=b.useState(`mounted`),w=b.useState(`modal`),T=b.useState(`value`),E=b.useState(`openMethod`),D=b.useState(`positionerElement`),O=b.useState(`triggerElement`),k=b.useState(`isItemEqualToValue`),A=b.useState(`transitionStatus`),j=_.useRef(null),M=_.useRef(null),[N,P]=_.useState(h),F=C&&N&&E!==`touch`;!C&&N!==h&&P(h),_.useImperativeHandle(b.context.alignItemWithTriggerActiveRef,()=>F),C_((F||w)&&S,E===`touch`,D,O);let I=md({anchor:n,floatingRootContext:x,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??F,collisionAvoidance:g,keepMounted:!0}),L=F?`none`:I.side,R=F?Mv:I.positionerStyles,z={open:S,side:L,align:I.align,anchorHidden:I.anchorHidden};X(()=>{b.set(`popupSide`,I.side)},[b,I.side]);let B=vd(e,z,{styles:R,transitionStatus:A,props:y,refs:[t,b.useStateSetter(`positionerElement`)],hidden:!C,inert:!S}),V=_.useRef(0),H=Q(e=>{if(b.context.valuesRef.current.length===0)return;let t=V.current;V.current=e.size;let n=vc(yc);if(t!==0&&!b.state.multiple&&T!==null&&Gg(b.context.valuesRef.current,T,k)===-1){let e=b.context.initialValueRef.current,t=e!=null&&Gg(b.context.valuesRef.current,e,k)!==-1?e:null;b.context.setValue(t,n),t===null&&(b.set(`selectedIndex`,null),b.context.selectedItemTextRef.current=null)}if(t!==0&&b.state.multiple&&Array.isArray(T)){let e=T.filter(e=>Gg(b.context.valuesRef.current,e,k)!==-1);e.length!==T.length&&(b.context.setValue(e,n),e.length===0&&(b.set(`selectedIndex`,null),b.context.selectedItemTextRef.current=null))}if(S&&F){b.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};Av(D,e),Av(b.context.popupRef.current,e)}}),U=_.useMemo(()=>({...I,side:L,alignItemWithTriggerActive:F,setControlledAlignItemWithTrigger:P,scrollUpArrowRef:j,scrollDownArrowRef:M}),[I,L,F,P]);return(0,Y.jsx)(s_,{elementsRef:b.context.listRef,labelsRef:b.context.labelsRef,onMapChange:H,children:(0,Y.jsxs)(Ov.Provider,{value:U,children:[C&&w&&(0,Y.jsx)(bg,{inert:dh(!S),cutout:O}),B]})})});Nv.displayName=`SelectPositioner`;var Pv=`--transform-origin`,Fv={...ks,...gs},Iv=_.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=hv(),c=s.useState(`multiple`),l=s.useState(`readOnly`),u=s.useState(`highlightItemOnHover`),d=gv(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=kv(),v=T_(!0)!=null,y=$u(),{nonce:b,disableStyleElements:x}=fv(),S=s.useState(`id`),C=s.useState(`open`),w=s.useState(`openMethod`),T=s.useState(`mounted`),E=s.useState(`popupProps`),D=s.useState(`transitionStatus`),O=s.useState(`triggerElement`),k=s.useState(`positionerElement`),A=s.useState(`listElement`),j=_.useRef(!1),M=_.useRef(!1),N=_.useRef({}),P=Kl(),F=Q(e=>{if(!k||!s.context.popupRef.current||!M.current)return;let t=k.style.top===`0px`,n=k.style.bottom===`0px`;if(j.current||!m||!t&&!n){s.context.handleScrollArrowVisibility(e);return}let r=zv(k),i=Bv(k.getBoundingClientRect().height,`y`,r),a=Bs(k),o=zi(k),c=o.getComputedStyle(k),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=Lv(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=Rv(e),g=null,_=e=>{k.style.height=`${e}px`},v=t?h-p:p,y=Math.min(i+v,f);if(v<=1){let n=fh(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?h:0,f-(i+n)<=1&&(j.current=!0),s.context.handleScrollArrowVisibility(e);return}f-y>1?g=t?1/0:0:n&&p<h&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=fh(g,0,Rv(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(j.current=!0),s.context.handleScrollArrowVisibility(e)});_.useImperativeHandle(s.context.scrollHandlerRef,()=>F,[F]),Ql({open:C,ref:s.context.popupRef,onComplete(){C&&s.context.onOpenChangeComplete(!0)}});let I={open:C,transitionStatus:D,side:f,align:p};X(()=>{k&&s.context.popupRef.current&&!Object.keys(N.current).length&&(N.current={top:k.style.top||`0`,left:k.style.left||`0`,right:k.style.right,height:k.style.height,bottom:k.style.bottom,minHeight:k.style.minHeight,maxHeight:k.style.maxHeight,marginTop:k.style.marginTop,marginBottom:k.style.marginBottom})},[s,k]),X(()=>{C||m||(M.current=!1,j.current=!1,Av(k,N.current))},[C,m,k]),X(()=>{let e=s.context.popupRef.current;if(!C||!O||!k||!e||m&&!h||s.state.transitionStatus===`ending`)return;if(M.current=!0,e.style.removeProperty(Pv),!m){P.request(()=>s.context.handleScrollArrowVisibility(A||e));return}let t=Uv(e);try{let t=s.context.selectedItemTextRef.current;t?.isConnected||(t=!s.select(`hasSelectedValue`)&&s.context.firstItemTextRef.current?.isConnected?s.context.firstItemTextRef.current:null);let n=s.context.valueRef.current,r=zi(k),i=r.getComputedStyle(k),a=r.getComputedStyle(e),o=Bs(O),c=zv(O),l=Vv(O.getBoundingClientRect(),c),d=Vv(k.getBoundingClientRect(),c),f=l.height,p=A||e,m=p.scrollHeight,h=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,v=parseFloat(i.marginBottom)||10,b=parseFloat(i.minHeight)||100,x=Lv(a),S=o.documentElement.clientHeight-_-v,C=o.documentElement.clientWidth,w=S-l.bottom+f,T,E=y===`rtl`?l.right-d.width:l.left,D=0;if(t&&n){let e=Vv(n.getBoundingClientRect(),c);T=Vv(t.getBoundingClientRect(),c),E=d.left+(y===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-l.top+e.height/2;D=T.top-d.top+T.height/2-r}let M=w+D+v+h,P=Math.min(S,M),F=S-_-v,I=M-P,L=C-5;k.style.left=`${fh(E,5,L-d.width)}px`,k.style.height=`${P}px`,k.style.maxHeight=`none`,k.style.marginTop=`${_}px`,k.style.marginBottom=`${v}px`,e.style.height=`100%`;let R=Rv(p),z=I>=R-1;z&&(P=Math.min(S,d.height)-(I-R));let B=l.top<20||l.bottom>S-20||Math.ceil(P)+1<Math.min(m,b),V=(r.visualViewport?.scale??1)!==1&&_c;if(B||V){Av(k,N.current),g(!1);return}let H=Math.max(b,P);if(z){let e=Math.max(0,S-M);k.style.top=d.height>=F?`0`:`${e}px`,k.style.height=`${P}px`,p.scrollTop=Rv(p)}else k.style.bottom=`0`,p.scrollTop=I;if(T){let t=d.top,n=d.height,r=T.top+T.height/2,i=fh(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(Pv,`50% ${i}%`)}(H===S||P>=x)&&(j.current=!0),s.context.handleScrollArrowVisibility(p),u&&s.state.selectedIndex===null&&s.state.activeIndex===null&&s.context.listRef.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,C,k,O,m,g,P,A,u,y,h]),_.useEffect(()=>{if(!m||!k||!C)return;let e=zi(k);function t(e){s.context.setOpen(!1,vc(Nc,e))}return Pc(e,`resize`,t)},[s,m,k,C]);let L={...A?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":c||void 0,"aria-readonly":l||void 0,id:`${S}-list`},onKeyDown(e){v&&j_.has(e.key)&&e.stopPropagation()},onScroll(e){A||F(e.currentTarget)},...m&&{style:A?{height:`100%`}:jv},className:!A&&m?lv.className:void 0},R=fi(`div`,e,{ref:[t,s.context.popupRef],state:I,stateAttributesMapping:Fv,props:[E,L,_d(D),o]});return(0,Y.jsxs)(_.Fragment,{children:[!x&&lv.getElement(b),(0,Y.jsx)(gg,{context:d,modal:!1,disabled:!T,openInteractionType:w,returnFocus:a,restoreFocus:!0,children:R})]})});Iv.displayName=`SelectPopup`;function Lv(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function Rv(e){return ov(e.scrollHeight,e.clientHeight)}function zv(e){return vo.getScale(e)}function Bv(e,t,n){return e/n[t]}function Vv(e,t){return Pa({x:Bv(e.x,`x`,t),y:Bv(e.y,`y`,t),width:Bv(e.width,`x`,t),height:Bv(e.height,`y`,t)})}var Hv=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function Uv(e){let{style:t}=e,n={};for(let[e,r]of Hv)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of Hv){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var Wv=_.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=hv(),s=o.useState(`multiple`),c=o.useState(`readOnly`),{alignItemWithTriggerActive:l}=kv(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:jv},className:u&&d!==`touch`?lv.className:void 0};return fi(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})});Wv.displayName=`SelectList`;var Gv=_.createContext(void 0);Gv.displayName=`SelectItemContext`;function Kv(){let e=_.useContext(Gv);if(!e)throw Error(`Base UI: SelectItemContext is missing. SelectItem parts must be placed within <Select.Item>.`);return e}var qv=_.memo(_.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=_.useRef(null),d=m_({guess:!0,label:o,textRef:u}),f=hv(),{props:p,multiple:m,disabled:h,readOnly:g,isItemEqualToValue:v}=f.useState(`itemRoot`),y=h||s,b=f.useState(`isActive`,d.index),x=f.useState(`open`),S=f.useState(`isSelected`,a),C=f.useState(`isSelectedByFocus`,d.index),w=d.index,T=_.useRef(null);X(()=>{let e=f.context.valuesRef.current;return e[w]=a,()=>{delete e[w]}},[w,a,f]),X(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=Jg(w,a,f.context.valuesRef.current,e,v,t),r=n===w,w===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&Hg(a,e,v),r&&(n=w)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[w,m,v,f,a]);let E=_.useRef(`mouse`),D=_.useRef(!1),{getButtonProps:O,buttonRef:k}=Km({disabled:y,focusableWhenDisabled:!0,native:c,composite:!0}),A={disabled:y,selected:S,highlighted:b};function j(e){if(h||g)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=S?Yg(n,a,v):[...n,a];f.context.setValue(r,vc(wc,e))}else f.context.setValue(a,vc(wc,e)),f.context.setOpen(!1,vc(wc,e))}function M(){f.context.selectionRef.current.dragY=0}let N={role:`option`,"aria-selected":S,tabIndex:x&&b?0:-1,onKeyDown(e){f.set(`activeIndex`,w),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=E.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&$o(e.nativeEvent)&&(n!==void 0||b),i=t&&!r&&!D.current;D.current=!1,!(y||i)&&j(e.nativeEvent)},onPointerEnter(e){E.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){E.current=e.pointerType,D.current=!0,M()},onMouseUp(){if(M(),y||E.current===`touch`||D.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&S,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!S;e||t||(D.current=!0,T.current?.click(),D.current=!1)}},P=fi(`div`,e,{ref:[k,t,d.ref,T],state:A,props:[p,N,l,O]}),F=_.useMemo(()=>({selected:S,index:w,textRef:u,selectedByFocus:C}),[S,w,u,C]);return(0,Y.jsx)(Gv.Provider,{value:F,children:P})}));qv.displayName=`SelectItem`;var Jv=_.forwardRef(function(e,t){let{selected:n}=Kv();return e.keepMounted||n?(0,Y.jsx)(x_,{...e,selected:n,ref:t}):null});Jv.displayName=`SelectItemIndicator`;var Yv=_.memo(_.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=Kv(),a=hv(),{render:o,className:s,style:c,...l}=e;return fi(`div`,e,{ref:[_.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]),t,r],props:l})}));Yv.displayName=`SelectItemText`;var Xv=_.createContext(void 0);Xv.displayName=`SelectGroupContext`;function Zv(){let e=_.useContext(Xv);if(e===void 0)throw Error(`Base UI: SelectGroupContext is missing. SelectGroup parts must be placed within <Select.Group>.`);return e}var Qv=_.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=_.useState(),c=_.useMemo(()=>({labelId:o,setLabelId:s}),[o,s]),l=fi(`div`,e,{ref:t,props:[{role:`group`,"aria-labelledby":o},a]});return(0,Y.jsx)(Xv.Provider,{value:c,children:l})});Qv.displayName=`SelectGroup`;var $v=_.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{setLabelId:s}=Zv(),c=Xu(a);return X(()=>(s(c),()=>{s(e=>e===c?void 0:e)}),[c,s]),fi(`div`,e,{ref:t,props:[{id:c,"aria-hidden":!0},o]})});$v.displayName=`SelectGroupLabel`;var ey=av;Sh.size;var ty={size:`base`};function ny({size:e=ty.size}={}){return J(_p({size:e}),`bg-kumo-control disabled:bg-kumo-control/50 data-[state=open]:bg-kumo-control`,`justify-between font-normal`,`focus:opacity-100 focus:ring-kumo-focus/50 focus-visible:ring-inset *:in-focus:opacity-100`)}var ry={xs:{iconSize:12,className:`text-kumo-subtle`},sm:{iconSize:14,className:`text-kumo-subtle`},base:{iconSize:16,className:`text-kumo-subtle`},lg:{iconSize:18,className:`text-kumo-subtle`}};function iy(e){if(typeof e!=`object`||!e||Array.isArray(e)||`$$typeof`in e||e instanceof Promise)return!1;let t=e;return`label`in t&&t.label!==void 0}function ay(e){return Array.isArray(e)?e:Object.entries(e).map(([e,t])=>({value:e,label:iy(t)?t.label:t}))}function oy(e){let t=ay(e),n=new Map;if(!Array.isArray(e))for(let[t,r]of Object.entries(e))iy(r)&&n.set(t,{disabled:r.disabled});return t.filter(e=>e.value!==null).map((e,t)=>{let r=typeof e.value==`string`?e.value:`option-${t}`,i=typeof e.value==`string`?n.get(e.value):void 0;return(0,Y.jsx)(cy,{value:e.value,disabled:i?.disabled,children:e.label},r)})}function sy({children:e,className:t,render:n,renderValue:r,label:i,hideLabel:a,placeholder:o,loading:s,size:c=ty.size,labelTooltip:l,description:u,error:d,required:f,container:p,side:m=`bottom`,sideOffset:h=4,align:g=`start`,alignOffset:v,alignItemWithTrigger:y=!1,anchor:b,arrowPadding:x,positionMethod:S,collisionAvoidance:C,collisionBoundary:w,collisionPadding:T,sticky:E,disableAnchorTracking:D,...O}){let k=(0,_.useId)(),A=Pi(),j=p??A??void 0,M=O,N=M[`aria-label`],P=M[`aria-labelledby`],F=typeof i==`string`?i:o;a!==void 0&&console.warn('[Kumo Select]: `hideLabel` is deprecated. For hidden labels, use `aria-label` instead of `label` + `hideLabel={true}`.\n Migration:\n - For visible labels: <Select label="Country" /> (hideLabel no longer needed)\n - For hidden labels: <Select aria-label="Select a country" /> (remove label and hideLabel)');let I=i&&a!==!0,L=I?void 0:P??(i?k:void 0),R=N??(L?void 0:F),z=O.items?ay(O.items):void 0,B=e||(O.items?oy(O.items):null),V=r?e=>{let t=o==null?null:(0,Y.jsx)(`span`,{className:`text-kumo-placeholder`,children:o});return e==null||e===``?t:r(e)??t}:void 0,{items:H,...U}=O,ee=i?(0,Y.jsx)(yv,{className:`m-0 text-base font-medium text-kumo-default select-none`,children:(0,Y.jsx)(Kp,{showOptional:f===!1,tooltip:a?void 0:l,asContent:!0,children:i})}):null,te=(0,Y.jsxs)(Cv,{"data-kumo-component":`Select`,"data-kumo-part":`trigger`,render:n,className:J(ny({size:c}),O.disabled&&`cursor-not-allowed opacity-50`,d&&`!ring-kumo-danger focus:ring-[1.5px] focus:ring-kumo-danger/50`,t),"aria-label":R,"aria-labelledby":L,children:[s?(0,Y.jsx)(rv,{className:`w-32`}):(0,Y.jsx)(Tv,{placeholder:o,className:`min-w-0 truncate data-[placeholder]:text-kumo-placeholder`,children:V}),(0,Y.jsx)(Ev,{className:J(`flex shrink-0 items-center`,ry[c].className),children:(0,Y.jsx)(Bf,{size:ry[c].iconSize,className:`fill-current`})})]}),W=(0,Y.jsxs)(vv,{...U,items:z,disabled:s||O.disabled,required:f,children:[ee,te,(0,Y.jsx)(Dv,{container:j,children:(0,Y.jsx)(Nv,{side:m,sideOffset:h,align:g,alignOffset:v,alignItemWithTrigger:y,anchor:b,arrowPadding:x,positionMethod:S,collisionAvoidance:C,collisionBoundary:w,collisionPadding:T,sticky:E,disableAnchorTracking:D,children:(0,Y.jsx)(Iv,{className:J(`flex flex-col`,`max-h-[var(--available-height)] bg-kumo-base text-kumo-default`,`rounded-lg shadow-lg ring ring-kumo-line`,`max-w-(--available-width) min-w-(--anchor-width) py-1.5`),children:(0,Y.jsx)(Wv,{className:J(`min-h-0 flex-1 scroll-pt-2 scroll-pb-2 overflow-y-auto overscroll-none`),children:B})})})})]});if(I)return(0,Y.jsx)(yh,{label:i,required:f,labelTooltip:l,description:u,error:d?typeof d==`string`?{message:d,match:!0}:d:void 0,hideLabel:!0,children:W});let ne=d?typeof d==`string`?{message:d,match:!0}:d:void 0;return(0,Y.jsxs)(`div`,{className:`grid gap-2`,children:[i&&(0,Y.jsx)(`span`,{id:k,className:`sr-only`,children:i}),W,ne?(0,Y.jsx)(`span`,{className:`text-sm text-kumo-danger`,children:ne.message}):u&&(0,Y.jsx)(`span`,{className:`text-sm leading-snug text-kumo-subtle`,children:u})]})}function cy({children:e,value:t,disabled:n,className:r}){return(0,Y.jsxs)(qv,{"data-kumo-component":`Select`,"data-kumo-part":`option`,value:t,disabled:n,className:J(`group mx-1.5 flex cursor-pointer items-center justify-between gap-2 rounded px-2 py-1.5 text-base outline-none`,`focus-visible:z-50 focus-visible:ring-2 focus-visible:ring-kumo-brand focus-visible:ring-inset`,`data-highlighted:bg-kumo-tint`,`data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,r),children:[(0,Y.jsx)(Yv,{children:e}),(0,Y.jsx)(Jv,{children:(0,Y.jsx)(Hf,{})})]})}var ly=(0,_.forwardRef)(({children:e,className:t},n)=>(0,Y.jsx)(Qv,{ref:n,className:J(t),children:e}));ly.displayName=`Select.Group`;var uy=(0,_.forwardRef)(({children:e,className:t},n)=>(0,Y.jsx)($v,{ref:n,className:J(`px-3.5 py-1.5 text-sm font-semibold text-kumo-subtle`,t),children:e}));uy.displayName=`Select.GroupLabel`;var dy=(0,_.forwardRef)(({className:e},t)=>(0,Y.jsx)(ey,{ref:t,className:J(`my-1 h-px bg-kumo-hairline`,e)}));dy.displayName=`Select.Separator`,sy.Option=cy,sy.Group=ly,sy.GroupLabel=uy,sy.Separator=dy,sy.Option.displayName=`Select.Option`;var fy=[25,50,100,250],py=(e,t,n)=>Math.min(Math.max(e,t),n),my={navigation:`Pagination`,firstPage:`First page`,previousPage:`Previous page`,nextPage:`Next page`,lastPage:`Last page`,pageNumber:`Page number`,pageSize:`Page size`},hy={controls:`full`},gy=(0,_.createContext)(null);function _y(){let e=(0,_.useContext)(gy);if(!e)throw Error(`Pagination compound components must be used within a Pagination component`);return e}function vy({children:e,className:t}){let{page:n,perPage:r,totalCount:i,pageShowingRange:a}=_y(),o=e?e({page:n,perPage:r,totalCount:i,pageShowingRange:a}):i&&i>0?(0,Y.jsxs)(Y.Fragment,{children:[`Showing `,(0,Y.jsx)(`span`,{className:`tabular-nums`,children:a}),` of`,` `,(0,Y.jsx)(`span`,{className:`tabular-nums`,children:i})]}):null;return(0,Y.jsx)(`div`,{"data-slot":`pagination-info`,className:J(`text-sm text-kumo-subtle`,t),children:o})}vy.displayName=`Pagination.Info`;function yy({value:e,onChange:t,options:n=fy,label:r=`Per page:`,className:i}){let{labels:a}=_y();return(0,Y.jsxs)(`div`,{"data-slot":`pagination-page-size`,className:J(`flex items-center gap-2`,i),children:[r&&(0,Y.jsx)(`span`,{className:`text-sm text-kumo-subtle`,children:r}),(0,Y.jsx)(sy,{"aria-label":a.pageSize,value:e,onValueChange:e=>t(e),children:n.map(e=>(0,Y.jsx)(sy.Option,{value:e,children:e},e))})]})}yy.displayName=`Pagination.PageSize`;function by({controls:e=hy.controls,pageSelector:t=`input`,className:n}){let{page:r,totalCount:i,hasNextPage:a,maxPage:o,setPage:s,editingPage:c,setEditingPage:l,labels:u}=_y(),d=i!=null,f=e===`full`&&!(!d&&a!==void 0),p=d?r===o:a!==!0;return(0,Y.jsx)(`div`,{"data-slot":`pagination-controls`,className:J(`flex grow flex-col items-end`,n),children:(0,Y.jsx)(`nav`,{"aria-label":u.navigation,children:(0,Y.jsxs)(Vh,{children:[f&&(0,Y.jsx)(Vh.Button,{variant:`secondary`,"aria-label":u.firstPage,disabled:r<=1,onClick:()=>{s(1),l(1)},children:(0,Y.jsx)(Pf,{size:16})}),(0,Y.jsx)(Vh.Button,{variant:`secondary`,"aria-label":u.previousPage,disabled:r<=1,onClick:()=>{let e=Math.max(r-1,1);s(e),l(e)},children:(0,Y.jsx)(Lf,{size:16})}),f&&(t===`dropdown`?(0,Y.jsx)(sy,{"aria-label":u.pageNumber,className:`rounded-none ring-kumo-hairline`,value:r,onValueChange:e=>{let t=e;s(t),l(t)},children:Array.from({length:o},(e,t)=>t+1).map(e=>(0,Y.jsx)(sy.Option,{value:e,children:e},e))}):(0,Y.jsx)(Vh.Input,{style:{width:50},className:`text-center`,"aria-label":u.pageNumber,value:c,onValueChange:e=>{l(Number(e))},onBlur:()=>{let e=py(c,1,o);s(e),l(e)},onKeyDown:e=>{if(e.key===`Enter`){let e=py(c,1,o);s(e),l(e)}},autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,"data-form-type":`other`})),(0,Y.jsx)(Vh.Button,{variant:`secondary`,"aria-label":u.nextPage,disabled:p,onClick:()=>{let e=d?Math.min(r+1,o):r+1;s(e),l(e)},children:(0,Y.jsx)(Rf,{size:16})}),f&&(0,Y.jsx)(Vh.Button,{variant:`secondary`,"aria-label":u.lastPage,disabled:r===o,onClick:()=>{s(o),l(o)},children:(0,Y.jsx)(Ff,{size:16})})]})})})}by.displayName=`Pagination.Controls`;function xy({className:e}){return(0,Y.jsx)(`div`,{"data-slot":`pagination-separator`,className:J(`mx-2 h-6 border-l border-kumo-hairline`,e)})}xy.displayName=`Pagination.Separator`;function Sy(e){let{page:t=1,perPage:n,totalCount:r,hasNextPage:i,setPage:a,children:o,className:s,labels:c}=e,l=`text`in e?e.text:void 0,u=`controls`in e?e.controls??hy.controls:hy.controls,[d,f]=(0,_.useState)(1),p=(0,_.useMemo)(()=>({...my,...c}),[c]);(0,_.useEffect)(()=>{f(t)},[t]);let m=(0,_.useMemo)(()=>{let e=t*(n??1)-(n??0)+1,i=Math.min(t*(n??0),r??0);return Number.isNaN(e)&&(e=0),Number.isNaN(i)&&(i=0),`${e}-${i}`},[t,n,r]),h={page:t,perPage:n,totalCount:r,hasNextPage:i,maxPage:(0,_.useMemo)(()=>Math.ceil((r??1)/(n??1)),[r,n]),pageShowingRange:m,setPage:a,editingPage:d,setEditingPage:f,labels:p};return o?(0,Y.jsx)(gy.Provider,{value:h,children:(0,Y.jsx)(`div`,{"data-slot":`pagination`,className:J(`flex w-full items-center gap-2`,s),children:o})}):(0,Y.jsx)(gy.Provider,{value:h,children:(0,Y.jsxs)(`div`,{"data-slot":`pagination`,className:J(`flex w-full items-center gap-2`,s),children:[(0,Y.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,"data-slot":`pagination-info`,className:`grow text-sm text-kumo-subtle`,children:l?l({page:t,perPage:n,totalCount:r,pageShowingRange:m}):r&&r>0?(0,Y.jsxs)(Y.Fragment,{children:[`Showing `,(0,Y.jsx)(`span`,{className:`tabular-nums`,children:m}),` of`,` `,(0,Y.jsx)(`span`,{className:`tabular-nums`,children:r})]}):null}),(0,Y.jsx)(by,{controls:u})]})})}Sy.displayName=`Pagination`;var Cy=Object.assign(Sy,{Info:vy,PageSize:yy,Controls:by,Separator:xy});function wy(e){let t=na(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Ui(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r;return(ua(n)!==a||ua(r)!==o)&&(n=a,r=o),{width:n,height:r}}var Ty=()=>()=>{},Ey=()=>!0,Dy=()=>!1;function Oy(){return(0,rl.useSyncExternalStore)(Ty,Ey,Dy)}function ky(){let[e,t]=_.useState(!1);return _.useEffect(()=>{t(!0)},[]),e}var Ay=Br(18)?Oy:ky;function jy(){return!Ay()}function My(e){let{script:t}=e,{nonce:n}=fv();return jy()?(0,Y.jsx)(`script`,{nonce:n,dangerouslySetInnerHTML:{__html:t},suppressHydrationWarning:!0}):null}var Ny=_.createContext(void 0);Ny.displayName=`TabsRootContext`;function Py(){let e=_.useContext(Ny);if(e===void 0)throw Error(`Base UI: TabsRootContext is missing. Tabs parts must be placed within <Tabs.Root>.`);return e}var Fy=`data-activation-direction`,Iy={tabActivationDirection:e=>({[Fy]:e})},Ly=_.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,style:c,...l}=e,u=e.defaultValue!==void 0,d=_.useRef([]),[f,p]=_.useState(()=>new Map),[m,h]=jm({controlled:s,default:r,name:`Tabs`,state:`value`}),g=s!==void 0,[v,y]=_.useState(()=>new Map),b=_.useRef(void 0),x=_.useCallback(e=>Ry(v,e),[v]),[S,C]=_.useState(()=>({previousValue:m,tabActivationDirection:`none`})),{previousValue:w,tabActivationDirection:T}=S,E=T,D=!1;w!==m&&(E=zy(w,m,a,v),D=w!=null&&m!=null&&x(m)==null);let O=D?w:m,k=w!==O||T!==E;X(()=>{k&&C({previousValue:O,tabActivationDirection:E})},[O,k,E]);let A=Q((e,t)=>{t.activationDirection=zy(m,e,a,v),i?.(e,t),!t.isCanceled&&h(()=>e)}),j=Q((e,t)=>{i?.(e,vc(t,void 0,void 0,{activationDirection:`none`}))}),M=Q((e,t)=>(p(n=>{let r=new Map(n);return r.set(e,t),r}),()=>{p(n=>{if(n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})})),N=_.useCallback(e=>f.get(e),[f]),P=_.useCallback(e=>{for(let t of v.values())if(e===t.value)return t.id},[v]),F=_.useMemo(()=>({getTabElementBySelectedValue:x,getTabIdByPanelValue:P,getTabPanelIdByValue:N,onValueChange:A,orientation:a,registerMountedTabPanel:M,setTabMap:y,tabActivationDirection:E,value:m}),[x,P,N,A,a,M,y,E,m]),I=_.useMemo(()=>{for(let e of v.values())if(e.value===m)return e},[v,m]),L=_.useMemo(()=>{for(let e of v.values())if(!e.disabled)return e.value},[v]),R=_.useRef(!u),z=_.useRef(r),B=_.useRef(u),V=_.useRef(!1);X(()=>{if(g)return;function e(e,t){h(()=>e),C({previousValue:e,tabActivationDirection:`none`}),j(e,t),R.current=!1}if(v.size===0){V.current&&m!==null&&!b.current?.isConnected&&e(null,Ac);return}V.current=!0,b.current=v.keys().next().value;let t=I?.disabled,n=I==null&&m!==null;if(!t&&m===z.current&&(B.current=!1),B.current&&t&&m===z.current)return;let r=R.current;if(t||n){let n=L??null;if(m===n){R.current=!1;return}let i=Ac;r?i=jc:t&&(i=kc),e(n,i)}else r&&I!=null&&(j(m,jc),R.current=!1)},[L,g,j,I,h,v,m]);let H=fi(`div`,e,{state:{orientation:a,tabActivationDirection:E},ref:t,props:l,stateAttributesMapping:Iy});return(0,Y.jsx)(Ny.Provider,{value:F,children:(0,Y.jsx)(s_,{elementsRef:d,children:H})})});Ly.displayName=`TabsRoot`;function Ry(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function zy(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=Ry(r,e),c=Ry(r,t);if(s==null||c==null)return s!==c&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?t>e?o:a:`none`;let l=s.getBoundingClientRect()[i],u=c.getBoundingClientRect()[i];return u<l?a:u>l?o:`none`}var By=_.createContext(void 0);By.displayName=`TabsListContext`;function Vy(){let e=_.useContext(By);if(e===void 0)throw Error(`Base UI: TabsListContext is missing. TabsList parts must be placed within <Tabs.List>.`);return e}var Hy=_.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,style:c,...l}=e,{value:u,getTabPanelIdByValue:d,onValueChange:f,orientation:p,tabActivationDirection:m}=Py(),{activateOnFocus:h,registerTabResizeObserverElement:g,tabsListElement:v}=Vy(),{highlightedIndex:y,onHighlightedIndexChange:b}=Um(),x=Xu(o),{compositeProps:S,compositeRef:C,index:w}=U_({metadata:_.useMemo(()=>({disabled:r,id:x,value:a}),[r,x,a])}),T=a===u,E=_.useRef(!1),D=_.useRef(null),O=Q(e=>{D.current?.(),D.current=e?g(e):null});X(()=>{if(E.current){E.current=!1;return}if(!(T&&w>-1&&y!==w))return;let e=v;if(e!=null){let t=rs(Bs(e));if(t&&Z(e,t))return}r||b(w)},[T,w,y,b,r,v]);let{getButtonProps:k,buttonRef:A}=Km({disabled:r,native:s,focusableWhenDisabled:!0}),j=d(a),M=_.useRef(!1),N=_.useRef(!1);function P(e){f(a,vc(yc,e.nativeEvent,void 0,{activationDirection:`none`}))}function F(e){T||r||P(e)}function I(e){T||r||h&&(!M.current||N.current)&&P(e)}function L(e){if(T||r)return;M.current=!0,N.current=e.button===0;let t=Bs(e.currentTarget);function n(){M.current=!1,N.current=!1,t.removeEventListener(`pointerup`,n),t.removeEventListener(`pointercancel`,n)}t.addEventListener(`pointerup`,n),t.addEventListener(`pointercancel`,n)}return fi(`button`,e,{state:{disabled:r,active:T,orientation:p,tabActivationDirection:m},ref:[t,A,C,O],props:[S,{role:`tab`,"aria-controls":j,"aria-selected":T,id:x,onClick:F,onFocus:I,onPointerDown:L,[R_]:T?``:void 0,onKeyDownCapture(){E.current=!0}},l,k],stateAttributesMapping:Iy})});Hy.displayName=`TabsTab`;var Uy=`--active-tab-left`,Wy=`--active-tab-right`,Gy=`--active-tab-top`,Ky=`--active-tab-bottom`,qy=`--active-tab-width`,Jy=`--active-tab-height`,Yy,Xy={...Iy,activeTabPosition:()=>null,activeTabSize:()=>null},Zy=2,Qy=_.forwardRef(function(e,t){let{className:n,render:r,renderBeforeHydration:i=!1,style:a,...o}=e,{getTabElementBySelectedValue:s,orientation:c,tabActivationDirection:l,value:u}=Py(),{tabsListElement:d,registerIndicatorUpdateListener:f}=Vy(),p=Uc();_.useEffect(()=>f(p),[f,p]);let m=0,h=0,g=0,v=0,y=0,b=0,x=!1;if(u!=null&&d!=null){let e=s(u);if(e!=null){x=!0;let{width:t,height:n}=wy(e),{width:r,height:i}=wy(d),a=e.getBoundingClientRect(),o=d.getBoundingClientRect(),s=r>0?o.width/r:1,c=i>0?o.height/i:1,l=$y(e,d);m=l.left,g=l.top;let u=(a.left-o.left)/s+d.scrollLeft-d.clientLeft,f=(a.top-o.top)/c+d.scrollTop-d.clientTop,p=tb(e);Math.abs(u-p.x-m)<=Zy&&Math.abs(f-p.y-g)<=Zy&&(m=u,g=f),y=t,b=n,h=d.scrollWidth-m-y,v=d.scrollHeight-g-b}}let S=x?{left:m,right:h,top:g,bottom:v}:null,C=x?{width:y,height:b}:null,w=x?{[Uy]:`${m}px`,[Wy]:`${h}px`,[Gy]:`${g}px`,[Ky]:`${v}px`,[qy]:`${y}px`,[Jy]:`${b}px`}:void 0,T=fi(`span`,e,{state:{orientation:c,activeTabPosition:S,activeTabSize:C,tabActivationDirection:l},ref:t,props:[{role:`presentation`,style:w,hidden:!(x&&y>0&&b>0)},o,{suppressHydrationWarning:!0}],stateAttributesMapping:Xy});return u==null?null:(0,Y.jsxs)(_.Fragment,{children:[T,i&&(Yy||=(0,Y.jsx)(My,{script:``}))]})});Qy.displayName=`TabsIndicator`;function $y(e,t){let n=eb(e),r=eb(t),i=n.left-r.left-t.clientLeft,a=n.top-r.top-t.clientTop,o=ia(e);for(;Ui(o)&&o!==t&&!ta(o);)i-=o.scrollLeft,a-=o.scrollTop,o=ia(o);return{left:i,top:a}}function eb(e){let t=0,n=0,r=e;for(;r!=null;){t+=r.offsetLeft,n+=r.offsetTop;let e=r.offsetParent;e!=null&&(t+=e.clientLeft,n+=e.clientTop),r=e}return{left:t,top:n}}function tb(e){let t=zi(e).getComputedStyle(e),{x:n,y:r}=ph(e,t),i=n,a=r,{translate:o}=t;if(o&&o!==`none`){let t=o.split(` `);i+=nb(t[0],e.offsetWidth),a+=nb(t[1],e.offsetHeight)}return{x:i,y:a}}function nb(e,t){if(!e)return 0;let n=parseFloat(e);return Number.isFinite(n)?e.endsWith(`%`)?n/100*t:n:0}var rb=_.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,style:o,...s}=e,{orientation:c,setTabMap:l,tabActivationDirection:u}=Py(),[d,f]=_.useState(0),[p,m]=_.useState(null),h=_.useRef(new Set),g=_.useRef(new Set),v=_.useRef(null);X(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{h.current.forEach(e=>{e()})});return v.current=e,p&&e.observe(p),g.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),v.current=null}},[p]);let y=Q(e=>(h.current.add(e),()=>{h.current.delete(e)})),b=Q(e=>(g.current.add(e),v.current?.observe(e),()=>{g.current.delete(e),v.current?.unobserve(e)})),x={orientation:c,tabActivationDirection:u},S={"aria-orientation":c===`vertical`?`vertical`:void 0,role:`tablist`},C=_.useMemo(()=>({activateOnFocus:n,registerIndicatorUpdateListener:y,registerTabResizeObserverElement:b,tabsListElement:p}),[n,y,b,p]);return(0,Y.jsx)(By.Provider,{value:C,children:(0,Y.jsx)(H_,{render:a,className:r,style:o,state:x,refs:[t,m],props:[S,s],stateAttributesMapping:Iy,highlightedIndex:d,enableHomeAndEndKeys:!0,loopFocus:i,orientation:c,onHighlightedIndexChange:f,onMapChange:l,disabledIndices:qr})})});rb.displayName=`TabsList`;var ib={variant:`segmented`,size:`base`},ab={scrollStart:`Scroll tabs left`,scrollEnd:`Scroll tabs right`};function ob({tabs:e,value:t,selectedValue:n,onValueChange:r,activateOnFocus:i,className:a,listClassName:o,indicatorClassName:s,labels:c,variant:l=ib.variant,size:u=ib.size}){let d=e??[];if(d.length===0)return null;let f=d[0]?.value,p=t!==void 0,m={value:p?t:void 0,defaultValue:p?void 0:n??f},h=l===`segmented`,g=l===`underline`,_=u===`sm`,v={...ab,...c},{ref:y,isOverflowing:b,canScrollStart:x,canScrollEnd:S}=db(!0,d.map(e=>e.value).join(`|`)),C=ub(y,b);return(0,Y.jsxs)(Ly,{...m,className:J(`relative isolate min-w-0 font-medium`,h&&(_?`rounded-md`:`rounded-lg`)+` ring ring-kumo-hairline/70`,a),onValueChange:e=>{r?.(String(e))},children:[h&&(0,Y.jsx)(`div`,{className:J(`absolute inset-x-0 top-1/2 z-0 -translate-y-1/2 rounded-lg bg-kumo-recessed`,_?`h-6.5`:`h-9`)}),(0,Y.jsxs)(rb,{ref:y,activateOnFocus:i,"data-overflowing":b?``:void 0,"data-overflow-start":x?``:void 0,"data-overflow-end":S?``:void 0,...C(),className:J(`kumo-tabs-list relative flex min-w-0 shrink scroll-px-(--scroll-fade-width) items-stretch overflow-x-auto overflow-y-hidden [--scroll-fade-width:3rem]`,h&&`rounded-lg bg-kumo-recessed px-0.5`,h&&(_?`h-6.5 rounded-md`:`h-9`),b&&`cursor-grab active:cursor-grabbing`,g&&`gap-4 border-b border-kumo-hairline pb-2`,g&&(_?`h-6.5`:`h-7.5`),o),children:[d.map(e=>(0,Y.jsx)(Hy,{"data-kumo-component":`Tabs`,"data-kumo-part":`tab`,value:e.value,render:e.render,nativeButton:e.nativeButton,onClick:e=>{e.currentTarget.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`})},className:J(`relative z-2 flex items-center rounded bg-transparent whitespace-nowrap focus:ring-kumo-focus/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-kumo-brand`,b?`cursor-grab active:cursor-grabbing`:`cursor-pointer`,_?`text-xs`:`text-base`,h&&`my-0.5 text-kumo-subtle hover:text-kumo-default focus-visible:ring-inset aria-selected:text-kumo-default`,h&&(_?`rounded-sm px-2`:`rounded-md px-2.5`),g&&`text-kumo-subtle hover:bg-kumo-tint hover:text-kumo-default aria-selected:font-medium aria-selected:text-kumo-default aria-selected:hover:bg-kumo-tint`,g&&(_?`px-1.5 py-2.5`:`px-2 py-3`),e.className),children:e.label},e.value)),(0,Y.jsx)(Qy,{render:e=>(0,Y.jsx)(`div`,{...e,className:J(`absolute left-0 z-1`,`w-(--active-tab-width) translate-x-(--active-tab-left) transition-all duration-200`,h&&J(`top-(--active-tab-top) h-(--active-tab-height) bg-kumo-base shadow-sm ring ring-kumo-line`,_?`rounded`:`rounded-md`),g&&`bottom-0 h-0.5 bg-kumo-brand`,s)})})]}),h&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(sb,{side:`start`,visible:x,variant:l,size:u,label:v.scrollStart,onClick:()=>cb(y,`start`)}),(0,Y.jsx)(sb,{side:`end`,visible:S,variant:l,size:u,label:v.scrollEnd,onClick:()=>cb(y,`end`)})]})]})}function sb({side:e,visible:t,variant:n,size:r,label:i,onClick:a}){let o=e===`start`,s=n===`segmented`;return(0,Y.jsx)(`button`,{type:`button`,"data-kumo-component":`Tabs`,"data-kumo-part":`overflow-control`,"data-side":e,"aria-label":i,"aria-hidden":!t,tabIndex:t?0:-1,onClick:a,className:J(`absolute inset-y-0 z-3 flex items-center border-0 bg-transparent p-0 transition-opacity duration-150 focus:outline-none focus-visible:[&>span]:ring-2 focus-visible:[&>span]:ring-kumo-brand`,o?`left-0 justify-start bg-linear-to-r`:`right-0 justify-end bg-linear-to-l`,t?`pointer-events-auto opacity-100`:`pointer-events-none opacity-0`,s?`from-kumo-recessed via-kumo-recessed/95 to-transparent`:`from-kumo-base via-kumo-base/95 to-transparent`,s&&(r===`sm`?`w-8 rounded-md`:`w-10 rounded-lg`),!s&&`w-8`),children:(0,Y.jsx)(`span`,{className:J(`flex items-center justify-center text-kumo-subtle transition-colors hover:text-kumo-default`,r===`sm`?`size-5`:`size-6`,s?r===`sm`?`rounded-sm`:`rounded-md`:`rounded`,o?`ml-1`:`mr-1`),children:(0,Y.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,className:`size-3.5`,"aria-hidden":`true`,children:(0,Y.jsx)(`path`,{d:o?`M9.25 4.25L5.75 8L9.25 11.75`:`M6.75 4.25L10.25 8L6.75 11.75`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`})})})})}function cb(e,t){let n=e.current;if(!n)return;let r=Array.from(n.querySelectorAll(`[data-kumo-part="tab"]`)),i=lb(n.clientWidth,r);n.scrollBy({left:t===`start`?-i:i,behavior:`smooth`})}function lb(e,t){let n=0;for(let r of t){let t=r.offsetWidth;if(n+t>e)return n||e;n+=t}return Math.max(80,Math.floor(e*.8))}function ub(e,t){let n=(0,_.useRef)(null),r=(0,_.useRef)(!1);return()=>({onPointerDownCapture:i=>{let a=e.current;a&&t&&i.pointerType===`mouse`&&i.button===0&&(n.current={pointerId:i.pointerId,startX:i.clientX,scrollLeft:a.scrollLeft,dragging:!1},r.current=!1)},onPointerMoveCapture:i=>{let a=e.current,o=n.current;if(!a||!t||!o||o.pointerId!==i.pointerId)return;let s=i.clientX-o.startX;if(!o.dragging){if(Math.abs(s)<=3)return;o.dragging=!0,r.current=!0,a.setPointerCapture(i.pointerId)}i.preventDefault(),a.scrollLeft=o.scrollLeft-s},onPointerUpCapture:t=>{let i=e.current,a=n.current;i&&a&&a.pointerId===t.pointerId&&(n.current=null,i.hasPointerCapture(t.pointerId)&&i.releasePointerCapture(t.pointerId),r.current&&window.setTimeout(()=>{r.current=!1},0))},onPointerCancelCapture:t=>{let r=e.current,i=n.current;r&&i&&i.pointerId===t.pointerId&&(n.current=null,r.hasPointerCapture(t.pointerId)&&r.releasePointerCapture(t.pointerId))},onClickCapture:e=>{r.current&&=(e.preventDefault(),e.stopPropagation(),!1)}})}function db(e,t){let n=(0,_.useRef)(null),[r,i]=(0,_.useState)({isOverflowing:!1,canScrollStart:!1,canScrollEnd:!1});return(0,_.useLayoutEffect)(()=>{if(!e)return;let t=n.current;t&&i(e=>fb(t,e))},[e,t]),(0,_.useEffect)(()=>{if(!e)return;let t=n.current;if(!t)return;let r=()=>{i(e=>fb(t,e))},a=new ResizeObserver(r);a.observe(t);let o=new MutationObserver(r);return o.observe(t,{childList:!0,characterData:!0,subtree:!0}),t.addEventListener(`scroll`,r,{passive:!0}),r(),()=>{a.disconnect(),o.disconnect(),t.removeEventListener(`scroll`,r)}},[e]),{ref:n,...r}}function fb(e,t){let n=Math.max(0,e.scrollWidth-e.clientWidth),r=Math.min(Math.max(0,e.scrollLeft),n),i={isOverflowing:n>1,canScrollStart:r>1,canScrollEnd:n-r>1};return t.isOverflowing===i.isOverflowing&&t.canScrollStart===i.canScrollStart&&t.canScrollEnd===i.canScrollEnd?t:i}var pb={layout:{auto:{classes:``,description:`Auto table layout - columns resize based on content`},fixed:{classes:`table-fixed`,description:`Fixed table layout - columns have equal width, controlled via colgroup`}},variant:{default:{classes:`even:bg-kumo-elevated [--kumo-table-row-bg:var(--color-kumo-base)] even:[--kumo-table-row-bg:var(--color-kumo-elevated)]`,description:`Default row variant`},selected:{classes:`bg-kumo-tint [--kumo-table-row-bg:var(--color-kumo-tint)]`,description:`Selected row variant`}},sticky:{left:{classes:`sticky left-0`,description:`Pin column to the left edge of the scroll container`},right:{classes:`sticky right-0`,description:`Pin column to the right edge of the scroll container`}}},mb=(e,t)=>{let n=yr(pb.sticky,e,`left`).classes,r=t===`head`?`z-2`:`z-1`,i=e===`right`?`before:-left-6`:`before:-right-6`,a=`before:pointer-events-none before:absolute before:inset-y-0 before:w-6`;return t===`cell`?J(n,r,`bg-(--kumo-table-row-bg)`,a,i,e===`right`?`before:bg-gradient-to-r before:from-transparent before:to-(--kumo-table-row-bg)`:`before:bg-gradient-to-l before:from-transparent before:to-(--kumo-table-row-bg)`):J(n,r,`bg-kumo-base group-data-[compact]/header:bg-kumo-elevated`,a,i,e===`right`?`before:bg-gradient-to-r before:from-transparent before:to-kumo-base group-data-[compact]/header:before:to-kumo-elevated`:`before:bg-gradient-to-l before:from-transparent before:to-kumo-base group-data-[compact]/header:before:to-kumo-elevated`)},hb={layout:`auto`,variant:`default`},gb=(0,_.forwardRef)(({layout:e=`auto`,...t},n)=>{let r=J(`isolate w-full`,yr(pb.layout,e,hb.layout).classes,`[&_td]:p-3`,`[&_th]:border-b [&_th]:border-kumo-fill [&_th]:p-3 [&_th]:text-base [&_th]:font-semibold`,`[&_th]:bg-kumo-base`,`text-left text-base text-kumo-default`,t.className);return(0,Y.jsx)(`table`,{ref:n,...t,className:r})}),_b=(0,_.forwardRef)(({variant:e=`default`,sticky:t,...n},r)=>{let i=e===`compact`,a=J(`group/header`,i&&`text-xs text-kumo-strong [&_th]:bg-kumo-elevated [&_th]:py-2`,t&&`[&_th]:sticky [&_th]:top-0 [&_th]:z-1`,n.className);return(0,Y.jsx)(`thead`,{ref:r,...n,className:a,...i&&{"data-compact":``}})}),vb=(0,_.forwardRef)(({sticky:e,...t},n)=>{let r=J(`group relative`,e&&mb(e,`head`),t.className);return(0,Y.jsx)(`th`,{ref:n,...t,className:r})}),yb=(0,_.forwardRef)(({variant:e=hb.variant,...t},n)=>{let r=J(yr(pb.variant,e,hb.variant).classes,t.className);return(0,Y.jsx)(`tr`,{ref:n,...t,className:r})}),bb=(0,_.forwardRef)((e,t)=>(0,Y.jsx)(`tbody`,{ref:t,...e})),xb=(0,_.forwardRef)(({sticky:e,...t},n)=>{let r=J(e&&mb(e,`cell`),t.className);return(0,Y.jsx)(`td`,{ref:n,...t,className:r})}),Sb=(0,_.forwardRef)((e,t)=>(0,Y.jsx)(`tfoot`,{ref:t,...e})),Cb=(0,_.forwardRef)((e,t)=>(0,Y.jsx)(`button`,{ref:t,...e,type:`button`,"aria-label":`Resize column`,className:J(`invisible h-full group-hover:visible`,`w-[10px]`,`flex items-center justify-center`,`cursor-col-resize touch-none select-none`,`absolute top-0 right-0`,`m-0 bg-kumo-base p-0`,`focus-visible:ring-2 focus-visible:ring-kumo-brand`),children:(0,Y.jsx)(`span`,{className:`h-5 w-[2px] rounded bg-kumo-hairline`})})),wb=(0,_.forwardRef)(({checked:e,indeterminate:t,onCheckedChange:n,onValueChange:r,label:i,disabled:a,...o},s)=>(0,Y.jsx)(xb,{ref:s,...o,className:J(`w-10 leading-none`,o.className),children:(0,Y.jsx)(lh,{checked:e,indeterminate:t,onCheckedChange:(e,t)=>{n?.(e,t),r?.(e)},"aria-label":i??`Select row`,disabled:a,className:`relative before:absolute before:-inset-3 before:content-['']`})})),Tb=(0,_.forwardRef)(({checked:e,indeterminate:t,onCheckedChange:n,onValueChange:r,label:i,disabled:a,...o},s)=>(0,Y.jsx)(vb,{ref:s,...o,className:J(`w-10 leading-none`,o.className),children:(0,Y.jsx)(lh,{checked:e,indeterminate:t,onCheckedChange:(e,t)=>{n?.(e,t),r?.(e)},"aria-label":i??`Select all rows`,disabled:a,className:`relative before:absolute before:-inset-3 before:content-['']`})}));gb.displayName=`Table`,bb.displayName=`Table.Body`,vb.displayName=`Table.Head`,yb.displayName=`Table.Row`,xb.displayName=`Table.Cell`,Sb.displayName=`Table.Footer`,_b.displayName=`Table.Header`,Cb.displayName=`Table.ResizeHandle`,wb.displayName=`Table.CheckCell`,Tb.displayName=`Table.CheckHead`;var $=Object.assign(gb,{Header:_b,Head:vb,Row:yb,Body:bb,Cell:xb,CheckCell:wb,CheckHead:Tb,Footer:Sb,ResizeHandle:Cb}),Eb={size:{sm:{classes:`text-sm h-10 gap-0.5`,description:`Compact breadcrumbs for dense UIs`},base:{classes:`text-base h-12 gap-1`,description:`Default breadcrumbs size`}}},Db={size:`base`};function Ob({size:e=Db.size}={}){return J(`group mr-4 flex min-w-0 grow items-center overflow-hidden whitespace-nowrap`,yr(Eb.size,e,Db.size).classes)}var kb=({href:e,icon:t,children:n})=>{let r=kr();return(0,Y.jsxs)(r,{"data-kumo-component":`Breadcrumbs`,"data-kumo-part":`link`,to:e,className:`flex shrink-0 items-center gap-1 whitespace-nowrap text-kumo-subtle no-underline`,children:[!!t&&(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center`,children:t}),(0,Y.jsx)(`span`,{children:n})]})};function Ab({children:e,icon:t,loading:n}){return n?(0,Y.jsxs)(`div`,{className:`flex w-[125px] min-w-0 items-center gap-1`,children:[t&&(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center`,children:t}),(0,Y.jsx)(rv,{})]}):(0,Y.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1 font-medium`,"aria-current":`page`,children:[t&&(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center`,children:t}),(0,Y.jsx)(`span`,{className:`truncate`,children:e})]})}function jb(){return(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center text-kumo-inactive`,"aria-hidden":`true`,children:(0,Y.jsx)(`svg`,{width:`24`,height:`24`,fill:`none`,viewBox:`0 0 24 24`,children:(0,Y.jsx)(`path`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,d:`M10.75 8.75L14.25 12L10.75 15.25`})})})}function Mb(){return(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center text-kumo-subtle`,"aria-hidden":!0,children:`...`})}function Nb({text:e}){let{copied:t,runCopy:n}=ev();return(0,Y.jsx)(kp,{variant:`ghost`,shape:`square`,size:`sm`,className:`opacity-0 transition-[opacity] group-hover:opacity-100`,onClick:async()=>{e&&await n(()=>navigator.clipboard.writeText(e),e=>console.error(`Failed to copy deeplink:`,e))},title:`Click to copy`,"aria-label":`Copy`,children:t?(0,Y.jsx)(Hf,{weight:`bold`,className:`text-kumo-success`}):(0,Y.jsx)(Wf,{weight:`regular`})})}function Pb({children:e,size:t=`base`,className:n}){let r=_.Children.toArray(e),i=Ib(r);return(0,Y.jsxs)(`nav`,{className:J(Ob({size:t}),n),"aria-label":`breadcrumb`,children:[(0,Y.jsx)(`div`,{className:`contents sm:hidden`,children:i}),(0,Y.jsx)(`div`,{className:`hidden sm:contents`,children:r})]})}function Fb(e,t){return(0,_.isValidElement)(e)&&e.type===t}function Ib(e){let t=e.filter(e=>Fb(e,kb)||Fb(e,Ab));if(t.length<=2)return e;let[n,r]=t.slice(-2),i=[(0,Y.jsx)(Mb,{},`kumo-breadcrumb-mobile-ellipsis`),(0,Y.jsx)(jb,{},`kumo-breadcrumb-mobile-separator-leading`),(0,_.cloneElement)(n,{key:`kumo-breadcrumb-mobile-parent`}),(0,Y.jsx)(jb,{},`kumo-breadcrumb-mobile-separator-trailing`),(0,_.cloneElement)(r,{key:`kumo-breadcrumb-mobile-current`})],a=e.filter(e=>!Fb(e,kb)&&!Fb(e,Ab)&&!Fb(e,jb));return[...i,...a]}Pb.Link=kb,Pb.Current=Ab,Pb.Separator=jb,Pb.Clipboard=Nb;var Lb={size:{sm:{classes:`px-6 py-8 gap-4`,description:`Compact empty state for smaller containers`},base:{classes:`px-10 py-16 gap-6`,description:`Default empty state size`},lg:{classes:`px-12 py-20 gap-8`,description:`Large empty state for prominent placement`}}},Rb={size:`base`};function zb({size:e=Rb.size}={}){return J(`flex w-full flex-col items-center rounded-xl border border-kumo-fill bg-kumo-control text-kumo-default`,yr(Lb.size,e,Rb.size).classes)}function Bb({icon:e,title:t,description:n,commandLine:r,contents:i,size:a=`base`,className:o}){let{copied:s,runCopy:c}=ev(1e3),l=(0,_.useCallback)(async()=>{r&&await c(()=>navigator.clipboard.writeText(r),e=>console.warn(`Clipboard copy failed`,e))},[r,c]);return(0,Y.jsxs)(`div`,{className:J(zb({size:a}),o),children:[e,(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-2.5`,children:[n?(0,Y.jsx)(Jh,{variant:`heading`,size:`lg`,as:`h2`,children:t}):(0,Y.jsx)(Jh,{variant:`secondary`,size:`base`,as:`h2`,children:t}),n&&(0,Y.jsx)(Jh,{variant:`secondary`,size:`base`,DANGEROUS_className:`max-w-140 text-center text-balance leading-normal`,children:n})]}),r&&(0,Y.jsxs)(`div`,{className:J(`relative inline-flex h-10 max-w-8/10 transform-gpu items-center gap-2 rounded-lg border border-white bg-kumo-overlay pr-2 pl-3 font-mono shadow-xs ring ring-kumo-line`),children:[(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 items-baseline gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-kumo-subtle select-none`,children:`$`}),(0,Y.jsx)(`span`,{className:`no-scrollbar overflow-scroll text-base whitespace-nowrap`,children:r})]}),(0,Y.jsx)(kp,{className:`text-kumo-subtle`,size:`sm`,variant:`ghost`,shape:`square`,"aria-label":`Copy command`,onClick:l,children:s?(0,Y.jsx)(Hf,{size:16,className:`animate-bounce-in text-kumo-success`}):(0,Y.jsx)(Wf,{size:16})})]}),i]})}var Vb=_.createContext(void 0);Vb.displayName=`ScrollAreaRootContext`;function Hb(){let e=_.useContext(Vb);if(e===void 0)throw Error(`Base UI: ScrollAreaRootContext is missing. ScrollArea parts must be placed within <ScrollArea.Root>.`);return e}function Ub(e,t,n){if(!e)return 0;let r=getComputedStyle(e),i=`${t}${n===`x`?`Inline`:`Block`}`,a=parseFloat(r[`${i}Start`]);return n===`x`&&t===`margin`?a*2:a+parseFloat(r[`${i}End`])}var Wb=`data-has-overflow-x`,Gb=`data-has-overflow-y`,Kb=`data-overflow-x-start`,qb=`data-overflow-x-end`,Jb=`data-overflow-y-start`,Yb=`data-overflow-y-end`,Xb=e=>t=>t?{[e]:``}:null,Zb={hasOverflowX:Xb(Wb),hasOverflowY:Xb(Gb),overflowXStart:Xb(Kb),overflowXEnd:Xb(qb),overflowYStart:Xb(Jb),overflowYEnd:Xb(Yb),cornerHidden:()=>null},Qb=`--scroll-area-corner-height`,$b=`--scroll-area-corner-width`,ex=`data-orientation`,tx={x:0,y:0},nx={width:0,height:0},rx={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},ix={x:!0,y:!0,corner:!0},ax=_.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=ox(i),d=Xu(),f=zl(),p=zl(),{nonce:m,disableStyleElements:h}=fv(),[g,v]=_.useState(!1),[y,b]=_.useState(!1),[x,S]=_.useState(!1),[C,w]=_.useState(!1),[T,E]=_.useState(!1),[D,O]=_.useState(nx),[k,A]=_.useState(nx),[j,M]=_.useState(rx),[N,P]=_.useState(ix),F=_.useRef(null),I=_.useRef(null),L=_.useRef(null),R=_.useRef(null),z=_.useRef(null),B=_.useRef(null),V=_.useRef(null),H=_.useRef(null),U=_.useRef(0),ee=_.useRef(0),te=_.useRef(0),W=_.useRef(0),ne=_.useRef(`vertical`),re=_.useRef(tx),ie=_.useRef(null);function ae(e){let t=e?S:b,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let G=Q(e=>{let t=e.x-re.current.x,n=e.y-re.current.y;re.current=e,n!==0&&ae(!0),t!==0&&ae(!1)}),K=Q(()=>{let e=I.current;e&&ie.current===null&&(ie.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),oe=Q(e=>{if(e.button!==0||H.current!==null&&(ne.current===`vertical`?z.current:B.current)?.hasPointerCapture(H.current))return;H.current=e.pointerId,U.current=e.clientY,ee.current=e.clientX,ne.current=e.currentTarget.getAttribute(ex);let t=I.current;t&&(te.current=t.scrollTop,W.current=t.scrollLeft,K()),(ne.current===`vertical`?z.current:B.current)?.setPointerCapture(e.pointerId)}),se=Q(e=>{if(e.pointerId!==H.current)return;H.current=null,(ne.current===`vertical`?S:b)(!1),ie.current!==null&&(I.current&&(I.current.style.scrollSnapType=ie.current),ie.current=null);let t=ne.current===`vertical`?z.current:B.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),ce=Q(e=>{if(e.pointerId!==H.current)return;if(e.buttons%2==0){se(e);return}let t=I.current;if(!t)return;let n=ne.current===`vertical`,r=n?z.current:B.current,i=n?L.current:R.current;if(!r||!i)return;let a=n?`y`:`x`,o=Ub(i,`padding`,a),s=Ub(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-U.current:e.clientX-ee.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?te.current:W.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),ae(n)});function le(e){w(e.pointerType===`touch`)}function ue(e){if(le(e),e.pointerType!==`touch`){let t=Z(F.current,e.target);v(t)}}let q=_.useMemo(()=>({scrolling:y||x,hasOverflowX:!N.x,hasOverflowY:!N.y,overflowXStart:j.xStart,overflowXEnd:j.xEnd,overflowYStart:j.yStart,overflowYEnd:j.yEnd,cornerHidden:N.corner}),[y,x,N.x,N.y,N.corner,j]),de={role:`presentation`,onPointerEnter:ue,onPointerMove:ue,onPointerDown:le,onPointerLeave(){v(!1)},style:{position:`relative`,[Qb]:`${D.height}px`,[$b]:`${D.width}px`}},fe=fi(`div`,e,{state:q,ref:[t,F],props:[de,o],stateAttributesMapping:Zb}),pe=_.useMemo(()=>({handlePointerDown:oe,handlePointerMove:ce,handlePointerUp:se,handleScroll:G,disableViewportSnap:K,cornerSize:D,setCornerSize:O,thumbSize:k,setThumbSize:A,hasMeasuredScrollbar:T,setHasMeasuredScrollbar:E,touchModality:C,cornerRef:V,scrollingX:y,scrollingY:x,hovering:g,setHovering:v,viewportRef:I,scrollbarYRef:L,scrollbarXRef:R,thumbYRef:z,thumbXRef:B,rootId:d,hiddenState:N,setHiddenState:P,overflowEdges:j,setOverflowEdges:M,viewportState:q,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[oe,ce,se,G,K,D,k,T,C,y,x,g,d,N,j,q,s,c,l,u]);return(0,Y.jsxs)(Vb.Provider,{value:pe,children:[!h&&lv.getElement(m),fe]})});ax.displayName=`ScrollAreaRoot`;function ox(e){let t=typeof e==`number`?{xStart:e,xEnd:e,yStart:e,yEnd:e}:e;return{xStart:Math.max(0,t?.xStart||0),xEnd:Math.max(0,t?.xEnd||0),yStart:Math.max(0,t?.yStart||0),yEnd:Math.max(0,t?.yEnd||0)}}var sx=_.createContext(void 0);sx.displayName=`ScrollAreaViewportContext`;function cx(){let e=_.useContext(sx);if(e===void 0)throw Error(`Base UI: ScrollAreaViewportContext missing. ScrollAreaViewport parts must be placed within <ScrollArea.Viewport>.`);return e}var lx=`--scroll-area-overflow-x-start`,ux=`--scroll-area-overflow-x-end`,dx=`--scroll-area-overflow-y-start`,fx=`--scroll-area-overflow-y-end`,px=`--scroll-area-thumb-height`,mx=`--scroll-area-thumb-width`,hx=[lx,ux,dx,fx],gx=!1;function _x(){gx||_c||(typeof CSS<`u`&&`registerProperty`in CSS&&hx.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),gx=!0)}var vx=_.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{viewportRef:o,scrollbarYRef:s,scrollbarXRef:c,thumbYRef:l,thumbXRef:u,cornerRef:d,cornerSize:f,setCornerSize:p,setThumbSize:m,rootId:h,setHiddenState:g,hiddenState:v,setHasMeasuredScrollbar:y,handleScroll:b,touchModality:x,setHovering:S,setOverflowEdges:C,overflowEdgeThreshold:w,viewportState:T}=Hb(),E=$u(),D=_.useRef(!0),O=_.useRef([NaN,NaN,NaN,NaN]),k=zl(),A=zl(),j=Q(()=>{let e=o.current,t=s.current,n=c.current,r=l.current,i=u.current,a=d.current;if(!e)return;let h=e.scrollHeight,_=e.scrollWidth,v=e.clientHeight,b=e.clientWidth,x=e.scrollTop,S=e.scrollLeft,T=O.current,D=Number.isNaN(T[0]);if(T[0]=v,T[1]=h,T[2]=b,T[3]=_,D&&y(!0),h===0||_===0)return;let k=yx(e),A=k.y,j=k.x,M=b/_,N=v/h,P=Math.max(0,_-b),F=Math.max(0,h-v),I=0,L=0;j||(I=sv(E===`rtl`?-S:S,P),L=P-I);let R=A?0:sv(x,F),z=A?0:F-R,B=j?0:b,V=A?0:v,H=0,U=0;!j&&!A&&(H=t?.offsetWidth||0,U=n?.offsetHeight||0);let ee=f.width===0&&f.height===0,te=ee?H:0,W=ee?U:0,ne=Ub(n,`padding`,`x`),re=Ub(t,`padding`,`y`),ie=Ub(i,`margin`,`x`),ae=Ub(r,`margin`,`y`),G=B-ne-ie,K=V-re-ae,oe=n?Math.min(n.offsetWidth-te,G):G,se=t?Math.min(t.offsetHeight-W,K):K,ce=Math.max(16,oe*M),le=Math.max(16,se*N);if(m(e=>bx(e,{width:ce,height:le})),t&&r){let e=xx(r,px,x,F,h,le,t.offsetHeight-le-re-ae);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-ce-ne-ie,t=xx(i,mx,E===`rtl`?-S:S,P,_,ce,e);i.style.transform=`translate3d(${E===`rtl`?-t:t}px,0,0)`}let ue=[I,L,R,z];hx.forEach((t,n)=>{e.style.setProperty(t,`${ue[n]}px`)}),a&&p(e=>bx(e,{width:H,height:U})),g(e=>bx(e,k));let q={xStart:!j&&I>w.xStart,xEnd:!j&&L>w.xEnd,yStart:!A&&R>w.yStart,yEnd:!A&&z>w.yEnd};C(e=>bx(e,q))});X(()=>{_x()},[]),X(()=>{queueMicrotask(j)},[j,v,E,w.xStart,w.xEnd,w.yStart,w.yEnd]),X(()=>{o.current?.matches(`:hover`)&&S(!0)},[o,S]),X(()=>{let e=o.current;if(typeof ResizeObserver>`u`||!e)return;let t=!1,n=new ResizeObserver(()=>{if(!t){t=!0;let n=O.current;if(n[0]===e.clientHeight&&n[1]===e.scrollHeight&&n[2]===e.clientWidth&&n[3]===e.scrollWidth)return}j()});return n.observe(e),A.start(0,()=>{let t=ql(e,{subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished.then(Kr))).then(j).catch(()=>{})}),()=>{n.disconnect(),A.clear()}},[j,o,A]);function M(){D.current=!1}let N={...h&&{"data-id":`${h}-viewport`},tabIndex:v.x&&v.y?-1:0,className:lv.className,style:{overflow:`scroll`},onScroll(){o.current&&(j(),(x||!D.current)&&b({x:o.current.scrollLeft,y:o.current.scrollTop}),k.start(100,()=>{D.current=!0}))},onWheel:M,onPointerMove:M,onPointerEnter:M,onKeyDown:M},P=fi(`div`,e,{ref:[t,o],state:T,props:[N,a],stateAttributesMapping:Zb}),F=_.useMemo(()=>({computeThumbPosition:j}),[j]);return(0,Y.jsx)(sx.Provider,{value:F,children:P})});vx.displayName=`ScrollAreaViewport`;function yx(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function bx(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function xx(e,t,n,r,i,a,o){let s=fh(n,0,r),c=n-s,l=Math.max(16,a*i/(i+Math.abs(c)));return e.style.setProperty(t,c?`${l}px`:``),(r?s/r*o:0)+(c>0?a-l:0)}var Sx=_.createContext(void 0);Sx.displayName=`ScrollAreaScrollbarContext`;function Cx(){let e=_.useContext(Sx);if(e===void 0)throw Error(`Base UI: ScrollAreaScrollbarContext is missing. ScrollAreaScrollbar parts must be placed within <ScrollArea.Scrollbar>.`);return e}var wx=_.forwardRef(function(e,t){let{render:n,className:r,orientation:i=`vertical`,keepMounted:a=!1,style:o,...s}=e,{hovering:c,scrollingX:l,scrollingY:u,hiddenState:d,scrollbarYRef:f,scrollbarXRef:p,viewportRef:m,thumbYRef:h,thumbXRef:g,handlePointerDown:v,handlePointerUp:y,handleScroll:b,disableViewportSnap:x,rootId:S,thumbSize:C,hasMeasuredScrollbar:w,viewportState:T}=Hb(),E=i===`vertical`,D={...T,hovering:c,scrolling:E?u:l,orientation:i},O=$u(),k=!w&&!a,A=E?d.y:d.x,j=a||!A;_.useEffect(()=>{if(!j)return;let e=m.current,t=E?f.current:p.current;if(!t)return;function n(t){if(!e||t.ctrlKey)return;let n=!E,r=n?`scrollLeft`:`scrollTop`,i=n?t.deltaX:t.deltaY;if(i===0)return;let a=n?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight,o=n&&O===`rtl`?-a:0,s=n&&O===`rtl`?0:a,c=e[r];c<=o&&i<0||c>=s&&i>0||(t.preventDefault(),e[r]=Math.min(s,Math.max(o,c+i)),b({x:e.scrollLeft,y:e.scrollTop}))}return Pc(t,`wheel`,n,{passive:!1})},[O,b,E,p,f,j,m]);let M={...S&&{"data-id":`${S}-scrollbar`},"aria-hidden":!0,onPointerDown(e){if(e.button!==0)return;let t=as(e.nativeEvent),n=E?h.current:g.current;if(n&&Z(n,t))return;let r=m.current;if(!r)return;let i=E?f.current:p.current;if(!n||!i)return;let a=E?`y`:`x`,o=Ub(n,`margin`,a),s=Ub(i,`padding`,a),c=E?n.offsetHeight:n.offsetWidth,l=i.getBoundingClientRect(),u=E?e.clientY-l.top-c/2-s+o/2:e.clientX-l.left-c/2-s+o/2,d=E?r.scrollHeight:r.scrollWidth,_=E?r.clientHeight:r.clientWidth,y=(E?i.offsetHeight:i.offsetWidth)-c-s-o;if(y<=0)return;let S=u/y,C=d-_;x(),E?r.scrollTop=S*C:r.scrollLeft=O===`rtl`?-(1-S)*C:S*C,b({x:r.scrollLeft,y:r.scrollTop}),v(e)},onMouseDown(e){e.preventDefault()},onPointerUp:y,onPointerCancel:y,style:{position:`absolute`,touchAction:`none`,WebkitUserSelect:`none`,userSelect:`none`,visibility:k?`hidden`:void 0,...E?{top:0,bottom:`var(${Qb})`,insetInlineEnd:0,[px]:`${C.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${$b})`,bottom:0,[mx]:`${C.width}px`}}},N=fi(`div`,e,{ref:[t,E?f:p],state:D,props:[M,s],stateAttributesMapping:Zb});return j?(0,Y.jsx)(Sx.Provider,{value:i,children:N}):null});wx.displayName=`ScrollAreaScrollbar`;var Tx=_.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{computeThumbPosition:o}=cx(),{hasMeasuredScrollbar:s,viewportState:c}=Hb(),l=_.useRef(null),u=_.useRef(s);return X(()=>{if(typeof ResizeObserver>`u`)return;let e=!1,t=new ResizeObserver(()=>{!e&&(e=!0,!u.current)||o()});return l.current&&t.observe(l.current),()=>{t.disconnect()}},[o]),fi(`div`,e,{ref:[t,l],state:c,stateAttributesMapping:Zb,props:[{role:`presentation`,style:{minWidth:`fit-content`}},a]})});Tx.displayName=`ScrollAreaContent`;var Ex=_.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{thumbYRef:o,thumbXRef:s,handlePointerDown:c,handlePointerMove:l,handlePointerUp:u,scrollingX:d,scrollingY:f,hasMeasuredScrollbar:p}=Hb(),m=Cx(),h=m===`vertical`;return fi(`div`,e,{ref:[t,h?o:s],state:{scrolling:h?f:d,orientation:m},props:[{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,style:{visibility:p?void 0:`hidden`,...h?{height:`var(--scroll-area-thumb-height)`}:{width:`var(--scroll-area-thumb-width)`}}},a]})});Ex.displayName=`ScrollAreaThumb`;var Dx={variant:`sidebar`,collapsible:`icon`,side:`left`},Ox=`16.25rem`,kx=`57px`,Ax=`cubic-bezier(0.77, 0, 0.175, 1)`,jx=250,Mx=50,Nx=768,Px=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function Fx(e,t,n,r=!0){let i=r&&n!==void 0,a=(0,_.useRef)(n),o=(0,_.useRef)(t),s=(0,_.useRef)(e),c=(0,_.useRef)(r),l=(0,_.useRef)(void 0),u=(0,_.useRef)(void 0);a.current=n,o.current=t;let d=(0,_.useCallback)(()=>{let e=l.current;e!==void 0&&(l.current=void 0,clearTimeout(u.current),a.current?.(e))},[]);return(0,_.useEffect)(()=>{let t=s.current!==e,n=c.current;if(s.current=e,c.current=r,!i)l.current=void 0,clearTimeout(u.current);else if(n&&t){if(l.current=e,o.current===0||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)d();else return u.current=setTimeout(d,o.current+Mx),()=>clearTimeout(u.current)}},[r,d,i,e]),d}function Ix(e=Nx){let t=`(max-width: ${e-1}px)`,n=(0,_.useCallback)(e=>{let n=window.matchMedia(t);return n.addEventListener(`change`,e),()=>n.removeEventListener(`change`,e)},[t]),r=(0,_.useCallback)(()=>window.matchMedia(t).matches,[t]),i=(0,_.useCallback)(()=>!1,[]);return(0,_.useSyncExternalStore)(n,r,i)}var Lx=(0,_.createContext)(null);function Rx(){let e=(0,_.useContext)(Lx);if(!e)throw Error(`useSidebar must be used within a Sidebar.Provider`);return e}var zx=256,Bx=200,Vx=480;function Hx({defaultOpen:e=!0,open:t,onOpenChange:n,onOpenChangeComplete:r,variant:i=Dx.variant,side:a=Dx.side,collapsible:o=Dx.collapsible,resizable:s=!1,defaultWidth:c=zx,minWidth:l=Bx,maxWidth:u=Vx,onWidthChange:d,contained:f=!1,peekable:p=!1,animationDuration:m=jx,mobileBreakpoint:h,children:g,className:v,style:y}){let b=Ix(h),[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(c),[T,E]=(0,_.useState)(!1),[D,O]=(0,_.useState)(!1),k=b&&t!==void 0?t:x,A=(0,_.useCallback)(e=>{S(e),b&&t!==void 0&&n?.(e)},[b,t,n]),j=(0,_.useCallback)(e=>{let t=Math.min(u,Math.max(l,e));w(t),d?.(t)},[l,u,d]),[M,N]=(0,_.useState)(e),P=t??M,F=(0,_.useCallback)(e=>{let t=typeof e==`function`?e(P):e;n?.(t),N(t)},[n,P]),I=(0,_.useCallback)(()=>{b?A(!k):(O(!1),F(e=>!e))},[b,k,A,F]),L=(0,_.useCallback)(()=>{p&&!P&&!b&&O(!0)},[p,P,b]),R=(0,_.useCallback)(()=>{O(!1)},[]),z=D?`peeking`:P?`expanded`:`collapsed`,B=s?`${C}px`:Ox,V=(0,_.useRef)(new Map),H=(0,_.useCallback)((e,t)=>{let n=V.current;t?n.set(e,t):n.delete(e)},[]),U=(0,_.useCallback)((e,t={})=>{let{align:n=`auto`,behavior:r=`auto`}=t,i=V.current.get(e);if(!i)return;let a=i.closest(`[data-sidebar="viewport"]`);if(!a)return;let o=i.getBoundingClientRect(),s=a.getBoundingClientRect(),c=a.offsetHeight>0&&s.height>0?s.height/a.offsetHeight:1,l=(o.top-s.top)/c+a.scrollTop,u;if(n===`center`)u=l-(a.clientHeight-i.offsetHeight)/2;else if(n===`end`)u=l-(a.clientHeight-i.offsetHeight);else if(n===`auto`){let e=l+i.offsetHeight,t=a.scrollTop+a.clientHeight;if(l<a.scrollTop)u=l;else if(e>t)u=e-a.clientHeight;else return}else u=l;let d=Math.max(0,Math.min(u,a.scrollHeight-a.clientHeight)),f=typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;a.scrollTo({top:d,behavior:f?`auto`:r})},[]),ee=(0,_.useCallback)((e,t={})=>{let n=V.current.get(e);if(!n)return;let r=n.closest(`[data-sidebar="viewport"]`);if(!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect();i.top>=a.top&&i.bottom<=a.bottom||U(e,t)},[U]),te=(0,_.useMemo)(()=>({state:z,open:P,setOpen:F,openMobile:k,setOpenMobile:A,isMobile:b,toggleSidebar:I,variant:i,side:a,collapsible:o,width:C,resizable:s,minWidth:l,maxWidth:u,isResizing:T,setIsResizing:E,setWidth:j,isPeeking:D,peekable:p,startPeek:L,stopPeek:R,contained:f,animationDuration:m,registerItem:H,scrollToItem:U,scrollItemIntoView:ee}),[z,P,k,b,C,T,D]),W=Fx(P,m,r,!b),ne=Fx(k,m,r,b),re=b?ne:W,ie=b?`transform`:`width`,ae=(0,_.useCallback)(e=>{let t=e.target;t.closest(`[data-sidebar-wrapper]`)===e.currentTarget&&t.dataset.sidebar===`sidebar`&&e.propertyName===ie&&re()},[re,ie]);return(0,Y.jsx)(Lx.Provider,{value:te,children:(0,Y.jsx)(`div`,{"data-sidebar-wrapper":``,"data-state":z,"data-side":a,onTransitionEnd:ae,style:{"--sidebar-width":B,"--sidebar-width-icon":kx,"--sidebar-animation-duration":`${m}ms`,"--sidebar-easing":Ax,...y},className:J(`group/sidebar-wrapper relative isolate flex w-full [--sidebar-active-bg:var(--color-kumo-tint)] [--sidebar-bg:var(--color-kumo-base)]`,!f&&!b&&`min-h-svh`,`has-data-[variant=inset]:bg-kumo-recessed`,T&&`select-none`,v),children:g})})}Hx.displayName=`Sidebar.Provider`;var Ux=(0,_.forwardRef)(({className:e,contentClassName:t,children:n,fullScreenOnMobile:r=!1,...i},a)=>{let{state:o,open:s,isMobile:c,openMobile:l,setOpenMobile:u,side:d,variant:f,collapsible:p,isResizing:m,resizable:h,width:g,isPeeking:v,startPeek:y,stopPeek:b,contained:x}=Rx(),S=(0,_.useCallback)(e=>{e&&(l?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[l]),C=(0,_.useCallback)(e=>{S(e),typeof a==`function`?a(e):a&&(a.current=e)},[a,S]),w=(0,_.useRef)(null),T=(0,_.useRef)(null),E=(0,_.useRef)(!1),D=(0,_.useRef)(!1);(0,_.useEffect)(()=>{if(!c||!l)return;let e=e=>{e.key===`Escape`&&(E.current=!0,u(!1))};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[c,l,u]),(0,_.useEffect)(()=>{c&&(l?(w.current=document.activeElement,E.current=!1,requestAnimationFrame(()=>{(T.current?.querySelector(Px)??T.current)?.focus()})):E.current&&w.current instanceof HTMLElement&&(w.current.focus(),E.current=!1,w.current=null))},[c,l]);let O=(0,_.useCallback)(e=>{!e.currentTarget.contains(e.relatedTarget)&&!D.current&&b()},[b]),k=(0,_.useCallback)(()=>{D.current=!0,y()},[y]),A=(0,_.useCallback)(()=>{D.current=!1,b()},[b]);if(p===`none`)return(0,Y.jsx)(`aside`,{ref:a,"data-state":`expanded`,"data-side":d,"data-variant":f,"data-sidebar":`sidebar`,style:{width:`var(--sidebar-width)`,minWidth:`var(--sidebar-width)`,maxWidth:`var(--sidebar-width)`},className:J(`relative flex h-full shrink-0 grow-0 flex-col overflow-hidden bg-(--sidebar-bg) text-kumo-default`,f===`sidebar`&&(d===`left`?`border-r border-kumo-line`:`border-l border-kumo-line`),f===`floating`&&`m-2 rounded-lg border border-kumo-line shadow-lg`,e),...i,children:n});if(c)return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{"data-sidebar-backdrop":``,className:J(x?`absolute inset-0 z-40 bg-kumo-recessed`:`fixed inset-0 z-40 bg-kumo-recessed`,`transition-opacity duration-(--sidebar-animation-duration) ease-(--sidebar-easing)`,`motion-reduce:transition-none`,l&&!r?`opacity-80`:`pointer-events-none opacity-0`),onClick:()=>{E.current=!0,u(!1)},"aria-hidden":`true`}),(0,Y.jsx)(`nav`,{ref:e=>{C(e),T.current=e},tabIndex:-1,"aria-label":`Navigation`,"aria-hidden":!l,"data-state":l?`expanded`:`collapsed`,"data-side":d,"data-variant":f,"data-collapsible":p,"data-sidebar":`sidebar`,"data-mobile":`true`,className:J(`group/sidebar inset-y-0 z-50 flex flex-col overflow-hidden`,x?`absolute`:`fixed`,r?`w-full`:`w-(--sidebar-width)`,`bg-(--sidebar-bg) text-kumo-default`,!r&&`border-r border-kumo-line`,`transition-transform duration-(--sidebar-animation-duration) ease-(--sidebar-easing)`,`motion-reduce:transition-none`,d===`left`&&`left-0`,d===`right`&&`right-0`,d===`left`&&(l?`translate-x-0`:`-translate-x-full`),d===`right`&&(l?`translate-x-0`:`translate-x-full`),e),...i,children:n})]});let j=p===`icon`?`var(--sidebar-width-icon)`:`0px`,M=h?`${g}px`:`var(--sidebar-width)`,N=s?M:j,P=s||v?M:j,F=f===`sidebar`?d===`left`?`border-r border-kumo-line`:`border-l border-kumo-line`:f===`floating`?`border border-kumo-line`:``;return(0,Y.jsx)(`aside`,{ref:a,"data-state":o,"data-side":d,"data-variant":f,"data-collapsible":p,"data-sidebar":`sidebar`,style:{width:N},className:J(`group/sidebar relative h-full shrink-0 grow-0`,`overflow-visible`,`transition-[width] duration-(--sidebar-animation-duration) ease-(--sidebar-easing)`,`motion-reduce:transition-none`,m&&`transition-none!`,f===`floating`&&`m-2 rounded-lg shadow-lg`,e),...i,children:(0,Y.jsx)(Jd,{children:(()=>{let e=_.Children.toArray(n),r=e.filter(e=>_.isValidElement(e)&&e.type?.displayName===`Sidebar.Footer`),i=e.filter(e=>!_.isValidElement(e)||e.type?.displayName!==`Sidebar.Footer`);return(0,Y.jsxs)(`div`,{"data-sidebar":`content-container`,style:{width:P},className:J(`flex h-full flex-col`,`min-w-0 overflow-hidden whitespace-nowrap`,`bg-(--sidebar-bg) text-kumo-default`,F,`transition-[width] duration-(--sidebar-animation-duration) ease-(--sidebar-easing)`,`motion-reduce:transition-none`,m&&`transition-none!`,!s&&J(x?`absolute`:`fixed`,`inset-y-0 z-40`,d===`left`&&`left-0`,d===`right`&&`right-0`),s&&`relative`,t),children:[(0,Y.jsx)(`div`,{"data-sidebar":`peek-zone`,className:`flex min-h-0 flex-1 flex-col`,onMouseEnter:k,onMouseLeave:A,onFocus:y,onBlur:O,children:i}),r]})})()})})});Ux.displayName=`Sidebar`;var Wx=(0,_.forwardRef)(({className:e,...t},n)=>(0,Y.jsx)(`div`,{ref:n,"data-sidebar":`header`,className:J(`flex h-[58px] shrink-0 items-center gap-1 border-b border-kumo-line`,`overflow-hidden px-3`,e),...t}));Wx.displayName=`Sidebar.Header`;var Gx=(0,_.forwardRef)(({className:e,children:t,...n},r)=>(0,Y.jsxs)(ax,{ref:r,"data-sidebar":`content`,className:J(`relative min-w-0 flex-1 overflow-hidden`,e),...n,children:[(0,Y.jsx)(vx,{tabIndex:-1,"data-sidebar":`viewport`,className:J(`h-full px-[11px] py-3 group-not-data-[state=collapsed]/sidebar:px-3.5`,`transition-[padding] duration-(--sidebar-animation-duration)`,`overflow-x-hidden!`,`[mask-image:linear-gradient(to_bottom,transparent_0,black_min(24px,var(--scroll-area-overflow-y-start,24px)),black_calc(100%-min(24px,var(--scroll-area-overflow-y-end,24px))),transparent_100%)]`),children:(0,Y.jsx)(Tx,{className:`flex min-w-0! flex-col`,children:t})}),(0,Y.jsx)(wx,{orientation:`vertical`,className:J(`flex w-1.5 touch-none p-px select-none`,`opacity-0 transition-opacity duration-150`,`data-[hovering]:opacity-100 data-[scrolling]:opacity-100`,`group-data-[state=collapsed]/sidebar:hidden`),children:(0,Y.jsx)(Ex,{className:`flex-1 rounded-full bg-kumo-line`})})]}));Gx.displayName=`Sidebar.Content`;var Kx=(0,_.forwardRef)(({className:e,...t},n)=>(0,Y.jsx)(`div`,{ref:n,"data-sidebar":`footer`,className:J(`flex h-12 shrink-0 items-center gap-4 overflow-hidden border-t border-kumo-line whitespace-nowrap`,`px-[11px] group-not-data-[state=collapsed]/sidebar:px-4`,`bg-(--sidebar-bg)`,`w-(--sidebar-width)`,`transition-[width,padding] duration-(--sidebar-animation-duration) ease-(--sidebar-easing)`,`motion-reduce:transition-none`,`sticky bottom-0`,`bg-clip-padding group-data-[state=collapsed]/sidebar:w-(--sidebar-width-icon)`,`group-data-[state=collapsed]/sidebar:border-r group-data-[state=collapsed]/sidebar:border-kumo-line`,e),...t}));Kx.displayName=`Sidebar.Footer`;var qx=[[`w-28`,`w-40`,`w-24`],[`w-24`,`w-36`,`w-32`]],Jx=(0,_.forwardRef)(({className:e,label:t=`Loading`,...n},r)=>(0,Y.jsx)(`div`,{ref:r,"data-sidebar":`loading`,role:`status`,"aria-label":t,className:J(`flex min-h-0 w-full flex-1 flex-col gap-4 px-2 py-3`,e),...n,children:qx.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(rv,{className:`mb-1 ml-2 h-2 w-16 rounded-full group-data-[state=collapsed]/sidebar:hidden`}),e.map((e,t)=>(0,Y.jsxs)(`div`,{className:`flex min-h-8.5 items-center gap-3 rounded-lg px-3 group-data-[state=collapsed]/sidebar:justify-center group-data-[state=collapsed]/sidebar:px-0`,children:[(0,Y.jsx)(rv,{className:`size-4.5 shrink-0 rounded-md`}),(0,Y.jsx)(rv,{className:J(`h-2.5 rounded-full group-data-[state=collapsed]/sidebar:hidden`,e)})]},t))]},t))}));Jx.displayName=`Sidebar.Loading`;var Yx=(0,_.forwardRef)(({className:e,children:t,...n},r)=>(0,Y.jsx)(`div`,{ref:r,"data-sidebar":`group`,className:J(`flex min-w-0 flex-col gap-y-px`,e),...n,children:t}));Yx.displayName=`Sidebar.Group`;var Xx=(0,_.forwardRef)(({className:e,children:t,...n},r)=>(0,Y.jsx)(`div`,{ref:r,"data-sidebar":`group-label`,className:J(`grid overflow-hidden`,`transition-[grid-template-rows,margin,border-color] duration-(--sidebar-animation-duration) ease-(--sidebar-easing)`,`group-data-[mobile=true]/sidebar:transition-none`,`my-3 grid-rows-[0fr] border-b border-kumo-line`,`[[data-sidebar=group]:first-child_&]:my-0 [[data-sidebar=group]:first-child_&]:border-transparent`,`group-not-data-[state=collapsed]/sidebar:my-0 group-not-data-[state=collapsed]/sidebar:grid-rows-[1fr] group-not-data-[state=collapsed]/sidebar:border-transparent`,`group-data-[mobile=true]/sidebar:my-0 group-data-[mobile=true]/sidebar:grid-rows-[1fr] group-data-[mobile=true]/sidebar:border-transparent`,e),...n,children:(0,Y.jsx)(`div`,{className:`min-h-0 min-w-0`,children:(0,Y.jsx)(`div`,{className:J(`mt-4 mb-2 truncate px-3 text-sm font-medium text-kumo-subtle`,`[[data-sidebar=group]:first-child_&]:mt-2`),children:t})})}));Xx.displayName=`Sidebar.GroupLabel`;var Zx=(0,_.createContext)(!1),Qx=(0,_.createContext)(!1),$x=(0,_.forwardRef)(({className:e,...t},n)=>(0,Y.jsx)(`ul`,{ref:n,"data-sidebar":`menu`,className:J(`m-0 flex min-w-0 list-none flex-col items-stretch gap-y-px p-0`,e),...t}));$x.displayName=`Sidebar.Menu`;var eS=(0,_.forwardRef)(({className:e,children:t,itemId:n,...r},i)=>{let{registerItem:a}=Rx(),o=(0,_.useCallback)(e=>{n&&a(n,e),typeof i==`function`?i(e):i&&(i.current=e)},[n,i,a]);return(0,Y.jsx)(Zx.Provider,{value:!0,children:(0,Y.jsx)(`li`,{ref:o,"data-sidebar":`menu-item`,"data-sidebar-item-id":n,className:J(`relative group-data-[state=collapsed]/sidebar:overflow-hidden`,e),...r,children:t})})});eS.displayName=`Sidebar.MenuItem`;var tS=(0,_.forwardRef)(({className:e,icon:t,active:n=!1,size:r=`base`,href:i,target:a,tooltip:o,itemId:s,children:c,...l},u)=>{let{state:d,peekable:f,registerItem:p}=Rx(),m=kr(),h=(0,_.useContext)(Zx),g=(0,_.useCallback)(e=>{s&&!h&&p(s,e)},[s,h,p]),v=(0,_.useCallback)(e=>{s&&h&&p(s,e),typeof u==`function`?u(e):u&&(u.current=e)},[s,h,u,p]),y=t?_.isValidElement(t)?t:(0,Y.jsx)(t,{className:J(`shrink-0 opacity-40`,r===`base`?`size-4`:`size-3.5`)}):null,b=(0,Y.jsxs)(`div`,{className:J(`flex min-w-0 flex-1 items-center gap-3`,`translate-x-[-3px] group-not-data-[state=collapsed]/sidebar:translate-x-0`,`transition-transform duration-(--sidebar-animation-duration)`),children:[y,(0,Y.jsx)(`span`,{className:J(`flex min-w-0 flex-1 items-center gap-2 overflow-hidden text-left`),children:_.Children.map(c,e=>typeof e==`string`||typeof e==`number`?(0,Y.jsx)(`span`,{className:`truncate`,children:e}):e)})]}),x=J(`group/menu-button relative flex w-full min-w-0 cursor-pointer items-center gap-2.5 rounded-lg outline-none`,`before:absolute before:inset-x-0 before:-inset-y-px`,r===`base`&&`min-h-8.5 px-3 py-0 text-sm font-medium`,r===`sm`&&`min-h-7 px-2 py-0 text-sm`,`text-kumo-default`,`transition-[color,box-shadow,outline] duration-(--sidebar-animation-duration)`,!n&&`hover:bg-(--sidebar-active-bg)`,n&&`bg-(--sidebar-active-bg)`,`has-[[data-active]]:bg-transparent has-[[data-active]]:hover:bg-(--sidebar-active-bg)`,`focus:outline-none focus-visible:bg-(--sidebar-active-bg) focus-visible:text-kumo-strong`,e),S,C=h?s:void 0;S=i?(0,Y.jsx)(m,{ref:v,...l,className:J(x,`no-underline!`),href:i,to:i,target:a,"data-active":n||void 0,"data-sidebar":`menu-button`,"data-sidebar-item-id":C,"data-kumo-component":`Sidebar`,"data-kumo-part":`menu-button-link`,"data-size":r,children:b}):(0,Y.jsx)(`button`,{ref:v,type:`button`,className:x,"data-active":n||void 0,"data-sidebar":`menu-button`,"data-sidebar-item-id":C,"data-kumo-component":`Sidebar`,"data-kumo-part":`menu-button`,"data-size":r,...l,children:b});let w=d===`collapsed`&&!f;return o&&(S=(0,Y.jsx)(Yd,{content:o,disabled:!w,side:`right`,render:S})),h?S:(0,Y.jsx)(`li`,{ref:g,"data-sidebar":`menu-item`,"data-sidebar-item-id":s,className:`relative group-data-[state=collapsed]/sidebar:overflow-hidden`,children:S})});tS.displayName=`Sidebar.MenuButton`;var nS=(0,_.forwardRef)(({className:e,...t},n)=>(0,Y.jsx)(`span`,{ref:n,"data-sidebar":`menu-badge`,className:J(`inline-flex shrink-0 items-center rounded-full border border-dashed border-kumo-line`,`px-1.5 py-0.5 text-[11px]/none font-medium text-kumo-strong select-none`,`group-data-[state=collapsed]/sidebar:hidden`,e),...t}));nS.displayName=`Sidebar.MenuBadge`;var rS=(0,_.forwardRef)(({className:e,children:t,...n},r)=>(0,Y.jsxs)(`ul`,{ref:r,"data-sidebar":`menu-sub`,className:J(`relative m-0 flex min-w-0 list-none flex-col gap-y-px overflow-hidden p-0 pr-0 pl-7`,e),...n,children:[(0,Y.jsx)(`li`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-px left-[19px] z-10 block w-px bg-kumo-line`}),t]}));rS.displayName=`Sidebar.MenuSub`;var iS=(0,_.forwardRef)(({className:e,children:t,...n},r)=>(0,Y.jsx)(Qx.Provider,{value:!0,children:(0,Y.jsx)(`li`,{ref:r,"data-sidebar":`menu-sub-item`,className:J(`relative`,e),...n,children:t})}));iS.displayName=`Sidebar.MenuSubItem`;var aS=(0,_.forwardRef)(({className:e,active:t=!1,href:n,target:r,children:i,...a},o)=>{let s=kr(),c=(0,_.useContext)(Qx),l=J(`group/menu-button relative flex min-h-8.5 w-full min-w-0 cursor-pointer items-center gap-2 rounded-lg px-3 py-0 text-sm font-medium outline-none`,`before:absolute before:inset-x-0 before:-inset-y-px`,`text-kumo-default transition-[color] duration-150`,!t&&`hover:bg-(--sidebar-active-bg)`,t&&`bg-(--sidebar-active-bg)`,`focus:outline-none focus-visible:bg-(--sidebar-active-bg) focus-visible:text-kumo-strong`,e),u=(0,Y.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2 overflow-hidden text-left`,children:_.Children.map(i,e=>typeof e==`string`||typeof e==`number`?(0,Y.jsx)(`span`,{className:`truncate`,children:e}):e)}),d;return d=n?(0,Y.jsx)(s,{ref:o,...a,className:J(l,`no-underline!`),href:n,to:n,target:r,"data-active":t||void 0,"data-sidebar":`menu-sub-button`,"data-kumo-component":`Sidebar`,"data-kumo-part":`menu-sub-button-link`,children:u}):(0,Y.jsx)(`button`,{ref:o,type:`button`,className:l,"data-active":t||void 0,"data-sidebar":`menu-sub-button`,"data-kumo-component":`Sidebar`,"data-kumo-part":`menu-sub-button`,...a,children:u}),c?d:(0,Y.jsx)(`li`,{"data-sidebar":`menu-sub-item`,className:`relative`,children:d})});aS.displayName=`Sidebar.MenuSubButton`;var oS=(0,_.forwardRef)(({className:e,...t},n)=>(0,Y.jsx)(`div`,{ref:n,"data-sidebar":`separator`,className:J(`my-3 px-2`,e),...t,children:(0,Y.jsx)(`div`,{className:`border-b border-kumo-line`})}));oS.displayName=`Sidebar.Separator`;function sS({className:e}){let{open:t}=Rx();return(0,Y.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,focusable:`false`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,className:J(`shrink-0`,e),children:[(0,Y.jsx)(`path`,{d:`M21.25 6.72v10.56a2.97 2.97 0 0 1-2.97 2.97H5.72a2.97 2.97 0 0 1-2.97-2.97V6.72a2.97 2.97 0 0 1 2.97-2.97h12.56a2.97 2.97 0 0 1 2.97 2.97`}),(0,Y.jsx)(`path`,{d:`M6.25 7.25v9.5`,className:J(`transition-transform duration-(--sidebar-animation-duration) ease-(--sidebar-easing)`,t?`translate-x-px`:`translate-x-[10.5px]`)})]})}sS.displayName=`Sidebar.PanelIcon`;var cS=(0,_.forwardRef)(({className:e,children:t,onClick:n,...r},i)=>{let{open:a,toggleSidebar:o}=Rx();return(0,Y.jsx)(`button`,{ref:i,type:`button`,"data-sidebar":`trigger`,"data-kumo-component":`Sidebar`,"data-kumo-part":`trigger`,"aria-expanded":a,"aria-label":a?`Collapse sidebar`:`Expand sidebar`,className:J(`flex size-8.5 shrink-0 cursor-pointer items-center justify-center rounded-lg`,`text-kumo-subtle hover:bg-(--sidebar-active-bg) hover:text-kumo-default`,`focus:outline-none focus-visible:ring-2 focus-visible:ring-kumo-brand focus-visible:ring-inset`,e),onClick:e=>{n?.(e),o()},...r,children:t??(0,Y.jsx)(sS,{})})});cS.displayName=`Sidebar.Trigger`;var lS=(0,_.forwardRef)(({className:e,onClick:t,...n},r)=>{let{setOpenMobile:i}=Rx();return(0,Y.jsx)(kp,{ref:r,variant:`ghost`,shape:`square`,size:`sm`,"data-sidebar":`close`,"data-kumo-component":`Sidebar`,"data-kumo-part":`close`,"aria-label":`Close navigation`,className:J(`shrink-0`,e),onClick:e=>{t?.(e),i(!1)},...n,children:(0,Y.jsx)(mp,{size:18})})});lS.displayName=`Sidebar.Close`;var uS=(0,_.forwardRef)(({className:e,...t},n)=>{let{toggleSidebar:r}=Rx();return(0,Y.jsx)(`button`,{ref:n,type:`button`,"data-sidebar":`rail`,"data-kumo-component":`Sidebar`,"data-kumo-part":`rail`,"aria-label":`Toggle sidebar`,tabIndex:-1,className:J(`absolute inset-y-0 z-1 hidden w-4 -translate-x-1/2 cursor-pointer transition-all`,`after:absolute after:inset-y-0 after:left-1/2 after:w-0.5`,`hover:after:bg-kumo-brand/20`,`group-data-[side=left]/sidebar-wrapper:right-0`,`group-data-[side=right]/sidebar-wrapper:left-0`,`sm:flex`,e),onClick:r,...t})});uS.displayName=`Sidebar.Rail`;var dS=(0,_.forwardRef)(({className:e,...t},n)=>{let{side:r,resizable:i,setIsResizing:a,setWidth:o,setOpen:s,open:c,minWidth:l,width:u,maxWidth:d}=Rx(),f=(0,_.useRef)(0),p=(0,_.useRef)(0),m=(0,_.useRef)(!1);return i?(0,Y.jsx)(`button`,{ref:n,type:`button`,"aria-label":`Resize sidebar`,tabIndex:0,"data-sidebar":`resize-handle`,className:J(`absolute inset-y-0 z-2 hidden w-3 cursor-col-resize sm:block`,`after:absolute after:inset-y-0 after:w-0.5`,`after:bg-transparent after:transition-colors`,`hover:after:bg-kumo-hairline focus-visible:after:bg-kumo-hairline active:after:bg-kumo-hairline`,`focus:outline-none`,r===`left`&&`right-0 after:right-0`,r===`right`&&`left-0 after:left-0`,e),onPointerDown:e=>{e.preventDefault(),a(!0),f.current=e.clientX,m.current=!c;let t=e.currentTarget.closest(`[data-sidebar-wrapper]`)?.querySelector(`[data-sidebar='sidebar']`);p.current=t?.getBoundingClientRect().width??0;let n=()=>{a(!1),document.removeEventListener(`pointermove`,i),document.removeEventListener(`pointerup`,u)},i=e=>{let t=r===`left`?e.clientX-f.current:f.current-e.clientX,n=p.current+t;m.current?n>=l&&(m.current=!1,s(!0),o(n)):n<l?(s(!1),m.current=!0):o(n)},u=()=>{n()};document.addEventListener(`pointermove`,i),document.addEventListener(`pointerup`,u)},onKeyDown:e=>{let t=r===`left`?`ArrowRight`:`ArrowLeft`,n=r===`left`?`ArrowLeft`:`ArrowRight`;if(e.key===t)e.preventDefault(),c?o(Math.min(u+10,d)):(s(!0),o(l));else if(e.key===n){e.preventDefault();let t=u-10;t<l?s(!1):o(t)}else e.key===`Home`?(e.preventDefault(),s(!1)):e.key===`End`&&(e.preventDefault(),s(!0),o(d))},...t}):null});dS.displayName=`Sidebar.ResizeHandle`;var fS=(e,{isMobile:t,openMobile:n,state:r})=>e&&(t?n:r!==`collapsed`),pS=(0,_.createContext)({contentId:``,isOpen:!0,isCollapsible:!1,autoScrollOnOpen:!1,toggle:()=>{},completeOpenChange:()=>{}}),mS=(0,_.forwardRef)(({defaultOpen:e=!1,open:t,onOpenChange:n,onOpenChangeComplete:r,autoScrollOnOpen:i=!1,className:a,children:o,...s},c)=>{let l=Rx(),{animationDuration:u}=l,[d,f]=(0,_.useState)(e),p=t??d,m=fS(p,l),h=(0,_.useId)(),g=(0,_.useRef)(!1),v=(0,_.useCallback)(()=>{let e=!p;f(e),n?.(e),g.current=!1},[p,n]),y=Fx(m,u,r),b=(0,_.useMemo)(()=>({contentId:h,isOpen:p,isCollapsible:!0,autoScrollOnOpen:i,toggle:v,completeOpenChange:y}),[h,p,i,v,y]),x=(0,_.useCallback)(e=>{!p&&e.target.matches(`:focus-visible`)&&(g.current=!0,f(!0),n?.(!0))},[p,n]),S=(0,_.useCallback)(e=>{g.current&&!e.currentTarget.contains(e.relatedTarget)&&!e.currentTarget.querySelector(`[data-active]`)&&(g.current=!1,f(!1),n?.(!1))},[n]);return(0,Y.jsx)(pS.Provider,{value:b,children:(0,Y.jsx)(`div`,{ref:c,"data-open":p||void 0,className:J(`min-w-0`,a),onFocus:x,onBlur:S,...s,children:o})})});mS.displayName=`Sidebar.Collapsible`;function hS({render:e}){let{contentId:t,isOpen:n,toggle:r}=(0,_.useContext)(pS);return _.cloneElement(e,{"aria-expanded":n,"aria-controls":t,"data-open":n||void 0,onClick:t=>{let n=e.props.onClick;n?.(t),r()}})}hS.displayName=`Sidebar.CollapsibleTrigger`;var gS=(0,_.forwardRef)(({className:e,children:t,onTransitionEnd:n,...r},i)=>{let{contentId:a,isOpen:o,autoScrollOnOpen:s,completeOpenChange:c}=(0,_.useContext)(pS),l=Rx(),{animationDuration:u}=l,d=(0,_.useRef)(null),f=fS(o,l);(0,_.useEffect)(()=>{if(!f||!s)return;let e=window.setTimeout(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;d.current?.scrollIntoView({block:`nearest`,behavior:e?`auto`:`smooth`})},u);return()=>window.clearTimeout(e)},[f,s,u]);let p=(0,_.useCallback)(e=>{e&&(f?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[f]),m=(0,_.useCallback)(e=>{d.current=e,p(e),typeof i==`function`?i(e):i&&(i.current=e)},[i,p]),h=(0,_.useCallback)(e=>{n?.(e),e.target===e.currentTarget&&e.propertyName===`grid-template-rows`&&c()},[c,n]);return(0,Y.jsx)(`div`,{ref:m,id:a,role:`region`,"aria-hidden":!f,onTransitionEnd:h,className:J(`grid`,`transition-[grid-template-rows] duration-(--sidebar-animation-duration) ease-(--sidebar-easing)`,`motion-reduce:transition-none`,f?`grid-rows-[1fr]`:`grid-rows-[0fr]`,e),...r,children:(0,Y.jsx)(`div`,{className:`overflow-hidden`,children:t})})});gS.displayName=`Sidebar.CollapsibleContent`;function _S({className:e}){let{isOpen:t,isCollapsible:n}=(0,_.useContext)(pS);return(0,Y.jsx)(Rf,{size:12,weight:`bold`,className:J(`ml-auto shrink-0 opacity-40 transition-[transform,rotate,opacity] duration-200 group-hover/menu-button:opacity-100`,n&&t&&`rotate-90`,`group-data-[state=collapsed]/sidebar:hidden`,e)})}_S.displayName=`Sidebar.MenuChevron`;var vS=(0,_.createContext)(``),yS=(0,_.forwardRef)(({activeKey:e,direction:t=`left`,className:n,children:r,...i},a)=>{let o=_.Children.toArray(r).findIndex(t=>_.isValidElement(t)&&t.props.value===e),s=typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,c=o>0?`-${o*100}%`:`0%`;return(0,Y.jsx)(vS.Provider,{value:e,children:(0,Y.jsx)(`div`,{ref:a,"data-sidebar":`sliding-views`,className:J(`flex min-h-0 max-w-(--sidebar-width) flex-1 overflow-hidden`,n),...i,children:(0,Y.jsx)(`div`,{className:`flex min-h-0 w-full shrink-0`,style:{transform:`translateX(${c})`,transition:s?`none`:`transform var(--sidebar-animation-duration) var(--sidebar-easing)`},children:r})})})});yS.displayName=`Sidebar.SlidingViews`;var bS=(0,_.forwardRef)(({value:e,className:t,children:n,...r},i)=>{let a=(0,_.useContext)(vS)===e,o=(0,_.useCallback)(e=>{e&&(a?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[a]),s=(0,_.useCallback)(e=>{o(e),typeof i==`function`?i(e):i&&(i.current=e)},[i,o]);return(0,Y.jsx)(`div`,{ref:s,"data-sidebar":`sliding-view`,"data-value":e,"aria-hidden":!a,className:J(`flex min-h-0 w-full shrink-0 flex-col`,!a&&`pointer-events-none`,t),...r,children:n})});bS.displayName=`Sidebar.SlidingView`;var xS=Object.assign(Ux,{Provider:Hx,Header:Wx,Content:Gx,Footer:Kx,Loading:Jx,Group:Yx,GroupLabel:Xx,Menu:$x,MenuItem:eS,MenuButton:tS,MenuBadge:nS,MenuSub:rS,MenuSubItem:iS,MenuSubButton:aS,Separator:oS,Trigger:cS,Close:lS,Rail:uS,ResizeHandle:dS,MenuChevron:_S,Collapsible:mS,CollapsibleTrigger:hS,CollapsibleContent:gS,SlidingViews:yS,SlidingView:bS}),SS=g(),CS=J(`text-[13px] [&_td]:px-3 [&_td]:py-1.5 [&_tbody_tr]:border-t [&_tbody_tr]:border-kumo-hairline`,`[&_th]:px-3 [&_th]:py-1.5 [&_th]:text-xs [&_th]:font-medium [&_th]:whitespace-nowrap [&_th]:text-kumo-subtle`),wS=`[&_td]:whitespace-nowrap`;function TS({children:e,className:t}){return(0,Y.jsx)($_,{className:J(`data-table overflow-x-auto p-0`,t),children:(0,Y.jsx)($,{className:J(CS,wS),children:e})})}function ES({children:e,wrap:t=!1}){return(0,Y.jsx)(`div`,{className:`nested overflow-x-auto rounded-md border border-kumo-hairline bg-kumo-base`,children:(0,Y.jsx)($,{className:J(CS,!t&&wS),children:e})})}function DS({colSpan:e,children:t}){return(0,Y.jsx)($.Row,{children:(0,Y.jsx)($.Cell,{colSpan:e,className:`text-kumo-subtle`,children:t})})}var OS=`table-link cursor-pointer text-left font-medium text-kumo-link hover:underline focus-visible:outline-2 focus-visible:outline-kumo-brand rounded-sm`,kS=`font-mono text-xs`;function AS({message:e,title:t}){return(0,Y.jsx)(Vp,{variant:`error`,size:`sm`,role:`alert`,title:t,description:e})}function jS(e){let t={name:``,path:``,children:new Map};for(let n of e){let e=n.path.split(`/`).filter(Boolean),r=t;e.forEach((t,i)=>{let a=i===e.length-1,o=e.slice(0,i+1).join(`/`),s=r.children.get(t);s||(s={name:t,path:o},r.children.set(t,s)),!a||n.kind===`directory`?s.children??=new Map:s.size=n.size,r=s})}return t}function MS(e){return[...e.children?.values()??[]].sort((e,t)=>Number(!e.children)-Number(!t.children)||e.name.localeCompare(t.name,void 0,{numeric:!0}))}function NS(e){return e===void 0?``:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var PS=40;function FS({entries:e,rootLabel:t,readFile:n,selected:r,onSelect:i,emptyMessage:a=`No files.`}){let o=(0,_.useMemo)(()=>jS(e),[e]),s=e.filter(e=>e.kind!==`directory`).length,[c,l]=(0,_.useState)(),u=r??c,d=i??l,[f,p]=(0,_.useState)(()=>new Set(s<PS?[]:e.flatMap(e=>{let t=e.path.split(`/`);return t.length>2?[t.slice(0,2).join(`/`)]:[]}))),m=e=>p(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});if(!e.length)return(0,Y.jsx)(`p`,{className:`text-[13px] text-kumo-subtle`,children:a});let h=(e,t)=>{let n=!!e.children,r=n&&!f.has(e.path),i=n?r?Yf:Jf:Kf;return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded px-1.5 py-0.5 text-left font-mono text-xs hover:bg-kumo-tint ${e.path===u?`bg-kumo-tint font-semibold text-kumo-strong`:`text-kumo-default`}`,style:{paddingLeft:`${t*.9+.375}rem`},title:e.path,"aria-expanded":n?r:void 0,"aria-current":e.path===u?`true`:void 0,onClick:()=>n?m(e.path):d(e.path),children:[n?(0,Y.jsx)(Rf,{"aria-hidden":!0,className:`size-3 shrink-0 text-kumo-subtle transition-transform ${r?`rotate-90`:``}`}):(0,Y.jsx)(`span`,{className:`size-3 shrink-0`}),(0,Y.jsx)(i,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-kumo-subtle`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name}),!n&&e.size!==void 0?(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] font-normal text-kumo-subtle tabular-nums`,children:NS(e.size)}):null]}),r?(0,Y.jsx)(`ul`,{children:MS(e).map(e=>h(e,t+1))}):null]},e.path)},g=e.find(e=>e.path===u);return(0,Y.jsxs)(`div`,{className:`file-explorer grid min-w-0 overflow-hidden rounded-lg border border-kumo-line bg-kumo-base md:grid-cols-[minmax(14rem,18rem)_1fr]`,children:[(0,Y.jsxs)(`div`,{className:`max-h-[28rem] overflow-auto border-b border-kumo-line p-1.5 md:border-r md:border-b-0`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center justify-between px-1.5 pb-1 text-[11px] font-medium text-kumo-subtle`,children:[(0,Y.jsx)(`span`,{className:`truncate font-mono`,children:t??`Files`}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[s,` `,s===1?`file`:`files`]})]}),(0,Y.jsx)(`ul`,{"aria-label":t??`Files`,children:MS(o).map(e=>h(e,0))})]}),(0,Y.jsx)(LS,{path:g?g.path:void 0,size:g?.size,readFile:n})]})}var IS=262144;function LS({path:e,size:t,readFile:n}){let[r,i]=(0,_.useState)({});if((0,_.useEffect)(()=>{if(!e||!n)return;let t=!0,r;return n(e).then(async e=>{let t=e.headers.get(`content-type`)??``,n=new Uint8Array(await e.arrayBuffer());if(t.startsWith(`image/`))return r=URL.createObjectURL(new Blob([n],{type:t})),{kind:`image`,url:r};let i=n.subarray(0,IS);return i.subarray(0,8e3).includes(0)?{kind:`binary`}:{kind:`text`,text:new TextDecoder().decode(i),truncated:n.byteLength>IS}}).then(n=>{t&&i({path:e,preview:n})}).catch(n=>{t&&i({path:e,error:n instanceof Error?n.message:`Unable to read file`})}),()=>{t=!1,r&&URL.revokeObjectURL(r)}},[e,n]),!e)return(0,Y.jsx)(`div`,{className:`flex min-h-32 items-center justify-center p-4 text-[13px] text-kumo-subtle`,children:`Select a file to preview it.`});let a=r.path===e?r:{};return(0,Y.jsxs)(`section`,{"aria-label":`Preview of ${e}`,className:`flex min-w-0 flex-col`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-kumo-line px-3 py-1.5`,children:[(0,Y.jsx)(`span`,{className:`truncate font-mono text-xs text-kumo-strong`,title:e,children:e}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-kumo-subtle tabular-nums`,children:NS(t)})]}),(0,Y.jsx)(`div`,{className:`max-h-[28rem] min-h-32 overflow-auto`,children:n?a.error?(0,Y.jsx)(`div`,{className:`p-3`,children:(0,Y.jsx)(AS,{message:a.error})}):a.preview?a.preview.kind===`image`?(0,Y.jsx)(`img`,{src:a.preview.url,alt:e,className:`max-w-full p-3`}):a.preview.kind===`binary`?(0,Y.jsx)(`p`,{className:`p-3 text-[13px] text-kumo-subtle`,children:`Binary file; no preview.`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`pre`,{className:`p-3 font-mono text-xs leading-relaxed whitespace-pre text-kumo-default`,children:a.preview.text}),a.preview.truncated?(0,Y.jsxs)(`p`,{className:`px-3 pb-3 text-xs text-kumo-subtle`,children:[`Showing the first `,NS(IS),`.`]}):null]}):(0,Y.jsx)(`p`,{className:`p-3 text-[13px] text-kumo-subtle`,children:`Loading…`}):(0,Y.jsx)(`p`,{className:`p-3 text-[13px] text-kumo-subtle`,children:`File contents are not available here.`})})]})}function RS({api:e,datasetId:t,mount:n,evaluatorOnly:r}){let[i,a]=(0,_.useState)({}),[o,s]=bn();(0,_.useEffect)(()=>{let n=!0;return e.listDatasetFiles(t).then(e=>{n&&a({id:t,listing:e})}).catch(e=>{n&&a({id:t,error:e instanceof Error?e.message:`Unable to list files`})}),()=>{n=!1}},[e,t]);let c=(0,_.useCallback)(n=>e.getDatasetFile(t,n),[e,t]),l=i.id===t?i:{},u=n===`.`?`workspace/`:`workspace/${n}/`;return(0,Y.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`Dataset files`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-kumo-strong`,children:`Files`}),l.error?(0,Y.jsx)(`p`,{className:`text-[13px] text-kumo-subtle`,children:`The file list is not available here.`}):l.listing?l.listing.kind===`computed`?(0,Y.jsx)(`p`,{className:`text-[13px] text-kumo-subtle`,children:`Its files are computed when a trial starts; open a trial's workspace to see them.`}):(0,Y.jsx)(FS,{entries:l.listing.files.map(e=>({...e,kind:`file`})),rootLabel:u,readFile:e.readOnly&&r?void 0:c,selected:o.get(`file`)??void 0,onSelect:e=>{let t=new URLSearchParams(o);t.set(`file`,e),s(t,{replace:!0})},emptyMessage:`This dataset has no files; it only provides a value.`}):(0,Y.jsx)(`p`,{className:`text-[13px] text-kumo-subtle`,children:`Loading files…`})]})}function zS({items:e}){return(0,Y.jsx)(`dl`,{className:`grid grid-cols-[max-content_minmax(0,1fr)] gap-x-4 gap-y-1 text-[13px]`,children:e.map(([e,t])=>(0,Y.jsxs)(`div`,{className:`contents`,children:[(0,Y.jsx)(`dt`,{className:`text-kumo-subtle`,children:e}),(0,Y.jsx)(`dd`,{className:`min-w-0 break-words text-kumo-default`,children:t})]},e))})}function BS({message:e,description:t}){return(0,Y.jsx)(Bb,{size:`sm`,title:e,description:t,className:`py-12`})}function VS(e){return e.agent.id??HS(e)}function HS(e){return e?.agent.name??e?.agent.id??e?.agent.kind??`adapter`}function US(e){let t=new Map,n=e=>{let n=VS({agent:e}),r=t.get(n)??{key:n,agent:e,scenarios:[],judging:[]};return t.set(n,r),r};for(let t of e)n(t.agent).scenarios.push(t),t.judgeAgent&&n(t.judgeAgent).judging.push(t);return[...t.values()].sort((e,t)=>e.key.localeCompare(t.key))}function WS(e){let t=new Map,n=(e,n)=>{let r=`${e.kind}\0${e.name}\0${e.definedAt??``}`,i=t.get(r)??{key:``,scorer:e,uses:[]};i.uses.push(n),t.set(r,i)};for(let t of e){for(let e of t.scorers)n(e,{scenario:t,placement:`final`});for(let[e,r]of(t.transcript??[]).entries())r.kind===`checkpoint`&&n(r.scorer,{scenario:t,placement:`checkpoint`,step:e})}let r=[...t.values()],i=new Map;for(let e of r)i.set(e.scorer.name,(i.get(e.scorer.name)??0)+1);for(let e of r)e.key=i.get(e.scorer.name)===1?e.scorer.name:`${e.scorer.name}@${e.scorer.definedAt??e.scorer.kind}`;return r.sort((e,t)=>e.key.localeCompare(t.key))}function GS(e){let t=new Map;for(let n of e)for(let e of n.datasets??[]){let r=t.get(e.id)??{dataset:e,scenarios:[]};r.scenarios.push(n),t.set(e.id,r)}return[...t.values()].sort((e,t)=>e.dataset.id.localeCompare(t.dataset.id))}function KS(e){let t=new Map;for(let n of e){let e=t.get(n.evalId);(!e||e.startedAt<n.startedAt)&&t.set(n.evalId,n)}return t}var qS=encodeURIComponent,JS=`/runs`,YS=e=>`/runs/${qS(e)}`,XS=(e,t)=>`${YS(e)}/trials/${qS(t)}`,ZS=(e,t)=>`${XS(e,t)}/workspace`,QS=(e,t)=>`/library/${e}${t===void 0?``:`/${qS(t)}`}`,$S=e=>QS(`agents`,e),eC=e=>QS(`judges`,e),tC=e=>QS(`scenarios`,e),nC=e=>QS(`datasets`,e);function rC({run:e,trial:t,workspace:n=!1}){let r=[{label:`Runs`,href:JS},{label:`Run ${e.id.slice(0,8)}`,href:YS(e.id)},...t?[{label:t.index===void 0?`Trial`:`Trial ${t.index+1}`,href:XS(e.id,t.id)}]:[],...n?[{label:`Workspace`}]:[]];return(0,Y.jsx)(`div`,{className:`shrink-0`,children:(0,Y.jsx)(Pb,{size:`sm`,className:`hierarchy-breadcrumbs`,children:r.map((e,t)=>(0,Y.jsxs)(_.Fragment,{children:[t?(0,Y.jsx)(Pb.Separator,{}):null,t===r.length-1||!e.href?(0,Y.jsx)(Pb.Current,{children:e.label}):(0,Y.jsx)(Pb.Link,{href:e.href,children:e.label})]},t))})})}function iC({title:e,subtitle:t,status:n,actions:r}){return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Y.jsxs)(`h2`,{className:`flex items-center gap-2 text-lg font-semibold text-kumo-strong`,children:[e,n]}),t?(0,Y.jsx)(`p`,{className:`truncate font-mono text-xs text-kumo-subtle`,children:t}):null]}),r?(0,Y.jsx)(`div`,{className:`flex items-center gap-2`,children:r}):null]})}function aC(e){if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(aC).join(`,`)}]`;if(typeof e==`object`&&Object.getPrototypeOf(e)===Object.prototype)return`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${aC(e[t])}`).join(`,`)}}`;throw Error(`Matrix parameters must be finite JSON values`)}function oC(e){return typeof e==`string`?e:JSON.stringify(e)??String(e)}function sC(e){let t=[...new Set(e.flatMap(e=>Object.keys(e.parameters??{})))].sort(),n=[],r=[];for(let i of t)new Set(e.map(e=>Object.hasOwn(e.parameters??{},i)?aC(e.parameters[i]):void 0)).size===1&&e.length>1?r.push([i,e[0].parameters[i]]):n.push(i);return{columns:n.slice(0,3),overflow:n.slice(3),constant:r}}function cC({entries:e}){return e.length?(0,Y.jsx)(`span`,{className:`flex flex-wrap gap-1`,children:e.map(([e,t])=>(0,Y.jsxs)(`span`,{className:`${kS} max-w-[20rem] truncate rounded border border-kumo-hairline px-1 text-[11px]`,title:`${e}=${oC(t)}`,children:[(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[e,`=`]}),oC(t)]},e))}):(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:`—`})}function lC({run:e,keys:t}){let n=t.flatMap(t=>Object.hasOwn(e.parameters??{},t)?[`${t}=${oC(e.parameters[t])}`]:[]);return n.length?(0,Y.jsx)(`span`,{className:`${kS} block max-w-[16rem] truncate text-xs`,title:n.join(`
|
|
31
|
-
`),children:n.join(` · `)}):(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:`—`})}function uC({run:e,name:t}){let n=Object.hasOwn(e.parameters??{},t),r=n?oC(e.parameters?.[t]):`—`;return(0,Y.jsx)(`span`,{className:`${kS} block max-w-[10rem] truncate`,title:n?r:`Not set on this run`,children:r})}function dC(e,t=Date.now()){let n=Math.round((t-Date.parse(e))/1e3);return Number.isFinite(n)?n<45?`just now`:n<3600?`${Math.round(n/60)} min ago`:n<86400?`${Math.round(n/3600)} h ago`:n<604800?`${Math.round(n/86400)} d ago`:new Date(e).toLocaleDateString():e}function fC(e){return e===void 0?`—`:Number.isInteger(e)?String(e):e.toFixed(2)}function pC(e){if(e!==void 0)return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`}function mC({run:e}){return(0,Y.jsxs)(`span`,{className:`flex flex-col tabular-nums`,children:[(0,Y.jsx)(`span`,{children:fC(e.score)}),(0,Y.jsxs)(`span`,{className:`text-xs text-kumo-subtle`,children:[e.completedTrials,`/`,e.requestedTrials,` trials`]})]})}function hC({run:e}){let t=pC(e.durationMs);return(0,Y.jsxs)(`span`,{className:`flex flex-col tabular-nums`,title:new Date(e.startedAt).toLocaleString(),children:[(0,Y.jsx)(`span`,{children:dC(e.startedAt)}),t?(0,Y.jsxs)(`span`,{className:`text-xs text-kumo-subtle`,children:[`took `,t]}):null]})}var gC={className:`row-link cursor-pointer hover:bg-kumo-tint`,onClick(e){if(e.target.closest(`a, button, input, select, label, textarea`)||window.getSelection()?.toString())return;let t=e.currentTarget.querySelector(`a[data-row-link]`);t&&(e.metaKey||e.ctrlKey||e.button===1?window.open(t.href,`_blank`,`noopener`):t.click())}},_C={passed:`bg-kumo-success`,failed:`bg-kumo-danger`,errored:`bg-kumo-warning`,running:`bg-kumo-info animate-pulse`,cancelled:`bg-kumo-neutral-450`,"not-run":`border border-dashed border-kumo-line bg-transparent`},vC={passed:`bg-kumo-success-tint`,failed:`bg-kumo-danger-tint`,errored:`bg-kumo-warning-tint`,running:`bg-kumo-info-tint`,cancelled:`bg-kumo-tint`,"not-run":``},yC={passed:`passed`,failed:`failed`,errored:`errored`,running:`running`,cancelled:`cancelled`,"not-run":`not run`},bC={failed:0,errored:1,running:2,cancelled:3,"not-run":4,passed:5};function xC(e){return e===void 0?`text-kumo-subtle`:e>=.9?`bg-kumo-success-tint`:e>=.5?`bg-kumo-warning-tint`:`bg-kumo-danger-tint`}var SC={agents:`Agents`,judges:`Judges`,scenarios:`Scenarios`,datasets:`Datasets`};function CC({section:e,current:t}){return(0,Y.jsx)(`div`,{className:`shrink-0`,children:(0,Y.jsxs)(Pb,{size:`sm`,className:`hierarchy-breadcrumbs`,children:[(0,Y.jsx)(Pb.Current,{children:`Library`}),(0,Y.jsx)(Pb.Separator,{}),t?(0,Y.jsx)(Pb.Link,{href:QS(e),children:SC[e]}):(0,Y.jsx)(Pb.Current,{children:SC[e]}),t?(0,Y.jsx)(Pb.Separator,{}):null,t?(0,Y.jsx)(Pb.Current,{children:t}):null]})})}function wC({at:e}){return e?(0,Y.jsx)(`span`,{className:`${kS} text-kumo-subtle`,title:`Where this is defined`,children:e}):(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:`—`})}function TC({children:e}){return(0,Y.jsx)(`span`,{className:`rounded border border-kumo-line px-1.5 py-0.5 text-xs`,children:e})}function EC({title:e,children:t}){return(0,Y.jsxs)($_,{className:`flex max-w-3xl flex-col gap-3 p-4`,children:[e?(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:e}):null,t]})}function DC({scenarios:e,runs:t,note:n}){let r=KS(t);return(0,Y.jsxs)(`section`,{"aria-label":`Used by`,className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:[`Used by`,` `,(0,Y.jsx)(`span`,{className:`font-normal text-kumo-subtle tabular-nums`,children:e.length}),n?(0,Y.jsx)(`span`,{className:`ml-2 text-xs font-normal text-kumo-subtle`,children:n}):null]}),(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Scenario`}),(0,Y.jsx)($.Head,{children:`Suite`}),(0,Y.jsx)($.Head,{children:`How`}),(0,Y.jsx)($.Head,{children:`Latest run`})]})}),(0,Y.jsxs)($.Body,{children:[e.map(({scenario:e,note:t},n)=>{let i=r.get(e.id);return(0,Y.jsxs)($.Row,{...gC,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(mn,{to:tC(e.id),"data-row-link":!0,className:OS,children:e.name??e.id})}),(0,Y.jsx)($.Cell,{children:e.suiteId??`—`}),(0,Y.jsx)($.Cell,{className:`text-kumo-subtle`,children:t??`—`}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(OC,{run:i})})]},`${e.id}-${n}`)}),e.length?null:(0,Y.jsx)(DS,{colSpan:4,children:`No scenario uses it.`})]})]})]})}function OC({run:e}){return e?(0,Y.jsxs)(mn,{to:YS(e.id),className:`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs ${vC[e.status]}`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-2 rounded-full ${_C[e.status]}`}),yC[e.status],(0,Y.jsx)(`span`,{className:`tabular-nums text-kumo-subtle`,children:fC(e.score)})]}):(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:`not run`})}function kC(e){return(0,Y.jsx)(`span`,{className:`flex flex-wrap gap-1`,children:e.runtimes.map(e=>(0,Y.jsxs)(TC,{children:[e.name,` `,(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[`(`,e.kind,`)`]})]},e.name))})}function AC({catalog:e}){let t=US(e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(CC,{section:`agents`}),t.length?(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Agent`}),(0,Y.jsx)($.Head,{children:`Kind`}),(0,Y.jsx)($.Head,{children:`Runtimes`}),(0,Y.jsx)($.Head,{children:`Scenarios`}),(0,Y.jsx)($.Head,{children:`Defined in`})]})}),(0,Y.jsx)($.Body,{children:t.map(({key:e,agent:t,scenarios:n,judging:r})=>(0,Y.jsxs)($.Row,{...gC,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(`span`,{className:`flex flex-col`,children:[(0,Y.jsx)(mn,{to:$S(e),"data-row-link":!0,className:OS,children:t.name??e}),t.name?(0,Y.jsx)(`span`,{className:`${kS} text-kumo-subtle`,children:e}):null]})}),(0,Y.jsx)($.Cell,{children:t.kind}),(0,Y.jsx)($.Cell,{children:kC(t)}),(0,Y.jsxs)($.Cell,{className:`tabular-nums`,children:[n.length,r.length?(0,Y.jsxs)(`span`,{className:`ml-1 text-xs text-kumo-subtle`,children:[`+ judges `,r.length]}):null]}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(wC,{at:t.definedAt})})]},e))})]}):(0,Y.jsx)(BS,{message:`No agents yet. Define one with defineAgent in agents/.`})]})}function jC({catalog:e,runs:t,agentKey:n}){let r=US(e).find(e=>e.key===n);if(!r)return(0,Y.jsx)(BS,{message:`Agent not found: ${n}`});let{agent:i,scenarios:a,judging:o}=r;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(CC,{section:`agents`,current:i.name??n}),(0,Y.jsx)(iC,{title:i.name??n,subtitle:n}),(0,Y.jsx)(EC,{children:(0,Y.jsx)(zS,{items:[[`ID`,(0,Y.jsx)(`span`,{className:kS,children:i.id??`—`},`id`)],[`Kind`,i.kind],...i.version?[[`Version`,i.version]]:[],[`Runtimes`,kC(i)],[`Defined in`,(0,Y.jsx)(wC,{at:i.definedAt},`at`)]]})}),(0,Y.jsx)(DC,{runs:t,scenarios:[...a.map(e=>({scenario:e,note:`agent under test`})),...o.map(e=>({scenario:e,note:`judge agent`}))]})]})}function MC({scorer:e}){return(0,Y.jsx)(Er,{variant:e.kind===`judge`?`beta`:`neutral`,children:e.kind===`judge`?`LLM judge`:`predicate`})}function NC(e){return e.kind===`judge`?`its verdict`:e.passAt===void 0?`only 1`:`≥ ${e.passAt}`}function PC(e){return e.placement===`final`?`final scoring`:`checkpoint after step ${(e.step??0)+1}`}function FC({catalog:e}){let t=WS(e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(CC,{section:`judges`}),t.length?(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Judge`}),(0,Y.jsx)($.Head,{children:`Kind`}),(0,Y.jsx)($.Head,{children:`Passes at`}),(0,Y.jsx)($.Head,{children:`Scenarios`}),(0,Y.jsx)($.Head,{children:`Defined in`})]})}),(0,Y.jsx)($.Body,{children:t.map(({key:e,scorer:t,uses:n})=>(0,Y.jsxs)($.Row,{...gC,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(mn,{to:eC(e),"data-row-link":!0,className:OS,children:t.name})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(MC,{scorer:t})}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:NC(t)}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:new Set(n.map(e=>e.scenario.id)).size}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(wC,{at:t.definedAt})})]},e))})]}):(0,Y.jsx)(BS,{message:`No judges yet. Add predicates or judges in judges/.`})]})}function IC({catalog:e,runs:t,judgeKey:n}){let r=WS(e).find(e=>e.key===n);if(!r)return(0,Y.jsx)(BS,{message:`Judge not found: ${n}`});let{scorer:i,uses:a}=r;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(CC,{section:`judges`,current:i.name}),(0,Y.jsx)(iC,{title:i.name,status:(0,Y.jsx)(MC,{scorer:i})}),(0,Y.jsxs)(EC,{children:[(0,Y.jsx)(zS,{items:[[`Kind`,i.kind===`judge`?`LLM judge: the scenario’s judge agent grades the trial against the rubric`:`Predicate: a function scores the trial from 0 to 1`],[`Passes at`,NC(i)],[`Partial trials`,i.supportsPartial?`Also scores trials that stopped early or failed`:`Only scores trials that ran to the end`],[`Defined in`,(0,Y.jsx)(wC,{at:i.definedAt},`at`)]]}),i.rubric?(0,Y.jsxs)(`figure`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`figcaption`,{className:`text-xs font-medium text-kumo-subtle`,children:`Rubric`}),(0,Y.jsx)(`blockquote`,{className:`rounded-md border-l-2 border-kumo-brand bg-kumo-elevated px-3 py-2 text-[13px] whitespace-pre-wrap`,children:i.rubric})]}):null]}),(0,Y.jsx)(DC,{runs:t,scenarios:a.map(e=>({scenario:e.scenario,note:PC(e)}))})]})}function LC(e){if(e.source===`computed`)return e.hooks?.onRun?`built by onLoad, adapted per trial by onRun`:`built by onLoad`;let t=[];return e.files&&t.push(`directory`in e.files?`files from ${e.files.directory}/`:`${e.files.paths.length} inline files`),e.value&&t.push(`file`in e.value?`value from ${e.value.file}`:`an inline value`),t.join(` and `)||`—`}function RC({catalog:e}){let t=GS(e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(CC,{section:`datasets`}),t.length?(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Dataset`}),(0,Y.jsx)($.Head,{children:`Kind`}),(0,Y.jsx)($.Head,{children:`Visible to`}),(0,Y.jsx)($.Head,{children:`Contents`}),(0,Y.jsx)($.Head,{children:`Scenarios`}),(0,Y.jsx)($.Head,{children:`Defined in`})]})}),(0,Y.jsx)($.Body,{children:t.map(({dataset:e,scenarios:t})=>(0,Y.jsxs)($.Row,{...gC,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(`span`,{className:`flex flex-col`,children:[(0,Y.jsx)(mn,{to:nC(e.id),"data-row-link":!0,className:OS,children:e.name??e.id}),e.name?(0,Y.jsx)(`span`,{className:`${kS} text-kumo-subtle`,children:e.id}):null]})}),(0,Y.jsx)($.Cell,{children:e.source}),(0,Y.jsx)($.Cell,{children:e.visibility===`candidate`?`agent and scorers`:`scorers only`}),(0,Y.jsx)($.Cell,{className:`max-w-[20rem] truncate`,children:LC(e)}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:t.length}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(wC,{at:e.definedAt})})]},e.id))})]}):(0,Y.jsx)(BS,{message:`No scenario uses a dataset yet. Define one with defineDataset in datasets/.`})]})}function zC({api:e,catalog:t,runs:n,datasetId:r}){let i=GS(t).find(e=>e.dataset.id===r);if(!i)return(0,Y.jsx)(BS,{message:`Dataset not found: ${r}`});let{dataset:a,scenarios:o}=i,s=a.files,c=a.value;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(CC,{section:`datasets`,current:a.name??a.id}),(0,Y.jsx)(iC,{title:a.name??a.id,subtitle:a.id,status:(0,Y.jsx)(Er,{variant:`neutral`,children:a.source})}),(0,Y.jsx)(EC,{children:(0,Y.jsx)(zS,{items:[[`Kind`,a.source===`computed`?`Computed: onLoad builds it once per process and caches it`:`Static: declared in the definition`],...a.hooks?[[`Hooks`,(0,Y.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Y.jsx)(TC,{children:`onLoad · once per process`}),a.hooks.onRun?(0,Y.jsx)(TC,{children:`onRun · once per trial`}):null]},`hooks`)]]:[],[`Visible to`,a.visibility===`candidate`?`The agent (in its workspace and context.data) and the scorers`:`Only the scorers; the agent never sees it`],[`Mounted at`,(0,Y.jsx)(`span`,{className:kS,children:a.mount===`.`?`workspace root`:`${a.mount}/`},`mount`)],[`Defined in`,(0,Y.jsx)(wC,{at:a.definedAt},`at`)]]})}),s||c?(0,Y.jsx)(EC,{title:`Contents`,children:(0,Y.jsx)(zS,{items:[...s?[[`Files`,`directory`in s?(0,Y.jsxs)(`span`,{children:[(0,Y.jsxs)(`span`,{className:kS,children:[s.directory,`/`]}),`, copied into each trial's workspace`]},`files`):`${s.paths.length} declared inline, written into each trial's workspace`]]:[],...c?[[`Value`,`file`in c?(0,Y.jsx)(`span`,{className:kS,children:c.file},`value`):(0,Y.jsx)(`span`,{children:c.shape.type===`array`?`array of ${c.shape.items} items`:c.shape.type===`object`?(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1`,children:[`object with`,c.shape.keys.map(e=>(0,Y.jsx)(TC,{children:(0,Y.jsx)(`span`,{className:kS,children:e})},e))]}):c.shape.type},`value`)]]:[]]})}):null,(0,Y.jsx)(RS,{api:e,datasetId:a.id,mount:a.mount,evaluatorOnly:a.visibility===`evaluator`}),(0,Y.jsx)(DC,{runs:n,scenarios:o.map(e=>({scenario:e}))})]})}function BC({label:e,noun:t,page:n,pageSize:r,total:i,onPage:a}){if(i<=r)return null;let o=n*r+1,s=Math.min((n+1)*r,i);return(0,Y.jsx)(`nav`,{className:`pager flex items-center justify-end`,"aria-label":e,children:(0,Y.jsxs)(Cy,{page:n+1,setPage:e=>a(e-1),perPage:r,totalCount:i,children:[(0,Y.jsx)(Cy.Info,{children:()=>(0,Y.jsxs)(`span`,{className:`text-xs text-kumo-subtle tabular-nums`,children:[t,` `,o,`–`,s,` of `,i]})}),(0,Y.jsx)(Cy.Controls,{})]})})}function VC(e,t,n){let r=t.trim().toLowerCase();return r?e.flatMap(e=>{if(e.label.toLowerCase().includes(r))return[e];let t=e.values.filter(t=>t.label.toLowerCase().includes(r)||n.getAll(e.key).includes(t.key));return t.length?[{...e,values:t}]:[]}):[...e]}var HC=(e,...t)=>!e||t.some(t=>t.includes(e));function UC({facets:e,search:t,archivedCount:n=0,onToggleFacet:r,onField:i,onClear:a}){let[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(``),u=c.trim().toLowerCase(),d=VC(e,c,t).filter(e=>e.values.length>1||t.has(e.key)),f=HC(u,`date`,`from`,`to`,`started`),p=n>0&&HC(u,`archived`,`removed`),m=[...t.keys()].filter(e=>e!==`q`).length,h=WC(e,t);return(0,Y.jsxs)(`section`,{"aria-label":`Run filters`,className:`runs-filter-panel rounded-lg border border-kumo-line bg-kumo-base`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-1.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":o,className:`flex shrink-0 cursor-pointer items-center gap-1.5 text-[13px] font-semibold text-kumo-strong select-none`,onClick:()=>s(e=>!e),children:[(0,Y.jsx)(Rf,{"aria-hidden":!0,className:`size-3 text-kumo-subtle transition-transform ${o?`rotate-90`:``}`}),(0,Y.jsx)(Xf,{"aria-hidden":!0,className:`size-3.5 text-kumo-subtle`}),`Filters`,m?` (${m} active)`:``]}),h.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`active-filter inline-flex max-w-[16rem] cursor-pointer items-center gap-1 rounded-full border border-kumo-line bg-kumo-elevated px-2 py-0.5 text-xs`,title:`Remove ${e.label}: ${e.choice}`,onClick:()=>e.facet?r(e.field,e.value):i(e.field,``),children:[(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[e.label,`:`]}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.choice}),(0,Y.jsx)(mp,{"aria-hidden":!0,className:`size-3 shrink-0 text-kumo-subtle`})]},`${e.field}=${e.value}`)),(0,Y.jsx)(kp,{size:`xs`,variant:`ghost`,shape:`square`,className:`clear-filters ml-auto shrink-0`,icon:(0,Y.jsx)(Zf,{}),"aria-label":`Clear filters`,title:`Clear filters`,disabled:!m,onClick:a})]}),o?(0,Y.jsxs)(`div`,{className:`flex max-h-[min(32rem,60vh)] flex-col gap-3 overflow-y-auto border-t border-kumo-hairline px-3 py-3`,children:[(0,Y.jsx)(Th,{type:`search`,size:`xs`,"aria-label":`Search filters`,placeholder:`Search filters`,value:c,className:`max-w-xs`,onChange:e=>l(e.target.value)}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(12rem,1fr))] gap-x-6 gap-y-4`,children:[d.map(e=>(0,Y.jsx)(KC,{facet:e,checked:t.getAll(e.key),searching:u.length>0,onToggle:t=>r(e.key,t)},e.key)),f?(0,Y.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsx)(`legend`,{className:`mb-1 text-xs font-medium text-kumo-subtle`,children:`Started`}),(0,Y.jsx)(Th,{type:`date`,size:`xs`,label:`From`,value:t.get(`from`)??``,onChange:e=>i(`from`,e.target.value)}),(0,Y.jsx)(Th,{type:`date`,size:`xs`,label:`To`,value:t.get(`to`)??``,onChange:e=>i(`to`,e.target.value)})]}):null,p?(0,Y.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsx)(`legend`,{className:`mb-1 text-xs font-medium text-kumo-subtle`,children:`Archived`}),(0,Y.jsx)(lh,{className:`runs-choice min-w-0`,checked:t.get(`archived`)===`show`,onCheckedChange:e=>i(`archived`,e?`show`:``),label:(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline justify-between gap-2 text-[13px]`,children:[(0,Y.jsx)(`span`,{children:`Show archived`}),(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle tabular-nums`,children:n})]})})]}):null]}),!d.length&&!f&&!p?(0,Y.jsxs)(`p`,{className:`text-[13px] text-kumo-subtle`,children:[`No filters match “`,c,`”.`]}):null]}):null]})}function WC(e,t){let n={from:`From`,to:`To`,archived:`Archived`};return[...t.entries()].flatMap(([t,r])=>{if(t===`q`)return[];let i=e.find(e=>e.key===t);if(i){let e=i.values.find(e=>e.key===r);return[{field:t,value:r,label:i.label,choice:e?.label??r,facet:!0}]}return[{field:t,value:r,label:n[t]??t,choice:r,facet:!1}]})}function GC(e,t,n,r=``){let i=e.length>8,a=r.trim().toLowerCase(),o=a?e.filter(e=>e.label.toLowerCase().includes(a)||t.includes(e.key)):[...e];if(!i)return{choices:o,hidden:0};let s=o.sort((e,n)=>Number(t.includes(n.key))-Number(t.includes(e.key))||n.count-e.count||e.label.localeCompare(n.label,void 0,{numeric:!0}));if(n)return{choices:s,hidden:0};let c=[...s.filter(e=>t.includes(e.key)),...s.filter(e=>!t.includes(e.key)).slice(0,6)];return{choices:c,hidden:s.length-c.length}}function KC({facet:e,checked:t,searching:n,onToggle:r}){let[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(``),{choices:c,hidden:l}=GC(e.values,t,i||n,i?o:``);return(0,Y.jsxs)(`fieldset`,{className:`facet-group flex min-w-0 flex-col gap-1`,children:[(0,Y.jsxs)(`legend`,{className:`mb-1 flex w-full items-baseline justify-between gap-2 text-xs font-medium text-kumo-subtle`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.label}),(0,Y.jsx)(`span`,{className:`tabular-nums`,children:e.values.length})]}),i&&e.values.length>8?(0,Y.jsx)(Th,{type:`search`,size:`xs`,"aria-label":`Search ${e.label}`,placeholder:`Search ${e.values.length} values`,value:o,onChange:e=>s(e.target.value)}):null,(0,Y.jsxs)(`div`,{className:`flex max-h-56 flex-col gap-1 overflow-y-auto`,children:[c.map(e=>(0,Y.jsx)(lh,{className:`runs-choice min-w-0`,checked:t.includes(e.key),onCheckedChange:()=>r(e.key),label:(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline justify-between gap-2 text-[13px]`,title:e.label,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle tabular-nums`,children:e.count})]})},e.key)),c.length?null:(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:`No matches.`})]}),l>0||i?(0,Y.jsx)(`button`,{type:`button`,className:`facet-more self-start text-xs text-kumo-link hover:underline`,onClick:()=>{a(e=>!e),s(``)},children:i?`Show fewer`:`Show all ${e.values.length}`}):null]})}var qC=`@missing`,JC=e=>`p.${e}`;function YC(e,t,n){let r=e.get(t);r?r.count++:e.set(t,{key:t,label:n,count:1})}function XC(e){return[{key:`eval`,label:`Scenario`},{key:`matrix`,label:`Matrix`},{key:`status`,label:`Status`},...[...new Set(e.flatMap(e=>Object.keys(e.parameters??{})))].sort().map(e=>({key:JC(e),label:e}))].map(({key:t,label:n})=>{let r=new Map;for(let n of e){let e=t===`eval`?n.evalId:t===`matrix`?n.matrixId:t===`status`?n.status:n.parameters?.[t.slice(2)],i=t===`eval`||t===`status`||(t===`matrix`?n.matrixId!==void 0:Object.hasOwn(n.parameters??{},t.slice(2)));YC(r,i?aC(e):qC,i?String(typeof e==`string`?e:JSON.stringify(e)):`Missing`)}return{key:t,label:n,values:[...r.values()].sort((e,t)=>e.label.localeCompare(t.label,void 0,{numeric:!0}))}})}function ZC(e,t={}){let n=new URLSearchParams;n.append(`eval`,aC(e));for(let[e,r]of Object.entries(t))r!=null&&n.append(JC(e),aC(r));return`/runs?${n}`}function QC(e,t){let n=[...t.keys()].filter(e=>[`eval`,`matrix`,`status`].includes(e)||e.startsWith(`p.`)),r=t.get(`from`),i=t.get(`to`);return e.filter(e=>r&&e.startedAt.slice(0,10)<r||i&&e.startedAt.slice(0,10)>i?!1:n.every(n=>{let r=t.getAll(n),i=n===`eval`||n===`status`||(n===`matrix`?e.matrixId!==void 0:Object.hasOwn(e.parameters??{},n.slice(2))),a=n===`eval`?e.evalId:n===`matrix`?e.matrixId:n===`status`?e.status:e.parameters?.[n.slice(2)],o=i?aC(a):qC;return r.includes(o)}))}function $C({label:e,placeholder:t,value:n,count:r,onChange:i}){return(0,Y.jsxs)(`div`,{className:`search-field flex min-w-0 flex-wrap items-center gap-3`,children:[(0,Y.jsx)(Th,{type:`search`,size:`sm`,"aria-label":e,placeholder:t,value:n,className:`w-full sm:w-80`,onChange:e=>i(e.target.value)}),(0,Y.jsx)(`span`,{className:`search-count text-xs text-kumo-subtle tabular-nums`,children:r})]})}function ew(e,t){let[n,r]=(0,_.useState)(()=>new URLSearchParams),i=e??n,a=t??r,o=i.get(`q`)??``,[s,c]=(0,_.useState)(o);return(0,_.useEffect)(()=>c(o),[o]),(0,_.useEffect)(()=>{if(s===o)return;let e=setTimeout(()=>{let e=new URLSearchParams(i);s?e.set(`q`,s):e.delete(`q`),a(e)},250);return()=>clearTimeout(e)},[s,o,i,a]),{activeSearch:i,query:s,setQuery:c,setField:(e,t)=>{let n=new URLSearchParams(i);t?n.set(e,t):n.delete(e),a(n)},toggleFacet:(e,t)=>{let n=new URLSearchParams(i),r=n.getAll(e);n.delete(e);for(let i of r.filter(e=>e!==t))n.append(e,i);r.includes(t)||n.append(e,t),a(n)},clearFilters:()=>a(new URLSearchParams)}}function tw(e,t){let[n,r]=(0,_.useState)({}),i=t?`${t.id}:${t.status}:${t.completedTrials}:${t.completedAt??``}`:``;return(0,_.useEffect)(()=>{if(!t)return;let n=!0;return e.listTrials(t.id).then(e=>{n&&r({runId:t.id,trials:e})}).catch(e=>{n&&r({runId:t.id,error:e instanceof Error?e.message:`Unable to load trials`})}),()=>{n=!1}},[e,i]),n.runId===t?.id?n:{}}function nw(e,t,n,r){let i=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return i.length?e.filter(e=>{let t=r.find(t=>t.id===e.evalId),a=n.find(t=>t.id===e.suiteId),o=Object.entries(e.parameters??{}).flatMap(([e,t])=>[e,oC(t)]),s=[e.id,e.evalId,t?.name,e.suiteId,a?.name,e.matrixId,t?.agent.name,t?.agent.kind,e.status,e.score,e.startedAt,e.source?.commit,e.source?.ref,e.source?.dirty?`dirty`:void 0,...o].map(oC).join(` `).toLowerCase();return i.every(e=>s.includes(e))}):[...e]}function rw({runs:e,catalog:t,suites:n,search:r,onSearchChange:i,trialStatus:a=!1}){let o=ew(r,i),{activeSearch:s,query:c}=o,l=s.get(`archived`)===`show`,u=e.filter(e=>e.archived).length,d=(0,_.useMemo)(()=>l?e:e.filter(e=>!e.archived),[e,l]),f=(0,_.useMemo)(()=>XC(d),[d]),p=(0,_.useMemo)(()=>{if(!a)return s;let e=new URLSearchParams(s);return e.delete(`status`),e},[s,a]),m=(0,_.useMemo)(()=>nw(QC(d,p),c,n,t),[d,p,c,n,t]),h=s.getAll(`status`);return{...o,listed:d,facets:f,filteredRuns:m,archivedCount:u,keepTrial:e=>!h.length||h.includes(aC(e.status))}}function iw(e,t){let n=new Map;for(let e of t)n.set(e.status,(n.get(e.status)??0)+1);return e.map(e=>e.key===`status`?{...e,label:`Trial status`,values:[...n].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:aC(e),label:e,count:t}))}:e)}function aw({selection:e,facets:t=e.facets,label:n,count:r}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($C,{label:n,placeholder:`Scenario, parameter, agent, commit or status`,value:e.query,count:r,onChange:e.setQuery}),(0,Y.jsx)(UC,{facets:t,search:e.activeSearch,archivedCount:e.archivedCount,onToggleFacet:e.toggleFacet,onField:e.setField,onClear:e.clearFilters})]})}function ow(e,t){let[n,r]=(0,_.useState)(e);return{sort:n,toggleSort:e=>{r(t=>t.key===e?{key:e,direction:t.direction===`asc`?`desc`:`asc`}:{key:e,direction:`asc`}),t?.()}}}function sw({label:e,sortKey:t,sort:n,onSort:r,sticky:i}){let a=n.key===t,o=a?n.direction===`asc`?`ascending`:`descending`:void 0,s=a?n.direction===`asc`?zf:If:Bf;return(0,Y.jsx)($.Head,{"aria-sort":o,sticky:i,children:(0,Y.jsxs)(`button`,{type:`button`,className:`table-sort inline-flex items-center gap-1 whitespace-nowrap rounded font-medium hover:text-kumo-strong focus-visible:outline-2 focus-visible:outline-kumo-brand`,onClick:()=>r(t),children:[e,(0,Y.jsx)(s,{"aria-hidden":!0,className:a?`size-3`:`size-3 text-kumo-inactive`})]})})}function cw(e,t,n){return(0,_.useMemo)(()=>{let r=[...e];return r.sort((e,r)=>{let i=n(e,t.key),a=n(r,t.key),o=typeof i==`number`&&typeof a==`number`?i-a:String(i??``).localeCompare(String(a??``),void 0,{numeric:!0,sensitivity:`base`});return t.direction===`asc`?o:-o}),r},[e,t,n])}var lw={passed:`success`,failed:`error`,errored:`warning`,error:`warning`};function uw({status:e}){return(0,Y.jsx)(`span`,{className:`inline-flex`,"data-status":e,children:(0,Y.jsx)(Er,{appearance:`dot`,variant:lw[e]??`neutral`,children:e})})}var dw=50,fw=6;function pw({runs:e,suites:t,catalog:n,search:r,onSearchChange:i}){let a=rw({runs:e,catalog:n,suites:t,search:r,onSearchChange:i}),{listed:o,filteredRuns:s,clearFilters:c}=a,l=sC(s),[u,d]=(0,_.useState)(0),{sort:f,toggleSort:p}=ow({key:`started`,direction:`desc`},()=>d(0)),m=e=>n.find(t=>t.id===e.evalId),h=e=>t.find(t=>t.id===e.suiteId)?.name,g=cw(s,f,(e,t)=>mw(e,t,m(e),h(e))),v=Math.max(1,Math.ceil(g.length/dw)),y=Math.min(u,v-1),b=g.slice(y*dw,(y+1)*dw),x=fw+l.columns.length+ +!!l.overflow.length,S=(e,t,n)=>(0,Y.jsx)(sw,{label:e,sortKey:t,sort:f,onSort:p,sticky:n});return e.length?(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsx)(aw,{selection:a,label:`Filter runs`,count:`${g.length} of ${o.length} runs`}),l.constant.length?(0,Y.jsxs)(`p`,{className:`constant-parameters flex flex-wrap items-center gap-1 text-[13px] text-kumo-subtle`,role:`note`,children:[`Same on every run shown:`,(0,Y.jsx)(cC,{entries:l.constant})]}):null,(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[S(`Run`,`run`,`left`),S(`Status`,`status`),S(`Scenario`,`eval`),S(`Score`,`score`),S(`Started`,`started`),S(`Commit`,`commit`),l.columns.map(e=>(0,Y.jsx)(sw,{label:e,sortKey:`param:${e}`,sort:f,onSort:p},e)),l.overflow.length?(0,Y.jsx)($.Head,{children:`Other parameters`}):null]})}),(0,Y.jsxs)($.Body,{children:[b.map(e=>(0,Y.jsx)(hw,{run:e,evaluation:m(e),suiteName:h(e),layout:l},e.id)),g.length?null:(0,Y.jsx)(DS,{colSpan:x,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[`No matching runs.`,(0,Y.jsx)(kp,{size:`xs`,variant:`ghost`,onClick:c,children:`Clear filters`})]})})]})]}),(0,Y.jsx)(BC,{label:`Run pages`,noun:`Runs`,page:y,pageSize:dw,total:g.length,onPage:d})]}):(0,Y.jsx)(BS,{message:`No runs yet. Open a scenario or suite to start one.`})}function mw(e,t,n,r){if(t.startsWith(`param:`)){let n=e.parameters?.[t.slice(6)];return n===void 0?void 0:typeof n==`number`?n:oC(n)}return{run:e.id,suite:r??e.suiteId,eval:n?.name??e.evalId,agent:n?.agent.name??n?.agent.kind??`Unnamed agent`,status:e.status,trials:e.completedTrials,score:e.score,runtime:e.durationMs,started:e.startedAt,commit:e.source?.commit}[t]}function hw({run:e,evaluation:t,suiteName:n,layout:r}){let i=t?.name??e.evalId,a=n??e.suiteId;return(0,Y.jsxs)($.Row,{...gC,children:[(0,Y.jsx)($.Cell,{sticky:`left`,children:(0,Y.jsx)(mn,{to:YS(e.id),"data-row-link":!0,className:`${OS} ${kS}`,title:e.id,children:e.id.slice(0,8)})}),(0,Y.jsx)($.Cell,{title:e.interrupted?`Its process stopped before the run finished`:void 0,children:(0,Y.jsx)(uw,{status:e.status})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(`span`,{className:`flex max-w-[14rem] flex-col`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(mn,{to:tC(e.evalId),className:`${OS} truncate font-medium`,title:i,children:i}),e.archived?(0,Y.jsx)(`span`,{className:`shrink-0 rounded border border-kumo-line px-1 text-[11px] text-kumo-subtle`,title:`This scenario is no longer in the project (evalkit tidy)`,children:`archived`}):null]}),a?(0,Y.jsx)(`span`,{className:`truncate text-xs text-kumo-subtle`,title:a,children:a}):null]})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(mC,{run:e})}),(0,Y.jsx)($.Cell,{className:`whitespace-nowrap`,children:(0,Y.jsx)(hC,{run:e})}),(0,Y.jsx)($.Cell,{className:`whitespace-nowrap`,children:(0,Y.jsx)(gw,{source:e.source})}),r.columns.map(t=>(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(uC,{run:e,name:t})},t)),r.overflow.length?(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(lC,{run:e,keys:r.overflow})}):null]})}function gw({source:e}){return e?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:[e.commit,e.ref&&`on ${e.ref}`,e.dirty&&`with uncommitted changes`].filter(Boolean).join(` `),children:[(0,Y.jsx)(`span`,{className:kS,children:e.commit.slice(0,7)}),e.dirty?(0,Y.jsx)(`span`,{className:`rounded border border-kumo-line px-1 text-[11px] text-kumo-subtle`,children:`dirty`}):null]}):(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:`—`})}function _w({run:e,trials:t}){let{sort:n,toggleSort:r}=ow({key:`index`,direction:`asc`}),i=(0,_.useMemo)(()=>[...new Set(t.flatMap(e=>(e.scores??[]).map(e=>e.name)))].sort(),[t]),a=cw(t,n,(e,t)=>t.startsWith(`score:`)?(e.scores??[]).find(e=>e.name===t.slice(6))?.value:{index:e.index,status:e.status,aggregate:e.score,runtime:e.durationMs,started:e.startedAt}[t]);return(0,Y.jsxs)(ES,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)(sw,{label:`Trial`,sortKey:`index`,sort:n,onSort:r}),(0,Y.jsx)(sw,{label:`Status`,sortKey:`status`,sort:n,onSort:r}),(0,Y.jsx)(sw,{label:`Aggregate`,sortKey:`aggregate`,sort:n,onSort:r}),i.map(e=>(0,Y.jsx)(sw,{label:e,sortKey:`score:${e}`,sort:n,onSort:r},e)),(0,Y.jsx)(sw,{label:`Runtime`,sortKey:`runtime`,sort:n,onSort:r}),(0,Y.jsx)(sw,{label:`Started`,sortKey:`started`,sort:n,onSort:r})]})}),(0,Y.jsxs)($.Body,{children:[a.map(t=>(0,Y.jsxs)($.Row,{...gC,children:[(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:(0,Y.jsxs)(mn,{to:XS(e.id,t.id),"data-row-link":!0,className:OS,title:t.id,children:[`Trial `,t.index+1]})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(uw,{status:t.status})}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:t.score??`—`}),i.map(e=>(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:(t.scores??[]).find(t=>t.name===e)?.value??`—`},e)),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:t.durationMs===void 0?`—`:`${t.durationMs}ms`}),(0,Y.jsx)($.Cell,{className:`whitespace-nowrap tabular-nums`,children:new Date(t.startedAt).toLocaleString()})]},t.id)),a.length?null:(0,Y.jsx)(DS,{colSpan:i.length+5,children:`No trials saved yet.`})]})]})}function vw({api:e,catalog:t,runs:n,runId:r}){let i=n.find(e=>e.id===r),{trials:a,error:o}=tw(e,i);if(!i)return(0,Y.jsx)(BS,{message:n.length?`Run not found: ${r}`:`Loading run…`});let s=t.find(e=>e.id===i.evalId),c=Object.entries(i.parameters??{});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(rC,{run:i}),(0,Y.jsx)(iC,{title:`Run ${i.id.slice(0,8)}`,subtitle:i.id,status:(0,Y.jsx)(`span`,{title:i.interrupted?`Its process stopped before the run finished`:void 0,children:(0,Y.jsx)(uw,{status:i.status})})}),(0,Y.jsx)(`div`,{className:`run-overview max-w-3xl`,children:(0,Y.jsx)(zS,{items:[[`Scenario`,(0,Y.jsx)(mn,{to:tC(i.evalId),className:OS,children:s?.name??i.evalId},`scenario`)],[`Agent`,s?HS(s):i.agent??`—`],[`Score`,i.score??`—`],[`Trials`,`${i.completedTrials} of ${i.requestedTrials}`],...c.length?[[`Parameters`,(0,Y.jsx)(`span`,{className:kS,children:c.map(([e,t])=>`${e}=${JSON.stringify(t)}`).join(` `)},`parameters`)]]:[],[`Started`,new Date(i.startedAt).toLocaleString()],[`Runtime`,i.durationMs===void 0?`—`:`${i.durationMs}ms`],[`Commit`,(0,Y.jsx)(gw,{source:i.source},`commit`)]]})}),o?(0,Y.jsx)(AS,{title:`Unable to load trials`,message:o}):null,(0,Y.jsxs)(`section`,{"aria-label":`Trials`,className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:`Trials`}),a?(0,Y.jsx)(_w,{run:i,trials:a}):o?null:(0,Y.jsx)(`output`,{className:`text-[13px] text-kumo-subtle`,children:`Loading trials…`})]})]})}function yw({id:e,evaluation:t,parameters:n=[],trials:r,onRun:i,runDisabled:a=!1,latestRun:o,cellParameters:s}){let c=ZC(t?.id??e,s),l=t?.name??e,u=t?.path??e;return(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[t?(0,Y.jsx)(Oi,{href:tC(t.id),className:OS,children:l}):(0,Y.jsx)(`span`,{className:`font-medium`,children:l}),u===l?null:(0,Y.jsx)(`span`,{className:`${kS} text-kumo-subtle`,children:u})]})}),n.map((e,t)=>(0,Y.jsx)($.Cell,{className:kS,children:typeof e==`string`?e:JSON.stringify(e)},t)),(0,Y.jsx)($.Cell,{children:t?(0,Y.jsx)(Oi,{href:$S(VS(t)),children:HS(t)}):HS(t)}),(0,Y.jsx)($.Cell,{children:t?.agent.runtimes.map(e=>e.name).join(`, `)||`default`}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:r??t?.trialCount??`—`}),(0,Y.jsx)($.Cell,{children:o?(0,Y.jsx)(Oi,{href:YS(o.id),title:`Open the latest run`,children:(0,Y.jsx)(uw,{status:o.status})}):`—`}),(0,Y.jsx)($.Cell,{className:`text-right`,children:(0,Y.jsxs)(`div`,{className:`inline-flex items-center justify-end gap-2`,children:[(0,Y.jsx)(Ap,{size:`xs`,variant:`secondary`,icon:(0,Y.jsx)(np,{}),href:c,children:`Runs`}),i||a?(0,Y.jsx)(kp,{size:`xs`,variant:`secondary`,icon:(0,Y.jsx)(ap,{weight:`fill`}),disabled:a,title:a?`Matrix configuration is still loading`:void 0,onClick:e=>{e.stopPropagation(),i?.()},children:`Run`}):null]})})]})}function bw({nested:e,children:t}){return e?(0,Y.jsx)(ES,{children:t}):(0,Y.jsx)(TS,{children:t})}function xw({axes:e,sort:t,onSort:n,planned:r=!1}){let i=(e,r)=>(0,Y.jsx)(sw,{label:e,sortKey:r,sort:t,onSort:n});return(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[i(`Scenario`,`eval`),e.map(e=>(0,Y.jsx)(sw,{label:e,sortKey:`axis:${e}`,sort:t,onSort:n},e)),i(`Agent`,`agent`),r?(0,Y.jsx)($.Head,{children:`Runtime`}):i(`Runtime`,`runtime`),i(`Trials`,`trials`),r?(0,Y.jsx)($.Head,{children:`Latest run`}):i(`Latest run`,`status`),(0,Y.jsx)($.Head,{className:`text-right`,children:`Actions`})]})})}var Sw=50;function Cw({api:e,evalIds:t,catalog:n,matrix:r,runs:i,nested:a=!1,onRun:o}){let[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(0),{sort:d,toggleSort:f}=ow({key:`eval`,direction:`asc`},()=>u(0)),[p,m]=(0,_.useState)(),[h,g]=(0,_.useState)(),v=r.dimensions??Object.keys(r.parameters),y=t.join(`,`);(0,_.useEffect)(()=>{let t=!0;return g(void 0),m(void 0),e.listMatrixCells({evalIds:y.split(`,`).filter(Boolean),query:s,offset:l*Sw,sort:d.key,direction:d.direction}).then(e=>{t&&m(e)}).catch(e=>{t&&g(e instanceof Error?e.message:`Unable to list matrix cells`)}),()=>{t=!1}},[e,y,s,l,d]);let b=new Map(n.map(e=>[e.id,e])),x=e=>i.filter(t=>t.matrixId===r.id&&t.cellKey===e).sort((e,t)=>t.startedAt.localeCompare(e.startedAt))[0],S=v.length+6;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)($C,{label:`Filter matrix cells`,placeholder:`Scenario, parameter or agent`,value:s,count:`${p?.total??0} of ${p?.planned??0} eligible cells`,onChange:e=>{c(e),u(0)}}),h?(0,Y.jsx)(AS,{message:h}):null,(0,Y.jsxs)(bw,{nested:a,children:[(0,Y.jsx)(xw,{axes:v,sort:d,onSort:f,planned:!0}),(0,Y.jsxs)($.Body,{children:[p?.cells.map(e=>{let t=b.get(e.evalId);return(0,Y.jsx)(yw,{id:e.evalId,evaluation:t,parameters:v.map(t=>e.parameters[t]===null?`None`:e.parameters[t]),trials:r.trials,latestRun:x(e.key),cellParameters:e.parameters,onRun:t?()=>o(t.path,Object.fromEntries(v.map(t=>[t,e.parameters[t]]))):void 0},e.key)}),!p&&!h?(0,Y.jsx)(DS,{colSpan:S,children:`Loading cells…`}):null,p&&!p.cells.length?(0,Y.jsx)(DS,{colSpan:S,children:`No matching cells.`}):null]})]}),(0,Y.jsx)(BC,{label:`Matrix cells pages`,noun:`Cells`,page:l,pageSize:Sw,total:p?.total??0,onPage:u})]})}var ww=50;function Tw(e,t,n,r){let i=t.reduce((e,[,t])=>e*t.length,1),a=e.length*i;if(!Number.isSafeInteger(a))throw Error(`Matrix exceeds safe cell count`);let o=[];for(let s=n;s<Math.min(n+r,a);s++){let n=e[Math.floor(s/i)],r=s%i,a={},c=Array(t.length);for(let e=t.length-1;e>=0;e--){let[n,i]=t[e],o=i[r%i.length];a[n]=o,c[e]=o,r=Math.floor(r/i.length)}o.push({id:n,parameters:a,values:c})}return{rows:o,total:a}}function Ew(e,t,n){return JSON.stringify([e,t.map(([e])=>n[e])])}function Dw(e){return typeof e==`string`?e:JSON.stringify(e)??String(e)}function Ow(e,t,n){let r=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return r.length?e.filter(e=>{let t=n(e).map(Dw).join(` `).toLowerCase();return r.every(e=>t.includes(e))}):[...e]}function kw(e){let t=e.matrix?e.evalIds.length*Object.values(e.matrix.parameters).reduce((e,t)=>e*t.length,1):0;return e.matrix&&(e.matrix.constrained||t>1e3)?(0,Y.jsx)(Cw,{...e,matrix:e.matrix}):(0,Y.jsx)(Aw,{...e})}function Aw({evalIds:e,catalog:t,matrix:n,runs:r,nested:i=!1,onRun:a}){let[o,s]=(0,_.useState)(0),[c,l]=(0,_.useState)(``),{sort:u,toggleSort:d}=ow({key:`eval`,direction:`asc`},()=>s(0)),f=n?Object.entries(n.parameters):[],p=new Map(t.map(e=>[e.id,e])),m=new Map;for(let e of r){if(n&&(e.matrixId!==n.id||!e.parameters))continue;let t=n?Ew(e.evalId,f,e.parameters):e.evalId,r=m.get(t);(!r||r.startedAt<=e.startedAt)&&m.set(t,e)}let h=e=>p.get(e.id),g=e=>m.get(n?Ew(e.id,f,e.parameters):e.id),v=e=>g(e)?.status,{total:y}=Tw(e,f,0,0),b=cw(Ow(Tw(e,f,0,y).rows,c,e=>{let t=h(e);return[t?.name??e.id,e.id,t?.path??e.id,...e.values,HS(t),t?.agent.runtimes.map(e=>e.name).join(`, `)??`default`,v(e)??`not run`]}),u,(e,t)=>{let r=h(e);return t.startsWith(`axis:`)?Dw(e.parameters[t.slice(5)]):t===`eval`?r?.name??e.id:t===`agent`?HS(r):t===`runtime`?r?.agent.runtimes.map(e=>e.name).join(`, `)??`default`:t===`trials`?n?.trials??r?.trialCount??0:t===`status`?v(e)??`not run`:``}),x=Math.max(1,Math.ceil(b.length/ww)),S=Math.min(o,x-1),C=b.slice(S*ww,(S+1)*ww);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)($C,{label:n?`Filter matrix cells`:`Filter scenarios`,placeholder:`Scenario, parameter, agent or status`,value:c,count:`${b.length} of ${y} ${n?`cells`:`scenarios`}`,onChange:e=>{l(e),s(0)}}),(0,Y.jsxs)(bw,{nested:i,children:[(0,Y.jsx)(xw,{axes:f.map(([e])=>e),sort:u,onSort:d}),(0,Y.jsx)($.Body,{children:C.length?C.map(e=>{let t=h(e);return(0,Y.jsx)(yw,{id:e.id,evaluation:t,parameters:e.values,trials:n?.trials,latestRun:g(e),cellParameters:e.parameters,onRun:t&&n!==void 0?()=>a(t.path,n?e.parameters:void 0):void 0,runDisabled:!!t&&n===void 0},Ew(e.id,f,e.parameters))}):(0,Y.jsx)(DS,{colSpan:f.length+6,children:`No matching cells.`})})]}),(0,Y.jsx)(BC,{label:`Matrix cells pages`,noun:`Cells`,page:S,pageSize:ww,total:b.length,onPage:s})]})}var jw=25;function Mw({api:e,catalog:t,suites:n,matrix:r,runs:i,evalId:a}){let[o,s]=(0,_.useState)(),c=t.find(e=>e.id===a),l=(0,_.useMemo)(()=>i.filter(e=>e.evalId===a).sort((e,t)=>t.startedAt.localeCompare(e.startedAt)),[i,a]);if(!c&&!l.length)return(0,Y.jsx)(BS,{message:`Scenario not found: ${a}`});let u=t=>{c&&(s(void 0),e.runEval(c.path,t).catch(e=>s(e instanceof Error?e.message:`Unable to start scenario`)))},d=!!c&&!e.readOnly;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(CC,{section:`scenarios`,current:c?.name??a}),(0,Y.jsx)(iC,{title:c?.name??a,subtitle:c?.id??`${a} (no longer in the project)`,status:l[0]?(0,Y.jsx)(uw,{status:l[0].status}):void 0,actions:d&&r===null?(0,Y.jsx)(kp,{size:`sm`,variant:`primary`,icon:(0,Y.jsx)(ap,{weight:`fill`}),className:`run-scenario`,onClick:()=>u(),children:`Run scenario`}):void 0}),o?(0,Y.jsx)(AS,{message:o}):null,c?(0,Y.jsx)(Nw,{scenario:c,suites:n,catalog:t}):null,c?.transcript?.length?(0,Y.jsx)(Pw,{scenario:c,catalog:t}):null,d&&r?(0,Y.jsxs)(`section`,{"aria-label":`Matrix cells`,className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:`Matrix cells`}),(0,Y.jsx)(kw,{api:e,evalIds:[a],catalog:t,matrix:r,runs:i,onRun:(e,t)=>u(t)})]}):null,(0,Y.jsxs)(`section`,{"aria-label":`Runs`,className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:[`Runs`,` `,(0,Y.jsx)(`span`,{className:`font-normal text-kumo-subtle tabular-nums`,children:l.length})]}),(0,Y.jsx)(Iw,{runs:l})]})]})}function Nw({scenario:e,suites:t,catalog:n}){let r=t.find(t=>t.id===e.suiteId||t.evalIds.includes(e.id)),i=WS(n),a=e=>i.find(t=>t.scorer.name===e.name&&t.scorer.kind===e.kind&&t.scorer.definedAt===e.definedAt)?.key??e.name,o=e.policy;return(0,Y.jsx)($_,{className:`scenario-definition max-w-3xl p-4`,children:(0,Y.jsx)(zS,{items:[...r?[[`Suite`,r.name??r.id]]:[],[`Agent`,(0,Y.jsx)(mn,{to:$S(VS(e)),className:OS,children:HS(e)},`agent`)],...e.judgeAgent?[[`Judge agent`,(0,Y.jsx)(mn,{to:$S(VS({agent:e.judgeAgent})),className:OS,children:e.judgeAgent.name??e.judgeAgent.id??e.judgeAgent.kind},`judge-agent`)]]:[],[`Final scoring`,e.scorers.length?(0,Y.jsx)(`span`,{className:`flex flex-wrap gap-x-2`,children:e.scorers.map(e=>(0,Y.jsx)(mn,{to:eC(a(e)),className:OS,children:e.name},`${e.kind}-${e.name}`))},`scorers`):`none`],[`Datasets`,(e.datasets??[]).length?(0,Y.jsx)(`span`,{className:`flex flex-wrap gap-x-2`,children:(e.datasets??[]).map(e=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(mn,{to:nC(e.id),className:OS,children:e.id}),` `,(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[`(`,e.visibility===`candidate`?`agent`:`scorers only`,`)`]})]},e.id))},`datasets`):`none`],[`Trials per run`,o?.trials??e.trialCount],...o?.timeoutMs===void 0?[]:[[`Timeout`,`${o.timeoutMs/1e3}s`]],...o?.failfast?[[`Failfast`,`stops at the first failed checkpoint`]]:[],[`Runtimes`,e.agent.runtimes.map(e=>`${e.name} (${e.kind})`).join(`, `)||`default`],[`Defined in`,(0,Y.jsx)(wC,{at:e.definedAt},`at`)]]})})}function Pw({scenario:e,catalog:t}){let n=WS(t);return(0,Y.jsxs)(`section`,{"aria-label":`Transcript`,className:`flex max-w-3xl flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:`Transcript`}),(0,Y.jsx)(`ol`,{className:`flex flex-col gap-1.5`,children:(e.transcript??[]).map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-3 rounded-md border border-kumo-hairline bg-kumo-base px-3 py-2 text-[13px]`,children:[(0,Y.jsx)(`span`,{className:`w-5 shrink-0 text-right text-xs text-kumo-subtle tabular-nums`,children:t+1}),(0,Y.jsx)(Fw,{step:e,judgeKey:e=>n.find(t=>t.scorer.name===e.name&&t.scorer.kind===e.kind&&t.scorer.definedAt===e.definedAt)?.key??e.name})]},t))})]})}function Fw({step:e,judgeKey:t}){let n=e=>(0,Y.jsx)(`span`,{className:`w-24 shrink-0 text-xs font-medium text-kumo-subtle`,children:e});switch(e.kind){case`user`:return(0,Y.jsxs)(Y.Fragment,{children:[n(`User says`),(0,Y.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.message})]});case`agent`:return(0,Y.jsxs)(Y.Fragment,{children:[n(`Agent should`),(0,Y.jsx)(`code`,{className:kS,children:JSON.stringify(e.expectation)})]});case`expect-tool-call`:return(0,Y.jsxs)(Y.Fragment,{children:[n(`Expect tool call`),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`code`,{className:kS,children:e.name}),e.arguments===void 0?null:(0,Y.jsx)(`code`,{className:`${kS} ml-2 text-kumo-subtle`,children:JSON.stringify(e.arguments)})]})]});case`checkpoint`:return(0,Y.jsxs)(Y.Fragment,{children:[n(`Checkpoint`),(0,Y.jsx)(mn,{to:eC(t(e.scorer)),className:OS,children:e.scorer.name}),(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:e.scorer.kind===`judge`?`LLM judge`:`predicate`})]})}}function Iw({runs:e}){let[t,n]=(0,_.useState)(0),r=sC(e),i=e.slice(t*jw,(t+1)*jw),a=5+r.columns.length+ +!!r.overflow.length;return(0,Y.jsxs)(Y.Fragment,{children:[r.constant.length?(0,Y.jsxs)(`p`,{className:`flex flex-wrap items-center gap-1 text-[13px] text-kumo-subtle`,role:`note`,children:[`Same on every run:`,(0,Y.jsx)(cC,{entries:r.constant})]}):null,(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Run`}),(0,Y.jsx)($.Head,{children:`Status`}),(0,Y.jsx)($.Head,{children:`Score`}),(0,Y.jsx)($.Head,{children:`Started`}),(0,Y.jsx)($.Head,{children:`Commit`}),r.columns.map(e=>(0,Y.jsx)($.Head,{children:e},e)),r.overflow.length?(0,Y.jsx)($.Head,{children:`Other parameters`}):null]})}),(0,Y.jsxs)($.Body,{children:[i.map(e=>(0,Y.jsxs)($.Row,{...gC,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(mn,{to:YS(e.id),"data-row-link":!0,className:`${OS} ${kS}`,title:e.id,children:e.id.slice(0,8)})}),(0,Y.jsx)($.Cell,{title:e.interrupted?`Its process stopped before the run finished`:void 0,children:(0,Y.jsx)(uw,{status:e.status})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(mC,{run:e})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(hC,{run:e})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(gw,{source:e.source})}),r.columns.map(t=>(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(uC,{run:e,name:t})},t)),r.overflow.length?(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(lC,{run:e,keys:r.overflow})}):null]},e.id)),e.length?null:(0,Y.jsx)(DS,{colSpan:a,children:`Not run yet.`})]})]}),(0,Y.jsx)(BC,{label:`Scenario run pages`,noun:`Runs`,page:t,pageSize:jw,total:e.length,onPage:n})]})}function Lw({suite:e,expanded:t,onToggle:n,onRun:r}){return(0,Y.jsxs)($.Row,{variant:t?`selected`:`default`,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(`button`,{type:`button`,className:`${OS} inline-flex items-center gap-1.5`,"aria-expanded":t,onClick:n,children:[(0,Y.jsx)(Rf,{"aria-hidden":!0,className:`size-3 transition-transform ${t?`rotate-90`:``}`}),e.name??e.id??`Unnamed suite`]})}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:e.evalIds.length}),(0,Y.jsx)($.Cell,{className:`text-right`,children:(0,Y.jsx)(kp,{size:`xs`,variant:`secondary`,icon:(0,Y.jsx)(ap,{weight:`fill`}),disabled:!r,title:r?void 0:`Run matrix cells individually from their rows`,onClick:e=>{e.stopPropagation(),r?.()},children:`Run suite`})})]})}function Rw({api:e,suites:t,catalog:n,matrix:r,runs:i=[],selectedSuiteId:a}){let[o,s]=(0,_.useState)(a),[c,l]=(0,_.useState)(),u=e=>t=>l(t instanceof Error?t.message:e),d=(t,n)=>{l(void 0),e.runEval(t,n).catch(u(`Unable to start scenario`))},f=t=>{l(void 0),e.runSuite(t).catch(u(`Unable to start suite`))},p=o,m=n.filter(e=>!e.suiteId&&!t.some(t=>t.evalIds.includes(e.id)));return!t.length&&!m.length?(0,Y.jsx)(BS,{message:`No scenarios are loaded.`}):(0,Y.jsxs)(Y.Fragment,{children:[r?(0,Y.jsx)(`p`,{className:`text-[13px] text-kumo-subtle`,children:`Each row is one configured matrix cell. Run one row at a time; use the CLI dry-run for larger selections.`}):null,c?(0,Y.jsx)(AS,{message:c}):null,t.length>0?(0,Y.jsxs)(`section`,{"aria-label":`Suites`,className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-kumo-strong`,children:`Suites`}),(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Suite`}),(0,Y.jsx)($.Head,{children:`Scenarios`}),(0,Y.jsx)($.Head,{className:`text-right`,children:`Actions`})]})}),(0,Y.jsx)($.Body,{children:t.map(t=>(0,Y.jsxs)(_.Fragment,{children:[(0,Y.jsx)(Lw,{suite:t,expanded:p===t.id,onToggle:()=>{s(p===t.id?void 0:t.id)},onRun:r===null?()=>f(t.id):void 0}),p===t.id?(0,Y.jsx)($.Row,{children:(0,Y.jsx)($.Cell,{colSpan:3,className:`bg-kumo-elevated`,children:(0,Y.jsx)(kw,{api:e,evalIds:t.evalIds,catalog:n,matrix:r,runs:i,nested:!0,onRun:d})})}):null]},t.id))})]})]}):null,m.length>0?(0,Y.jsxs)(`section`,{"aria-label":`Scenarios without a suite`,className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-kumo-strong`,children:t.length?`Scenarios without a suite`:`Scenarios`}),(0,Y.jsx)(kw,{api:e,evalIds:m.map(e=>e.id),catalog:n,matrix:r,runs:i,onRun:d})]}):null]})}function zw(e,t,n){let r=(n,r)=>r?.suiteId??e.find(e=>e.id===n)?.suiteId??t.find(e=>e.evalIds.includes(n))?.id,i=new Map;for(let e of n){if(e.archived)continue;let t=Bw(e.evalId,e.parameters??{});i.set(t,[...i.get(t)??[],e])}let a=[...i].map(([t,n])=>{let i=n.sort((e,t)=>t.startedAt.localeCompare(e.startedAt)).slice(0,10),a=i[0],o=i.filter(e=>[`passed`,`failed`,`errored`].includes(e.status));return{key:t,evalId:a.evalId,scenario:e.find(e=>e.id===a.evalId),suiteId:r(a.evalId,a),parameters:a.parameters??{},runs:i,outcome:a.status,...o.length?{passRate:o.filter(e=>e.status===`passed`).length/o.length}:{}}});for(let t of e)a.some(e=>e.evalId===t.id)||a.push({key:Bw(t.id,{}),evalId:t.id,scenario:t,suiteId:r(t.id),parameters:{},runs:[],outcome:`not-run`});return a}function Bw(e,t){return`${e}\0${aC(t)}`}function Vw({api:e,catalog:t,suites:n,runs:r}){let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(!0),[c,l]=(0,_.useState)(),u=(0,_.useMemo)(()=>zw(t,n,r),[t,n,r]);if(!u.length)return(0,Y.jsx)(BS,{message:`No scenarios yet. Add one in scenarios/.`});let d=i.trim().toLowerCase().split(/\s+/).filter(Boolean),f=u.filter(e=>{let t=[e.evalId,e.scenario?.name,e.suiteId,yC[e.outcome],...Object.entries(e.parameters).map(([e,t])=>`${e}=${JSON.stringify(t)}`)].join(` `).toLowerCase();return d.every(e=>t.includes(e))}).sort((e,t)=>(o?bC[e.outcome]-bC[t.outcome]:0)||(e.scenario?.name??e.evalId).localeCompare(t.scenario?.name??t.evalId)||e.key.localeCompare(t.key)),p=new Map;for(let e of f){let t=e.suiteId??``;p.set(t,[...p.get(t)??[],e])}let m=e=>n.find(t=>t.id===e)?.name??e,h=t=>{t.scenario&&(l(void 0),e.runEval(t.scenario.path,Object.keys(t.parameters).length?t.parameters:void 0).catch(e=>l(e instanceof Error?e.message:`Unable to start scenario`)))};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Gw,{rows:u}),c?(0,Y.jsx)(AS,{message:c}):null,(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsx)($C,{label:`Filter scoreboard`,placeholder:`Scenario, suite, parameter or outcome`,value:i,count:`${f.length} of ${u.length}`,onChange:a}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[13px] text-kumo-subtle`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Failures first`]})]}),(0,Y.jsxs)(TS,{className:`scoreboard`,children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Scenario`}),(0,Y.jsx)($.Head,{children:`Latest`}),(0,Y.jsx)($.Head,{children:`Score`}),(0,Y.jsxs)($.Head,{children:[`Last `,10,` runs`]}),(0,Y.jsx)($.Head,{children:`Pass rate`}),(0,Y.jsx)($.Head,{className:`text-right`,children:e.readOnly?null:`Run`})]})}),(0,Y.jsx)($.Body,{children:[...p].map(([t,n])=>(0,Y.jsxs)(_.Fragment,{children:[p.size>1||t?(0,Y.jsx)($.Row,{className:`bg-kumo-elevated`,children:(0,Y.jsx)($.Cell,{colSpan:6,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-semibold text-kumo-strong`,children:t?m(t):`No suite`}),(0,Y.jsx)(Kw,{rows:n})]})})}):null,n.map(t=>(0,Y.jsx)(Hw,{row:t,onRun:e.readOnly||!t.scenario?void 0:()=>h(t)},t.key))]},t))})]})]})}function Hw({row:e,onRun:t}){let n=e.runs[0],r=Object.entries(e.parameters);return(0,Y.jsxs)($.Row,{"data-outcome":e.outcome,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(`span`,{className:`flex max-w-[22rem] flex-col gap-0.5`,children:[(0,Y.jsx)(mn,{to:tC(e.evalId),className:`${OS} truncate`,title:e.scenario?.name??e.evalId,children:e.scenario?.name??e.evalId}),r.length?(0,Y.jsx)(cC,{entries:r}):null]})}),(0,Y.jsx)($.Cell,{children:n?(0,Y.jsxs)(mn,{to:YS(n.id),className:`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium ${vC[e.outcome]}`,title:`Latest run ${n.id.slice(0,8)}, ${new Date(n.startedAt).toLocaleString()}`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-2 rounded-full ${_C[e.outcome]}`}),yC[e.outcome],(0,Y.jsx)(`span`,{className:`font-normal text-kumo-subtle`,children:dC(n.startedAt)})]}):(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:`not run`})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(`span`,{className:`inline-block min-w-10 rounded px-1.5 py-0.5 text-center tabular-nums ${n?vC[e.outcome]:``}`,children:fC(n?.score)})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(Uw,{runs:e.runs})}),(0,Y.jsx)($.Cell,{children:e.passRate===void 0?(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:`—`}):(0,Y.jsxs)(`span`,{className:`inline-block min-w-12 rounded px-1.5 py-0.5 text-center tabular-nums ${xC(e.passRate)}`,children:[Math.round(e.passRate*100),`%`]})}),(0,Y.jsx)($.Cell,{className:`text-right`,children:t?(0,Y.jsx)(kp,{size:`xs`,variant:`secondary`,shape:`square`,"aria-label":`Run ${e.scenario?.name??e.evalId}`,title:`Run again`,icon:(0,Y.jsx)(ap,{weight:`fill`}),onClick:t}):null})]})}function Uw({runs:e}){let t=[...Array(Math.max(0,10-e.length)).fill(void 0),...[...e].reverse()];return(0,Y.jsx)(`span`,{className:`history inline-flex items-center gap-0.5`,children:t.map((e,t)=>e?(0,Y.jsx)(mn,{to:YS(e.id),className:`size-3.5 rounded-[3px] hover:ring-2 hover:ring-kumo-focus ${_C[e.status]}`,title:`${yC[e.status]} · score ${fC(e.score)} · ${new Date(e.startedAt).toLocaleString()}`,"aria-label":`${yC[e.status]} run ${e.id.slice(0,8)}`},e.id):(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-3.5 rounded-[3px] border border-dashed border-kumo-hairline`},`empty-${t}`))})}var Ww=[`passed`,`failed`,`errored`,`running`,`not-run`];function Gw({rows:e}){return(0,Y.jsx)(`div`,{className:`tally grid grid-cols-2 gap-2 sm:grid-cols-5`,children:Ww.map(t=>{let n=e.filter(e=>e.outcome===t).length;return(0,Y.jsxs)(`div`,{"data-outcome":t,className:`flex items-center gap-3 rounded-lg border border-kumo-line px-3 py-2 ${n?vC[t]:``}`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-3 rounded-full ${_C[t]}`}),(0,Y.jsx)(`span`,{className:`text-xl font-semibold text-kumo-strong tabular-nums`,children:n}),(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:yC[t]})]},t)})})}function Kw({rows:e}){let t=[...e].sort((e,t)=>bC[e.outcome]-bC[t.outcome]),n=e.filter(e=>e.outcome===`passed`).length;return(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`flex h-2 w-40 overflow-hidden rounded-full bg-kumo-fill`,children:t.map(e=>(0,Y.jsx)(`span`,{className:`h-full flex-1 ${_C[e.outcome]}`},e.key))}),(0,Y.jsxs)(`span`,{className:`${kS} text-kumo-subtle`,children:[n,`/`,e.length]})]})}function qw({artifact:e}){return(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Cell,{className:`${kS} break-all`,children:e.path}),(0,Y.jsx)($.Cell,{children:e.kind}),(0,Y.jsx)($.Cell,{className:`whitespace-nowrap tabular-nums`,children:e.size===void 0?`—`:`${e.size} B`})]})}var Jw=e=>typeof e==`string`?e:void 0,Yw=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0;function Xw(e){if(typeof e==`object`&&e){let t=e;return{name:Jw(t.name),message:Jw(t.message)??JSON.stringify(e),stack:Jw(t.stack)}}return{message:String(e)}}function Zw(e){if(typeof e!=`object`||!e)return;let t=e,n={inputTokens:Yw(t.inputTokens),outputTokens:Yw(t.outputTokens),totalTokens:Yw(t.totalTokens)};return Object.values(n).some(e=>e!==void 0)?n:void 0}var Qw=new Set([`trial-started`,`trial-completed`,`started`,`transcript-step-completed`]);function $w(e){let t=e.map(e=>Date.parse(e.timestamp)),n=t.find(e=>!Number.isNaN(e))??0,r=e=>{let r=t[e];return Number.isNaN(r)?0:Math.max(0,r-n)},i=[],a=[],o=new Map,s=new Map,c=new Map,l=new Map,u,d=!1,f=()=>a.at(-1)?.items??i,p=()=>(a.push({items:[]}),d=!1,a.at(-1));e.forEach((e,t)=>{let n=r(t);if(!Qw.has(e.kind))switch(e.kind){case`transcript-step-started`:{let t=Jw(e.message);if(t===void 0)return;p().items.push({type:`user`,at:n,text:t}),d=!0;return}case`turn-started`:{let t=Yw(e.turn),n=d?a.at(-1):p();n.turn=t,d=!1;return}case`turn-completed`:{let t=a.at(-1);if(!t)return;t.turn??=Yw(e.turn),t.latencyMs=Yw(e.latencyMs),t.usage=Zw(e.usage);return}case`message`:{d=!1;let t=Jw(e.role)??`unknown`;if(t===`user`){let t=typeof e.content==`string`?e.content:void 0,r=a.at(-1)?.items.find(e=>e.type===`user`);if(t!==void 0&&r?.type===`user`&&r.text===t)return;f().push({type:`user`,at:n,text:t??JSON.stringify(e.content)});return}if(t===`assistant`){u=e.content,f().push({type:`assistant`,at:n,content:e.content});return}f().push({type:`message`,at:n,role:t,content:e.content});return}case`tool-call`:{d=!1;let r=Jw(e.id)??`call-${t}`,i={type:`tool`,at:n,id:r,name:Jw(e.name)??`tool`,arguments:e.arguments};c.set(r,i),f().push(i);return}case`tool-result`:{let r=c.get(Jw(e.id)??``);if(r&&!r.result){r.result={value:e.result,durationMs:n-r.at};return}f().push({type:`tool`,at:n,id:Jw(e.id)??`result-${t}`,name:Jw(e.name)??`tool`,result:{value:e.result,durationMs:0}});return}case`checkpoint-started`:{let r=Yw(e.step)??t,i={type:`checkpoint`,at:n,step:r,name:Jw(e.name)??`step ${r+1}`,state:`running`};l.set(r,i),f().push(i);return}case`checkpoint-completed`:case`checkpoint-error`:{let t=Yw(e.step)??-1,r=l.get(t);if(!r)return;if(r.durationMs=n-r.at,e.kind===`checkpoint-error`)r.state=`error`,r.error=Xw(e.error);else{let t=Jw(e.status);r.state=t===`passed`||t===`failed`||t===`skipped`?t:`error`}return}case`transcript-step-skipped`:f().push({type:`skipped-step`,at:n,step:Yw(e.step)??-1});return;case`scorer-started`:s.set(Jw(e.scorer)??`scorer`,n);return;case`scorer-completed`:case`scorer-failed`:{let t=Jw(e.scorer)??`scorer`,r=s.get(t);o.set(t,{name:t,value:Yw(e.value),skipped:e.skipped===!0,error:e.kind===`scorer-failed`?Xw(e.error):void 0,durationMs:r===void 0?void 0:n-r});return}case`completed`:if(e.output===void 0||JSON.stringify(e.output)===JSON.stringify(u))return;f().push({type:`output`,at:n,output:e.output});return;case`error`:f().push({type:`error`,at:n,source:e.source,error:Xw(e.error)});return;default:f().push({type:`unknown`,at:n,event:e})}});let m=e.length?r(e.length-1):void 0;return{preamble:i,turns:a,scorers:[...o.values()],durationMs:m}}function eT(e){if(e<1)return`<1ms`;if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFixed(e<1e4?2:1)}s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return`${t}m ${String(n).padStart(2,`0`)}s`}function tT(e){let t=e.totalTokens??(e.inputTokens!==void 0||e.outputTokens!==void 0?(e.inputTokens??0)+(e.outputTokens??0):void 0),n=[e.inputTokens===void 0?void 0:`${e.inputTokens.toLocaleString()} in`,e.outputTokens===void 0?void 0:`${e.outputTokens.toLocaleString()} out`].filter(Boolean),r=t===void 0?``:`${t.toLocaleString()} tokens`;return n.length?`${r}${r?` `:``}(${n.join(` · `)})`:r}function nT({events:e}){let[t,n]=(0,_.useState)(`conversation`),r=$w(e);return(0,Y.jsxs)(`section`,{className:`trajectory flex min-w-0 flex-col gap-3`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:`Trajectory`}),(0,Y.jsx)(ob,{variant:`segmented`,size:`sm`,value:t,onValueChange:e=>n(e),tabs:[{value:`conversation`,label:`Conversation`},{value:`events`,label:`All events (${e.length})`}]})]}),t===`events`?(0,Y.jsx)(lT,{events:e}):(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[r.preamble.length?(0,Y.jsx)(iT,{items:r.preamble}):null,r.turns.map((e,t)=>(0,Y.jsx)(rT,{turn:e,index:t},t)),e.length?(0,Y.jsx)(cT,{durationMs:r.durationMs,scorers:r.scorers}):(0,Y.jsx)(`p`,{className:`text-[13px] text-kumo-subtle`,children:`No events recorded.`})]})]})}function rT({turn:e,index:t}){let n=[e.latencyMs===void 0?void 0:eT(e.latencyMs),e.usage?tT(e.usage):void 0].filter(Boolean);return(0,Y.jsxs)(`section`,{className:`turn border-t border-kumo-line pt-3 pb-4 first:border-t-0 first:pt-0`,"aria-label":`Turn ${e.turn??t+1}`,children:[(0,Y.jsxs)(`header`,{className:`mb-2 flex items-baseline justify-between gap-3 text-xs`,children:[(0,Y.jsxs)(`h4`,{className:`font-medium text-kumo-strong`,children:[`Turn `,e.turn??t+1]}),n.length?(0,Y.jsx)(`span`,{className:`text-kumo-subtle tabular-nums`,children:n.join(` · `)}):null]}),(0,Y.jsx)(iT,{items:e.items})]})}function iT({items:e}){return(0,Y.jsx)(`ol`,{className:`relative flex flex-col gap-3 before:absolute before:top-2 before:bottom-2 before:left-[11px] before:w-px before:bg-kumo-line`,children:e.map((e,t)=>(0,Y.jsx)(`li`,{className:`trajectory-item item-${e.type}`,children:(0,Y.jsx)(oT,{item:e})},t))})}function aT({icon:e,tone:t=`default`,label:n,at:r,children:i}){return(0,Y.jsxs)(`div`,{className:`grid grid-cols-[24px_minmax(0,1fr)] gap-x-3`,children:[(0,Y.jsx)(`span`,{className:J(`relative z-10 flex size-6 items-center justify-center rounded-full border border-kumo-line bg-kumo-base text-[13px]`,t===`danger`&&`border-kumo-danger text-kumo-danger`,t===`muted`?`text-kumo-subtle`:`text-kumo-default`),"aria-hidden":!0,children:e}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5 pt-0.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-5 items-baseline gap-2 text-xs`,children:[(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-baseline gap-x-2 gap-y-1`,children:n}),r===void 0?null:(0,Y.jsxs)(`time`,{className:`shrink-0 font-mono text-[11px] text-kumo-subtle tabular-nums`,children:[`+`,eT(r)]})]}),i]})]})}function oT({item:e}){switch(e.type){case`user`:return(0,Y.jsx)(aT,{icon:(0,Y.jsx)(dp,{}),label:(0,Y.jsx)(uT,{children:`User`}),at:e.at,children:(0,Y.jsx)(_T,{className:`rounded-lg bg-kumo-elevated px-3 py-2`,children:e.text})});case`assistant`:return(0,Y.jsx)(aT,{icon:(0,Y.jsx)(sp,{}),label:(0,Y.jsx)(uT,{children:`Assistant`}),at:e.at,children:(0,Y.jsx)(mT,{value:e.content})});case`message`:return(0,Y.jsx)(aT,{icon:(0,Y.jsx)($f,{}),tone:`muted`,label:(0,Y.jsxs)(uT,{children:[e.role,` message`]}),at:e.at,children:(0,Y.jsx)(mT,{value:e.content})});case`tool`:return(0,Y.jsx)(sT,{item:e});case`checkpoint`:return(0,Y.jsx)(aT,{icon:(0,Y.jsx)(qf,{}),tone:e.state===`error`?`danger`:`default`,label:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(uT,{children:`Checkpoint`}),(0,Y.jsx)(`span`,{className:`text-[13px] text-kumo-default`,children:e.name}),(0,Y.jsx)(uw,{status:e.state}),e.durationMs===void 0?null:(0,Y.jsx)(dT,{children:eT(e.durationMs)})]}),at:e.at,children:e.error?(0,Y.jsx)(pT,{error:e.error}):null});case`skipped-step`:return(0,Y.jsx)(aT,{icon:(0,Y.jsx)(lp,{}),tone:`muted`,label:(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[`Step `,e.step+1,` skipped after a failed checkpoint`]}),at:e.at});case`error`:return(0,Y.jsx)(aT,{icon:(0,Y.jsx)(fp,{}),tone:`danger`,label:(0,Y.jsx)(`span`,{className:`font-semibold text-kumo-danger`,children:e.source===`aut`?`Agent error`:`Runner error`}),at:e.at,children:(0,Y.jsx)(pT,{error:e.error})});case`output`:return(0,Y.jsx)(aT,{icon:(0,Y.jsx)(cp,{}),label:(0,Y.jsx)(uT,{children:`Final output`}),at:e.at,children:(0,Y.jsx)(mT,{value:e.output})});case`unknown`:{let{source:t,kind:n,timestamp:r,...i}=e.event;return(0,Y.jsx)(aT,{icon:(0,Y.jsx)(op,{}),tone:`muted`,label:(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[t,` · `,(0,Y.jsx)(`span`,{className:`font-mono`,children:n})]}),at:e.at,children:Object.keys(i).length?(0,Y.jsx)(vT,{value:i}):null})}}}function sT({item:e}){let t=yT(e.arguments);return(0,Y.jsxs)(`details`,{className:`tool-call group`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer list-none rounded-md select-none focus-visible:outline-2 focus-visible:outline-kumo-brand [&::-webkit-details-marker]:hidden`,children:(0,Y.jsx)(aT,{icon:(0,Y.jsx)(pp,{}),label:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Rf,{"aria-hidden":!0,className:`self-center text-kumo-subtle transition-transform group-open:rotate-90`}),(0,Y.jsx)(`span`,{className:`font-mono text-[13px] font-medium text-kumo-strong`,children:e.name}),t?(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono text-kumo-subtle`,children:t}):null,e.result?(0,Y.jsx)(dT,{children:eT(e.result.durationMs)}):(0,Y.jsx)(`span`,{className:`text-kumo-warning`,children:`no result`})]}),at:e.at,children:e.result?(0,Y.jsxs)(`span`,{className:`line-clamp-2 font-mono text-xs break-words text-kumo-subtle group-open:hidden`,children:[`→ `,yT(e.result.value,240)]}):null})}),(0,Y.jsxs)(`div`,{className:`mt-2 ml-9 flex flex-col gap-2`,children:[e.arguments===void 0?null:(0,Y.jsx)(fT,{label:`Arguments`,children:(0,Y.jsx)(vT,{value:e.arguments})}),e.result?(0,Y.jsx)(fT,{label:`Result`,children:(0,Y.jsx)(vT,{value:e.result.value})}):null]})]})}function cT({durationMs:e,scorers:t}){let n=t.filter(e=>e.error).length,r=[e===void 0?void 0:`Finished in ${eT(e)}`,t.length?`${t.length} final ${t.length===1?`scorer`:`scorers`} ran${n?`, ${n} errored`:``}`:void 0].filter(Boolean);return r.length?(0,Y.jsx)(`p`,{className:`border-t border-kumo-line pt-3 text-xs text-kumo-subtle tabular-nums`,children:r.join(` · `)}):null}function lT({events:e}){let t=Date.parse(e[0]?.timestamp??``);return(0,Y.jsx)(`ol`,{className:`raw-events flex flex-col divide-y divide-kumo-line rounded-lg border border-kumo-line text-xs`,children:e.map((e,n)=>{let{source:r,kind:i,timestamp:a,...o}=e,s=Date.parse(a)-t,c=Object.keys(o).length?JSON.stringify(o):``;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`details`,{className:`group`,children:[(0,Y.jsxs)(`summary`,{className:`grid cursor-pointer list-none grid-cols-[2rem_4rem_3rem_13rem_minmax(0,1fr)] items-baseline gap-x-3 px-3 py-1.5 select-none hover:bg-kumo-elevated [&::-webkit-details-marker]:hidden`,children:[(0,Y.jsx)(`span`,{className:`text-right font-mono text-kumo-subtle tabular-nums`,children:n+1}),(0,Y.jsx)(`span`,{className:`font-mono text-kumo-subtle tabular-nums`,children:Number.isNaN(s)?``:`+${eT(s)}`}),(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:r}),(0,Y.jsx)(`span`,{className:`font-mono text-kumo-strong`,children:i}),(0,Y.jsx)(`span`,{className:`truncate font-mono text-kumo-subtle`,children:c})]}),(0,Y.jsx)(`div`,{className:`px-3 pb-2`,children:(0,Y.jsx)(vT,{value:e})})]})},`${a}-${n}`)})})}function uT({children:e}){return(0,Y.jsx)(`span`,{className:`font-semibold text-kumo-strong first-letter:uppercase`,children:e})}function dT({children:e}){return(0,Y.jsx)(`span`,{className:`text-kumo-subtle tabular-nums`,children:e})}function fT({label:e,children:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:e}),t]})}function pT({error:e}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`p`,{className:`text-[13px] text-kumo-danger`,children:[e.name&&e.name!==`Error`?`${e.name}: `:``,e.message]}),e.stack?(0,Y.jsxs)(`details`,{className:`text-xs`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer text-kumo-subtle select-none`,children:`Stack trace`}),(0,Y.jsx)(`pre`,{className:`mt-1 overflow-x-auto rounded-md bg-kumo-elevated px-3 py-2 font-mono text-[11px]`,children:e.stack})]}):null]})}function mT({value:e}){return typeof e==`string`?(0,Y.jsx)(_T,{children:e}):(0,Y.jsx)(vT,{value:e})}var hT=1200,gT=16;function _T({children:e,className:t}){let n=e.length>hT||e.split(`
|
|
32
|
-
`).length>
|
|
33
|
-
`).length} lines`}):null]})}function vT({value:e}){let t=typeof e==`string`?e:JSON.stringify(e,null,2);return(0,Y.jsx)(`pre`,{className:`max-h-96 overflow-auto rounded-md bg-kumo-elevated px-3 py-2 font-mono text-xs break-words whitespace-pre-wrap text-kumo-default`,children:t})}function yT(e,t=120){if(e===void 0)return``;let n=typeof e==`object`&&e&&!Array.isArray(e)?Object.entries(e).map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(`, `):typeof e==`string`?e:JSON.stringify(e);return n.length>t?`${n.slice(0,t-1)}…`:n}function bT({api:e,selected:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(),[c,l]=(0,_.useState)([]);if((0,_.useEffect)(()=>{if(!t)return;let n=!0;return a(void 0),r([]),s(void 0),l([]),Promise.all([e.getTrialEvents(t.run.id,t.trial.id),e.getTrial(t.run.id,t.trial.id),e.listArtifacts(t.run.id,t.trial.id)]).then(([e,t,i])=>{n&&(r(e),s(t),l(i))}).catch(e=>{n&&a(e instanceof Error?e.message:`Unable to load trial details`)}),()=>{n=!1}},[e,t]),!t)return(0,Y.jsx)(BS,{message:`Select a trial from a run to inspect it.`});let{trial:u}=t,d=TT(o?.manifest);return(0,Y.jsxs)(`section`,{className:`trial-inspector grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(320px,400px)]`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[i?(0,Y.jsx)(AS,{title:`Unable to load trial details`,message:i}):null,(0,Y.jsx)(nT,{events:n})]}),(0,Y.jsxs)(`aside`,{className:`trial-overview flex min-w-0 flex-col gap-4`,children:[(0,Y.jsx)(zS,{items:[[`Status`,(0,Y.jsx)(uw,{status:u.status},`status`)],[`Aggregate score`,u.score??`—`],[`Runtime`,u.durationMs===void 0?`—`:`${u.durationMs}ms`],[`Started`,new Date(u.startedAt).toLocaleString()]]}),(0,Y.jsxs)(xT,{title:`Final scoring`,children:[(0,Y.jsx)(wT,{scores:u.scores}),u.skippedScorers?.length?(0,Y.jsxs)(`p`,{className:`text-xs text-kumo-subtle`,children:[`Skipped final scorers: `,u.skippedScorers.join(`, `)]}):null]}),u.checkpoints?.length?(0,Y.jsx)(xT,{title:`Checkpoints`,children:(0,Y.jsx)(ST,{checkpoints:u.checkpoints})}):null,d.length?(0,Y.jsx)(xT,{title:`Datasets`,children:(0,Y.jsx)(zS,{items:d.map(e=>[e.id,(0,Y.jsxs)(`span`,{title:e.digest,children:[e.visibility,` · `,e.source,` ·`,` `,(0,Y.jsx)(`span`,{className:kS,children:e.digest.replace(`sha256:`,``).slice(0,12)})]},e.id)])})}):null,c.length?(0,Y.jsx)(xT,{title:`Artifacts`,children:(0,Y.jsxs)(ES,{wrap:!0,children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Path`}),(0,Y.jsx)($.Head,{children:`Kind`}),(0,Y.jsx)($.Head,{children:`Size`})]})}),(0,Y.jsx)($.Body,{children:c.map(e=>(0,Y.jsx)(qw,{artifact:e},e.path))})]})}):null,o?(0,Y.jsxs)(`details`,{className:`raw-details text-xs`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer font-medium text-kumo-subtle select-none`,children:`Raw trial summary`}),(0,Y.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-kumo-elevated px-3 py-2 font-mono`,children:JSON.stringify(o.summary,null,2)})]}):null]})]})}function xT({title:e,children:t}){return(0,Y.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:e}),t]})}function ST({checkpoints:e}){return(0,Y.jsxs)(ES,{wrap:!0,children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Step`}),(0,Y.jsx)($.Head,{children:`Rule`}),(0,Y.jsx)($.Head,{children:`Value`}),(0,Y.jsx)($.Head,{children:`Result`})]})}),(0,Y.jsx)($.Body,{children:e.map(e=>(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:e.step+1}),(0,Y.jsxs)($.Cell,{children:[(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[e.kind,`:`]}),` `,e.name,e.matchedToolCall?` (event ${e.matchedToolCall.eventIndex+1})`:``]}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:e.value??`—`}),(0,Y.jsxs)($.Cell,{children:[(0,Y.jsx)(uw,{status:e.status}),e.error?(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-kumo-danger`,children:e.error.message}):null]})]},`${e.step}-${e.name}`))})]})}function CT(e){return e.error?`error`:e.skipped?`skipped`:e.passed===!0?`passed`:e.passed===!1?`failed`:`not scored`}function wT({scores:e}){return(0,Y.jsxs)(ES,{wrap:!0,children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Scorer`}),(0,Y.jsx)($.Head,{children:`Value`}),(0,Y.jsx)($.Head,{children:`Result`})]})}),(0,Y.jsxs)($.Body,{children:[e.map(e=>(0,Y.jsxs)($.Row,{children:[(0,Y.jsxs)($.Cell,{children:[e.kind?(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[e.kind,`: `]}):null,e.name]}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:e.value??`—`}),(0,Y.jsxs)($.Cell,{children:[(0,Y.jsx)(uw,{status:CT(e)}),e.skipped&&e.explanation?(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-kumo-subtle`,children:e.explanation}):null,e.error?(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-kumo-danger`,children:e.error.message}):null]})]},e.name)),e.length?null:(0,Y.jsx)($.Row,{children:(0,Y.jsx)($.Cell,{colSpan:3,className:`text-kumo-subtle`,children:`No final scorers.`})})]})]})}function TT(e){let t=e?.datasets;return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&typeof e.digest==`string`):[]}function ET({api:e,selected:t}){let[n,r]=(0,_.useState)(),[i,a]=(0,_.useState)(),[o,s]=bn();(0,_.useEffect)(()=>{if(!t)return;let n=!0;return r(void 0),a(void 0),e.listWorkspace(t.run.id,t.trial.id).then(e=>{n&&r(e)}).catch(e=>{n&&a(e instanceof Error?e.message:`Unable to load workspace`)}),()=>{n=!1}},[e,t]);let c=t?.run.id,l=t?.trial.id,u=(0,_.useCallback)(t=>e.getWorkspaceFile(c,l,t),[e,c,l]);return t?(0,Y.jsxs)(`section`,{className:`workspace-inspector flex flex-col gap-2`,children:[i?(0,Y.jsx)(AS,{message:i}):null,!n&&!i?(0,Y.jsx)(`p`,{className:`text-[13px] text-kumo-subtle`,children:`Loading workspace…`}):null,n?(0,Y.jsx)(FS,{entries:n,rootLabel:`workspace/`,readFile:u,selected:o.get(`file`)??void 0,onSelect:e=>{let t=new URLSearchParams(o);t.set(`file`,e),s(t,{replace:!0})},emptyMessage:`The workspace is empty.`}):null]}):(0,Y.jsx)(BS,{message:`Select a trial to inspect its workspace.`})}function DT({api:e,runs:t,runId:n,trialId:r,workspace:i=!1}){let a=$e(),o=t.find(e=>e.id===n),{trials:s,error:c}=tw(e,o),l=s?.find(e=>e.id===r);if(!o)return(0,Y.jsx)(BS,{message:t.length?`Run not found: ${n}`:`Loading trial…`});let u=(0,Y.jsx)(rC,{run:o,trial:l??{id:r},workspace:i});if(c||s&&!l)return(0,Y.jsxs)(Y.Fragment,{children:[u,(0,Y.jsx)(AS,{message:c??`Trial ${r} was not found in this run.`})]});if(!l)return(0,Y.jsxs)(Y.Fragment,{children:[u,(0,Y.jsx)(`output`,{className:`text-[13px] text-kumo-subtle`,children:`Loading trial…`})]});let d={run:o,trial:l};return(0,Y.jsxs)(Y.Fragment,{children:[u,(0,Y.jsx)(iC,{title:i?`Candidate workspace`:`Trial ${l.index+1}`,subtitle:l.id,status:i?void 0:(0,Y.jsx)(uw,{status:l.status}),actions:i?void 0:(0,Y.jsx)(kp,{size:`sm`,variant:`secondary`,icon:(0,Y.jsx)(Yf,{}),className:`open-workspace`,onClick:()=>a(ZS(o.id,l.id)),children:`Candidate workspace`})}),i?(0,Y.jsx)(ET,{api:e,selected:d}):(0,Y.jsx)(bT,{api:e,selected:d})]})}var OT=20;function kT(e,t){let n=(0,_.useMemo)(()=>[...t].sort((e,t)=>t.startedAt.localeCompare(e.startedAt)),[t]),[r,i]=(0,_.useState)(OT),[a,o]=(0,_.useState)({}),[s,c]=(0,_.useState)(),l=n.slice(0,r),u=l.map(e=>`${e.id}:${e.completedTrials}:${e.status}`).join(`,`);return(0,_.useEffect)(()=>{let t=!0;return Promise.all(l.map(async t=>[t.id,await e.listTrials(t.id)])).then(e=>{t&&o(t=>({...t,...Object.fromEntries(e)}))}).catch(e=>{t&&c(e instanceof Error?e.message:`Unable to load trials`)}),()=>{t=!1}},[e,u]),{trials:l.flatMap(e=>(a[e.id]??[]).slice().sort((e,t)=>e.index-t.index).map(t=>({run:e,trial:t}))),error:s,loading:l.some(e=>!a[e.id]),more:n.length>r,loadMore:()=>i(e=>e+OT),runCount:l.length,totalRuns:n.length}}function AT({api:e,catalog:t,suites:n,runs:r,search:i,onSearchChange:a,workspaces:o=!1}){let s=rw({runs:r,catalog:t,suites:n,search:i,onSearchChange:a,trialStatus:!0}),c=kT(e,s.filteredRuns),l=c.trials.filter(({trial:e})=>s.keepTrial(e)),u=iw(s.facets,c.trials.map(({trial:e})=>e)),d=sC([...new Set(l.map(({run:e})=>e))]);if(!r.length)return(0,Y.jsx)(BS,{message:`No runs yet. Run a scenario to see its trials.`});let f=e=>t.find(t=>t.id===e)?.name??e,p=7+d.columns.length+ +!!d.overflow.length;return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-[13px] text-kumo-subtle`,children:o?`Each trial ran in its own workspace; open one to browse the files the agent left.`:`Every trial of the matching runs; open one for its trajectory and scores.`}),(0,Y.jsx)(aw,{selection:s,facets:u,label:o?`Filter workspaces`:`Filter trials`,count:`${l.length} trials of ${c.runCount} of ${c.totalRuns} matching runs`}),d.constant.length?(0,Y.jsxs)(`p`,{className:`constant-parameters flex flex-wrap items-center gap-1 text-[13px] text-kumo-subtle`,role:`note`,children:[`Same on every trial shown:`,(0,Y.jsx)(cC,{entries:d.constant})]}):null,c.error?(0,Y.jsx)(AS,{message:c.error}):null,(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:o?`Workspace`:`Trial`}),(0,Y.jsx)($.Head,{children:`Status`}),(0,Y.jsx)($.Head,{children:`Scenario`}),(0,Y.jsx)($.Head,{children:`Score`}),(0,Y.jsx)($.Head,{children:`Started`}),(0,Y.jsx)($.Head,{children:`Run`}),(0,Y.jsx)($.Head,{children:`Commit`}),d.columns.map(e=>(0,Y.jsx)($.Head,{children:e},e)),d.overflow.length?(0,Y.jsx)($.Head,{children:`Other parameters`}):null]})}),(0,Y.jsxs)($.Body,{children:[l.map(({run:e,trial:t})=>(0,Y.jsxs)($.Row,{...gC,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(mn,{to:o?ZS(e.id,t.id):XS(e.id,t.id),"data-row-link":!0,className:OS,title:t.id,children:[`Trial `,t.index+1]})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(uw,{status:t.status})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(mn,{to:tC(e.evalId),className:`${OS} block max-w-[16rem] truncate`,children:f(e.evalId)})}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:fC(t.score)}),(0,Y.jsxs)($.Cell,{className:`whitespace-nowrap tabular-nums`,title:new Date(t.startedAt).toLocaleString(),children:[dC(t.startedAt),t.durationMs===void 0?null:(0,Y.jsxs)(`span`,{className:`ml-2 text-xs text-kumo-subtle`,children:[`took `,pC(t.durationMs)]})]}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(mn,{to:YS(e.id),className:`${OS} ${kS}`,title:e.id,children:e.id.slice(0,8)})}),(0,Y.jsx)($.Cell,{className:`whitespace-nowrap`,children:(0,Y.jsx)(gw,{source:e.source})}),d.columns.map(t=>(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(uC,{run:e,name:t})},t)),d.overflow.length?(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(lC,{run:e,keys:d.overflow})}):null]},`${e.id}/${t.id}`)),l.length?null:(0,Y.jsx)(DS,{colSpan:p,children:c.loading?`Loading trials…`:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[`No matching trials.`,(0,Y.jsx)(kp,{size:`xs`,variant:`ghost`,onClick:s.clearFilters,children:`Clear filters`})]})})]})]}),c.more?(0,Y.jsx)(kp,{size:`sm`,variant:`secondary`,className:`self-start`,onClick:c.loadMore,children:`Load trials of older runs`}):null]})}function jT(e){return(0,Y.jsxs)(Et,{children:[(0,Y.jsx)(wt,{path:`/`,element:(0,Y.jsx)(Ct,{to:`/scoreboard`,replace:!0})}),(0,Y.jsx)(wt,{path:`/scoreboard`,element:(0,Y.jsx)(Vw,{...e})}),(0,Y.jsx)(wt,{path:`/runs`,element:(0,Y.jsx)(LT,{...e})}),(0,Y.jsx)(wt,{path:`/runs/:runId`,element:(0,Y.jsx)(zT,{...e})}),(0,Y.jsx)(wt,{path:`/runs/:runId/trials/:trialId`,element:(0,Y.jsx)(BT,{...e})}),(0,Y.jsx)(wt,{path:`/runs/:runId/trials/:trialId/workspace`,element:(0,Y.jsx)(BT,{...e,workspace:!0})}),(0,Y.jsx)(wt,{path:`/trials`,element:(0,Y.jsx)(RT,{...e})}),(0,Y.jsx)(wt,{path:`/workspaces`,element:(0,Y.jsx)(RT,{...e,workspaces:!0})}),(0,Y.jsx)(wt,{path:`/library/agents`,element:(0,Y.jsx)(AC,{...e})}),(0,Y.jsx)(wt,{path:`/library/agents/:id`,element:(0,Y.jsx)(PT,{...e})}),(0,Y.jsx)(wt,{path:`/library/judges`,element:(0,Y.jsx)(FC,{...e})}),(0,Y.jsx)(wt,{path:`/library/judges/:id`,element:(0,Y.jsx)(FT,{...e})}),(0,Y.jsx)(wt,{path:`/library/scenarios`,element:(0,Y.jsx)(MT,{...e})}),(0,Y.jsx)(wt,{path:`/library/scenarios/:id`,element:(0,Y.jsx)(NT,{...e})}),(0,Y.jsx)(wt,{path:`/library/datasets`,element:(0,Y.jsx)(RC,{...e})}),(0,Y.jsx)(wt,{path:`/library/datasets/:id`,element:(0,Y.jsx)(IT,{...e})}),(0,Y.jsx)(wt,{path:`*`,element:(0,Y.jsx)(Ct,{to:`/scoreboard`,replace:!0})})]})}function MT(e){let[t]=bn(),n=t.get(`suite`)??void 0;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(CC,{section:`scenarios`}),(0,Y.jsx)(Rw,{...e,selectedSuiteId:n},n)]})}function NT(e){let{id:t=``}=tt();return(0,Y.jsx)(Mw,{...e,evalId:t})}function PT(e){let{id:t=``}=tt();return(0,Y.jsx)(jC,{...e,agentKey:t})}function FT(e){let{id:t=``}=tt();return(0,Y.jsx)(IC,{...e,judgeKey:t})}function IT(e){let{id:t=``}=tt();return(0,Y.jsx)(zC,{...e,datasetId:t})}function LT({catalog:e,suites:t,runs:n}){let[r,i]=bn();return(0,Y.jsx)(pw,{catalog:e,suites:t,runs:n,search:r,onSearchChange:e=>i(e,{replace:!0})})}function RT({workspaces:e=!1,...t}){let[n,r]=bn();return(0,Y.jsx)(AT,{...t,workspaces:e,search:n,onSearchChange:e=>r(e,{replace:!0})})}function zT(e){let{runId:t=``}=tt();return(0,Y.jsx)(vw,{...e,runId:t})}function BT({workspace:e=!1,...t}){let{runId:n=``,trialId:r=``}=tt();return(0,Y.jsx)(DT,{...t,runId:n,trialId:r,workspace:e})}var VT=(0,_.forwardRef)(function({href:e=`/`,...t},n){return(0,Y.jsx)(mn,{ref:n,to:e,...t})}),HT=e=>t=>t===e||t.startsWith(`${e}/`),UT=[{label:`Evals`,sections:[{label:`Scoreboard`,href:`/scoreboard`,icon:up,matches:e=>e===`/`||HT(`/scoreboard`)(e)},{label:`Runs`,href:`/runs`,icon:Uf,matches:e=>HT(`/runs`)(e)&&!/\/trials\//.test(e)},{label:`Trials`,href:`/trials`,icon:rp,matches:e=>HT(`/trials`)(e)||/^\/runs\/[^/]+\/trials\//.test(e)&&!e.endsWith(`/workspace`)},{label:`Workspaces`,href:`/workspaces`,icon:Yf,matches:e=>HT(`/workspaces`)(e)||e.endsWith(`/workspace`)}]},{label:`Library`,sections:[{label:`Agents`,href:`/library/agents`,icon:sp,matches:HT(`/library/agents`)},{label:`Judges`,href:`/library/judges`,icon:Qf,matches:HT(`/library/judges`)},{label:`Scenarios`,href:`/library/scenarios`,icon:Vf,matches:HT(`/library/scenarios`)},{label:`Datasets`,href:`/library/datasets`,icon:Gf,matches:HT(`/library/datasets`)}]}],WT=new Set([`/runs`,`/trials`,`/workspaces`]),GT=UT.flatMap(e=>e.sections);function KT(e){return GT.find(t=>t.matches(e))??GT[0]}function qT(e){return/^\/runs\/[^/]+\/trials\/[^/]+\/workspace$/.test(e)?`Candidate workspace`:/^\/runs\/[^/]+\/trials\//.test(e)?`Trial`:e.startsWith(`/runs/`)?`Run`:KT(e).label}function JT({project:e}){if(!e)return(0,Y.jsx)(`span`,{className:`truncate text-sm font-semibold text-kumo-strong`,children:`EvalKit`});let t=e.repo.split(`/`).slice(1).join(`/`)||e.repo;return(0,Y.jsxs)(`span`,{className:`project-label flex min-w-0 flex-col leading-tight`,title:`${e.repo}${e.project?`/${e.project}`:``} at ${e.commit}${e.ref?` (${e.ref})`:``}${e.dirty?`, with uncommitted changes`:``}`,children:[(0,Y.jsxs)(`span`,{className:`truncate text-sm font-semibold text-kumo-strong`,children:[t,(0,Y.jsxs)(`span`,{className:`font-mono font-normal text-kumo-subtle`,children:[`#`,e.commit.slice(0,7)]})]}),(0,Y.jsx)(`span`,{className:`truncate text-xs text-kumo-subtle`,children:[e.project,e.ref,e.dirty?`dirty`:void 0].filter(Boolean).join(` · `)})]})}function YT({children:e,header:t,project:n}){let{pathname:r,search:i}=Xe(),a=KT(r),o=e=>WT.has(r)&&WT.has(e.href)?`${e.href}${i}`:e.href;return(0,Y.jsx)(Ar,{component:VT,children:(0,Y.jsxs)(xS.Provider,{collapsible:`icon`,defaultWidth:208,className:`h-dvh`,children:[(0,Y.jsxs)(xS,{id:`dashboard-navigation`,children:[(0,Y.jsxs)(xS.Header,{className:`justify-between`,children:[(0,Y.jsx)(mn,{to:`/scoreboard`,className:`min-w-0 group-data-[state=collapsed]/sidebar:hidden`,children:(0,Y.jsx)(JT,{project:n})}),(0,Y.jsx)(xS.Trigger,{className:`navigation-toggle`})]}),(0,Y.jsx)(xS.Content,{children:(0,Y.jsx)(`nav`,{"aria-label":`Dashboard`,children:UT.map((e,t)=>(0,Y.jsxs)(xS.Group,{children:[(0,Y.jsx)(xS.GroupLabel,{children:e.label}),(0,Y.jsx)(xS.Menu,{children:e.sections.map(e=>(0,Y.jsx)(xS.MenuButton,{href:o(e),icon:e.icon,active:e===a,"aria-current":e===a?`page`:void 0,tooltip:e.label,children:e.label},e.href))})]},e.label??t))})})]}),(0,Y.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col overflow-y-auto`,children:[(0,Y.jsxs)(`header`,{className:`sticky top-0 z-10 flex h-12 shrink-0 items-center gap-2 border-b border-kumo-line bg-kumo-base px-4 md:px-6`,children:[(0,Y.jsx)(xS.Trigger,{className:`md:hidden`}),(0,Y.jsx)(`h1`,{className:`text-base font-semibold text-kumo-strong`,children:qT(r)}),t]}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-4 px-4 py-4 md:px-6`,children:e})]})]})})}function XT({share:e}){let[t,n]=(0,_.useState)(),[r,i]=(0,_.useState)();return(0,_.useEffect)(()=>{fetch(e.repos).then(e=>e.json()).then(e=>n(e.repos)).catch(()=>i(`Unable to load repositories`))},[e.repos]),(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-4 px-4 py-8`,children:[(0,Y.jsx)(`h1`,{className:`text-base font-semibold text-kumo-strong`,children:`EvalKit · Shared evals`}),e.missing||e.repo&&!e.data?(0,Y.jsx)(AS,{message:e.missing?`No shared results for ${e.missing} in ${e.repo}.`:`No shared results for ${e.repo}.`}):null,r?(0,Y.jsx)(AS,{message:r}):null,t&&!t.length?(0,Y.jsx)(BS,{message:"Nothing shared yet. Run `evalkit share` in an eval project."}):null,t?.length?(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Repository`}),(0,Y.jsx)($.Head,{children:`Commits`}),(0,Y.jsx)($.Head,{children:`Last upload`})]})}),(0,Y.jsx)($.Body,{children:t.map(e=>(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(`a`,{className:OS,href:`/${e.key}`,children:e.key})}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:e.commits}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:e.lastUploadAt.slice(0,16).replace(`T`,` `)})]},e.key))})]}):null]})}function ZT(e=document.documentElement){let t=e.dataset.evalkitShare;if(!t)return;let n;try{n=JSON.parse(t)}catch{return}if(typeof n?.repos!=`string`)return;let r=e=>typeof n[e]==`string`?{[e]:n[e]}:{};return{repos:n.repos,...r(`commits`),...r(`data`),...r(`repo`),...r(`missing`)}}function QT(e,t,n,r){let i=/^\/(runs|trials|workspaces)\/./.test(n);return`/${e}/-/${t}${i?`/runs`:n===`/`?`/`:n}${i?``:r}`}function $T(e){let t=(e.committedAt??e.firstSeenAt).slice(0,10),n=e.runs?`${e.passed}/${e.runs} passed`:`no committed runs`;return[e.commit.slice(0,7),e.ref,t,n].filter(Boolean).join(` · `)}function eE({repo:e,current:t,commitsUrl:n}){let r=Xe(),[i,a]=(0,_.useState)();(0,_.useEffect)(()=>{let e=!0;return fetch(n).then(e=>e.json()).then(t=>{e&&a(t.commits)}).catch(()=>{e&&a([])}),()=>{e=!1}},[n]);let o=i?.some(e=>e.commit===t);return(0,Y.jsxs)(`label`,{className:`version-picker ml-auto flex min-w-0 items-center gap-2 text-[13px] text-kumo-subtle`,children:[(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:`Version`}),(0,Y.jsxs)(`select`,{"aria-label":`Version`,className:`max-w-[22rem] min-w-0 truncate rounded-md border border-kumo-line bg-kumo-base px-2 py-1 font-mono text-xs text-kumo-strong`,value:t,onChange:t=>window.location.assign(QT(e,t.target.value,r.pathname,r.search)),children:[o?null:(0,Y.jsx)(`option`,{value:t,children:t.slice(0,7)}),i?.map(e=>(0,Y.jsx)(`option`,{value:e.commit,children:$T(e)},e.commit))]})]})}function tE({api:e,basename:t,share:n}){return n&&!n.data?(0,Y.jsx)(XT,{share:n}):(0,Y.jsx)(pn,{basename:t,children:(0,Y.jsx)(nE,{api:e,share:n,basename:t})})}function nE({api:e,share:t,basename:n}){let r=n?.split(`/-/`)[1],[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(),[u,d]=(0,_.useState)([]),f=(0,_.useRef)(``),[p,m]=(0,_.useState)(),[h,g]=(0,_.useState)([]),[v,y]=(0,_.useState)(()=>rE(t,r));return(0,_.useEffect)(()=>{let n=!0;return Promise.all([e.listCatalog(),e.listSuites(),e.getMatrix(),e.listLoadErrors?.()??[],t?null:e.getProject?.().catch(()=>null)??null]).then(([e,r,i,o,c])=>{n&&(t||y(c),a(e),g(o),s(r),l(i))}).catch(e=>{n&&m(e instanceof Error?e.message:`Unable to load dashboard`)}),()=>{n=!1}},[e]),(0,_.useEffect)(()=>{let t=!0,n=!1,r=async()=>{if(!n){n=!0;try{let n=await e.listRuns();if(t){let e=JSON.stringify(n);e!==f.current&&(f.current=e,d(n))}}catch(e){t&&m(e instanceof Error?e.message:`Unable to load runs`)}finally{n=!1}}};r();let i=setInterval(()=>void r(),2e3);return()=>{t=!1,clearInterval(i)}},[e]),(0,Y.jsxs)(YT,{project:v,header:t?.repo&&t.commits&&r?(0,Y.jsx)(eE,{repo:t.repo,current:r,commitsUrl:t.commits}):void 0,children:[t?.repo?(0,Y.jsxs)(`p`,{className:`text-[13px] text-kumo-subtle`,role:`note`,children:[`Shared results for`,` `,(0,Y.jsx)(`a`,{href:`/${t.repo}`,className:`font-mono`,children:t.repo}),`. Runs cannot be started here.`]}):e.readOnly?(0,Y.jsxs)(`p`,{className:`text-[13px] text-kumo-subtle`,role:`note`,children:[`Read-only snapshot built with `,(0,Y.jsx)(`code`,{children:`evalkit build`}),`. Runs cannot be started here.`]}):null,p?(0,Y.jsx)(AS,{message:p}):null,h.length?(0,Y.jsx)(AS,{title:`${h.length===1?`1 scenario file`:`${h.length} scenario files`} failed to load; their scenarios are missing`,message:h.map(e=>`${e.file}: ${e.error.message}`).join(`
|
|
34
|
-
`)}):null,(0,Y.jsx)(
|
|
31
|
+
`),children:n.join(` · `)}):(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:`—`})}function uC({run:e,name:t}){let n=Object.hasOwn(e.parameters??{},t),r=n?oC(e.parameters?.[t]):`—`;return(0,Y.jsx)(`span`,{className:`${kS} block max-w-[10rem] truncate`,title:n?r:`Not set on this run`,children:r})}function dC(e,t=Date.now()){let n=Math.round((t-Date.parse(e))/1e3);return Number.isFinite(n)?n<45?`just now`:n<3600?`${Math.round(n/60)} min ago`:n<86400?`${Math.round(n/3600)} h ago`:n<604800?`${Math.round(n/86400)} d ago`:new Date(e).toLocaleDateString():e}function fC(e){return e===void 0?`—`:Number.isInteger(e)?String(e):e.toFixed(2)}function pC(e){if(e!==void 0)return e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`}function mC(e,t){if(t===`ms`)return pC(e);let n=Math.abs(e)>=1e4?new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(e):Number.isInteger(e)?e.toLocaleString(`en`):e.toFixed(e<10?2:1);return t&&t!==`tokens`?`${n} ${t}`:n}function hC({run:e}){return(0,Y.jsxs)(`span`,{className:`flex flex-col tabular-nums`,children:[(0,Y.jsx)(`span`,{children:fC(e.score)}),(0,Y.jsxs)(`span`,{className:`text-xs text-kumo-subtle`,children:[e.completedTrials,`/`,e.requestedTrials,` trials`]})]})}function gC({run:e}){let t=pC(e.durationMs);return(0,Y.jsxs)(`span`,{className:`flex flex-col tabular-nums`,title:new Date(e.startedAt).toLocaleString(),children:[(0,Y.jsx)(`span`,{children:dC(e.startedAt)}),t?(0,Y.jsxs)(`span`,{className:`text-xs text-kumo-subtle`,children:[`took `,t]}):null]})}var _C={className:`row-link cursor-pointer hover:bg-kumo-tint`,onClick(e){if(e.target.closest(`a, button, input, select, label, textarea`)||window.getSelection()?.toString())return;let t=e.currentTarget.querySelector(`a[data-row-link]`);t&&(e.metaKey||e.ctrlKey||e.button===1?window.open(t.href,`_blank`,`noopener`):t.click())}},vC={passed:`bg-kumo-success`,failed:`bg-kumo-danger`,errored:`bg-kumo-warning`,running:`bg-kumo-info animate-pulse`,cancelled:`bg-kumo-neutral-450`,"not-run":`border border-dashed border-kumo-line bg-transparent`},yC={passed:`bg-kumo-success-tint`,failed:`bg-kumo-danger-tint`,errored:`bg-kumo-warning-tint`,running:`bg-kumo-info-tint`,cancelled:`bg-kumo-tint`,"not-run":``},bC={passed:`passed`,failed:`failed`,errored:`errored`,running:`running`,cancelled:`cancelled`,"not-run":`not run`},xC={failed:0,errored:1,running:2,cancelled:3,"not-run":4,passed:5};function SC(e){return e===void 0?`text-kumo-subtle`:e>=.9?`bg-kumo-success-tint`:e>=.5?`bg-kumo-warning-tint`:`bg-kumo-danger-tint`}var CC={agents:`Agents`,judges:`Judges`,scenarios:`Scenarios`,datasets:`Datasets`};function wC({section:e,current:t}){return(0,Y.jsx)(`div`,{className:`shrink-0`,children:(0,Y.jsxs)(Pb,{size:`sm`,className:`hierarchy-breadcrumbs`,children:[(0,Y.jsx)(Pb.Current,{children:`Library`}),(0,Y.jsx)(Pb.Separator,{}),t?(0,Y.jsx)(Pb.Link,{href:QS(e),children:CC[e]}):(0,Y.jsx)(Pb.Current,{children:CC[e]}),t?(0,Y.jsx)(Pb.Separator,{}):null,t?(0,Y.jsx)(Pb.Current,{children:t}):null]})})}function TC({at:e}){return e?(0,Y.jsx)(`span`,{className:`${kS} text-kumo-subtle`,title:`Where this is defined`,children:e}):(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:`—`})}function EC({children:e}){return(0,Y.jsx)(`span`,{className:`rounded border border-kumo-line px-1.5 py-0.5 text-xs`,children:e})}function DC({title:e,children:t}){return(0,Y.jsxs)($_,{className:`flex max-w-3xl flex-col gap-3 p-4`,children:[e?(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:e}):null,t]})}function OC({scenarios:e,runs:t,note:n}){let r=KS(t);return(0,Y.jsxs)(`section`,{"aria-label":`Used by`,className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:[`Used by`,` `,(0,Y.jsx)(`span`,{className:`font-normal text-kumo-subtle tabular-nums`,children:e.length}),n?(0,Y.jsx)(`span`,{className:`ml-2 text-xs font-normal text-kumo-subtle`,children:n}):null]}),(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Scenario`}),(0,Y.jsx)($.Head,{children:`Suite`}),(0,Y.jsx)($.Head,{children:`How`}),(0,Y.jsx)($.Head,{children:`Latest run`})]})}),(0,Y.jsxs)($.Body,{children:[e.map(({scenario:e,note:t},n)=>{let i=r.get(e.id);return(0,Y.jsxs)($.Row,{..._C,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(mn,{to:tC(e.id),"data-row-link":!0,className:OS,children:e.name??e.id})}),(0,Y.jsx)($.Cell,{children:e.suiteId??`—`}),(0,Y.jsx)($.Cell,{className:`text-kumo-subtle`,children:t??`—`}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(kC,{run:i})})]},`${e.id}-${n}`)}),e.length?null:(0,Y.jsx)(DS,{colSpan:4,children:`No scenario uses it.`})]})]})]})}function kC({run:e}){return e?(0,Y.jsxs)(mn,{to:YS(e.id),className:`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs ${yC[e.status]}`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-2 rounded-full ${vC[e.status]}`}),bC[e.status],(0,Y.jsx)(`span`,{className:`tabular-nums text-kumo-subtle`,children:fC(e.score)})]}):(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:`not run`})}function AC(e){return(0,Y.jsx)(`span`,{className:`flex flex-wrap gap-1`,children:e.runtimes.map(e=>(0,Y.jsxs)(EC,{children:[e.name,` `,(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[`(`,e.kind,`)`]})]},e.name))})}function jC({catalog:e}){let t=US(e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(wC,{section:`agents`}),t.length?(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Agent`}),(0,Y.jsx)($.Head,{children:`Kind`}),(0,Y.jsx)($.Head,{children:`Runtimes`}),(0,Y.jsx)($.Head,{children:`Scenarios`}),(0,Y.jsx)($.Head,{children:`Defined in`})]})}),(0,Y.jsx)($.Body,{children:t.map(({key:e,agent:t,scenarios:n,judging:r})=>(0,Y.jsxs)($.Row,{..._C,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(`span`,{className:`flex flex-col`,children:[(0,Y.jsx)(mn,{to:$S(e),"data-row-link":!0,className:OS,children:t.name??e}),t.name?(0,Y.jsx)(`span`,{className:`${kS} text-kumo-subtle`,children:e}):null]})}),(0,Y.jsx)($.Cell,{children:t.kind}),(0,Y.jsx)($.Cell,{children:AC(t)}),(0,Y.jsxs)($.Cell,{className:`tabular-nums`,children:[n.length,r.length?(0,Y.jsxs)(`span`,{className:`ml-1 text-xs text-kumo-subtle`,children:[`+ judges `,r.length]}):null]}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(TC,{at:t.definedAt})})]},e))})]}):(0,Y.jsx)(BS,{message:`No agents yet. Define one with defineAgent in agents/.`})]})}function MC({catalog:e,runs:t,agentKey:n}){let r=US(e).find(e=>e.key===n);if(!r)return(0,Y.jsx)(BS,{message:`Agent not found: ${n}`});let{agent:i,scenarios:a,judging:o}=r;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(wC,{section:`agents`,current:i.name??n}),(0,Y.jsx)(iC,{title:i.name??n,subtitle:n}),(0,Y.jsx)(DC,{children:(0,Y.jsx)(zS,{items:[[`ID`,(0,Y.jsx)(`span`,{className:kS,children:i.id??`—`},`id`)],[`Kind`,i.kind],...i.version?[[`Version`,i.version]]:[],[`Runtimes`,AC(i)],[`Defined in`,(0,Y.jsx)(TC,{at:i.definedAt},`at`)]]})}),(0,Y.jsx)(OC,{runs:t,scenarios:[...a.map(e=>({scenario:e,note:`agent under test`})),...o.map(e=>({scenario:e,note:`judge agent`}))]})]})}function NC({scorer:e}){return(0,Y.jsx)(Er,{variant:e.kind===`judge`?`beta`:`neutral`,children:e.kind===`judge`?`LLM judge`:`predicate`})}function PC(e){return e.kind===`judge`?`its verdict`:e.passAt===void 0?`only 1`:`≥ ${e.passAt}`}function FC(e){return e.placement===`final`?`final scoring`:`checkpoint after step ${(e.step??0)+1}`}function IC({catalog:e}){let t=WS(e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(wC,{section:`judges`}),t.length?(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Judge`}),(0,Y.jsx)($.Head,{children:`Kind`}),(0,Y.jsx)($.Head,{children:`Passes at`}),(0,Y.jsx)($.Head,{children:`Scenarios`}),(0,Y.jsx)($.Head,{children:`Defined in`})]})}),(0,Y.jsx)($.Body,{children:t.map(({key:e,scorer:t,uses:n})=>(0,Y.jsxs)($.Row,{..._C,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(mn,{to:eC(e),"data-row-link":!0,className:OS,children:t.name})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(NC,{scorer:t})}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:PC(t)}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:new Set(n.map(e=>e.scenario.id)).size}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(TC,{at:t.definedAt})})]},e))})]}):(0,Y.jsx)(BS,{message:`No judges yet. Add predicates or judges in judges/.`})]})}function LC({catalog:e,runs:t,judgeKey:n}){let r=WS(e).find(e=>e.key===n);if(!r)return(0,Y.jsx)(BS,{message:`Judge not found: ${n}`});let{scorer:i,uses:a}=r;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(wC,{section:`judges`,current:i.name}),(0,Y.jsx)(iC,{title:i.name,status:(0,Y.jsx)(NC,{scorer:i})}),(0,Y.jsxs)(DC,{children:[(0,Y.jsx)(zS,{items:[[`Kind`,i.kind===`judge`?`LLM judge: the scenario’s judge agent grades the trial against the rubric`:`Predicate: a function scores the trial from 0 to 1`],[`Passes at`,PC(i)],[`Partial trials`,i.supportsPartial?`Also scores trials that stopped early or failed`:`Only scores trials that ran to the end`],[`Defined in`,(0,Y.jsx)(TC,{at:i.definedAt},`at`)]]}),i.rubric?(0,Y.jsxs)(`figure`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`figcaption`,{className:`text-xs font-medium text-kumo-subtle`,children:`Rubric`}),(0,Y.jsx)(`blockquote`,{className:`rounded-md border-l-2 border-kumo-brand bg-kumo-elevated px-3 py-2 text-[13px] whitespace-pre-wrap`,children:i.rubric})]}):null]}),(0,Y.jsx)(OC,{runs:t,scenarios:a.map(e=>({scenario:e.scenario,note:FC(e)}))})]})}function RC(e){if(e.source===`computed`)return e.hooks?.onRun?`built by onLoad, adapted per trial by onRun`:`built by onLoad`;let t=[];return e.files&&t.push(`directory`in e.files?`files from ${e.files.directory}/`:`${e.files.paths.length} inline files`),e.value&&t.push(`file`in e.value?`value from ${e.value.file}`:`an inline value`),t.join(` and `)||`—`}function zC({catalog:e}){let t=GS(e);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(wC,{section:`datasets`}),t.length?(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Dataset`}),(0,Y.jsx)($.Head,{children:`Kind`}),(0,Y.jsx)($.Head,{children:`Visible to`}),(0,Y.jsx)($.Head,{children:`Contents`}),(0,Y.jsx)($.Head,{children:`Scenarios`}),(0,Y.jsx)($.Head,{children:`Defined in`})]})}),(0,Y.jsx)($.Body,{children:t.map(({dataset:e,scenarios:t})=>(0,Y.jsxs)($.Row,{..._C,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(`span`,{className:`flex flex-col`,children:[(0,Y.jsx)(mn,{to:nC(e.id),"data-row-link":!0,className:OS,children:e.name??e.id}),e.name?(0,Y.jsx)(`span`,{className:`${kS} text-kumo-subtle`,children:e.id}):null]})}),(0,Y.jsx)($.Cell,{children:e.source}),(0,Y.jsx)($.Cell,{children:e.visibility===`candidate`?`agent and scorers`:`scorers only`}),(0,Y.jsx)($.Cell,{className:`max-w-[20rem] truncate`,children:RC(e)}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:t.length}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(TC,{at:e.definedAt})})]},e.id))})]}):(0,Y.jsx)(BS,{message:`No scenario uses a dataset yet. Define one with defineDataset in datasets/.`})]})}function BC({api:e,catalog:t,runs:n,datasetId:r}){let i=GS(t).find(e=>e.dataset.id===r);if(!i)return(0,Y.jsx)(BS,{message:`Dataset not found: ${r}`});let{dataset:a,scenarios:o}=i,s=a.files,c=a.value;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(wC,{section:`datasets`,current:a.name??a.id}),(0,Y.jsx)(iC,{title:a.name??a.id,subtitle:a.id,status:(0,Y.jsx)(Er,{variant:`neutral`,children:a.source})}),(0,Y.jsx)(DC,{children:(0,Y.jsx)(zS,{items:[[`Kind`,a.source===`computed`?`Computed: onLoad builds it once per process and caches it`:`Static: declared in the definition`],...a.hooks?[[`Hooks`,(0,Y.jsxs)(`span`,{className:`flex gap-1`,children:[(0,Y.jsx)(EC,{children:`onLoad · once per process`}),a.hooks.onRun?(0,Y.jsx)(EC,{children:`onRun · once per trial`}):null]},`hooks`)]]:[],[`Visible to`,a.visibility===`candidate`?`The agent (in its workspace and context.data) and the scorers`:`Only the scorers; the agent never sees it`],[`Mounted at`,(0,Y.jsx)(`span`,{className:kS,children:a.mount===`.`?`workspace root`:`${a.mount}/`},`mount`)],[`Defined in`,(0,Y.jsx)(TC,{at:a.definedAt},`at`)]]})}),s||c?(0,Y.jsx)(DC,{title:`Contents`,children:(0,Y.jsx)(zS,{items:[...s?[[`Files`,`directory`in s?(0,Y.jsxs)(`span`,{children:[(0,Y.jsxs)(`span`,{className:kS,children:[s.directory,`/`]}),`, copied into each trial's workspace`]},`files`):`${s.paths.length} declared inline, written into each trial's workspace`]]:[],...c?[[`Value`,`file`in c?(0,Y.jsx)(`span`,{className:kS,children:c.file},`value`):(0,Y.jsx)(`span`,{children:c.shape.type===`array`?`array of ${c.shape.items} items`:c.shape.type===`object`?(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1`,children:[`object with`,c.shape.keys.map(e=>(0,Y.jsx)(EC,{children:(0,Y.jsx)(`span`,{className:kS,children:e})},e))]}):c.shape.type},`value`)]]:[]]})}):null,(0,Y.jsx)(RS,{api:e,datasetId:a.id,mount:a.mount,evaluatorOnly:a.visibility===`evaluator`}),(0,Y.jsx)(OC,{runs:n,scenarios:o.map(e=>({scenario:e}))})]})}function VC({label:e,noun:t,page:n,pageSize:r,total:i,onPage:a}){if(i<=r)return null;let o=n*r+1,s=Math.min((n+1)*r,i);return(0,Y.jsx)(`nav`,{className:`pager flex items-center justify-end`,"aria-label":e,children:(0,Y.jsxs)(Cy,{page:n+1,setPage:e=>a(e-1),perPage:r,totalCount:i,children:[(0,Y.jsx)(Cy.Info,{children:()=>(0,Y.jsxs)(`span`,{className:`text-xs text-kumo-subtle tabular-nums`,children:[t,` `,o,`–`,s,` of `,i]})}),(0,Y.jsx)(Cy.Controls,{})]})})}function HC(e,t,n){let r=t.trim().toLowerCase();return r?e.flatMap(e=>{if(e.label.toLowerCase().includes(r))return[e];let t=e.values.filter(t=>t.label.toLowerCase().includes(r)||n.getAll(e.key).includes(t.key));return t.length?[{...e,values:t}]:[]}):[...e]}var UC=(e,...t)=>!e||t.some(t=>t.includes(e));function WC({facets:e,search:t,archivedCount:n=0,onToggleFacet:r,onField:i,onClear:a}){let[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(``),u=c.trim().toLowerCase(),d=HC(e,c,t).filter(e=>e.values.length>1||t.has(e.key)),f=UC(u,`date`,`from`,`to`,`started`),p=n>0&&UC(u,`archived`,`removed`),m=[...t.keys()].filter(e=>e!==`q`).length,h=GC(e,t);return(0,Y.jsxs)(`section`,{"aria-label":`Run filters`,className:`runs-filter-panel rounded-lg border border-kumo-line bg-kumo-base`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-1.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":o,className:`flex shrink-0 cursor-pointer items-center gap-1.5 text-[13px] font-semibold text-kumo-strong select-none`,onClick:()=>s(e=>!e),children:[(0,Y.jsx)(Rf,{"aria-hidden":!0,className:`size-3 text-kumo-subtle transition-transform ${o?`rotate-90`:``}`}),(0,Y.jsx)(Xf,{"aria-hidden":!0,className:`size-3.5 text-kumo-subtle`}),`Filters`,m?` (${m} active)`:``]}),h.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`active-filter inline-flex max-w-[16rem] cursor-pointer items-center gap-1 rounded-full border border-kumo-line bg-kumo-elevated px-2 py-0.5 text-xs`,title:`Remove ${e.label}: ${e.choice}`,onClick:()=>e.facet?r(e.field,e.value):i(e.field,``),children:[(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[e.label,`:`]}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.choice}),(0,Y.jsx)(mp,{"aria-hidden":!0,className:`size-3 shrink-0 text-kumo-subtle`})]},`${e.field}=${e.value}`)),(0,Y.jsx)(kp,{size:`xs`,variant:`ghost`,shape:`square`,className:`clear-filters ml-auto shrink-0`,icon:(0,Y.jsx)(Zf,{}),"aria-label":`Clear filters`,title:`Clear filters`,disabled:!m,onClick:a})]}),o?(0,Y.jsxs)(`div`,{className:`flex max-h-[min(32rem,60vh)] flex-col gap-3 overflow-y-auto border-t border-kumo-hairline px-3 py-3`,children:[(0,Y.jsx)(Th,{type:`search`,size:`xs`,"aria-label":`Search filters`,placeholder:`Search filters`,value:c,className:`max-w-xs`,onChange:e=>l(e.target.value)}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(12rem,1fr))] gap-x-6 gap-y-4`,children:[d.map(e=>(0,Y.jsx)(qC,{facet:e,checked:t.getAll(e.key),searching:u.length>0,onToggle:t=>r(e.key,t)},e.key)),f?(0,Y.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsx)(`legend`,{className:`mb-1 text-xs font-medium text-kumo-subtle`,children:`Started`}),(0,Y.jsx)(Th,{type:`date`,size:`xs`,label:`From`,value:t.get(`from`)??``,onChange:e=>i(`from`,e.target.value)}),(0,Y.jsx)(Th,{type:`date`,size:`xs`,label:`To`,value:t.get(`to`)??``,onChange:e=>i(`to`,e.target.value)})]}):null,p?(0,Y.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Y.jsx)(`legend`,{className:`mb-1 text-xs font-medium text-kumo-subtle`,children:`Archived`}),(0,Y.jsx)(lh,{className:`runs-choice min-w-0`,checked:t.get(`archived`)===`show`,onCheckedChange:e=>i(`archived`,e?`show`:``),label:(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline justify-between gap-2 text-[13px]`,children:[(0,Y.jsx)(`span`,{children:`Show archived`}),(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle tabular-nums`,children:n})]})})]}):null]}),!d.length&&!f&&!p?(0,Y.jsxs)(`p`,{className:`text-[13px] text-kumo-subtle`,children:[`No filters match “`,c,`”.`]}):null]}):null]})}function GC(e,t){let n={from:`From`,to:`To`,archived:`Archived`};return[...t.entries()].flatMap(([t,r])=>{if(t===`q`)return[];let i=e.find(e=>e.key===t);if(i){let e=i.values.find(e=>e.key===r);return[{field:t,value:r,label:i.label,choice:e?.label??r,facet:!0}]}return[{field:t,value:r,label:n[t]??t,choice:r,facet:!1}]})}function KC(e,t,n,r=``){let i=e.length>8,a=r.trim().toLowerCase(),o=a?e.filter(e=>e.label.toLowerCase().includes(a)||t.includes(e.key)):[...e];if(!i)return{choices:o,hidden:0};let s=o.sort((e,n)=>Number(t.includes(n.key))-Number(t.includes(e.key))||n.count-e.count||e.label.localeCompare(n.label,void 0,{numeric:!0}));if(n)return{choices:s,hidden:0};let c=[...s.filter(e=>t.includes(e.key)),...s.filter(e=>!t.includes(e.key)).slice(0,6)];return{choices:c,hidden:s.length-c.length}}function qC({facet:e,checked:t,searching:n,onToggle:r}){let[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(``),{choices:c,hidden:l}=KC(e.values,t,i||n,i?o:``);return(0,Y.jsxs)(`fieldset`,{className:`facet-group flex min-w-0 flex-col gap-1`,children:[(0,Y.jsxs)(`legend`,{className:`mb-1 flex w-full items-baseline justify-between gap-2 text-xs font-medium text-kumo-subtle`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.label}),(0,Y.jsx)(`span`,{className:`tabular-nums`,children:e.values.length})]}),i&&e.values.length>8?(0,Y.jsx)(Th,{type:`search`,size:`xs`,"aria-label":`Search ${e.label}`,placeholder:`Search ${e.values.length} values`,value:o,onChange:e=>s(e.target.value)}):null,(0,Y.jsxs)(`div`,{className:`flex max-h-56 flex-col gap-1 overflow-y-auto`,children:[c.map(e=>(0,Y.jsx)(lh,{className:`runs-choice min-w-0`,checked:t.includes(e.key),onCheckedChange:()=>r(e.key),label:(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline justify-between gap-2 text-[13px]`,title:e.label,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle tabular-nums`,children:e.count})]})},e.key)),c.length?null:(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:`No matches.`})]}),l>0||i?(0,Y.jsx)(`button`,{type:`button`,className:`facet-more self-start text-xs text-kumo-link hover:underline`,onClick:()=>{a(e=>!e),s(``)},children:i?`Show fewer`:`Show all ${e.values.length}`}):null]})}var JC=`@missing`,YC=e=>`p.${e}`;function XC(e,t,n){let r=e.get(t);r?r.count++:e.set(t,{key:t,label:n,count:1})}function ZC(e){return[{key:`eval`,label:`Scenario`},{key:`matrix`,label:`Matrix`},{key:`status`,label:`Status`},...[...new Set(e.flatMap(e=>Object.keys(e.parameters??{})))].sort().map(e=>({key:YC(e),label:e}))].map(({key:t,label:n})=>{let r=new Map;for(let n of e){let e=t===`eval`?n.evalId:t===`matrix`?n.matrixId:t===`status`?n.status:n.parameters?.[t.slice(2)],i=t===`eval`||t===`status`||(t===`matrix`?n.matrixId!==void 0:Object.hasOwn(n.parameters??{},t.slice(2)));XC(r,i?aC(e):JC,i?String(typeof e==`string`?e:JSON.stringify(e)):`Missing`)}return{key:t,label:n,values:[...r.values()].sort((e,t)=>e.label.localeCompare(t.label,void 0,{numeric:!0}))}})}function QC(e,t={}){let n=new URLSearchParams;n.append(`eval`,aC(e));for(let[e,r]of Object.entries(t))r!=null&&n.append(YC(e),aC(r));return`/runs?${n}`}function $C(e,t){let n=[...t.keys()].filter(e=>[`eval`,`matrix`,`status`].includes(e)||e.startsWith(`p.`)),r=t.get(`from`),i=t.get(`to`);return e.filter(e=>r&&e.startedAt.slice(0,10)<r||i&&e.startedAt.slice(0,10)>i?!1:n.every(n=>{let r=t.getAll(n),i=n===`eval`||n===`status`||(n===`matrix`?e.matrixId!==void 0:Object.hasOwn(e.parameters??{},n.slice(2))),a=n===`eval`?e.evalId:n===`matrix`?e.matrixId:n===`status`?e.status:e.parameters?.[n.slice(2)],o=i?aC(a):JC;return r.includes(o)}))}function ew({label:e,placeholder:t,value:n,count:r,onChange:i}){return(0,Y.jsxs)(`div`,{className:`search-field flex min-w-0 flex-wrap items-center gap-3`,children:[(0,Y.jsx)(Th,{type:`search`,size:`sm`,"aria-label":e,placeholder:t,value:n,className:`w-full sm:w-80`,onChange:e=>i(e.target.value)}),(0,Y.jsx)(`span`,{className:`search-count text-xs text-kumo-subtle tabular-nums`,children:r})]})}function tw(e,t){let[n,r]=(0,_.useState)(()=>new URLSearchParams),i=e??n,a=t??r,o=i.get(`q`)??``,[s,c]=(0,_.useState)(o);return(0,_.useEffect)(()=>c(o),[o]),(0,_.useEffect)(()=>{if(s===o)return;let e=setTimeout(()=>{let e=new URLSearchParams(i);s?e.set(`q`,s):e.delete(`q`),a(e)},250);return()=>clearTimeout(e)},[s,o,i,a]),{activeSearch:i,query:s,setQuery:c,setField:(e,t)=>{let n=new URLSearchParams(i);t?n.set(e,t):n.delete(e),a(n)},toggleFacet:(e,t)=>{let n=new URLSearchParams(i),r=n.getAll(e);n.delete(e);for(let i of r.filter(e=>e!==t))n.append(e,i);r.includes(t)||n.append(e,t),a(n)},clearFilters:()=>a(new URLSearchParams)}}function nw(e,t){let[n,r]=(0,_.useState)({}),i=t?`${t.id}:${t.status}:${t.completedTrials}:${t.completedAt??``}`:``;return(0,_.useEffect)(()=>{if(!t)return;let n=!0;return e.listTrials(t.id).then(e=>{n&&r({runId:t.id,trials:e})}).catch(e=>{n&&r({runId:t.id,error:e instanceof Error?e.message:`Unable to load trials`})}),()=>{n=!1}},[e,i]),n.runId===t?.id?n:{}}function rw(e,t,n,r){let i=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return i.length?e.filter(e=>{let t=r.find(t=>t.id===e.evalId),a=n.find(t=>t.id===e.suiteId),o=Object.entries(e.parameters??{}).flatMap(([e,t])=>[e,oC(t)]),s=[e.id,e.evalId,t?.name,e.suiteId,a?.name,e.matrixId,t?.agent.name,t?.agent.kind,e.status,e.score,e.startedAt,e.source?.commit,e.source?.ref,e.source?.dirty?`dirty`:void 0,...o].map(oC).join(` `).toLowerCase();return i.every(e=>s.includes(e))}):[...e]}function iw({runs:e,catalog:t,suites:n,search:r,onSearchChange:i,trialStatus:a=!1}){let o=tw(r,i),{activeSearch:s,query:c}=o,l=s.get(`archived`)===`show`,u=e.filter(e=>e.archived).length,d=(0,_.useMemo)(()=>l?e:e.filter(e=>!e.archived),[e,l]),f=(0,_.useMemo)(()=>ZC(d),[d]),p=(0,_.useMemo)(()=>{if(!a)return s;let e=new URLSearchParams(s);return e.delete(`status`),e},[s,a]),m=(0,_.useMemo)(()=>rw($C(d,p),c,n,t),[d,p,c,n,t]),h=s.getAll(`status`);return{...o,listed:d,facets:f,filteredRuns:m,archivedCount:u,keepTrial:e=>!h.length||h.includes(aC(e.status))}}function aw(e,t){let n=new Map;for(let e of t)n.set(e.status,(n.get(e.status)??0)+1);return e.map(e=>e.key===`status`?{...e,label:`Trial status`,values:[...n].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:aC(e),label:e,count:t}))}:e)}function ow({selection:e,facets:t=e.facets,label:n,count:r}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ew,{label:n,placeholder:`Scenario, parameter, agent, commit or status`,value:e.query,count:r,onChange:e.setQuery}),(0,Y.jsx)(WC,{facets:t,search:e.activeSearch,archivedCount:e.archivedCount,onToggleFacet:e.toggleFacet,onField:e.setField,onClear:e.clearFilters})]})}function sw(e,t){let[n,r]=(0,_.useState)(e);return{sort:n,toggleSort:e=>{r(t=>t.key===e?{key:e,direction:t.direction===`asc`?`desc`:`asc`}:{key:e,direction:`asc`}),t?.()}}}function cw({label:e,sortKey:t,sort:n,onSort:r,sticky:i}){let a=n.key===t,o=a?n.direction===`asc`?`ascending`:`descending`:void 0,s=a?n.direction===`asc`?zf:If:Bf;return(0,Y.jsx)($.Head,{"aria-sort":o,sticky:i,children:(0,Y.jsxs)(`button`,{type:`button`,className:`table-sort inline-flex items-center gap-1 whitespace-nowrap rounded font-medium hover:text-kumo-strong focus-visible:outline-2 focus-visible:outline-kumo-brand`,onClick:()=>r(t),children:[e,(0,Y.jsx)(s,{"aria-hidden":!0,className:a?`size-3`:`size-3 text-kumo-inactive`})]})})}function lw(e,t,n){return(0,_.useMemo)(()=>{let r=[...e];return r.sort((e,r)=>{let i=n(e,t.key),a=n(r,t.key),o=typeof i==`number`&&typeof a==`number`?i-a:String(i??``).localeCompare(String(a??``),void 0,{numeric:!0,sensitivity:`base`});return t.direction===`asc`?o:-o}),r},[e,t,n])}var uw={passed:`success`,failed:`error`,errored:`warning`,error:`warning`};function dw({status:e}){return(0,Y.jsx)(`span`,{className:`inline-flex`,"data-status":e,children:(0,Y.jsx)(Er,{appearance:`dot`,variant:uw[e]??`neutral`,children:e})})}var fw=50,pw=6;function mw({runs:e,suites:t,catalog:n,search:r,onSearchChange:i}){let a=iw({runs:e,catalog:n,suites:t,search:r,onSearchChange:i}),{listed:o,filteredRuns:s,clearFilters:c}=a,l=sC(s),[u,d]=(0,_.useState)(0),{sort:f,toggleSort:p}=sw({key:`started`,direction:`desc`},()=>d(0)),m=e=>n.find(t=>t.id===e.evalId),h=e=>t.find(t=>t.id===e.suiteId)?.name,g=lw(s,f,(e,t)=>hw(e,t,m(e),h(e))),v=Math.max(1,Math.ceil(g.length/fw)),y=Math.min(u,v-1),b=g.slice(y*fw,(y+1)*fw),x=pw+l.columns.length+ +!!l.overflow.length,S=(e,t,n)=>(0,Y.jsx)(cw,{label:e,sortKey:t,sort:f,onSort:p,sticky:n});return e.length?(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsx)(ow,{selection:a,label:`Filter runs`,count:`${g.length} of ${o.length} runs`}),l.constant.length?(0,Y.jsxs)(`p`,{className:`constant-parameters flex flex-wrap items-center gap-1 text-[13px] text-kumo-subtle`,role:`note`,children:[`Same on every run shown:`,(0,Y.jsx)(cC,{entries:l.constant})]}):null,(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[S(`Run`,`run`,`left`),S(`Status`,`status`),S(`Scenario`,`eval`),S(`Score`,`score`),S(`Started`,`started`),S(`Commit`,`commit`),l.columns.map(e=>(0,Y.jsx)(cw,{label:e,sortKey:`param:${e}`,sort:f,onSort:p},e)),l.overflow.length?(0,Y.jsx)($.Head,{children:`Other parameters`}):null]})}),(0,Y.jsxs)($.Body,{children:[b.map(e=>(0,Y.jsx)(gw,{run:e,evaluation:m(e),suiteName:h(e),layout:l},e.id)),g.length?null:(0,Y.jsx)(DS,{colSpan:x,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[`No matching runs.`,(0,Y.jsx)(kp,{size:`xs`,variant:`ghost`,onClick:c,children:`Clear filters`})]})})]})]}),(0,Y.jsx)(VC,{label:`Run pages`,noun:`Runs`,page:y,pageSize:fw,total:g.length,onPage:d})]}):(0,Y.jsx)(BS,{message:`No runs yet. Open a scenario or suite to start one.`})}function hw(e,t,n,r){if(t.startsWith(`param:`)){let n=e.parameters?.[t.slice(6)];return n===void 0?void 0:typeof n==`number`?n:oC(n)}return{run:e.id,suite:r??e.suiteId,eval:n?.name??e.evalId,agent:n?.agent.name??n?.agent.kind??`Unnamed agent`,status:e.status,trials:e.completedTrials,score:e.score,runtime:e.durationMs,started:e.startedAt,commit:e.source?.commit}[t]}function gw({run:e,evaluation:t,suiteName:n,layout:r}){let i=t?.name??e.evalId,a=n??e.suiteId;return(0,Y.jsxs)($.Row,{..._C,children:[(0,Y.jsx)($.Cell,{sticky:`left`,children:(0,Y.jsx)(mn,{to:YS(e.id),"data-row-link":!0,className:`${OS} ${kS}`,title:e.id,children:e.id.slice(0,8)})}),(0,Y.jsx)($.Cell,{title:e.interrupted?`Its process stopped before the run finished`:void 0,children:(0,Y.jsx)(dw,{status:e.status})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(`span`,{className:`flex max-w-[14rem] flex-col`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(mn,{to:tC(e.evalId),className:`${OS} truncate font-medium`,title:i,children:i}),e.archived?(0,Y.jsx)(`span`,{className:`shrink-0 rounded border border-kumo-line px-1 text-[11px] text-kumo-subtle`,title:`This scenario is no longer in the project (evalkit tidy)`,children:`archived`}):null]}),a?(0,Y.jsx)(`span`,{className:`truncate text-xs text-kumo-subtle`,title:a,children:a}):null]})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(hC,{run:e})}),(0,Y.jsx)($.Cell,{className:`whitespace-nowrap`,children:(0,Y.jsx)(gC,{run:e})}),(0,Y.jsx)($.Cell,{className:`whitespace-nowrap`,children:(0,Y.jsx)(_w,{source:e.source})}),r.columns.map(t=>(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(uC,{run:e,name:t})},t)),r.overflow.length?(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(lC,{run:e,keys:r.overflow})}):null]})}function _w({source:e}){return e?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:[e.commit,e.ref&&`on ${e.ref}`,e.dirty&&`with uncommitted changes`].filter(Boolean).join(` `),children:[(0,Y.jsx)(`span`,{className:kS,children:e.commit.slice(0,7)}),e.dirty?(0,Y.jsx)(`span`,{className:`rounded border border-kumo-line px-1 text-[11px] text-kumo-subtle`,children:`dirty`}):null]}):(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:`—`})}function vw({run:e,trials:t}){let{sort:n,toggleSort:r}=sw({key:`index`,direction:`asc`}),i=(0,_.useMemo)(()=>[...new Set(t.flatMap(e=>(e.scores??[]).map(e=>e.name)))].sort(),[t]),a=lw(t,n,(e,t)=>t.startsWith(`score:`)?(e.scores??[]).find(e=>e.name===t.slice(6))?.value:{index:e.index,status:e.status,aggregate:e.score,runtime:e.durationMs,started:e.startedAt}[t]);return(0,Y.jsxs)(ES,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)(cw,{label:`Trial`,sortKey:`index`,sort:n,onSort:r}),(0,Y.jsx)(cw,{label:`Status`,sortKey:`status`,sort:n,onSort:r}),(0,Y.jsx)(cw,{label:`Aggregate`,sortKey:`aggregate`,sort:n,onSort:r}),i.map(e=>(0,Y.jsx)(cw,{label:e,sortKey:`score:${e}`,sort:n,onSort:r},e)),(0,Y.jsx)(cw,{label:`Runtime`,sortKey:`runtime`,sort:n,onSort:r}),(0,Y.jsx)(cw,{label:`Started`,sortKey:`started`,sort:n,onSort:r})]})}),(0,Y.jsxs)($.Body,{children:[a.map(t=>(0,Y.jsxs)($.Row,{..._C,children:[(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:(0,Y.jsxs)(mn,{to:XS(e.id,t.id),"data-row-link":!0,className:OS,title:t.id,children:[`Trial `,t.index+1]})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(dw,{status:t.status})}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:t.score??`—`}),i.map(e=>(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:(t.scores??[]).find(t=>t.name===e)?.value??`—`},e)),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:t.durationMs===void 0?`—`:`${t.durationMs}ms`}),(0,Y.jsx)($.Cell,{className:`whitespace-nowrap tabular-nums`,children:new Date(t.startedAt).toLocaleString()})]},t.id)),a.length?null:(0,Y.jsx)(DS,{colSpan:i.length+5,children:`No trials saved yet.`})]})]})}function yw({api:e,catalog:t,runs:n,runId:r}){let i=n.find(e=>e.id===r),{trials:a,error:o}=nw(e,i);if(!i)return(0,Y.jsx)(BS,{message:n.length?`Run not found: ${r}`:`Loading run…`});let s=t.find(e=>e.id===i.evalId),c=Object.entries(i.parameters??{});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(rC,{run:i}),(0,Y.jsx)(iC,{title:`Run ${i.id.slice(0,8)}`,subtitle:i.id,status:(0,Y.jsx)(`span`,{title:i.interrupted?`Its process stopped before the run finished`:void 0,children:(0,Y.jsx)(dw,{status:i.status})})}),(0,Y.jsx)(`div`,{className:`run-overview max-w-3xl`,children:(0,Y.jsx)(zS,{items:[[`Scenario`,(0,Y.jsx)(mn,{to:tC(i.evalId),className:OS,children:s?.name??i.evalId},`scenario`)],[`Agent`,s?HS(s):i.agent??`—`],[`Score`,i.score??`—`],[`Trials`,`${i.completedTrials} of ${i.requestedTrials}`],...c.length?[[`Parameters`,(0,Y.jsx)(`span`,{className:kS,children:c.map(([e,t])=>`${e}=${JSON.stringify(t)}`).join(` `)},`parameters`)]]:[],[`Started`,new Date(i.startedAt).toLocaleString()],[`Runtime`,i.durationMs===void 0?`—`:pC(i.durationMs)],...(i.metrics??[]).filter(e=>e.mean!==void 0).map(e=>[e.count>1?`Mean ${e.name}`:e.name,(0,Y.jsx)(`span`,{className:`tabular-nums`,children:mC(e.mean,e.unit)},e.name)]),[`Commit`,(0,Y.jsx)(_w,{source:i.source},`commit`)]]})}),o?(0,Y.jsx)(AS,{title:`Unable to load trials`,message:o}):null,(0,Y.jsxs)(`section`,{"aria-label":`Trials`,className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:`Trials`}),a?(0,Y.jsx)(vw,{run:i,trials:a}):o?null:(0,Y.jsx)(`output`,{className:`text-[13px] text-kumo-subtle`,children:`Loading trials…`})]})]})}var bw=[`agent time`,`tokens`,`tool calls`];function xw(e){let t=new Map;for(let n of e)for(let e of n.metrics??[])e.mean!==void 0&&!t.has(e.name)&&t.set(e.name,{name:e.name,...e.unit?{unit:e.unit}:{},...e.better?{better:e.better}:{}});let n=e=>{let t=bw.indexOf(e);return t===-1?bw.length:t};return[...t.values()].sort((e,t)=>n(e.name)-n(t.name)||e.name.localeCompare(t.name))}function Sw(e){let t=new Map;for(let n of e)for(let e of n.metrics??[]){if(e.mean===void 0||!e.count)continue;let n=t.get(e.name)??{sum:0,count:0};n.sum+=e.mean*e.count,n.count+=e.count,t.set(e.name,n)}return Object.fromEntries([...t].map(([e,{sum:t,count:n}])=>[e,t/n]))}function Cw(e,t,n){let r=(n,r)=>r?.suiteId??e.find(e=>e.id===n)?.suiteId??t.find(e=>e.evalIds.includes(n))?.id,i=new Map;for(let e of n){if(e.archived)continue;let t=ww(e.evalId,e.parameters??{});i.set(t,[...i.get(t)??[],e])}let a=[...i].map(([t,n])=>{let i=n.sort((e,t)=>t.startedAt.localeCompare(e.startedAt)).slice(0,10),a=i[0],o=i.filter(e=>[`passed`,`failed`,`errored`].includes(e.status)),s=o.filter(e=>e.score!==void 0);return{key:t,evalId:a.evalId,scenario:e.find(e=>e.id===a.evalId),suiteId:r(a.evalId,a),parameters:a.parameters??{},runs:i,outcome:a.status,metrics:Sw(o),...s.length?{meanScore:s.reduce((e,t)=>e+t.score,0)/s.length}:{},...o.length?{passRate:o.filter(e=>e.status===`passed`).length/o.length}:{}}});for(let t of e)a.some(e=>e.evalId===t.id)||a.push({key:ww(t.id,{}),evalId:t.id,scenario:t,suiteId:r(t.id),parameters:{},runs:[],outcome:`not-run`,metrics:{}});return a}function ww(e,t){return`${e}\0${aC(t)}`}function Tw({api:e,catalog:t,suites:n,runs:r}){let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(!0),{sort:c,toggleSort:l}=sw({key:``,direction:`asc`}),[u,d]=(0,_.useState)(),f=(0,_.useMemo)(()=>Cw(t,n,r),[t,n,r]),p=(0,_.useMemo)(()=>xw(r.filter(e=>!e.archived)),[r]);if(!f.length)return(0,Y.jsx)(BS,{message:`No scenarios yet. Add one in scenarios/.`});let m=i.trim().toLowerCase().split(/\s+/).filter(Boolean),h=f.filter(e=>{let t=[e.evalId,e.scenario?.name,e.suiteId,bC[e.outcome],...Object.entries(e.parameters).map(([e,t])=>`${e}=${JSON.stringify(t)}`)].join(` `).toLowerCase();return m.every(e=>t.includes(e))}).sort((e,t)=>Ow(e,t,c)||(o?xC[e.outcome]-xC[t.outcome]:0)||(e.scenario?.name??e.evalId).localeCompare(t.scenario?.name??t.evalId)||e.key.localeCompare(t.key)),g=new Map;for(let e of h){let t=e.suiteId??``;g.set(t,[...g.get(t)??[],e])}let v=kw(h,p),y=(e,t)=>(0,Y.jsx)(cw,{label:e,sortKey:t,sort:c,onSort:l}),b=e=>n.find(t=>t.id===e)?.name??e,x=t=>{t.scenario&&(d(void 0),e.runEval(t.scenario.path,Object.keys(t.parameters).length?t.parameters:void 0).catch(e=>d(e instanceof Error?e.message:`Unable to start scenario`)))};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Nw,{rows:f}),u?(0,Y.jsx)(AS,{message:u}):null,(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsx)(ew,{label:`Filter scoreboard`,placeholder:`Scenario, suite, parameter or outcome`,value:i,count:`${h.length} of ${f.length}`,onChange:a}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[13px] text-kumo-subtle`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Failures first`]})]}),(0,Y.jsxs)(TS,{className:`scoreboard`,children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Scenario`}),(0,Y.jsx)($.Head,{children:`Latest`}),y(`Score`,`score`),y(`Mean score`,`meanScore`),(0,Y.jsxs)($.Head,{children:[`Last `,10,` runs`]}),y(`Pass rate`,`passRate`),p.map(e=>(0,Y.jsx)(_.Fragment,{children:y(`Mean ${e.name}`,`metric:${e.name}`)},e.name)),(0,Y.jsx)($.Head,{className:`text-right`,children:e.readOnly?null:`Run`})]})}),(0,Y.jsx)($.Body,{children:[...g].map(([t,n])=>(0,Y.jsxs)(_.Fragment,{children:[g.size>1||t?(0,Y.jsx)($.Row,{className:`bg-kumo-elevated`,children:(0,Y.jsx)($.Cell,{colSpan:7+p.length,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-semibold text-kumo-strong`,children:t?b(t):`No suite`}),(0,Y.jsx)(Pw,{rows:n})]})})}):null,n.map(t=>(0,Y.jsx)(Ew,{row:t,columns:p,ranges:v,onRun:e.readOnly||!t.scenario?void 0:()=>x(t)},t.key))]},t))})]})]})}function Ew({row:e,columns:t,ranges:n,onRun:r}){let i=e.runs[0],a=Object.entries(e.parameters);return(0,Y.jsxs)($.Row,{"data-outcome":e.outcome,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(`span`,{className:`flex max-w-[22rem] flex-col gap-0.5`,children:[(0,Y.jsx)(mn,{to:tC(e.evalId),className:`${OS} truncate`,title:e.scenario?.name??e.evalId,children:e.scenario?.name??e.evalId}),a.length?(0,Y.jsx)(cC,{entries:a}):null]})}),(0,Y.jsx)($.Cell,{children:i?(0,Y.jsxs)(mn,{to:YS(i.id),className:`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium ${yC[e.outcome]}`,title:`Latest run ${i.id.slice(0,8)}, ${new Date(i.startedAt).toLocaleString()}`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-2 rounded-full ${vC[e.outcome]}`}),bC[e.outcome],(0,Y.jsx)(`span`,{className:`font-normal text-kumo-subtle`,children:dC(i.startedAt)})]}):(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:`not run`})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(`span`,{className:`inline-block min-w-10 rounded px-1.5 py-0.5 text-center tabular-nums ${i?yC[e.outcome]:``}`,children:fC(i?.score)})}),(0,Y.jsx)($.Cell,{children:e.meanScore===void 0?(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:`—`}):(0,Y.jsx)(`span`,{className:`inline-block min-w-10 rounded px-1.5 py-0.5 text-center tabular-nums ${SC(e.meanScore)}`,title:`Mean over the last 10 runs`,children:fC(e.meanScore)})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(jw,{runs:e.runs})}),(0,Y.jsx)($.Cell,{children:e.passRate===void 0?(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:`—`}):(0,Y.jsxs)(`span`,{className:`inline-block min-w-12 rounded px-1.5 py-0.5 text-center tabular-nums ${SC(e.passRate)}`,children:[Math.round(e.passRate*100),`%`]})}),t.map(t=>{let r=e.metrics[t.name];return(0,Y.jsx)($.Cell,{className:`text-right`,children:r===void 0?(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:`—`}):(0,Y.jsx)(`span`,{className:`inline-block rounded px-1.5 py-0.5 tabular-nums ${Aw(r,t,n.get(t.name))}`,title:`Mean ${t.name} over the last 10 runs`,children:mC(r,t.unit)})},t.name)}),(0,Y.jsx)($.Cell,{className:`text-right`,children:r?(0,Y.jsx)(kp,{size:`xs`,variant:`secondary`,shape:`square`,"aria-label":`Run ${e.scenario?.name??e.evalId}`,title:`Run again`,icon:(0,Y.jsx)(ap,{weight:`fill`}),onClick:r}):null})]})}function Dw(e,t){if(t===`score`)return e.runs[0]?.score;if(t===`meanScore`)return e.meanScore;if(t===`passRate`)return e.passRate;if(t.startsWith(`metric:`))return e.metrics[t.slice(7)]}function Ow(e,t,n){if(!n.key)return 0;let r=Dw(e,n.key),i=Dw(t,n.key);return r===void 0||i===void 0?r===i?0:r===void 0?1:-1:n.direction===`asc`?r-i:i-r}function kw(e,t){let n=new Map;for(let r of t){let t=e.map(e=>e.metrics[r.name]).filter(e=>e!==void 0);t.length&&n.set(r.name,{min:Math.min(...t),max:Math.max(...t)})}return n}function Aw(e,t,n){if(!t.better||!n||n.max===n.min)return``;let r=(e-n.min)/(n.max-n.min);return SC(t.better===`lower`?1-r:r)}function jw({runs:e}){let t=[...Array(Math.max(0,10-e.length)).fill(void 0),...[...e].reverse()];return(0,Y.jsx)(`span`,{className:`history inline-flex items-center gap-0.5`,children:t.map((e,t)=>e?(0,Y.jsx)(mn,{to:YS(e.id),className:`size-3.5 rounded-[3px] hover:ring-2 hover:ring-kumo-focus ${vC[e.status]}`,title:`${bC[e.status]} · score ${fC(e.score)} · ${new Date(e.startedAt).toLocaleString()}`,"aria-label":`${bC[e.status]} run ${e.id.slice(0,8)}`},e.id):(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-3.5 rounded-[3px] border border-dashed border-kumo-hairline`},`empty-${t}`))})}var Mw=[`passed`,`failed`,`errored`,`running`,`not-run`];function Nw({rows:e}){return(0,Y.jsx)(`div`,{className:`tally grid grid-cols-2 gap-2 sm:grid-cols-5`,children:Mw.map(t=>{let n=e.filter(e=>e.outcome===t).length;return(0,Y.jsxs)(`div`,{"data-outcome":t,className:`flex items-center gap-3 rounded-lg border border-kumo-line px-3 py-2 ${n?yC[t]:``}`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`size-3 rounded-full ${vC[t]}`}),(0,Y.jsx)(`span`,{className:`text-xl font-semibold text-kumo-strong tabular-nums`,children:n}),(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:bC[t]})]},t)})})}function Pw({rows:e}){let t=[...e].sort((e,t)=>xC[e.outcome]-xC[t.outcome]),n=e.filter(e=>e.outcome===`passed`).length;return(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`flex h-2 w-40 overflow-hidden rounded-full bg-kumo-fill`,children:t.map(e=>(0,Y.jsx)(`span`,{className:`h-full flex-1 ${vC[e.outcome]}`},e.key))}),(0,Y.jsxs)(`span`,{className:`${kS} text-kumo-subtle`,children:[n,`/`,e.length]})]})}var Fw=new Set([`passed`,`failed`,`errored`]),Iw=`\0all`;function Lw(e){return aC(e??null)}function Rw(e){let t=new Map;for(let n of e)for(let[e,r]of Object.entries(n.parameters??{}))t.set(e,(t.get(e)??new Set).add(Lw(r)));let n=t=>e.every(e=>e.parameters&&t in e.parameters);return[...t].filter(([e,t])=>t.size>1||!n(e)).map(([e])=>e).sort()}function zw(e){return[{id:`pass-rate`,label:`Pass rate`,measure:{kind:`pass-rate`}},{id:`score`,label:`Mean score`,measure:{kind:`score`}},...xw(e).map(e=>({id:`metric:${e.name}`,label:`Mean ${e.name}`,measure:{kind:`metric`,metric:e}}))]}function Bw(e,t,n,r,i={}){let a=new Map;for(let t of e){if(t.archived||!Fw.has(t.status))continue;let e=aC(t.parameters??{});a.set(e,[...a.get(e)??[],t])}let o=[...a.values()].flatMap(e=>e.sort((e,t)=>t.startedAt.localeCompare(e.startedAt)).slice(0,10)),s=Vw(o,t,i[t]),c=n?Vw(o,n,i[n]):[{key:Iw,label:``,value:void 0}],l=new Map;for(let e of o){let r=`${Lw(e.parameters?.[t])}\0${n?Lw(e.parameters?.[n]):Iw}`;l.set(r,[...l.get(r)??[],e])}let u={};for(let e of s){u[e.key]={};for(let t of c){let n=l.get(`${e.key}\0${t.key}`)??[],i=Hw(n,r);u[e.key][t.key]={runs:n.length,...i===void 0?{}:{value:i}}}}return{rows:s,columns:c,cells:u}}function Vw(e,t,n=[]){let r=new Map;for(let n of e){let e=n.parameters?.[t],i=Lw(e);r.has(i)||r.set(i,{key:i,label:e===void 0?`(not set)`:oC(e),value:e})}let i=e=>{let t=n.findIndex(t=>Lw(t)===e.key);return t===-1?n.length:t};return[...r.values()].sort((e,t)=>i(e)-i(t)||e.label.localeCompare(t.label,void 0,{numeric:!0}))}function Hw(e,t){if(!e.length)return;if(t.kind===`pass-rate`)return e.filter(e=>e.status===`passed`).length/e.length;if(t.kind===`score`){let t=e.map(e=>e.score).filter(e=>e!==void 0);return t.length?t.reduce((e,t)=>e+t,0)/t.length:void 0}let n=0,r=0;for(let i of e)for(let e of i.metrics??[])e.name===t.metric.name&&e.mean!==void 0&&e.count&&(n+=e.mean*e.count,r+=e.count);return r?n/r:void 0}var Uw=`-`;function Ww({runs:e,order:t}){let[n,r]=bn(),i=(0,_.useMemo)(()=>Rw(e),[e]),a=(0,_.useMemo)(()=>zw(e),[e]),o=i.includes(n.get(`by`)??``)?n.get(`by`):i[0],s=n.get(`across`),c=s===Uw?void 0:s&&s!==o&&i.includes(s)?s:i.find(e=>e!==o),l=a.find(e=>e.id===n.get(`show`))??a[0],u=(0,_.useMemo)(()=>o?Bw(e,o,c,l.measure,t):void 0,[e,o,c,l,t]);if(!o||!u||!u.rows.length)return null;let d=(e,t)=>r(n=>{let r=new URLSearchParams(n);return r.set(e,t),r},{replace:!0}),f=u.rows.flatMap(e=>u.columns.map(t=>u.cells[e.key]?.[t.key]?.value).filter(e=>e!==void 0)),p=f.length?{min:Math.min(...f),max:Math.max(...f)}:void 0;return(0,Y.jsxs)(`section`,{"aria-label":`Compare`,className:`compare flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:[`Compare`,` `,(0,Y.jsxs)(`span`,{className:`font-normal text-kumo-subtle`,children:[`newest `,10,` finished runs per parameter combination`]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(sy,{"aria-label":`Rows`,size:`sm`,className:`min-w-32`,value:o,onValueChange:e=>e&&d(`by`,String(e)),items:Object.fromEntries(i.map(e=>[e,`Rows: ${e}`]))}),(0,Y.jsx)(sy,{"aria-label":`Columns`,size:`sm`,className:`min-w-32`,value:c??Uw,onValueChange:e=>e&&d(`across`,String(e)),items:{[Uw]:`Columns: none`,...Object.fromEntries(i.filter(e=>e!==o).map(e=>[e,`Columns: ${e}`]))}}),(0,Y.jsx)(sy,{"aria-label":`Show`,size:`sm`,className:`min-w-36`,value:l.id,onValueChange:e=>e&&d(`show`,String(e)),items:Object.fromEntries(a.map(e=>[e.id,e.label]))})]})]}),(0,Y.jsxs)(TS,{className:`w-fit max-w-full`,children:[(0,Y.jsx)($.Header,{children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsxs)($.Head,{children:[o,c?(0,Y.jsxs)(`span`,{className:`font-normal`,children:[` ↓ · `,c,` →`]}):null]}),u.columns.map(e=>(0,Y.jsx)($.Head,{className:`text-right`,children:c?(0,Y.jsx)(`span`,{className:kS,children:e.label}):l.label},e.key))]})}),(0,Y.jsx)($.Body,{children:u.rows.map(e=>(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(`span`,{className:kS,children:e.label})}),u.columns.map(t=>{let n=u.cells[e.key]?.[t.key];return(0,Y.jsx)($.Cell,{className:`text-right`,children:(0,Y.jsx)(Gw,{value:n?.value,runs:n?.runs??0,measure:l.measure,range:p})},t.key)})]},e.key))})]})]})}function Gw({value:e,runs:t,measure:n,range:r}){if(e===void 0)return(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,title:t?`Not measured`:`No finished runs`,children:`—`});let i=n.kind===`pass-rate`?`${Math.round(e*100)}%`:n.kind===`score`?fC(e):mC(e,n.metric.unit),a=n.kind===`metric`?Aw(e,n.metric,r):SC(e);return(0,Y.jsxs)(`span`,{className:`inline-flex flex-col items-end`,children:[(0,Y.jsx)(`span`,{className:`inline-block min-w-12 rounded px-1.5 py-0.5 text-center tabular-nums ${a}`,children:i}),(0,Y.jsxs)(`span`,{className:`text-[11px] text-kumo-subtle tabular-nums`,children:[t,` `,t===1?`run`:`runs`]})]})}function Kw({id:e,evaluation:t,parameters:n=[],trials:r,onRun:i,runDisabled:a=!1,latestRun:o,cellParameters:s}){let c=QC(t?.id??e,s),l=t?.name??e,u=t?.path??e;return(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[t?(0,Y.jsx)(Oi,{href:tC(t.id),className:OS,children:l}):(0,Y.jsx)(`span`,{className:`font-medium`,children:l}),u===l?null:(0,Y.jsx)(`span`,{className:`${kS} text-kumo-subtle`,children:u})]})}),n.map((e,t)=>(0,Y.jsx)($.Cell,{className:kS,children:typeof e==`string`?e:JSON.stringify(e)},t)),(0,Y.jsx)($.Cell,{children:t?(0,Y.jsx)(Oi,{href:$S(VS(t)),children:HS(t)}):HS(t)}),(0,Y.jsx)($.Cell,{children:t?.agent.runtimes.map(e=>e.name).join(`, `)||`default`}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:r??t?.trialCount??`—`}),(0,Y.jsx)($.Cell,{children:o?(0,Y.jsx)(Oi,{href:YS(o.id),title:`Open the latest run`,children:(0,Y.jsx)(dw,{status:o.status})}):`—`}),(0,Y.jsx)($.Cell,{className:`text-right`,children:(0,Y.jsxs)(`div`,{className:`inline-flex items-center justify-end gap-2`,children:[(0,Y.jsx)(Ap,{size:`xs`,variant:`secondary`,icon:(0,Y.jsx)(np,{}),href:c,children:`Runs`}),i||a?(0,Y.jsx)(kp,{size:`xs`,variant:`secondary`,icon:(0,Y.jsx)(ap,{weight:`fill`}),disabled:a,title:a?`Matrix configuration is still loading`:void 0,onClick:e=>{e.stopPropagation(),i?.()},children:`Run`}):null]})})]})}function qw({nested:e,children:t}){return e?(0,Y.jsx)(ES,{children:t}):(0,Y.jsx)(TS,{children:t})}function Jw({axes:e,sort:t,onSort:n,planned:r=!1}){let i=(e,r)=>(0,Y.jsx)(cw,{label:e,sortKey:r,sort:t,onSort:n});return(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[i(`Scenario`,`eval`),e.map(e=>(0,Y.jsx)(cw,{label:e,sortKey:`axis:${e}`,sort:t,onSort:n},e)),i(`Agent`,`agent`),r?(0,Y.jsx)($.Head,{children:`Runtime`}):i(`Runtime`,`runtime`),i(`Trials`,`trials`),r?(0,Y.jsx)($.Head,{children:`Latest run`}):i(`Latest run`,`status`),(0,Y.jsx)($.Head,{className:`text-right`,children:`Actions`})]})})}var Yw=50;function Xw({api:e,evalIds:t,catalog:n,matrix:r,runs:i,nested:a=!1,onRun:o}){let[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(0),{sort:d,toggleSort:f}=sw({key:`eval`,direction:`asc`},()=>u(0)),[p,m]=(0,_.useState)(),[h,g]=(0,_.useState)(),v=r.dimensions??Object.keys(r.parameters),y=t.join(`,`);(0,_.useEffect)(()=>{let t=!0;return g(void 0),m(void 0),e.listMatrixCells({evalIds:y.split(`,`).filter(Boolean),query:s,offset:l*Yw,sort:d.key,direction:d.direction}).then(e=>{t&&m(e)}).catch(e=>{t&&g(e instanceof Error?e.message:`Unable to list matrix cells`)}),()=>{t=!1}},[e,y,s,l,d]);let b=new Map(n.map(e=>[e.id,e])),x=e=>i.filter(t=>t.matrixId===r.id&&t.cellKey===e).sort((e,t)=>t.startedAt.localeCompare(e.startedAt))[0],S=v.length+6;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(ew,{label:`Filter matrix cells`,placeholder:`Scenario, parameter or agent`,value:s,count:`${p?.total??0} of ${p?.planned??0} eligible cells`,onChange:e=>{c(e),u(0)}}),h?(0,Y.jsx)(AS,{message:h}):null,(0,Y.jsxs)(qw,{nested:a,children:[(0,Y.jsx)(Jw,{axes:v,sort:d,onSort:f,planned:!0}),(0,Y.jsxs)($.Body,{children:[p?.cells.map(e=>{let t=b.get(e.evalId);return(0,Y.jsx)(Kw,{id:e.evalId,evaluation:t,parameters:v.map(t=>e.parameters[t]===null?`None`:e.parameters[t]),trials:r.trials,latestRun:x(e.key),cellParameters:e.parameters,onRun:t?()=>o(t.path,Object.fromEntries(v.map(t=>[t,e.parameters[t]]))):void 0},e.key)}),!p&&!h?(0,Y.jsx)(DS,{colSpan:S,children:`Loading cells…`}):null,p&&!p.cells.length?(0,Y.jsx)(DS,{colSpan:S,children:`No matching cells.`}):null]})]}),(0,Y.jsx)(VC,{label:`Matrix cells pages`,noun:`Cells`,page:l,pageSize:Yw,total:p?.total??0,onPage:u})]})}var Zw=50;function Qw(e,t,n,r){let i=t.reduce((e,[,t])=>e*t.length,1),a=e.length*i;if(!Number.isSafeInteger(a))throw Error(`Matrix exceeds safe cell count`);let o=[];for(let s=n;s<Math.min(n+r,a);s++){let n=e[Math.floor(s/i)],r=s%i,a={},c=Array(t.length);for(let e=t.length-1;e>=0;e--){let[n,i]=t[e],o=i[r%i.length];a[n]=o,c[e]=o,r=Math.floor(r/i.length)}o.push({id:n,parameters:a,values:c})}return{rows:o,total:a}}function $w(e,t,n){return JSON.stringify([e,t.map(([e])=>n[e])])}function eT(e){return typeof e==`string`?e:JSON.stringify(e)??String(e)}function tT(e,t,n){let r=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return r.length?e.filter(e=>{let t=n(e).map(eT).join(` `).toLowerCase();return r.every(e=>t.includes(e))}):[...e]}function nT(e){let t=e.matrix?e.evalIds.length*Object.values(e.matrix.parameters).reduce((e,t)=>e*t.length,1):0;return e.matrix&&(e.matrix.constrained||t>1e3)?(0,Y.jsx)(Xw,{...e,matrix:e.matrix}):(0,Y.jsx)(rT,{...e})}function rT({evalIds:e,catalog:t,matrix:n,runs:r,nested:i=!1,onRun:a}){let[o,s]=(0,_.useState)(0),[c,l]=(0,_.useState)(``),{sort:u,toggleSort:d}=sw({key:`eval`,direction:`asc`},()=>s(0)),f=n?Object.entries(n.parameters):[],p=new Map(t.map(e=>[e.id,e])),m=new Map;for(let e of r){if(n&&(e.matrixId!==n.id||!e.parameters))continue;let t=n?$w(e.evalId,f,e.parameters):e.evalId,r=m.get(t);(!r||r.startedAt<=e.startedAt)&&m.set(t,e)}let h=e=>p.get(e.id),g=e=>m.get(n?$w(e.id,f,e.parameters):e.id),v=e=>g(e)?.status,{total:y}=Qw(e,f,0,0),b=lw(tT(Qw(e,f,0,y).rows,c,e=>{let t=h(e);return[t?.name??e.id,e.id,t?.path??e.id,...e.values,HS(t),t?.agent.runtimes.map(e=>e.name).join(`, `)??`default`,v(e)??`not run`]}),u,(e,t)=>{let r=h(e);return t.startsWith(`axis:`)?eT(e.parameters[t.slice(5)]):t===`eval`?r?.name??e.id:t===`agent`?HS(r):t===`runtime`?r?.agent.runtimes.map(e=>e.name).join(`, `)??`default`:t===`trials`?n?.trials??r?.trialCount??0:t===`status`?v(e)??`not run`:``}),x=Math.max(1,Math.ceil(b.length/Zw)),S=Math.min(o,x-1),C=b.slice(S*Zw,(S+1)*Zw);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(ew,{label:n?`Filter matrix cells`:`Filter scenarios`,placeholder:`Scenario, parameter, agent or status`,value:c,count:`${b.length} of ${y} ${n?`cells`:`scenarios`}`,onChange:e=>{l(e),s(0)}}),(0,Y.jsxs)(qw,{nested:i,children:[(0,Y.jsx)(Jw,{axes:f.map(([e])=>e),sort:u,onSort:d}),(0,Y.jsx)($.Body,{children:C.length?C.map(e=>{let t=h(e);return(0,Y.jsx)(Kw,{id:e.id,evaluation:t,parameters:e.values,trials:n?.trials,latestRun:g(e),cellParameters:e.parameters,onRun:t&&n!==void 0?()=>a(t.path,n?e.parameters:void 0):void 0,runDisabled:!!t&&n===void 0},$w(e.id,f,e.parameters))}):(0,Y.jsx)(DS,{colSpan:f.length+6,children:`No matching cells.`})})]}),(0,Y.jsx)(VC,{label:`Matrix cells pages`,noun:`Cells`,page:S,pageSize:Zw,total:b.length,onPage:s})]})}var iT=25;function aT({api:e,catalog:t,suites:n,matrix:r,runs:i,evalId:a}){let[o,s]=(0,_.useState)(),c=t.find(e=>e.id===a),l=(0,_.useMemo)(()=>i.filter(e=>e.evalId===a).sort((e,t)=>t.startedAt.localeCompare(e.startedAt)),[i,a]);if(!c&&!l.length)return(0,Y.jsx)(BS,{message:`Scenario not found: ${a}`});let u=t=>{c&&(s(void 0),e.runEval(c.path,t).catch(e=>s(e instanceof Error?e.message:`Unable to start scenario`)))},d=!!c&&!e.readOnly;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(wC,{section:`scenarios`,current:c?.name??a}),(0,Y.jsx)(iC,{title:c?.name??a,subtitle:c?.id??`${a} (no longer in the project)`,status:l[0]?(0,Y.jsx)(dw,{status:l[0].status}):void 0,actions:d&&r===null?(0,Y.jsx)(kp,{size:`sm`,variant:`primary`,icon:(0,Y.jsx)(ap,{weight:`fill`}),className:`run-scenario`,onClick:()=>u(),children:`Run scenario`}):void 0}),o?(0,Y.jsx)(AS,{message:o}):null,c?(0,Y.jsx)(oT,{scenario:c,suites:n,catalog:t}):null,c?.transcript?.length?(0,Y.jsx)(sT,{scenario:c,catalog:t}):null,d&&r?(0,Y.jsxs)(`section`,{"aria-label":`Matrix cells`,className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:`Matrix cells`}),(0,Y.jsx)(nT,{api:e,evalIds:[a],catalog:t,matrix:r,runs:i,onRun:(e,t)=>u(t)})]}):null,(0,Y.jsx)(Ww,{runs:l,order:r?.parameters}),(0,Y.jsxs)(`section`,{"aria-label":`Runs`,className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:[`Runs`,` `,(0,Y.jsx)(`span`,{className:`font-normal text-kumo-subtle tabular-nums`,children:l.length})]}),(0,Y.jsx)(lT,{runs:l})]})]})}function oT({scenario:e,suites:t,catalog:n}){let r=t.find(t=>t.id===e.suiteId||t.evalIds.includes(e.id)),i=WS(n),a=e=>i.find(t=>t.scorer.name===e.name&&t.scorer.kind===e.kind&&t.scorer.definedAt===e.definedAt)?.key??e.name,o=e.policy;return(0,Y.jsx)($_,{className:`scenario-definition max-w-3xl p-4`,children:(0,Y.jsx)(zS,{items:[...r?[[`Suite`,r.name??r.id]]:[],[`Agent`,(0,Y.jsx)(mn,{to:$S(VS(e)),className:OS,children:HS(e)},`agent`)],...e.judgeAgent?[[`Judge agent`,(0,Y.jsx)(mn,{to:$S(VS({agent:e.judgeAgent})),className:OS,children:e.judgeAgent.name??e.judgeAgent.id??e.judgeAgent.kind},`judge-agent`)]]:[],[`Final scoring`,e.scorers.length?(0,Y.jsx)(`span`,{className:`flex flex-wrap gap-x-2`,children:e.scorers.map(e=>(0,Y.jsx)(mn,{to:eC(a(e)),className:OS,children:e.name},`${e.kind}-${e.name}`))},`scorers`):`none`],[`Datasets`,(e.datasets??[]).length?(0,Y.jsx)(`span`,{className:`flex flex-wrap gap-x-2`,children:(e.datasets??[]).map(e=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(mn,{to:nC(e.id),className:OS,children:e.id}),` `,(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[`(`,e.visibility===`candidate`?`agent`:`scorers only`,`)`]})]},e.id))},`datasets`):`none`],[`Trials per run`,o?.trials??e.trialCount],...o?.timeoutMs===void 0?[]:[[`Timeout`,`${o.timeoutMs/1e3}s`]],...o?.failfast?[[`Failfast`,`stops at the first failed checkpoint`]]:[],[`Runtimes`,e.agent.runtimes.map(e=>`${e.name} (${e.kind})`).join(`, `)||`default`],[`Defined in`,(0,Y.jsx)(TC,{at:e.definedAt},`at`)]]})})}function sT({scenario:e,catalog:t}){let n=WS(t);return(0,Y.jsxs)(`section`,{"aria-label":`Transcript`,className:`flex max-w-3xl flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:`Transcript`}),(0,Y.jsx)(`ol`,{className:`flex flex-col gap-1.5`,children:(e.transcript??[]).map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-3 rounded-md border border-kumo-hairline bg-kumo-base px-3 py-2 text-[13px]`,children:[(0,Y.jsx)(`span`,{className:`w-5 shrink-0 text-right text-xs text-kumo-subtle tabular-nums`,children:t+1}),(0,Y.jsx)(cT,{step:e,judgeKey:e=>n.find(t=>t.scorer.name===e.name&&t.scorer.kind===e.kind&&t.scorer.definedAt===e.definedAt)?.key??e.name})]},t))})]})}function cT({step:e,judgeKey:t}){let n=e=>(0,Y.jsx)(`span`,{className:`w-24 shrink-0 text-xs font-medium text-kumo-subtle`,children:e});switch(e.kind){case`user`:return(0,Y.jsxs)(Y.Fragment,{children:[n(`User says`),e.message===void 0?(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:`Computed for each trial from its parameters and datasets; each trial's trajectory shows the message it was sent.`}):(0,Y.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.message})]});case`agent`:return(0,Y.jsxs)(Y.Fragment,{children:[n(`Agent should`),(0,Y.jsx)(`code`,{className:kS,children:JSON.stringify(e.expectation)})]});case`expect-tool-call`:return(0,Y.jsxs)(Y.Fragment,{children:[n(`Expect tool call`),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`code`,{className:kS,children:e.name}),e.arguments===void 0?null:(0,Y.jsx)(`code`,{className:`${kS} ml-2 text-kumo-subtle`,children:JSON.stringify(e.arguments)})]})]});case`checkpoint`:return(0,Y.jsxs)(Y.Fragment,{children:[n(`Checkpoint`),(0,Y.jsx)(mn,{to:eC(t(e.scorer)),className:OS,children:e.scorer.name}),(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:e.scorer.kind===`judge`?`LLM judge`:`predicate`})]})}}function lT({runs:e}){let[t,n]=(0,_.useState)(0),r=sC(e),i=e.slice(t*iT,(t+1)*iT),a=5+r.columns.length+ +!!r.overflow.length;return(0,Y.jsxs)(Y.Fragment,{children:[r.constant.length?(0,Y.jsxs)(`p`,{className:`flex flex-wrap items-center gap-1 text-[13px] text-kumo-subtle`,role:`note`,children:[`Same on every run:`,(0,Y.jsx)(cC,{entries:r.constant})]}):null,(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Run`}),(0,Y.jsx)($.Head,{children:`Status`}),(0,Y.jsx)($.Head,{children:`Score`}),(0,Y.jsx)($.Head,{children:`Started`}),(0,Y.jsx)($.Head,{children:`Commit`}),r.columns.map(e=>(0,Y.jsx)($.Head,{children:e},e)),r.overflow.length?(0,Y.jsx)($.Head,{children:`Other parameters`}):null]})}),(0,Y.jsxs)($.Body,{children:[i.map(e=>(0,Y.jsxs)($.Row,{..._C,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(mn,{to:YS(e.id),"data-row-link":!0,className:`${OS} ${kS}`,title:e.id,children:e.id.slice(0,8)})}),(0,Y.jsx)($.Cell,{title:e.interrupted?`Its process stopped before the run finished`:void 0,children:(0,Y.jsx)(dw,{status:e.status})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(hC,{run:e})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(gC,{run:e})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(_w,{source:e.source})}),r.columns.map(t=>(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(uC,{run:e,name:t})},t)),r.overflow.length?(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(lC,{run:e,keys:r.overflow})}):null]},e.id)),e.length?null:(0,Y.jsx)(DS,{colSpan:a,children:`Not run yet.`})]})]}),(0,Y.jsx)(VC,{label:`Scenario run pages`,noun:`Runs`,page:t,pageSize:iT,total:e.length,onPage:n})]})}function uT({suite:e,expanded:t,onToggle:n,onRun:r}){return(0,Y.jsxs)($.Row,{variant:t?`selected`:`default`,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(`button`,{type:`button`,className:`${OS} inline-flex items-center gap-1.5`,"aria-expanded":t,onClick:n,children:[(0,Y.jsx)(Rf,{"aria-hidden":!0,className:`size-3 transition-transform ${t?`rotate-90`:``}`}),e.name??e.id??`Unnamed suite`]})}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:e.evalIds.length}),(0,Y.jsx)($.Cell,{className:`text-right`,children:(0,Y.jsx)(kp,{size:`xs`,variant:`secondary`,icon:(0,Y.jsx)(ap,{weight:`fill`}),disabled:!r,title:r?void 0:`Run matrix cells individually from their rows`,onClick:e=>{e.stopPropagation(),r?.()},children:`Run suite`})})]})}function dT({api:e,suites:t,catalog:n,matrix:r,runs:i=[],selectedSuiteId:a}){let[o,s]=(0,_.useState)(a),[c,l]=(0,_.useState)(),u=e=>t=>l(t instanceof Error?t.message:e),d=(t,n)=>{l(void 0),e.runEval(t,n).catch(u(`Unable to start scenario`))},f=t=>{l(void 0),e.runSuite(t).catch(u(`Unable to start suite`))},p=o,m=n.filter(e=>!e.suiteId&&!t.some(t=>t.evalIds.includes(e.id)));return!t.length&&!m.length?(0,Y.jsx)(BS,{message:`No scenarios are loaded.`}):(0,Y.jsxs)(Y.Fragment,{children:[r?(0,Y.jsx)(`p`,{className:`text-[13px] text-kumo-subtle`,children:`Each row is one configured matrix cell. Run one row at a time; use the CLI dry-run for larger selections.`}):null,c?(0,Y.jsx)(AS,{message:c}):null,t.length>0?(0,Y.jsxs)(`section`,{"aria-label":`Suites`,className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-kumo-strong`,children:`Suites`}),(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Suite`}),(0,Y.jsx)($.Head,{children:`Scenarios`}),(0,Y.jsx)($.Head,{className:`text-right`,children:`Actions`})]})}),(0,Y.jsx)($.Body,{children:t.map(t=>(0,Y.jsxs)(_.Fragment,{children:[(0,Y.jsx)(uT,{suite:t,expanded:p===t.id,onToggle:()=>{s(p===t.id?void 0:t.id)},onRun:r===null?()=>f(t.id):void 0}),p===t.id?(0,Y.jsx)($.Row,{children:(0,Y.jsx)($.Cell,{colSpan:3,className:`bg-kumo-elevated`,children:(0,Y.jsx)(nT,{api:e,evalIds:t.evalIds,catalog:n,matrix:r,runs:i,nested:!0,onRun:d})})}):null]},t.id))})]})]}):null,m.length>0?(0,Y.jsxs)(`section`,{"aria-label":`Scenarios without a suite`,className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-kumo-strong`,children:t.length?`Scenarios without a suite`:`Scenarios`}),(0,Y.jsx)(nT,{api:e,evalIds:m.map(e=>e.id),catalog:n,matrix:r,runs:i,onRun:d})]}):null]})}function fT({artifact:e}){return(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Cell,{className:`${kS} break-all`,children:e.path}),(0,Y.jsx)($.Cell,{children:e.kind}),(0,Y.jsx)($.Cell,{className:`whitespace-nowrap tabular-nums`,children:e.size===void 0?`—`:`${e.size} B`})]})}var pT=e=>typeof e==`string`?e:void 0,mT=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0;function hT(e){if(typeof e==`object`&&e){let t=e;return{name:pT(t.name),message:pT(t.message)??JSON.stringify(e),stack:pT(t.stack)}}return{message:String(e)}}function gT(e){if(typeof e!=`object`||!e)return;let t=e,n={inputTokens:mT(t.inputTokens),outputTokens:mT(t.outputTokens),totalTokens:mT(t.totalTokens)};return Object.values(n).some(e=>e!==void 0)?n:void 0}var _T=new Set([`trial-started`,`trial-completed`,`started`,`transcript-step-completed`]);function vT(e){let t=e.map(e=>Date.parse(e.timestamp)),n=t.find(e=>!Number.isNaN(e))??0,r=e=>{let r=t[e];return Number.isNaN(r)?0:Math.max(0,r-n)},i=[],a=[],o=new Map,s=new Map,c=new Map,l=new Map,u,d=!1,f=()=>a.at(-1)?.items??i,p=()=>(a.push({items:[]}),d=!1,a.at(-1));e.forEach((e,t)=>{let n=r(t);if(!_T.has(e.kind))switch(e.kind){case`transcript-step-started`:{let t=pT(e.message);if(t===void 0)return;p().items.push({type:`user`,at:n,text:t}),d=!0;return}case`turn-started`:{let t=mT(e.turn),n=d?a.at(-1):p();n.turn=t,d=!1;return}case`turn-completed`:{let t=a.at(-1);if(!t)return;t.turn??=mT(e.turn),t.latencyMs=mT(e.latencyMs),t.usage=gT(e.usage);return}case`message`:{d=!1;let t=pT(e.role)??`unknown`;if(t===`user`){let t=typeof e.content==`string`?e.content:void 0,r=a.at(-1)?.items.find(e=>e.type===`user`);if(t!==void 0&&r?.type===`user`&&r.text===t)return;f().push({type:`user`,at:n,text:t??JSON.stringify(e.content)});return}if(t===`assistant`){u=e.content,f().push({type:`assistant`,at:n,content:e.content});return}f().push({type:`message`,at:n,role:t,content:e.content});return}case`tool-call`:{d=!1;let r=pT(e.id)??`call-${t}`,i={type:`tool`,at:n,id:r,name:pT(e.name)??`tool`,arguments:e.arguments};c.set(r,i),f().push(i);return}case`tool-result`:{let r=c.get(pT(e.id)??``);if(r&&!r.result){r.result={value:e.result,durationMs:n-r.at};return}f().push({type:`tool`,at:n,id:pT(e.id)??`result-${t}`,name:pT(e.name)??`tool`,result:{value:e.result,durationMs:0}});return}case`checkpoint-started`:{let r=mT(e.step)??t,i={type:`checkpoint`,at:n,step:r,name:pT(e.name)??`step ${r+1}`,state:`running`};l.set(r,i),f().push(i);return}case`checkpoint-completed`:case`checkpoint-error`:{let t=mT(e.step)??-1,r=l.get(t);if(!r)return;if(r.durationMs=n-r.at,e.kind===`checkpoint-error`)r.state=`error`,r.error=hT(e.error);else{let t=pT(e.status);r.state=t===`passed`||t===`failed`||t===`skipped`?t:`error`}return}case`transcript-step-skipped`:f().push({type:`skipped-step`,at:n,step:mT(e.step)??-1});return;case`scorer-started`:s.set(pT(e.scorer)??`scorer`,n);return;case`scorer-completed`:case`scorer-failed`:{let t=pT(e.scorer)??`scorer`,r=s.get(t);o.set(t,{name:t,value:mT(e.value),skipped:e.skipped===!0,error:e.kind===`scorer-failed`?hT(e.error):void 0,durationMs:r===void 0?void 0:n-r});return}case`completed`:if(e.output===void 0||JSON.stringify(e.output)===JSON.stringify(u))return;f().push({type:`output`,at:n,output:e.output});return;case`error`:f().push({type:`error`,at:n,source:e.source,error:hT(e.error)});return;default:f().push({type:`unknown`,at:n,event:e})}});let m=e.length?r(e.length-1):void 0;return{preamble:i,turns:a,scorers:[...o.values()],durationMs:m}}function yT(e){if(e<1)return`<1ms`;if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFixed(e<1e4?2:1)}s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return`${t}m ${String(n).padStart(2,`0`)}s`}function bT(e){let t=e.totalTokens??(e.inputTokens!==void 0||e.outputTokens!==void 0?(e.inputTokens??0)+(e.outputTokens??0):void 0),n=[e.inputTokens===void 0?void 0:`${e.inputTokens.toLocaleString()} in`,e.outputTokens===void 0?void 0:`${e.outputTokens.toLocaleString()} out`].filter(Boolean),r=t===void 0?``:`${t.toLocaleString()} tokens`;return n.length?`${r}${r?` `:``}(${n.join(` · `)})`:r}function xT({events:e}){let[t,n]=(0,_.useState)(`conversation`),r=vT(e);return(0,Y.jsxs)(`section`,{className:`trajectory flex min-w-0 flex-col gap-3`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:`Trajectory`}),(0,Y.jsx)(ob,{variant:`segmented`,size:`sm`,value:t,onValueChange:e=>n(e),tabs:[{value:`conversation`,label:`Conversation`},{value:`events`,label:`All events (${e.length})`}]})]}),t===`events`?(0,Y.jsx)(OT,{events:e}):(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[r.preamble.length?(0,Y.jsx)(CT,{items:r.preamble}):null,r.turns.map((e,t)=>(0,Y.jsx)(ST,{turn:e,index:t},t)),e.length?(0,Y.jsx)(DT,{durationMs:r.durationMs,scorers:r.scorers}):(0,Y.jsx)(`p`,{className:`text-[13px] text-kumo-subtle`,children:`No events recorded.`})]})]})}function ST({turn:e,index:t}){let n=[e.latencyMs===void 0?void 0:yT(e.latencyMs),e.usage?bT(e.usage):void 0].filter(Boolean);return(0,Y.jsxs)(`section`,{className:`turn border-t border-kumo-line pt-3 pb-4 first:border-t-0 first:pt-0`,"aria-label":`Turn ${e.turn??t+1}`,children:[(0,Y.jsxs)(`header`,{className:`mb-2 flex items-baseline justify-between gap-3 text-xs`,children:[(0,Y.jsxs)(`h4`,{className:`font-medium text-kumo-strong`,children:[`Turn `,e.turn??t+1]}),n.length?(0,Y.jsx)(`span`,{className:`text-kumo-subtle tabular-nums`,children:n.join(` · `)}):null]}),(0,Y.jsx)(CT,{items:e.items})]})}function CT({items:e}){return(0,Y.jsx)(`ol`,{className:`relative flex flex-col gap-3 before:absolute before:top-2 before:bottom-2 before:left-[11px] before:w-px before:bg-kumo-line`,children:e.map((e,t)=>(0,Y.jsx)(`li`,{className:`trajectory-item item-${e.type}`,children:(0,Y.jsx)(TT,{item:e})},t))})}function wT({icon:e,tone:t=`default`,label:n,at:r,children:i}){return(0,Y.jsxs)(`div`,{className:`grid grid-cols-[24px_minmax(0,1fr)] gap-x-3`,children:[(0,Y.jsx)(`span`,{className:J(`relative z-10 flex size-6 items-center justify-center rounded-full border border-kumo-line bg-kumo-base text-[13px]`,t===`danger`&&`border-kumo-danger text-kumo-danger`,t===`muted`?`text-kumo-subtle`:`text-kumo-default`),"aria-hidden":!0,children:e}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5 pt-0.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-5 items-baseline gap-2 text-xs`,children:[(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-baseline gap-x-2 gap-y-1`,children:n}),r===void 0?null:(0,Y.jsxs)(`time`,{className:`shrink-0 font-mono text-[11px] text-kumo-subtle tabular-nums`,children:[`+`,yT(r)]})]}),i]})]})}function TT({item:e}){switch(e.type){case`user`:return(0,Y.jsx)(wT,{icon:(0,Y.jsx)(dp,{}),label:(0,Y.jsx)(kT,{children:`User`}),at:e.at,children:(0,Y.jsx)(IT,{className:`rounded-lg bg-kumo-elevated px-3 py-2`,children:e.text})});case`assistant`:return(0,Y.jsx)(wT,{icon:(0,Y.jsx)(sp,{}),label:(0,Y.jsx)(kT,{children:`Assistant`}),at:e.at,children:(0,Y.jsx)(NT,{value:e.content})});case`message`:return(0,Y.jsx)(wT,{icon:(0,Y.jsx)($f,{}),tone:`muted`,label:(0,Y.jsxs)(kT,{children:[e.role,` message`]}),at:e.at,children:(0,Y.jsx)(NT,{value:e.content})});case`tool`:return(0,Y.jsx)(ET,{item:e});case`checkpoint`:return(0,Y.jsx)(wT,{icon:(0,Y.jsx)(qf,{}),tone:e.state===`error`?`danger`:`default`,label:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(kT,{children:`Checkpoint`}),(0,Y.jsx)(`span`,{className:`text-[13px] text-kumo-default`,children:e.name}),(0,Y.jsx)(dw,{status:e.state}),e.durationMs===void 0?null:(0,Y.jsx)(AT,{children:yT(e.durationMs)})]}),at:e.at,children:e.error?(0,Y.jsx)(MT,{error:e.error}):null});case`skipped-step`:return(0,Y.jsx)(wT,{icon:(0,Y.jsx)(lp,{}),tone:`muted`,label:(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[`Step `,e.step+1,` skipped after a failed checkpoint`]}),at:e.at});case`error`:return(0,Y.jsx)(wT,{icon:(0,Y.jsx)(fp,{}),tone:`danger`,label:(0,Y.jsx)(`span`,{className:`font-semibold text-kumo-danger`,children:e.source===`aut`?`Agent error`:`Runner error`}),at:e.at,children:(0,Y.jsx)(MT,{error:e.error})});case`output`:return(0,Y.jsx)(wT,{icon:(0,Y.jsx)(cp,{}),label:(0,Y.jsx)(kT,{children:`Final output`}),at:e.at,children:(0,Y.jsx)(NT,{value:e.output})});case`unknown`:{let{source:t,kind:n,timestamp:r,...i}=e.event;return(0,Y.jsx)(wT,{icon:(0,Y.jsx)(op,{}),tone:`muted`,label:(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[t,` · `,(0,Y.jsx)(`span`,{className:`font-mono`,children:n})]}),at:e.at,children:Object.keys(i).length?(0,Y.jsx)(LT,{value:i}):null})}}}function ET({item:e}){let t=RT(e.arguments);return(0,Y.jsxs)(`details`,{className:`tool-call group`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer list-none rounded-md select-none focus-visible:outline-2 focus-visible:outline-kumo-brand [&::-webkit-details-marker]:hidden`,children:(0,Y.jsx)(wT,{icon:(0,Y.jsx)(pp,{}),label:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Rf,{"aria-hidden":!0,className:`self-center text-kumo-subtle transition-transform group-open:rotate-90`}),(0,Y.jsx)(`span`,{className:`font-mono text-[13px] font-medium text-kumo-strong`,children:e.name}),t?(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono text-kumo-subtle`,children:t}):null,e.result?(0,Y.jsx)(AT,{children:yT(e.result.durationMs)}):(0,Y.jsx)(`span`,{className:`text-kumo-warning`,children:`no result`})]}),at:e.at,children:e.result?(0,Y.jsxs)(`span`,{className:`line-clamp-2 font-mono text-xs break-words text-kumo-subtle group-open:hidden`,children:[`→ `,RT(e.result.value,240)]}):null})}),(0,Y.jsxs)(`div`,{className:`mt-2 ml-9 flex flex-col gap-2`,children:[e.arguments===void 0?null:(0,Y.jsx)(jT,{label:`Arguments`,children:(0,Y.jsx)(LT,{value:e.arguments})}),e.result?(0,Y.jsx)(jT,{label:`Result`,children:(0,Y.jsx)(LT,{value:e.result.value})}):null]})]})}function DT({durationMs:e,scorers:t}){let n=t.filter(e=>e.error).length,r=[e===void 0?void 0:`Finished in ${yT(e)}`,t.length?`${t.length} final ${t.length===1?`scorer`:`scorers`} ran${n?`, ${n} errored`:``}`:void 0].filter(Boolean);return r.length?(0,Y.jsx)(`p`,{className:`border-t border-kumo-line pt-3 text-xs text-kumo-subtle tabular-nums`,children:r.join(` · `)}):null}function OT({events:e}){let t=Date.parse(e[0]?.timestamp??``);return(0,Y.jsx)(`ol`,{className:`raw-events flex flex-col divide-y divide-kumo-line rounded-lg border border-kumo-line text-xs`,children:e.map((e,n)=>{let{source:r,kind:i,timestamp:a,...o}=e,s=Date.parse(a)-t,c=Object.keys(o).length?JSON.stringify(o):``;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`details`,{className:`group`,children:[(0,Y.jsxs)(`summary`,{className:`grid cursor-pointer list-none grid-cols-[2rem_4rem_3rem_13rem_minmax(0,1fr)] items-baseline gap-x-3 px-3 py-1.5 select-none hover:bg-kumo-elevated [&::-webkit-details-marker]:hidden`,children:[(0,Y.jsx)(`span`,{className:`text-right font-mono text-kumo-subtle tabular-nums`,children:n+1}),(0,Y.jsx)(`span`,{className:`font-mono text-kumo-subtle tabular-nums`,children:Number.isNaN(s)?``:`+${yT(s)}`}),(0,Y.jsx)(`span`,{className:`text-kumo-subtle`,children:r}),(0,Y.jsx)(`span`,{className:`font-mono text-kumo-strong`,children:i}),(0,Y.jsx)(`span`,{className:`truncate font-mono text-kumo-subtle`,children:c})]}),(0,Y.jsx)(`div`,{className:`px-3 pb-2`,children:(0,Y.jsx)(LT,{value:e})})]})},`${a}-${n}`)})})}function kT({children:e}){return(0,Y.jsx)(`span`,{className:`font-semibold text-kumo-strong first-letter:uppercase`,children:e})}function AT({children:e}){return(0,Y.jsx)(`span`,{className:`text-kumo-subtle tabular-nums`,children:e})}function jT({label:e,children:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:e}),t]})}function MT({error:e}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`p`,{className:`text-[13px] text-kumo-danger`,children:[e.name&&e.name!==`Error`?`${e.name}: `:``,e.message]}),e.stack?(0,Y.jsxs)(`details`,{className:`text-xs`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer text-kumo-subtle select-none`,children:`Stack trace`}),(0,Y.jsx)(`pre`,{className:`mt-1 overflow-x-auto rounded-md bg-kumo-elevated px-3 py-2 font-mono text-[11px]`,children:e.stack})]}):null]})}function NT({value:e}){return typeof e==`string`?(0,Y.jsx)(IT,{children:e}):(0,Y.jsx)(LT,{value:e})}var PT=1200,FT=16;function IT({children:e,className:t}){let n=e.length>PT||e.split(`
|
|
32
|
+
`).length>FT,[r,i]=(0,_.useState)(!1);return(0,Y.jsxs)(`div`,{className:J(`flex max-w-[75ch] flex-col items-start gap-1`,t),children:[(0,Y.jsx)(`p`,{className:J(`text-[13px] leading-relaxed break-words whitespace-pre-wrap text-kumo-default`,n&&!r&&`line-clamp-[12]`),children:e}),n?(0,Y.jsx)(kp,{size:`xs`,variant:`ghost`,onClick:()=>i(!r),children:r?`Show less`:`Show all ${e.split(`
|
|
33
|
+
`).length} lines`}):null]})}function LT({value:e}){let t=typeof e==`string`?e:JSON.stringify(e,null,2);return(0,Y.jsx)(`pre`,{className:`max-h-96 overflow-auto rounded-md bg-kumo-elevated px-3 py-2 font-mono text-xs break-words whitespace-pre-wrap text-kumo-default`,children:t})}function RT(e,t=120){if(e===void 0)return``;let n=typeof e==`object`&&e&&!Array.isArray(e)?Object.entries(e).map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(`, `):typeof e==`string`?e:JSON.stringify(e);return n.length>t?`${n.slice(0,t-1)}…`:n}function zT({api:e,selected:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(),[c,l]=(0,_.useState)([]);if((0,_.useEffect)(()=>{if(!t)return;let n=!0;return a(void 0),r([]),s(void 0),l([]),Promise.all([e.getTrialEvents(t.run.id,t.trial.id),e.getTrial(t.run.id,t.trial.id),e.listArtifacts(t.run.id,t.trial.id)]).then(([e,t,i])=>{n&&(r(e),s(t),l(i))}).catch(e=>{n&&a(e instanceof Error?e.message:`Unable to load trial details`)}),()=>{n=!1}},[e,t]),!t)return(0,Y.jsx)(BS,{message:`Select a trial from a run to inspect it.`});let{trial:u}=t,d=WT(o?.manifest);return(0,Y.jsxs)(`section`,{className:`trial-inspector grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(320px,400px)]`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[i?(0,Y.jsx)(AS,{title:`Unable to load trial details`,message:i}):null,(0,Y.jsx)(xT,{events:n})]}),(0,Y.jsxs)(`aside`,{className:`trial-overview flex min-w-0 flex-col gap-4`,children:[(0,Y.jsx)(zS,{items:[[`Status`,(0,Y.jsx)(dw,{status:u.status},`status`)],[`Aggregate score`,u.score??`—`],[`Runtime`,u.durationMs===void 0?`—`:pC(u.durationMs)],[`Started`,new Date(u.startedAt).toLocaleString()]]}),(0,Y.jsxs)(BT,{title:`Final scoring`,children:[(0,Y.jsx)(UT,{scores:u.scores}),u.skippedScorers?.length?(0,Y.jsxs)(`p`,{className:`text-xs text-kumo-subtle`,children:[`Skipped final scorers: `,u.skippedScorers.join(`, `)]}):null]}),u.metrics?.length?(0,Y.jsx)(BT,{title:`Metrics`,children:(0,Y.jsx)(zS,{items:u.metrics.map(e=>[e.name,e.error?(0,Y.jsx)(`span`,{className:`text-kumo-danger`,children:e.error.message},e.name):(0,Y.jsx)(`span`,{className:`tabular-nums`,children:e.value===void 0?`—`:mC(e.value,e.unit)},e.name)])})}):null,u.checkpoints?.length?(0,Y.jsx)(BT,{title:`Checkpoints`,children:(0,Y.jsx)(VT,{checkpoints:u.checkpoints})}):null,d.length?(0,Y.jsx)(BT,{title:`Datasets`,children:(0,Y.jsx)(zS,{items:d.map(e=>[e.id,(0,Y.jsxs)(`span`,{title:e.digest,children:[e.visibility,` · `,e.source,` ·`,` `,(0,Y.jsx)(`span`,{className:kS,children:e.digest.replace(`sha256:`,``).slice(0,12)})]},e.id)])})}):null,c.length?(0,Y.jsx)(BT,{title:`Artifacts`,children:(0,Y.jsxs)(ES,{wrap:!0,children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Path`}),(0,Y.jsx)($.Head,{children:`Kind`}),(0,Y.jsx)($.Head,{children:`Size`})]})}),(0,Y.jsx)($.Body,{children:c.map(e=>(0,Y.jsx)(fT,{artifact:e},e.path))})]})}):null,o?(0,Y.jsxs)(`details`,{className:`raw-details text-xs`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer font-medium text-kumo-subtle select-none`,children:`Raw trial summary`}),(0,Y.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-kumo-elevated px-3 py-2 font-mono`,children:JSON.stringify(o.summary,null,2)})]}):null]})]})}function BT({title:e,children:t}){return(0,Y.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-kumo-strong`,children:e}),t]})}function VT({checkpoints:e}){return(0,Y.jsxs)(ES,{wrap:!0,children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Step`}),(0,Y.jsx)($.Head,{children:`Rule`}),(0,Y.jsx)($.Head,{children:`Value`}),(0,Y.jsx)($.Head,{children:`Result`})]})}),(0,Y.jsx)($.Body,{children:e.map(e=>(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:e.step+1}),(0,Y.jsxs)($.Cell,{children:[(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[e.kind,`:`]}),` `,e.name,e.matchedToolCall?` (event ${e.matchedToolCall.eventIndex+1})`:``]}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:e.value??`—`}),(0,Y.jsxs)($.Cell,{children:[(0,Y.jsx)(dw,{status:e.status}),e.error?(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-kumo-danger`,children:e.error.message}):null]})]},`${e.step}-${e.name}`))})]})}function HT(e){return e.error?`error`:e.skipped?`skipped`:e.passed===!0?`passed`:e.passed===!1?`failed`:`not scored`}function UT({scores:e}){return(0,Y.jsxs)(ES,{wrap:!0,children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Scorer`}),(0,Y.jsx)($.Head,{children:`Value`}),(0,Y.jsx)($.Head,{children:`Result`})]})}),(0,Y.jsxs)($.Body,{children:[e.map(e=>(0,Y.jsxs)($.Row,{children:[(0,Y.jsxs)($.Cell,{children:[e.kind?(0,Y.jsxs)(`span`,{className:`text-kumo-subtle`,children:[e.kind,`: `]}):null,e.name]}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:e.value??`—`}),(0,Y.jsxs)($.Cell,{children:[(0,Y.jsx)(dw,{status:HT(e)}),e.skipped&&e.explanation?(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-kumo-subtle`,children:e.explanation}):null,e.error?(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-kumo-danger`,children:e.error.message}):null]})]},e.name)),e.length?null:(0,Y.jsx)($.Row,{children:(0,Y.jsx)($.Cell,{colSpan:3,className:`text-kumo-subtle`,children:`No final scorers.`})})]})]})}function WT(e){let t=e?.datasets;return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&typeof e.digest==`string`):[]}function GT({api:e,selected:t}){let[n,r]=(0,_.useState)(),[i,a]=(0,_.useState)(),[o,s]=bn();(0,_.useEffect)(()=>{if(!t)return;let n=!0;return r(void 0),a(void 0),e.listWorkspace(t.run.id,t.trial.id).then(e=>{n&&r(e)}).catch(e=>{n&&a(e instanceof Error?e.message:`Unable to load workspace`)}),()=>{n=!1}},[e,t]);let c=t?.run.id,l=t?.trial.id,u=(0,_.useCallback)(t=>e.getWorkspaceFile(c,l,t),[e,c,l]);return t?(0,Y.jsxs)(`section`,{className:`workspace-inspector flex flex-col gap-2`,children:[i?(0,Y.jsx)(AS,{message:i}):null,!n&&!i?(0,Y.jsx)(`p`,{className:`text-[13px] text-kumo-subtle`,children:`Loading workspace…`}):null,n?(0,Y.jsx)(FS,{entries:n,rootLabel:`workspace/`,readFile:u,selected:o.get(`file`)??void 0,onSelect:e=>{let t=new URLSearchParams(o);t.set(`file`,e),s(t,{replace:!0})},emptyMessage:`The workspace is empty.`}):null]}):(0,Y.jsx)(BS,{message:`Select a trial to inspect its workspace.`})}function KT({api:e,runs:t,runId:n,trialId:r,workspace:i=!1}){let a=$e(),o=t.find(e=>e.id===n),{trials:s,error:c}=nw(e,o),l=s?.find(e=>e.id===r);if(!o)return(0,Y.jsx)(BS,{message:t.length?`Run not found: ${n}`:`Loading trial…`});let u=(0,Y.jsx)(rC,{run:o,trial:l??{id:r},workspace:i});if(c||s&&!l)return(0,Y.jsxs)(Y.Fragment,{children:[u,(0,Y.jsx)(AS,{message:c??`Trial ${r} was not found in this run.`})]});if(!l)return(0,Y.jsxs)(Y.Fragment,{children:[u,(0,Y.jsx)(`output`,{className:`text-[13px] text-kumo-subtle`,children:`Loading trial…`})]});let d={run:o,trial:l};return(0,Y.jsxs)(Y.Fragment,{children:[u,(0,Y.jsx)(iC,{title:i?`Candidate workspace`:`Trial ${l.index+1}`,subtitle:l.id,status:i?void 0:(0,Y.jsx)(dw,{status:l.status}),actions:i?void 0:(0,Y.jsx)(kp,{size:`sm`,variant:`secondary`,icon:(0,Y.jsx)(Yf,{}),className:`open-workspace`,onClick:()=>a(ZS(o.id,l.id)),children:`Candidate workspace`})}),i?(0,Y.jsx)(GT,{api:e,selected:d}):(0,Y.jsx)(zT,{api:e,selected:d})]})}var qT=20;function JT(e,t){let n=(0,_.useMemo)(()=>[...t].sort((e,t)=>t.startedAt.localeCompare(e.startedAt)),[t]),[r,i]=(0,_.useState)(qT),[a,o]=(0,_.useState)({}),[s,c]=(0,_.useState)(),l=n.slice(0,r),u=l.map(e=>`${e.id}:${e.completedTrials}:${e.status}`).join(`,`);return(0,_.useEffect)(()=>{let t=!0;return Promise.all(l.map(async t=>[t.id,await e.listTrials(t.id)])).then(e=>{t&&o(t=>({...t,...Object.fromEntries(e)}))}).catch(e=>{t&&c(e instanceof Error?e.message:`Unable to load trials`)}),()=>{t=!1}},[e,u]),{trials:l.flatMap(e=>(a[e.id]??[]).slice().sort((e,t)=>e.index-t.index).map(t=>({run:e,trial:t}))),error:s,loading:l.some(e=>!a[e.id]),more:n.length>r,loadMore:()=>i(e=>e+qT),runCount:l.length,totalRuns:n.length}}function YT({api:e,catalog:t,suites:n,runs:r,search:i,onSearchChange:a,workspaces:o=!1}){let s=iw({runs:r,catalog:t,suites:n,search:i,onSearchChange:a,trialStatus:!0}),c=JT(e,s.filteredRuns),l=c.trials.filter(({trial:e})=>s.keepTrial(e)),u=aw(s.facets,c.trials.map(({trial:e})=>e)),d=sC([...new Set(l.map(({run:e})=>e))]);if(!r.length)return(0,Y.jsx)(BS,{message:`No runs yet. Run a scenario to see its trials.`});let f=e=>t.find(t=>t.id===e)?.name??e,p=7+d.columns.length+ +!!d.overflow.length;return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-[13px] text-kumo-subtle`,children:o?`Each trial ran in its own workspace; open one to browse the files the agent left.`:`Every trial of the matching runs; open one for its trajectory and scores.`}),(0,Y.jsx)(ow,{selection:s,facets:u,label:o?`Filter workspaces`:`Filter trials`,count:`${l.length} trials of ${c.runCount} of ${c.totalRuns} matching runs`}),d.constant.length?(0,Y.jsxs)(`p`,{className:`constant-parameters flex flex-wrap items-center gap-1 text-[13px] text-kumo-subtle`,role:`note`,children:[`Same on every trial shown:`,(0,Y.jsx)(cC,{entries:d.constant})]}):null,c.error?(0,Y.jsx)(AS,{message:c.error}):null,(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:o?`Workspace`:`Trial`}),(0,Y.jsx)($.Head,{children:`Status`}),(0,Y.jsx)($.Head,{children:`Scenario`}),(0,Y.jsx)($.Head,{children:`Score`}),(0,Y.jsx)($.Head,{children:`Started`}),(0,Y.jsx)($.Head,{children:`Run`}),(0,Y.jsx)($.Head,{children:`Commit`}),d.columns.map(e=>(0,Y.jsx)($.Head,{children:e},e)),d.overflow.length?(0,Y.jsx)($.Head,{children:`Other parameters`}):null]})}),(0,Y.jsxs)($.Body,{children:[l.map(({run:e,trial:t})=>(0,Y.jsxs)($.Row,{..._C,children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsxs)(mn,{to:o?ZS(e.id,t.id):XS(e.id,t.id),"data-row-link":!0,className:OS,title:t.id,children:[`Trial `,t.index+1]})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(dw,{status:t.status})}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(mn,{to:tC(e.evalId),className:`${OS} block max-w-[16rem] truncate`,children:f(e.evalId)})}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:fC(t.score)}),(0,Y.jsxs)($.Cell,{className:`whitespace-nowrap tabular-nums`,title:new Date(t.startedAt).toLocaleString(),children:[dC(t.startedAt),t.durationMs===void 0?null:(0,Y.jsxs)(`span`,{className:`ml-2 text-xs text-kumo-subtle`,children:[`took `,pC(t.durationMs)]})]}),(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(mn,{to:YS(e.id),className:`${OS} ${kS}`,title:e.id,children:e.id.slice(0,8)})}),(0,Y.jsx)($.Cell,{className:`whitespace-nowrap`,children:(0,Y.jsx)(_w,{source:e.source})}),d.columns.map(t=>(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(uC,{run:e,name:t})},t)),d.overflow.length?(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(lC,{run:e,keys:d.overflow})}):null]},`${e.id}/${t.id}`)),l.length?null:(0,Y.jsx)(DS,{colSpan:p,children:c.loading?`Loading trials…`:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[`No matching trials.`,(0,Y.jsx)(kp,{size:`xs`,variant:`ghost`,onClick:s.clearFilters,children:`Clear filters`})]})})]})]}),c.more?(0,Y.jsx)(kp,{size:`sm`,variant:`secondary`,className:`self-start`,onClick:c.loadMore,children:`Load trials of older runs`}):null]})}function XT(e){return(0,Y.jsxs)(Et,{children:[(0,Y.jsx)(wt,{path:`/`,element:(0,Y.jsx)(Ct,{to:`/scoreboard`,replace:!0})}),(0,Y.jsx)(wt,{path:`/scoreboard`,element:(0,Y.jsx)(Tw,{...e})}),(0,Y.jsx)(wt,{path:`/runs`,element:(0,Y.jsx)(nE,{...e})}),(0,Y.jsx)(wt,{path:`/runs/:runId`,element:(0,Y.jsx)(iE,{...e})}),(0,Y.jsx)(wt,{path:`/runs/:runId/trials/:trialId`,element:(0,Y.jsx)(aE,{...e})}),(0,Y.jsx)(wt,{path:`/runs/:runId/trials/:trialId/workspace`,element:(0,Y.jsx)(aE,{...e,workspace:!0})}),(0,Y.jsx)(wt,{path:`/trials`,element:(0,Y.jsx)(rE,{...e})}),(0,Y.jsx)(wt,{path:`/workspaces`,element:(0,Y.jsx)(rE,{...e,workspaces:!0})}),(0,Y.jsx)(wt,{path:`/library/agents`,element:(0,Y.jsx)(jC,{...e})}),(0,Y.jsx)(wt,{path:`/library/agents/:id`,element:(0,Y.jsx)($T,{...e})}),(0,Y.jsx)(wt,{path:`/library/judges`,element:(0,Y.jsx)(IC,{...e})}),(0,Y.jsx)(wt,{path:`/library/judges/:id`,element:(0,Y.jsx)(eE,{...e})}),(0,Y.jsx)(wt,{path:`/library/scenarios`,element:(0,Y.jsx)(ZT,{...e})}),(0,Y.jsx)(wt,{path:`/library/scenarios/:id`,element:(0,Y.jsx)(QT,{...e})}),(0,Y.jsx)(wt,{path:`/library/datasets`,element:(0,Y.jsx)(zC,{...e})}),(0,Y.jsx)(wt,{path:`/library/datasets/:id`,element:(0,Y.jsx)(tE,{...e})}),(0,Y.jsx)(wt,{path:`*`,element:(0,Y.jsx)(Ct,{to:`/scoreboard`,replace:!0})})]})}function ZT(e){let[t]=bn(),n=t.get(`suite`)??void 0;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(wC,{section:`scenarios`}),(0,Y.jsx)(dT,{...e,selectedSuiteId:n},n)]})}function QT(e){let{id:t=``}=tt();return(0,Y.jsx)(aT,{...e,evalId:t})}function $T(e){let{id:t=``}=tt();return(0,Y.jsx)(MC,{...e,agentKey:t})}function eE(e){let{id:t=``}=tt();return(0,Y.jsx)(LC,{...e,judgeKey:t})}function tE(e){let{id:t=``}=tt();return(0,Y.jsx)(BC,{...e,datasetId:t})}function nE({catalog:e,suites:t,runs:n}){let[r,i]=bn();return(0,Y.jsx)(mw,{catalog:e,suites:t,runs:n,search:r,onSearchChange:e=>i(e,{replace:!0})})}function rE({workspaces:e=!1,...t}){let[n,r]=bn();return(0,Y.jsx)(YT,{...t,workspaces:e,search:n,onSearchChange:e=>r(e,{replace:!0})})}function iE(e){let{runId:t=``}=tt();return(0,Y.jsx)(yw,{...e,runId:t})}function aE({workspace:e=!1,...t}){let{runId:n=``,trialId:r=``}=tt();return(0,Y.jsx)(KT,{...t,runId:n,trialId:r,workspace:e})}var oE=(0,_.forwardRef)(function({href:e=`/`,...t},n){return(0,Y.jsx)(mn,{ref:n,to:e,...t})}),sE=e=>t=>t===e||t.startsWith(`${e}/`),cE=[{label:`Evals`,sections:[{label:`Scoreboard`,href:`/scoreboard`,icon:up,matches:e=>e===`/`||sE(`/scoreboard`)(e)},{label:`Runs`,href:`/runs`,icon:Uf,matches:e=>sE(`/runs`)(e)&&!/\/trials\//.test(e)},{label:`Trials`,href:`/trials`,icon:rp,matches:e=>sE(`/trials`)(e)||/^\/runs\/[^/]+\/trials\//.test(e)&&!e.endsWith(`/workspace`)},{label:`Workspaces`,href:`/workspaces`,icon:Yf,matches:e=>sE(`/workspaces`)(e)||e.endsWith(`/workspace`)}]},{label:`Library`,sections:[{label:`Agents`,href:`/library/agents`,icon:sp,matches:sE(`/library/agents`)},{label:`Judges`,href:`/library/judges`,icon:Qf,matches:sE(`/library/judges`)},{label:`Scenarios`,href:`/library/scenarios`,icon:Vf,matches:sE(`/library/scenarios`)},{label:`Datasets`,href:`/library/datasets`,icon:Gf,matches:sE(`/library/datasets`)}]}],lE=new Set([`/runs`,`/trials`,`/workspaces`]),uE=cE.flatMap(e=>e.sections);function dE(e){return uE.find(t=>t.matches(e))??uE[0]}function fE(e){return/^\/runs\/[^/]+\/trials\/[^/]+\/workspace$/.test(e)?`Candidate workspace`:/^\/runs\/[^/]+\/trials\//.test(e)?`Trial`:e.startsWith(`/runs/`)?`Run`:dE(e).label}function pE({project:e}){if(!e)return(0,Y.jsx)(`span`,{className:`truncate text-sm font-semibold text-kumo-strong`,children:`EvalKit`});let t=e.repo.split(`/`).slice(1).join(`/`)||e.repo;return(0,Y.jsxs)(`span`,{className:`project-label flex min-w-0 flex-col leading-tight`,title:`${e.repo}${e.project?`/${e.project}`:``} at ${e.commit}${e.ref?` (${e.ref})`:``}${e.dirty?`, with uncommitted changes`:``}`,children:[(0,Y.jsxs)(`span`,{className:`truncate text-sm font-semibold text-kumo-strong`,children:[t,(0,Y.jsxs)(`span`,{className:`font-mono font-normal text-kumo-subtle`,children:[`#`,e.commit.slice(0,7)]})]}),(0,Y.jsx)(`span`,{className:`truncate text-xs text-kumo-subtle`,children:[e.project,e.ref,e.dirty?`dirty`:void 0].filter(Boolean).join(` · `)})]})}function mE({children:e,header:t,project:n}){let{pathname:r,search:i}=Xe(),a=dE(r),o=e=>lE.has(r)&&lE.has(e.href)?`${e.href}${i}`:e.href;return(0,Y.jsx)(Ar,{component:oE,children:(0,Y.jsxs)(xS.Provider,{collapsible:`icon`,defaultWidth:208,className:`h-dvh`,children:[(0,Y.jsxs)(xS,{id:`dashboard-navigation`,children:[(0,Y.jsxs)(xS.Header,{className:`justify-between`,children:[(0,Y.jsx)(mn,{to:`/scoreboard`,className:`min-w-0 group-data-[state=collapsed]/sidebar:hidden`,children:(0,Y.jsx)(pE,{project:n})}),(0,Y.jsx)(xS.Trigger,{className:`navigation-toggle`})]}),(0,Y.jsx)(xS.Content,{children:(0,Y.jsx)(`nav`,{"aria-label":`Dashboard`,children:cE.map((e,t)=>(0,Y.jsxs)(xS.Group,{children:[(0,Y.jsx)(xS.GroupLabel,{children:e.label}),(0,Y.jsx)(xS.Menu,{children:e.sections.map(e=>(0,Y.jsx)(xS.MenuButton,{href:o(e),icon:e.icon,active:e===a,"aria-current":e===a?`page`:void 0,tooltip:e.label,children:e.label},e.href))})]},e.label??t))})})]}),(0,Y.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col overflow-y-auto`,children:[(0,Y.jsxs)(`header`,{className:`sticky top-0 z-10 flex h-12 shrink-0 items-center gap-2 border-b border-kumo-line bg-kumo-base px-4 md:px-6`,children:[(0,Y.jsx)(xS.Trigger,{className:`md:hidden`}),(0,Y.jsx)(`h1`,{className:`text-base font-semibold text-kumo-strong`,children:fE(r)}),t]}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-4 px-4 py-4 md:px-6`,children:e})]})]})})}function hE({share:e}){let[t,n]=(0,_.useState)(),[r,i]=(0,_.useState)();return(0,_.useEffect)(()=>{fetch(e.repos).then(e=>e.json()).then(e=>n(e.repos)).catch(()=>i(`Unable to load repositories`))},[e.repos]),(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-4 px-4 py-8`,children:[(0,Y.jsx)(`h1`,{className:`text-base font-semibold text-kumo-strong`,children:`EvalKit · Shared evals`}),e.missing||e.repo&&!e.data?(0,Y.jsx)(AS,{message:e.missing?`No shared results for ${e.missing} in ${e.repo}.`:`No shared results for ${e.repo}.`}):null,r?(0,Y.jsx)(AS,{message:r}):null,t&&!t.length?(0,Y.jsx)(BS,{message:"Nothing shared yet. Run `evalkit share` in an eval project."}):null,t?.length?(0,Y.jsxs)(TS,{children:[(0,Y.jsx)($.Header,{variant:`compact`,children:(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Head,{children:`Repository`}),(0,Y.jsx)($.Head,{children:`Commits`}),(0,Y.jsx)($.Head,{children:`Last upload`})]})}),(0,Y.jsx)($.Body,{children:t.map(e=>(0,Y.jsxs)($.Row,{children:[(0,Y.jsx)($.Cell,{children:(0,Y.jsx)(`a`,{className:OS,href:`/${e.key}`,children:e.key})}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:e.commits}),(0,Y.jsx)($.Cell,{className:`tabular-nums`,children:e.lastUploadAt.slice(0,16).replace(`T`,` `)})]},e.key))})]}):null]})}function gE(e=document.documentElement){let t=e.dataset.evalkitShare;if(!t)return;let n;try{n=JSON.parse(t)}catch{return}if(typeof n?.repos!=`string`)return;let r=e=>typeof n[e]==`string`?{[e]:n[e]}:{};return{repos:n.repos,...r(`commits`),...r(`data`),...r(`repo`),...r(`missing`)}}function _E(e,t,n,r){let i=/^\/(runs|trials|workspaces)\/./.test(n);return`/${e}/-/${t}${i?`/runs`:n===`/`?`/`:n}${i?``:r}`}function vE(e){let t=(e.committedAt??e.firstSeenAt).slice(0,10),n=e.runs?`${e.passed}/${e.runs} passed`:`no committed runs`;return[e.commit.slice(0,7),e.ref,t,n].filter(Boolean).join(` · `)}function yE({repo:e,current:t,commitsUrl:n}){let r=Xe(),[i,a]=(0,_.useState)();(0,_.useEffect)(()=>{let e=!0;return fetch(n).then(e=>e.json()).then(t=>{e&&a(t.commits)}).catch(()=>{e&&a([])}),()=>{e=!1}},[n]);let o=i?.some(e=>e.commit===t);return(0,Y.jsxs)(`label`,{className:`version-picker ml-auto flex min-w-0 items-center gap-2 text-[13px] text-kumo-subtle`,children:[(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:`Version`}),(0,Y.jsxs)(`select`,{"aria-label":`Version`,className:`max-w-[22rem] min-w-0 truncate rounded-md border border-kumo-line bg-kumo-base px-2 py-1 font-mono text-xs text-kumo-strong`,value:t,onChange:t=>window.location.assign(_E(e,t.target.value,r.pathname,r.search)),children:[o?null:(0,Y.jsx)(`option`,{value:t,children:t.slice(0,7)}),i?.map(e=>(0,Y.jsx)(`option`,{value:e.commit,children:vE(e)},e.commit))]})]})}function bE({api:e,basename:t,share:n}){return n&&!n.data?(0,Y.jsx)(hE,{share:n}):(0,Y.jsx)(pn,{basename:t,children:(0,Y.jsx)(xE,{api:e,share:n,basename:t})})}function xE({api:e,share:t,basename:n}){let r=n?.split(`/-/`)[1],[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(),[u,d]=(0,_.useState)([]),f=(0,_.useRef)(``),[p,m]=(0,_.useState)(),[h,g]=(0,_.useState)([]),[v,y]=(0,_.useState)(()=>SE(t,r));return(0,_.useEffect)(()=>{let n=!0;return Promise.all([e.listCatalog(),e.listSuites(),e.getMatrix(),e.listLoadErrors?.()??[],t?null:e.getProject?.().catch(()=>null)??null]).then(([e,r,i,o,c])=>{n&&(t||y(c),a(e),g(o),s(r),l(i))}).catch(e=>{n&&m(e instanceof Error?e.message:`Unable to load dashboard`)}),()=>{n=!1}},[e]),(0,_.useEffect)(()=>{let t=!0,n=!1,r=async()=>{if(!n){n=!0;try{let n=await e.listRuns();if(t){let e=JSON.stringify(n);e!==f.current&&(f.current=e,d(n))}}catch(e){t&&m(e instanceof Error?e.message:`Unable to load runs`)}finally{n=!1}}};r();let i=setInterval(()=>void r(),2e3);return()=>{t=!1,clearInterval(i)}},[e]),(0,Y.jsxs)(mE,{project:v,header:t?.repo&&t.commits&&r?(0,Y.jsx)(yE,{repo:t.repo,current:r,commitsUrl:t.commits}):void 0,children:[t?.repo?(0,Y.jsxs)(`p`,{className:`text-[13px] text-kumo-subtle`,role:`note`,children:[`Shared results for`,` `,(0,Y.jsx)(`a`,{href:`/${t.repo}`,className:`font-mono`,children:t.repo}),`. Runs cannot be started here.`]}):e.readOnly?(0,Y.jsxs)(`p`,{className:`text-[13px] text-kumo-subtle`,role:`note`,children:[`Read-only snapshot built with `,(0,Y.jsx)(`code`,{children:`evalkit build`}),`. Runs cannot be started here.`]}):null,p?(0,Y.jsx)(AS,{message:p}):null,h.length?(0,Y.jsx)(AS,{title:`${h.length===1?`1 scenario file`:`${h.length} scenario files`} failed to load; their scenarios are missing`,message:h.map(e=>`${e.file}: ${e.error.message}`).join(`
|
|
34
|
+
`)}):null,(0,Y.jsx)(XT,{api:e,catalog:i,suites:o,matrix:c,runs:u})]})}function SE(e,t){if(!e?.repo||!t)return null;let[n,r]=e.repo.split(`/~`);return{repo:n,...r?{project:r}:{},commit:t}}function CE(e){let t=e.fetch??globalThis.fetch,n=async(n,r)=>{let i=await t(new URL(n,e.baseUrl),r);if(!i.ok)throw Error(await i.text()||`Dashboard request failed: ${i.status}`);return i.json()};return{async listCatalog(){return(await n(`/v1/catalog`)).evals},async getProject(){return(await n(`/v1/project`)).project},async listLoadErrors(){return(await n(`/v1/catalog`)).loadErrors??[]},async listMatrixCells(t){let r=new URL(`/v1/matrix/cells`,e.baseUrl);for(let e of t.evalIds)r.searchParams.append(`eval`,e);return r.searchParams.set(`q`,t.query),r.searchParams.set(`offset`,String(t.offset)),r.searchParams.set(`sort`,t.sort),r.searchParams.set(`direction`,t.direction),n(r.pathname+r.search)},async getMatrix(){return(await n(`/v1/matrix`)).matrix},async listEvals(){return(await n(`/v1/evals`)).evals},async listSuites(){return(await n(`/v1/suites`)).suites},async listRuns(){return(await n(`/v1/runs`)).runs},async listTrials(e){return(await n(`/v1/runs/${encodeURIComponent(e)}/trials`)).trials},async getTrial(e,t){return n(`/v1/runs/${encodeURIComponent(e)}/trials/${encodeURIComponent(t)}`)},async listArtifacts(e,t){return(await n(`/v1/runs/${encodeURIComponent(e)}/trials/${encodeURIComponent(t)}/artifacts`)).artifacts},async listWorkspace(e,t){return n(`/v1/runs/${encodeURIComponent(e)}/trials/${encodeURIComponent(t)}/workspace`)},async getWorkspaceFile(n,r,i){let a=await t(new URL(`/v1/runs/${encodeURIComponent(n)}/trials/${encodeURIComponent(r)}/workspace/${wE(i)}`,e.baseUrl));if(!a.ok)throw Error(`Dashboard request failed: ${a.status}`);return a},async listDatasetFiles(e){return n(`/v1/datasets/${encodeURIComponent(e)}/files`)},async getDatasetFile(n,r){let i=await t(new URL(`/v1/datasets/${encodeURIComponent(n)}/files/${wE(r)}`,e.baseUrl));if(!i.ok)throw Error(`Dashboard request failed: ${i.status}`);return i},async getTrialEvents(e,t){return(await n(`/v1/runs/${encodeURIComponent(e)}/trials/${encodeURIComponent(t)}/events`)).events},async runEval(e,t){await n(`/v1/runs`,{method:`POST`,body:JSON.stringify({path:e,...t?{parameters:t}:{}}),headers:{"content-type":`application/json`}})},async runSuite(e){await n(`/v1/suites/${encodeURIComponent(e)}/runs`,{method:`POST`})}}}function wE(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}var TE="This is a read-only dashboard snapshot. Run evals with `evalkit run`, then rebuild it with `evalkit build`.";function EE(e){let t=e.fetch??globalThis.fetch,n=t=>new URL(`data/${t}`,e.baseUrl),r=async e=>{let r=await t(n(e));if(!r.ok)throw Error(e.includes(`/workspace/`)||/^datasets\/[^/]+\/files\//.test(e)?`This file is listed, but its contents were not shared.`:`Snapshot file is missing: data/${e}`);return r},i=async e=>(await r(e)).json(),a=(e,t)=>`runs/${encodeURIComponent(e)}/trials/${encodeURIComponent(t)}`;return{readOnly:!0,listCatalog:async()=>(await i(`catalog.json`)).evals,getProject:async()=>(await i(`project.json`).catch(()=>({project:null}))).project,getMatrix:async()=>null,listMatrixCells:async()=>{throw Error(TE)},listEvals:async()=>(await i(`evals.json`)).evals,listSuites:async()=>(await i(`suites.json`)).suites,listRuns:async()=>(await i(`runs.json`)).runs,listTrials:async e=>(await i(`runs/${encodeURIComponent(e)}/trials.json`)).trials,getTrial:(e,t)=>i(`${a(e,t)}/detail.json`),getTrialEvents:async(e,t)=>(await i(`${a(e,t)}/events.json`)).events,listArtifacts:async(e,t)=>(await i(`${a(e,t)}/artifacts.json`)).artifacts,listWorkspace:(e,t)=>i(`${a(e,t)}/workspace.json`),getWorkspaceFile:(e,t,n)=>r(`${a(e,t)}/workspace/${n.split(`/`).map(encodeURIComponent).join(`/`)}`),listDatasetFiles:e=>i(`datasets/${encodeURIComponent(e)}/files.json`),getDatasetFile:(e,t)=>r(`datasets/${encodeURIComponent(e)}/files/${wE(t)}`),runEval:async()=>{throw Error(TE)},runSuite:async()=>{throw Error(TE)}}}var DE=document.querySelector(`#root`);if(!DE)throw Error(`Dashboard root is missing`);var OE=document.documentElement.dataset.evalkitSnapshot===`static`,kE=gE(),AE=OE?EE({baseUrl:kE?.data?new URL(kE.data,window.location.origin).href:document.baseURI}):CE({baseUrl:window.location.origin}),jE=OE&&new URL(document.baseURI).pathname.replace(/\/$/,``)||void 0;(0,SS.createRoot)(DE).render((0,Y.jsx)(bE,{api:AE,basename:jE,share:kE}));
|