agentv 4.30.0 → 4.31.0-next.1

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.
Files changed (26) hide show
  1. package/dist/{artifact-writer-JJLJUUUY.js → artifact-writer-K4B2S7OE.js} +4 -4
  2. package/dist/{chunk-L3FMZXCD.js → chunk-2Z2V7RJO.js} +12 -29
  3. package/dist/{chunk-L3FMZXCD.js.map → chunk-2Z2V7RJO.js.map} +1 -1
  4. package/dist/{chunk-B2YJVU72.js → chunk-BCZHBAUK.js} +43 -55
  5. package/dist/chunk-BCZHBAUK.js.map +1 -0
  6. package/dist/{chunk-YFVD6FC6.js → chunk-BMSSZSND.js} +3 -3
  7. package/dist/{chunk-LUZRCQNH.js → chunk-FLSABQ33.js} +12 -12
  8. package/dist/chunk-FLSABQ33.js.map +1 -0
  9. package/dist/{chunk-J4AMO3MD.js → chunk-NACNTFNH.js} +9 -9
  10. package/dist/{chunk-J4AMO3MD.js.map → chunk-NACNTFNH.js.map} +1 -1
  11. package/dist/cli.js +5 -5
  12. package/dist/{dist-GYCHDLTZ.js → dist-2E6ZNN32.js} +5 -5
  13. package/dist/index.js +5 -5
  14. package/dist/{interactive-DIQOOZX4.js → interactive-22PLS22Z.js} +5 -5
  15. package/dist/studio/assets/{index-SVeKAE-f.js → index-Bh_LwYWq.js} +1 -1
  16. package/dist/studio/assets/{index-BUmBj4ej.js → index-DsVyXC9S.js} +1 -1
  17. package/dist/studio/index.html +1 -1
  18. package/dist/{ts-eval-loader-JL5DGTJL-U5LTKGOE.js → ts-eval-loader-TWWSN6OX-VRZ43CUR.js} +2 -2
  19. package/package.json +1 -1
  20. package/dist/chunk-B2YJVU72.js.map +0 -1
  21. package/dist/chunk-LUZRCQNH.js.map +0 -1
  22. /package/dist/{artifact-writer-JJLJUUUY.js.map → artifact-writer-K4B2S7OE.js.map} +0 -0
  23. /package/dist/{chunk-YFVD6FC6.js.map → chunk-BMSSZSND.js.map} +0 -0
  24. /package/dist/{dist-GYCHDLTZ.js.map → dist-2E6ZNN32.js.map} +0 -0
  25. /package/dist/{interactive-DIQOOZX4.js.map → interactive-22PLS22Z.js.map} +0 -0
  26. /package/dist/{ts-eval-loader-JL5DGTJL-U5LTKGOE.js.map → ts-eval-loader-TWWSN6OX-VRZ43CUR.js.map} +0 -0
@@ -113,4 +113,4 @@ Error generating stack: `+f.message+`
113
113
  *
114
114
  * This source code is licensed under the MIT license found in the
115
115
  * LICENSE file in the root directory of this source tree.
116
- */var tP;function sX(){if(tP)return et;tP=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),x=Symbol.for("react.client.reference");function S(w){if(typeof w=="object"&&w!==null){var O=w.$$typeof;switch(O){case e:switch(w=w.type,w){case r:case i:case n:case d:case h:case g:return w;default:switch(w=w&&w.$$typeof,w){case u:case c:case p:case m:return w;case l:return w;default:return O}}case t:return O}}}return et.ContextConsumer=l,et.ContextProvider=u,et.Element=e,et.ForwardRef=c,et.Fragment=r,et.Lazy=p,et.Memo=m,et.Portal=t,et.Profiler=i,et.StrictMode=n,et.Suspense=d,et.SuspenseList=h,et.isContextConsumer=function(w){return S(w)===l},et.isContextProvider=function(w){return S(w)===u},et.isElement=function(w){return typeof w=="object"&&w!==null&&w.$$typeof===e},et.isForwardRef=function(w){return S(w)===c},et.isFragment=function(w){return S(w)===r},et.isLazy=function(w){return S(w)===p},et.isMemo=function(w){return S(w)===m},et.isPortal=function(w){return S(w)===t},et.isProfiler=function(w){return S(w)===i},et.isStrictMode=function(w){return S(w)===n},et.isSuspense=function(w){return S(w)===d},et.isSuspenseList=function(w){return S(w)===h},et.isValidElementType=function(w){return typeof w=="string"||typeof w=="function"||w===r||w===i||w===n||w===d||w===h||typeof w=="object"&&w!==null&&(w.$$typeof===p||w.$$typeof===m||w.$$typeof===u||w.$$typeof===l||w.$$typeof===c||w.$$typeof===x||w.getModuleId!==void 0)},et.typeOf=S,et}var rP;function lX(){return rP||(rP=1,g0.exports=sX()),g0.exports}var oX=lX(),nP=e=>typeof e=="string"?e:e?e.displayName||e.name||"Component":"",aP=null,x0=null,RD=e=>{if(e===aP&&Array.isArray(x0))return x0;var t=[];return j.Children.forEach(e,r=>{ht(r)||(oX.isFragment(r)?t=t.concat(RD(r.props.children)):t.push(r))}),x0=t,aP=e,t};function uX(e,t){var r=[],n=[];return Array.isArray(t)?n=t.map(i=>nP(i)):n=[nP(t)],RD(e).forEach(i=>{var l=Co(i,"type.displayName")||Co(i,"type.name");l&&n.indexOf(l)!==-1&&r.push(i)}),r}var DD=e=>e&&typeof e=="object"&&"clipDot"in e?!!e.clipDot:!0,b0={},iP;function cX(){return iP||(iP=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){var i;if(typeof r!="object"||r==null)return!1;if(Object.getPrototypeOf(r)===null)return!0;if(Object.prototype.toString.call(r)!=="[object Object]"){const l=r[Symbol.toStringTag];return l==null||!((i=Object.getOwnPropertyDescriptor(r,Symbol.toStringTag))!=null&&i.writable)?!1:r.toString()===`[object ${l}]`}let n=r;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(r)===n}e.isPlainObject=t})(b0)),b0}var S0,sP;function fX(){return sP||(sP=1,S0=cX().isPlainObject),S0}var dX=fX();const hX=Zi(dX);var lP,oP,uP,cP,fP;function dP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function hP(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?dP(Object(r),!0).forEach(function(n){mX(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function mX(e,t,r){return(t=pX(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function pX(e){var t=vX(e,"string");return typeof t=="symbol"?t:t+""}function vX(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function um(){return um=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},um.apply(null,arguments)}function oc(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var mP=(e,t,r,n,i)=>{var l=r-n,u;return u=gt(lP||(lP=oc(["M ",",",""])),e,t),u+=gt(oP||(oP=oc(["L ",",",""])),e+r,t),u+=gt(uP||(uP=oc(["L ",",",""])),e+r-l/2,t+i),u+=gt(cP||(cP=oc(["L ",",",""])),e+r-l/2-n,t+i),u+=gt(fP||(fP=oc(["L ",","," Z"])),e,t),u},yX={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},gX=e=>{var t=sr(e,yX),{x:r,y:n,upperWidth:i,lowerWidth:l,height:u,className:c}=t,{animationEasing:d,animationDuration:h,animationBegin:m,isUpdateAnimationActive:p}=t,g=j.useRef(null),[x,S]=j.useState(-1),w=j.useRef(i),O=j.useRef(l),_=j.useRef(u),E=j.useRef(r),T=j.useRef(n),A=Fm(e,"trapezoid-");if(j.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var te=g.current.getTotalLength();te&&S(te)}catch{}},[]),r!==+r||n!==+n||i!==+i||l!==+l||u!==+u||i===0&&l===0||u===0)return null;var C=Qe("recharts-trapezoid",c);if(!p)return j.createElement("g",null,j.createElement("path",um({},jr(t),{className:C,d:mP(r,n,i,l,u)})));var M=w.current,R=O.current,z=_.current,$=E.current,D=T.current,H="0px ".concat(x===-1?1:x,"px"),U="".concat(x,"px ").concat(x,"px"),ie=K2(["strokeDasharray"],h,d);return j.createElement(Km,{animationId:A,key:A,canBegin:x>0,duration:h,easing:d,isActive:p,begin:m},te=>{var ae=xt(M,i,te),q=xt(R,l,te),V=xt(z,u,te),ne=xt($,r,te),se=xt(D,n,te);g.current&&(w.current=ae,O.current=q,_.current=V,E.current=ne,T.current=se);var fe=te>0?{transition:ie,strokeDasharray:U}:{strokeDasharray:H};return j.createElement("path",um({},jr(t),{className:C,d:mP(ne,se,ae,q,V),ref:g,style:hP(hP({},fe),t.style)}))})},xX=["option","shapeType","activeClassName","inActiveClassName"];function bX(e,t){if(e==null)return{};var r,n,i=SX(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function SX(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function pP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function cm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?pP(Object(r),!0).forEach(function(n){wX(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function wX(e,t,r){return(t=jX(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function jX(e){var t=OX(e,"string");return typeof t=="symbol"?t:t+""}function OX(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function _X(e,t){return cm(cm({},t),e)}function NX(e,t){return e==="symbols"}function vP(e){var{shapeType:t,elementProps:r}=e;switch(t){case"rectangle":return j.createElement(V2,r);case"trapezoid":return j.createElement(gX,r);case"sector":return j.createElement(Z2,r);case"symbols":if(NX(t))return j.createElement(jb,r);break;case"curve":return j.createElement(H2,r);default:return null}}function EX(e){return j.isValidElement(e)?e.props:e}function kD(e){var{option:t,shapeType:r,activeClassName:n="recharts-active-shape",inActiveClassName:i="recharts-shape"}=e,l=bX(e,xX),u;if(j.isValidElement(t))u=j.cloneElement(t,cm(cm({},l),EX(t)));else if(typeof t=="function")u=t(l,l.index);else if(hX(t)&&typeof t!="boolean"){var c=_X(t,l);u=j.createElement(vP,{shapeType:r,elementProps:c})}else{var d=l;u=j.createElement(vP,{shapeType:r,elementProps:d})}return l.isActive?j.createElement(en,{className:n},u):j.createElement(en,{className:i},u)}var ID=(e,t,r)=>{var n=ut();return(i,l)=>u=>{e==null||e(i,l,u),n(H4({activeIndex:String(l),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:r}))}},LD=e=>{var t=ut();return(r,n)=>i=>{e==null||e(r,n,i),t(KY())}},zD=(e,t,r)=>{var n=ut();return(i,l)=>u=>{e==null||e(i,l,u),n(FY({activeIndex:String(l),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:r}))}};function $D(e){var{tooltipEntrySettings:t}=e,r=ut(),n=vr(),i=j.useRef(null);return j.useLayoutEffect(()=>{n||(i.current===null?r(BY(t)):i.current!==t&&r(UY({prev:i.current,next:t})),i.current=t)},[t,r,n]),j.useLayoutEffect(()=>()=>{i.current&&(r(qY(i.current)),i.current=null)},[r]),null}function BD(e){var{legendPayload:t}=e,r=ut(),n=vr(),i=j.useRef(null);return j.useLayoutEffect(()=>{n||(i.current===null?r(Pq(t)):i.current!==t&&r(Cq({prev:i.current,next:t})),i.current=t)},[r,n,t]),j.useLayoutEffect(()=>()=>{i.current&&(r(Mq(i.current)),i.current=null)},[r]),null}var w0,AX=()=>{var[e]=j.useState(()=>Nc("uid-"));return e},TX=(w0=N5.useId)!==null&&w0!==void 0?w0:AX;function PX(e,t){var r=TX();return t||(e?"".concat(e,"-").concat(r):r)}var CX=j.createContext(void 0),UD=e=>{var{id:t,type:r,children:n}=e,i=PX("recharts-".concat(r),t);return j.createElement(CX.Provider,{value:i},n(i))},MX={cartesianItems:[],polarItems:[]},qD=pr({name:"graphicalItems",initialState:MX,reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(t.payload)},prepare:lt()},replaceCartesianGraphicalItem:{reducer(e,t){var{prev:r,next:n}=t.payload,i=bn(e).cartesianItems.indexOf(r);i>-1&&(e.cartesianItems[i]=n)},prepare:lt()},removeCartesianGraphicalItem:{reducer(e,t){var r=bn(e).cartesianItems.indexOf(t.payload);r>-1&&e.cartesianItems.splice(r,1)},prepare:lt()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(t.payload)},prepare:lt()},removePolarGraphicalItem:{reducer(e,t){var r=bn(e).polarItems.indexOf(t.payload);r>-1&&e.polarItems.splice(r,1)},prepare:lt()},replacePolarGraphicalItem:{reducer(e,t){var{prev:r,next:n}=t.payload,i=bn(e).polarItems.indexOf(r);i>-1&&(e.polarItems[i]=n)},prepare:lt()}}}),{addCartesianGraphicalItem:RX,replaceCartesianGraphicalItem:DX,removeCartesianGraphicalItem:kX,addPolarGraphicalItem:pne,removePolarGraphicalItem:vne,replacePolarGraphicalItem:yne}=qD.actions,IX=qD.reducer,LX=e=>{var t=ut(),r=j.useRef(null);return j.useLayoutEffect(()=>{r.current===null?t(RX(e)):r.current!==e&&t(DX({prev:r.current,next:e})),r.current=e},[t,e]),j.useLayoutEffect(()=>()=>{r.current&&(t(kX(r.current)),r.current=null)},[t]),null},HD=j.memo(LX),zX=["points"];function yP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function j0(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?yP(Object(r),!0).forEach(function(n){$X(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):yP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function $X(e,t,r){return(t=BX(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function BX(e){var t=UX(e,"string");return typeof t=="symbol"?t:t+""}function UX(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function fm(){return fm=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},fm.apply(null,arguments)}function qX(e,t){if(e==null)return{};var r,n,i=HX(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function HX(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function KX(e){var{option:t,dotProps:r,className:n}=e;if(j.isValidElement(t))return j.cloneElement(t,r);if(typeof t=="function")return t(r);var i=Qe(n,typeof t!="boolean"?t.className:""),l=r??{},{points:u}=l,c=qX(l,zX);return j.createElement(CD,fm({},c,{className:i}))}function FX(e,t){return e==null?!1:t?!0:e.length===1}function YX(e){var{points:t,dot:r,className:n,dotClassName:i,dataKey:l,baseProps:u,needClip:c,clipPathId:d,zIndex:h=Ft.scatter}=e;if(!FX(t,r))return null;var m=DD(r),p=v8(r),g=t.map((S,w)=>{var O,_,E=j0(j0(j0({r:3},u),p),{},{index:w,cx:(O=S.x)!==null&&O!==void 0?O:void 0,cy:(_=S.y)!==null&&_!==void 0?_:void 0,dataKey:l,value:S.value,payload:S.payload,points:t});return j.createElement(KX,{key:"dot-".concat(w),option:r,dotProps:E,className:i})}),x={};return c&&d!=null&&(x.clipPath="url(#clipPath-".concat(m?"":"dots-").concat(d,")")),j.createElement(_n,{zIndex:h},j.createElement(en,fm({className:n},x),g))}function gP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function xP(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?gP(Object(r),!0).forEach(function(n){GX(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):gP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function GX(e,t,r){return(t=VX(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function VX(e){var t=QX(e,"string");return typeof t=="symbol"?t:t+""}function QX(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var KD=0,XX={xAxis:{},yAxis:{},zAxis:{}},FD=pr({name:"cartesianAxis",initialState:XX,reducers:{addXAxis:{reducer(e,t){e.xAxis[t.payload.id]=t.payload},prepare:lt()},replaceXAxis:{reducer(e,t){var{prev:r,next:n}=t.payload;e.xAxis[r.id]!==void 0&&(r.id!==n.id&&delete e.xAxis[r.id],e.xAxis[n.id]=n)},prepare:lt()},removeXAxis:{reducer(e,t){delete e.xAxis[t.payload.id]},prepare:lt()},addYAxis:{reducer(e,t){e.yAxis[t.payload.id]=t.payload},prepare:lt()},replaceYAxis:{reducer(e,t){var{prev:r,next:n}=t.payload;e.yAxis[r.id]!==void 0&&(r.id!==n.id&&delete e.yAxis[r.id],e.yAxis[n.id]=n)},prepare:lt()},removeYAxis:{reducer(e,t){delete e.yAxis[t.payload.id]},prepare:lt()},addZAxis:{reducer(e,t){e.zAxis[t.payload.id]=t.payload},prepare:lt()},replaceZAxis:{reducer(e,t){var{prev:r,next:n}=t.payload;e.zAxis[r.id]!==void 0&&(r.id!==n.id&&delete e.zAxis[r.id],e.zAxis[n.id]=n)},prepare:lt()},removeZAxis:{reducer(e,t){delete e.zAxis[t.payload.id]},prepare:lt()},updateYAxisWidth(e,t){var{id:r,width:n}=t.payload,i=e.yAxis[r];if(i){var l,u=i.widthHistory||[];if(u.length===3&&u[0]===u[2]&&n===u[1]&&n!==i.width&&Math.abs(n-((l=u[0])!==null&&l!==void 0?l:0))<=1)return;var c=[...u,n].slice(-3);e.yAxis[r]=xP(xP({},i),{},{width:n,widthHistory:c})}}}}),{addXAxis:ZX,replaceXAxis:WX,removeXAxis:JX,addYAxis:eZ,replaceYAxis:tZ,removeYAxis:rZ,addZAxis:gne,replaceZAxis:xne,removeZAxis:bne,updateYAxisWidth:nZ}=FD.actions,aZ=FD.reducer,iZ=G([Yt],e=>({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),sZ=G([iZ,Ga,Va],(e,t,r)=>{if(!(!e||t==null||r==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,r-e.top-e.bottom)}}),KS=()=>ye(sZ),lZ=()=>ye(BG);function bP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function O0(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?bP(Object(r),!0).forEach(function(n){oZ(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):bP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function oZ(e,t,r){return(t=uZ(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function uZ(e){var t=cZ(e,"string");return typeof t=="symbol"?t:t+""}function cZ(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var fZ=e=>{var{point:t,childIndex:r,mainColor:n,activeDot:i,dataKey:l,clipPath:u}=e;if(i===!1||t.x==null||t.y==null)return null;var c={index:r,dataKey:l,cx:t.x,cy:t.y,r:4,fill:n??"none",strokeWidth:2,stroke:"#fff",payload:t.payload,value:t.value},d=O0(O0(O0({},c),Qc(i)),Ob(i)),h;return j.isValidElement(i)?h=j.cloneElement(i,d):typeof i=="function"?h=i(d):h=j.createElement(CD,d),j.createElement(en,{className:"recharts-active-dot",clipPath:u},h)};function dZ(e){var{points:t,mainColor:r,activeDot:n,itemDataKey:i,clipPath:l,zIndex:u=Ft.activeDot}=e,c=ye(rl),d=lZ();if(t==null||d==null)return null;var h=t.find(m=>d.includes(m.payload));return ht(h)?null:j.createElement(_n,{zIndex:u},j.createElement(fZ,{point:h,childIndex:Number(c),mainColor:r,dataKey:i,activeDot:n,clipPath:l}))}var SP=(e,t,r)=>{var n=r??e;if(!ht(n))return kn(n,t,0)},hZ=(e,t,r)=>{var n={},i=e.filter(Zm),l=e.filter(h=>h.stackId==null),u=i.reduce((h,m)=>{var p=h[m.stackId];return p==null&&(p=[]),p.push(m),h[m.stackId]=p,h},n),c=Object.entries(u).map(h=>{var m,[p,g]=h,x=g.map(w=>w.dataKey),S=SP(t,r,(m=g[0])===null||m===void 0?void 0:m.barSize);return{stackId:p,dataKeys:x,barSize:S}}),d=l.map(h=>{var m=[h.dataKey].filter(g=>g!=null),p=SP(t,r,h.barSize);return{stackId:void 0,dataKeys:m,barSize:p}});return[...c,...d]};function wP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Wd(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?wP(Object(r),!0).forEach(function(n){mZ(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function mZ(e,t,r){return(t=pZ(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function pZ(e){var t=vZ(e,"string");return typeof t=="symbol"?t:t+""}function vZ(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function yZ(e,t,r,n,i){var l,u=n.length;if(!(u<1)){var c=kn(e,r,0,!0),d,h=[];if(Be((l=n[0])===null||l===void 0?void 0:l.barSize)){var m=!1,p=r/u,g=n.reduce((E,T)=>E+(T.barSize||0),0);g+=(u-1)*c,g>=r&&(g-=(u-1)*c,c=0),g>=r&&p>0&&(m=!0,p*=.9,g=u*p);var x=(r-g)/2>>0,S={offset:x-c,size:0};d=n.reduce((E,T)=>{var A,C={stackId:T.stackId,dataKeys:T.dataKeys,position:{offset:S.offset+S.size+c,size:m?p:(A=T.barSize)!==null&&A!==void 0?A:0}},M=[...E,C];return S=C.position,M},h)}else{var w=kn(t,r,0,!0);r-2*w-(u-1)*c<=0&&(c=0);var O=(r-2*w-(u-1)*c)/u;O>1&&(O>>=0);var _=Be(i)?Math.min(O,i):O;d=n.reduce((E,T,A)=>[...E,{stackId:T.stackId,dataKeys:T.dataKeys,position:{offset:w+(O+c)*A+(O-_)/2,size:_}}],h)}return d}}var gZ=(e,t,r,n,i,l,u)=>{var c=ht(u)?t:u,d=yZ(r,n,i!==l?i:l,e,c);return i!==l&&d!=null&&(d=d.map(h=>Wd(Wd({},h),{},{position:Wd(Wd({},h.position),{},{offset:h.position.offset-i/2})}))),d},xZ=(e,t)=>{var r=Zb(t);if(!(!e||r==null||t==null)){var{stackId:n}=t;if(n!=null){var i=e[n];if(i){var{stackedData:l}=i;if(l)return l.find(u=>u.key===r)}}}},bZ=(e,t)=>{if(!(e==null||t==null)){var r=e.find(n=>n.stackId===t.stackId&&t.dataKey!=null&&n.dataKeys.includes(t.dataKey));if(r!=null)return r.position}};function SZ(e,t){return e&&typeof e=="object"&&"zIndex"in e&&typeof e.zIndex=="number"&&Be(e.zIndex)?e.zIndex:t}var wZ=e=>{var{chartData:t}=e,r=ut(),n=vr();return j.useEffect(()=>n?()=>{}:(r(IT(t)),()=>{r(IT(void 0))}),[t,r,n]),null},jP={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},YD=pr({name:"brush",initialState:jP,reducers:{setBrushSettings(e,t){return t.payload==null?jP:t.payload}}}),{setBrushSettings:Sne}=YD.actions,jZ=YD.reducer;function OZ(e){return(e%180+180)%180}var _Z=function(t){var{width:r,height:n}=t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,l=OZ(i),u=l*Math.PI/180,c=Math.atan(n/r),d=u>c&&u<Math.PI-c?n/Math.sin(u):r/Math.cos(u);return Math.abs(d)},NZ={dots:[],areas:[],lines:[]},GD=pr({name:"referenceElements",initialState:NZ,reducers:{addDot:(e,t)=>{e.dots.push(t.payload)},removeDot:(e,t)=>{var r=bn(e).dots.findIndex(n=>n===t.payload);r!==-1&&e.dots.splice(r,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var r=bn(e).areas.findIndex(n=>n===t.payload);r!==-1&&e.areas.splice(r,1)},addLine:(e,t)=>{e.lines.push(t.payload)},removeLine:(e,t)=>{var r=bn(e).lines.findIndex(n=>n===t.payload);r!==-1&&e.lines.splice(r,1)}}}),{addDot:wne,removeDot:jne,addArea:One,removeArea:_ne,addLine:Nne,removeLine:Ene}=GD.actions,EZ=GD.reducer,AZ=j.createContext(void 0),TZ=e=>{var{children:t}=e,[r]=j.useState("".concat(Nc("recharts"),"-clip")),n=KS();if(n==null)return null;var{x:i,y:l,width:u,height:c}=n;return j.createElement(AZ.Provider,{value:r},j.createElement("defs",null,j.createElement("clipPath",{id:r},j.createElement("rect",{x:i,y:l,height:c,width:u}))),t)};function VD(e,t){if(t<1)return[];if(t===1)return e;for(var r=[],n=0;n<e.length;n+=t){var i=e[n];i!==void 0&&r.push(i)}return r}function PZ(e,t,r){var n={width:e.width+t.width,height:e.height+t.height};return _Z(n,r)}function CZ(e,t,r){var n=r==="width",{x:i,y:l,width:u,height:c}=e;return t===1?{start:n?i:l,end:n?i+u:l+c}:{start:n?i+u:l+c,end:n?i:l}}function Bc(e,t,r,n,i){if(e*t<e*n||e*t>e*i)return!1;var l=r();return e*(t-e*l/2-n)>=0&&e*(t+e*l/2-i)<=0}function MZ(e,t){return VD(e,t+1)}function RZ(e,t,r,n,i){for(var l=(n||[]).slice(),{start:u,end:c}=t,d=0,h=1,m=u,p=function(){var S=n==null?void 0:n[d];if(S===void 0)return{v:VD(n,h)};var w=d,O,_=()=>(O===void 0&&(O=r(S,w)),O),E=S.coordinate,T=d===0||Bc(e,E,_,m,c);T||(d=0,m=u,h+=1),T&&(m=E+e*(_()/2+i),d+=h)},g;h<=l.length;)if(g=p(),g)return g.v;return[]}function DZ(e,t,r,n,i){var l=(n||[]).slice(),u=l.length;if(u===0)return[];for(var{start:c,end:d}=t,h=1;h<=u;h++){for(var m=(u-1)%h,p=c,g=!0,x=function(){var A=n[w];if(A==null)return 0;var C=w,M,R=()=>(M===void 0&&(M=r(A,C)),M),z=A.coordinate,$=w===m||Bc(e,z,R,p,d);if(!$)return g=!1,1;$&&(p=z+e*(R()/2+i))},S,w=m;w<u&&(S=x(),!(S!==0&&S===1));w+=h);if(g){for(var O=[],_=m;_<u;_+=h){var E=n[_];E!=null&&O.push(E)}return O}}return[]}function OP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function fr(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?OP(Object(r),!0).forEach(function(n){kZ(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):OP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function kZ(e,t,r){return(t=IZ(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function IZ(e){var t=LZ(e,"string");return typeof t=="symbol"?t:t+""}function LZ(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function zZ(e,t,r,n,i){for(var l=(n||[]).slice(),u=l.length,{start:c}=t,{end:d}=t,h=function(g){var x=l[g];if(x==null)return 1;var S=x,w,O=()=>(w===void 0&&(w=r(x,g)),w);if(g===u-1){var _=e*(S.coordinate+e*O()/2-d);l[g]=S=fr(fr({},S),{},{tickCoord:_>0?S.coordinate-_*e:S.coordinate})}else l[g]=S=fr(fr({},S),{},{tickCoord:S.coordinate});if(S.tickCoord!=null){var E=Bc(e,S.tickCoord,O,c,d);E&&(d=S.tickCoord-e*(O()/2+i),l[g]=fr(fr({},S),{},{isShow:!0}))}},m=u-1;m>=0;m--)h(m);return l}function $Z(e,t,r,n,i,l){var u=(n||[]).slice(),c=u.length,{start:d,end:h}=t;if(l){var m=n[c-1];if(m!=null){var p=r(m,c-1),g=e*(m.coordinate+e*p/2-h);if(u[c-1]=m=fr(fr({},m),{},{tickCoord:g>0?m.coordinate-g*e:m.coordinate}),m.tickCoord!=null){var x=Bc(e,m.tickCoord,()=>p,d,h);x&&(h=m.tickCoord-e*(p/2+i),u[c-1]=fr(fr({},m),{},{isShow:!0}))}}}for(var S=l?c-1:c,w=function(E){var T=u[E];if(T==null)return 1;var A=T,C,M=()=>(C===void 0&&(C=r(T,E)),C);if(E===0){var R=e*(A.coordinate-e*M()/2-d);u[E]=A=fr(fr({},A),{},{tickCoord:R<0?A.coordinate-R*e:A.coordinate})}else u[E]=A=fr(fr({},A),{},{tickCoord:A.coordinate});if(A.tickCoord!=null){var z=Bc(e,A.tickCoord,M,d,h);z&&(d=A.tickCoord+e*(M()/2+i),u[E]=fr(fr({},A),{},{isShow:!0}))}},O=0;O<S;O++)w(O);return u}function FS(e,t,r){var{tick:n,ticks:i,viewBox:l,minTickGap:u,orientation:c,interval:d,tickFormatter:h,unit:m,angle:p}=e;if(!i||!i.length||!n)return[];if(pe(d)||rf.isSsr){var g;return(g=MZ(i,pe(d)?d:0))!==null&&g!==void 0?g:[]}var x=[],S=c==="top"||c==="bottom"?"width":"height",w=m&&S==="width"?gc(m,{fontSize:t,letterSpacing:r}):{width:0,height:0},O=(C,M)=>{var R=typeof h=="function"?h(C.value,M):C.value;return S==="width"?PZ(gc(R,{fontSize:t,letterSpacing:r}),w,p):gc(R,{fontSize:t,letterSpacing:r})[S]},_=i[0],E=i[1],T=i.length>=2&&_!=null&&E!=null?Lr(E.coordinate-_.coordinate):1,A=CZ(l,T,S);return d==="equidistantPreserveStart"?RZ(T,A,O,i,u):d==="equidistantPreserveEnd"?DZ(T,A,O,i,u):(d==="preserveStart"||d==="preserveStartEnd"?x=$Z(T,A,O,i,u,d==="preserveStartEnd"):x=zZ(T,A,O,i,u),x.filter(C=>C.isShow))}var BZ=e=>{var{ticks:t,label:r,labelGapWithTick:n=5,tickSize:i=0,tickMargin:l=0}=e,u=0;if(t){Array.from(t).forEach(m=>{if(m){var p=m.getBoundingClientRect();p.width>u&&(u=p.width)}});var c=r?r.getBoundingClientRect().width:0,d=i+l,h=u+d+c+(r?n:0);return Math.round(h)}return 0},UZ={xAxis:{},yAxis:{}},QD=pr({name:"renderedTicks",initialState:UZ,reducers:{setRenderedTicks:(e,t)=>{var{axisType:r,axisId:n,ticks:i}=t.payload;e[r][n]=i},removeRenderedTicks:(e,t)=>{var{axisType:r,axisId:n}=t.payload;delete e[r][n]}}}),{setRenderedTicks:qZ,removeRenderedTicks:HZ}=QD.actions,KZ=QD.reducer,FZ=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function YZ(e,t){if(e==null)return{};var r,n,i=GZ(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function GZ(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function nl(){return nl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},nl.apply(null,arguments)}function _P(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function yt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?_P(Object(r),!0).forEach(function(n){VZ(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_P(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function VZ(e,t,r){return(t=QZ(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function QZ(e){var t=XZ(e,"string");return typeof t=="symbol"?t:t+""}function XZ(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var $a={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:Ft.axis};function ZZ(e){var{x:t,y:r,width:n,height:i,orientation:l,mirror:u,axisLine:c,otherSvgProps:d}=e;if(!c)return null;var h=yt(yt(yt({},d),Dn(c)),{},{fill:"none"});if(l==="top"||l==="bottom"){var m=+(l==="top"&&!u||l==="bottom"&&u);h=yt(yt({},h),{},{x1:t,y1:r+m*i,x2:t+n,y2:r+m*i})}else{var p=+(l==="left"&&!u||l==="right"&&u);h=yt(yt({},h),{},{x1:t+p*n,y1:r,x2:t+p*n,y2:r+i})}return j.createElement("line",nl({},h,{className:Qe("recharts-cartesian-axis-line",Co(c,"className"))}))}function WZ(e,t,r,n,i,l,u,c,d){var h,m,p,g,x,S,w=c?-1:1,O=e.tickSize||u,_=pe(e.tickCoord)?e.tickCoord:e.coordinate;switch(l){case"top":h=m=e.coordinate,g=r+ +!c*i,p=g-w*O,S=p-w*d,x=_;break;case"left":p=g=e.coordinate,m=t+ +!c*n,h=m-w*O,x=h-w*d,S=_;break;case"right":p=g=e.coordinate,m=t+ +c*n,h=m+w*O,x=h+w*d,S=_;break;default:h=m=e.coordinate,g=r+ +c*i,p=g+w*O,S=p+w*d,x=_;break}return{line:{x1:h,y1:p,x2:m,y2:g},tick:{x,y:S}}}function JZ(e,t){switch(e){case"left":return t?"start":"end";case"right":return t?"end":"start";default:return"middle"}}function eW(e,t){switch(e){case"left":case"right":return"middle";case"top":return t?"start":"end";default:return t?"end":"start"}}function tW(e){var{option:t,tickProps:r,value:n}=e,i,l=Qe(r.className,"recharts-cartesian-axis-tick-value");if(j.isValidElement(t))i=j.cloneElement(t,yt(yt({},r),{},{className:l}));else if(typeof t=="function")i=t(yt(yt({},r),{},{className:l}));else{var u="recharts-cartesian-axis-tick-value";typeof t!="boolean"&&(u=Qe(u,iX(t))),i=j.createElement(qS,nl({},r,{className:u}),n)}return i}function rW(e){var{ticks:t,axisType:r,axisId:n}=e,i=ut();return j.useEffect(()=>{if(n==null||r==null)return sl;var l=t.map(u=>({value:u.value,coordinate:u.coordinate,offset:u.offset,index:u.index}));return i(qZ({ticks:l,axisId:n,axisType:r})),()=>{i(HZ({axisId:n,axisType:r}))}},[i,t,n,r]),null}var nW=j.forwardRef((e,t)=>{var{ticks:r=[],tick:n,tickLine:i,stroke:l,tickFormatter:u,unit:c,padding:d,tickTextProps:h,orientation:m,mirror:p,x:g,y:x,width:S,height:w,tickSize:O,tickMargin:_,fontSize:E,letterSpacing:T,getTicksConfig:A,events:C,axisType:M,axisId:R}=e,z=FS(yt(yt({},A),{},{ticks:r}),E,T),$=Dn(A),D=Qc(n),H=SD($.textAnchor)?$.textAnchor:JZ(m,p),U=eW(m,p),ie={};typeof i=="object"&&(ie=i);var te=yt(yt({},$),{},{fill:"none"},ie),ae=z.map(ne=>yt({entry:ne},WZ(ne,g,x,S,w,m,O,p,_))),q=ae.map(ne=>{var{entry:se,line:fe}=ne;return j.createElement(en,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(se.value,"-").concat(se.coordinate,"-").concat(se.tickCoord)},i&&j.createElement("line",nl({},te,fe,{className:Qe("recharts-cartesian-axis-tick-line",Co(i,"className"))})))}),V=ae.map((ne,se)=>{var fe,I,{entry:X,tick:le}=ne,oe=yt(yt(yt(yt({verticalAnchor:U},$),{},{textAnchor:H,stroke:"none",fill:l},le),{},{index:se,payload:X,visibleTicksCount:z.length,tickFormatter:u,padding:d},h),{},{angle:(fe=(I=h==null?void 0:h.angle)!==null&&I!==void 0?I:$.angle)!==null&&fe!==void 0?fe:0}),ge=yt(yt({},oe),D);return j.createElement(en,nl({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(X.value,"-").concat(X.coordinate,"-").concat(X.tickCoord)},Om(C,X,se)),n&&j.createElement(tW,{option:n,tickProps:ge,value:"".concat(typeof u=="function"?u(X.value,se):X.value).concat(c||"")}))});return j.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(M,"-ticks")},j.createElement(rW,{ticks:z,axisId:R,axisType:M}),V.length>0&&j.createElement(_n,{zIndex:Ft.label},j.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(M,"-tick-labels"),ref:t},V)),q.length>0&&j.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(M,"-tick-lines")},q))}),aW=j.forwardRef((e,t)=>{var{axisLine:r,width:n,height:i,className:l,hide:u,ticks:c,axisType:d,axisId:h}=e,m=YZ(e,FZ),[p,g]=j.useState(""),[x,S]=j.useState(""),w=j.useRef(null);j.useImperativeHandle(t,()=>({getCalculatedWidth:()=>{var _;return BZ({ticks:w.current,label:(_=e.labelRef)===null||_===void 0?void 0:_.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var O=j.useCallback(_=>{if(_){var E=_.getElementsByClassName("recharts-cartesian-axis-tick-value");w.current=E;var T=E[0];if(T){var A=window.getComputedStyle(T),C=A.fontSize,M=A.letterSpacing;(C!==p||M!==x)&&(g(C),S(M))}}},[p,x]);return u||n!=null&&n<=0||i!=null&&i<=0?null:j.createElement(_n,{zIndex:e.zIndex},j.createElement(en,{className:Qe("recharts-cartesian-axis",l)},j.createElement(ZZ,{x:e.x,y:e.y,width:n,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:r,otherSvgProps:Dn(e)}),j.createElement(nW,{ref:O,axisType:d,events:m,fontSize:p,getTicksConfig:e,height:e.height,letterSpacing:x,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:c,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:h}),j.createElement(BQ,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},j.createElement(XQ,{label:e.label,labelRef:e.labelRef}),e.children)))}),YS=j.forwardRef((e,t)=>{var r=sr(e,$a);return j.createElement(aW,nl({},r,{ref:t}))});YS.displayName="CartesianAxis";var iW=["x1","y1","x2","y2","key"],sW=["offset"],lW=["xAxisId","yAxisId"],oW=["xAxisId","yAxisId"];function NP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function dr(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?NP(Object(r),!0).forEach(function(n){uW(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):NP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function uW(e,t,r){return(t=cW(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function cW(e){var t=fW(e,"string");return typeof t=="symbol"?t:t+""}function fW(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ms(){return Ms=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Ms.apply(null,arguments)}function dm(e,t){if(e==null)return{};var r,n,i=dW(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function dW(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var hW=e=>{var{fill:t}=e;if(!t||t==="none")return null;var{fillOpacity:r,x:n,y:i,width:l,height:u,ry:c}=e;return j.createElement("rect",{x:n,y:i,ry:c,width:l,height:u,stroke:"none",fill:t,fillOpacity:r,className:"recharts-cartesian-grid-bg"})};function XD(e){var{option:t,lineItemProps:r}=e,n;if(j.isValidElement(t))n=j.cloneElement(t,r);else if(typeof t=="function")n=t(r);else{var i,{x1:l,y1:u,x2:c,y2:d,key:h}=r,m=dm(r,iW),p=(i=Dn(m))!==null&&i!==void 0?i:{},{offset:g}=p,x=dm(p,sW);n=j.createElement("line",Ms({},x,{x1:l,y1:u,x2:c,y2:d,fill:"none",key:h}))}return n}function mW(e){var{x:t,width:r,horizontal:n=!0,horizontalPoints:i}=e;if(!n||!i||!i.length)return null;var{xAxisId:l,yAxisId:u}=e,c=dm(e,lW),d=i.map((h,m)=>{var p=dr(dr({},c),{},{x1:t,y1:h,x2:t+r,y2:h,key:"line-".concat(m),index:m});return j.createElement(XD,{key:"line-".concat(m),option:n,lineItemProps:p})});return j.createElement("g",{className:"recharts-cartesian-grid-horizontal"},d)}function pW(e){var{y:t,height:r,vertical:n=!0,verticalPoints:i}=e;if(!n||!i||!i.length)return null;var{xAxisId:l,yAxisId:u}=e,c=dm(e,oW),d=i.map((h,m)=>{var p=dr(dr({},c),{},{x1:h,y1:t,x2:h,y2:t+r,key:"line-".concat(m),index:m});return j.createElement(XD,{option:n,lineItemProps:p,key:"line-".concat(m)})});return j.createElement("g",{className:"recharts-cartesian-grid-vertical"},d)}function vW(e){var{horizontalFill:t,fillOpacity:r,x:n,y:i,width:l,height:u,horizontalPoints:c,horizontal:d=!0}=e;if(!d||!t||!t.length||c==null)return null;var h=c.map(p=>Math.round(p+i-i)).sort((p,g)=>p-g);i!==h[0]&&h.unshift(0);var m=h.map((p,g)=>{var x=h[g+1],S=x==null,w=S?i+u-p:x-p;if(w<=0)return null;var O=g%t.length;return j.createElement("rect",{key:"react-".concat(g),y:p,x:n,height:w,width:l,stroke:"none",fill:t[O],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return j.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},m)}function yW(e){var{vertical:t=!0,verticalFill:r,fillOpacity:n,x:i,y:l,width:u,height:c,verticalPoints:d}=e;if(!t||!r||!r.length)return null;var h=d.map(p=>Math.round(p+i-i)).sort((p,g)=>p-g);i!==h[0]&&h.unshift(0);var m=h.map((p,g)=>{var x=h[g+1],S=x==null,w=S?i+u-p:x-p;if(w<=0)return null;var O=g%r.length;return j.createElement("rect",{key:"react-".concat(g),x:p,y:l,width:w,height:c,stroke:"none",fill:r[O],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return j.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},m)}var gW=(e,t)=>{var{xAxis:r,width:n,height:i,offset:l}=e;return O2(FS(dr(dr(dr({},$a),r),{},{ticks:_2(r),viewBox:{x:0,y:0,width:n,height:i}})),l.left,l.left+l.width,t)},xW=(e,t)=>{var{yAxis:r,width:n,height:i,offset:l}=e;return O2(FS(dr(dr(dr({},$a),r),{},{ticks:_2(r),viewBox:{x:0,y:0,width:n,height:i}})),l.top,l.top+l.height,t)},bW={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Ft.grid};function cp(e){var t=Lb(),r=zb(),n=P2(),i=dr(dr({},sr(e,bW)),{},{x:pe(e.x)?e.x:n.left,y:pe(e.y)?e.y:n.top,width:pe(e.width)?e.width:n.width,height:pe(e.height)?e.height:n.height}),{xAxisId:l,yAxisId:u,x:c,y:d,width:h,height:m,syncWithTicks:p,horizontalValues:g,verticalValues:x}=i,S=vr(),w=ye($=>jT($,"xAxis",l,S)),O=ye($=>jT($,"yAxis",u,S));if(!aa(h)||!aa(m)||!pe(c)||!pe(d))return null;var _=i.verticalCoordinatesGenerator||gW,E=i.horizontalCoordinatesGenerator||xW,{horizontalPoints:T,verticalPoints:A}=i;if((!T||!T.length)&&typeof E=="function"){var C=g&&g.length,M=E({yAxis:O?dr(dr({},O),{},{ticks:C?g:O.ticks}):void 0,width:t??h,height:r??m,offset:n},C?!0:p);Lh(Array.isArray(M),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof M,"]")),Array.isArray(M)&&(T=M)}if((!A||!A.length)&&typeof _=="function"){var R=x&&x.length,z=_({xAxis:w?dr(dr({},w),{},{ticks:R?x:w.ticks}):void 0,width:t??h,height:r??m,offset:n},R?!0:p);Lh(Array.isArray(z),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof z,"]")),Array.isArray(z)&&(A=z)}return j.createElement(_n,{zIndex:i.zIndex},j.createElement("g",{className:"recharts-cartesian-grid"},j.createElement(hW,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),j.createElement(vW,Ms({},i,{horizontalPoints:T})),j.createElement(yW,Ms({},i,{verticalPoints:A})),j.createElement(mW,Ms({},i,{offset:n,horizontalPoints:T,xAxis:w,yAxis:O})),j.createElement(pW,Ms({},i,{offset:n,verticalPoints:A,xAxis:w,yAxis:O}))))}cp.displayName="CartesianGrid";var SW={},ZD=pr({name:"errorBars",initialState:SW,reducers:{addErrorBar:(e,t)=>{var{itemId:r,errorBar:n}=t.payload;e[r]||(e[r]=[]),e[r].push(n)},replaceErrorBar:(e,t)=>{var{itemId:r,prev:n,next:i}=t.payload;e[r]&&(e[r]=e[r].map(l=>l.dataKey===n.dataKey&&l.direction===n.direction?i:l))},removeErrorBar:(e,t)=>{var{itemId:r,errorBar:n}=t.payload;e[r]&&(e[r]=e[r].filter(i=>i.dataKey!==n.dataKey||i.direction!==n.direction))}}}),{addErrorBar:Ane,replaceErrorBar:Tne,removeErrorBar:Pne}=ZD.actions,wW=ZD.reducer,jW=["children"];function OW(e,t){if(e==null)return{};var r,n,i=_W(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function _W(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var NW={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},EW=j.createContext(NW);function WD(e){var{children:t}=e,r=OW(e,jW);return j.createElement(EW.Provider,{value:r},t)}function GS(e,t){var r,n,i=ye(h=>Xa(h,e)),l=ye(h=>Za(h,t)),u=(r=i==null?void 0:i.allowDataOverflow)!==null&&r!==void 0?r:kt.allowDataOverflow,c=(n=l==null?void 0:l.allowDataOverflow)!==null&&n!==void 0?n:It.allowDataOverflow,d=u||c;return{needClip:d,needClipX:u,needClipY:c}}function JD(e){var{xAxisId:t,yAxisId:r,clipPathId:n}=e,i=KS(),{needClipX:l,needClipY:u,needClip:c}=GS(t,r);if(!c||!i)return null;var{x:d,y:h,width:m,height:p}=i;return j.createElement("clipPath",{id:"clipPath-".concat(n)},j.createElement("rect",{x:l?d:d-m/2,y:u?h:h-p/2,width:l?m:m*2,height:u?p:p*2}))}var e3=(e,t,r,n)=>Qi(e,"xAxis",t,n),t3=(e,t,r,n)=>Vi(e,"xAxis",t,n),r3=(e,t,r,n)=>Qi(e,"yAxis",r,n),n3=(e,t,r,n)=>Vi(e,"yAxis",r,n),AW=G([Xe,e3,r3,t3,n3],(e,t,r,n,i)=>Ya(e,"xAxis")?Ro(t,n,!1):Ro(r,i,!1)),TW=(e,t,r,n,i)=>i;function PW(e){return e.type==="line"}var CW=G([sp,TW],(e,t)=>e.filter(PW).find(r=>r.id===t)),MW=G([Xe,e3,r3,t3,n3,CW,AW,nf],(e,t,r,n,i,l,u,c)=>{var{chartData:d,dataStartIndex:h,dataEndIndex:m}=c;if(!(l==null||t==null||r==null||n==null||i==null||n.length===0||i.length===0||u==null||e!=="horizontal"&&e!=="vertical")){var{dataKey:p,data:g}=l,x;if(g!=null&&g.length>0?x=g:x=d==null?void 0:d.slice(h,m+1),x!=null)return JW({layout:e,xAxis:t,yAxis:r,xAxisTicks:n,yAxisTicks:i,dataKey:p,bandSize:u,displayedData:x})}});function RW(e){var t=Qc(e),r=3,n=2;if(t!=null){var{r:i,strokeWidth:l}=t,u=Number(i),c=Number(l);return(Number.isNaN(u)||u<0)&&(u=r),(Number.isNaN(c)||c<0)&&(c=n),{r:u,strokeWidth:c}}return{r,strokeWidth:n}}var DW=["id"],kW=["type","layout","connectNulls","needClip","shape"],IW=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function Uc(){return Uc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Uc.apply(null,arguments)}function EP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Zn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?EP(Object(r),!0).forEach(function(n){LW(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):EP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function LW(e,t,r){return(t=zW(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function zW(e){var t=$W(e,"string");return typeof t=="symbol"?t:t+""}function $W(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function VS(e,t){if(e==null)return{};var r,n,i=BW(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function BW(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var UW=e=>{var{dataKey:t,name:r,stroke:n,legendType:i,hide:l}=e;return[{inactive:l,dataKey:t,type:i,color:n,value:km(r,t),payload:e}]},qW=j.memo(e=>{var{dataKey:t,data:r,stroke:n,strokeWidth:i,fill:l,name:u,hide:c,unit:d,tooltipType:h,id:m}=e,p={dataDefinedOnItem:r,getPosition:sl,settings:{stroke:n,strokeWidth:i,fill:l,dataKey:t,nameKey:void 0,name:km(u,t),hide:c,type:h,color:n,unit:d,graphicalItemId:m}};return j.createElement($D,{tooltipEntrySettings:p})}),a3=(e,t)=>"".concat(t,"px ").concat(e,"px");function HW(e,t){for(var r=e.length%2!==0?[...e,0]:e,n=[],i=0;i<t;++i)n.push(...r);return n}var KW=(e,t,r)=>{var n=r.reduce((g,x)=>g+x,0);if(!n)return a3(t,e);for(var i=Math.floor(e/n),l=e%n,u=[],c=0,d=0;c<r.length;d+=(h=r[c])!==null&&h!==void 0?h:0,++c){var h,m=r[c];if(m!=null&&d+m>l){u=[...r.slice(0,c),l-d];break}}var p=u.length%2===0?[0,t]:[t];return[...HW(r,i),...u,...p].map(g=>"".concat(g,"px")).join(", ")};function FW(e){var{clipPathId:t,points:r,props:n}=e,{dot:i,dataKey:l,needClip:u}=n,{id:c}=n,d=VS(n,DW),h=Dn(d);return j.createElement(YX,{points:r,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:l,baseProps:h,needClip:u,clipPathId:t})}function YW(e){var{showLabels:t,children:r,points:n}=e,i=j.useMemo(()=>n==null?void 0:n.map(l=>{var u,c,d={x:(u=l.x)!==null&&u!==void 0?u:0,y:(c=l.y)!==null&&c!==void 0?c:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Zn(Zn({},d),{},{value:l.value,payload:l.payload,viewBox:d,parentViewBox:void 0,fill:void 0})}),[n]);return j.createElement(AD,{value:t?i:void 0},r)}function AP(e){var{clipPathId:t,pathRef:r,points:n,strokeDasharray:i,props:l}=e,{type:u,layout:c,connectNulls:d,needClip:h,shape:m}=l,p=VS(l,kW),g=Zn(Zn({},jr(p)),{},{fill:"none",className:"recharts-line-curve",clipPath:h?"url(#clipPath-".concat(t,")"):void 0,points:n,type:u,layout:c,connectNulls:d,strokeDasharray:i??l.strokeDasharray});return j.createElement(j.Fragment,null,(n==null?void 0:n.length)>1&&j.createElement(kD,Uc({shapeType:"curve",option:m},g,{pathRef:r})),j.createElement(FW,{points:n,clipPathId:t,props:l}))}function GW(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function VW(e){var{clipPathId:t,props:r,pathRef:n,previousPointsRef:i,longestAnimatedLengthRef:l}=e,{points:u,strokeDasharray:c,isAnimationActive:d,animationBegin:h,animationDuration:m,animationEasing:p,animateNewValues:g,width:x,height:S,onAnimationEnd:w,onAnimationStart:O}=r,_=i.current,E=Fm(u,"recharts-line-"),T=j.useRef(E),[A,C]=j.useState(!1),M=!A,R=j.useCallback(()=>{typeof w=="function"&&w(),C(!1)},[w]),z=j.useCallback(()=>{typeof O=="function"&&O(),C(!0)},[O]),$=GW(n.current),D=j.useRef(0);T.current!==E&&(D.current=l.current,T.current=E);var H=D.current;return j.createElement(YW,{points:u,showLabels:M},r.children,j.createElement(Km,{animationId:E,begin:h,duration:m,isActive:d,easing:p,onAnimationEnd:R,onAnimationStart:z,key:E},U=>{var ie=xt(H,$+H,U),te=Math.min(ie,$),ae;if(d)if(c){var q="".concat(c).split(/[,\s]+/gim).map(se=>parseFloat(se));ae=KW(te,$,q)}else ae=a3($,te);else ae=c==null?void 0:String(c);if(U>0&&$>0&&(i.current=u,l.current=Math.max(l.current,te)),_){var V=_.length/u.length,ne=U===1?u:u.map((se,fe)=>{var I=Math.floor(fe*V);if(_[I]){var X=_[I];return Zn(Zn({},se),{},{x:xt(X.x,se.x,U),y:xt(X.y,se.y,U)})}return g?Zn(Zn({},se),{},{x:xt(x*2,se.x,U),y:xt(S/2,se.y,U)}):Zn(Zn({},se),{},{x:se.x,y:se.y})});return i.current=ne,j.createElement(AP,{props:r,points:ne,clipPathId:t,pathRef:n,strokeDasharray:ae})}return j.createElement(AP,{props:r,points:u,clipPathId:t,pathRef:n,strokeDasharray:ae})}),j.createElement(PD,{label:r.label}))}function QW(e){var{clipPathId:t,props:r}=e,n=j.useRef(null),i=j.useRef(0),l=j.useRef(null);return j.createElement(VW,{props:r,clipPathId:t,previousPointsRef:n,longestAnimatedLengthRef:i,pathRef:l})}var XW=(e,t)=>{var r,n;return{x:(r=e.x)!==null&&r!==void 0?r:void 0,y:(n=e.y)!==null&&n!==void 0?n:void 0,value:e.value,errorVal:Ot(e.payload,t)}};class ZW extends j.Component{render(){var{hide:t,dot:r,points:n,className:i,xAxisId:l,yAxisId:u,top:c,left:d,width:h,height:m,id:p,needClip:g,zIndex:x}=this.props;if(t)return null;var S=Qe("recharts-line",i),w=p,{r:O,strokeWidth:_}=RW(r),E=DD(r),T=O*2+_,A=g?"url(#clipPath-".concat(E?"":"dots-").concat(w,")"):void 0;return j.createElement(_n,{zIndex:x},j.createElement(en,{className:S},g&&j.createElement("defs",null,j.createElement(JD,{clipPathId:w,xAxisId:l,yAxisId:u}),!E&&j.createElement("clipPath",{id:"clipPath-dots-".concat(w)},j.createElement("rect",{x:d-T/2,y:c-T/2,width:h+T,height:m+T}))),j.createElement(WD,{xAxisId:l,yAxisId:u,data:n,dataPointFormatter:XW,errorBarOffset:0},j.createElement(QW,{props:this.props,clipPathId:w}))),j.createElement(dZ,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var i3={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:Ft.line,type:"linear"};function WW(e){var t=sr(e,i3),{activeDot:r,animateNewValues:n,animationBegin:i,animationDuration:l,animationEasing:u,connectNulls:c,dot:d,hide:h,isAnimationActive:m,label:p,legendType:g,xAxisId:x,yAxisId:S,id:w}=t,O=VS(t,IW),{needClip:_}=GS(x,S),E=KS(),T=ll(),A=vr(),C=ye(D=>MW(D,x,S,A,w));if(T!=="horizontal"&&T!=="vertical"||C==null||E==null)return null;var{height:M,width:R,x:z,y:$}=E;return j.createElement(ZW,Uc({},O,{id:w,connectNulls:c,dot:d,activeDot:r,animateNewValues:n,animationBegin:i,animationDuration:l,animationEasing:u,isAnimationActive:m,hide:h,label:p,legendType:g,xAxisId:x,yAxisId:S,points:C,layout:T,height:M,width:R,left:z,top:$,needClip:_}))}function JW(e){var{layout:t,xAxis:r,yAxis:n,xAxisTicks:i,yAxisTicks:l,dataKey:u,bandSize:c,displayedData:d}=e;return d.map((h,m)=>{var p=Ot(h,u);if(t==="horizontal"){var g=pE({axis:r,ticks:i,bandSize:c,entry:h,index:m}),x=ht(p)?null:n.scale.map(p);return{x:g,y:x??null,value:p,payload:h}}var S=ht(p)?null:r.scale.map(p),w=pE({axis:n,ticks:l,bandSize:c,entry:h,index:m});return S==null||w==null?null:{x:S,y:w,value:p,payload:h}}).filter(Boolean)}function eJ(e){var t=sr(e,i3),r=vr();return j.createElement(UD,{id:t.id,type:"line"},n=>j.createElement(j.Fragment,null,j.createElement(BD,{legendPayload:UW(t)}),j.createElement(qW,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:n}),j.createElement(HD,{type:"line",id:n,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:r}),j.createElement(WW,Uc({},t,{id:n}))))}var s3=j.memo(eJ,Fo);s3.displayName="Line";function fl(e,t){var r,n;return(r=(n=e.graphicalItems.cartesianItems.find(i=>i.id===t))===null||n===void 0?void 0:n.xAxisId)!==null&&r!==void 0?r:KD}function dl(e,t){var r,n;return(r=(n=e.graphicalItems.cartesianItems.find(i=>i.id===t))===null||n===void 0?void 0:n.yAxisId)!==null&&r!==void 0?r:KD}var tJ="Invariant failed";function rJ(e,t){throw new Error(tJ)}function $x(){return $x=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},$x.apply(null,arguments)}function QS(e){return j.createElement(kD,$x({shapeType:"rectangle",activeClassName:"recharts-active-bar",inActiveClassName:"recharts-inactive-bar"},e))}var nJ=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(n,i)=>{if(pe(t))return t;var l=pe(n)||ht(n);return l?t(n,i):(l||rJ(),r)}},aJ=(e,t,r)=>r,iJ=(e,t)=>t,mf=G([sp,iJ],(e,t)=>e.filter(r=>r.type==="bar").find(r=>r.id===t)),sJ=G([mf],e=>e==null?void 0:e.maxBarSize),lJ=(e,t,r,n)=>n,oJ=G([Xe,sp,fl,dl,aJ],(e,t,r,n,i)=>t.filter(l=>e==="horizontal"?l.xAxisId===r:l.yAxisId===n).filter(l=>l.isPanorama===i).filter(l=>l.hide===!1).filter(l=>l.type==="bar")),uJ=(e,t,r)=>{var n=Xe(e),i=fl(e,t),l=dl(e,t);if(!(i==null||l==null))return n==="horizontal"?Dx(e,"yAxis",l,r):Dx(e,"xAxis",i,r)},cJ=(e,t)=>{var r=Xe(e),n=fl(e,t),i=dl(e,t);if(!(n==null||i==null))return r==="horizontal"?wT(e,"xAxis",n):wT(e,"yAxis",i)},fJ=G([oJ,GH,cJ],hZ),dJ=(e,t,r)=>{var n,i,l=mf(e,t);if(l==null)return 0;var u=fl(e,t),c=dl(e,t);if(u==null||c==null)return 0;var d=Xe(e),h=cR(e),{maxBarSize:m}=l,p=ht(m)?h:m,g,x;return d==="horizontal"?(g=Qi(e,"xAxis",u,r),x=Vi(e,"xAxis",u,r)):(g=Qi(e,"yAxis",c,r),x=Vi(e,"yAxis",c,r)),(n=(i=Ro(g,x,!0))!==null&&i!==void 0?i:p)!==null&&n!==void 0?n:0},l3=(e,t,r)=>{var n=Xe(e),i=fl(e,t),l=dl(e,t);if(!(i==null||l==null)){var u,c;return n==="horizontal"?(u=Qi(e,"xAxis",i,r),c=Vi(e,"xAxis",i,r)):(u=Qi(e,"yAxis",l,r),c=Vi(e,"yAxis",l,r)),Ro(u,c)}},hJ=G([fJ,cR,YH,fR,dJ,l3,sJ],gZ),mJ=(e,t,r)=>{var n=fl(e,t);if(n!=null)return Qi(e,"xAxis",n,r)},pJ=(e,t,r)=>{var n=dl(e,t);if(n!=null)return Qi(e,"yAxis",n,r)},vJ=(e,t,r)=>{var n=fl(e,t);if(n!=null)return Vi(e,"xAxis",n,r)},yJ=(e,t,r)=>{var n=dl(e,t);if(n!=null)return Vi(e,"yAxis",n,r)},gJ=G([hJ,mf],bZ),xJ=G([uJ,mf],xZ),bJ=G([Yt,Rb,mJ,pJ,vJ,yJ,gJ,Xe,zH,l3,xJ,mf,lJ],(e,t,r,n,i,l,u,c,d,h,m,p,g)=>{var{chartData:x,dataStartIndex:S,dataEndIndex:w}=d;if(!(p==null||u==null||t==null||c!=="horizontal"&&c!=="vertical"||r==null||n==null||i==null||l==null||h==null)){var{data:O}=p,_;if(O!=null&&O.length>0?_=O:_=x==null?void 0:x.slice(S,w+1),_!=null)return VJ({layout:c,barSettings:p,pos:u,parentViewBox:t,bandSize:h,xAxis:r,yAxis:n,xAxisTicks:i,yAxisTicks:l,stackedData:m,displayedData:_,offset:e,cells:g,dataStartIndex:S})}}),SJ=["index"];function Bx(){return Bx=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Bx.apply(null,arguments)}function wJ(e,t){if(e==null)return{};var r,n,i=jJ(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function jJ(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var o3=j.createContext(void 0),OJ=e=>{var t=j.useContext(o3);if(t!=null)return t.stackId;if(e!=null)return CU(e)},_J=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),NJ=e=>{var t=j.useContext(o3);if(t!=null){var{stackId:r}=t;return"url(#".concat(_J(r,e),")")}},u3=e=>{var{index:t}=e,r=wJ(e,SJ),n=NJ(t);return j.createElement(en,Bx({className:"recharts-bar-stack-layer",clipPath:n},r))},EJ=["onMouseEnter","onMouseLeave","onClick"],AJ=["value","background","tooltipPosition"],TJ=["id"],PJ=["onMouseEnter","onClick","onMouseLeave"];function Xi(){return Xi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Xi.apply(null,arguments)}function TP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function br(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?TP(Object(r),!0).forEach(function(n){CJ(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):TP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function CJ(e,t,r){return(t=MJ(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function MJ(e){var t=RJ(e,"string");return typeof t=="symbol"?t:t+""}function RJ(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function hm(e,t){if(e==null)return{};var r,n,i=DJ(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function DJ(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var kJ=e=>{var{dataKey:t,name:r,fill:n,legendType:i,hide:l}=e;return[{inactive:l,dataKey:t,type:i,color:n,value:km(r,t),payload:e}]},IJ=j.memo(e=>{var{dataKey:t,stroke:r,strokeWidth:n,fill:i,name:l,hide:u,unit:c,tooltipType:d,id:h}=e,m={dataDefinedOnItem:void 0,getPosition:sl,settings:{stroke:r,strokeWidth:n,fill:i,dataKey:t,nameKey:void 0,name:km(l,t),hide:u,type:d,color:i,unit:c,graphicalItemId:h}};return j.createElement($D,{tooltipEntrySettings:m})});function LJ(e){var t=ye(rl),{data:r,dataKey:n,background:i,allOtherBarProps:l}=e,{onMouseEnter:u,onMouseLeave:c,onClick:d}=l,h=hm(l,EJ),m=ID(u,n,l.id),p=LD(c),g=zD(d,n,l.id);if(!i||r==null)return null;var x=Qc(i);return j.createElement(_n,{zIndex:SZ(i,Ft.barBackground)},r.map((S,w)=>{var{value:O,background:_,tooltipPosition:E}=S,T=hm(S,AJ);if(!_)return null;var A=m(S,w),C=p(S,w),M=g(S,w),R=br(br(br(br(br({option:i,isActive:String(w)===t},T),{},{fill:"#eee"},_),x),Om(h,S,w)),{},{onMouseEnter:A,onMouseLeave:C,onClick:M,dataKey:n,index:w,className:"recharts-bar-background-rectangle"});return j.createElement(QS,Xi({key:"background-bar-".concat(w)},R))}))}function zJ(e){var{showLabels:t,children:r,rects:n}=e,i=n==null?void 0:n.map(l=>{var u={x:l.x,y:l.y,width:l.width,lowerWidth:l.width,upperWidth:l.width,height:l.height};return br(br({},u),{},{value:l.value,payload:l.payload,parentViewBox:l.parentViewBox,viewBox:u,fill:l.fill})});return j.createElement(AD,{value:t?i:void 0},r)}function $J(e){var{shape:t,activeBar:r,baseProps:n,entry:i,index:l,dataKey:u}=e,c=ye(rl),d=ye(iD),h=r&&String(i.originalDataIndex)===c&&(d==null||u===d),[m,p]=j.useState(!1),[g,x]=j.useState(!1);j.useEffect(()=>{var T;return h?(p(!0),T=requestAnimationFrame(()=>{x(!0)})):x(!1),()=>{cancelAnimationFrame(T)}},[h]);var S=j.useCallback(()=>{h||p(!1)},[h]),w=h&&g,O=h||m,_;h?r===!0?_=t:_=r:_=t;var E=j.createElement(QS,Xi({},n,{name:String(n.name)},i,{isActive:w,option:_,index:l,dataKey:u,onTransitionEnd:S}));return O?j.createElement(_n,{zIndex:Ft.activeBar},j.createElement(u3,{index:i.originalDataIndex},E)):E}function BJ(e){var{shape:t,baseProps:r,entry:n,index:i,dataKey:l}=e;return j.createElement(QS,Xi({},r,{name:String(r.name)},n,{isActive:!1,option:t,index:i,dataKey:l}))}function UJ(e){var t,{data:r,props:n}=e,i=(t=Dn(n))!==null&&t!==void 0?t:{},{id:l}=i,u=hm(i,TJ),{shape:c,dataKey:d,activeBar:h}=n,{onMouseEnter:m,onClick:p,onMouseLeave:g}=n,x=hm(n,PJ),S=ID(m,d,l),w=LD(g),O=zD(p,d,l);return r?j.createElement(j.Fragment,null,r.map((_,E)=>j.createElement(u3,Xi({index:_.originalDataIndex,key:"rectangle-".concat(_==null?void 0:_.x,"-").concat(_==null?void 0:_.y,"-").concat(_==null?void 0:_.value,"-").concat(E),className:"recharts-bar-rectangle"},Om(x,_,E),{onMouseEnter:S(_,E),onMouseLeave:w(_,E),onClick:O(_,E)}),h?j.createElement($J,{shape:c,activeBar:h,baseProps:u,entry:_,index:E,dataKey:d}):j.createElement(BJ,{shape:c,baseProps:u,entry:_,index:E,dataKey:d})))):null}function qJ(e){var{props:t,previousRectanglesRef:r}=e,{data:n,layout:i,isAnimationActive:l,animationBegin:u,animationDuration:c,animationEasing:d,onAnimationEnd:h,onAnimationStart:m}=t,p=r.current,g=Fm(t,"recharts-bar-"),[x,S]=j.useState(!1),w=!x,O=j.useCallback(()=>{typeof h=="function"&&h(),S(!1)},[h]),_=j.useCallback(()=>{typeof m=="function"&&m(),S(!0)},[m]);return j.createElement(zJ,{showLabels:w,rects:n},j.createElement(Km,{animationId:g,begin:u,duration:c,isActive:l,easing:d,onAnimationEnd:O,onAnimationStart:_,key:g},E=>{var T=E===1?n:n==null?void 0:n.map((A,C)=>{var M=p&&p[C];if(M)return br(br({},A),{},{x:xt(M.x,A.x,E),y:xt(M.y,A.y,E),width:xt(M.width,A.width,E),height:xt(M.height,A.height,E)});if(i==="horizontal"){var R=xt(0,A.height,E),z=xt(A.stackedBarStart,A.y,E);return br(br({},A),{},{y:z,height:R})}var $=xt(0,A.width,E),D=xt(A.stackedBarStart,A.x,E);return br(br({},A),{},{width:$,x:D})});return E>0&&(r.current=T??null),T==null?null:j.createElement(en,null,j.createElement(UJ,{props:t,data:T}))}),j.createElement(PD,{label:t.label}),t.children)}function HJ(e){var t=j.useRef(null);return j.createElement(qJ,{previousRectanglesRef:t,props:e})}var c3=0,KJ=(e,t)=>{var r=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:r,errorVal:Ot(e,t)}};class FJ extends j.PureComponent{render(){var{hide:t,data:r,dataKey:n,className:i,xAxisId:l,yAxisId:u,needClip:c,background:d,id:h}=this.props;if(t||r==null)return null;var m=Qe("recharts-bar",i),p=h;return j.createElement(en,{className:m,id:h},c&&j.createElement("defs",null,j.createElement(JD,{clipPathId:p,xAxisId:l,yAxisId:u})),j.createElement(en,{className:"recharts-bar-rectangles",clipPath:c?"url(#clipPath-".concat(p,")"):void 0},j.createElement(LJ,{data:r,dataKey:n,background:d,allOtherBarProps:this.props}),j.createElement(HJ,this.props)))}}var YJ={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:c3,xAxisId:0,yAxisId:0,zIndex:Ft.bar};function GJ(e){var{xAxisId:t,yAxisId:r,hide:n,legendType:i,minPointSize:l,activeBar:u,animationBegin:c,animationDuration:d,animationEasing:h,isAnimationActive:m}=e,{needClip:p}=GS(t,r),g=ll(),x=vr(),S=uX(e.children,US),w=ye(E=>bJ(E,e.id,x,S));if(g!=="vertical"&&g!=="horizontal")return null;var O,_=w==null?void 0:w[0];return _==null||_.height==null||_.width==null?O=0:O=g==="vertical"?_.height/2:_.width/2,j.createElement(WD,{xAxisId:t,yAxisId:r,data:w,dataPointFormatter:KJ,errorBarOffset:O},j.createElement(FJ,Xi({},e,{layout:g,needClip:p,data:w,xAxisId:t,yAxisId:r,hide:n,legendType:i,minPointSize:l,activeBar:u,animationBegin:c,animationDuration:d,animationEasing:h,isAnimationActive:m})))}function VJ(e){var{layout:t,barSettings:{dataKey:r,minPointSize:n,hasCustomShape:i},pos:l,bandSize:u,xAxis:c,yAxis:d,xAxisTicks:h,yAxisTicks:m,stackedData:p,displayedData:g,offset:x,cells:S,parentViewBox:w,dataStartIndex:O}=e,_=t==="horizontal"?d:c,E=p?_.scale.domain():null,T=MU({numericAxis:_}),A=_.scale.map(T);return g.map((C,M)=>{var R,z,$,D,H,U;if(p){var ie=p[M+O];if(ie==null)return null;R=NU(ie,E)}else R=Ot(C,r),Array.isArray(R)||(R=[T,R]);var te=nJ(n,c3)(R[1],M);if(t==="horizontal"){var ae,q=d.scale.map(R[0]),V=d.scale.map(R[1]);if(q==null||V==null)return null;z=vE({axis:c,ticks:h,bandSize:u,offset:l.offset,entry:C,index:M}),$=(ae=V??q)!==null&&ae!==void 0?ae:void 0,D=l.size;var ne=q-V;if(H=ra(ne)?0:ne,U={x:z,y:x.top,width:D,height:x.height},Math.abs(te)>0&&Math.abs(H)<Math.abs(te)){var se=Lr(H||te)*(Math.abs(te)-Math.abs(H));$-=se,H+=se}}else{var fe=c.scale.map(R[0]),I=c.scale.map(R[1]);if(fe==null||I==null)return null;if(z=fe,$=vE({axis:d,ticks:m,bandSize:u,offset:l.offset,entry:C,index:M}),D=I-fe,H=l.size,U={x:x.left,y:$,width:x.width,height:H},Math.abs(te)>0&&Math.abs(D)<Math.abs(te)){var X=Lr(D||te)*(Math.abs(te)-Math.abs(D));D+=X}}if(z==null||$==null||D==null||H==null||!i&&(D===0||H===0))return null;var le=br(br({},C),{},{stackedBarStart:A,x:z,y:$,width:D,height:H,value:p?R:R[1],payload:C,background:U,tooltipPosition:{x:z+D/2,y:$+H/2},parentViewBox:w,originalDataIndex:M},S&&S[M]&&S[M].props);return le}).filter(Boolean)}function QJ(e){var t=sr(e,YJ),r=OJ(t.stackId),n=vr();return j.createElement(UD,{id:t.id,type:"bar"},i=>j.createElement(j.Fragment,null,j.createElement(BD,{legendPayload:kJ(t)}),j.createElement(IJ,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:i}),j.createElement(HD,{type:"bar",id:i,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:r,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:n,hasCustomShape:t.shape!=null}),j.createElement(_n,{zIndex:t.zIndex},j.createElement(GJ,Xi({},t,{id:i})))))}var XS=j.memo(QJ,Fo);XS.displayName="Bar";var XJ=["domain","range"],ZJ=["domain","range"];function PP(e,t){if(e==null)return{};var r,n,i=WJ(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function WJ(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function CP(e,t){return e===t?!0:Array.isArray(e)&&e.length===2&&Array.isArray(t)&&t.length===2?e[0]===t[0]&&e[1]===t[1]:!1}function f3(e,t){if(e===t)return!0;var{domain:r,range:n}=e,i=PP(e,XJ),{domain:l,range:u}=t,c=PP(t,ZJ);return!CP(r,l)||!CP(n,u)?!1:Fo(i,c)}var JJ=["type"],eee=["dangerouslySetInnerHTML","ticks","scale"],tee=["id","scale"];function Ux(){return Ux=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Ux.apply(null,arguments)}function MP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function RP(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?MP(Object(r),!0).forEach(function(n){ree(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):MP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ree(e,t,r){return(t=nee(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function nee(e){var t=aee(e,"string");return typeof t=="symbol"?t:t+""}function aee(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function qx(e,t){if(e==null)return{};var r,n,i=iee(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function iee(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function see(e){var t=ut(),r=j.useRef(null),n=C2(),{type:i}=e,l=qx(e,JJ),u=Vm(n,"xAxis",i),c=j.useMemo(()=>{if(u!=null)return RP(RP({},l),{},{type:u})},[l,u]);return j.useLayoutEffect(()=>{c!=null&&(r.current===null?t(ZX(c)):r.current!==c&&t(WX({prev:r.current,next:c})),r.current=c)},[c,t]),j.useLayoutEffect(()=>()=>{r.current&&(t(JX(r.current)),r.current=null)},[t]),null}var lee=e=>{var{xAxisId:t,className:r}=e,n=ye(Rb),i=vr(),l="xAxis",u=ye(_=>L4(_,l,t,i)),c=ye(_=>D4(_,t)),d=ye(_=>AY(_,t)),h=ye(_=>r4(_,t));if(c==null||d==null||h==null)return null;var{dangerouslySetInnerHTML:m,ticks:p,scale:g}=e,x=qx(e,eee),{id:S,scale:w}=h,O=qx(h,tee);return j.createElement(YS,Ux({},x,O,{x:d.x,y:d.y,width:c.width,height:c.height,className:Qe("recharts-".concat(l," ").concat(l),r),viewBox:n,ticks:u,axisType:l,axisId:t}))},oee={allowDataOverflow:kt.allowDataOverflow,allowDecimals:kt.allowDecimals,allowDuplicatedCategory:kt.allowDuplicatedCategory,angle:kt.angle,axisLine:$a.axisLine,height:kt.height,hide:!1,includeHidden:kt.includeHidden,interval:kt.interval,label:!1,minTickGap:kt.minTickGap,mirror:kt.mirror,orientation:kt.orientation,padding:kt.padding,reversed:kt.reversed,scale:kt.scale,tick:kt.tick,tickCount:kt.tickCount,tickLine:$a.tickLine,tickSize:$a.tickSize,type:kt.type,niceTicks:kt.niceTicks,xAxisId:0},uee=e=>{var t=sr(e,oee);return j.createElement(j.Fragment,null,j.createElement(see,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),j.createElement(lee,t))},fp=j.memo(uee,f3);fp.displayName="XAxis";var cee=["type"],fee=["dangerouslySetInnerHTML","ticks","scale"],dee=["id","scale"];function Hx(){return Hx=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Hx.apply(null,arguments)}function DP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function kP(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?DP(Object(r),!0).forEach(function(n){hee(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):DP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function hee(e,t,r){return(t=mee(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function mee(e){var t=pee(e,"string");return typeof t=="symbol"?t:t+""}function pee(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Kx(e,t){if(e==null)return{};var r,n,i=vee(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function vee(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function yee(e){var t=ut(),r=j.useRef(null),n=C2(),{type:i}=e,l=Kx(e,cee),u=Vm(n,"yAxis",i),c=j.useMemo(()=>{if(u!=null)return kP(kP({},l),{},{type:u})},[u,l]);return j.useLayoutEffect(()=>{c!=null&&(r.current===null?t(eZ(c)):r.current!==c&&t(tZ({prev:r.current,next:c})),r.current=c)},[c,t]),j.useLayoutEffect(()=>()=>{r.current&&(t(rZ(r.current)),r.current=null)},[t]),null}function gee(e){var{yAxisId:t,className:r,width:n,label:i}=e,l=j.useRef(null),u=j.useRef(null),c=ye(Rb),d=vr(),h=ut(),m="yAxis",p=ye(M=>k4(M,t)),g=ye(M=>PY(M,t)),x=ye(M=>L4(M,m,t,d)),S=ye(M=>n4(M,t));if(j.useLayoutEffect(()=>{if(!(n!=="auto"||!p||HS(i)||j.isValidElement(i)||S==null)){var M=l.current;if(M){var R=M.getCalculatedWidth();Math.round(p.width)!==Math.round(R)&&h(nZ({id:t,width:R}))}}},[x,p,h,i,t,n,S]),p==null||g==null||S==null)return null;var{dangerouslySetInnerHTML:w,ticks:O,scale:_}=e,E=Kx(e,fee),{id:T,scale:A}=S,C=Kx(S,dee);return j.createElement(YS,Hx({},E,C,{ref:l,labelRef:u,x:g.x,y:g.y,tickTextProps:n==="auto"?{width:void 0}:{width:n},width:p.width,height:p.height,className:Qe("recharts-".concat(m," ").concat(m),r),viewBox:c,ticks:x,axisType:m,axisId:t}))}var xee={allowDataOverflow:It.allowDataOverflow,allowDecimals:It.allowDecimals,allowDuplicatedCategory:It.allowDuplicatedCategory,angle:It.angle,axisLine:$a.axisLine,hide:!1,includeHidden:It.includeHidden,interval:It.interval,label:!1,minTickGap:It.minTickGap,mirror:It.mirror,orientation:It.orientation,padding:It.padding,reversed:It.reversed,scale:It.scale,tick:It.tick,tickCount:It.tickCount,tickLine:$a.tickLine,tickSize:$a.tickSize,type:It.type,niceTicks:It.niceTicks,width:It.width,yAxisId:0},bee=e=>{var t=sr(e,xee);return j.createElement(j.Fragment,null,j.createElement(yee,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),j.createElement(gee,t))},dp=j.memo(bee,f3);dp.displayName="YAxis";var See=(e,t)=>t,ZS=G([See,Xe,gR,Vt,tD,Wa,JG,Yt],sV);function wee(e){return"getBBox"in e.currentTarget&&typeof e.currentTarget.getBBox=="function"}function WS(e){var t=e.currentTarget.getBoundingClientRect(),r,n;if(wee(e)){var i=e.currentTarget.getBBox();r=i.width>0?t.width/i.width:1,n=i.height>0?t.height/i.height:1}else{var l=e.currentTarget;r=l.offsetWidth>0?t.width/l.offsetWidth:1,n=l.offsetHeight>0?t.height/l.offsetHeight:1}var u=(c,d)=>({relativeX:Math.round((c-t.left)/r),relativeY:Math.round((d-t.top)/n)});return"touches"in e?Array.from(e.touches).map(c=>u(c.clientX,c.clientY)):u(e.clientX,e.clientY)}var d3=tn("mouseClick"),h3=Wc();h3.startListening({actionCreator:d3,effect:(e,t)=>{var r=e.payload,n=ZS(t.getState(),WS(r));(n==null?void 0:n.activeIndex)!=null&&t.dispatch(YY({activeIndex:n.activeIndex,activeDataKey:void 0,activeCoordinate:n.activeCoordinate}))}});var Fx=tn("mouseMove"),m3=Wc(),io=null,bs=null,_0=null;m3.startListening({actionCreator:Fx,effect:(e,t)=>{var r=e.payload,n=t.getState(),{throttleDelay:i,throttledEvents:l}=n.eventSettings,u=l==="all"||(l==null?void 0:l.includes("mousemove"));io!==null&&(cancelAnimationFrame(io),io=null),bs!==null&&(typeof i!="number"||!u)&&(clearTimeout(bs),bs=null),_0=WS(r);var c=()=>{var d=t.getState(),h=df(d,d.tooltip.settings.shared);if(!_0){io=null,bs=null;return}if(h==="axis"){var m=ZS(d,_0);(m==null?void 0:m.activeIndex)!=null?t.dispatch(F4({activeIndex:m.activeIndex,activeDataKey:void 0,activeCoordinate:m.activeCoordinate})):t.dispatch(K4())}io=null,bs=null};if(!u){c();return}i==="raf"?io=requestAnimationFrame(c):typeof i=="number"&&bs===null&&(bs=setTimeout(c,i))}});function jee(e,t){return t instanceof HTMLElement?"HTMLElement <".concat(t.tagName,' class="').concat(t.className,'">'):t===window?"global.window":e==="children"&&typeof t=="object"&&t!==null?"<<CHILDREN>>":t}var IP={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},p3=pr({name:"rootProps",initialState:IP,reducers:{updateOptions:(e,t)=>{var r;e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=(r=t.payload.barGap)!==null&&r!==void 0?r:IP.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),Oee=p3.reducer,{updateOptions:_ee}=p3.actions,Nee=null,Eee={updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)},v3=pr({name:"polarOptions",initialState:Nee,reducers:Eee}),{updatePolarOptions:Cne}=v3.actions,Aee=v3.reducer,y3=tn("keyDown"),g3=tn("focus"),x3=tn("blur"),hp=Wc(),so=null,Ss=null,Jd=null;hp.startListening({actionCreator:y3,effect:(e,t)=>{Jd=e.payload,so!==null&&(cancelAnimationFrame(so),so=null);var r=t.getState(),{throttleDelay:n,throttledEvents:i}=r.eventSettings,l=i==="all"||i.includes("keydown");Ss!==null&&(typeof n!="number"||!l)&&(clearTimeout(Ss),Ss=null);var u=()=>{try{var c=t.getState(),d=c.rootProps.accessibilityLayer!==!1;if(!d)return;var{keyboardInteraction:h}=c.tooltip,m=Jd;if(m!=="ArrowRight"&&m!=="ArrowLeft"&&m!=="Enter")return;var p=yc(h,tl(c),$o(c),Bo(c)),g=p==null?-1:Number(p),x=!Number.isFinite(g)||g<0,S=Wa(c),w=tl(c),O=df(c,c.tooltip.settings.shared);if(m==="Enter"){if(x)return;var _=lm(c,O,"hover",String(h.index));t.dispatch(sm({active:!h.active,activeIndex:h.index,activeCoordinate:_}));return}var E=kY(c),T=E==="left-to-right"?1:-1,A=m==="ArrowRight"?1:-1,C;if(x){var M=$o(c),R=Bo(c),z=A*T,$=te=>({active:!1,index:String(te),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(C=-1,z>0){for(var D=0;D<w.length;D++)if(yc($(D),w,M,R)!=null){C=D;break}}else for(var H=w.length-1;H>=0;H--)if(yc($(H),w,M,R)!=null){C=H;break}if(C<0)return}else{C=g+A*T;var U=(S==null?void 0:S.length)||w.length;if(U===0||C>=U||C<0)return}var ie=lm(c,O,"hover",String(C));t.dispatch(sm({active:!0,activeIndex:C.toString(),activeCoordinate:ie}))}finally{so=null,Ss=null}};if(!l){u();return}n==="raf"?so=requestAnimationFrame(u):typeof n=="number"&&Ss===null&&(u(),Jd=null,Ss=setTimeout(()=>{Jd?u():(Ss=null,so=null)},n))}});hp.startListening({actionCreator:g3,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:i}=r.tooltip;if(!i.active&&i.index==null){var l="0",u=df(r,r.tooltip.settings.shared),c=lm(r,u,"hover",String(l));t.dispatch(sm({active:!0,activeIndex:l,activeCoordinate:c}))}}}});hp.startListening({actionCreator:x3,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:i}=r.tooltip;i.active&&t.dispatch(sm({active:!1,activeIndex:i.index,activeCoordinate:i.coordinate}))}}});function b3(e){e.persist();var{currentTarget:t}=e;return new Proxy(e,{get:(r,n)=>{if(n==="currentTarget")return t;var i=Reflect.get(r,n);return typeof i=="function"?i.bind(r):i}})}var vn=tn("externalEvent"),S3=Wc(),eh=new Map,uc=new Map,N0=new Map;S3.startListening({actionCreator:vn,effect:(e,t)=>{var{handler:r,reactEvent:n}=e.payload;if(r!=null){var i=n.type,l=b3(n);N0.set(i,{handler:r,reactEvent:l});var u=eh.get(i);u!==void 0&&(cancelAnimationFrame(u),eh.delete(i));var c=t.getState(),{throttleDelay:d,throttledEvents:h}=c.eventSettings,m=h,p=m==="all"||(m==null?void 0:m.includes(i)),g=uc.get(i);g!==void 0&&(typeof d!="number"||!p)&&(clearTimeout(g),uc.delete(i));var x=()=>{var O=N0.get(i);try{if(!O)return;var{handler:_,reactEvent:E}=O,T=t.getState(),A={activeCoordinate:LG(T),activeDataKey:iD(T),activeIndex:rl(T),activeLabel:aD(T),activeTooltipIndex:rl(T),isTooltipActive:zG(T)};_&&_(A,E)}finally{eh.delete(i),uc.delete(i),N0.delete(i)}};if(!p){x();return}if(d==="raf"){var S=requestAnimationFrame(x);eh.set(i,S)}else if(typeof d=="number"){if(!uc.has(i)){x();var w=setTimeout(x,d);uc.set(i,w)}}else x()}}});var Tee=G([Jo],e=>e.tooltipItemPayloads),Pee=G([Tee,(e,t)=>t,(e,t,r)=>r],(e,t,r)=>{if(t!=null){var n=e.find(l=>l.settings.graphicalItemId===r);if(n!=null){var{getPosition:i}=n;if(i!=null)return i(t)}}}),w3=tn("touchMove"),j3=Wc(),ws=null,_i=null,LP=null,cc=null;j3.startListening({actionCreator:w3,effect:(e,t)=>{var r=e.payload;if(!(r.touches==null||r.touches.length===0)){cc=b3(r);var n=t.getState(),{throttleDelay:i,throttledEvents:l}=n.eventSettings,u=l==="all"||l.includes("touchmove");ws!==null&&(cancelAnimationFrame(ws),ws=null),_i!==null&&(typeof i!="number"||!u)&&(clearTimeout(_i),_i=null),LP=Array.from(r.touches).map(d=>WS({clientX:d.clientX,clientY:d.clientY,currentTarget:r.currentTarget}));var c=()=>{if(cc!=null){var d=t.getState(),h=df(d,d.tooltip.settings.shared);if(h==="axis"){var m,p=(m=LP)===null||m===void 0?void 0:m[0];if(p==null){ws=null,_i=null;return}var g=ZS(d,p);(g==null?void 0:g.activeIndex)!=null&&t.dispatch(F4({activeIndex:g.activeIndex,activeDataKey:void 0,activeCoordinate:g.activeCoordinate}))}else if(h==="item"){var x,S=cc.touches[0];if(document.elementFromPoint==null||S==null)return;var w=document.elementFromPoint(S.clientX,S.clientY);if(!w||!w.getAttribute)return;var O=w.getAttribute($U),_=(x=w.getAttribute(BU))!==null&&x!==void 0?x:void 0,E=cl(d).find(C=>C.id===_);if(O==null||E==null||_==null)return;var{dataKey:T}=E,A=Pee(d,O,_);t.dispatch(H4({activeDataKey:T,activeIndex:O,activeCoordinate:A,activeGraphicalItemId:_}))}ws=null,_i=null}};if(!u){c();return}i==="raf"?ws=requestAnimationFrame(c):typeof i=="number"&&_i===null&&(c(),cc=null,_i=setTimeout(()=>{cc?c():(_i=null,ws=null)},i))}}});var O3={throttleDelay:"raf",throttledEvents:["mousemove","touchmove","pointermove","scroll","wheel"]},_3=pr({name:"eventSettings",initialState:O3,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=t.payload.throttledEvents)}}}),{setEventSettings:Cee}=_3.actions,Mee=_3.reducer,Ree=QM({brush:jZ,cartesianAxis:aZ,chartData:IV,errorBars:wW,eventSettings:Mee,graphicalItems:IX,layout:SU,legend:Rq,options:CV,polarAxis:aX,polarOptions:Aee,referenceElements:EZ,renderedTicks:KZ,rootProps:Oee,tooltip:GY,zIndex:xV}),Dee=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return Y6({reducer:Ree,preloadedState:t,middleware:n=>{var i;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((i="es6")!==null&&i!==void 0?i:"")}).concat([h3.middleware,m3.middleware,hp.middleware,S3.middleware,j3.middleware])},enhancers:n=>{var i=n;return typeof n=="function"&&(i=n()),i.concat(c2({type:"raf"}))},devTools:{serialize:{replacer:jee},name:"recharts-".concat(r)}})};function kee(e){var{preloadedState:t,children:r,reduxStoreName:n}=e,i=vr(),l=j.useRef(null);if(i)return r;l.current==null&&(l.current=Dee(t,n));var u=Nb;return j.createElement(Qq,{context:u,store:l.current},r)}function Iee(e){var{layout:t,margin:r}=e,n=ut(),i=vr();return j.useEffect(()=>{i||(n(gU(t)),n(yU(r)))},[n,i,t,r]),null}var Lee=j.memo(Iee,Fo);function zee(e){var t=ut();return j.useEffect(()=>{t(_ee(e))},[t,e]),null}var $ee=e=>{var t=ut();return j.useEffect(()=>{t(Cee(e))},[t,e]),null},Bee=j.memo($ee,Fo);function zP(e){var{zIndex:t,isPanorama:r}=e,n=j.useRef(null),i=ut();return j.useLayoutEffect(()=>(n.current&&i(yV({zIndex:t,element:n.current,isPanorama:r})),()=>{i(gV({zIndex:t,isPanorama:r}))}),[i,t,r]),j.createElement("g",{tabIndex:-1,ref:n,className:"recharts-zIndex-layer_".concat(t)})}function $P(e){var{children:t,isPanorama:r}=e,n=ye(oV);if(!n||n.length===0)return t;var i=n.filter(u=>u<0),l=n.filter(u=>u>0);return j.createElement(j.Fragment,null,i.map(u=>j.createElement(zP,{key:u,zIndex:u,isPanorama:r})),t,l.map(u=>j.createElement(zP,{key:u,zIndex:u,isPanorama:r})))}var Uee=["children"];function qee(e,t){if(e==null)return{};var r,n,i=Hee(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function Hee(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function mm(){return mm=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},mm.apply(null,arguments)}var Kee={width:"100%",height:"100%",display:"block"},Fee=j.forwardRef((e,t)=>{var r=Lb(),n=zb(),i=q2();if(!aa(r)||!aa(n))return null;var{children:l,otherAttributes:u,title:c,desc:d}=e,h,m;return u!=null&&(typeof u.tabIndex=="number"?h=u.tabIndex:h=i?0:void 0,typeof u.role=="string"?m=u.role:m=i?"application":void 0),j.createElement(vb,mm({},u,{title:c,desc:d,role:m,tabIndex:h,width:r,height:n,style:Kee,ref:t}),l)}),Yee=e=>{var{children:t}=e,r=ye($m);if(!r)return null;var{width:n,height:i,y:l,x:u}=r;return j.createElement(vb,{width:n,height:i,x:u,y:l},t)},BP=j.forwardRef((e,t)=>{var{children:r}=e,n=qee(e,Uee),i=vr();return i?j.createElement(Yee,null,j.createElement($P,{isPanorama:!0},r)):j.createElement(Fee,mm({ref:t},n),j.createElement($P,{isPanorama:!1},r))});function Gee(){var e=ut(),[t,r]=j.useState(null),n=ye(zU);return j.useEffect(()=>{if(t!=null){var i=t.getBoundingClientRect(),l=i.width/t.offsetWidth;Be(l)&&l!==n&&e(bU(l))}},[t,e,n]),r}function UP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Vee(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?UP(Object(r),!0).forEach(function(n){Qee(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):UP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Qee(e,t,r){return(t=Xee(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Xee(e){var t=Zee(e,"string");return typeof t=="symbol"?t:t+""}function Zee(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Gi(){return Gi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Gi.apply(null,arguments)}var Wee=()=>(FV(),null);function pm(e){if(typeof e=="number")return e;if(typeof e=="string"){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var Jee=j.forwardRef((e,t)=>{var r,n,i=j.useRef(null),[l,u]=j.useState({containerWidth:pm((r=e.style)===null||r===void 0?void 0:r.width),containerHeight:pm((n=e.style)===null||n===void 0?void 0:n.height)}),c=j.useCallback((h,m)=>{u(p=>{var g=Math.round(h),x=Math.round(m);return p.containerWidth===g&&p.containerHeight===x?p:{containerWidth:g,containerHeight:x}})},[]),d=j.useCallback(h=>{if(typeof t=="function"&&t(h),i.current!=null&&(i.current.disconnect(),i.current=null),h!=null&&typeof ResizeObserver<"u"){var{width:m,height:p}=h.getBoundingClientRect();c(m,p);var g=S=>{var w=S[0];if(w!=null){var{width:O,height:_}=w.contentRect;c(O,_)}},x=new ResizeObserver(g);x.observe(h),i.current=x}},[t,c]);return j.useEffect(()=>()=>{var h=i.current;h!=null&&h.disconnect()},[c]),j.createElement(j.Fragment,null,j.createElement(ef,{width:l.containerWidth,height:l.containerHeight}),j.createElement("div",Gi({ref:d},e)))}),ete=j.forwardRef((e,t)=>{var{width:r,height:n}=e,[i,l]=j.useState({containerWidth:pm(r),containerHeight:pm(n)}),u=j.useCallback((d,h)=>{l(m=>{var p=Math.round(d),g=Math.round(h);return m.containerWidth===p&&m.containerHeight===g?m:{containerWidth:p,containerHeight:g}})},[]),c=j.useCallback(d=>{if(typeof t=="function"&&t(d),d!=null){var{width:h,height:m}=d.getBoundingClientRect();u(h,m)}},[t,u]);return j.createElement(j.Fragment,null,j.createElement(ef,{width:i.containerWidth,height:i.containerHeight}),j.createElement("div",Gi({ref:c},e)))}),tte=j.forwardRef((e,t)=>{var{width:r,height:n}=e;return j.createElement(j.Fragment,null,j.createElement(ef,{width:r,height:n}),j.createElement("div",Gi({ref:t},e)))}),rte=j.forwardRef((e,t)=>{var{width:r,height:n}=e;return typeof r=="string"||typeof n=="string"?j.createElement(ete,Gi({},e,{ref:t})):typeof r=="number"&&typeof n=="number"?j.createElement(tte,Gi({},e,{width:r,height:n,ref:t})):j.createElement(j.Fragment,null,j.createElement(ef,{width:r,height:n}),j.createElement("div",Gi({ref:t},e)))});function nte(e){return e?Jee:rte}var ate=j.forwardRef((e,t)=>{var{children:r,className:n,height:i,onClick:l,onContextMenu:u,onDoubleClick:c,onMouseDown:d,onMouseEnter:h,onMouseLeave:m,onMouseMove:p,onMouseUp:g,onTouchEnd:x,onTouchMove:S,onTouchStart:w,style:O,width:_,responsive:E,dispatchTouchEvents:T=!0}=e,A=j.useRef(null),C=ut(),[M,R]=j.useState(null),[z,$]=j.useState(null),D=Gee(),H=Db(),U=(H==null?void 0:H.width)>0?H.width:_,ie=(H==null?void 0:H.height)>0?H.height:i,te=j.useCallback(ce=>{D(ce),typeof t=="function"&&t(ce),R(ce),$(ce),ce!=null&&(A.current=ce)},[D,t,R,$]),ae=j.useCallback(ce=>{C(d3(ce)),C(vn({handler:l,reactEvent:ce}))},[C,l]),q=j.useCallback(ce=>{C(Fx(ce)),C(vn({handler:h,reactEvent:ce}))},[C,h]),V=j.useCallback(ce=>{C(K4()),C(vn({handler:m,reactEvent:ce}))},[C,m]),ne=j.useCallback(ce=>{C(Fx(ce)),C(vn({handler:p,reactEvent:ce}))},[C,p]),se=j.useCallback(()=>{C(g3())},[C]),fe=j.useCallback(()=>{C(x3())},[C]),I=j.useCallback(ce=>{C(y3(ce.key))},[C]),X=j.useCallback(ce=>{C(vn({handler:u,reactEvent:ce}))},[C,u]),le=j.useCallback(ce=>{C(vn({handler:c,reactEvent:ce}))},[C,c]),oe=j.useCallback(ce=>{C(vn({handler:d,reactEvent:ce}))},[C,d]),ge=j.useCallback(ce=>{C(vn({handler:g,reactEvent:ce}))},[C,g]),je=j.useCallback(ce=>{C(vn({handler:w,reactEvent:ce}))},[C,w]),Oe=j.useCallback(ce=>{T&&C(w3(ce)),C(vn({handler:S,reactEvent:ce}))},[C,T,S]),Ce=j.useCallback(ce=>{C(vn({handler:x,reactEvent:ce}))},[C,x]),W=nte(E);return j.createElement(dD.Provider,{value:M},j.createElement(cM.Provider,{value:z},j.createElement(W,{width:U??(O==null?void 0:O.width),height:ie??(O==null?void 0:O.height),className:Qe("recharts-wrapper",n),style:Vee({position:"relative",cursor:"default",width:U,height:ie},O),onClick:ae,onContextMenu:X,onDoubleClick:le,onFocus:se,onBlur:fe,onKeyDown:I,onMouseDown:oe,onMouseEnter:q,onMouseLeave:V,onMouseMove:ne,onMouseUp:ge,onTouchEnd:Ce,onTouchMove:Oe,onTouchStart:je,ref:te},j.createElement(Wee,null),r)))}),ite=["width","height","responsive","children","className","style","compact","title","desc"];function ste(e,t){if(e==null)return{};var r,n,i=lte(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function lte(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var ote=j.forwardRef((e,t)=>{var{width:r,height:n,responsive:i,children:l,className:u,style:c,compact:d,title:h,desc:m}=e,p=ste(e,ite),g=Dn(p);return d?j.createElement(j.Fragment,null,j.createElement(ef,{width:r,height:n}),j.createElement(BP,{otherAttributes:g,title:h,desc:m},l)):j.createElement(ate,{className:u,style:c,width:r,height:n,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},j.createElement(BP,{otherAttributes:g,title:h,desc:m,ref:t},j.createElement(TZ,null,l)))});function Yx(){return Yx=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Yx.apply(null,arguments)}function qP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function ute(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?qP(Object(r),!0).forEach(function(n){cte(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):qP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function cte(e,t,r){return(t=fte(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function fte(e){var t=dte(e,"string");return typeof t=="symbol"?t:t+""}function dte(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var hte={top:5,right:5,bottom:5,left:5},mte=ute({accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:hte,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},O3),N3=j.forwardRef(function(t,r){var n,i=sr(t.categoricalChartProps,mte),{chartName:l,defaultTooltipEventType:u,validateTooltipEventTypes:c,tooltipPayloadSearcher:d,categoricalChartProps:h}=t,m={chartName:l,defaultTooltipEventType:u,validateTooltipEventTypes:c,tooltipPayloadSearcher:d,eventEmitter:void 0};return j.createElement(kee,{preloadedState:{options:m},reduxStoreName:(n=h.id)!==null&&n!==void 0?n:l},j.createElement(wZ,{chartData:h.data}),j.createElement(Lee,{layout:i.layout,margin:i.margin}),j.createElement(Bee,{throttleDelay:i.throttleDelay,throttledEvents:i.throttledEvents}),j.createElement(zee,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),j.createElement(ote,Yx({},i,{ref:r})))}),pte=["axis"],vte=j.forwardRef((e,t)=>j.createElement(N3,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:pte,tooltipPayloadSearcher:hD,categoricalChartProps:e,ref:t})),yte=["axis","item"],E3=j.forwardRef((e,t)=>j.createElement(N3,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:yte,tooltipPayloadSearcher:hD,categoricalChartProps:e,ref:t}));const jt={green:"#34d399",red:"#f87171",gray:"#4b5563",cyan:"#22d3ee",gridLine:"#1f2937",labelText:"#9ca3af"},HP=["#22d3ee","#34d399","#facc15","#f87171","#a78bfa","#fb923c","#f472b6","#60a5fa"];function gte(e){return HP[e%HP.length]}function xte({data:e,projectId:t}){const[r,n]=j.useState(!0),[i,l]=j.useState(""),u=e.targets,c=Fe(t?aM(t,i||void 0):b$(i||void 0)),d=i?c.data:void 0,h=j.useMemo(()=>Ote(e.runs??[]),[e.runs]);return v.jsxs("div",{className:"rounded-lg border border-gray-800",children:[v.jsxs("button",{type:"button",onClick:()=>n(m=>!m),className:"flex w-full items-center justify-between px-4 py-3 text-left transition-colors hover:bg-gray-900/30",children:[v.jsx("span",{className:"text-sm font-medium text-gray-300",children:"Analytics"}),v.jsx("span",{className:"text-xs text-gray-500",children:r?"▸ Show":"▾ Hide"})]}),!r&&v.jsxs("div",{className:"space-y-6 border-t border-gray-800 px-4 py-4",children:[v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsx("label",{htmlFor:"baseline-select",className:"text-xs font-medium uppercase tracking-wider text-gray-500",children:"Baseline target"}),v.jsxs("select",{id:"baseline-select",value:i,onChange:m=>l(m.target.value),className:"rounded-md border border-gray-700 bg-gray-950 px-3 py-1.5 text-sm text-gray-100 focus:border-cyan-500 focus:outline-none focus:ring-1 focus:ring-cyan-500",children:[v.jsx("option",{value:"",children:"Select a baseline…"}),u.map(m=>v.jsx("option",{value:m,children:m},m))]}),i&&c.isLoading&&v.jsx("span",{className:"text-xs text-gray-500",children:"Loading…"})]}),i&&d&&v.jsx(bte,{data:d,baseline:i}),e.runs&&e.runs.length>0&&u.length>1&&v.jsx(Ste,{runs:e.runs,targets:u}),i&&d&&v.jsx(wte,{data:d,baseline:i}),v.jsx(jte,{data:e}),h.length>1&&u.length>0&&v.jsx(_te,{data:h,targets:u}),!i&&v.jsx("p",{className:"text-xs text-gray-500",children:"Select a baseline target above to see gain and delta charts."})]})]})}function JS({active:e,payload:t,label:r}){return!e||!(t!=null&&t.length)?null:v.jsxs("div",{className:"rounded-md border border-gray-700 bg-gray-900 px-3 py-2 text-xs shadow-xl",children:[r&&v.jsx("div",{className:"mb-1 font-medium text-gray-300",children:r}),t.map((n,i)=>v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:n.color}}),v.jsxs("span",{className:"text-gray-400",children:[n.name,":"]}),v.jsx("span",{className:"tabular-nums text-gray-200",children:typeof n.value=="number"?n.value.toFixed(3):n.value})]},`${n.name}-${i}`))]})}function Uo({title:e,children:t}){return v.jsxs("div",{className:"space-y-3",children:[v.jsx("h3",{className:"text-sm font-medium text-gray-400",children:e}),t]})}function bte({data:e,baseline:t}){const r=j.useMemo(()=>{const i=[];for(const l of e.cells)l.target!==t&&l.delta!==void 0&&i.push({experiment:l.experiment,target:l.target,g:l.normalized_gain??null,delta:l.delta});return i.sort((l,u)=>Math.abs(u.g??0)-Math.abs(l.g??0)),i},[e.cells,t]);if(r.length===0)return v.jsx(Uo,{title:"Normalized Gain (g)",children:v.jsx("p",{className:"text-xs text-gray-500",children:"No gain data available. Ensure multiple targets exist."})});const n=r.map(i=>({name:`${i.target} · ${i.experiment}`,g:i.g??0,isNull:i.g===null}));return v.jsx(Uo,{title:"Normalized Gain (g)",children:v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900/30 p-3",children:v.jsx(kb,{width:"100%",height:Math.max(200,n.length*32),children:v.jsxs(E3,{data:n,layout:"vertical",margin:{left:120,right:20,top:5,bottom:5},children:[v.jsx(cp,{strokeDasharray:"3 3",stroke:jt.gridLine,horizontal:!1}),v.jsx(fp,{type:"number",tick:{fill:jt.labelText,fontSize:11},axisLine:{stroke:jt.gridLine}}),v.jsx(dp,{type:"category",dataKey:"name",tick:{fill:jt.labelText,fontSize:11},width:120,axisLine:{stroke:jt.gridLine}}),v.jsx(BS,{content:v.jsx(JS,{})}),v.jsx(XS,{dataKey:"g",name:"Normalized Gain",children:n.map(i=>v.jsx(US,{fill:i.isNull?jt.gray:i.g>0?jt.green:i.g<0?jt.red:jt.gray},i.name))})]})})})})}function Ste({runs:e,targets:t}){const{tags:r,grid:n}=j.useMemo(()=>{const i=new Map;for(const c of e)for(const d of c.tags??[]){let h=i.get(d);h||(h=new Map,i.set(d,h));let m=h.get(c.target);m||(m={passed:0,total:0},h.set(c.target,m)),m.passed+=c.passed_count,m.total+=c.eval_count}const l=[...i.keys()].sort(),u=l.map(c=>{const d={tag:c},h=i.get(c);if(!h)return d;for(const m of t){const p=h.get(m);d[m]=p&&p.total>0?p.passed/p.total:-1}return d});return{tags:l,grid:u}},[e,t]);return r.length===0?null:v.jsx(Uo,{title:"Pass Rate by Tag × Target",children:v.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Tag"}),t.map(i=>v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:i},i))]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:n.map(i=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3 font-medium text-gray-200",children:i.tag}),t.map(l=>{const u=i[l];if(u<0)return v.jsx("td",{className:"px-4 py-3 text-center text-gray-600",children:"—"},l);const c=Math.round(u*100),d=u>=.8?"bg-emerald-400/20 text-emerald-400":u>=.5?"bg-yellow-400/20 text-yellow-400":"bg-red-400/20 text-red-400";return v.jsx("td",{className:"px-4 py-3",children:v.jsxs("span",{className:`inline-block rounded px-2 py-0.5 text-xs tabular-nums font-medium ${d}`,children:[c,"%"]})},l)})]},i.tag))})]})})})}function wte({data:e,baseline:t}){const r=j.useMemo(()=>e.cells.filter(n=>n.target!==t&&n.delta!==void 0&&n.delta<0).sort((n,i)=>(n.delta??0)-(i.delta??0)),[e.cells,t]);return r.length===0?null:v.jsx(Uo,{title:"Regressions vs. Baseline",children:v.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Experiment"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Target"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Avg Score"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Delta"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"g"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:r.map(n=>{var i;return v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3 font-medium text-gray-200",children:n.experiment}),v.jsx("td",{className:"px-4 py-3 text-gray-300",children:n.target}),v.jsxs("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:[Math.round(n.avg_score*100),"%"]}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-red-400",children:(i=n.delta)==null?void 0:i.toFixed(3)}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-red-400",children:n.normalized_gain!==void 0&&n.normalized_gain!==null?n.normalized_gain.toFixed(3):"—"})]},`${n.experiment}::${n.target}`)})})]})})})}function jte({data:e}){const t=j.useMemo(()=>{const r=[];for(const i of e.cells)for(const l of i.tests)r.push(l.score);if(r.length===0)return[];const n=Array.from({length:10},(i,l)=>({range:`${l*10}–${(l+1)*10}%`,count:0}));for(const i of r){const l=Math.min(Math.floor(i*10),9);n[l].count++}return n},[e.cells]);return t.length===0?null:v.jsx(Uo,{title:"Score Distribution",children:v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900/30 p-3",children:v.jsx(kb,{width:"100%",height:200,children:v.jsxs(E3,{data:t,margin:{left:10,right:10,top:5,bottom:5},children:[v.jsx(cp,{strokeDasharray:"3 3",stroke:jt.gridLine,vertical:!1}),v.jsx(fp,{dataKey:"range",tick:{fill:jt.labelText,fontSize:11},axisLine:{stroke:jt.gridLine}}),v.jsx(dp,{tick:{fill:jt.labelText,fontSize:11},axisLine:{stroke:jt.gridLine}}),v.jsx(BS,{content:v.jsx(JS,{})}),v.jsx(XS,{dataKey:"count",name:"Tests",fill:jt.cyan,radius:[2,2,0,0]})]})})})})}function Ote(e){if(e.length===0)return[];const t=new Map;for(const n of e){const i=n.started_at.slice(0,10);let l=t.get(i);l||(l=new Map,t.set(i,l));let u=l.get(n.target);u||(u={scoreSum:0,count:0},l.set(n.target,u)),u.scoreSum+=n.avg_score,u.count++}return[...t.keys()].sort().map(n=>{const i={date:n},l=t.get(n);if(!l)return i;for(const[u,c]of l)i[u]=Math.round(c.scoreSum/c.count*1e3)/1e3;return i})}function _te({data:e,targets:t}){return v.jsx(Uo,{title:"Score Trend Over Time",children:v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900/30 p-3",children:v.jsx(kb,{width:"100%",height:250,children:v.jsxs(vte,{data:e,margin:{left:10,right:20,top:5,bottom:5},children:[v.jsx(cp,{strokeDasharray:"3 3",stroke:jt.gridLine}),v.jsx(fp,{dataKey:"date",tick:{fill:jt.labelText,fontSize:11},axisLine:{stroke:jt.gridLine}}),v.jsx(dp,{domain:[0,1],tick:{fill:jt.labelText,fontSize:11},axisLine:{stroke:jt.gridLine}}),v.jsx(BS,{content:v.jsx(JS,{})}),v.jsx(B2,{wrapperStyle:{fontSize:12,color:jt.labelText}}),t.map((r,n)=>v.jsx(s3,{type:"monotone",dataKey:r,stroke:gte(n),strokeWidth:2,dot:{r:3},connectNulls:!0},r))]})})})})}function wn({rate:e}){const t=Math.round(e*100);return v.jsxs("div",{className:"relative h-5 w-20 overflow-hidden rounded-full bg-gray-800",children:[v.jsx("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r from-blue-400 to-blue-600",style:{width:`${t}%`}}),v.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-xs font-semibold tabular-nums text-white",children:[t,"%"]})]})}function A3({data:e,isLoading:t,isError:r,error:n,projectId:i,readOnly:l}){var E,T;const[u,c]=j.useState("aggregated"),[d,h]=j.useState([]),{allTags:m,tagCounts:p}=j.useMemo(()=>{const A=new Map;for(const C of(e==null?void 0:e.runs)??[])for(const M of C.tags??[])A.set(M,(A.get(M)??0)+1);return{allTags:[...A.keys()].sort(),tagCounts:A}},[e==null?void 0:e.runs]),g=j.useMemo(()=>{if(!e||d.length===0)return e;const A=new Set(d),C=(e.runs??[]).filter(D=>(D.tags??[]).some(H=>A.has(H))),M=new Map,R=new Set,z=new Set;for(const D of C){R.add(D.experiment),z.add(D.target);const H=`${D.experiment}::${D.target}`,U=M.get(H)??{experiment:D.experiment,target:D.target,eval_count:0,passed_count:0,score_sum:0,tests:[]};U.eval_count+=D.eval_count,U.passed_count+=D.passed_count,U.score_sum+=D.avg_score*D.eval_count;for(const ie of D.tests)U.tests.push(ie);M.set(H,U)}const $=[...M.values()].map(D=>{const H=new Map;for(const U of D.tests)H.set(U.test_id,U);return{experiment:D.experiment,target:D.target,eval_count:D.eval_count,passed_count:D.passed_count,pass_rate:D.eval_count>0?D.passed_count/D.eval_count:0,avg_score:D.eval_count>0?D.score_sum/D.eval_count:0,tests:[...H.values()].slice(-100)}});return{...e,experiments:[...R].sort(),targets:[...z].sort(),cells:$,runs:C}},[e,d]),x=A=>{h(C=>C.includes(A)?C.filter(M=>M!==A):[...C,A])},S=()=>h([]),w=((E=g==null?void 0:g.runs)==null?void 0:E.length)??0,O=e&&e.cells.length>0,_=d.length>0&&g&&(((T=g.runs)==null?void 0:T.length)??0)===0;return v.jsxs("div",{className:"space-y-4",children:[v.jsx(Ete,{mode:u,onModeChange:c,runsCount:w}),t&&v.jsx(qte,{}),!t&&r&&n&&v.jsx(Bte,{message:`Failed to load comparison data: ${n.message}`}),!t&&!r&&!O&&v.jsx(Ute,{}),!t&&!r&&O&&v.jsxs(v.Fragment,{children:[m.length>0&&v.jsx(Nte,{allTags:m,tagCounts:p,selected:d,onToggle:x,onClear:S}),_?v.jsx(mp,{headline:`No runs match ${d.map(A=>`\`${A}\``).join(" + ")}`,body:"Clear the filter or pick a different tag combination.",action:{label:"Clear filter",onClick:S}}):g&&v.jsxs(v.Fragment,{children:[u==="aggregated"&&v.jsx(Tte,{data:g,projectId:i}),u==="per-run"&&v.jsx(Dte,{data:g,projectId:i,readOnly:l??!1})]})]})]})}function Nte({allTags:e,tagCounts:t,selected:r,onToggle:n,onClear:i}){const l=new Set(r),u=r.length>0;return v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900/40 px-4 py-3",children:[v.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[v.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-gray-500",children:"Filter by tag"}),e.map(c=>{const d=l.has(c),h=t.get(c)??0;return v.jsxs("button",{type:"button",onClick:()=>n(c),"aria-pressed":d,className:`inline-flex items-center gap-1.5 rounded-md border px-2 py-0.5 text-xs font-medium transition-colors ${d?"border-cyan-900/60 bg-cyan-950/30 text-cyan-300 hover:border-cyan-800/80":"border-gray-700 text-gray-400 hover:border-gray-600 hover:text-gray-200"}`,children:[v.jsx("span",{children:c}),v.jsx("span",{className:`rounded px-1 text-[0.65rem] tabular-nums ${d?"bg-cyan-900/50 text-cyan-200":"bg-gray-800 text-gray-500"}`,children:h})]},c)}),u&&v.jsx("button",{type:"button",onClick:i,className:"ml-1 text-xs text-gray-500 underline-offset-2 transition-colors hover:text-gray-300 hover:underline",children:"Clear"})]}),v.jsxs("p",{className:"mt-2 text-xs text-gray-500",children:["Showing runs with ",v.jsx("span",{className:"text-gray-400",children:"any"})," selected tag."]})]})}function Ete({mode:e,onModeChange:t,runsCount:r}){return v.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[v.jsxs("div",{children:[v.jsx("h2",{className:"text-xl font-semibold text-white",children:"Analyze runs"}),v.jsx("p",{className:"mt-1 text-sm text-gray-400",children:"Study one experiment against another, or pit individual runs head-to-head."})]}),v.jsx(Ate,{mode:e,onChange:t,runsCount:r})]})}function Ate({mode:e,onChange:t,runsCount:r}){const n=r===0;return v.jsxs("div",{role:"tablist","aria-label":"Comparison view mode",className:"inline-flex items-center rounded-lg border border-gray-800 bg-gray-900/50 p-1",children:[v.jsx(KP,{active:e==="aggregated",onClick:()=>t("aggregated"),children:"Aggregated"}),v.jsxs(KP,{active:e==="per-run",onClick:()=>t("per-run"),disabled:n,title:n?"No runs available":void 0,children:["Per run",r>0&&v.jsx("span",{className:"ml-1.5 rounded bg-gray-800 px-1.5 py-0.5 text-xs tabular-nums text-gray-400",children:r})]})]})}function KP({active:e,onClick:t,disabled:r,title:n,children:i}){return v.jsx("button",{type:"button",role:"tab","aria-selected":e,onClick:t,disabled:r,title:n,className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${e?"bg-gray-800 text-cyan-400 shadow-sm":"text-gray-400 hover:text-gray-200 disabled:text-gray-600 disabled:hover:text-gray-600"}`,children:i})}function Tte({data:e,projectId:t}){const{experiments:r,targets:n,cells:i}=e,l=j.useMemo(()=>{const u=new Map;for(const c of i)u.set(`${c.experiment}::${c.target}`,c);return u},[i]);return r.length<=1&&n.length<=1?v.jsx(mp,{headline:"Not enough variation to compare",body:`The aggregated matrix requires at least 2 experiments or 2 targets. Currently ${r.length} experiment(s) and ${n.length} target(s).`}):v.jsxs("div",{className:"space-y-3",children:[v.jsx($te,{}),v.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:v.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Target ↓ / Experiment →"})}),r.map(u=>v.jsx("th",{className:"px-4 py-3 font-medium text-gray-300",children:u},u))]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:n.map(u=>v.jsx(Pte,{target:u,experiments:r,cellMap:l},u))})]})}),v.jsx(xte,{data:e,projectId:t})]})}function Pte({target:e,experiments:t,cellMap:r}){return v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3 font-medium text-gray-200",children:e}),t.map(n=>{const i=r.get(`${n}::${e}`);return v.jsx("td",{className:"px-4 py-3",children:i?v.jsx(Cte,{cell:i}):v.jsx(Mte,{})},n)})]})}function Cte({cell:e}){const[t,r]=j.useState(!1),n=Math.round(e.avg_score*100);return v.jsxs("div",{className:"space-y-2",children:[v.jsxs("button",{type:"button",className:"group flex w-full flex-col gap-1 rounded-md border border-gray-800 bg-gray-900/40 px-3 py-2 text-left transition-colors hover:border-gray-700 hover:bg-gray-900/70",onClick:()=>r(i=>!i),"aria-expanded":t,children:[v.jsx(wn,{rate:e.pass_rate}),v.jsxs("div",{className:"flex items-center gap-2 text-xs tabular-nums text-gray-500",children:[v.jsxs("span",{children:[v.jsx("span",{className:"text-emerald-400",children:e.passed_count}),v.jsx("span",{className:"text-gray-600",children:" / "}),v.jsx("span",{children:e.eval_count})]}),v.jsx("span",{className:"text-gray-700",children:"·"}),v.jsxs("span",{children:["avg ",n,"%"]})]})]}),t&&v.jsx(Rte,{tests:e.tests})]})}function Mte(){return v.jsx("div",{className:"text-center text-gray-600",children:"—"})}function Rte({tests:e}){return v.jsxs("div",{className:"rounded-md border border-gray-800 bg-gray-950/60 px-3 py-2",children:[v.jsx("div",{className:"mb-1.5 text-xs font-medium uppercase tracking-wider text-gray-500",children:"Test cases"}),v.jsx("ul",{className:"space-y-1",children:e.map(t=>v.jsxs("li",{className:"flex items-center gap-2 text-xs",children:[v.jsx("span",{"aria-hidden":!0,className:`h-1.5 w-1.5 rounded-full ${t.passed?"bg-emerald-400":"bg-red-400"}`}),v.jsx("span",{className:"flex-1 truncate text-gray-300",title:t.test_id,children:t.test_id}),v.jsxs("span",{className:`tabular-nums ${t.passed?"text-emerald-400":"text-red-400"}`,children:[Math.round(t.score*100),"%"]})]},t.test_id))})]})}function Dte({data:e,projectId:t,readOnly:r}){const n=e.runs??[],[i,l]=j.useState(new Set),[u,c]=j.useState(!1),[d,h]=j.useState(null),m=x=>{l(S=>{const w=new Set(S);return w.has(x)?w.delete(x):w.add(x),w})},p=()=>l(new Set),g=j.useMemo(()=>n.filter(x=>i.has(x.run_id)),[n,i]);return n.length===0?v.jsx(mp,{headline:"No runs yet",body:"Run an evaluation to populate the per-run view."}):u&&g.length>=2?v.jsx(Lte,{runs:g,onBack:()=>c(!1)}):v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"flex items-center justify-between text-sm text-gray-400",children:v.jsxs("span",{children:[v.jsx("span",{className:"font-medium text-gray-300",children:n.length})," run",n.length===1?"":"s"," — select two or more to compare side-by-side"]})}),v.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"w-10 px-3 py-3","aria-label":"Select"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Timestamp"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Tags"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Experiment"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Target"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Tests"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Pass rate"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Avg"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:n.map(x=>v.jsx(kte,{run:x,checked:i.has(x.run_id),onToggle:()=>m(x.run_id),editing:d===x.run_id,onStartEdit:()=>h(x.run_id),onEndEdit:()=>h(null),projectId:t,readOnly:r},x.run_id))})]})}),i.size>0&&v.jsxs("div",{role:"toolbar","aria-label":"Selection actions",className:"sticky bottom-4 z-10 flex items-center justify-between gap-3 rounded-lg border border-cyan-900/50 bg-gray-900/95 px-4 py-3 shadow-xl backdrop-blur",children:[v.jsxs("div",{className:"text-sm text-gray-300",children:[v.jsx("span",{className:"font-semibold tabular-nums text-cyan-400",children:i.size})," ","selected"]}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("button",{type:"button",onClick:p,className:"rounded-md px-3 py-1.5 text-sm text-gray-400 transition-colors hover:text-gray-200",children:"Clear"}),v.jsxs("button",{type:"button",disabled:i.size<2,onClick:()=>c(!0),className:"inline-flex items-center gap-1.5 rounded-md bg-cyan-500 px-3 py-1.5 text-sm font-medium text-gray-950 transition-colors hover:bg-cyan-400 disabled:cursor-not-allowed disabled:bg-gray-700 disabled:text-gray-500",children:["Compare ",i.size,v.jsx("span",{"aria-hidden":!0,children:"→"})]})]})]})]})}function kte({run:e,checked:t,onToggle:r,editing:n,onStartEdit:i,onEndEdit:l,projectId:u,readOnly:c}){const d=Math.round(e.avg_score*100),h=!c&&e.source!=="remote",m=j.useRef(null),p=e.tags??[],g=p[0]??e.run_id,x=Hte(e.run_id),S=j.useRef(n);return j.useEffect(()=>{var w;S.current&&!n&&((w=m.current)==null||w.focus()),S.current=n},[n]),v.jsxs(v.Fragment,{children:[v.jsxs("tr",{className:`transition-colors ${t?"bg-cyan-950/20 hover:bg-cyan-950/30":"hover:bg-gray-900/30"}`,children:[v.jsx("td",{className:"px-3 py-3 align-middle",children:v.jsx("input",{type:"checkbox",className:"h-4 w-4 cursor-pointer rounded border-gray-700 bg-gray-900 text-cyan-500 accent-cyan-500 focus:ring-cyan-500",checked:t,onChange:r,"aria-label":`Select run ${g}`})}),v.jsxs("td",{className:"px-4 py-3 align-middle",title:e.run_id,children:[v.jsx("div",{className:"font-medium text-gray-200 tabular-nums",children:T3(e.started_at)}),x&&v.jsx("div",{className:"text-xs text-gray-500",children:x})]}),v.jsx("td",{className:"px-4 py-3 align-middle",children:h?v.jsx("button",{ref:m,type:"button",onClick:w=>{w.stopPropagation(),i()},className:p.length>0?"inline-flex flex-wrap items-center gap-1 rounded-md px-1 py-0.5 transition-colors hover:bg-gray-800/60":"rounded-md border border-dashed border-gray-700 px-2 py-0.5 text-xs text-gray-500 transition-colors hover:border-cyan-800 hover:text-cyan-400","aria-label":p.length>0?"Edit tags":"Add tags",children:p.length>0?p.map(w=>v.jsx("span",{className:"rounded-md border border-cyan-900/60 bg-cyan-950/30 px-2 py-0.5 text-xs font-medium text-cyan-300",children:w},w)):v.jsx(v.Fragment,{children:"+ tags"})}):p.length>0?v.jsx("div",{className:"inline-flex flex-wrap items-center gap-1",children:p.map(w=>v.jsx("span",{className:"rounded-md border border-cyan-900/60 bg-cyan-950/30 px-2 py-0.5 text-xs font-medium text-cyan-300",children:w},w))}):v.jsx("span",{className:"text-gray-600",children:"—"})}),v.jsx("td",{className:"px-4 py-3 align-middle text-gray-300",children:e.experiment}),v.jsx("td",{className:"px-4 py-3 align-middle text-gray-300",children:e.target}),v.jsx("td",{className:"px-4 py-3 align-middle text-right tabular-nums text-gray-400",children:e.eval_count}),v.jsx("td",{className:"px-4 py-3 align-middle",children:v.jsx(wn,{rate:e.pass_rate})}),v.jsxs("td",{className:"px-4 py-3 align-middle text-right tabular-nums text-gray-400",children:[d,"%"]})]}),n&&v.jsx("tr",{className:"bg-gray-950/80",children:v.jsx("td",{colSpan:8,className:"px-4 py-3",children:v.jsx(Ite,{runId:e.run_id,currentTags:p,projectId:u,onClose:l})})})]})}function Ite({runId:e,currentTags:t,projectId:r,onClose:n}){const[i,l]=j.useState(t),[u,c]=j.useState(""),[d,h]=j.useState(null),m=Fa(),p=j.useRef(null);j.useEffect(()=>{var E;(E=p.current)==null||E.focus()},[]);const g=H0({mutationFn:()=>U$(e,i,r),onSuccess:()=>{m.invalidateQueries({queryKey:["compare"]}),m.invalidateQueries({queryKey:["runs"]}),r&&(m.invalidateQueries({queryKey:["projects",r,"compare"]}),m.invalidateQueries({queryKey:["projects",r,"runs"]})),n()},onError:E=>h(E.message)}),x=H0({mutationFn:()=>q$(e,r),onSuccess:()=>{m.invalidateQueries({queryKey:["compare"]}),m.invalidateQueries({queryKey:["runs"]}),r&&(m.invalidateQueries({queryKey:["projects",r,"compare"]}),m.invalidateQueries({queryKey:["projects",r,"runs"]})),n()},onError:E=>h(E.message)}),S=g.isPending||x.isPending,w=i.length!==t.length||i.some((E,T)=>E!==t[T]),O=()=>{const E=u.trim();if(E!==""){if(i.includes(E)){c("");return}l([...i,E]),c(""),h(null)}},_=E=>{l(i.filter(T=>T!==E))};return v.jsxs("div",{className:"space-y-2 rounded-md border border-gray-800 bg-gray-900/60 p-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-gray-400",children:"Tag run"}),v.jsx("span",{className:"text-xs text-gray-500",children:"Multi-valued. Enter or comma adds; Backspace removes the last chip."})]}),v.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-md border border-gray-700 bg-gray-950 px-2 py-1.5 focus-within:border-cyan-500 focus-within:ring-1 focus-within:ring-cyan-500",children:[i.map(E=>v.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-cyan-900/60 bg-cyan-950/30 px-2 py-0.5 text-xs font-medium text-cyan-300",children:[E,v.jsx("button",{type:"button",onClick:()=>_(E),disabled:S,className:"text-cyan-500 transition-colors hover:text-cyan-200 disabled:opacity-50","aria-label":`Remove tag ${E}`,children:"×"})]},E)),v.jsx("input",{ref:p,type:"text",className:"flex-1 min-w-[140px] bg-transparent text-sm text-gray-100 placeholder:text-gray-600 focus:outline-none disabled:opacity-50",placeholder:i.length===0?"e.g. baseline, v2-prompt, slow":"Add tag…",value:u,onChange:E=>{h(null),c(E.target.value)},maxLength:60,disabled:S,onKeyDown:E=>{E.key==="Enter"||E.key===","?(E.preventDefault(),O()):E.key==="Backspace"&&u===""&&i.length>0?(E.preventDefault(),l(i.slice(0,-1))):E.key==="Escape"&&n()},onBlur:O})]}),v.jsxs("div",{className:"flex items-center justify-end gap-2",children:[v.jsx("button",{type:"button",onClick:n,disabled:S,className:"rounded-md px-3 py-1.5 text-sm text-gray-400 transition-colors hover:text-gray-200 disabled:opacity-50",children:"Cancel"}),t.length>0&&v.jsx("button",{type:"button",onClick:()=>{S||x.mutate()},disabled:S,className:"rounded-md border border-red-900/60 px-3 py-1.5 text-sm text-red-400 transition-colors hover:border-red-800 hover:bg-red-950/30 hover:text-red-300 disabled:opacity-50",children:"Clear all"}),v.jsx("button",{type:"button",disabled:!w||S,onClick:()=>{S||!w||g.mutate()},className:"rounded-md bg-cyan-500 px-3 py-1.5 text-sm font-medium text-gray-950 transition-colors hover:bg-cyan-400 disabled:cursor-not-allowed disabled:bg-gray-700 disabled:text-gray-500",children:g.isPending?"Saving…":"Save"})]}),d&&v.jsx("div",{className:"rounded-md border border-red-900/60 bg-red-950/30 px-3 py-1.5 text-xs text-red-400",children:d})]})}function Lte({runs:e,onBack:t}){const r=j.useMemo(()=>{const i=new Set,l=[];for(const u of e)for(const c of u.tests)i.has(c.test_id)||(i.add(c.test_id),l.push(c.test_id));return l},[e]),n=j.useMemo(()=>e.map(i=>{const l=new Map;for(const u of i.tests)l.set(u.test_id,u);return l}),[e]);return v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("button",{type:"button",onClick:t,className:"inline-flex items-center gap-1 text-sm text-cyan-400 transition-colors hover:text-cyan-300",children:[v.jsx("span",{"aria-hidden":!0,children:"←"})," Back to runs"]}),v.jsxs("span",{className:"text-sm text-gray-500",children:[e.length," runs · ",r.length," tests"]})]}),v.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsxs("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:[v.jsxs("tr",{children:[v.jsx("th",{className:"sticky left-0 z-10 bg-gray-900/80 px-4 py-3 font-medium text-gray-400 backdrop-blur",children:"Test case"}),e.map(i=>v.jsx("th",{className:"px-4 py-3 align-bottom",children:v.jsx(zte,{run:i})},i.run_id))]}),v.jsxs("tr",{className:"border-t border-gray-800/50 bg-gray-900/30",children:[v.jsx("th",{className:"sticky left-0 z-10 bg-gray-900/80 px-4 py-2 text-xs font-medium uppercase tracking-wider text-gray-500 backdrop-blur",children:"Pass rate"}),e.map(i=>v.jsx("th",{className:"px-4 py-2",children:v.jsx(wn,{rate:i.pass_rate})},i.run_id))]})]}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:r.map(i=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"sticky left-0 z-10 bg-gray-950/70 px-4 py-3 font-medium text-gray-200 backdrop-blur",children:i}),n.map((l,u)=>{const c=l.get(i),d=e[u].run_id;return c?v.jsx("td",{className:"px-4 py-3",children:v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("span",{"aria-hidden":!0,className:`h-1.5 w-1.5 rounded-full ${c.passed?"bg-emerald-400":"bg-red-400"}`}),v.jsxs("span",{className:`tabular-nums ${c.passed?"text-emerald-400":"text-red-400"}`,children:[Math.round(c.score*100),"%"]})]})},d):v.jsx("td",{className:"px-4 py-3 text-center text-gray-600",children:"—"},d)})]},i))})]})})]})}function zte({run:e}){const t=e.tags??[];return v.jsxs("div",{className:"min-w-[140px] space-y-1",children:[v.jsx("div",{className:"text-sm font-medium text-gray-200 tabular-nums",title:e.run_id,children:T3(e.started_at)}),t.length>0&&v.jsx("div",{className:"flex flex-wrap gap-1",children:t.map(r=>v.jsx("span",{className:"rounded-md border border-cyan-900/60 bg-cyan-950/30 px-1.5 py-0.5 text-[0.7rem] font-medium text-cyan-300",children:r},r))}),v.jsxs("div",{className:"text-xs text-gray-500",children:[e.experiment," · ",e.target]})]})}function $te(){return v.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500",role:"note",children:[v.jsx(th,{className:"bg-emerald-400",label:"80%+"}),v.jsx(th,{className:"bg-yellow-400",label:"50–80%"}),v.jsx(th,{className:"bg-red-400",label:"< 50%"}),v.jsx(th,{className:"bg-gray-700",label:"no data"})]})}function th({className:e,label:t}){return v.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[v.jsx("span",{className:`h-2 w-2 rounded-full ${e}`,"aria-hidden":!0}),v.jsx("span",{children:t})]})}function Bte({message:e}){return v.jsx("div",{className:"rounded-lg border border-red-900/60 bg-red-950/30 p-4 text-sm text-red-400",children:e})}function Ute(){return v.jsx(mp,{headline:"No comparison data yet",body:"Run evaluations with different experiment and target combinations to populate this view."})}function mp({headline:e,body:t,action:r}){return v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:[v.jsx("p",{className:"text-lg text-gray-300",children:e}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:t}),r&&v.jsx("button",{type:"button",onClick:r.onClick,className:"mt-4 inline-flex items-center rounded-md bg-cyan-500 px-3 py-1.5 text-sm font-medium text-gray-950 transition-colors hover:bg-cyan-400",children:r.label})]})}function qte(){return v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("div",{className:"animate-pulse",children:[v.jsx("div",{className:"border-b border-gray-800 bg-gray-900/50 px-4 py-3",children:v.jsx("div",{className:"h-4 w-48 rounded bg-gray-800"})}),["sk-1","sk-2","sk-3","sk-4","sk-5"].map(e=>v.jsxs("div",{className:"flex gap-4 border-b border-gray-800/50 px-4 py-3",children:[v.jsx("div",{className:"h-4 w-32 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-12 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-12 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-48 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-24 rounded bg-gray-800"})]},e))]})})}function T3(e){try{const t=new Date(e);if(Number.isNaN(t.getTime()))return e;const r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0"),l=String(t.getHours()).padStart(2,"0"),u=String(t.getMinutes()).padStart(2,"0");return`${r}-${n}-${i} ${l}:${u}`}catch{return e}}function Hte(e){const t=e.split("::");return t.length<2?null:t.slice(0,-1).join(" · ")}function P3({projectId:e}){const{data:t,isLoading:r}=e?Fe(db(e)):JC();if(r)return v.jsx(Kte,{});const n=(t==null?void 0:t.experiments)??[];return n.length===0?v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No experiments found"}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"Experiments will appear here once evaluations are run with experiment labels."})]}):v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Experiment"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Runs"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Targets"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Evals"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Pass Rate"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Last Run"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:n.map(i=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3",children:e?v.jsx(Se,{to:"/projects/$projectId/experiments/$experimentName",params:{projectId:e,experimentName:i.name},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:i.name}):v.jsx(Se,{to:"/experiments/$experimentName",params:{experimentName:i.name},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:i.name})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:i.run_count}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:i.target_count}),v.jsxs("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:[v.jsx("span",{className:"text-emerald-400",children:i.passed_count}),v.jsx("span",{className:"text-gray-600",children:" / "}),i.eval_count]}),v.jsx("td",{className:"px-4 py-3",children:v.jsx(wn,{rate:i.pass_rate})}),v.jsx("td",{className:"px-4 py-3 text-gray-400",title:FP(i.last_run).full,children:FP(i.last_run).date})]},i.name))})]})})}function FP(e){if(!e)return{date:"N/A",full:"N/A"};try{const t=new Date(e);if(Number.isNaN(t.getTime()))return{date:"N/A",full:"N/A"};const r=t.toLocaleString(),n=Date.now()-t.getTime(),i=Math.floor(n/6e4),l=Math.floor(n/36e5);let u;return i<1?u="just now":i<60?u=`${i} min ago`:l<24?u=`${l} hour${l===1?"":"s"} ago`:u=t.toLocaleDateString(),{date:u,full:r}}catch{return{date:"N/A",full:"N/A"}}}function Kte(){return v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("div",{className:"animate-pulse",children:[v.jsx("div",{className:"border-b border-gray-800 bg-gray-900/50 px-4 py-3",children:v.jsx("div",{className:"h-4 w-48 rounded bg-gray-800"})}),["sk-1","sk-2","sk-3","sk-4","sk-5"].map(e=>v.jsxs("div",{className:"flex gap-4 border-b border-gray-800/50 px-4 py-3",children:[v.jsx("div",{className:"h-4 w-32 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-12 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-12 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-48 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-24 rounded bg-gray-800"})]},e))]})})}function Fte(e){if(!e)return"No runs";const t=new Date(e);if(Number.isNaN(t.getTime()))return"N/A";const r=Date.now()-t.getTime(),n=Math.floor(r/6e4);if(n<1)return"Just now";if(n<60)return`${n}m ago`;const i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Yte({project:e}){const t=Math.round(e.pass_rate*100);return v.jsxs(Se,{to:"/projects/$projectId",params:{projectId:e.id},className:"group block rounded-lg border border-gray-800 bg-gray-900/50 p-5 transition-colors hover:border-cyan-800 hover:bg-gray-900",children:[v.jsx("div",{className:"flex items-start justify-between",children:v.jsxs("div",{className:"min-w-0 flex-1",children:[v.jsx("h3",{className:"truncate text-lg font-semibold text-white group-hover:text-cyan-400",children:e.name}),v.jsx("p",{className:"mt-1 truncate text-xs text-gray-500",children:e.path})]})}),v.jsxs("div",{className:"mt-4 grid grid-cols-3 gap-3",children:[v.jsxs("div",{children:[v.jsx("p",{className:"text-xs text-gray-500",children:"Runs"}),v.jsx("p",{className:"text-lg font-semibold text-white",children:e.run_count})]}),v.jsxs("div",{children:[v.jsx("p",{className:"text-xs text-gray-500",children:"Pass Rate"}),v.jsx("p",{className:`text-lg font-semibold ${e.run_count===0?"text-gray-500":t>=80?"text-emerald-400":t>=50?"text-yellow-400":"text-red-400"}`,children:e.run_count>0?`${t}%`:"--"})]}),v.jsxs("div",{children:[v.jsx("p",{className:"text-xs text-gray-500",children:"Last Run"}),v.jsx("p",{className:"text-sm text-gray-300",children:Fte(e.last_run)})]})]})]})}function Gte(e,t,r){return t?e:e1(e,r)}function e1(e,t){return e||String(t??_c)}function Vte({suiteFilter:e,testIds:t,target:r,thresholdInput:n,studioThreshold:i,workers:l,dryRun:u}){const c={};e.trim()&&(c.suite_filter=e.trim()),t.length>0&&(c.test_ids=t),r&&(c.target=r);const d=e1(n,i);return d&&(c.threshold=Number.parseFloat(d)),l&&(c.workers=Number.parseInt(l,10)),u&&(c.dry_run=!0),c}function hl({open:e,onClose:t,projectId:r,prefill:n}){const i=Fa(),l=il(),[u,c]=j.useState((n==null?void 0:n.suiteFilter)??""),[d,h]=j.useState(""),[m,p]=j.useState((n==null?void 0:n.testIds)??[]),[g,x]=j.useState((n==null?void 0:n.target)??""),[S,w]=j.useState(""),[O,_]=j.useState(!1),[E,T]=j.useState(""),[A,C]=j.useState(!1),[M,R]=j.useState(!1),[z,$]=j.useState(null),[D,H]=j.useState(null),[U,ie]=j.useState(!1),[te,ae]=j.useState(null),{data:q}=F$(r),{data:V}=G$(r),{data:ne}=hb(z,r),{data:se}=bt(r),fe=j.useMemo(()=>(q==null?void 0:q.eval_files)??[],[q]),I=j.useMemo(()=>(V==null?void 0:V.targets)??[],[V]),X=j.useMemo(()=>e1(S,se==null?void 0:se.threshold),[se==null?void 0:se.threshold,S]),le=j.useMemo(()=>Gte(S,O,se==null?void 0:se.threshold),[se==null?void 0:se.threshold,S,O]);j.useEffect(()=>{e&&(c((n==null?void 0:n.suiteFilter)??""),p((n==null?void 0:n.testIds)??[]),x((n==null?void 0:n.target)??""),h(""),w(""),_(!1),T(""),C(!1),R(!1),$(null),H(null),ie(!1),ae(null))},[e,n]),j.useEffect(()=>{((ne==null?void 0:ne.status)==="finished"||(ne==null?void 0:ne.status)==="failed")&&(i.invalidateQueries({queryKey:["runs"]}),i.invalidateQueries({queryKey:["projects"]}))},[ne==null?void 0:ne.status,i]);const oe=j.useCallback(()=>Vte({suiteFilter:u,testIds:m,target:g,thresholdInput:S,studioThreshold:se==null?void 0:se.threshold,workers:E,dryRun:A}),[A,se==null?void 0:se.threshold,u,g,m,S,E]);j.useEffect(()=>{const W=oe();if(!W.suite_filter&&(!W.test_ids||W.test_ids.length===0)){ae(null);return}Z$(W,r).then(ce=>ae(ce.command)).catch(()=>ae(null))},[oe,r]);function ge(){const W=d.trim();W&&!m.includes(W)&&p([...m,W]),h("")}function je(W){p(m.filter(ce=>ce!==W))}async function Oe(){H(null),ie(!0);try{const W=oe(),ce=await sM(W,r);$(ce.id)}catch(W){H(W.message)}finally{ie(!1)}}if(!e)return null;if(z&&ne){let W=function(){t(),l({to:f$(r)})};return v.jsx(YP,{onClose:t,title:"Eval Run",children:v.jsx(Qte,{status:ne,onClose:t,onRunInBackground:W,runId:z})})}const Ce=!!(u.trim()||m.length>0);return v.jsx(YP,{onClose:t,title:"Run Eval",children:v.jsxs("div",{className:"space-y-4",children:[v.jsxs("div",{children:[v.jsx("label",{htmlFor:"suite-filter",className:"mb-1 block text-sm font-medium text-gray-300",children:"Suite Filter"}),v.jsx("input",{id:"suite-filter",type:"text",value:u,onChange:W=>c(W.target.value),placeholder:"evals/**/*.eval.yaml",className:"w-full rounded-md border border-gray-700 bg-gray-800 px-3 py-2 text-sm text-white placeholder-gray-500 focus:border-cyan-600 focus:outline-none"}),fe.length>0&&!u&&v.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[fe.slice(0,5).map(W=>v.jsx("button",{type:"button",onClick:()=>c(ce=>ce?`${ce}, ${W.relative_path}`:W.relative_path),className:"rounded bg-gray-800 px-2 py-0.5 text-xs text-gray-400 hover:bg-gray-700 hover:text-gray-200",children:W.relative_path},W.relative_path)),fe.length>5&&v.jsxs("span",{className:"px-1 text-xs text-gray-500",children:["+",fe.length-5," more"]})]})]}),v.jsxs("div",{children:[v.jsx("label",{htmlFor:"test-id-input",className:"mb-1 block text-sm font-medium text-gray-300",children:"Test ID Filter"}),v.jsxs("div",{className:"flex gap-2",children:[v.jsx("input",{id:"test-id-input",type:"text",value:d,onChange:W=>h(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),ge())},placeholder:"auth-*, retrieval-basic",className:"flex-1 rounded-md border border-gray-700 bg-gray-800 px-3 py-2 text-sm text-white placeholder-gray-500 focus:border-cyan-600 focus:outline-none"}),v.jsx("button",{type:"button",onClick:ge,disabled:!d.trim(),className:"rounded-md bg-gray-700 px-3 py-2 text-sm text-white hover:bg-gray-600 disabled:opacity-50",children:"Add"})]}),m.length>0&&v.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1",children:m.map(W=>v.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-cyan-900/40 px-2.5 py-0.5 text-xs text-cyan-300",children:[W,v.jsx("button",{type:"button",onClick:()=>je(W),className:"text-cyan-400 hover:text-white",children:"×"})]},W))})]}),v.jsxs("div",{children:[v.jsx("label",{htmlFor:"target-override",className:"mb-1 block text-sm font-medium text-gray-300",children:"Target Override"}),v.jsxs("select",{id:"target-override",value:g,onChange:W=>x(W.target.value),className:"w-full rounded-md border border-gray-700 bg-gray-800 px-3 py-2 text-sm text-white focus:border-cyan-600 focus:outline-none",children:[v.jsx("option",{value:"",children:"Use eval's configured target"}),I.map(W=>v.jsx("option",{value:W,children:W},W))]})]}),v.jsxs("div",{children:[v.jsxs("button",{type:"button",onClick:()=>R(!M),className:"text-sm text-gray-400 hover:text-gray-200",children:[M?"▾":"▸"," Advanced Options"]}),M&&v.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-3",children:[v.jsxs("div",{children:[v.jsx("label",{htmlFor:"threshold-input",className:"mb-1 block text-xs text-gray-400",children:"Threshold (0–1)"}),v.jsx("input",{id:"threshold-input",type:"number",value:le,onChange:W=>{_(!0),w(W.target.value)},min:"0",max:"1",step:"0.1",placeholder:X,className:"w-full rounded-md border border-gray-700 bg-gray-800 px-3 py-1.5 text-sm text-white placeholder-gray-500 focus:border-cyan-600 focus:outline-none"})]}),v.jsxs("div",{children:[v.jsx("label",{htmlFor:"workers-input",className:"mb-1 block text-xs text-gray-400",children:"Workers"}),v.jsx("input",{id:"workers-input",type:"number",value:E,onChange:W=>T(W.target.value),min:"1",max:"50",placeholder:"3",className:"w-full rounded-md border border-gray-700 bg-gray-800 px-3 py-1.5 text-sm text-white placeholder-gray-500 focus:border-cyan-600 focus:outline-none"})]}),v.jsx("div",{className:"col-span-2",children:v.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-400",children:[v.jsx("input",{type:"checkbox",checked:A,onChange:W=>C(W.target.checked),className:"rounded border-gray-600 bg-gray-800"}),"Dry run (mock provider responses)"]})})]})]}),te&&v.jsxs("div",{className:"rounded-md border border-gray-700 bg-gray-950 p-3",children:[v.jsx("div",{className:"mb-1 text-xs text-gray-500",children:"CLI Preview"}),v.jsx("code",{className:"block break-all text-xs text-cyan-300",children:te})]}),D&&v.jsx("div",{className:"rounded-md border border-red-900/50 bg-red-950/20 p-2 text-sm text-red-400",children:D}),v.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[v.jsx("button",{type:"button",onClick:t,className:"rounded-md bg-gray-700 px-4 py-2 text-sm text-white hover:bg-gray-600",children:"Cancel"}),v.jsx("button",{type:"button",onClick:Oe,disabled:!Ce||U,className:"rounded-md bg-cyan-600 px-4 py-2 text-sm font-medium text-white hover:bg-cyan-500 disabled:opacity-50",children:U?"Launching…":"Run Now"})]})]})})}function YP({children:e,onClose:t,title:r}){return v.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/60 pt-[10vh]",children:v.jsxs("div",{className:"w-full max-w-lg rounded-lg border border-gray-700 bg-gray-900 shadow-xl",children:[v.jsxs("div",{className:"flex items-center justify-between border-b border-gray-800 px-5 py-3",children:[v.jsx("h2",{className:"text-lg font-semibold text-white",children:r}),v.jsx("button",{type:"button",onClick:t,className:"text-gray-400 hover:text-white",children:"✕"})]}),v.jsx("div",{className:"px-5 py-4",children:e})]})})}function Qte({status:e,onClose:t,onRunInBackground:r,runId:n}){const i=e.status==="finished"||e.status==="failed",l={starting:"text-yellow-400",running:"text-cyan-400",finished:"text-emerald-400",failed:"text-red-400"};return v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsxs("span",{className:`text-sm font-medium ${l[e.status]??"text-gray-400"}`,children:[e.status==="running"&&"●"," ",e.status.charAt(0).toUpperCase()+e.status.slice(1)]}),!i&&v.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-cyan-400 border-t-transparent"})]}),v.jsx("div",{className:"rounded-md border border-gray-700 bg-gray-950 p-3",children:v.jsx("code",{className:"block break-all text-xs text-cyan-300",children:e.command})}),e.stdout&&v.jsx("div",{className:"max-h-48 overflow-y-auto rounded-md bg-gray-950 p-3",children:v.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-300",children:e.stdout.slice(-3e3)})}),e.stderr&&v.jsx("div",{className:"max-h-24 overflow-y-auto rounded-md bg-red-950/20 p-3",children:v.jsx("pre",{className:"whitespace-pre-wrap text-xs text-red-300",children:e.stderr.slice(-2e3)})}),v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("span",{className:"text-xs text-gray-500",children:i?v.jsxs(v.Fragment,{children:["Exit code: ",e.exit_code,e.finished_at&&` · ${new Date(e.finished_at).toLocaleTimeString()}`]}):n&&v.jsx("button",{type:"button",onClick:r,className:"text-xs text-gray-400 hover:text-cyan-400",children:"Run in background"})}),i&&v.jsx("button",{type:"button",onClick:t,className:"rounded-md bg-gray-700 px-4 py-2 text-sm text-white hover:bg-gray-600",children:"Close"})]})]})}function Xte(e){if(!e)return{date:"N/A",full:"N/A"};try{const t=new Date(e);if(Number.isNaN(t.getTime()))return{date:"N/A",full:"N/A"};const r=t.toLocaleString(),n=Date.now()-t.getTime(),i=Math.floor(n/6e4),l=Math.floor(n/36e5);let u;return i<1?u="just now":i<60?u=`${i} min ago`:l<24?u=`${l} hour${l===1?"":"s"} ago`:u=t.toLocaleDateString(),{date:u,full:r}}catch{return{date:"N/A",full:"N/A"}}}function pp({runs:e,projectId:t,emptyMessage:r}){const{data:n}=bt(t),i=(n==null?void 0:n.threshold)??_c;return e.length===0?v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:r??v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No evaluation runs found."}),v.jsxs("p",{className:"mt-2 text-sm text-gray-500",children:["Run an evaluation first:"," ",v.jsx("code",{className:"rounded bg-gray-800 px-2 py-1 text-cyan-400",children:"agentv eval <eval-file>"})]})]})}):v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"w-8 px-4 py-3"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Run"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Passed"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Failed"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Total"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Pass Rate"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"When"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:e.map(l=>{const u=Xte(l.timestamp),c=l.pass_rate>=i,d=l.status==="starting"||l.status==="running",h=bh(l),m=Math.round(l.pass_rate*l.test_count),p=l.test_count-m;return v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3 text-center",children:d?v.jsx("span",{className:"inline-block h-2 w-2 animate-pulse rounded-full bg-cyan-400",title:l.status==="starting"?"Starting…":"Running…","aria-label":l.status==="starting"?"Starting":"Running"}):v.jsx("span",{className:`text-base font-bold ${c?"text-emerald-400":"text-red-400"}`,children:c?"✓":"✗"})}),v.jsx("td",{className:"px-4 py-3",children:t?v.jsx(Se,{to:"/projects/$projectId/runs/$runId",params:{projectId:t,runId:l.filename},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:h}):v.jsx(Se,{to:"/runs/$runId",params:{runId:l.filename},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:h})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-emerald-300",children:m}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-red-400",children:p>0?p:v.jsx("span",{className:"text-gray-600",children:"0"})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:l.test_count}),v.jsx("td",{className:"px-4 py-3",children:v.jsx(wn,{rate:l.pass_rate})}),v.jsx("td",{className:"px-4 py-3 text-gray-400",title:u.full,children:u.date})]},l.filename)})})]})})}function Zte(e){if(!e)return"Never synced";const t=new Date(e);return Number.isNaN(t.getTime())?"Never synced":`Last synced ${t.toLocaleString()}`}function C3({filter:e,onFilterChange:t,remoteStatus:r,syncInFlight:n,onSync:i}){const l=(r==null?void 0:r.configured)===!0,u=l&&(r==null?void 0:r.available)!==!0;return v.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-gray-800 bg-gray-900/40 p-4",children:[v.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[v.jsx("div",{className:"flex flex-wrap items-center gap-2",children:["all","local","remote"].map(c=>{const d=c==="remote"&&!l;return v.jsx("button",{type:"button",onClick:()=>t(c),title:d?"Remote results are not configured":void 0,className:`rounded-full px-3 py-1 text-sm font-medium transition-colors ${e===c?"bg-cyan-500/20 text-cyan-300":d?"bg-gray-800 text-gray-600":"bg-gray-800 text-gray-400 hover:text-gray-200"}`,children:c==="all"?"All Sources":c==="local"?"Local Only":"Remote Only"},c)})}),l&&i?v.jsx("button",{type:"button",onClick:i,disabled:n,className:"rounded-md border border-cyan-800 bg-cyan-950/40 px-3 py-1.5 text-sm font-medium text-cyan-300 transition-colors hover:bg-cyan-900/50 disabled:cursor-not-allowed disabled:opacity-60",children:n?"Syncing…":"Sync Remote Results"}):null]}),l?v.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-gray-400",children:[v.jsx("span",{children:Zte(r==null?void 0:r.last_synced_at)}),r!=null&&r.repo?v.jsxs("span",{children:["Repo: ",r.repo]}):null,u?v.jsx("span",{className:"text-yellow-400",children:"Remote cache unavailable"}):null]}):e==="all"?v.jsxs("p",{className:"text-sm text-gray-500",children:["Remote results are not configured. Add"," ",v.jsx("code",{className:"rounded bg-gray-800 px-1 text-gray-400",children:"results.export"})," to"," ",v.jsx("code",{className:"rounded bg-gray-800 px-1 text-gray-400",children:".agentv/config.yaml"})," to enable."]}):null,r!=null&&r.last_error?v.jsx("div",{className:"rounded-md border border-yellow-900/50 bg-yellow-950/20 px-3 py-2 text-sm text-yellow-300",children:r.last_error}):null]})}function M3({projectId:e}={}){var p,g;const[t,r]=j.useState(null),n=Fe(e?$$(e):w$),i=Fe(e?fb(e):ub),l=((p=n.data)==null?void 0:p.targets)??[],u=((g=i.data)==null?void 0:g.runs)??[],c=n.error??i.error,d=n.isLoading||i.isLoading,h=j.useMemo(()=>l.find(x=>x.name===t)??null,[t,l]);j.useEffect(()=>{t&&!l.some(x=>x.name===t)&&r(null)},[t,l]);const m=j.useMemo(()=>{if(!h)return[];const x=new Map;for(const S of u){if((S.target??"default")!==h.name)continue;const O=S.experiment??"default",_=x.get(O)??[];_.push(S),x.set(O,_)}return[...x.entries()].map(([S,w])=>Wte(S,w)).sort((S,w)=>S.latestTimestamp&&w.latestTimestamp&&S.latestTimestamp!==w.latestTimestamp?w.latestTimestamp.localeCompare(S.latestTimestamp):S.latestTimestamp?-1:w.latestTimestamp?1:S.name.localeCompare(w.name))},[u,h]);return d?v.jsx(tre,{}):c?v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load targets: ",c.message]}):l.length===0?v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No targets found"}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"Targets will appear here once evaluations are run with target labels."})]}):h?v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"space-y-3",children:[v.jsx("button",{type:"button",onClick:()=>r(null),className:"rounded-md px-3 py-1.5 text-sm text-gray-400 transition-colors hover:text-gray-200",children:"← Back to targets"}),v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900/50 p-4",children:v.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[v.jsxs("div",{children:[v.jsx("h2",{className:"text-xl font-semibold text-white",children:h.name}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:[h.run_count," run",h.run_count===1?"":"s"," ·"," ",h.experiment_count," experiment",h.experiment_count===1?"":"s"," ·"," ",v.jsx("span",{className:"text-emerald-400",children:h.passed_count}),v.jsx("span",{className:"text-gray-600",children:" / "}),h.eval_count," evals passed"]})]}),v.jsx("div",{className:"w-full max-w-52",children:v.jsx(wn,{rate:h.pass_rate})})]})})]}),m.length===0?v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No runs found for this target"}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"This target summary exists, but there are no matching runs to group by experiment."})]}):v.jsx("div",{className:"space-y-6",children:m.map(x=>v.jsxs("section",{className:"space-y-3",children:[v.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-gray-800 bg-gray-900/40 p-4 sm:flex-row sm:items-center sm:justify-between",children:[v.jsxs("div",{children:[v.jsx("h3",{className:"text-lg font-medium text-gray-200",children:Jte(x.name)}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:[x.runs.length," run",x.runs.length===1?"":"s"," ·"," ",v.jsx("span",{className:"text-emerald-400",children:x.passedCount}),v.jsx("span",{className:"text-gray-600",children:" / "}),x.evalCount," evals passed",x.latestTimestamp&&v.jsxs("span",{className:"ml-2 text-gray-500",children:["· Last run ",ere(x.latestTimestamp)]})]})]}),v.jsx("div",{className:"w-full max-w-52",children:v.jsx(wn,{rate:x.passRate})})]}),v.jsx(pp,{runs:x.runs,projectId:e})]},x.name))})]}):v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Target"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Runs"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Experiments"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Pass Rate"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Evals"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:l.map(x=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3",children:v.jsx("button",{type:"button",onClick:()=>r(x.name),className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:x.name})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:x.run_count}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:x.experiment_count}),v.jsx("td",{className:"px-4 py-3",children:v.jsx(wn,{rate:x.pass_rate})}),v.jsxs("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:[v.jsx("span",{className:"text-emerald-400",children:x.passed_count}),v.jsx("span",{className:"text-gray-600",children:" / "}),v.jsx("span",{children:x.eval_count})]})]},x.name))})]})})}function Wte(e,t){let r=0,n=0,i=null;for(const l of t)r+=l.test_count,n+=Math.round(l.pass_rate*l.test_count),l.timestamp&&(!i||l.timestamp>i)&&(i=l.timestamp);return{name:e,runs:t,latestTimestamp:i,evalCount:r,passedCount:n,passRate:r>0?n/r:0}}function Jte(e){return e==="default"?"Default experiment":e}function ere(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return e;const r=Date.now()-t.getTime(),n=Math.floor(r/6e4),i=Math.floor(r/36e5);return n<1?"just now":n<60?`${n} min ago`:i<24?`${i} hour${i===1?"":"s"} ago`:t.toLocaleDateString()}function tre(){return v.jsxs("div",{className:"space-y-4",children:[v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900/50 p-4",children:[v.jsx("div",{className:"h-6 w-40 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"mt-3 h-4 w-72 animate-pulse rounded bg-gray-800"})]}),v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("div",{className:"animate-pulse",children:[v.jsx("div",{className:"border-b border-gray-800 bg-gray-900/50 px-4 py-3",children:v.jsx("div",{className:"h-4 w-48 rounded bg-gray-800"})}),["sk-1","sk-2","sk-3","sk-4","sk-5"].map(e=>v.jsxs("div",{className:"flex gap-4 border-b border-gray-800/50 px-4 py-3",children:[v.jsx("div",{className:"h-4 w-32 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-12 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-12 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-48 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-20 rounded bg-gray-800"})]},e))]})}),v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900/40 p-4",children:[v.jsx("div",{className:"h-5 w-48 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"mt-3 h-4 w-56 animate-pulse rounded bg-gray-800"})]})]})}const GP=[{id:"runs",label:"🏃 Recent Runs"},{id:"experiments",label:"🧪 Experiments"},{id:"analytics",label:"📊 Analytics"},{id:"targets",label:"🤖 Targets"}],rre=_r("/")({component:nre});function nre(){const e=il(),n=lb().location.search.tab,{data:i,isLoading:l}=cb(),{data:u,isLoading:c}=bt(),d=(i==null?void 0:i.projects)??[],h=d$(d.map(m=>m.id),u==null?void 0:u.project_dashboard,n);return j.useEffect(()=>{h.kind==="redirect"&&h.redirectPath&&e({to:h.redirectPath,replace:!0})},[h,e]),l||c?v.jsx(Gx,{}):h.kind==="redirect"?v.jsx(Gx,{}):h.kind==="dashboard"?v.jsx(are,{}):v.jsx(ire,{})}function are(){const{data:e}=cb(),{data:t}=bt(),r=Fa(),[n,i]=j.useState(""),[l,u]=j.useState(null),[c,d]=j.useState(!1),[h,m]=j.useState(!1),p=(e==null?void 0:e.projects)??[],g=(t==null?void 0:t.read_only)===!0;async function x(S){if(S.preventDefault(),!!n.trim()){u(null);try{await k$(n.trim()),i(""),d(!1),r.invalidateQueries({queryKey:["projects"]})}catch(w){u(w.message)}}}return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:"Projects"}),v.jsx("div",{className:"flex gap-2",children:!g&&v.jsxs(v.Fragment,{children:[v.jsx("button",{type:"button",onClick:()=>m(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run Eval"}),v.jsx("button",{type:"button",onClick:()=>d(!c),className:"rounded-md bg-cyan-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-cyan-500",children:c?"Cancel":"Add Project"})]})})]}),l&&v.jsx("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-3 text-sm text-red-400",children:l}),!g&&c&&v.jsx("div",{className:"space-y-3 rounded-lg border border-gray-800 bg-gray-900/50 p-4",children:v.jsxs("form",{onSubmit:x,className:"flex gap-2",children:[v.jsx("input",{type:"text",value:n,onChange:S=>i(S.target.value),placeholder:"Project path (e.g., /home/user/projects/my-evals)",className:"flex-1 rounded-md border border-gray-700 bg-gray-800 px-3 py-1.5 text-sm text-white placeholder-gray-500 focus:border-cyan-600 focus:outline-none"}),v.jsx("button",{type:"submit",className:"rounded-md bg-cyan-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-cyan-500",children:"Add"})]})}),p.length===0?v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900/50 p-8 text-center",children:[v.jsx("p",{className:"text-lg text-gray-300",children:"No projects registered yet."}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"Add a project path to start browsing runs, experiments, analytics, and targets."})]}):v.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:p.map(S=>v.jsx(Yte,{project:S},S.id))}),!g&&v.jsx(hl,{open:h,onClose:()=>m(!1)})]})}function ire(){const r=lb().location.search.tab,n=il(),i=Fa(),{data:l,isLoading:u,error:c}=WC(),{data:d}=tM(),{data:h}=bt(),[m,p]=j.useState(!1),[g,x]=j.useState("all"),[S,w]=j.useState(!1),O=(h==null?void 0:h.read_only)===!0,_=GP.some(A=>A.id===r)?r:"experiments",E=g==="all"?(l==null?void 0:l.runs)??[]:((l==null?void 0:l.runs)??[]).filter(A=>A.source===g);async function T(){w(!0);try{await iM(),await Promise.all([i.invalidateQueries({queryKey:["runs"]}),i.invalidateQueries({queryKey:["experiments"]}),i.invalidateQueries({queryKey:["compare"]}),i.invalidateQueries({queryKey:["targets"]}),i.invalidateQueries({queryKey:["remote-status",""]})])}finally{w(!1)}}return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:"Evaluation Runs"}),(h==null?void 0:h.project_name)&&v.jsx("p",{className:"mt-0.5 text-sm text-gray-500",children:h.project_name})]}),!O&&v.jsx("button",{type:"button",onClick:()=>p(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run Eval"})]}),v.jsx("div",{className:"border-b border-gray-800",children:v.jsx("div",{className:"flex gap-1",children:GP.map(A=>v.jsx("button",{type:"button",onClick:()=>n({to:"/",search:{tab:A.id}}),className:`px-4 py-2 text-sm font-medium transition-colors ${_===A.id?"border-b-2 border-cyan-400 text-cyan-400":"text-gray-400 hover:text-gray-300"}`,children:A.label},A.id))})}),_==="runs"&&v.jsx(lre,{runs:E,isLoading:u,error:c,sourceFilter:g,onSourceFilterChange:x,remoteStatus:d,syncInFlight:S,onSyncRemote:T}),_==="experiments"&&v.jsx(P3,{}),_==="analytics"&&v.jsx(sre,{readOnly:O}),_==="targets"&&v.jsx(M3,{}),!O&&v.jsx(hl,{open:m,onClose:()=>p(!1)})]})}function sre({readOnly:e}){const{data:t,isLoading:r,isError:n,error:i}=T$();return v.jsx(A3,{data:t,isLoading:r,isError:n,error:i,readOnly:e})}function lre({runs:e,isLoading:t,error:r,sourceFilter:n,onSourceFilterChange:i,remoteStatus:l,syncInFlight:u,onSyncRemote:c}){return t?v.jsx(Gx,{}):r?v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load runs: ",r.message]}):v.jsxs("div",{className:"space-y-4",children:[v.jsx(ore,{}),v.jsx(C3,{filter:n,onFilterChange:i,remoteStatus:l,syncInFlight:u,onSync:c}),v.jsx(pp,{runs:e,emptyMessage:n==="remote"?l!=null&&l.configured?v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No remote runs found."}),v.jsxs("p",{className:"mt-2 text-sm text-gray-500",children:["Sync remote results or run an eval with"," ",v.jsx("code",{className:"rounded bg-gray-800 px-2 py-1 text-cyan-400",children:"auto_push: true"})," ","in your config."]})]}):v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"text-lg text-gray-400",children:"Remote results are not configured."}),v.jsxs("p",{className:"mt-2 text-sm text-gray-500",children:["Add"," ",v.jsx("code",{className:"rounded bg-gray-800 px-2 py-1 text-cyan-400",children:"results.export"})," ","to"," ",v.jsx("code",{className:"rounded bg-gray-800 px-2 py-1 text-cyan-400",children:".agentv/config.yaml"})," ","to enable remote result syncing."]})]}):void 0})]})}function ore(){const{data:e}=mb(),t=((e==null?void 0:e.runs)??[]).filter(r=>r.status==="starting"||r.status==="running");return t.length===0?null:v.jsxs("div",{className:"rounded-lg border border-cyan-900/40 bg-cyan-950/10",children:[v.jsx("div",{className:"border-b border-cyan-900/30 px-4 py-2.5",children:v.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-cyan-400",children:"Active"})}),v.jsx("ul",{className:"divide-y divide-gray-800/50",children:t.map(r=>v.jsxs("li",{className:"flex items-center justify-between px-4 py-3",children:[v.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[v.jsx("span",{className:"inline-block h-2 w-2 flex-shrink-0 animate-pulse rounded-full bg-cyan-400"}),v.jsx("span",{className:"truncate font-mono text-sm text-gray-300",children:r.id}),v.jsx("span",{className:"flex-shrink-0 text-xs text-gray-500",children:new Date(r.started_at).toLocaleTimeString()})]}),v.jsx(Se,{to:"/jobs/$runId",params:{runId:r.id},className:"ml-4 flex-shrink-0 text-xs text-cyan-400 hover:text-cyan-300",children:"View Log →"})]},r.id))})]})}function Gx(){return v.jsx("div",{className:"space-y-2",children:["s1","s2","s3","s4","s5"].map(e=>v.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-gray-900"},e))})}function ure(e,t,r){return t?!1:!!(e.some(n=>n.executionStatus==="execution_error")||r!==void 0&&e.length<r)}function cre(e){const t={suite_filter:e.suiteFilter,output:e.runDir};return e.target&&(t.target=e.target),e.mode==="resume"?t.resume=!0:t.rerun_failed=!0,t}function R3({results:e,runDir:t,suiteFilter:r,target:n,projectId:i,isReadOnly:l,plannedTestCount:u}){const c=il(),[d,h]=j.useState(null),[m,p]=j.useState(null);if(!ure(e,l,u))return null;const g=!!t&&!!r,x=t?r?"":"Original eval file path missing from benchmark.json — cannot determine what to resume":"Run directory unavailable (remote run cannot be resumed in place)";async function S(w){if(!(!g||!t||!r)){h(w),p(null);try{const O=cre({mode:w,runDir:t,suiteFilter:r,target:n}),_=await sM(O,i);c(i?{to:"/projects/$projectId/jobs/$runId",params:{projectId:i,runId:_.id}}:{to:"/jobs/$runId",params:{runId:_.id}})}catch(O){p(O instanceof Error?O.message:"Failed to launch resume"),h(null)}}}return v.jsxs("div",{className:"flex flex-col items-end gap-1",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("button",{type:"button",onClick:()=>S("resume"),disabled:!g||d!==null,title:g?"Skip already-completed tests, run the rest":x,className:"rounded-md bg-amber-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-amber-500 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"resume-run-button",children:d==="resume"?"Resuming…":"↻ Resume run"}),v.jsx("button",{type:"button",onClick:()=>S("rerun"),disabled:!g||d!==null,title:g?"Re-run failed/errored tests, keep passing results":x,className:"rounded-md border border-amber-600/60 bg-transparent px-3 py-1.5 text-sm font-medium text-amber-300 hover:bg-amber-950/40 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"rerun-failed-button",children:d==="rerun"?"Re-running…":"Rerun failed cases"})]}),m&&v.jsx("p",{className:"text-xs text-red-400",children:m})]})}function qo({total:e,passed:t,failed:r,passRate:n,totalCost:i}){const l=Math.round(n*100),u=l>=80?"text-cyan-400":l>=60?"text-amber-400":"text-red-400";return v.jsxs("div",{className:"flex flex-wrap items-center gap-6 rounded-lg border border-gray-800 bg-gray-900/60 px-5 py-3",children:[v.jsx(fc,{label:"Pass Rate",value:`${l}%`,accent:u,large:!0}),v.jsx("div",{className:"h-6 w-px bg-gray-700"}),v.jsx(fc,{label:"Passed",value:String(t),accent:"text-emerald-400"}),v.jsx(fc,{label:"Failed",value:String(r),accent:"text-red-400"}),v.jsx(fc,{label:"Total",value:String(e)}),i!==void 0&&v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"h-6 w-px bg-gray-700"}),v.jsx(fc,{label:"Cost",value:`$${i.toFixed(4)}`,accent:"text-amber-400"})]})]})}function fc({label:e,value:t,accent:r,large:n}){return v.jsxs("div",{className:"flex flex-col",children:[v.jsx("span",{className:"text-xs text-gray-500",children:e}),v.jsx("span",{className:`tabular-nums font-semibold ${n?"text-2xl":"text-lg"} ${r??"text-white"}`,children:t})]})}function fre(e,t){const r=new Map;for(const n of e){const i=n.category??"Uncategorized",l=n.suite??"Uncategorized";r.has(i)||r.set(i,new Map);const u=r.get(i),c=u.get(l)??{passed:0,failed:0,total:0,scoreSum:0};c.total+=1,c.scoreSum+=n.score,Jr(n.score,t)?c.passed+=1:c.failed+=1,u.set(l,c)}return Array.from(r.entries()).map(([n,i])=>{const l=Array.from(i.entries()).map(([m,p])=>({name:m,...p,avgScore:p.total>0?p.scoreSum/p.total:0})).sort((m,p)=>m.name.localeCompare(p.name)),u=l.reduce((m,p)=>m+p.total,0),c=l.reduce((m,p)=>m+p.passed,0),d=l.reduce((m,p)=>m+p.failed,0),h=l.reduce((m,p)=>m+p.avgScore*p.total,0);return{name:n,suites:l,total:u,passed:c,failed:d,avgScore:u>0?h/u:0}}).sort((n,i)=>n.name.localeCompare(i.name))}function D3({results:e,runId:t,projectId:r}){const{data:n}=bt(r),i=(n==null?void 0:n.threshold)??(n==null?void 0:n.pass_threshold)??.8,l=e.length,u=e.filter(p=>Jr(p.score,i)).length,c=l-u,d=l>0?u/l:0,h=e.reduce((p,g)=>p+(g.costUsd??0),0),m=fre(e,i);return l===0?v.jsxs("div",{className:"space-y-6",children:[v.jsx(qo,{total:0,passed:0,failed:0,passRate:0}),v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No evaluations found"}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"This run has no results yet."})]})]}):v.jsxs("div",{className:"space-y-6",children:[v.jsx(qo,{total:l,passed:u,failed:c,passRate:d,totalCost:h>0?h:void 0}),v.jsxs("div",{children:[v.jsx("h3",{className:"mb-3 text-sm font-medium text-gray-400",children:"Category Breakdown"}),v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-2.5 font-medium text-gray-400",children:"Category"}),v.jsx("th",{className:"px-4 py-2.5 font-medium text-gray-400",children:"Pass Rate"}),v.jsx("th",{className:"px-4 py-2.5 text-right font-medium text-gray-400",children:"Passed"}),v.jsx("th",{className:"px-4 py-2.5 text-right font-medium text-gray-400",children:"Failed"}),v.jsx("th",{className:"px-4 py-2.5 text-right font-medium text-gray-400",children:"Total"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:m.map(p=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-2.5 font-medium text-gray-200",children:r?v.jsx(Se,{to:"/projects/$projectId/runs/$runId/category/$category",params:{projectId:r,runId:t,category:p.name},className:"text-cyan-400 hover:text-cyan-300 hover:underline",children:p.name}):v.jsx(Se,{to:"/runs/$runId/category/$category",params:{runId:t,category:p.name},className:"text-cyan-400 hover:text-cyan-300 hover:underline",children:p.name})}),v.jsx("td",{className:"px-4 py-2.5",children:v.jsx(wn,{rate:p.total>0?p.passed/p.total:0})}),v.jsx("td",{className:"px-4 py-2.5 text-right tabular-nums text-emerald-400",children:p.passed}),v.jsx("td",{className:"px-4 py-2.5 text-right tabular-nums text-red-400",children:p.failed>0?p.failed:v.jsx("span",{className:"text-gray-600",children:"0"})}),v.jsx("td",{className:"px-4 py-2.5 text-right tabular-nums text-gray-400",children:p.total})]},p.name))})]})})]}),v.jsxs("div",{children:[v.jsx("h3",{className:"mb-3 text-sm font-medium text-gray-400",children:"All Evals"}),v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"w-8 px-4 py-3"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Test ID"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Target"}),v.jsx("th",{className:"w-48 px-4 py-3 font-medium text-gray-400",children:"Score"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Duration"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Cost"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:e.map((p,g)=>{const x=p.executionStatus==="execution_error",S=Jr(p.score,i);return v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3 text-center",children:x?v.jsx("span",{className:"text-base font-bold text-red-400",children:"!"}):v.jsx("span",{className:`text-base font-bold ${S?"text-emerald-400":"text-red-400"}`,children:S?"✓":"✗"})}),v.jsx("td",{className:"px-4 py-3",children:r?v.jsx(Se,{to:"/projects/$projectId/evals/$runId/$evalId",params:{projectId:r,runId:t,evalId:p.testId},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:p.testId}):v.jsx(Se,{to:"/evals/$runId/$evalId",params:{runId:t,evalId:p.testId},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:p.testId})}),v.jsx("td",{className:"px-4 py-3 text-gray-400",children:p.target??"-"}),v.jsx("td",{className:"px-4 py-3",children:x?v.jsx("span",{className:"inline-flex rounded-full bg-red-900/50 px-2 py-0.5 text-xs font-medium text-red-400",children:"ERR"}):v.jsx(wn,{rate:p.score})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:p.durationMs!=null?`${(p.durationMs/1e3).toFixed(1)}s`:"-"}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:p.costUsd!=null?`$${p.costUsd.toFixed(4)}`:"-"})]},`${p.testId}-${g}`)})})]})})]}),v.jsx(dre,{runId:t,projectId:r})]})}function dre({runId:e,projectId:t}){const[r,n]=j.useState(!1),{data:i,isLoading:l,error:u}=g$(e,t);return!l&&!u&&i==null?null:v.jsxs("div",{children:[v.jsxs("button",{type:"button",onClick:()=>n(c=>!c),className:"flex w-full items-center justify-between rounded-lg border border-gray-800 bg-gray-900/50 px-4 py-2 text-left text-sm font-medium text-gray-300 transition-colors hover:bg-gray-900","aria-expanded":r,children:[v.jsxs("span",{className:"flex items-center gap-2",children:[v.jsx("span",{"aria-hidden":"true",children:r?"▾":"▸"}),"Console Log"]}),v.jsx("span",{className:"text-xs text-gray-500",children:l?"Loading…":u?"Failed to load":i?`${i.length} chars`:""})]}),r&&v.jsx("div",{className:"mt-2 overflow-hidden rounded-lg border border-gray-800 bg-black",children:u?v.jsxs("div",{className:"p-4 text-sm text-red-400",children:["Failed to load console log: ",u.message]}):v.jsx("pre",{className:"max-h-[480px] overflow-auto whitespace-pre-wrap break-words p-4 font-mono text-xs leading-relaxed text-gray-200",children:i??""})})]})}const k3=_r("/runs/$runId")({component:hre});function hre(){var w;const{runId:e}=k3.useParams(),{data:t,isLoading:r,error:n}=Gc(e),{data:i}=bt(),[l,u]=j.useState(!1),c=(i==null?void 0:i.read_only)===!0;if(r)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-5 gap-4",children:["s1","s2","s3","s4","s5"].map(O=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},O))})]});if(n)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load run: ",n.message]});const d=(w=t==null?void 0:t.results)==null?void 0:w[0],h=d==null?void 0:d.target,m=d==null?void 0:d.experiment,p=d==null?void 0:d.timestamp,g=h?{target:h}:void 0,x=(()=>{const O=[m,h].filter(_=>_&&_!=="default");return O.length>0?O.join(" · "):e})(),S=[h,m&&m!=="default"?m:null,p?new Date(p).toLocaleString():null,t==null?void 0:t.source].filter(Boolean).join(" · ");return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:x}),v.jsx("p",{className:"mt-1 text-sm text-gray-500",children:S})]}),v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsx(R3,{results:(t==null?void 0:t.results)??[],runDir:t==null?void 0:t.run_dir,suiteFilter:t==null?void 0:t.suite_filter,target:h??void 0,isReadOnly:c,plannedTestCount:t==null?void 0:t.planned_test_count}),!c&&v.jsx("button",{type:"button",onClick:()=>u(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run evals"})]})]}),v.jsx(D3,{results:(t==null?void 0:t.results)??[],runId:e}),!c&&v.jsx(hl,{open:l,onClose:()=>u(!1),prefill:g})]})}const VP=[{id:"runs",label:"🏃 Recent Runs"},{id:"experiments",label:"🧪 Experiments"},{id:"analytics",label:"📊 Analytics"},{id:"targets",label:"🤖 Targets"}],I3=_r("/projects/$projectId")({component:mre});function mre(){const{projectId:e}=I3.useParams(),n=lb().location.search.tab,i=il(),[l,u]=j.useState(!1),{data:c}=bt(e),d=(c==null?void 0:c.read_only)===!0,h=VP.some(m=>m.id===n)?n:"experiments";return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:e}),!d&&v.jsx("button",{type:"button",onClick:()=>u(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run Eval"})]}),v.jsx("div",{className:"border-b border-gray-800",children:v.jsx("div",{className:"flex gap-1",children:VP.map(m=>v.jsx("button",{type:"button",onClick:()=>i({to:"/projects/$projectId",params:{projectId:e},search:{tab:m.id}}),className:`px-4 py-2 text-sm font-medium transition-colors ${h===m.id?"border-b-2 border-cyan-400 text-cyan-400":"text-gray-400 hover:text-gray-300"}`,children:m.label},m.id))})}),h==="runs"&&v.jsx(pre,{projectId:e}),h==="experiments"&&v.jsx(P3,{projectId:e}),h==="analytics"&&v.jsx(vre,{projectId:e,readOnly:d}),h==="targets"&&v.jsx(M3,{projectId:e}),!d&&v.jsx(hl,{open:l,onClose:()=>u(!1),projectId:e})]})}function pre({projectId:e}){const t=Fa(),{data:r,isLoading:n,error:i}=rM(e),{data:l}=mb(e),{data:u}=tM(e),[c,d]=j.useState("all"),[h,m]=j.useState(!1),p=((l==null?void 0:l.runs)??[]).filter(S=>S.status==="starting"||S.status==="running"),g=c==="all"?(r==null?void 0:r.runs)??[]:((r==null?void 0:r.runs)??[]).filter(S=>S.source===c);async function x(){m(!0);try{await iM(e),await Promise.all([t.invalidateQueries({queryKey:["projects",e,"runs"]}),t.invalidateQueries({queryKey:["projects",e,"experiments"]}),t.invalidateQueries({queryKey:["projects",e,"compare"]}),t.invalidateQueries({queryKey:["projects",e,"targets"]}),t.invalidateQueries({queryKey:["remote-status",e]})])}finally{m(!1)}}return n?v.jsx("div",{className:"space-y-2",children:["s1","s2","s3"].map(S=>v.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-gray-900"},S))}):i?v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load runs: ",i.message]}):v.jsxs("div",{className:"space-y-4",children:[p.length>0&&v.jsxs("div",{className:"rounded-lg border border-cyan-900/40 bg-cyan-950/10",children:[v.jsx("div",{className:"border-b border-cyan-900/30 px-4 py-2.5",children:v.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-cyan-400",children:"Active"})}),v.jsx("ul",{className:"divide-y divide-gray-800/50",children:p.map(S=>v.jsxs("li",{className:"flex items-center justify-between gap-4 px-4 py-3",children:[v.jsxs("div",{className:"min-w-0 flex items-center gap-3",children:[v.jsx("span",{className:"inline-block h-2 w-2 flex-shrink-0 animate-pulse rounded-full bg-cyan-400"}),v.jsx("span",{className:"truncate font-mono text-sm text-gray-300",children:S.id}),v.jsx("span",{className:"flex-shrink-0 text-xs text-gray-500",children:new Date(S.started_at).toLocaleTimeString()})]}),v.jsx(Se,{to:"/projects/$projectId/jobs/$runId",params:{projectId:e,runId:S.id},className:"flex-shrink-0 text-xs text-cyan-400 hover:text-cyan-300",children:"View Log →"})]},S.id))})]}),v.jsx(C3,{filter:c,onFilterChange:d,remoteStatus:u,syncInFlight:h,onSync:x}),v.jsx(pp,{runs:g,projectId:e})]})}function vre({projectId:e,readOnly:t}){const{data:r,isLoading:n,isError:i,error:l}=Fe(aM(e));return v.jsx(A3,{data:r,isLoading:n,isError:i,error:l,projectId:e,readOnly:t})}function yre(e){return e==="finished"||e==="failed"}function gre(e,t){return t||!e?!1:!yre(e)}function L3({runId:e,status:t,isReadOnly:r,projectId:n}){const[i,l]=j.useState(!1),[u,c]=j.useState(null);if(!gre(t,r))return null;async function d(){l(!0),c(null);try{await V$(e,n)}catch(h){c(h instanceof Error?h.message:"Failed to stop run"),l(!1)}}return v.jsxs("div",{className:"flex flex-col items-end gap-1",children:[v.jsx("button",{type:"button",onClick:d,disabled:i,className:"rounded-md border border-gray-700 bg-transparent px-3 py-1.5 text-sm font-medium text-gray-300 hover:bg-gray-800 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"stop-run-button",children:i?"Stopping…":"⏸ Stop"}),u&&v.jsx("p",{className:"text-xs text-red-400",children:u})]})}const z3=_r("/jobs/$runId")({component:xre});function xre(){const{runId:e}=z3.useParams(),{data:t,isLoading:r,error:n}=hb(e),{data:i}=bt(),l=(i==null?void 0:i.read_only)===!0;if(r)return v.jsxs("div",{className:"space-y-4",children:[v.jsx(E0,{}),v.jsx("div",{className:"h-8 w-48 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"h-64 animate-pulse rounded-lg bg-gray-900"})]});if(n||!t)return v.jsxs("div",{className:"space-y-4",children:[v.jsx(E0,{}),v.jsx("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-4 text-sm text-red-400",children:n?`Failed to load run: ${n.message}`:"Run not found."})]});const u=t.status==="finished"||t.status==="failed",d={starting:"text-yellow-400",running:"text-cyan-400",finished:"text-emerald-400",failed:"text-red-400"}[t.status]??"text-gray-400";return v.jsxs("div",{className:"space-y-4",children:[v.jsx(E0,{}),v.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-4",children:[v.jsxs("div",{className:"min-w-0",children:[v.jsx("h1",{className:"truncate font-mono text-base font-semibold text-white",children:e}),v.jsxs("p",{className:"mt-0.5 text-xs text-gray-500",children:["Started ",new Date(t.started_at).toLocaleString(),t.finished_at&&v.jsxs(v.Fragment,{children:[" · ","Finished ",new Date(t.finished_at).toLocaleString()," · ",Math.round((new Date(t.finished_at).getTime()-new Date(t.started_at).getTime())/1e3),"s"]})]})]}),v.jsxs("div",{className:"flex flex-shrink-0 items-center gap-3",children:[v.jsx(L3,{runId:e,status:t.status,isReadOnly:l}),v.jsx("span",{className:`text-sm font-medium ${d}`,children:t.status.charAt(0).toUpperCase()+t.status.slice(1)}),!u&&v.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-cyan-400 border-t-transparent"})]})]}),v.jsxs("div",{className:"rounded-md border border-gray-700 bg-gray-950 px-4 py-3",children:[v.jsx("p",{className:"mb-1 text-xs font-medium uppercase tracking-wider text-gray-500",children:"Command"}),v.jsx("code",{className:"break-all text-xs text-cyan-300",children:t.command})]}),t.stdout?v.jsxs("div",{children:[v.jsx("p",{className:"mb-1 text-xs font-medium uppercase tracking-wider text-gray-500",children:"Output"}),v.jsx("div",{className:"max-h-[60vh] overflow-y-auto rounded-lg border border-gray-700 bg-gray-950 p-4",children:v.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs text-gray-200",children:t.stdout})})]}):!u&&v.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[v.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-spin rounded-full border-2 border-gray-500 border-t-transparent"}),"Waiting for output…"]}),t.stderr&&v.jsxs("div",{children:[v.jsx("p",{className:"mb-1 text-xs font-medium uppercase tracking-wider text-red-500",children:"Stderr"}),v.jsx("div",{className:"max-h-48 overflow-y-auto rounded-lg border border-red-900/40 bg-red-950/20 p-4",children:v.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs text-red-300",children:t.stderr})})]}),u&&v.jsxs("p",{className:"text-xs text-gray-500",children:["Exit code:"," ",v.jsx("span",{className:t.exit_code===0?"text-emerald-400":"text-red-400",children:t.exit_code})]})]})}function E0(){return v.jsx(Se,{to:"/",search:{tab:"runs"},className:"text-xs text-gray-400 hover:text-cyan-400",children:"← Back to Runs"})}function $3({experimentName:e,projectId:t}){var g;const{data:r,isLoading:n}=Fe(t?db(t):ZC),{data:i,isLoading:l}=Fe(t?fb(t):ub);if(n||l)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-4 gap-4",children:["s1","s2","s3","s4"].map(x=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},x))})]});const c=(g=r==null?void 0:r.experiments)==null?void 0:g.find(x=>x.name===e),d=((i==null?void 0:i.runs)??[]).filter(x=>(x.experiment??"default")===e),h=(c==null?void 0:c.pass_rate)??0,m=(c==null?void 0:c.run_count)??d.length,p=(c==null?void 0:c.target_count)??0;return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:e}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:[m," run",m!==1?"s":""," · ",p," target",p!==1?"s":"",(c==null?void 0:c.last_run)&&v.jsxs("span",{className:"ml-2",children:["· Last run: ",QP(c.last_run)]})]})]}),c&&v.jsxs("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-4",children:[v.jsx(rh,{label:"Runs",value:String(m)}),v.jsx(rh,{label:"Targets",value:String(p)}),v.jsx(rh,{label:"Pass Rate",value:`${Math.round(h*100)}%`,accent:"text-cyan-400"}),v.jsx(rh,{label:"Last Run",value:QP(c.last_run)})]}),v.jsxs("div",{children:[v.jsx("h2",{className:"mb-4 text-lg font-medium text-gray-200",children:"All Runs"}),v.jsx(pp,{runs:d,projectId:t,emptyMessage:v.jsxs("div",{children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No evaluation runs found for this experiment."}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"Runs will appear here once this experiment has execution results."})]})})]})]})}function rh({label:e,value:t,accent:r}){return v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-4",children:[v.jsx("p",{className:"text-sm text-gray-400",children:e}),v.jsx("p",{className:`mt-1 text-2xl font-semibold tabular-nums ${r??"text-white"}`,children:t})]})}function QP(e){if(!e)return"N/A";try{const t=new Date(e);return Number.isNaN(t.getTime())?"N/A":t.toLocaleString()}catch{return"N/A"}}const B3=_r("/experiments/$experimentName")({component:bre});function bre(){const{experimentName:e}=B3.useParams();return v.jsx($3,{experimentName:e})}async function Sre(e,t){const r=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reviews:[{test_id:e,comment:t}]})});if(!r.ok)throw new Error(`Failed to save feedback: ${r.status}`);return r.json()}function wre({testId:e}){var m;const{data:t}=A$(),r=Fa(),n=(m=t==null?void 0:t.reviews)==null?void 0:m.find(p=>p.test_id===e),[i,l]=j.useState((n==null?void 0:n.comment)??""),[u,c]=j.useState(!1);j.useEffect(()=>{l((n==null?void 0:n.comment)??""),c(!1)},[n==null?void 0:n.comment]);const d=H0({mutationFn:()=>Sre(e,i),onSuccess:()=>{r.invalidateQueries({queryKey:["feedback"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),h=j.useCallback(()=>{d.mutate()},[d]);return v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-4",children:[v.jsx("h4",{className:"mb-2 text-sm font-medium text-gray-400",children:"Feedback"}),v.jsx("textarea",{value:i,onChange:p=>{l(p.target.value),c(!1)},placeholder:"Add feedback for this test...",className:"w-full rounded-md border border-gray-700 bg-gray-800 p-3 text-sm text-gray-200 placeholder-gray-500 focus:border-cyan-400 focus:outline-none",rows:3}),v.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[v.jsx("button",{type:"button",onClick:h,disabled:d.isPending,className:"rounded-md bg-cyan-600 px-4 py-1.5 text-sm font-medium text-white hover:bg-cyan-500 disabled:opacity-50",children:d.isPending?"Saving...":"Save Feedback"}),u&&v.jsx("span",{className:"text-sm text-emerald-400",children:"Saved"}),d.isError&&v.jsx("span",{className:"text-sm text-red-400",children:"Error saving feedback"})]})]})}function jre(e){var r;switch((r=e.split(".").pop())==null?void 0:r.toLowerCase()){case"ts":case"tsx":return"📘";case"json":return"📋";case"log":case"txt":return"📜";case"md":return"📝";default:return"📄"}}function U3(e){const t=[];for(const r of e)r.type==="dir"&&(t.push(r.path),r.children&&t.push(...U3(r.children)));return t}function q3({node:e,selectedPath:t,onSelect:r,openFolders:n,toggleFolder:i,depth:l=0}){const u=e.type==="dir",c=n.has(e.path),d=t===e.path;return v.jsxs("div",{children:[v.jsxs("button",{type:"button",onClick:()=>{u?i(e.path):r(e.path)},className:`flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm transition-colors ${d?"bg-cyan-400/20 text-cyan-400":"text-gray-300 hover:bg-gray-800/50 hover:text-gray-200"}`,style:{paddingLeft:`${l*16+8}px`},children:[v.jsx("span",{className:"flex-shrink-0 text-xs",children:u?c?"📂":"📁":jre(e.name)}),v.jsx("span",{className:"truncate",children:e.name})]}),u&&c&&e.children&&v.jsx("div",{children:e.children.map(h=>v.jsx(q3,{node:h,selectedPath:t,onSelect:r,openFolders:n,toggleFolder:i,depth:l+1},h.path))})]})}function Ore({files:e,selectedPath:t,onSelect:r}){const[n,i]=j.useState(()=>new Set(U3(e))),l=u=>{i(c=>{const d=new Set(c);return d.has(u)?d.delete(u):d.add(u),d})};return v.jsxs("div",{className:"w-64 overflow-y-auto rounded-lg border border-gray-800 bg-gray-900 py-2",children:[e.length===0&&v.jsx("p",{className:"px-4 py-2 text-sm text-gray-500",children:"No files."}),e.map(u=>v.jsx(q3,{node:u,selectedPath:t,onSelect:r,openFolders:n,toggleFolder:l},u.path))]})}const _re="modulepreload",Nre=function(e){return"/"+e},XP={},Ere=function(t,r,n){let i=Promise.resolve();if(r&&r.length>0){let u=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));i=u(r.map(h=>{if(h=Nre(h),h in XP)return;XP[h]=!0;const m=h.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":_re,m||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),m)return new Promise((x,S)=>{g.addEventListener("load",x),g.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${h}`)))})}))}function l(u){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=u,window.dispatchEvent(c),!c.defaultPrevented)throw u}return i.then(u=>{for(const c of u||[])c.status==="rejected"&&l(c.reason);return t().catch(l)})},Are=j.lazy(()=>Ere(()=>import("./index-SVeKAE-f.js"),[]));function Tre({value:e,language:t="json",height:r="400px"}){return v.jsx(j.Suspense,{fallback:v.jsx("div",{className:"flex items-center justify-center rounded-lg bg-gray-900 p-8 text-gray-500",children:"Loading editor..."}),children:v.jsx(Are,{height:r,language:t,value:e,theme:"vs-dark",options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:"on",wordWrap:"on",padding:{top:12}}})})}function vm({score:e,className:t=""}){const r=Math.round(Math.max(0,Math.min(1,e))*100);return v.jsxs("div",{className:`flex items-center gap-3 ${t}`,children:[v.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-gray-800",children:v.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-cyan-400 to-blue-500 transition-all duration-300",style:{width:`${r}%`}})}),v.jsxs("span",{className:"w-12 text-right text-sm font-medium tabular-nums text-gray-300",children:[r,"%"]})]})}function H3(e){for(const t of e){if(t.type==="file")return t.path;if(t.children){const r=H3(t.children);if(r)return r}}return null}function K3({eval:e,runId:t,projectId:r}){const[n,i]=j.useState("checks"),{data:l}=bt(r),u=(l==null?void 0:l.read_only)===!0,c=[{id:"checks",label:"Checks"},{id:"files",label:"Files"},...u?[]:[{id:"feedback",label:"Feedback"}]];return v.jsxs("div",{className:"flex min-h-full flex-col",children:[v.jsx("div",{className:"border-b border-gray-800",children:v.jsx("div",{className:"flex gap-1 px-4",children:c.map(d=>v.jsx("button",{type:"button",onClick:()=>i(d.id),className:`px-4 py-2 text-sm font-medium transition-colors ${n===d.id?"border-b-2 border-cyan-400 text-cyan-400":"text-gray-400 hover:text-gray-300"}`,children:d.label},d.id))})}),v.jsxs("div",{className:"min-h-0 flex-1",children:[n==="checks"&&v.jsx("div",{className:"overflow-auto p-4",children:v.jsx(Pre,{result:e,projectId:r})}),n==="files"&&v.jsx("div",{className:"h-full p-4",children:v.jsx(Cre,{result:e,runId:t,projectId:r})}),!u&&n==="feedback"&&v.jsx("div",{className:"p-4",children:v.jsx(wre,{testId:e.testId})})]})]})}function ZP({assertion:e}){return v.jsxs("div",{className:`flex items-start gap-3 rounded-lg border p-3 ${e.passed?"border-emerald-900/50 bg-emerald-950/20":"border-red-900/50 bg-red-950/20"}`,children:[v.jsx("span",{className:`mt-0.5 text-lg ${e.passed?"text-emerald-400":"text-red-400"}`,children:e.passed?"✓":"✗"}),v.jsxs("div",{className:"min-w-0 flex-1",children:[v.jsxs("p",{className:"text-sm text-gray-200",children:[e.text,e.durationMs!=null&&v.jsxs("span",{className:"ml-2 text-xs text-gray-500",children:["(",(e.durationMs/1e3).toFixed(1),"s)"]})]}),e.evidence&&v.jsx("p",{className:"mt-1 text-xs text-gray-400",children:e.evidence})]})]})}function Pre({result:e,projectId:t}){const{data:r}=bt(t),n=(r==null?void 0:r.threshold)??(r==null?void 0:r.pass_threshold)??.8,i=!Jr(e.score,n)||e.executionStatus==="error"||e.executionStatus==="failed",l=(e.scores??[]).filter(m=>Array.isArray(m.assertions)&&m.assertions.length>0),u=l.length>0,c=e.assertions??[],d=[];e.error&&d.push(e.error),(e.executionStatus==="error"||e.executionStatus==="failed")&&d.push(`Execution status: ${e.executionStatus}`);const h=u?l.flatMap(m=>m.assertions):c;for(const m of h.filter(p=>!p.passed)){const p=m.evidence?`${m.text}: ${m.evidence}`:m.text;d.push(p)}if(e.scores){for(const m of e.scores)if(!Jr(m.score,n)&&m.details){const p=typeof m.details=="string"?m.details:JSON.stringify(m.details,null,2);d.push(`[${m.name??m.type??"evaluator"}] ${p}`)}}return v.jsxs("div",{className:"space-y-6",children:[v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-4",children:v.jsxs("div",{className:"flex items-center gap-4",children:[v.jsx("span",{className:"text-sm font-medium text-gray-400",children:"Overall score"}),v.jsx("div",{className:"flex-1",children:v.jsx(vm,{score:e.score})})]})}),e.scores&&e.scores.length>0&&v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-4",children:[v.jsx("h4",{className:"mb-3 text-sm font-medium text-gray-400",children:"Grader Scores"}),v.jsx("div",{className:"space-y-3",children:e.scores.map((m,p)=>v.jsxs("div",{className:"flex items-center gap-4",children:[v.jsx("span",{className:"w-40 truncate text-sm text-gray-300",children:m.name??m.type??`Score ${p+1}`}),v.jsx("div",{className:"flex-1",children:v.jsx(vm,{score:m.score})})]},`${m.name??m.type??p}`))})]}),u?v.jsx("div",{className:"space-y-6",children:l.map((m,p)=>{const g=m.name??m.type??`Grader ${p+1}`;return v.jsxs("div",{className:"space-y-2",children:[v.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-300",children:g}),m.assertions.map((x,S)=>v.jsx(ZP,{assertion:x},`${x.text}-${S}`))]},`${m.name??m.type??p}`)})}):c.length>0?v.jsx("div",{className:"space-y-2",children:c.map((m,p)=>v.jsx(ZP,{assertion:m},`${m.text}-${p}`))}):v.jsx("p",{className:"text-sm text-gray-500",children:"No assertion steps recorded."}),i&&d.length>0&&v.jsxs("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 p-4",children:[v.jsx("h4",{className:"mb-2 text-sm font-medium text-red-400",children:"Failure Reason"}),v.jsx("div",{className:"space-y-2",children:d.map(m=>v.jsx("p",{className:"text-sm text-gray-300",children:m},m))})]})]})}function Cre({result:e,runId:t,projectId:r}){const n=e.testId,{data:i}=r?Fe(L$(r,t,n)):P$(t,n),l=(i==null?void 0:i.files)??[],[u,c]=j.useState(null),d=u??(l.length>0?H3(l):null),{data:h,isLoading:m}=r?Fe(z$(r,t,n,d??"")):C$(t,n,d??"");if(l.length===0)return v.jsx("p",{className:"text-sm text-gray-500",children:"No artifact files available."});const p=d?m?"Loading...":(h==null?void 0:h.content)??"":"",g=d?(h==null?void 0:h.language)??"plaintext":"plaintext";return v.jsxs("div",{className:"flex h-full min-h-[400px] gap-4",children:[v.jsx(Ore,{files:l,selectedPath:d,onSelect:c}),v.jsx("div",{className:"flex-1",children:v.jsx(Tre,{value:p,language:g,height:"100%"})})]})}const F3=_r("/evals/$runId/$evalId")({component:Mre});function Mre(){const{runId:e,evalId:t}=F3.useParams(),{data:r,isLoading:n,error:i}=Gc(e),{data:l}=bt(),[u,c]=j.useState(!1),d=(l==null?void 0:l.read_only)===!0;if(n)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"h-48 animate-pulse rounded-lg bg-gray-900"})]});if(i)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load eval: ",i.message]});const h=r==null?void 0:r.results.find(g=>g.testId===t);if(!h)return v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-6 text-center",children:v.jsxs("p",{className:"text-gray-400",children:["Eval ",v.jsx("code",{className:"text-cyan-400",children:t})," not found in run"," ",v.jsx("code",{className:"text-cyan-400",children:e}),"."]})});const m=(l==null?void 0:l.threshold)??(l==null?void 0:l.pass_threshold)??.8,p=Jr(h.score,m)&&h.executionStatus!=="error"&&h.executionStatus!=="failed";return v.jsxs("div",{className:"flex h-full flex-col gap-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsxs("p",{className:"text-sm text-gray-400",children:["Run: ",e," / Eval: ",t]}),v.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-semibold text-white",children:[v.jsx("span",{className:`text-2xl font-bold leading-none ${p?"text-emerald-400":"text-red-400"}`,children:p?"✓":"✗"}),t]})]}),!d&&v.jsx("button",{type:"button",onClick:()=>c(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run this Test"})]}),v.jsx(K3,{eval:h,runId:e}),!d&&v.jsx(hl,{open:u,onClose:()=>c(!1),prefill:{testIds:[t],target:h.target}})]})}const Y3=_r("/runs/$runId_/suite/$suite")({component:Rre});function Rre(){const{runId:e,suite:t}=Y3.useParams(),{data:r,isLoading:n,error:i}=Gc(e),{data:l}=bt(),u=(l==null?void 0:l.threshold)??(l==null?void 0:l.pass_threshold)??.8;if(n)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-5 gap-4",children:["s1","s2","s3","s4","s5"].map(x=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},x))})]});if(i)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load run: ",i.message]});const c=((r==null?void 0:r.results)??[]).filter(x=>(x.suite??"Uncategorized")===t),d=c.length,h=c.filter(x=>Jr(x.score,u)).length,m=d-h,p=d>0?h/d:0,g=c.reduce((x,S)=>x+(S.costUsd??0),0);return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:t}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:["Suite in run: ",e]})]}),v.jsx(qo,{total:d,passed:h,failed:m,passRate:p,totalCost:g>0?g:void 0}),d===0?v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:v.jsx("p",{className:"text-lg text-gray-400",children:"No evaluations in this suite"})}):v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Test ID"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Target"}),v.jsx("th",{className:"w-48 px-4 py-3 font-medium text-gray-400",children:"Score"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Duration"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Cost"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:c.map((x,S)=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3",children:v.jsx(Se,{to:"/evals/$runId/$evalId",params:{runId:e,evalId:x.testId},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:x.testId})}),v.jsx("td",{className:"px-4 py-3 text-gray-400",children:x.target??"-"}),v.jsx("td",{className:"px-4 py-3",children:x.executionStatus==="execution_error"?v.jsx("span",{className:"inline-flex rounded-full px-2 py-0.5 text-xs font-medium bg-red-900/50 text-red-400",children:"ERR"}):v.jsx(wn,{rate:x.score})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:x.durationMs!=null?`${(x.durationMs/1e3).toFixed(1)}s`:"-"}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:x.costUsd!=null?`$${x.costUsd.toFixed(4)}`:"-"})]},`${x.testId}-${S}`))})]})})]})}const G3=_r("/runs/$runId_/category/$category")({component:Dre});function Dre(){const{runId:e,category:t}=G3.useParams(),{data:r,isLoading:n,error:i}=eM(e,t);if(n)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-5 gap-4",children:["s1","s2","s3","s4","s5"].map(m=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},m))})]});if(i)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load category: ",i.message]});const l=(r==null?void 0:r.suites)??[],u=l.reduce((m,p)=>m+p.total,0),c=l.reduce((m,p)=>m+p.passed,0),d=u-c,h=u>0?c/u:0;return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:t}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:["Category in run: ",e]})]}),v.jsx(qo,{total:u,passed:c,failed:d,passRate:h}),l.length===0?v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:v.jsx("p",{className:"text-lg text-gray-400",children:"No suites in this category"})}):v.jsxs("div",{className:"space-y-3",children:[v.jsx("h3",{className:"text-sm font-medium text-gray-400",children:"Suites"}),v.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:l.map(m=>v.jsxs(Se,{to:"/runs/$runId/suite/$suite",params:{runId:e,suite:m.name},className:"rounded-lg border border-gray-800 bg-gray-900 p-3 text-left transition-colors hover:border-gray-700",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("span",{className:"text-sm font-medium text-gray-200 truncate",children:m.name}),v.jsxs("span",{className:"ml-2 text-xs text-gray-500",children:[m.passed,"/",m.total]})]}),v.jsx("div",{className:"mt-2",children:v.jsx(vm,{score:m.avg_score})}),v.jsxs("div",{className:"mt-1 flex gap-3 text-xs",children:[v.jsxs("span",{className:"text-emerald-400",children:[m.passed," passed"]}),m.failed>0&&v.jsxs("span",{className:"text-red-400",children:[m.failed," failed"]})]})]},m.name))})]})]})}const V3=_r("/projects/$projectId_/runs/$runId")({component:kre});function kre(){var O;const{projectId:e,runId:t}=V3.useParams(),{data:r,isLoading:n,error:i}=Vc(e,t),{data:l}=bt(e),[u,c]=j.useState(!1),d=(l==null?void 0:l.read_only)===!0;if(n)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-5 gap-4",children:["s1","s2","s3","s4","s5"].map(_=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},_))})]});if(i)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load run: ",i.message]});const h=(O=r==null?void 0:r.results)==null?void 0:O[0],m=h==null?void 0:h.target,p=h==null?void 0:h.experiment,g=h==null?void 0:h.timestamp,x=m?{target:m}:void 0,S=(()=>{const _=[p,m].filter(E=>E&&E!=="default");return _.length>0?_.join(" · "):t})(),w=[m,p&&p!=="default"?p:null,g?new Date(g).toLocaleString():null,r==null?void 0:r.source].filter(Boolean).join(" · ");return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:S}),v.jsx("p",{className:"mt-1 text-sm text-gray-500",children:w})]}),v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsx(R3,{results:(r==null?void 0:r.results)??[],runDir:r==null?void 0:r.run_dir,suiteFilter:r==null?void 0:r.suite_filter,target:m??void 0,projectId:e,isReadOnly:d,plannedTestCount:r==null?void 0:r.planned_test_count}),!d&&v.jsx("button",{type:"button",onClick:()=>c(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run evals"})]})]}),v.jsx(D3,{results:(r==null?void 0:r.results)??[],runId:t,projectId:e}),!d&&v.jsx(hl,{open:u,onClose:()=>c(!1),projectId:e,prefill:x})]})}const Q3=_r("/projects/$projectId_/jobs/$runId")({component:Ire});function Ire(){const{projectId:e,runId:t}=Q3.useParams(),{data:r,isLoading:n,error:i}=hb(t,e),{data:l}=bt(e),u=(l==null?void 0:l.read_only)===!0;if(n)return v.jsxs("div",{className:"space-y-4",children:[v.jsx(A0,{projectId:e}),v.jsx("div",{className:"h-8 w-48 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"h-64 animate-pulse rounded-lg bg-gray-900"})]});if(i||!r)return v.jsxs("div",{className:"space-y-4",children:[v.jsx(A0,{projectId:e}),v.jsx("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-4 text-sm text-red-400",children:i?`Failed to load run: ${i.message}`:"Run not found."})]});const c=r.status==="finished"||r.status==="failed",h={starting:"text-yellow-400",running:"text-cyan-400",finished:"text-emerald-400",failed:"text-red-400"}[r.status]??"text-gray-400";return v.jsxs("div",{className:"space-y-4",children:[v.jsx(A0,{projectId:e}),v.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-4",children:[v.jsxs("div",{className:"min-w-0",children:[v.jsx("h1",{className:"truncate font-mono text-base font-semibold text-white",children:t}),v.jsxs("p",{className:"mt-0.5 text-xs text-gray-500",children:["Started ",new Date(r.started_at).toLocaleString(),r.finished_at&&v.jsxs(v.Fragment,{children:[" · ","Finished ",new Date(r.finished_at).toLocaleString()," · ",Math.round((new Date(r.finished_at).getTime()-new Date(r.started_at).getTime())/1e3),"s"]})]})]}),v.jsxs("div",{className:"flex flex-shrink-0 items-center gap-3",children:[v.jsx(L3,{runId:t,status:r.status,isReadOnly:u,projectId:e}),v.jsx("span",{className:`text-sm font-medium ${h}`,children:r.status.charAt(0).toUpperCase()+r.status.slice(1)}),!c&&v.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-cyan-400 border-t-transparent"})]})]}),v.jsxs("div",{className:"rounded-md border border-gray-700 bg-gray-950 px-4 py-3",children:[v.jsx("p",{className:"mb-1 text-xs font-medium uppercase tracking-wider text-gray-500",children:"Command"}),v.jsx("code",{className:"break-all text-xs text-cyan-300",children:r.command})]}),r.stdout?v.jsxs("div",{children:[v.jsx("p",{className:"mb-1 text-xs font-medium uppercase tracking-wider text-gray-500",children:"Output"}),v.jsx("div",{className:"max-h-[60vh] overflow-y-auto rounded-lg border border-gray-700 bg-gray-950 p-4",children:v.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs text-gray-200",children:r.stdout})})]}):!c&&v.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[v.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-spin rounded-full border-2 border-gray-500 border-t-transparent"}),"Waiting for output…"]}),r.stderr&&v.jsxs("div",{children:[v.jsx("p",{className:"mb-1 text-xs font-medium uppercase tracking-wider text-red-500",children:"Stderr"}),v.jsx("div",{className:"max-h-48 overflow-y-auto rounded-lg border border-red-900/40 bg-red-950/20 p-4",children:v.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs text-red-300",children:r.stderr})})]}),c&&v.jsxs("p",{className:"text-xs text-gray-500",children:["Exit code:"," ",v.jsx("span",{className:r.exit_code===0?"text-emerald-400":"text-red-400",children:r.exit_code})]})]})}function A0({projectId:e}){return v.jsx(Se,{to:"/projects/$projectId",params:{projectId:e},search:{tab:"runs"},className:"text-xs text-gray-400 hover:text-cyan-400",children:"← Back to Runs"})}const X3=_r("/projects/$projectId_/experiments/$experimentName")({component:Lre});function Lre(){const{projectId:e,experimentName:t}=X3.useParams();return v.jsx($3,{experimentName:t,projectId:e})}const Z3=_r("/projects/$projectId_/evals/$runId/$evalId")({component:zre});function zre(){const{projectId:e,runId:t,evalId:r}=Z3.useParams(),{data:n,isLoading:i,error:l}=Vc(e,t),{data:u}=bt(e),[c,d]=j.useState(!1),h=(u==null?void 0:u.read_only)===!0;if(i)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"h-48 animate-pulse rounded-lg bg-gray-900"})]});if(l)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load eval: ",l.message]});const m=n==null?void 0:n.results.find(x=>x.testId===r);if(!m)return v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-6 text-center",children:v.jsxs("p",{className:"text-gray-400",children:["Eval ",v.jsx("code",{className:"text-cyan-400",children:r})," not found in run"," ",v.jsx("code",{className:"text-cyan-400",children:t}),"."]})});const p=(u==null?void 0:u.threshold)??(u==null?void 0:u.pass_threshold)??.8,g=Jr(m.score,p)&&m.executionStatus!=="error"&&m.executionStatus!=="failed";return v.jsxs("div",{className:"flex h-full flex-col gap-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsxs("p",{className:"text-sm text-gray-400",children:["Run: ",t," / Eval: ",r]}),v.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-semibold text-white",children:[v.jsx("span",{className:`text-2xl font-bold leading-none ${g?"text-emerald-400":"text-red-400"}`,children:g?"✓":"✗"}),r]})]}),!h&&v.jsx("button",{type:"button",onClick:()=>d(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run this Test"})]}),v.jsx(K3,{eval:m,runId:t,projectId:e}),!h&&v.jsx(hl,{open:c,onClose:()=>d(!1),projectId:e,prefill:{testIds:[r],target:m.target}})]})}const W3=_r("/projects/$projectId_/runs/$runId_/suite/$suite")({component:$re});function $re(){const{projectId:e,runId:t,suite:r}=W3.useParams(),{data:n,isLoading:i,error:l}=Vc(e,t),{data:u}=bt(e),c=(u==null?void 0:u.threshold)??(u==null?void 0:u.pass_threshold)??.8;if(i)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-5 gap-4",children:["s1","s2","s3","s4","s5"].map(S=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},S))})]});if(l)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load run: ",l.message]});const d=((n==null?void 0:n.results)??[]).filter(S=>(S.suite??"Uncategorized")===r),h=d.length,m=d.filter(S=>Jr(S.score,c)).length,p=h-m,g=h>0?m/h:0,x=d.reduce((S,w)=>S+(w.costUsd??0),0);return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:r}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:["Suite in run: ",t]})]}),v.jsx(qo,{total:h,passed:m,failed:p,passRate:g,totalCost:x>0?x:void 0}),h===0?v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:v.jsx("p",{className:"text-lg text-gray-400",children:"No evaluations in this suite"})}):v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Test ID"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Target"}),v.jsx("th",{className:"w-48 px-4 py-3 font-medium text-gray-400",children:"Score"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Duration"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Cost"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:d.map((S,w)=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3",children:v.jsx(Se,{to:"/projects/$projectId/evals/$runId/$evalId",params:{projectId:e,runId:t,evalId:S.testId},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:S.testId})}),v.jsx("td",{className:"px-4 py-3 text-gray-400",children:S.target??"-"}),v.jsx("td",{className:"px-4 py-3",children:S.executionStatus==="execution_error"?v.jsx("span",{className:"inline-flex rounded-full bg-red-900/50 px-2 py-0.5 text-xs font-medium text-red-400",children:"ERR"}):v.jsx(wn,{rate:S.score})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:S.durationMs!=null?`${(S.durationMs/1e3).toFixed(1)}s`:"-"}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:S.costUsd!=null?`$${S.costUsd.toFixed(4)}`:"-"})]},`${S.testId}-${w}`))})]})})]})}const J3=_r("/projects/$projectId_/runs/$runId_/category/$category")({component:Bre});function Bre(){const{projectId:e,runId:t,category:r}=J3.useParams(),{data:n,isLoading:i,error:l}=Fe(nM(e,t,r));if(i)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-5 gap-4",children:["s1","s2","s3","s4","s5"].map(p=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},p))})]});if(l)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load category: ",l.message]});const u=(n==null?void 0:n.suites)??[],c=u.reduce((p,g)=>p+g.total,0),d=u.reduce((p,g)=>p+g.passed,0),h=c-d,m=c>0?d/c:0;return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:r}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:["Category in run: ",t]})]}),v.jsx(qo,{total:c,passed:d,failed:h,passRate:m}),u.length===0?v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:v.jsx("p",{className:"text-lg text-gray-400",children:"No suites in this category"})}):v.jsxs("div",{className:"space-y-3",children:[v.jsx("h3",{className:"text-sm font-medium text-gray-400",children:"Suites"}),v.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:u.map(p=>v.jsxs(Se,{to:"/projects/$projectId/runs/$runId/suite/$suite",params:{projectId:e,runId:t,suite:p.name},className:"rounded-lg border border-gray-800 bg-gray-900 p-3 text-left transition-colors hover:border-gray-700",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("span",{className:"truncate text-sm font-medium text-gray-200",children:p.name}),v.jsxs("span",{className:"ml-2 text-xs text-gray-500",children:[p.passed,"/",p.total]})]}),v.jsx("div",{className:"mt-2",children:v.jsx(vm,{score:p.avg_score})}),v.jsxs("div",{className:"mt-1 flex gap-3 text-xs",children:[v.jsxs("span",{className:"text-emerald-400",children:[p.passed," passed"]}),p.failed>0&&v.jsxs("span",{className:"text-red-400",children:[p.failed," failed"]})]})]},p.name))})]})]})}const Ure=f8.update({id:"/settings",path:"/settings",getParentRoute:()=>mr}),qre=rre.update({id:"/",path:"/",getParentRoute:()=>mr}),Hre=k3.update({id:"/runs/$runId",path:"/runs/$runId",getParentRoute:()=>mr}),Kre=I3.update({id:"/projects/$projectId",path:"/projects/$projectId",getParentRoute:()=>mr}),Fre=z3.update({id:"/jobs/$runId",path:"/jobs/$runId",getParentRoute:()=>mr}),Yre=B3.update({id:"/experiments/$experimentName",path:"/experiments/$experimentName",getParentRoute:()=>mr}),Gre=F3.update({id:"/evals/$runId/$evalId",path:"/evals/$runId/$evalId",getParentRoute:()=>mr}),Vre=Y3.update({id:"/runs/$runId_/suite/$suite",path:"/runs/$runId/suite/$suite",getParentRoute:()=>mr}),Qre=G3.update({id:"/runs/$runId_/category/$category",path:"/runs/$runId/category/$category",getParentRoute:()=>mr}),Xre=V3.update({id:"/projects/$projectId_/runs/$runId",path:"/projects/$projectId/runs/$runId",getParentRoute:()=>mr}),Zre=Q3.update({id:"/projects/$projectId_/jobs/$runId",path:"/projects/$projectId/jobs/$runId",getParentRoute:()=>mr}),Wre=X3.update({id:"/projects/$projectId_/experiments/$experimentName",path:"/projects/$projectId/experiments/$experimentName",getParentRoute:()=>mr}),Jre=Z3.update({id:"/projects/$projectId_/evals/$runId/$evalId",path:"/projects/$projectId/evals/$runId/$evalId",getParentRoute:()=>mr}),ene=W3.update({id:"/projects/$projectId_/runs/$runId_/suite/$suite",path:"/projects/$projectId/runs/$runId/suite/$suite",getParentRoute:()=>mr}),tne=J3.update({id:"/projects/$projectId_/runs/$runId_/category/$category",path:"/projects/$projectId/runs/$runId/category/$category",getParentRoute:()=>mr}),rne={IndexRoute:qre,SettingsRoute:Ure,ExperimentsExperimentNameRoute:Yre,JobsRunIdRoute:Fre,ProjectsProjectIdRoute:Kre,RunsRunIdRoute:Hre,EvalsRunIdEvalIdRoute:Gre,ProjectsProjectIdExperimentsExperimentNameRoute:Wre,ProjectsProjectIdJobsRunIdRoute:Zre,ProjectsProjectIdRunsRunIdRoute:Xre,RunsRunIdCategoryCategoryRoute:Qre,RunsRunIdSuiteSuiteRoute:Vre,ProjectsProjectIdEvalsRunIdEvalIdRoute:Jre,ProjectsProjectIdRunsRunIdCategoryCategoryRoute:tne,ProjectsProjectIdRunsRunIdSuiteSuiteRoute:ene},nne=mr._addFileChildren(rne)._addFileTypes(),ane=new nL({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!0}}}),ine=i$({routeTree:nne}),ek=document.getElementById("root");if(!ek)throw new Error("Root element not found");M5.createRoot(ek).render(v.jsx(j.StrictMode,{children:v.jsx(aL,{client:ane,children:v.jsx(o$,{router:ine})})}));export{Ao as W,j as r};
116
+ */var tP;function sX(){if(tP)return et;tP=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),x=Symbol.for("react.client.reference");function S(w){if(typeof w=="object"&&w!==null){var O=w.$$typeof;switch(O){case e:switch(w=w.type,w){case r:case i:case n:case d:case h:case g:return w;default:switch(w=w&&w.$$typeof,w){case u:case c:case p:case m:return w;case l:return w;default:return O}}case t:return O}}}return et.ContextConsumer=l,et.ContextProvider=u,et.Element=e,et.ForwardRef=c,et.Fragment=r,et.Lazy=p,et.Memo=m,et.Portal=t,et.Profiler=i,et.StrictMode=n,et.Suspense=d,et.SuspenseList=h,et.isContextConsumer=function(w){return S(w)===l},et.isContextProvider=function(w){return S(w)===u},et.isElement=function(w){return typeof w=="object"&&w!==null&&w.$$typeof===e},et.isForwardRef=function(w){return S(w)===c},et.isFragment=function(w){return S(w)===r},et.isLazy=function(w){return S(w)===p},et.isMemo=function(w){return S(w)===m},et.isPortal=function(w){return S(w)===t},et.isProfiler=function(w){return S(w)===i},et.isStrictMode=function(w){return S(w)===n},et.isSuspense=function(w){return S(w)===d},et.isSuspenseList=function(w){return S(w)===h},et.isValidElementType=function(w){return typeof w=="string"||typeof w=="function"||w===r||w===i||w===n||w===d||w===h||typeof w=="object"&&w!==null&&(w.$$typeof===p||w.$$typeof===m||w.$$typeof===u||w.$$typeof===l||w.$$typeof===c||w.$$typeof===x||w.getModuleId!==void 0)},et.typeOf=S,et}var rP;function lX(){return rP||(rP=1,g0.exports=sX()),g0.exports}var oX=lX(),nP=e=>typeof e=="string"?e:e?e.displayName||e.name||"Component":"",aP=null,x0=null,RD=e=>{if(e===aP&&Array.isArray(x0))return x0;var t=[];return j.Children.forEach(e,r=>{ht(r)||(oX.isFragment(r)?t=t.concat(RD(r.props.children)):t.push(r))}),x0=t,aP=e,t};function uX(e,t){var r=[],n=[];return Array.isArray(t)?n=t.map(i=>nP(i)):n=[nP(t)],RD(e).forEach(i=>{var l=Co(i,"type.displayName")||Co(i,"type.name");l&&n.indexOf(l)!==-1&&r.push(i)}),r}var DD=e=>e&&typeof e=="object"&&"clipDot"in e?!!e.clipDot:!0,b0={},iP;function cX(){return iP||(iP=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){var i;if(typeof r!="object"||r==null)return!1;if(Object.getPrototypeOf(r)===null)return!0;if(Object.prototype.toString.call(r)!=="[object Object]"){const l=r[Symbol.toStringTag];return l==null||!((i=Object.getOwnPropertyDescriptor(r,Symbol.toStringTag))!=null&&i.writable)?!1:r.toString()===`[object ${l}]`}let n=r;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(r)===n}e.isPlainObject=t})(b0)),b0}var S0,sP;function fX(){return sP||(sP=1,S0=cX().isPlainObject),S0}var dX=fX();const hX=Zi(dX);var lP,oP,uP,cP,fP;function dP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function hP(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?dP(Object(r),!0).forEach(function(n){mX(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function mX(e,t,r){return(t=pX(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function pX(e){var t=vX(e,"string");return typeof t=="symbol"?t:t+""}function vX(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function um(){return um=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},um.apply(null,arguments)}function oc(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var mP=(e,t,r,n,i)=>{var l=r-n,u;return u=gt(lP||(lP=oc(["M ",",",""])),e,t),u+=gt(oP||(oP=oc(["L ",",",""])),e+r,t),u+=gt(uP||(uP=oc(["L ",",",""])),e+r-l/2,t+i),u+=gt(cP||(cP=oc(["L ",",",""])),e+r-l/2-n,t+i),u+=gt(fP||(fP=oc(["L ",","," Z"])),e,t),u},yX={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},gX=e=>{var t=sr(e,yX),{x:r,y:n,upperWidth:i,lowerWidth:l,height:u,className:c}=t,{animationEasing:d,animationDuration:h,animationBegin:m,isUpdateAnimationActive:p}=t,g=j.useRef(null),[x,S]=j.useState(-1),w=j.useRef(i),O=j.useRef(l),_=j.useRef(u),E=j.useRef(r),T=j.useRef(n),A=Fm(e,"trapezoid-");if(j.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var te=g.current.getTotalLength();te&&S(te)}catch{}},[]),r!==+r||n!==+n||i!==+i||l!==+l||u!==+u||i===0&&l===0||u===0)return null;var C=Qe("recharts-trapezoid",c);if(!p)return j.createElement("g",null,j.createElement("path",um({},jr(t),{className:C,d:mP(r,n,i,l,u)})));var M=w.current,R=O.current,z=_.current,$=E.current,D=T.current,H="0px ".concat(x===-1?1:x,"px"),U="".concat(x,"px ").concat(x,"px"),ie=K2(["strokeDasharray"],h,d);return j.createElement(Km,{animationId:A,key:A,canBegin:x>0,duration:h,easing:d,isActive:p,begin:m},te=>{var ae=xt(M,i,te),q=xt(R,l,te),V=xt(z,u,te),ne=xt($,r,te),se=xt(D,n,te);g.current&&(w.current=ae,O.current=q,_.current=V,E.current=ne,T.current=se);var fe=te>0?{transition:ie,strokeDasharray:U}:{strokeDasharray:H};return j.createElement("path",um({},jr(t),{className:C,d:mP(ne,se,ae,q,V),ref:g,style:hP(hP({},fe),t.style)}))})},xX=["option","shapeType","activeClassName","inActiveClassName"];function bX(e,t){if(e==null)return{};var r,n,i=SX(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function SX(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function pP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function cm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?pP(Object(r),!0).forEach(function(n){wX(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function wX(e,t,r){return(t=jX(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function jX(e){var t=OX(e,"string");return typeof t=="symbol"?t:t+""}function OX(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function _X(e,t){return cm(cm({},t),e)}function NX(e,t){return e==="symbols"}function vP(e){var{shapeType:t,elementProps:r}=e;switch(t){case"rectangle":return j.createElement(V2,r);case"trapezoid":return j.createElement(gX,r);case"sector":return j.createElement(Z2,r);case"symbols":if(NX(t))return j.createElement(jb,r);break;case"curve":return j.createElement(H2,r);default:return null}}function EX(e){return j.isValidElement(e)?e.props:e}function kD(e){var{option:t,shapeType:r,activeClassName:n="recharts-active-shape",inActiveClassName:i="recharts-shape"}=e,l=bX(e,xX),u;if(j.isValidElement(t))u=j.cloneElement(t,cm(cm({},l),EX(t)));else if(typeof t=="function")u=t(l,l.index);else if(hX(t)&&typeof t!="boolean"){var c=_X(t,l);u=j.createElement(vP,{shapeType:r,elementProps:c})}else{var d=l;u=j.createElement(vP,{shapeType:r,elementProps:d})}return l.isActive?j.createElement(en,{className:n},u):j.createElement(en,{className:i},u)}var ID=(e,t,r)=>{var n=ut();return(i,l)=>u=>{e==null||e(i,l,u),n(H4({activeIndex:String(l),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:r}))}},LD=e=>{var t=ut();return(r,n)=>i=>{e==null||e(r,n,i),t(KY())}},zD=(e,t,r)=>{var n=ut();return(i,l)=>u=>{e==null||e(i,l,u),n(FY({activeIndex:String(l),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:r}))}};function $D(e){var{tooltipEntrySettings:t}=e,r=ut(),n=vr(),i=j.useRef(null);return j.useLayoutEffect(()=>{n||(i.current===null?r(BY(t)):i.current!==t&&r(UY({prev:i.current,next:t})),i.current=t)},[t,r,n]),j.useLayoutEffect(()=>()=>{i.current&&(r(qY(i.current)),i.current=null)},[r]),null}function BD(e){var{legendPayload:t}=e,r=ut(),n=vr(),i=j.useRef(null);return j.useLayoutEffect(()=>{n||(i.current===null?r(Pq(t)):i.current!==t&&r(Cq({prev:i.current,next:t})),i.current=t)},[r,n,t]),j.useLayoutEffect(()=>()=>{i.current&&(r(Mq(i.current)),i.current=null)},[r]),null}var w0,AX=()=>{var[e]=j.useState(()=>Nc("uid-"));return e},TX=(w0=N5.useId)!==null&&w0!==void 0?w0:AX;function PX(e,t){var r=TX();return t||(e?"".concat(e,"-").concat(r):r)}var CX=j.createContext(void 0),UD=e=>{var{id:t,type:r,children:n}=e,i=PX("recharts-".concat(r),t);return j.createElement(CX.Provider,{value:i},n(i))},MX={cartesianItems:[],polarItems:[]},qD=pr({name:"graphicalItems",initialState:MX,reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(t.payload)},prepare:lt()},replaceCartesianGraphicalItem:{reducer(e,t){var{prev:r,next:n}=t.payload,i=bn(e).cartesianItems.indexOf(r);i>-1&&(e.cartesianItems[i]=n)},prepare:lt()},removeCartesianGraphicalItem:{reducer(e,t){var r=bn(e).cartesianItems.indexOf(t.payload);r>-1&&e.cartesianItems.splice(r,1)},prepare:lt()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(t.payload)},prepare:lt()},removePolarGraphicalItem:{reducer(e,t){var r=bn(e).polarItems.indexOf(t.payload);r>-1&&e.polarItems.splice(r,1)},prepare:lt()},replacePolarGraphicalItem:{reducer(e,t){var{prev:r,next:n}=t.payload,i=bn(e).polarItems.indexOf(r);i>-1&&(e.polarItems[i]=n)},prepare:lt()}}}),{addCartesianGraphicalItem:RX,replaceCartesianGraphicalItem:DX,removeCartesianGraphicalItem:kX,addPolarGraphicalItem:pne,removePolarGraphicalItem:vne,replacePolarGraphicalItem:yne}=qD.actions,IX=qD.reducer,LX=e=>{var t=ut(),r=j.useRef(null);return j.useLayoutEffect(()=>{r.current===null?t(RX(e)):r.current!==e&&t(DX({prev:r.current,next:e})),r.current=e},[t,e]),j.useLayoutEffect(()=>()=>{r.current&&(t(kX(r.current)),r.current=null)},[t]),null},HD=j.memo(LX),zX=["points"];function yP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function j0(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?yP(Object(r),!0).forEach(function(n){$X(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):yP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function $X(e,t,r){return(t=BX(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function BX(e){var t=UX(e,"string");return typeof t=="symbol"?t:t+""}function UX(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function fm(){return fm=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},fm.apply(null,arguments)}function qX(e,t){if(e==null)return{};var r,n,i=HX(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function HX(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function KX(e){var{option:t,dotProps:r,className:n}=e;if(j.isValidElement(t))return j.cloneElement(t,r);if(typeof t=="function")return t(r);var i=Qe(n,typeof t!="boolean"?t.className:""),l=r??{},{points:u}=l,c=qX(l,zX);return j.createElement(CD,fm({},c,{className:i}))}function FX(e,t){return e==null?!1:t?!0:e.length===1}function YX(e){var{points:t,dot:r,className:n,dotClassName:i,dataKey:l,baseProps:u,needClip:c,clipPathId:d,zIndex:h=Ft.scatter}=e;if(!FX(t,r))return null;var m=DD(r),p=v8(r),g=t.map((S,w)=>{var O,_,E=j0(j0(j0({r:3},u),p),{},{index:w,cx:(O=S.x)!==null&&O!==void 0?O:void 0,cy:(_=S.y)!==null&&_!==void 0?_:void 0,dataKey:l,value:S.value,payload:S.payload,points:t});return j.createElement(KX,{key:"dot-".concat(w),option:r,dotProps:E,className:i})}),x={};return c&&d!=null&&(x.clipPath="url(#clipPath-".concat(m?"":"dots-").concat(d,")")),j.createElement(_n,{zIndex:h},j.createElement(en,fm({className:n},x),g))}function gP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function xP(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?gP(Object(r),!0).forEach(function(n){GX(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):gP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function GX(e,t,r){return(t=VX(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function VX(e){var t=QX(e,"string");return typeof t=="symbol"?t:t+""}function QX(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var KD=0,XX={xAxis:{},yAxis:{},zAxis:{}},FD=pr({name:"cartesianAxis",initialState:XX,reducers:{addXAxis:{reducer(e,t){e.xAxis[t.payload.id]=t.payload},prepare:lt()},replaceXAxis:{reducer(e,t){var{prev:r,next:n}=t.payload;e.xAxis[r.id]!==void 0&&(r.id!==n.id&&delete e.xAxis[r.id],e.xAxis[n.id]=n)},prepare:lt()},removeXAxis:{reducer(e,t){delete e.xAxis[t.payload.id]},prepare:lt()},addYAxis:{reducer(e,t){e.yAxis[t.payload.id]=t.payload},prepare:lt()},replaceYAxis:{reducer(e,t){var{prev:r,next:n}=t.payload;e.yAxis[r.id]!==void 0&&(r.id!==n.id&&delete e.yAxis[r.id],e.yAxis[n.id]=n)},prepare:lt()},removeYAxis:{reducer(e,t){delete e.yAxis[t.payload.id]},prepare:lt()},addZAxis:{reducer(e,t){e.zAxis[t.payload.id]=t.payload},prepare:lt()},replaceZAxis:{reducer(e,t){var{prev:r,next:n}=t.payload;e.zAxis[r.id]!==void 0&&(r.id!==n.id&&delete e.zAxis[r.id],e.zAxis[n.id]=n)},prepare:lt()},removeZAxis:{reducer(e,t){delete e.zAxis[t.payload.id]},prepare:lt()},updateYAxisWidth(e,t){var{id:r,width:n}=t.payload,i=e.yAxis[r];if(i){var l,u=i.widthHistory||[];if(u.length===3&&u[0]===u[2]&&n===u[1]&&n!==i.width&&Math.abs(n-((l=u[0])!==null&&l!==void 0?l:0))<=1)return;var c=[...u,n].slice(-3);e.yAxis[r]=xP(xP({},i),{},{width:n,widthHistory:c})}}}}),{addXAxis:ZX,replaceXAxis:WX,removeXAxis:JX,addYAxis:eZ,replaceYAxis:tZ,removeYAxis:rZ,addZAxis:gne,replaceZAxis:xne,removeZAxis:bne,updateYAxisWidth:nZ}=FD.actions,aZ=FD.reducer,iZ=G([Yt],e=>({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),sZ=G([iZ,Ga,Va],(e,t,r)=>{if(!(!e||t==null||r==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,r-e.top-e.bottom)}}),KS=()=>ye(sZ),lZ=()=>ye(BG);function bP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function O0(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?bP(Object(r),!0).forEach(function(n){oZ(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):bP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function oZ(e,t,r){return(t=uZ(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function uZ(e){var t=cZ(e,"string");return typeof t=="symbol"?t:t+""}function cZ(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var fZ=e=>{var{point:t,childIndex:r,mainColor:n,activeDot:i,dataKey:l,clipPath:u}=e;if(i===!1||t.x==null||t.y==null)return null;var c={index:r,dataKey:l,cx:t.x,cy:t.y,r:4,fill:n??"none",strokeWidth:2,stroke:"#fff",payload:t.payload,value:t.value},d=O0(O0(O0({},c),Qc(i)),Ob(i)),h;return j.isValidElement(i)?h=j.cloneElement(i,d):typeof i=="function"?h=i(d):h=j.createElement(CD,d),j.createElement(en,{className:"recharts-active-dot",clipPath:u},h)};function dZ(e){var{points:t,mainColor:r,activeDot:n,itemDataKey:i,clipPath:l,zIndex:u=Ft.activeDot}=e,c=ye(rl),d=lZ();if(t==null||d==null)return null;var h=t.find(m=>d.includes(m.payload));return ht(h)?null:j.createElement(_n,{zIndex:u},j.createElement(fZ,{point:h,childIndex:Number(c),mainColor:r,dataKey:i,activeDot:n,clipPath:l}))}var SP=(e,t,r)=>{var n=r??e;if(!ht(n))return kn(n,t,0)},hZ=(e,t,r)=>{var n={},i=e.filter(Zm),l=e.filter(h=>h.stackId==null),u=i.reduce((h,m)=>{var p=h[m.stackId];return p==null&&(p=[]),p.push(m),h[m.stackId]=p,h},n),c=Object.entries(u).map(h=>{var m,[p,g]=h,x=g.map(w=>w.dataKey),S=SP(t,r,(m=g[0])===null||m===void 0?void 0:m.barSize);return{stackId:p,dataKeys:x,barSize:S}}),d=l.map(h=>{var m=[h.dataKey].filter(g=>g!=null),p=SP(t,r,h.barSize);return{stackId:void 0,dataKeys:m,barSize:p}});return[...c,...d]};function wP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Wd(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?wP(Object(r),!0).forEach(function(n){mZ(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function mZ(e,t,r){return(t=pZ(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function pZ(e){var t=vZ(e,"string");return typeof t=="symbol"?t:t+""}function vZ(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function yZ(e,t,r,n,i){var l,u=n.length;if(!(u<1)){var c=kn(e,r,0,!0),d,h=[];if(Be((l=n[0])===null||l===void 0?void 0:l.barSize)){var m=!1,p=r/u,g=n.reduce((E,T)=>E+(T.barSize||0),0);g+=(u-1)*c,g>=r&&(g-=(u-1)*c,c=0),g>=r&&p>0&&(m=!0,p*=.9,g=u*p);var x=(r-g)/2>>0,S={offset:x-c,size:0};d=n.reduce((E,T)=>{var A,C={stackId:T.stackId,dataKeys:T.dataKeys,position:{offset:S.offset+S.size+c,size:m?p:(A=T.barSize)!==null&&A!==void 0?A:0}},M=[...E,C];return S=C.position,M},h)}else{var w=kn(t,r,0,!0);r-2*w-(u-1)*c<=0&&(c=0);var O=(r-2*w-(u-1)*c)/u;O>1&&(O>>=0);var _=Be(i)?Math.min(O,i):O;d=n.reduce((E,T,A)=>[...E,{stackId:T.stackId,dataKeys:T.dataKeys,position:{offset:w+(O+c)*A+(O-_)/2,size:_}}],h)}return d}}var gZ=(e,t,r,n,i,l,u)=>{var c=ht(u)?t:u,d=yZ(r,n,i!==l?i:l,e,c);return i!==l&&d!=null&&(d=d.map(h=>Wd(Wd({},h),{},{position:Wd(Wd({},h.position),{},{offset:h.position.offset-i/2})}))),d},xZ=(e,t)=>{var r=Zb(t);if(!(!e||r==null||t==null)){var{stackId:n}=t;if(n!=null){var i=e[n];if(i){var{stackedData:l}=i;if(l)return l.find(u=>u.key===r)}}}},bZ=(e,t)=>{if(!(e==null||t==null)){var r=e.find(n=>n.stackId===t.stackId&&t.dataKey!=null&&n.dataKeys.includes(t.dataKey));if(r!=null)return r.position}};function SZ(e,t){return e&&typeof e=="object"&&"zIndex"in e&&typeof e.zIndex=="number"&&Be(e.zIndex)?e.zIndex:t}var wZ=e=>{var{chartData:t}=e,r=ut(),n=vr();return j.useEffect(()=>n?()=>{}:(r(IT(t)),()=>{r(IT(void 0))}),[t,r,n]),null},jP={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},YD=pr({name:"brush",initialState:jP,reducers:{setBrushSettings(e,t){return t.payload==null?jP:t.payload}}}),{setBrushSettings:Sne}=YD.actions,jZ=YD.reducer;function OZ(e){return(e%180+180)%180}var _Z=function(t){var{width:r,height:n}=t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,l=OZ(i),u=l*Math.PI/180,c=Math.atan(n/r),d=u>c&&u<Math.PI-c?n/Math.sin(u):r/Math.cos(u);return Math.abs(d)},NZ={dots:[],areas:[],lines:[]},GD=pr({name:"referenceElements",initialState:NZ,reducers:{addDot:(e,t)=>{e.dots.push(t.payload)},removeDot:(e,t)=>{var r=bn(e).dots.findIndex(n=>n===t.payload);r!==-1&&e.dots.splice(r,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var r=bn(e).areas.findIndex(n=>n===t.payload);r!==-1&&e.areas.splice(r,1)},addLine:(e,t)=>{e.lines.push(t.payload)},removeLine:(e,t)=>{var r=bn(e).lines.findIndex(n=>n===t.payload);r!==-1&&e.lines.splice(r,1)}}}),{addDot:wne,removeDot:jne,addArea:One,removeArea:_ne,addLine:Nne,removeLine:Ene}=GD.actions,EZ=GD.reducer,AZ=j.createContext(void 0),TZ=e=>{var{children:t}=e,[r]=j.useState("".concat(Nc("recharts"),"-clip")),n=KS();if(n==null)return null;var{x:i,y:l,width:u,height:c}=n;return j.createElement(AZ.Provider,{value:r},j.createElement("defs",null,j.createElement("clipPath",{id:r},j.createElement("rect",{x:i,y:l,height:c,width:u}))),t)};function VD(e,t){if(t<1)return[];if(t===1)return e;for(var r=[],n=0;n<e.length;n+=t){var i=e[n];i!==void 0&&r.push(i)}return r}function PZ(e,t,r){var n={width:e.width+t.width,height:e.height+t.height};return _Z(n,r)}function CZ(e,t,r){var n=r==="width",{x:i,y:l,width:u,height:c}=e;return t===1?{start:n?i:l,end:n?i+u:l+c}:{start:n?i+u:l+c,end:n?i:l}}function Bc(e,t,r,n,i){if(e*t<e*n||e*t>e*i)return!1;var l=r();return e*(t-e*l/2-n)>=0&&e*(t+e*l/2-i)<=0}function MZ(e,t){return VD(e,t+1)}function RZ(e,t,r,n,i){for(var l=(n||[]).slice(),{start:u,end:c}=t,d=0,h=1,m=u,p=function(){var S=n==null?void 0:n[d];if(S===void 0)return{v:VD(n,h)};var w=d,O,_=()=>(O===void 0&&(O=r(S,w)),O),E=S.coordinate,T=d===0||Bc(e,E,_,m,c);T||(d=0,m=u,h+=1),T&&(m=E+e*(_()/2+i),d+=h)},g;h<=l.length;)if(g=p(),g)return g.v;return[]}function DZ(e,t,r,n,i){var l=(n||[]).slice(),u=l.length;if(u===0)return[];for(var{start:c,end:d}=t,h=1;h<=u;h++){for(var m=(u-1)%h,p=c,g=!0,x=function(){var A=n[w];if(A==null)return 0;var C=w,M,R=()=>(M===void 0&&(M=r(A,C)),M),z=A.coordinate,$=w===m||Bc(e,z,R,p,d);if(!$)return g=!1,1;$&&(p=z+e*(R()/2+i))},S,w=m;w<u&&(S=x(),!(S!==0&&S===1));w+=h);if(g){for(var O=[],_=m;_<u;_+=h){var E=n[_];E!=null&&O.push(E)}return O}}return[]}function OP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function fr(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?OP(Object(r),!0).forEach(function(n){kZ(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):OP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function kZ(e,t,r){return(t=IZ(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function IZ(e){var t=LZ(e,"string");return typeof t=="symbol"?t:t+""}function LZ(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function zZ(e,t,r,n,i){for(var l=(n||[]).slice(),u=l.length,{start:c}=t,{end:d}=t,h=function(g){var x=l[g];if(x==null)return 1;var S=x,w,O=()=>(w===void 0&&(w=r(x,g)),w);if(g===u-1){var _=e*(S.coordinate+e*O()/2-d);l[g]=S=fr(fr({},S),{},{tickCoord:_>0?S.coordinate-_*e:S.coordinate})}else l[g]=S=fr(fr({},S),{},{tickCoord:S.coordinate});if(S.tickCoord!=null){var E=Bc(e,S.tickCoord,O,c,d);E&&(d=S.tickCoord-e*(O()/2+i),l[g]=fr(fr({},S),{},{isShow:!0}))}},m=u-1;m>=0;m--)h(m);return l}function $Z(e,t,r,n,i,l){var u=(n||[]).slice(),c=u.length,{start:d,end:h}=t;if(l){var m=n[c-1];if(m!=null){var p=r(m,c-1),g=e*(m.coordinate+e*p/2-h);if(u[c-1]=m=fr(fr({},m),{},{tickCoord:g>0?m.coordinate-g*e:m.coordinate}),m.tickCoord!=null){var x=Bc(e,m.tickCoord,()=>p,d,h);x&&(h=m.tickCoord-e*(p/2+i),u[c-1]=fr(fr({},m),{},{isShow:!0}))}}}for(var S=l?c-1:c,w=function(E){var T=u[E];if(T==null)return 1;var A=T,C,M=()=>(C===void 0&&(C=r(T,E)),C);if(E===0){var R=e*(A.coordinate-e*M()/2-d);u[E]=A=fr(fr({},A),{},{tickCoord:R<0?A.coordinate-R*e:A.coordinate})}else u[E]=A=fr(fr({},A),{},{tickCoord:A.coordinate});if(A.tickCoord!=null){var z=Bc(e,A.tickCoord,M,d,h);z&&(d=A.tickCoord+e*(M()/2+i),u[E]=fr(fr({},A),{},{isShow:!0}))}},O=0;O<S;O++)w(O);return u}function FS(e,t,r){var{tick:n,ticks:i,viewBox:l,minTickGap:u,orientation:c,interval:d,tickFormatter:h,unit:m,angle:p}=e;if(!i||!i.length||!n)return[];if(pe(d)||rf.isSsr){var g;return(g=MZ(i,pe(d)?d:0))!==null&&g!==void 0?g:[]}var x=[],S=c==="top"||c==="bottom"?"width":"height",w=m&&S==="width"?gc(m,{fontSize:t,letterSpacing:r}):{width:0,height:0},O=(C,M)=>{var R=typeof h=="function"?h(C.value,M):C.value;return S==="width"?PZ(gc(R,{fontSize:t,letterSpacing:r}),w,p):gc(R,{fontSize:t,letterSpacing:r})[S]},_=i[0],E=i[1],T=i.length>=2&&_!=null&&E!=null?Lr(E.coordinate-_.coordinate):1,A=CZ(l,T,S);return d==="equidistantPreserveStart"?RZ(T,A,O,i,u):d==="equidistantPreserveEnd"?DZ(T,A,O,i,u):(d==="preserveStart"||d==="preserveStartEnd"?x=$Z(T,A,O,i,u,d==="preserveStartEnd"):x=zZ(T,A,O,i,u),x.filter(C=>C.isShow))}var BZ=e=>{var{ticks:t,label:r,labelGapWithTick:n=5,tickSize:i=0,tickMargin:l=0}=e,u=0;if(t){Array.from(t).forEach(m=>{if(m){var p=m.getBoundingClientRect();p.width>u&&(u=p.width)}});var c=r?r.getBoundingClientRect().width:0,d=i+l,h=u+d+c+(r?n:0);return Math.round(h)}return 0},UZ={xAxis:{},yAxis:{}},QD=pr({name:"renderedTicks",initialState:UZ,reducers:{setRenderedTicks:(e,t)=>{var{axisType:r,axisId:n,ticks:i}=t.payload;e[r][n]=i},removeRenderedTicks:(e,t)=>{var{axisType:r,axisId:n}=t.payload;delete e[r][n]}}}),{setRenderedTicks:qZ,removeRenderedTicks:HZ}=QD.actions,KZ=QD.reducer,FZ=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function YZ(e,t){if(e==null)return{};var r,n,i=GZ(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function GZ(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function nl(){return nl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},nl.apply(null,arguments)}function _P(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function yt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?_P(Object(r),!0).forEach(function(n){VZ(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_P(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function VZ(e,t,r){return(t=QZ(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function QZ(e){var t=XZ(e,"string");return typeof t=="symbol"?t:t+""}function XZ(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var $a={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:Ft.axis};function ZZ(e){var{x:t,y:r,width:n,height:i,orientation:l,mirror:u,axisLine:c,otherSvgProps:d}=e;if(!c)return null;var h=yt(yt(yt({},d),Dn(c)),{},{fill:"none"});if(l==="top"||l==="bottom"){var m=+(l==="top"&&!u||l==="bottom"&&u);h=yt(yt({},h),{},{x1:t,y1:r+m*i,x2:t+n,y2:r+m*i})}else{var p=+(l==="left"&&!u||l==="right"&&u);h=yt(yt({},h),{},{x1:t+p*n,y1:r,x2:t+p*n,y2:r+i})}return j.createElement("line",nl({},h,{className:Qe("recharts-cartesian-axis-line",Co(c,"className"))}))}function WZ(e,t,r,n,i,l,u,c,d){var h,m,p,g,x,S,w=c?-1:1,O=e.tickSize||u,_=pe(e.tickCoord)?e.tickCoord:e.coordinate;switch(l){case"top":h=m=e.coordinate,g=r+ +!c*i,p=g-w*O,S=p-w*d,x=_;break;case"left":p=g=e.coordinate,m=t+ +!c*n,h=m-w*O,x=h-w*d,S=_;break;case"right":p=g=e.coordinate,m=t+ +c*n,h=m+w*O,x=h+w*d,S=_;break;default:h=m=e.coordinate,g=r+ +c*i,p=g+w*O,S=p+w*d,x=_;break}return{line:{x1:h,y1:p,x2:m,y2:g},tick:{x,y:S}}}function JZ(e,t){switch(e){case"left":return t?"start":"end";case"right":return t?"end":"start";default:return"middle"}}function eW(e,t){switch(e){case"left":case"right":return"middle";case"top":return t?"start":"end";default:return t?"end":"start"}}function tW(e){var{option:t,tickProps:r,value:n}=e,i,l=Qe(r.className,"recharts-cartesian-axis-tick-value");if(j.isValidElement(t))i=j.cloneElement(t,yt(yt({},r),{},{className:l}));else if(typeof t=="function")i=t(yt(yt({},r),{},{className:l}));else{var u="recharts-cartesian-axis-tick-value";typeof t!="boolean"&&(u=Qe(u,iX(t))),i=j.createElement(qS,nl({},r,{className:u}),n)}return i}function rW(e){var{ticks:t,axisType:r,axisId:n}=e,i=ut();return j.useEffect(()=>{if(n==null||r==null)return sl;var l=t.map(u=>({value:u.value,coordinate:u.coordinate,offset:u.offset,index:u.index}));return i(qZ({ticks:l,axisId:n,axisType:r})),()=>{i(HZ({axisId:n,axisType:r}))}},[i,t,n,r]),null}var nW=j.forwardRef((e,t)=>{var{ticks:r=[],tick:n,tickLine:i,stroke:l,tickFormatter:u,unit:c,padding:d,tickTextProps:h,orientation:m,mirror:p,x:g,y:x,width:S,height:w,tickSize:O,tickMargin:_,fontSize:E,letterSpacing:T,getTicksConfig:A,events:C,axisType:M,axisId:R}=e,z=FS(yt(yt({},A),{},{ticks:r}),E,T),$=Dn(A),D=Qc(n),H=SD($.textAnchor)?$.textAnchor:JZ(m,p),U=eW(m,p),ie={};typeof i=="object"&&(ie=i);var te=yt(yt({},$),{},{fill:"none"},ie),ae=z.map(ne=>yt({entry:ne},WZ(ne,g,x,S,w,m,O,p,_))),q=ae.map(ne=>{var{entry:se,line:fe}=ne;return j.createElement(en,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(se.value,"-").concat(se.coordinate,"-").concat(se.tickCoord)},i&&j.createElement("line",nl({},te,fe,{className:Qe("recharts-cartesian-axis-tick-line",Co(i,"className"))})))}),V=ae.map((ne,se)=>{var fe,I,{entry:X,tick:le}=ne,oe=yt(yt(yt(yt({verticalAnchor:U},$),{},{textAnchor:H,stroke:"none",fill:l},le),{},{index:se,payload:X,visibleTicksCount:z.length,tickFormatter:u,padding:d},h),{},{angle:(fe=(I=h==null?void 0:h.angle)!==null&&I!==void 0?I:$.angle)!==null&&fe!==void 0?fe:0}),ge=yt(yt({},oe),D);return j.createElement(en,nl({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(X.value,"-").concat(X.coordinate,"-").concat(X.tickCoord)},Om(C,X,se)),n&&j.createElement(tW,{option:n,tickProps:ge,value:"".concat(typeof u=="function"?u(X.value,se):X.value).concat(c||"")}))});return j.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(M,"-ticks")},j.createElement(rW,{ticks:z,axisId:R,axisType:M}),V.length>0&&j.createElement(_n,{zIndex:Ft.label},j.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(M,"-tick-labels"),ref:t},V)),q.length>0&&j.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(M,"-tick-lines")},q))}),aW=j.forwardRef((e,t)=>{var{axisLine:r,width:n,height:i,className:l,hide:u,ticks:c,axisType:d,axisId:h}=e,m=YZ(e,FZ),[p,g]=j.useState(""),[x,S]=j.useState(""),w=j.useRef(null);j.useImperativeHandle(t,()=>({getCalculatedWidth:()=>{var _;return BZ({ticks:w.current,label:(_=e.labelRef)===null||_===void 0?void 0:_.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var O=j.useCallback(_=>{if(_){var E=_.getElementsByClassName("recharts-cartesian-axis-tick-value");w.current=E;var T=E[0];if(T){var A=window.getComputedStyle(T),C=A.fontSize,M=A.letterSpacing;(C!==p||M!==x)&&(g(C),S(M))}}},[p,x]);return u||n!=null&&n<=0||i!=null&&i<=0?null:j.createElement(_n,{zIndex:e.zIndex},j.createElement(en,{className:Qe("recharts-cartesian-axis",l)},j.createElement(ZZ,{x:e.x,y:e.y,width:n,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:r,otherSvgProps:Dn(e)}),j.createElement(nW,{ref:O,axisType:d,events:m,fontSize:p,getTicksConfig:e,height:e.height,letterSpacing:x,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:c,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:h}),j.createElement(BQ,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},j.createElement(XQ,{label:e.label,labelRef:e.labelRef}),e.children)))}),YS=j.forwardRef((e,t)=>{var r=sr(e,$a);return j.createElement(aW,nl({},r,{ref:t}))});YS.displayName="CartesianAxis";var iW=["x1","y1","x2","y2","key"],sW=["offset"],lW=["xAxisId","yAxisId"],oW=["xAxisId","yAxisId"];function NP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function dr(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?NP(Object(r),!0).forEach(function(n){uW(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):NP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function uW(e,t,r){return(t=cW(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function cW(e){var t=fW(e,"string");return typeof t=="symbol"?t:t+""}function fW(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ms(){return Ms=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Ms.apply(null,arguments)}function dm(e,t){if(e==null)return{};var r,n,i=dW(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function dW(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var hW=e=>{var{fill:t}=e;if(!t||t==="none")return null;var{fillOpacity:r,x:n,y:i,width:l,height:u,ry:c}=e;return j.createElement("rect",{x:n,y:i,ry:c,width:l,height:u,stroke:"none",fill:t,fillOpacity:r,className:"recharts-cartesian-grid-bg"})};function XD(e){var{option:t,lineItemProps:r}=e,n;if(j.isValidElement(t))n=j.cloneElement(t,r);else if(typeof t=="function")n=t(r);else{var i,{x1:l,y1:u,x2:c,y2:d,key:h}=r,m=dm(r,iW),p=(i=Dn(m))!==null&&i!==void 0?i:{},{offset:g}=p,x=dm(p,sW);n=j.createElement("line",Ms({},x,{x1:l,y1:u,x2:c,y2:d,fill:"none",key:h}))}return n}function mW(e){var{x:t,width:r,horizontal:n=!0,horizontalPoints:i}=e;if(!n||!i||!i.length)return null;var{xAxisId:l,yAxisId:u}=e,c=dm(e,lW),d=i.map((h,m)=>{var p=dr(dr({},c),{},{x1:t,y1:h,x2:t+r,y2:h,key:"line-".concat(m),index:m});return j.createElement(XD,{key:"line-".concat(m),option:n,lineItemProps:p})});return j.createElement("g",{className:"recharts-cartesian-grid-horizontal"},d)}function pW(e){var{y:t,height:r,vertical:n=!0,verticalPoints:i}=e;if(!n||!i||!i.length)return null;var{xAxisId:l,yAxisId:u}=e,c=dm(e,oW),d=i.map((h,m)=>{var p=dr(dr({},c),{},{x1:h,y1:t,x2:h,y2:t+r,key:"line-".concat(m),index:m});return j.createElement(XD,{option:n,lineItemProps:p,key:"line-".concat(m)})});return j.createElement("g",{className:"recharts-cartesian-grid-vertical"},d)}function vW(e){var{horizontalFill:t,fillOpacity:r,x:n,y:i,width:l,height:u,horizontalPoints:c,horizontal:d=!0}=e;if(!d||!t||!t.length||c==null)return null;var h=c.map(p=>Math.round(p+i-i)).sort((p,g)=>p-g);i!==h[0]&&h.unshift(0);var m=h.map((p,g)=>{var x=h[g+1],S=x==null,w=S?i+u-p:x-p;if(w<=0)return null;var O=g%t.length;return j.createElement("rect",{key:"react-".concat(g),y:p,x:n,height:w,width:l,stroke:"none",fill:t[O],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return j.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},m)}function yW(e){var{vertical:t=!0,verticalFill:r,fillOpacity:n,x:i,y:l,width:u,height:c,verticalPoints:d}=e;if(!t||!r||!r.length)return null;var h=d.map(p=>Math.round(p+i-i)).sort((p,g)=>p-g);i!==h[0]&&h.unshift(0);var m=h.map((p,g)=>{var x=h[g+1],S=x==null,w=S?i+u-p:x-p;if(w<=0)return null;var O=g%r.length;return j.createElement("rect",{key:"react-".concat(g),x:p,y:l,width:w,height:c,stroke:"none",fill:r[O],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return j.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},m)}var gW=(e,t)=>{var{xAxis:r,width:n,height:i,offset:l}=e;return O2(FS(dr(dr(dr({},$a),r),{},{ticks:_2(r),viewBox:{x:0,y:0,width:n,height:i}})),l.left,l.left+l.width,t)},xW=(e,t)=>{var{yAxis:r,width:n,height:i,offset:l}=e;return O2(FS(dr(dr(dr({},$a),r),{},{ticks:_2(r),viewBox:{x:0,y:0,width:n,height:i}})),l.top,l.top+l.height,t)},bW={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Ft.grid};function cp(e){var t=Lb(),r=zb(),n=P2(),i=dr(dr({},sr(e,bW)),{},{x:pe(e.x)?e.x:n.left,y:pe(e.y)?e.y:n.top,width:pe(e.width)?e.width:n.width,height:pe(e.height)?e.height:n.height}),{xAxisId:l,yAxisId:u,x:c,y:d,width:h,height:m,syncWithTicks:p,horizontalValues:g,verticalValues:x}=i,S=vr(),w=ye($=>jT($,"xAxis",l,S)),O=ye($=>jT($,"yAxis",u,S));if(!aa(h)||!aa(m)||!pe(c)||!pe(d))return null;var _=i.verticalCoordinatesGenerator||gW,E=i.horizontalCoordinatesGenerator||xW,{horizontalPoints:T,verticalPoints:A}=i;if((!T||!T.length)&&typeof E=="function"){var C=g&&g.length,M=E({yAxis:O?dr(dr({},O),{},{ticks:C?g:O.ticks}):void 0,width:t??h,height:r??m,offset:n},C?!0:p);Lh(Array.isArray(M),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof M,"]")),Array.isArray(M)&&(T=M)}if((!A||!A.length)&&typeof _=="function"){var R=x&&x.length,z=_({xAxis:w?dr(dr({},w),{},{ticks:R?x:w.ticks}):void 0,width:t??h,height:r??m,offset:n},R?!0:p);Lh(Array.isArray(z),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof z,"]")),Array.isArray(z)&&(A=z)}return j.createElement(_n,{zIndex:i.zIndex},j.createElement("g",{className:"recharts-cartesian-grid"},j.createElement(hW,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),j.createElement(vW,Ms({},i,{horizontalPoints:T})),j.createElement(yW,Ms({},i,{verticalPoints:A})),j.createElement(mW,Ms({},i,{offset:n,horizontalPoints:T,xAxis:w,yAxis:O})),j.createElement(pW,Ms({},i,{offset:n,verticalPoints:A,xAxis:w,yAxis:O}))))}cp.displayName="CartesianGrid";var SW={},ZD=pr({name:"errorBars",initialState:SW,reducers:{addErrorBar:(e,t)=>{var{itemId:r,errorBar:n}=t.payload;e[r]||(e[r]=[]),e[r].push(n)},replaceErrorBar:(e,t)=>{var{itemId:r,prev:n,next:i}=t.payload;e[r]&&(e[r]=e[r].map(l=>l.dataKey===n.dataKey&&l.direction===n.direction?i:l))},removeErrorBar:(e,t)=>{var{itemId:r,errorBar:n}=t.payload;e[r]&&(e[r]=e[r].filter(i=>i.dataKey!==n.dataKey||i.direction!==n.direction))}}}),{addErrorBar:Ane,replaceErrorBar:Tne,removeErrorBar:Pne}=ZD.actions,wW=ZD.reducer,jW=["children"];function OW(e,t){if(e==null)return{};var r,n,i=_W(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function _W(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var NW={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},EW=j.createContext(NW);function WD(e){var{children:t}=e,r=OW(e,jW);return j.createElement(EW.Provider,{value:r},t)}function GS(e,t){var r,n,i=ye(h=>Xa(h,e)),l=ye(h=>Za(h,t)),u=(r=i==null?void 0:i.allowDataOverflow)!==null&&r!==void 0?r:kt.allowDataOverflow,c=(n=l==null?void 0:l.allowDataOverflow)!==null&&n!==void 0?n:It.allowDataOverflow,d=u||c;return{needClip:d,needClipX:u,needClipY:c}}function JD(e){var{xAxisId:t,yAxisId:r,clipPathId:n}=e,i=KS(),{needClipX:l,needClipY:u,needClip:c}=GS(t,r);if(!c||!i)return null;var{x:d,y:h,width:m,height:p}=i;return j.createElement("clipPath",{id:"clipPath-".concat(n)},j.createElement("rect",{x:l?d:d-m/2,y:u?h:h-p/2,width:l?m:m*2,height:u?p:p*2}))}var e3=(e,t,r,n)=>Qi(e,"xAxis",t,n),t3=(e,t,r,n)=>Vi(e,"xAxis",t,n),r3=(e,t,r,n)=>Qi(e,"yAxis",r,n),n3=(e,t,r,n)=>Vi(e,"yAxis",r,n),AW=G([Xe,e3,r3,t3,n3],(e,t,r,n,i)=>Ya(e,"xAxis")?Ro(t,n,!1):Ro(r,i,!1)),TW=(e,t,r,n,i)=>i;function PW(e){return e.type==="line"}var CW=G([sp,TW],(e,t)=>e.filter(PW).find(r=>r.id===t)),MW=G([Xe,e3,r3,t3,n3,CW,AW,nf],(e,t,r,n,i,l,u,c)=>{var{chartData:d,dataStartIndex:h,dataEndIndex:m}=c;if(!(l==null||t==null||r==null||n==null||i==null||n.length===0||i.length===0||u==null||e!=="horizontal"&&e!=="vertical")){var{dataKey:p,data:g}=l,x;if(g!=null&&g.length>0?x=g:x=d==null?void 0:d.slice(h,m+1),x!=null)return JW({layout:e,xAxis:t,yAxis:r,xAxisTicks:n,yAxisTicks:i,dataKey:p,bandSize:u,displayedData:x})}});function RW(e){var t=Qc(e),r=3,n=2;if(t!=null){var{r:i,strokeWidth:l}=t,u=Number(i),c=Number(l);return(Number.isNaN(u)||u<0)&&(u=r),(Number.isNaN(c)||c<0)&&(c=n),{r:u,strokeWidth:c}}return{r,strokeWidth:n}}var DW=["id"],kW=["type","layout","connectNulls","needClip","shape"],IW=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function Uc(){return Uc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Uc.apply(null,arguments)}function EP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Zn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?EP(Object(r),!0).forEach(function(n){LW(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):EP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function LW(e,t,r){return(t=zW(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function zW(e){var t=$W(e,"string");return typeof t=="symbol"?t:t+""}function $W(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function VS(e,t){if(e==null)return{};var r,n,i=BW(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function BW(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var UW=e=>{var{dataKey:t,name:r,stroke:n,legendType:i,hide:l}=e;return[{inactive:l,dataKey:t,type:i,color:n,value:km(r,t),payload:e}]},qW=j.memo(e=>{var{dataKey:t,data:r,stroke:n,strokeWidth:i,fill:l,name:u,hide:c,unit:d,tooltipType:h,id:m}=e,p={dataDefinedOnItem:r,getPosition:sl,settings:{stroke:n,strokeWidth:i,fill:l,dataKey:t,nameKey:void 0,name:km(u,t),hide:c,type:h,color:n,unit:d,graphicalItemId:m}};return j.createElement($D,{tooltipEntrySettings:p})}),a3=(e,t)=>"".concat(t,"px ").concat(e,"px");function HW(e,t){for(var r=e.length%2!==0?[...e,0]:e,n=[],i=0;i<t;++i)n.push(...r);return n}var KW=(e,t,r)=>{var n=r.reduce((g,x)=>g+x,0);if(!n)return a3(t,e);for(var i=Math.floor(e/n),l=e%n,u=[],c=0,d=0;c<r.length;d+=(h=r[c])!==null&&h!==void 0?h:0,++c){var h,m=r[c];if(m!=null&&d+m>l){u=[...r.slice(0,c),l-d];break}}var p=u.length%2===0?[0,t]:[t];return[...HW(r,i),...u,...p].map(g=>"".concat(g,"px")).join(", ")};function FW(e){var{clipPathId:t,points:r,props:n}=e,{dot:i,dataKey:l,needClip:u}=n,{id:c}=n,d=VS(n,DW),h=Dn(d);return j.createElement(YX,{points:r,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:l,baseProps:h,needClip:u,clipPathId:t})}function YW(e){var{showLabels:t,children:r,points:n}=e,i=j.useMemo(()=>n==null?void 0:n.map(l=>{var u,c,d={x:(u=l.x)!==null&&u!==void 0?u:0,y:(c=l.y)!==null&&c!==void 0?c:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Zn(Zn({},d),{},{value:l.value,payload:l.payload,viewBox:d,parentViewBox:void 0,fill:void 0})}),[n]);return j.createElement(AD,{value:t?i:void 0},r)}function AP(e){var{clipPathId:t,pathRef:r,points:n,strokeDasharray:i,props:l}=e,{type:u,layout:c,connectNulls:d,needClip:h,shape:m}=l,p=VS(l,kW),g=Zn(Zn({},jr(p)),{},{fill:"none",className:"recharts-line-curve",clipPath:h?"url(#clipPath-".concat(t,")"):void 0,points:n,type:u,layout:c,connectNulls:d,strokeDasharray:i??l.strokeDasharray});return j.createElement(j.Fragment,null,(n==null?void 0:n.length)>1&&j.createElement(kD,Uc({shapeType:"curve",option:m},g,{pathRef:r})),j.createElement(FW,{points:n,clipPathId:t,props:l}))}function GW(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function VW(e){var{clipPathId:t,props:r,pathRef:n,previousPointsRef:i,longestAnimatedLengthRef:l}=e,{points:u,strokeDasharray:c,isAnimationActive:d,animationBegin:h,animationDuration:m,animationEasing:p,animateNewValues:g,width:x,height:S,onAnimationEnd:w,onAnimationStart:O}=r,_=i.current,E=Fm(u,"recharts-line-"),T=j.useRef(E),[A,C]=j.useState(!1),M=!A,R=j.useCallback(()=>{typeof w=="function"&&w(),C(!1)},[w]),z=j.useCallback(()=>{typeof O=="function"&&O(),C(!0)},[O]),$=GW(n.current),D=j.useRef(0);T.current!==E&&(D.current=l.current,T.current=E);var H=D.current;return j.createElement(YW,{points:u,showLabels:M},r.children,j.createElement(Km,{animationId:E,begin:h,duration:m,isActive:d,easing:p,onAnimationEnd:R,onAnimationStart:z,key:E},U=>{var ie=xt(H,$+H,U),te=Math.min(ie,$),ae;if(d)if(c){var q="".concat(c).split(/[,\s]+/gim).map(se=>parseFloat(se));ae=KW(te,$,q)}else ae=a3($,te);else ae=c==null?void 0:String(c);if(U>0&&$>0&&(i.current=u,l.current=Math.max(l.current,te)),_){var V=_.length/u.length,ne=U===1?u:u.map((se,fe)=>{var I=Math.floor(fe*V);if(_[I]){var X=_[I];return Zn(Zn({},se),{},{x:xt(X.x,se.x,U),y:xt(X.y,se.y,U)})}return g?Zn(Zn({},se),{},{x:xt(x*2,se.x,U),y:xt(S/2,se.y,U)}):Zn(Zn({},se),{},{x:se.x,y:se.y})});return i.current=ne,j.createElement(AP,{props:r,points:ne,clipPathId:t,pathRef:n,strokeDasharray:ae})}return j.createElement(AP,{props:r,points:u,clipPathId:t,pathRef:n,strokeDasharray:ae})}),j.createElement(PD,{label:r.label}))}function QW(e){var{clipPathId:t,props:r}=e,n=j.useRef(null),i=j.useRef(0),l=j.useRef(null);return j.createElement(VW,{props:r,clipPathId:t,previousPointsRef:n,longestAnimatedLengthRef:i,pathRef:l})}var XW=(e,t)=>{var r,n;return{x:(r=e.x)!==null&&r!==void 0?r:void 0,y:(n=e.y)!==null&&n!==void 0?n:void 0,value:e.value,errorVal:Ot(e.payload,t)}};class ZW extends j.Component{render(){var{hide:t,dot:r,points:n,className:i,xAxisId:l,yAxisId:u,top:c,left:d,width:h,height:m,id:p,needClip:g,zIndex:x}=this.props;if(t)return null;var S=Qe("recharts-line",i),w=p,{r:O,strokeWidth:_}=RW(r),E=DD(r),T=O*2+_,A=g?"url(#clipPath-".concat(E?"":"dots-").concat(w,")"):void 0;return j.createElement(_n,{zIndex:x},j.createElement(en,{className:S},g&&j.createElement("defs",null,j.createElement(JD,{clipPathId:w,xAxisId:l,yAxisId:u}),!E&&j.createElement("clipPath",{id:"clipPath-dots-".concat(w)},j.createElement("rect",{x:d-T/2,y:c-T/2,width:h+T,height:m+T}))),j.createElement(WD,{xAxisId:l,yAxisId:u,data:n,dataPointFormatter:XW,errorBarOffset:0},j.createElement(QW,{props:this.props,clipPathId:w}))),j.createElement(dZ,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var i3={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:Ft.line,type:"linear"};function WW(e){var t=sr(e,i3),{activeDot:r,animateNewValues:n,animationBegin:i,animationDuration:l,animationEasing:u,connectNulls:c,dot:d,hide:h,isAnimationActive:m,label:p,legendType:g,xAxisId:x,yAxisId:S,id:w}=t,O=VS(t,IW),{needClip:_}=GS(x,S),E=KS(),T=ll(),A=vr(),C=ye(D=>MW(D,x,S,A,w));if(T!=="horizontal"&&T!=="vertical"||C==null||E==null)return null;var{height:M,width:R,x:z,y:$}=E;return j.createElement(ZW,Uc({},O,{id:w,connectNulls:c,dot:d,activeDot:r,animateNewValues:n,animationBegin:i,animationDuration:l,animationEasing:u,isAnimationActive:m,hide:h,label:p,legendType:g,xAxisId:x,yAxisId:S,points:C,layout:T,height:M,width:R,left:z,top:$,needClip:_}))}function JW(e){var{layout:t,xAxis:r,yAxis:n,xAxisTicks:i,yAxisTicks:l,dataKey:u,bandSize:c,displayedData:d}=e;return d.map((h,m)=>{var p=Ot(h,u);if(t==="horizontal"){var g=pE({axis:r,ticks:i,bandSize:c,entry:h,index:m}),x=ht(p)?null:n.scale.map(p);return{x:g,y:x??null,value:p,payload:h}}var S=ht(p)?null:r.scale.map(p),w=pE({axis:n,ticks:l,bandSize:c,entry:h,index:m});return S==null||w==null?null:{x:S,y:w,value:p,payload:h}}).filter(Boolean)}function eJ(e){var t=sr(e,i3),r=vr();return j.createElement(UD,{id:t.id,type:"line"},n=>j.createElement(j.Fragment,null,j.createElement(BD,{legendPayload:UW(t)}),j.createElement(qW,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:n}),j.createElement(HD,{type:"line",id:n,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:r}),j.createElement(WW,Uc({},t,{id:n}))))}var s3=j.memo(eJ,Fo);s3.displayName="Line";function fl(e,t){var r,n;return(r=(n=e.graphicalItems.cartesianItems.find(i=>i.id===t))===null||n===void 0?void 0:n.xAxisId)!==null&&r!==void 0?r:KD}function dl(e,t){var r,n;return(r=(n=e.graphicalItems.cartesianItems.find(i=>i.id===t))===null||n===void 0?void 0:n.yAxisId)!==null&&r!==void 0?r:KD}var tJ="Invariant failed";function rJ(e,t){throw new Error(tJ)}function $x(){return $x=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},$x.apply(null,arguments)}function QS(e){return j.createElement(kD,$x({shapeType:"rectangle",activeClassName:"recharts-active-bar",inActiveClassName:"recharts-inactive-bar"},e))}var nJ=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(n,i)=>{if(pe(t))return t;var l=pe(n)||ht(n);return l?t(n,i):(l||rJ(),r)}},aJ=(e,t,r)=>r,iJ=(e,t)=>t,mf=G([sp,iJ],(e,t)=>e.filter(r=>r.type==="bar").find(r=>r.id===t)),sJ=G([mf],e=>e==null?void 0:e.maxBarSize),lJ=(e,t,r,n)=>n,oJ=G([Xe,sp,fl,dl,aJ],(e,t,r,n,i)=>t.filter(l=>e==="horizontal"?l.xAxisId===r:l.yAxisId===n).filter(l=>l.isPanorama===i).filter(l=>l.hide===!1).filter(l=>l.type==="bar")),uJ=(e,t,r)=>{var n=Xe(e),i=fl(e,t),l=dl(e,t);if(!(i==null||l==null))return n==="horizontal"?Dx(e,"yAxis",l,r):Dx(e,"xAxis",i,r)},cJ=(e,t)=>{var r=Xe(e),n=fl(e,t),i=dl(e,t);if(!(n==null||i==null))return r==="horizontal"?wT(e,"xAxis",n):wT(e,"yAxis",i)},fJ=G([oJ,GH,cJ],hZ),dJ=(e,t,r)=>{var n,i,l=mf(e,t);if(l==null)return 0;var u=fl(e,t),c=dl(e,t);if(u==null||c==null)return 0;var d=Xe(e),h=cR(e),{maxBarSize:m}=l,p=ht(m)?h:m,g,x;return d==="horizontal"?(g=Qi(e,"xAxis",u,r),x=Vi(e,"xAxis",u,r)):(g=Qi(e,"yAxis",c,r),x=Vi(e,"yAxis",c,r)),(n=(i=Ro(g,x,!0))!==null&&i!==void 0?i:p)!==null&&n!==void 0?n:0},l3=(e,t,r)=>{var n=Xe(e),i=fl(e,t),l=dl(e,t);if(!(i==null||l==null)){var u,c;return n==="horizontal"?(u=Qi(e,"xAxis",i,r),c=Vi(e,"xAxis",i,r)):(u=Qi(e,"yAxis",l,r),c=Vi(e,"yAxis",l,r)),Ro(u,c)}},hJ=G([fJ,cR,YH,fR,dJ,l3,sJ],gZ),mJ=(e,t,r)=>{var n=fl(e,t);if(n!=null)return Qi(e,"xAxis",n,r)},pJ=(e,t,r)=>{var n=dl(e,t);if(n!=null)return Qi(e,"yAxis",n,r)},vJ=(e,t,r)=>{var n=fl(e,t);if(n!=null)return Vi(e,"xAxis",n,r)},yJ=(e,t,r)=>{var n=dl(e,t);if(n!=null)return Vi(e,"yAxis",n,r)},gJ=G([hJ,mf],bZ),xJ=G([uJ,mf],xZ),bJ=G([Yt,Rb,mJ,pJ,vJ,yJ,gJ,Xe,zH,l3,xJ,mf,lJ],(e,t,r,n,i,l,u,c,d,h,m,p,g)=>{var{chartData:x,dataStartIndex:S,dataEndIndex:w}=d;if(!(p==null||u==null||t==null||c!=="horizontal"&&c!=="vertical"||r==null||n==null||i==null||l==null||h==null)){var{data:O}=p,_;if(O!=null&&O.length>0?_=O:_=x==null?void 0:x.slice(S,w+1),_!=null)return VJ({layout:c,barSettings:p,pos:u,parentViewBox:t,bandSize:h,xAxis:r,yAxis:n,xAxisTicks:i,yAxisTicks:l,stackedData:m,displayedData:_,offset:e,cells:g,dataStartIndex:S})}}),SJ=["index"];function Bx(){return Bx=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Bx.apply(null,arguments)}function wJ(e,t){if(e==null)return{};var r,n,i=jJ(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function jJ(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var o3=j.createContext(void 0),OJ=e=>{var t=j.useContext(o3);if(t!=null)return t.stackId;if(e!=null)return CU(e)},_J=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),NJ=e=>{var t=j.useContext(o3);if(t!=null){var{stackId:r}=t;return"url(#".concat(_J(r,e),")")}},u3=e=>{var{index:t}=e,r=wJ(e,SJ),n=NJ(t);return j.createElement(en,Bx({className:"recharts-bar-stack-layer",clipPath:n},r))},EJ=["onMouseEnter","onMouseLeave","onClick"],AJ=["value","background","tooltipPosition"],TJ=["id"],PJ=["onMouseEnter","onClick","onMouseLeave"];function Xi(){return Xi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Xi.apply(null,arguments)}function TP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function br(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?TP(Object(r),!0).forEach(function(n){CJ(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):TP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function CJ(e,t,r){return(t=MJ(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function MJ(e){var t=RJ(e,"string");return typeof t=="symbol"?t:t+""}function RJ(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function hm(e,t){if(e==null)return{};var r,n,i=DJ(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function DJ(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var kJ=e=>{var{dataKey:t,name:r,fill:n,legendType:i,hide:l}=e;return[{inactive:l,dataKey:t,type:i,color:n,value:km(r,t),payload:e}]},IJ=j.memo(e=>{var{dataKey:t,stroke:r,strokeWidth:n,fill:i,name:l,hide:u,unit:c,tooltipType:d,id:h}=e,m={dataDefinedOnItem:void 0,getPosition:sl,settings:{stroke:r,strokeWidth:n,fill:i,dataKey:t,nameKey:void 0,name:km(l,t),hide:u,type:d,color:i,unit:c,graphicalItemId:h}};return j.createElement($D,{tooltipEntrySettings:m})});function LJ(e){var t=ye(rl),{data:r,dataKey:n,background:i,allOtherBarProps:l}=e,{onMouseEnter:u,onMouseLeave:c,onClick:d}=l,h=hm(l,EJ),m=ID(u,n,l.id),p=LD(c),g=zD(d,n,l.id);if(!i||r==null)return null;var x=Qc(i);return j.createElement(_n,{zIndex:SZ(i,Ft.barBackground)},r.map((S,w)=>{var{value:O,background:_,tooltipPosition:E}=S,T=hm(S,AJ);if(!_)return null;var A=m(S,w),C=p(S,w),M=g(S,w),R=br(br(br(br(br({option:i,isActive:String(w)===t},T),{},{fill:"#eee"},_),x),Om(h,S,w)),{},{onMouseEnter:A,onMouseLeave:C,onClick:M,dataKey:n,index:w,className:"recharts-bar-background-rectangle"});return j.createElement(QS,Xi({key:"background-bar-".concat(w)},R))}))}function zJ(e){var{showLabels:t,children:r,rects:n}=e,i=n==null?void 0:n.map(l=>{var u={x:l.x,y:l.y,width:l.width,lowerWidth:l.width,upperWidth:l.width,height:l.height};return br(br({},u),{},{value:l.value,payload:l.payload,parentViewBox:l.parentViewBox,viewBox:u,fill:l.fill})});return j.createElement(AD,{value:t?i:void 0},r)}function $J(e){var{shape:t,activeBar:r,baseProps:n,entry:i,index:l,dataKey:u}=e,c=ye(rl),d=ye(iD),h=r&&String(i.originalDataIndex)===c&&(d==null||u===d),[m,p]=j.useState(!1),[g,x]=j.useState(!1);j.useEffect(()=>{var T;return h?(p(!0),T=requestAnimationFrame(()=>{x(!0)})):x(!1),()=>{cancelAnimationFrame(T)}},[h]);var S=j.useCallback(()=>{h||p(!1)},[h]),w=h&&g,O=h||m,_;h?r===!0?_=t:_=r:_=t;var E=j.createElement(QS,Xi({},n,{name:String(n.name)},i,{isActive:w,option:_,index:l,dataKey:u,onTransitionEnd:S}));return O?j.createElement(_n,{zIndex:Ft.activeBar},j.createElement(u3,{index:i.originalDataIndex},E)):E}function BJ(e){var{shape:t,baseProps:r,entry:n,index:i,dataKey:l}=e;return j.createElement(QS,Xi({},r,{name:String(r.name)},n,{isActive:!1,option:t,index:i,dataKey:l}))}function UJ(e){var t,{data:r,props:n}=e,i=(t=Dn(n))!==null&&t!==void 0?t:{},{id:l}=i,u=hm(i,TJ),{shape:c,dataKey:d,activeBar:h}=n,{onMouseEnter:m,onClick:p,onMouseLeave:g}=n,x=hm(n,PJ),S=ID(m,d,l),w=LD(g),O=zD(p,d,l);return r?j.createElement(j.Fragment,null,r.map((_,E)=>j.createElement(u3,Xi({index:_.originalDataIndex,key:"rectangle-".concat(_==null?void 0:_.x,"-").concat(_==null?void 0:_.y,"-").concat(_==null?void 0:_.value,"-").concat(E),className:"recharts-bar-rectangle"},Om(x,_,E),{onMouseEnter:S(_,E),onMouseLeave:w(_,E),onClick:O(_,E)}),h?j.createElement($J,{shape:c,activeBar:h,baseProps:u,entry:_,index:E,dataKey:d}):j.createElement(BJ,{shape:c,baseProps:u,entry:_,index:E,dataKey:d})))):null}function qJ(e){var{props:t,previousRectanglesRef:r}=e,{data:n,layout:i,isAnimationActive:l,animationBegin:u,animationDuration:c,animationEasing:d,onAnimationEnd:h,onAnimationStart:m}=t,p=r.current,g=Fm(t,"recharts-bar-"),[x,S]=j.useState(!1),w=!x,O=j.useCallback(()=>{typeof h=="function"&&h(),S(!1)},[h]),_=j.useCallback(()=>{typeof m=="function"&&m(),S(!0)},[m]);return j.createElement(zJ,{showLabels:w,rects:n},j.createElement(Km,{animationId:g,begin:u,duration:c,isActive:l,easing:d,onAnimationEnd:O,onAnimationStart:_,key:g},E=>{var T=E===1?n:n==null?void 0:n.map((A,C)=>{var M=p&&p[C];if(M)return br(br({},A),{},{x:xt(M.x,A.x,E),y:xt(M.y,A.y,E),width:xt(M.width,A.width,E),height:xt(M.height,A.height,E)});if(i==="horizontal"){var R=xt(0,A.height,E),z=xt(A.stackedBarStart,A.y,E);return br(br({},A),{},{y:z,height:R})}var $=xt(0,A.width,E),D=xt(A.stackedBarStart,A.x,E);return br(br({},A),{},{width:$,x:D})});return E>0&&(r.current=T??null),T==null?null:j.createElement(en,null,j.createElement(UJ,{props:t,data:T}))}),j.createElement(PD,{label:t.label}),t.children)}function HJ(e){var t=j.useRef(null);return j.createElement(qJ,{previousRectanglesRef:t,props:e})}var c3=0,KJ=(e,t)=>{var r=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:r,errorVal:Ot(e,t)}};class FJ extends j.PureComponent{render(){var{hide:t,data:r,dataKey:n,className:i,xAxisId:l,yAxisId:u,needClip:c,background:d,id:h}=this.props;if(t||r==null)return null;var m=Qe("recharts-bar",i),p=h;return j.createElement(en,{className:m,id:h},c&&j.createElement("defs",null,j.createElement(JD,{clipPathId:p,xAxisId:l,yAxisId:u})),j.createElement(en,{className:"recharts-bar-rectangles",clipPath:c?"url(#clipPath-".concat(p,")"):void 0},j.createElement(LJ,{data:r,dataKey:n,background:d,allOtherBarProps:this.props}),j.createElement(HJ,this.props)))}}var YJ={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:c3,xAxisId:0,yAxisId:0,zIndex:Ft.bar};function GJ(e){var{xAxisId:t,yAxisId:r,hide:n,legendType:i,minPointSize:l,activeBar:u,animationBegin:c,animationDuration:d,animationEasing:h,isAnimationActive:m}=e,{needClip:p}=GS(t,r),g=ll(),x=vr(),S=uX(e.children,US),w=ye(E=>bJ(E,e.id,x,S));if(g!=="vertical"&&g!=="horizontal")return null;var O,_=w==null?void 0:w[0];return _==null||_.height==null||_.width==null?O=0:O=g==="vertical"?_.height/2:_.width/2,j.createElement(WD,{xAxisId:t,yAxisId:r,data:w,dataPointFormatter:KJ,errorBarOffset:O},j.createElement(FJ,Xi({},e,{layout:g,needClip:p,data:w,xAxisId:t,yAxisId:r,hide:n,legendType:i,minPointSize:l,activeBar:u,animationBegin:c,animationDuration:d,animationEasing:h,isAnimationActive:m})))}function VJ(e){var{layout:t,barSettings:{dataKey:r,minPointSize:n,hasCustomShape:i},pos:l,bandSize:u,xAxis:c,yAxis:d,xAxisTicks:h,yAxisTicks:m,stackedData:p,displayedData:g,offset:x,cells:S,parentViewBox:w,dataStartIndex:O}=e,_=t==="horizontal"?d:c,E=p?_.scale.domain():null,T=MU({numericAxis:_}),A=_.scale.map(T);return g.map((C,M)=>{var R,z,$,D,H,U;if(p){var ie=p[M+O];if(ie==null)return null;R=NU(ie,E)}else R=Ot(C,r),Array.isArray(R)||(R=[T,R]);var te=nJ(n,c3)(R[1],M);if(t==="horizontal"){var ae,q=d.scale.map(R[0]),V=d.scale.map(R[1]);if(q==null||V==null)return null;z=vE({axis:c,ticks:h,bandSize:u,offset:l.offset,entry:C,index:M}),$=(ae=V??q)!==null&&ae!==void 0?ae:void 0,D=l.size;var ne=q-V;if(H=ra(ne)?0:ne,U={x:z,y:x.top,width:D,height:x.height},Math.abs(te)>0&&Math.abs(H)<Math.abs(te)){var se=Lr(H||te)*(Math.abs(te)-Math.abs(H));$-=se,H+=se}}else{var fe=c.scale.map(R[0]),I=c.scale.map(R[1]);if(fe==null||I==null)return null;if(z=fe,$=vE({axis:d,ticks:m,bandSize:u,offset:l.offset,entry:C,index:M}),D=I-fe,H=l.size,U={x:x.left,y:$,width:x.width,height:H},Math.abs(te)>0&&Math.abs(D)<Math.abs(te)){var X=Lr(D||te)*(Math.abs(te)-Math.abs(D));D+=X}}if(z==null||$==null||D==null||H==null||!i&&(D===0||H===0))return null;var le=br(br({},C),{},{stackedBarStart:A,x:z,y:$,width:D,height:H,value:p?R:R[1],payload:C,background:U,tooltipPosition:{x:z+D/2,y:$+H/2},parentViewBox:w,originalDataIndex:M},S&&S[M]&&S[M].props);return le}).filter(Boolean)}function QJ(e){var t=sr(e,YJ),r=OJ(t.stackId),n=vr();return j.createElement(UD,{id:t.id,type:"bar"},i=>j.createElement(j.Fragment,null,j.createElement(BD,{legendPayload:kJ(t)}),j.createElement(IJ,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:i}),j.createElement(HD,{type:"bar",id:i,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:r,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:n,hasCustomShape:t.shape!=null}),j.createElement(_n,{zIndex:t.zIndex},j.createElement(GJ,Xi({},t,{id:i})))))}var XS=j.memo(QJ,Fo);XS.displayName="Bar";var XJ=["domain","range"],ZJ=["domain","range"];function PP(e,t){if(e==null)return{};var r,n,i=WJ(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function WJ(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function CP(e,t){return e===t?!0:Array.isArray(e)&&e.length===2&&Array.isArray(t)&&t.length===2?e[0]===t[0]&&e[1]===t[1]:!1}function f3(e,t){if(e===t)return!0;var{domain:r,range:n}=e,i=PP(e,XJ),{domain:l,range:u}=t,c=PP(t,ZJ);return!CP(r,l)||!CP(n,u)?!1:Fo(i,c)}var JJ=["type"],eee=["dangerouslySetInnerHTML","ticks","scale"],tee=["id","scale"];function Ux(){return Ux=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Ux.apply(null,arguments)}function MP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function RP(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?MP(Object(r),!0).forEach(function(n){ree(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):MP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ree(e,t,r){return(t=nee(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function nee(e){var t=aee(e,"string");return typeof t=="symbol"?t:t+""}function aee(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function qx(e,t){if(e==null)return{};var r,n,i=iee(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function iee(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function see(e){var t=ut(),r=j.useRef(null),n=C2(),{type:i}=e,l=qx(e,JJ),u=Vm(n,"xAxis",i),c=j.useMemo(()=>{if(u!=null)return RP(RP({},l),{},{type:u})},[l,u]);return j.useLayoutEffect(()=>{c!=null&&(r.current===null?t(ZX(c)):r.current!==c&&t(WX({prev:r.current,next:c})),r.current=c)},[c,t]),j.useLayoutEffect(()=>()=>{r.current&&(t(JX(r.current)),r.current=null)},[t]),null}var lee=e=>{var{xAxisId:t,className:r}=e,n=ye(Rb),i=vr(),l="xAxis",u=ye(_=>L4(_,l,t,i)),c=ye(_=>D4(_,t)),d=ye(_=>AY(_,t)),h=ye(_=>r4(_,t));if(c==null||d==null||h==null)return null;var{dangerouslySetInnerHTML:m,ticks:p,scale:g}=e,x=qx(e,eee),{id:S,scale:w}=h,O=qx(h,tee);return j.createElement(YS,Ux({},x,O,{x:d.x,y:d.y,width:c.width,height:c.height,className:Qe("recharts-".concat(l," ").concat(l),r),viewBox:n,ticks:u,axisType:l,axisId:t}))},oee={allowDataOverflow:kt.allowDataOverflow,allowDecimals:kt.allowDecimals,allowDuplicatedCategory:kt.allowDuplicatedCategory,angle:kt.angle,axisLine:$a.axisLine,height:kt.height,hide:!1,includeHidden:kt.includeHidden,interval:kt.interval,label:!1,minTickGap:kt.minTickGap,mirror:kt.mirror,orientation:kt.orientation,padding:kt.padding,reversed:kt.reversed,scale:kt.scale,tick:kt.tick,tickCount:kt.tickCount,tickLine:$a.tickLine,tickSize:$a.tickSize,type:kt.type,niceTicks:kt.niceTicks,xAxisId:0},uee=e=>{var t=sr(e,oee);return j.createElement(j.Fragment,null,j.createElement(see,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),j.createElement(lee,t))},fp=j.memo(uee,f3);fp.displayName="XAxis";var cee=["type"],fee=["dangerouslySetInnerHTML","ticks","scale"],dee=["id","scale"];function Hx(){return Hx=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Hx.apply(null,arguments)}function DP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function kP(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?DP(Object(r),!0).forEach(function(n){hee(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):DP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function hee(e,t,r){return(t=mee(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function mee(e){var t=pee(e,"string");return typeof t=="symbol"?t:t+""}function pee(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Kx(e,t){if(e==null)return{};var r,n,i=vee(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function vee(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function yee(e){var t=ut(),r=j.useRef(null),n=C2(),{type:i}=e,l=Kx(e,cee),u=Vm(n,"yAxis",i),c=j.useMemo(()=>{if(u!=null)return kP(kP({},l),{},{type:u})},[u,l]);return j.useLayoutEffect(()=>{c!=null&&(r.current===null?t(eZ(c)):r.current!==c&&t(tZ({prev:r.current,next:c})),r.current=c)},[c,t]),j.useLayoutEffect(()=>()=>{r.current&&(t(rZ(r.current)),r.current=null)},[t]),null}function gee(e){var{yAxisId:t,className:r,width:n,label:i}=e,l=j.useRef(null),u=j.useRef(null),c=ye(Rb),d=vr(),h=ut(),m="yAxis",p=ye(M=>k4(M,t)),g=ye(M=>PY(M,t)),x=ye(M=>L4(M,m,t,d)),S=ye(M=>n4(M,t));if(j.useLayoutEffect(()=>{if(!(n!=="auto"||!p||HS(i)||j.isValidElement(i)||S==null)){var M=l.current;if(M){var R=M.getCalculatedWidth();Math.round(p.width)!==Math.round(R)&&h(nZ({id:t,width:R}))}}},[x,p,h,i,t,n,S]),p==null||g==null||S==null)return null;var{dangerouslySetInnerHTML:w,ticks:O,scale:_}=e,E=Kx(e,fee),{id:T,scale:A}=S,C=Kx(S,dee);return j.createElement(YS,Hx({},E,C,{ref:l,labelRef:u,x:g.x,y:g.y,tickTextProps:n==="auto"?{width:void 0}:{width:n},width:p.width,height:p.height,className:Qe("recharts-".concat(m," ").concat(m),r),viewBox:c,ticks:x,axisType:m,axisId:t}))}var xee={allowDataOverflow:It.allowDataOverflow,allowDecimals:It.allowDecimals,allowDuplicatedCategory:It.allowDuplicatedCategory,angle:It.angle,axisLine:$a.axisLine,hide:!1,includeHidden:It.includeHidden,interval:It.interval,label:!1,minTickGap:It.minTickGap,mirror:It.mirror,orientation:It.orientation,padding:It.padding,reversed:It.reversed,scale:It.scale,tick:It.tick,tickCount:It.tickCount,tickLine:$a.tickLine,tickSize:$a.tickSize,type:It.type,niceTicks:It.niceTicks,width:It.width,yAxisId:0},bee=e=>{var t=sr(e,xee);return j.createElement(j.Fragment,null,j.createElement(yee,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),j.createElement(gee,t))},dp=j.memo(bee,f3);dp.displayName="YAxis";var See=(e,t)=>t,ZS=G([See,Xe,gR,Vt,tD,Wa,JG,Yt],sV);function wee(e){return"getBBox"in e.currentTarget&&typeof e.currentTarget.getBBox=="function"}function WS(e){var t=e.currentTarget.getBoundingClientRect(),r,n;if(wee(e)){var i=e.currentTarget.getBBox();r=i.width>0?t.width/i.width:1,n=i.height>0?t.height/i.height:1}else{var l=e.currentTarget;r=l.offsetWidth>0?t.width/l.offsetWidth:1,n=l.offsetHeight>0?t.height/l.offsetHeight:1}var u=(c,d)=>({relativeX:Math.round((c-t.left)/r),relativeY:Math.round((d-t.top)/n)});return"touches"in e?Array.from(e.touches).map(c=>u(c.clientX,c.clientY)):u(e.clientX,e.clientY)}var d3=tn("mouseClick"),h3=Wc();h3.startListening({actionCreator:d3,effect:(e,t)=>{var r=e.payload,n=ZS(t.getState(),WS(r));(n==null?void 0:n.activeIndex)!=null&&t.dispatch(YY({activeIndex:n.activeIndex,activeDataKey:void 0,activeCoordinate:n.activeCoordinate}))}});var Fx=tn("mouseMove"),m3=Wc(),io=null,bs=null,_0=null;m3.startListening({actionCreator:Fx,effect:(e,t)=>{var r=e.payload,n=t.getState(),{throttleDelay:i,throttledEvents:l}=n.eventSettings,u=l==="all"||(l==null?void 0:l.includes("mousemove"));io!==null&&(cancelAnimationFrame(io),io=null),bs!==null&&(typeof i!="number"||!u)&&(clearTimeout(bs),bs=null),_0=WS(r);var c=()=>{var d=t.getState(),h=df(d,d.tooltip.settings.shared);if(!_0){io=null,bs=null;return}if(h==="axis"){var m=ZS(d,_0);(m==null?void 0:m.activeIndex)!=null?t.dispatch(F4({activeIndex:m.activeIndex,activeDataKey:void 0,activeCoordinate:m.activeCoordinate})):t.dispatch(K4())}io=null,bs=null};if(!u){c();return}i==="raf"?io=requestAnimationFrame(c):typeof i=="number"&&bs===null&&(bs=setTimeout(c,i))}});function jee(e,t){return t instanceof HTMLElement?"HTMLElement <".concat(t.tagName,' class="').concat(t.className,'">'):t===window?"global.window":e==="children"&&typeof t=="object"&&t!==null?"<<CHILDREN>>":t}var IP={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},p3=pr({name:"rootProps",initialState:IP,reducers:{updateOptions:(e,t)=>{var r;e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=(r=t.payload.barGap)!==null&&r!==void 0?r:IP.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),Oee=p3.reducer,{updateOptions:_ee}=p3.actions,Nee=null,Eee={updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)},v3=pr({name:"polarOptions",initialState:Nee,reducers:Eee}),{updatePolarOptions:Cne}=v3.actions,Aee=v3.reducer,y3=tn("keyDown"),g3=tn("focus"),x3=tn("blur"),hp=Wc(),so=null,Ss=null,Jd=null;hp.startListening({actionCreator:y3,effect:(e,t)=>{Jd=e.payload,so!==null&&(cancelAnimationFrame(so),so=null);var r=t.getState(),{throttleDelay:n,throttledEvents:i}=r.eventSettings,l=i==="all"||i.includes("keydown");Ss!==null&&(typeof n!="number"||!l)&&(clearTimeout(Ss),Ss=null);var u=()=>{try{var c=t.getState(),d=c.rootProps.accessibilityLayer!==!1;if(!d)return;var{keyboardInteraction:h}=c.tooltip,m=Jd;if(m!=="ArrowRight"&&m!=="ArrowLeft"&&m!=="Enter")return;var p=yc(h,tl(c),$o(c),Bo(c)),g=p==null?-1:Number(p),x=!Number.isFinite(g)||g<0,S=Wa(c),w=tl(c),O=df(c,c.tooltip.settings.shared);if(m==="Enter"){if(x)return;var _=lm(c,O,"hover",String(h.index));t.dispatch(sm({active:!h.active,activeIndex:h.index,activeCoordinate:_}));return}var E=kY(c),T=E==="left-to-right"?1:-1,A=m==="ArrowRight"?1:-1,C;if(x){var M=$o(c),R=Bo(c),z=A*T,$=te=>({active:!1,index:String(te),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(C=-1,z>0){for(var D=0;D<w.length;D++)if(yc($(D),w,M,R)!=null){C=D;break}}else for(var H=w.length-1;H>=0;H--)if(yc($(H),w,M,R)!=null){C=H;break}if(C<0)return}else{C=g+A*T;var U=(S==null?void 0:S.length)||w.length;if(U===0||C>=U||C<0)return}var ie=lm(c,O,"hover",String(C));t.dispatch(sm({active:!0,activeIndex:C.toString(),activeCoordinate:ie}))}finally{so=null,Ss=null}};if(!l){u();return}n==="raf"?so=requestAnimationFrame(u):typeof n=="number"&&Ss===null&&(u(),Jd=null,Ss=setTimeout(()=>{Jd?u():(Ss=null,so=null)},n))}});hp.startListening({actionCreator:g3,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:i}=r.tooltip;if(!i.active&&i.index==null){var l="0",u=df(r,r.tooltip.settings.shared),c=lm(r,u,"hover",String(l));t.dispatch(sm({active:!0,activeIndex:l,activeCoordinate:c}))}}}});hp.startListening({actionCreator:x3,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:i}=r.tooltip;i.active&&t.dispatch(sm({active:!1,activeIndex:i.index,activeCoordinate:i.coordinate}))}}});function b3(e){e.persist();var{currentTarget:t}=e;return new Proxy(e,{get:(r,n)=>{if(n==="currentTarget")return t;var i=Reflect.get(r,n);return typeof i=="function"?i.bind(r):i}})}var vn=tn("externalEvent"),S3=Wc(),eh=new Map,uc=new Map,N0=new Map;S3.startListening({actionCreator:vn,effect:(e,t)=>{var{handler:r,reactEvent:n}=e.payload;if(r!=null){var i=n.type,l=b3(n);N0.set(i,{handler:r,reactEvent:l});var u=eh.get(i);u!==void 0&&(cancelAnimationFrame(u),eh.delete(i));var c=t.getState(),{throttleDelay:d,throttledEvents:h}=c.eventSettings,m=h,p=m==="all"||(m==null?void 0:m.includes(i)),g=uc.get(i);g!==void 0&&(typeof d!="number"||!p)&&(clearTimeout(g),uc.delete(i));var x=()=>{var O=N0.get(i);try{if(!O)return;var{handler:_,reactEvent:E}=O,T=t.getState(),A={activeCoordinate:LG(T),activeDataKey:iD(T),activeIndex:rl(T),activeLabel:aD(T),activeTooltipIndex:rl(T),isTooltipActive:zG(T)};_&&_(A,E)}finally{eh.delete(i),uc.delete(i),N0.delete(i)}};if(!p){x();return}if(d==="raf"){var S=requestAnimationFrame(x);eh.set(i,S)}else if(typeof d=="number"){if(!uc.has(i)){x();var w=setTimeout(x,d);uc.set(i,w)}}else x()}}});var Tee=G([Jo],e=>e.tooltipItemPayloads),Pee=G([Tee,(e,t)=>t,(e,t,r)=>r],(e,t,r)=>{if(t!=null){var n=e.find(l=>l.settings.graphicalItemId===r);if(n!=null){var{getPosition:i}=n;if(i!=null)return i(t)}}}),w3=tn("touchMove"),j3=Wc(),ws=null,_i=null,LP=null,cc=null;j3.startListening({actionCreator:w3,effect:(e,t)=>{var r=e.payload;if(!(r.touches==null||r.touches.length===0)){cc=b3(r);var n=t.getState(),{throttleDelay:i,throttledEvents:l}=n.eventSettings,u=l==="all"||l.includes("touchmove");ws!==null&&(cancelAnimationFrame(ws),ws=null),_i!==null&&(typeof i!="number"||!u)&&(clearTimeout(_i),_i=null),LP=Array.from(r.touches).map(d=>WS({clientX:d.clientX,clientY:d.clientY,currentTarget:r.currentTarget}));var c=()=>{if(cc!=null){var d=t.getState(),h=df(d,d.tooltip.settings.shared);if(h==="axis"){var m,p=(m=LP)===null||m===void 0?void 0:m[0];if(p==null){ws=null,_i=null;return}var g=ZS(d,p);(g==null?void 0:g.activeIndex)!=null&&t.dispatch(F4({activeIndex:g.activeIndex,activeDataKey:void 0,activeCoordinate:g.activeCoordinate}))}else if(h==="item"){var x,S=cc.touches[0];if(document.elementFromPoint==null||S==null)return;var w=document.elementFromPoint(S.clientX,S.clientY);if(!w||!w.getAttribute)return;var O=w.getAttribute($U),_=(x=w.getAttribute(BU))!==null&&x!==void 0?x:void 0,E=cl(d).find(C=>C.id===_);if(O==null||E==null||_==null)return;var{dataKey:T}=E,A=Pee(d,O,_);t.dispatch(H4({activeDataKey:T,activeIndex:O,activeCoordinate:A,activeGraphicalItemId:_}))}ws=null,_i=null}};if(!u){c();return}i==="raf"?ws=requestAnimationFrame(c):typeof i=="number"&&_i===null&&(c(),cc=null,_i=setTimeout(()=>{cc?c():(_i=null,ws=null)},i))}}});var O3={throttleDelay:"raf",throttledEvents:["mousemove","touchmove","pointermove","scroll","wheel"]},_3=pr({name:"eventSettings",initialState:O3,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=t.payload.throttledEvents)}}}),{setEventSettings:Cee}=_3.actions,Mee=_3.reducer,Ree=QM({brush:jZ,cartesianAxis:aZ,chartData:IV,errorBars:wW,eventSettings:Mee,graphicalItems:IX,layout:SU,legend:Rq,options:CV,polarAxis:aX,polarOptions:Aee,referenceElements:EZ,renderedTicks:KZ,rootProps:Oee,tooltip:GY,zIndex:xV}),Dee=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return Y6({reducer:Ree,preloadedState:t,middleware:n=>{var i;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((i="es6")!==null&&i!==void 0?i:"")}).concat([h3.middleware,m3.middleware,hp.middleware,S3.middleware,j3.middleware])},enhancers:n=>{var i=n;return typeof n=="function"&&(i=n()),i.concat(c2({type:"raf"}))},devTools:{serialize:{replacer:jee},name:"recharts-".concat(r)}})};function kee(e){var{preloadedState:t,children:r,reduxStoreName:n}=e,i=vr(),l=j.useRef(null);if(i)return r;l.current==null&&(l.current=Dee(t,n));var u=Nb;return j.createElement(Qq,{context:u,store:l.current},r)}function Iee(e){var{layout:t,margin:r}=e,n=ut(),i=vr();return j.useEffect(()=>{i||(n(gU(t)),n(yU(r)))},[n,i,t,r]),null}var Lee=j.memo(Iee,Fo);function zee(e){var t=ut();return j.useEffect(()=>{t(_ee(e))},[t,e]),null}var $ee=e=>{var t=ut();return j.useEffect(()=>{t(Cee(e))},[t,e]),null},Bee=j.memo($ee,Fo);function zP(e){var{zIndex:t,isPanorama:r}=e,n=j.useRef(null),i=ut();return j.useLayoutEffect(()=>(n.current&&i(yV({zIndex:t,element:n.current,isPanorama:r})),()=>{i(gV({zIndex:t,isPanorama:r}))}),[i,t,r]),j.createElement("g",{tabIndex:-1,ref:n,className:"recharts-zIndex-layer_".concat(t)})}function $P(e){var{children:t,isPanorama:r}=e,n=ye(oV);if(!n||n.length===0)return t;var i=n.filter(u=>u<0),l=n.filter(u=>u>0);return j.createElement(j.Fragment,null,i.map(u=>j.createElement(zP,{key:u,zIndex:u,isPanorama:r})),t,l.map(u=>j.createElement(zP,{key:u,zIndex:u,isPanorama:r})))}var Uee=["children"];function qee(e,t){if(e==null)return{};var r,n,i=Hee(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function Hee(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function mm(){return mm=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},mm.apply(null,arguments)}var Kee={width:"100%",height:"100%",display:"block"},Fee=j.forwardRef((e,t)=>{var r=Lb(),n=zb(),i=q2();if(!aa(r)||!aa(n))return null;var{children:l,otherAttributes:u,title:c,desc:d}=e,h,m;return u!=null&&(typeof u.tabIndex=="number"?h=u.tabIndex:h=i?0:void 0,typeof u.role=="string"?m=u.role:m=i?"application":void 0),j.createElement(vb,mm({},u,{title:c,desc:d,role:m,tabIndex:h,width:r,height:n,style:Kee,ref:t}),l)}),Yee=e=>{var{children:t}=e,r=ye($m);if(!r)return null;var{width:n,height:i,y:l,x:u}=r;return j.createElement(vb,{width:n,height:i,x:u,y:l},t)},BP=j.forwardRef((e,t)=>{var{children:r}=e,n=qee(e,Uee),i=vr();return i?j.createElement(Yee,null,j.createElement($P,{isPanorama:!0},r)):j.createElement(Fee,mm({ref:t},n),j.createElement($P,{isPanorama:!1},r))});function Gee(){var e=ut(),[t,r]=j.useState(null),n=ye(zU);return j.useEffect(()=>{if(t!=null){var i=t.getBoundingClientRect(),l=i.width/t.offsetWidth;Be(l)&&l!==n&&e(bU(l))}},[t,e,n]),r}function UP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Vee(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?UP(Object(r),!0).forEach(function(n){Qee(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):UP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Qee(e,t,r){return(t=Xee(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Xee(e){var t=Zee(e,"string");return typeof t=="symbol"?t:t+""}function Zee(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Gi(){return Gi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Gi.apply(null,arguments)}var Wee=()=>(FV(),null);function pm(e){if(typeof e=="number")return e;if(typeof e=="string"){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var Jee=j.forwardRef((e,t)=>{var r,n,i=j.useRef(null),[l,u]=j.useState({containerWidth:pm((r=e.style)===null||r===void 0?void 0:r.width),containerHeight:pm((n=e.style)===null||n===void 0?void 0:n.height)}),c=j.useCallback((h,m)=>{u(p=>{var g=Math.round(h),x=Math.round(m);return p.containerWidth===g&&p.containerHeight===x?p:{containerWidth:g,containerHeight:x}})},[]),d=j.useCallback(h=>{if(typeof t=="function"&&t(h),i.current!=null&&(i.current.disconnect(),i.current=null),h!=null&&typeof ResizeObserver<"u"){var{width:m,height:p}=h.getBoundingClientRect();c(m,p);var g=S=>{var w=S[0];if(w!=null){var{width:O,height:_}=w.contentRect;c(O,_)}},x=new ResizeObserver(g);x.observe(h),i.current=x}},[t,c]);return j.useEffect(()=>()=>{var h=i.current;h!=null&&h.disconnect()},[c]),j.createElement(j.Fragment,null,j.createElement(ef,{width:l.containerWidth,height:l.containerHeight}),j.createElement("div",Gi({ref:d},e)))}),ete=j.forwardRef((e,t)=>{var{width:r,height:n}=e,[i,l]=j.useState({containerWidth:pm(r),containerHeight:pm(n)}),u=j.useCallback((d,h)=>{l(m=>{var p=Math.round(d),g=Math.round(h);return m.containerWidth===p&&m.containerHeight===g?m:{containerWidth:p,containerHeight:g}})},[]),c=j.useCallback(d=>{if(typeof t=="function"&&t(d),d!=null){var{width:h,height:m}=d.getBoundingClientRect();u(h,m)}},[t,u]);return j.createElement(j.Fragment,null,j.createElement(ef,{width:i.containerWidth,height:i.containerHeight}),j.createElement("div",Gi({ref:c},e)))}),tte=j.forwardRef((e,t)=>{var{width:r,height:n}=e;return j.createElement(j.Fragment,null,j.createElement(ef,{width:r,height:n}),j.createElement("div",Gi({ref:t},e)))}),rte=j.forwardRef((e,t)=>{var{width:r,height:n}=e;return typeof r=="string"||typeof n=="string"?j.createElement(ete,Gi({},e,{ref:t})):typeof r=="number"&&typeof n=="number"?j.createElement(tte,Gi({},e,{width:r,height:n,ref:t})):j.createElement(j.Fragment,null,j.createElement(ef,{width:r,height:n}),j.createElement("div",Gi({ref:t},e)))});function nte(e){return e?Jee:rte}var ate=j.forwardRef((e,t)=>{var{children:r,className:n,height:i,onClick:l,onContextMenu:u,onDoubleClick:c,onMouseDown:d,onMouseEnter:h,onMouseLeave:m,onMouseMove:p,onMouseUp:g,onTouchEnd:x,onTouchMove:S,onTouchStart:w,style:O,width:_,responsive:E,dispatchTouchEvents:T=!0}=e,A=j.useRef(null),C=ut(),[M,R]=j.useState(null),[z,$]=j.useState(null),D=Gee(),H=Db(),U=(H==null?void 0:H.width)>0?H.width:_,ie=(H==null?void 0:H.height)>0?H.height:i,te=j.useCallback(ce=>{D(ce),typeof t=="function"&&t(ce),R(ce),$(ce),ce!=null&&(A.current=ce)},[D,t,R,$]),ae=j.useCallback(ce=>{C(d3(ce)),C(vn({handler:l,reactEvent:ce}))},[C,l]),q=j.useCallback(ce=>{C(Fx(ce)),C(vn({handler:h,reactEvent:ce}))},[C,h]),V=j.useCallback(ce=>{C(K4()),C(vn({handler:m,reactEvent:ce}))},[C,m]),ne=j.useCallback(ce=>{C(Fx(ce)),C(vn({handler:p,reactEvent:ce}))},[C,p]),se=j.useCallback(()=>{C(g3())},[C]),fe=j.useCallback(()=>{C(x3())},[C]),I=j.useCallback(ce=>{C(y3(ce.key))},[C]),X=j.useCallback(ce=>{C(vn({handler:u,reactEvent:ce}))},[C,u]),le=j.useCallback(ce=>{C(vn({handler:c,reactEvent:ce}))},[C,c]),oe=j.useCallback(ce=>{C(vn({handler:d,reactEvent:ce}))},[C,d]),ge=j.useCallback(ce=>{C(vn({handler:g,reactEvent:ce}))},[C,g]),je=j.useCallback(ce=>{C(vn({handler:w,reactEvent:ce}))},[C,w]),Oe=j.useCallback(ce=>{T&&C(w3(ce)),C(vn({handler:S,reactEvent:ce}))},[C,T,S]),Ce=j.useCallback(ce=>{C(vn({handler:x,reactEvent:ce}))},[C,x]),W=nte(E);return j.createElement(dD.Provider,{value:M},j.createElement(cM.Provider,{value:z},j.createElement(W,{width:U??(O==null?void 0:O.width),height:ie??(O==null?void 0:O.height),className:Qe("recharts-wrapper",n),style:Vee({position:"relative",cursor:"default",width:U,height:ie},O),onClick:ae,onContextMenu:X,onDoubleClick:le,onFocus:se,onBlur:fe,onKeyDown:I,onMouseDown:oe,onMouseEnter:q,onMouseLeave:V,onMouseMove:ne,onMouseUp:ge,onTouchEnd:Ce,onTouchMove:Oe,onTouchStart:je,ref:te},j.createElement(Wee,null),r)))}),ite=["width","height","responsive","children","className","style","compact","title","desc"];function ste(e,t){if(e==null)return{};var r,n,i=lte(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function lte(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var ote=j.forwardRef((e,t)=>{var{width:r,height:n,responsive:i,children:l,className:u,style:c,compact:d,title:h,desc:m}=e,p=ste(e,ite),g=Dn(p);return d?j.createElement(j.Fragment,null,j.createElement(ef,{width:r,height:n}),j.createElement(BP,{otherAttributes:g,title:h,desc:m},l)):j.createElement(ate,{className:u,style:c,width:r,height:n,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},j.createElement(BP,{otherAttributes:g,title:h,desc:m,ref:t},j.createElement(TZ,null,l)))});function Yx(){return Yx=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Yx.apply(null,arguments)}function qP(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function ute(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?qP(Object(r),!0).forEach(function(n){cte(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):qP(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function cte(e,t,r){return(t=fte(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function fte(e){var t=dte(e,"string");return typeof t=="symbol"?t:t+""}function dte(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var hte={top:5,right:5,bottom:5,left:5},mte=ute({accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:hte,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},O3),N3=j.forwardRef(function(t,r){var n,i=sr(t.categoricalChartProps,mte),{chartName:l,defaultTooltipEventType:u,validateTooltipEventTypes:c,tooltipPayloadSearcher:d,categoricalChartProps:h}=t,m={chartName:l,defaultTooltipEventType:u,validateTooltipEventTypes:c,tooltipPayloadSearcher:d,eventEmitter:void 0};return j.createElement(kee,{preloadedState:{options:m},reduxStoreName:(n=h.id)!==null&&n!==void 0?n:l},j.createElement(wZ,{chartData:h.data}),j.createElement(Lee,{layout:i.layout,margin:i.margin}),j.createElement(Bee,{throttleDelay:i.throttleDelay,throttledEvents:i.throttledEvents}),j.createElement(zee,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),j.createElement(ote,Yx({},i,{ref:r})))}),pte=["axis"],vte=j.forwardRef((e,t)=>j.createElement(N3,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:pte,tooltipPayloadSearcher:hD,categoricalChartProps:e,ref:t})),yte=["axis","item"],E3=j.forwardRef((e,t)=>j.createElement(N3,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:yte,tooltipPayloadSearcher:hD,categoricalChartProps:e,ref:t}));const jt={green:"#34d399",red:"#f87171",gray:"#4b5563",cyan:"#22d3ee",gridLine:"#1f2937",labelText:"#9ca3af"},HP=["#22d3ee","#34d399","#facc15","#f87171","#a78bfa","#fb923c","#f472b6","#60a5fa"];function gte(e){return HP[e%HP.length]}function xte({data:e,projectId:t}){const[r,n]=j.useState(!0),[i,l]=j.useState(""),u=e.targets,c=Fe(t?aM(t,i||void 0):b$(i||void 0)),d=i?c.data:void 0,h=j.useMemo(()=>Ote(e.runs??[]),[e.runs]);return v.jsxs("div",{className:"rounded-lg border border-gray-800",children:[v.jsxs("button",{type:"button",onClick:()=>n(m=>!m),className:"flex w-full items-center justify-between px-4 py-3 text-left transition-colors hover:bg-gray-900/30",children:[v.jsx("span",{className:"text-sm font-medium text-gray-300",children:"Analytics"}),v.jsx("span",{className:"text-xs text-gray-500",children:r?"▸ Show":"▾ Hide"})]}),!r&&v.jsxs("div",{className:"space-y-6 border-t border-gray-800 px-4 py-4",children:[v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsx("label",{htmlFor:"baseline-select",className:"text-xs font-medium uppercase tracking-wider text-gray-500",children:"Baseline target"}),v.jsxs("select",{id:"baseline-select",value:i,onChange:m=>l(m.target.value),className:"rounded-md border border-gray-700 bg-gray-950 px-3 py-1.5 text-sm text-gray-100 focus:border-cyan-500 focus:outline-none focus:ring-1 focus:ring-cyan-500",children:[v.jsx("option",{value:"",children:"Select a baseline…"}),u.map(m=>v.jsx("option",{value:m,children:m},m))]}),i&&c.isLoading&&v.jsx("span",{className:"text-xs text-gray-500",children:"Loading…"})]}),i&&d&&v.jsx(bte,{data:d,baseline:i}),e.runs&&e.runs.length>0&&u.length>1&&v.jsx(Ste,{runs:e.runs,targets:u}),i&&d&&v.jsx(wte,{data:d,baseline:i}),v.jsx(jte,{data:e}),h.length>1&&u.length>0&&v.jsx(_te,{data:h,targets:u}),!i&&v.jsx("p",{className:"text-xs text-gray-500",children:"Select a baseline target above to see gain and delta charts."})]})]})}function JS({active:e,payload:t,label:r}){return!e||!(t!=null&&t.length)?null:v.jsxs("div",{className:"rounded-md border border-gray-700 bg-gray-900 px-3 py-2 text-xs shadow-xl",children:[r&&v.jsx("div",{className:"mb-1 font-medium text-gray-300",children:r}),t.map((n,i)=>v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:n.color}}),v.jsxs("span",{className:"text-gray-400",children:[n.name,":"]}),v.jsx("span",{className:"tabular-nums text-gray-200",children:typeof n.value=="number"?n.value.toFixed(3):n.value})]},`${n.name}-${i}`))]})}function Uo({title:e,children:t}){return v.jsxs("div",{className:"space-y-3",children:[v.jsx("h3",{className:"text-sm font-medium text-gray-400",children:e}),t]})}function bte({data:e,baseline:t}){const r=j.useMemo(()=>{const i=[];for(const l of e.cells)l.target!==t&&l.delta!==void 0&&i.push({experiment:l.experiment,target:l.target,g:l.normalized_gain??null,delta:l.delta});return i.sort((l,u)=>Math.abs(u.g??0)-Math.abs(l.g??0)),i},[e.cells,t]);if(r.length===0)return v.jsx(Uo,{title:"Normalized Gain (g)",children:v.jsx("p",{className:"text-xs text-gray-500",children:"No gain data available. Ensure multiple targets exist."})});const n=r.map(i=>({name:`${i.target} · ${i.experiment}`,g:i.g??0,isNull:i.g===null}));return v.jsx(Uo,{title:"Normalized Gain (g)",children:v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900/30 p-3",children:v.jsx(kb,{width:"100%",height:Math.max(200,n.length*32),children:v.jsxs(E3,{data:n,layout:"vertical",margin:{left:120,right:20,top:5,bottom:5},children:[v.jsx(cp,{strokeDasharray:"3 3",stroke:jt.gridLine,horizontal:!1}),v.jsx(fp,{type:"number",tick:{fill:jt.labelText,fontSize:11},axisLine:{stroke:jt.gridLine}}),v.jsx(dp,{type:"category",dataKey:"name",tick:{fill:jt.labelText,fontSize:11},width:120,axisLine:{stroke:jt.gridLine}}),v.jsx(BS,{content:v.jsx(JS,{})}),v.jsx(XS,{dataKey:"g",name:"Normalized Gain",children:n.map(i=>v.jsx(US,{fill:i.isNull?jt.gray:i.g>0?jt.green:i.g<0?jt.red:jt.gray},i.name))})]})})})})}function Ste({runs:e,targets:t}){const{tags:r,grid:n}=j.useMemo(()=>{const i=new Map;for(const c of e)for(const d of c.tags??[]){let h=i.get(d);h||(h=new Map,i.set(d,h));let m=h.get(c.target);m||(m={passed:0,total:0},h.set(c.target,m)),m.passed+=c.passed_count,m.total+=c.eval_count}const l=[...i.keys()].sort(),u=l.map(c=>{const d={tag:c},h=i.get(c);if(!h)return d;for(const m of t){const p=h.get(m);d[m]=p&&p.total>0?p.passed/p.total:-1}return d});return{tags:l,grid:u}},[e,t]);return r.length===0?null:v.jsx(Uo,{title:"Pass Rate by Tag × Target",children:v.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Tag"}),t.map(i=>v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:i},i))]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:n.map(i=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3 font-medium text-gray-200",children:i.tag}),t.map(l=>{const u=i[l];if(u<0)return v.jsx("td",{className:"px-4 py-3 text-center text-gray-600",children:"—"},l);const c=Math.round(u*100),d=u>=.8?"bg-emerald-400/20 text-emerald-400":u>=.5?"bg-yellow-400/20 text-yellow-400":"bg-red-400/20 text-red-400";return v.jsx("td",{className:"px-4 py-3",children:v.jsxs("span",{className:`inline-block rounded px-2 py-0.5 text-xs tabular-nums font-medium ${d}`,children:[c,"%"]})},l)})]},i.tag))})]})})})}function wte({data:e,baseline:t}){const r=j.useMemo(()=>e.cells.filter(n=>n.target!==t&&n.delta!==void 0&&n.delta<0).sort((n,i)=>(n.delta??0)-(i.delta??0)),[e.cells,t]);return r.length===0?null:v.jsx(Uo,{title:"Regressions vs. Baseline",children:v.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Experiment"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Target"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Avg Score"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Delta"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"g"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:r.map(n=>{var i;return v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3 font-medium text-gray-200",children:n.experiment}),v.jsx("td",{className:"px-4 py-3 text-gray-300",children:n.target}),v.jsxs("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:[Math.round(n.avg_score*100),"%"]}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-red-400",children:(i=n.delta)==null?void 0:i.toFixed(3)}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-red-400",children:n.normalized_gain!==void 0&&n.normalized_gain!==null?n.normalized_gain.toFixed(3):"—"})]},`${n.experiment}::${n.target}`)})})]})})})}function jte({data:e}){const t=j.useMemo(()=>{const r=[];for(const i of e.cells)for(const l of i.tests)r.push(l.score);if(r.length===0)return[];const n=Array.from({length:10},(i,l)=>({range:`${l*10}–${(l+1)*10}%`,count:0}));for(const i of r){const l=Math.min(Math.floor(i*10),9);n[l].count++}return n},[e.cells]);return t.length===0?null:v.jsx(Uo,{title:"Score Distribution",children:v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900/30 p-3",children:v.jsx(kb,{width:"100%",height:200,children:v.jsxs(E3,{data:t,margin:{left:10,right:10,top:5,bottom:5},children:[v.jsx(cp,{strokeDasharray:"3 3",stroke:jt.gridLine,vertical:!1}),v.jsx(fp,{dataKey:"range",tick:{fill:jt.labelText,fontSize:11},axisLine:{stroke:jt.gridLine}}),v.jsx(dp,{tick:{fill:jt.labelText,fontSize:11},axisLine:{stroke:jt.gridLine}}),v.jsx(BS,{content:v.jsx(JS,{})}),v.jsx(XS,{dataKey:"count",name:"Tests",fill:jt.cyan,radius:[2,2,0,0]})]})})})})}function Ote(e){if(e.length===0)return[];const t=new Map;for(const n of e){const i=n.started_at.slice(0,10);let l=t.get(i);l||(l=new Map,t.set(i,l));let u=l.get(n.target);u||(u={scoreSum:0,count:0},l.set(n.target,u)),u.scoreSum+=n.avg_score,u.count++}return[...t.keys()].sort().map(n=>{const i={date:n},l=t.get(n);if(!l)return i;for(const[u,c]of l)i[u]=Math.round(c.scoreSum/c.count*1e3)/1e3;return i})}function _te({data:e,targets:t}){return v.jsx(Uo,{title:"Score Trend Over Time",children:v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900/30 p-3",children:v.jsx(kb,{width:"100%",height:250,children:v.jsxs(vte,{data:e,margin:{left:10,right:20,top:5,bottom:5},children:[v.jsx(cp,{strokeDasharray:"3 3",stroke:jt.gridLine}),v.jsx(fp,{dataKey:"date",tick:{fill:jt.labelText,fontSize:11},axisLine:{stroke:jt.gridLine}}),v.jsx(dp,{domain:[0,1],tick:{fill:jt.labelText,fontSize:11},axisLine:{stroke:jt.gridLine}}),v.jsx(BS,{content:v.jsx(JS,{})}),v.jsx(B2,{wrapperStyle:{fontSize:12,color:jt.labelText}}),t.map((r,n)=>v.jsx(s3,{type:"monotone",dataKey:r,stroke:gte(n),strokeWidth:2,dot:{r:3},connectNulls:!0},r))]})})})})}function wn({rate:e}){const t=Math.round(e*100);return v.jsxs("div",{className:"relative h-5 w-20 overflow-hidden rounded-full bg-gray-800",children:[v.jsx("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r from-blue-400 to-blue-600",style:{width:`${t}%`}}),v.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-xs font-semibold tabular-nums text-white",children:[t,"%"]})]})}function A3({data:e,isLoading:t,isError:r,error:n,projectId:i,readOnly:l}){var E,T;const[u,c]=j.useState("aggregated"),[d,h]=j.useState([]),{allTags:m,tagCounts:p}=j.useMemo(()=>{const A=new Map;for(const C of(e==null?void 0:e.runs)??[])for(const M of C.tags??[])A.set(M,(A.get(M)??0)+1);return{allTags:[...A.keys()].sort(),tagCounts:A}},[e==null?void 0:e.runs]),g=j.useMemo(()=>{if(!e||d.length===0)return e;const A=new Set(d),C=(e.runs??[]).filter(D=>(D.tags??[]).some(H=>A.has(H))),M=new Map,R=new Set,z=new Set;for(const D of C){R.add(D.experiment),z.add(D.target);const H=`${D.experiment}::${D.target}`,U=M.get(H)??{experiment:D.experiment,target:D.target,eval_count:0,passed_count:0,score_sum:0,tests:[]};U.eval_count+=D.eval_count,U.passed_count+=D.passed_count,U.score_sum+=D.avg_score*D.eval_count;for(const ie of D.tests)U.tests.push(ie);M.set(H,U)}const $=[...M.values()].map(D=>{const H=new Map;for(const U of D.tests)H.set(U.test_id,U);return{experiment:D.experiment,target:D.target,eval_count:D.eval_count,passed_count:D.passed_count,pass_rate:D.eval_count>0?D.passed_count/D.eval_count:0,avg_score:D.eval_count>0?D.score_sum/D.eval_count:0,tests:[...H.values()].slice(-100)}});return{...e,experiments:[...R].sort(),targets:[...z].sort(),cells:$,runs:C}},[e,d]),x=A=>{h(C=>C.includes(A)?C.filter(M=>M!==A):[...C,A])},S=()=>h([]),w=((E=g==null?void 0:g.runs)==null?void 0:E.length)??0,O=e&&e.cells.length>0,_=d.length>0&&g&&(((T=g.runs)==null?void 0:T.length)??0)===0;return v.jsxs("div",{className:"space-y-4",children:[v.jsx(Ete,{mode:u,onModeChange:c,runsCount:w}),t&&v.jsx(qte,{}),!t&&r&&n&&v.jsx(Bte,{message:`Failed to load comparison data: ${n.message}`}),!t&&!r&&!O&&v.jsx(Ute,{}),!t&&!r&&O&&v.jsxs(v.Fragment,{children:[m.length>0&&v.jsx(Nte,{allTags:m,tagCounts:p,selected:d,onToggle:x,onClear:S}),_?v.jsx(mp,{headline:`No runs match ${d.map(A=>`\`${A}\``).join(" + ")}`,body:"Clear the filter or pick a different tag combination.",action:{label:"Clear filter",onClick:S}}):g&&v.jsxs(v.Fragment,{children:[u==="aggregated"&&v.jsx(Tte,{data:g,projectId:i}),u==="per-run"&&v.jsx(Dte,{data:g,projectId:i,readOnly:l??!1})]})]})]})}function Nte({allTags:e,tagCounts:t,selected:r,onToggle:n,onClear:i}){const l=new Set(r),u=r.length>0;return v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900/40 px-4 py-3",children:[v.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[v.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-gray-500",children:"Filter by tag"}),e.map(c=>{const d=l.has(c),h=t.get(c)??0;return v.jsxs("button",{type:"button",onClick:()=>n(c),"aria-pressed":d,className:`inline-flex items-center gap-1.5 rounded-md border px-2 py-0.5 text-xs font-medium transition-colors ${d?"border-cyan-900/60 bg-cyan-950/30 text-cyan-300 hover:border-cyan-800/80":"border-gray-700 text-gray-400 hover:border-gray-600 hover:text-gray-200"}`,children:[v.jsx("span",{children:c}),v.jsx("span",{className:`rounded px-1 text-[0.65rem] tabular-nums ${d?"bg-cyan-900/50 text-cyan-200":"bg-gray-800 text-gray-500"}`,children:h})]},c)}),u&&v.jsx("button",{type:"button",onClick:i,className:"ml-1 text-xs text-gray-500 underline-offset-2 transition-colors hover:text-gray-300 hover:underline",children:"Clear"})]}),v.jsxs("p",{className:"mt-2 text-xs text-gray-500",children:["Showing runs with ",v.jsx("span",{className:"text-gray-400",children:"any"})," selected tag."]})]})}function Ete({mode:e,onModeChange:t,runsCount:r}){return v.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[v.jsxs("div",{children:[v.jsx("h2",{className:"text-xl font-semibold text-white",children:"Analyze runs"}),v.jsx("p",{className:"mt-1 text-sm text-gray-400",children:"Study one experiment against another, or pit individual runs head-to-head."})]}),v.jsx(Ate,{mode:e,onChange:t,runsCount:r})]})}function Ate({mode:e,onChange:t,runsCount:r}){const n=r===0;return v.jsxs("div",{role:"tablist","aria-label":"Comparison view mode",className:"inline-flex items-center rounded-lg border border-gray-800 bg-gray-900/50 p-1",children:[v.jsx(KP,{active:e==="aggregated",onClick:()=>t("aggregated"),children:"Aggregated"}),v.jsxs(KP,{active:e==="per-run",onClick:()=>t("per-run"),disabled:n,title:n?"No runs available":void 0,children:["Per run",r>0&&v.jsx("span",{className:"ml-1.5 rounded bg-gray-800 px-1.5 py-0.5 text-xs tabular-nums text-gray-400",children:r})]})]})}function KP({active:e,onClick:t,disabled:r,title:n,children:i}){return v.jsx("button",{type:"button",role:"tab","aria-selected":e,onClick:t,disabled:r,title:n,className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${e?"bg-gray-800 text-cyan-400 shadow-sm":"text-gray-400 hover:text-gray-200 disabled:text-gray-600 disabled:hover:text-gray-600"}`,children:i})}function Tte({data:e,projectId:t}){const{experiments:r,targets:n,cells:i}=e,l=j.useMemo(()=>{const u=new Map;for(const c of i)u.set(`${c.experiment}::${c.target}`,c);return u},[i]);return r.length<=1&&n.length<=1?v.jsx(mp,{headline:"Not enough variation to compare",body:`The aggregated matrix requires at least 2 experiments or 2 targets. Currently ${r.length} experiment(s) and ${n.length} target(s).`}):v.jsxs("div",{className:"space-y-3",children:[v.jsx($te,{}),v.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:v.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Target ↓ / Experiment →"})}),r.map(u=>v.jsx("th",{className:"px-4 py-3 font-medium text-gray-300",children:u},u))]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:n.map(u=>v.jsx(Pte,{target:u,experiments:r,cellMap:l},u))})]})}),v.jsx(xte,{data:e,projectId:t})]})}function Pte({target:e,experiments:t,cellMap:r}){return v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3 font-medium text-gray-200",children:e}),t.map(n=>{const i=r.get(`${n}::${e}`);return v.jsx("td",{className:"px-4 py-3",children:i?v.jsx(Cte,{cell:i}):v.jsx(Mte,{})},n)})]})}function Cte({cell:e}){const[t,r]=j.useState(!1),n=Math.round(e.avg_score*100);return v.jsxs("div",{className:"space-y-2",children:[v.jsxs("button",{type:"button",className:"group flex w-full flex-col gap-1 rounded-md border border-gray-800 bg-gray-900/40 px-3 py-2 text-left transition-colors hover:border-gray-700 hover:bg-gray-900/70",onClick:()=>r(i=>!i),"aria-expanded":t,children:[v.jsx(wn,{rate:e.pass_rate}),v.jsxs("div",{className:"flex items-center gap-2 text-xs tabular-nums text-gray-500",children:[v.jsxs("span",{children:[v.jsx("span",{className:"text-emerald-400",children:e.passed_count}),v.jsx("span",{className:"text-gray-600",children:" / "}),v.jsx("span",{children:e.eval_count})]}),v.jsx("span",{className:"text-gray-700",children:"·"}),v.jsxs("span",{children:["avg ",n,"%"]})]})]}),t&&v.jsx(Rte,{tests:e.tests})]})}function Mte(){return v.jsx("div",{className:"text-center text-gray-600",children:"—"})}function Rte({tests:e}){return v.jsxs("div",{className:"rounded-md border border-gray-800 bg-gray-950/60 px-3 py-2",children:[v.jsx("div",{className:"mb-1.5 text-xs font-medium uppercase tracking-wider text-gray-500",children:"Test cases"}),v.jsx("ul",{className:"space-y-1",children:e.map(t=>v.jsxs("li",{className:"flex items-center gap-2 text-xs",children:[v.jsx("span",{"aria-hidden":!0,className:`h-1.5 w-1.5 rounded-full ${t.passed?"bg-emerald-400":"bg-red-400"}`}),v.jsx("span",{className:"flex-1 truncate text-gray-300",title:t.test_id,children:t.test_id}),v.jsxs("span",{className:`tabular-nums ${t.passed?"text-emerald-400":"text-red-400"}`,children:[Math.round(t.score*100),"%"]})]},t.test_id))})]})}function Dte({data:e,projectId:t,readOnly:r}){const n=e.runs??[],[i,l]=j.useState(new Set),[u,c]=j.useState(!1),[d,h]=j.useState(null),m=x=>{l(S=>{const w=new Set(S);return w.has(x)?w.delete(x):w.add(x),w})},p=()=>l(new Set),g=j.useMemo(()=>n.filter(x=>i.has(x.run_id)),[n,i]);return n.length===0?v.jsx(mp,{headline:"No runs yet",body:"Run an evaluation to populate the per-run view."}):u&&g.length>=2?v.jsx(Lte,{runs:g,onBack:()=>c(!1)}):v.jsxs("div",{className:"space-y-3",children:[v.jsx("div",{className:"flex items-center justify-between text-sm text-gray-400",children:v.jsxs("span",{children:[v.jsx("span",{className:"font-medium text-gray-300",children:n.length})," run",n.length===1?"":"s"," — select two or more to compare side-by-side"]})}),v.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"w-10 px-3 py-3","aria-label":"Select"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Timestamp"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Tags"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Experiment"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Target"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Tests"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Pass rate"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Avg"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:n.map(x=>v.jsx(kte,{run:x,checked:i.has(x.run_id),onToggle:()=>m(x.run_id),editing:d===x.run_id,onStartEdit:()=>h(x.run_id),onEndEdit:()=>h(null),projectId:t,readOnly:r},x.run_id))})]})}),i.size>0&&v.jsxs("div",{role:"toolbar","aria-label":"Selection actions",className:"sticky bottom-4 z-10 flex items-center justify-between gap-3 rounded-lg border border-cyan-900/50 bg-gray-900/95 px-4 py-3 shadow-xl backdrop-blur",children:[v.jsxs("div",{className:"text-sm text-gray-300",children:[v.jsx("span",{className:"font-semibold tabular-nums text-cyan-400",children:i.size})," ","selected"]}),v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("button",{type:"button",onClick:p,className:"rounded-md px-3 py-1.5 text-sm text-gray-400 transition-colors hover:text-gray-200",children:"Clear"}),v.jsxs("button",{type:"button",disabled:i.size<2,onClick:()=>c(!0),className:"inline-flex items-center gap-1.5 rounded-md bg-cyan-500 px-3 py-1.5 text-sm font-medium text-gray-950 transition-colors hover:bg-cyan-400 disabled:cursor-not-allowed disabled:bg-gray-700 disabled:text-gray-500",children:["Compare ",i.size,v.jsx("span",{"aria-hidden":!0,children:"→"})]})]})]})]})}function kte({run:e,checked:t,onToggle:r,editing:n,onStartEdit:i,onEndEdit:l,projectId:u,readOnly:c}){const d=Math.round(e.avg_score*100),h=!c&&e.source!=="remote",m=j.useRef(null),p=e.tags??[],g=p[0]??e.run_id,x=Hte(e.run_id),S=j.useRef(n);return j.useEffect(()=>{var w;S.current&&!n&&((w=m.current)==null||w.focus()),S.current=n},[n]),v.jsxs(v.Fragment,{children:[v.jsxs("tr",{className:`transition-colors ${t?"bg-cyan-950/20 hover:bg-cyan-950/30":"hover:bg-gray-900/30"}`,children:[v.jsx("td",{className:"px-3 py-3 align-middle",children:v.jsx("input",{type:"checkbox",className:"h-4 w-4 cursor-pointer rounded border-gray-700 bg-gray-900 text-cyan-500 accent-cyan-500 focus:ring-cyan-500",checked:t,onChange:r,"aria-label":`Select run ${g}`})}),v.jsxs("td",{className:"px-4 py-3 align-middle",title:e.run_id,children:[v.jsx("div",{className:"font-medium text-gray-200 tabular-nums",children:T3(e.started_at)}),x&&v.jsx("div",{className:"text-xs text-gray-500",children:x})]}),v.jsx("td",{className:"px-4 py-3 align-middle",children:h?v.jsx("button",{ref:m,type:"button",onClick:w=>{w.stopPropagation(),i()},className:p.length>0?"inline-flex flex-wrap items-center gap-1 rounded-md px-1 py-0.5 transition-colors hover:bg-gray-800/60":"rounded-md border border-dashed border-gray-700 px-2 py-0.5 text-xs text-gray-500 transition-colors hover:border-cyan-800 hover:text-cyan-400","aria-label":p.length>0?"Edit tags":"Add tags",children:p.length>0?p.map(w=>v.jsx("span",{className:"rounded-md border border-cyan-900/60 bg-cyan-950/30 px-2 py-0.5 text-xs font-medium text-cyan-300",children:w},w)):v.jsx(v.Fragment,{children:"+ tags"})}):p.length>0?v.jsx("div",{className:"inline-flex flex-wrap items-center gap-1",children:p.map(w=>v.jsx("span",{className:"rounded-md border border-cyan-900/60 bg-cyan-950/30 px-2 py-0.5 text-xs font-medium text-cyan-300",children:w},w))}):v.jsx("span",{className:"text-gray-600",children:"—"})}),v.jsx("td",{className:"px-4 py-3 align-middle text-gray-300",children:e.experiment}),v.jsx("td",{className:"px-4 py-3 align-middle text-gray-300",children:e.target}),v.jsx("td",{className:"px-4 py-3 align-middle text-right tabular-nums text-gray-400",children:e.eval_count}),v.jsx("td",{className:"px-4 py-3 align-middle",children:v.jsx(wn,{rate:e.pass_rate})}),v.jsxs("td",{className:"px-4 py-3 align-middle text-right tabular-nums text-gray-400",children:[d,"%"]})]}),n&&v.jsx("tr",{className:"bg-gray-950/80",children:v.jsx("td",{colSpan:8,className:"px-4 py-3",children:v.jsx(Ite,{runId:e.run_id,currentTags:p,projectId:u,onClose:l})})})]})}function Ite({runId:e,currentTags:t,projectId:r,onClose:n}){const[i,l]=j.useState(t),[u,c]=j.useState(""),[d,h]=j.useState(null),m=Fa(),p=j.useRef(null);j.useEffect(()=>{var E;(E=p.current)==null||E.focus()},[]);const g=H0({mutationFn:()=>U$(e,i,r),onSuccess:()=>{m.invalidateQueries({queryKey:["compare"]}),m.invalidateQueries({queryKey:["runs"]}),r&&(m.invalidateQueries({queryKey:["projects",r,"compare"]}),m.invalidateQueries({queryKey:["projects",r,"runs"]})),n()},onError:E=>h(E.message)}),x=H0({mutationFn:()=>q$(e,r),onSuccess:()=>{m.invalidateQueries({queryKey:["compare"]}),m.invalidateQueries({queryKey:["runs"]}),r&&(m.invalidateQueries({queryKey:["projects",r,"compare"]}),m.invalidateQueries({queryKey:["projects",r,"runs"]})),n()},onError:E=>h(E.message)}),S=g.isPending||x.isPending,w=i.length!==t.length||i.some((E,T)=>E!==t[T]),O=()=>{const E=u.trim();if(E!==""){if(i.includes(E)){c("");return}l([...i,E]),c(""),h(null)}},_=E=>{l(i.filter(T=>T!==E))};return v.jsxs("div",{className:"space-y-2 rounded-md border border-gray-800 bg-gray-900/60 p-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-gray-400",children:"Tag run"}),v.jsx("span",{className:"text-xs text-gray-500",children:"Multi-valued. Enter or comma adds; Backspace removes the last chip."})]}),v.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-md border border-gray-700 bg-gray-950 px-2 py-1.5 focus-within:border-cyan-500 focus-within:ring-1 focus-within:ring-cyan-500",children:[i.map(E=>v.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-cyan-900/60 bg-cyan-950/30 px-2 py-0.5 text-xs font-medium text-cyan-300",children:[E,v.jsx("button",{type:"button",onClick:()=>_(E),disabled:S,className:"text-cyan-500 transition-colors hover:text-cyan-200 disabled:opacity-50","aria-label":`Remove tag ${E}`,children:"×"})]},E)),v.jsx("input",{ref:p,type:"text",className:"flex-1 min-w-[140px] bg-transparent text-sm text-gray-100 placeholder:text-gray-600 focus:outline-none disabled:opacity-50",placeholder:i.length===0?"e.g. baseline, v2-prompt, slow":"Add tag…",value:u,onChange:E=>{h(null),c(E.target.value)},maxLength:60,disabled:S,onKeyDown:E=>{E.key==="Enter"||E.key===","?(E.preventDefault(),O()):E.key==="Backspace"&&u===""&&i.length>0?(E.preventDefault(),l(i.slice(0,-1))):E.key==="Escape"&&n()},onBlur:O})]}),v.jsxs("div",{className:"flex items-center justify-end gap-2",children:[v.jsx("button",{type:"button",onClick:n,disabled:S,className:"rounded-md px-3 py-1.5 text-sm text-gray-400 transition-colors hover:text-gray-200 disabled:opacity-50",children:"Cancel"}),t.length>0&&v.jsx("button",{type:"button",onClick:()=>{S||x.mutate()},disabled:S,className:"rounded-md border border-red-900/60 px-3 py-1.5 text-sm text-red-400 transition-colors hover:border-red-800 hover:bg-red-950/30 hover:text-red-300 disabled:opacity-50",children:"Clear all"}),v.jsx("button",{type:"button",disabled:!w||S,onClick:()=>{S||!w||g.mutate()},className:"rounded-md bg-cyan-500 px-3 py-1.5 text-sm font-medium text-gray-950 transition-colors hover:bg-cyan-400 disabled:cursor-not-allowed disabled:bg-gray-700 disabled:text-gray-500",children:g.isPending?"Saving…":"Save"})]}),d&&v.jsx("div",{className:"rounded-md border border-red-900/60 bg-red-950/30 px-3 py-1.5 text-xs text-red-400",children:d})]})}function Lte({runs:e,onBack:t}){const r=j.useMemo(()=>{const i=new Set,l=[];for(const u of e)for(const c of u.tests)i.has(c.test_id)||(i.add(c.test_id),l.push(c.test_id));return l},[e]),n=j.useMemo(()=>e.map(i=>{const l=new Map;for(const u of i.tests)l.set(u.test_id,u);return l}),[e]);return v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("button",{type:"button",onClick:t,className:"inline-flex items-center gap-1 text-sm text-cyan-400 transition-colors hover:text-cyan-300",children:[v.jsx("span",{"aria-hidden":!0,children:"←"})," Back to runs"]}),v.jsxs("span",{className:"text-sm text-gray-500",children:[e.length," runs · ",r.length," tests"]})]}),v.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsxs("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:[v.jsxs("tr",{children:[v.jsx("th",{className:"sticky left-0 z-10 bg-gray-900/80 px-4 py-3 font-medium text-gray-400 backdrop-blur",children:"Test case"}),e.map(i=>v.jsx("th",{className:"px-4 py-3 align-bottom",children:v.jsx(zte,{run:i})},i.run_id))]}),v.jsxs("tr",{className:"border-t border-gray-800/50 bg-gray-900/30",children:[v.jsx("th",{className:"sticky left-0 z-10 bg-gray-900/80 px-4 py-2 text-xs font-medium uppercase tracking-wider text-gray-500 backdrop-blur",children:"Pass rate"}),e.map(i=>v.jsx("th",{className:"px-4 py-2",children:v.jsx(wn,{rate:i.pass_rate})},i.run_id))]})]}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:r.map(i=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"sticky left-0 z-10 bg-gray-950/70 px-4 py-3 font-medium text-gray-200 backdrop-blur",children:i}),n.map((l,u)=>{const c=l.get(i),d=e[u].run_id;return c?v.jsx("td",{className:"px-4 py-3",children:v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("span",{"aria-hidden":!0,className:`h-1.5 w-1.5 rounded-full ${c.passed?"bg-emerald-400":"bg-red-400"}`}),v.jsxs("span",{className:`tabular-nums ${c.passed?"text-emerald-400":"text-red-400"}`,children:[Math.round(c.score*100),"%"]})]})},d):v.jsx("td",{className:"px-4 py-3 text-center text-gray-600",children:"—"},d)})]},i))})]})})]})}function zte({run:e}){const t=e.tags??[];return v.jsxs("div",{className:"min-w-[140px] space-y-1",children:[v.jsx("div",{className:"text-sm font-medium text-gray-200 tabular-nums",title:e.run_id,children:T3(e.started_at)}),t.length>0&&v.jsx("div",{className:"flex flex-wrap gap-1",children:t.map(r=>v.jsx("span",{className:"rounded-md border border-cyan-900/60 bg-cyan-950/30 px-1.5 py-0.5 text-[0.7rem] font-medium text-cyan-300",children:r},r))}),v.jsxs("div",{className:"text-xs text-gray-500",children:[e.experiment," · ",e.target]})]})}function $te(){return v.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500",role:"note",children:[v.jsx(th,{className:"bg-emerald-400",label:"80%+"}),v.jsx(th,{className:"bg-yellow-400",label:"50–80%"}),v.jsx(th,{className:"bg-red-400",label:"< 50%"}),v.jsx(th,{className:"bg-gray-700",label:"no data"})]})}function th({className:e,label:t}){return v.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[v.jsx("span",{className:`h-2 w-2 rounded-full ${e}`,"aria-hidden":!0}),v.jsx("span",{children:t})]})}function Bte({message:e}){return v.jsx("div",{className:"rounded-lg border border-red-900/60 bg-red-950/30 p-4 text-sm text-red-400",children:e})}function Ute(){return v.jsx(mp,{headline:"No comparison data yet",body:"Run evaluations with different experiment and target combinations to populate this view."})}function mp({headline:e,body:t,action:r}){return v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:[v.jsx("p",{className:"text-lg text-gray-300",children:e}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:t}),r&&v.jsx("button",{type:"button",onClick:r.onClick,className:"mt-4 inline-flex items-center rounded-md bg-cyan-500 px-3 py-1.5 text-sm font-medium text-gray-950 transition-colors hover:bg-cyan-400",children:r.label})]})}function qte(){return v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("div",{className:"animate-pulse",children:[v.jsx("div",{className:"border-b border-gray-800 bg-gray-900/50 px-4 py-3",children:v.jsx("div",{className:"h-4 w-48 rounded bg-gray-800"})}),["sk-1","sk-2","sk-3","sk-4","sk-5"].map(e=>v.jsxs("div",{className:"flex gap-4 border-b border-gray-800/50 px-4 py-3",children:[v.jsx("div",{className:"h-4 w-32 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-12 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-12 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-48 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-24 rounded bg-gray-800"})]},e))]})})}function T3(e){try{const t=new Date(e);if(Number.isNaN(t.getTime()))return e;const r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0"),l=String(t.getHours()).padStart(2,"0"),u=String(t.getMinutes()).padStart(2,"0");return`${r}-${n}-${i} ${l}:${u}`}catch{return e}}function Hte(e){const t=e.split("::");return t.length<2?null:t.slice(0,-1).join(" · ")}function P3({projectId:e}){const{data:t,isLoading:r}=e?Fe(db(e)):JC();if(r)return v.jsx(Kte,{});const n=(t==null?void 0:t.experiments)??[];return n.length===0?v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No experiments found"}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"Experiments will appear here once evaluations are run with experiment labels."})]}):v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Experiment"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Runs"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Targets"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Evals"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Pass Rate"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Last Run"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:n.map(i=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3",children:e?v.jsx(Se,{to:"/projects/$projectId/experiments/$experimentName",params:{projectId:e,experimentName:i.name},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:i.name}):v.jsx(Se,{to:"/experiments/$experimentName",params:{experimentName:i.name},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:i.name})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:i.run_count}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:i.target_count}),v.jsxs("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:[v.jsx("span",{className:"text-emerald-400",children:i.passed_count}),v.jsx("span",{className:"text-gray-600",children:" / "}),i.eval_count]}),v.jsx("td",{className:"px-4 py-3",children:v.jsx(wn,{rate:i.pass_rate})}),v.jsx("td",{className:"px-4 py-3 text-gray-400",title:FP(i.last_run).full,children:FP(i.last_run).date})]},i.name))})]})})}function FP(e){if(!e)return{date:"N/A",full:"N/A"};try{const t=new Date(e);if(Number.isNaN(t.getTime()))return{date:"N/A",full:"N/A"};const r=t.toLocaleString(),n=Date.now()-t.getTime(),i=Math.floor(n/6e4),l=Math.floor(n/36e5);let u;return i<1?u="just now":i<60?u=`${i} min ago`:l<24?u=`${l} hour${l===1?"":"s"} ago`:u=t.toLocaleDateString(),{date:u,full:r}}catch{return{date:"N/A",full:"N/A"}}}function Kte(){return v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("div",{className:"animate-pulse",children:[v.jsx("div",{className:"border-b border-gray-800 bg-gray-900/50 px-4 py-3",children:v.jsx("div",{className:"h-4 w-48 rounded bg-gray-800"})}),["sk-1","sk-2","sk-3","sk-4","sk-5"].map(e=>v.jsxs("div",{className:"flex gap-4 border-b border-gray-800/50 px-4 py-3",children:[v.jsx("div",{className:"h-4 w-32 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-12 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-12 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-48 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-24 rounded bg-gray-800"})]},e))]})})}function Fte(e){if(!e)return"No runs";const t=new Date(e);if(Number.isNaN(t.getTime()))return"N/A";const r=Date.now()-t.getTime(),n=Math.floor(r/6e4);if(n<1)return"Just now";if(n<60)return`${n}m ago`;const i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Yte({project:e}){const t=Math.round(e.pass_rate*100);return v.jsxs(Se,{to:"/projects/$projectId",params:{projectId:e.id},className:"group block rounded-lg border border-gray-800 bg-gray-900/50 p-5 transition-colors hover:border-cyan-800 hover:bg-gray-900",children:[v.jsx("div",{className:"flex items-start justify-between",children:v.jsxs("div",{className:"min-w-0 flex-1",children:[v.jsx("h3",{className:"truncate text-lg font-semibold text-white group-hover:text-cyan-400",children:e.name}),v.jsx("p",{className:"mt-1 truncate text-xs text-gray-500",children:e.path})]})}),v.jsxs("div",{className:"mt-4 grid grid-cols-3 gap-3",children:[v.jsxs("div",{children:[v.jsx("p",{className:"text-xs text-gray-500",children:"Runs"}),v.jsx("p",{className:"text-lg font-semibold text-white",children:e.run_count})]}),v.jsxs("div",{children:[v.jsx("p",{className:"text-xs text-gray-500",children:"Pass Rate"}),v.jsx("p",{className:`text-lg font-semibold ${e.run_count===0?"text-gray-500":t>=80?"text-emerald-400":t>=50?"text-yellow-400":"text-red-400"}`,children:e.run_count>0?`${t}%`:"--"})]}),v.jsxs("div",{children:[v.jsx("p",{className:"text-xs text-gray-500",children:"Last Run"}),v.jsx("p",{className:"text-sm text-gray-300",children:Fte(e.last_run)})]})]})]})}function Gte(e,t,r){return t?e:e1(e,r)}function e1(e,t){return e||String(t??_c)}function Vte({suiteFilter:e,testIds:t,target:r,thresholdInput:n,studioThreshold:i,workers:l,dryRun:u}){const c={};e.trim()&&(c.suite_filter=e.trim()),t.length>0&&(c.test_ids=t),r&&(c.target=r);const d=e1(n,i);return d&&(c.threshold=Number.parseFloat(d)),l&&(c.workers=Number.parseInt(l,10)),u&&(c.dry_run=!0),c}function hl({open:e,onClose:t,projectId:r,prefill:n}){const i=Fa(),l=il(),[u,c]=j.useState((n==null?void 0:n.suiteFilter)??""),[d,h]=j.useState(""),[m,p]=j.useState((n==null?void 0:n.testIds)??[]),[g,x]=j.useState((n==null?void 0:n.target)??""),[S,w]=j.useState(""),[O,_]=j.useState(!1),[E,T]=j.useState(""),[A,C]=j.useState(!1),[M,R]=j.useState(!1),[z,$]=j.useState(null),[D,H]=j.useState(null),[U,ie]=j.useState(!1),[te,ae]=j.useState(null),{data:q}=F$(r),{data:V}=G$(r),{data:ne}=hb(z,r),{data:se}=bt(r),fe=j.useMemo(()=>(q==null?void 0:q.eval_files)??[],[q]),I=j.useMemo(()=>(V==null?void 0:V.targets)??[],[V]),X=j.useMemo(()=>e1(S,se==null?void 0:se.threshold),[se==null?void 0:se.threshold,S]),le=j.useMemo(()=>Gte(S,O,se==null?void 0:se.threshold),[se==null?void 0:se.threshold,S,O]);j.useEffect(()=>{e&&(c((n==null?void 0:n.suiteFilter)??""),p((n==null?void 0:n.testIds)??[]),x((n==null?void 0:n.target)??""),h(""),w(""),_(!1),T(""),C(!1),R(!1),$(null),H(null),ie(!1),ae(null))},[e,n]),j.useEffect(()=>{((ne==null?void 0:ne.status)==="finished"||(ne==null?void 0:ne.status)==="failed")&&(i.invalidateQueries({queryKey:["runs"]}),i.invalidateQueries({queryKey:["projects"]}))},[ne==null?void 0:ne.status,i]);const oe=j.useCallback(()=>Vte({suiteFilter:u,testIds:m,target:g,thresholdInput:S,studioThreshold:se==null?void 0:se.threshold,workers:E,dryRun:A}),[A,se==null?void 0:se.threshold,u,g,m,S,E]);j.useEffect(()=>{const W=oe();if(!W.suite_filter&&(!W.test_ids||W.test_ids.length===0)){ae(null);return}Z$(W,r).then(ce=>ae(ce.command)).catch(()=>ae(null))},[oe,r]);function ge(){const W=d.trim();W&&!m.includes(W)&&p([...m,W]),h("")}function je(W){p(m.filter(ce=>ce!==W))}async function Oe(){H(null),ie(!0);try{const W=oe(),ce=await sM(W,r);$(ce.id)}catch(W){H(W.message)}finally{ie(!1)}}if(!e)return null;if(z&&ne){let W=function(){t(),l({to:f$(r)})};return v.jsx(YP,{onClose:t,title:"Eval Run",children:v.jsx(Qte,{status:ne,onClose:t,onRunInBackground:W,runId:z})})}const Ce=!!(u.trim()||m.length>0);return v.jsx(YP,{onClose:t,title:"Run Eval",children:v.jsxs("div",{className:"space-y-4",children:[v.jsxs("div",{children:[v.jsx("label",{htmlFor:"suite-filter",className:"mb-1 block text-sm font-medium text-gray-300",children:"Suite Filter"}),v.jsx("input",{id:"suite-filter",type:"text",value:u,onChange:W=>c(W.target.value),placeholder:"evals/**/*.eval.yaml",className:"w-full rounded-md border border-gray-700 bg-gray-800 px-3 py-2 text-sm text-white placeholder-gray-500 focus:border-cyan-600 focus:outline-none"}),fe.length>0&&!u&&v.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[fe.slice(0,5).map(W=>v.jsx("button",{type:"button",onClick:()=>c(ce=>ce?`${ce}, ${W.relative_path}`:W.relative_path),className:"rounded bg-gray-800 px-2 py-0.5 text-xs text-gray-400 hover:bg-gray-700 hover:text-gray-200",children:W.relative_path},W.relative_path)),fe.length>5&&v.jsxs("span",{className:"px-1 text-xs text-gray-500",children:["+",fe.length-5," more"]})]})]}),v.jsxs("div",{children:[v.jsx("label",{htmlFor:"test-id-input",className:"mb-1 block text-sm font-medium text-gray-300",children:"Test ID Filter"}),v.jsxs("div",{className:"flex gap-2",children:[v.jsx("input",{id:"test-id-input",type:"text",value:d,onChange:W=>h(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),ge())},placeholder:"auth-*, retrieval-basic",className:"flex-1 rounded-md border border-gray-700 bg-gray-800 px-3 py-2 text-sm text-white placeholder-gray-500 focus:border-cyan-600 focus:outline-none"}),v.jsx("button",{type:"button",onClick:ge,disabled:!d.trim(),className:"rounded-md bg-gray-700 px-3 py-2 text-sm text-white hover:bg-gray-600 disabled:opacity-50",children:"Add"})]}),m.length>0&&v.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1",children:m.map(W=>v.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-cyan-900/40 px-2.5 py-0.5 text-xs text-cyan-300",children:[W,v.jsx("button",{type:"button",onClick:()=>je(W),className:"text-cyan-400 hover:text-white",children:"×"})]},W))})]}),v.jsxs("div",{children:[v.jsx("label",{htmlFor:"target-override",className:"mb-1 block text-sm font-medium text-gray-300",children:"Target Override"}),v.jsxs("select",{id:"target-override",value:g,onChange:W=>x(W.target.value),className:"w-full rounded-md border border-gray-700 bg-gray-800 px-3 py-2 text-sm text-white focus:border-cyan-600 focus:outline-none",children:[v.jsx("option",{value:"",children:"Use eval's configured target"}),I.map(W=>v.jsx("option",{value:W,children:W},W))]})]}),v.jsxs("div",{children:[v.jsxs("button",{type:"button",onClick:()=>R(!M),className:"text-sm text-gray-400 hover:text-gray-200",children:[M?"▾":"▸"," Advanced Options"]}),M&&v.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-3",children:[v.jsxs("div",{children:[v.jsx("label",{htmlFor:"threshold-input",className:"mb-1 block text-xs text-gray-400",children:"Threshold (0–1)"}),v.jsx("input",{id:"threshold-input",type:"number",value:le,onChange:W=>{_(!0),w(W.target.value)},min:"0",max:"1",step:"0.1",placeholder:X,className:"w-full rounded-md border border-gray-700 bg-gray-800 px-3 py-1.5 text-sm text-white placeholder-gray-500 focus:border-cyan-600 focus:outline-none"})]}),v.jsxs("div",{children:[v.jsx("label",{htmlFor:"workers-input",className:"mb-1 block text-xs text-gray-400",children:"Workers"}),v.jsx("input",{id:"workers-input",type:"number",value:E,onChange:W=>T(W.target.value),min:"1",max:"50",placeholder:"3",className:"w-full rounded-md border border-gray-700 bg-gray-800 px-3 py-1.5 text-sm text-white placeholder-gray-500 focus:border-cyan-600 focus:outline-none"})]}),v.jsx("div",{className:"col-span-2",children:v.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-400",children:[v.jsx("input",{type:"checkbox",checked:A,onChange:W=>C(W.target.checked),className:"rounded border-gray-600 bg-gray-800"}),"Dry run (mock provider responses)"]})})]})]}),te&&v.jsxs("div",{className:"rounded-md border border-gray-700 bg-gray-950 p-3",children:[v.jsx("div",{className:"mb-1 text-xs text-gray-500",children:"CLI Preview"}),v.jsx("code",{className:"block break-all text-xs text-cyan-300",children:te})]}),D&&v.jsx("div",{className:"rounded-md border border-red-900/50 bg-red-950/20 p-2 text-sm text-red-400",children:D}),v.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[v.jsx("button",{type:"button",onClick:t,className:"rounded-md bg-gray-700 px-4 py-2 text-sm text-white hover:bg-gray-600",children:"Cancel"}),v.jsx("button",{type:"button",onClick:Oe,disabled:!Ce||U,className:"rounded-md bg-cyan-600 px-4 py-2 text-sm font-medium text-white hover:bg-cyan-500 disabled:opacity-50",children:U?"Launching…":"Run Now"})]})]})})}function YP({children:e,onClose:t,title:r}){return v.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/60 pt-[10vh]",children:v.jsxs("div",{className:"w-full max-w-lg rounded-lg border border-gray-700 bg-gray-900 shadow-xl",children:[v.jsxs("div",{className:"flex items-center justify-between border-b border-gray-800 px-5 py-3",children:[v.jsx("h2",{className:"text-lg font-semibold text-white",children:r}),v.jsx("button",{type:"button",onClick:t,className:"text-gray-400 hover:text-white",children:"✕"})]}),v.jsx("div",{className:"px-5 py-4",children:e})]})})}function Qte({status:e,onClose:t,onRunInBackground:r,runId:n}){const i=e.status==="finished"||e.status==="failed",l={starting:"text-yellow-400",running:"text-cyan-400",finished:"text-emerald-400",failed:"text-red-400"};return v.jsxs("div",{className:"space-y-3",children:[v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsxs("span",{className:`text-sm font-medium ${l[e.status]??"text-gray-400"}`,children:[e.status==="running"&&"●"," ",e.status.charAt(0).toUpperCase()+e.status.slice(1)]}),!i&&v.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-cyan-400 border-t-transparent"})]}),v.jsx("div",{className:"rounded-md border border-gray-700 bg-gray-950 p-3",children:v.jsx("code",{className:"block break-all text-xs text-cyan-300",children:e.command})}),e.stdout&&v.jsx("div",{className:"max-h-48 overflow-y-auto rounded-md bg-gray-950 p-3",children:v.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-300",children:e.stdout.slice(-3e3)})}),e.stderr&&v.jsx("div",{className:"max-h-24 overflow-y-auto rounded-md bg-red-950/20 p-3",children:v.jsx("pre",{className:"whitespace-pre-wrap text-xs text-red-300",children:e.stderr.slice(-2e3)})}),v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("span",{className:"text-xs text-gray-500",children:i?v.jsxs(v.Fragment,{children:["Exit code: ",e.exit_code,e.finished_at&&` · ${new Date(e.finished_at).toLocaleTimeString()}`]}):n&&v.jsx("button",{type:"button",onClick:r,className:"text-xs text-gray-400 hover:text-cyan-400",children:"Run in background"})}),i&&v.jsx("button",{type:"button",onClick:t,className:"rounded-md bg-gray-700 px-4 py-2 text-sm text-white hover:bg-gray-600",children:"Close"})]})]})}function Xte(e){if(!e)return{date:"N/A",full:"N/A"};try{const t=new Date(e);if(Number.isNaN(t.getTime()))return{date:"N/A",full:"N/A"};const r=t.toLocaleString(),n=Date.now()-t.getTime(),i=Math.floor(n/6e4),l=Math.floor(n/36e5);let u;return i<1?u="just now":i<60?u=`${i} min ago`:l<24?u=`${l} hour${l===1?"":"s"} ago`:u=t.toLocaleDateString(),{date:u,full:r}}catch{return{date:"N/A",full:"N/A"}}}function pp({runs:e,projectId:t,emptyMessage:r}){const{data:n}=bt(t),i=(n==null?void 0:n.threshold)??_c;return e.length===0?v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:r??v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No evaluation runs found."}),v.jsxs("p",{className:"mt-2 text-sm text-gray-500",children:["Run an evaluation first:"," ",v.jsx("code",{className:"rounded bg-gray-800 px-2 py-1 text-cyan-400",children:"agentv eval <eval-file>"})]})]})}):v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"w-8 px-4 py-3"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Run"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Passed"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Failed"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Total"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Pass Rate"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"When"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:e.map(l=>{const u=Xte(l.timestamp),c=l.pass_rate>=i,d=l.status==="starting"||l.status==="running",h=bh(l),m=Math.round(l.pass_rate*l.test_count),p=l.test_count-m;return v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3 text-center",children:d?v.jsx("span",{className:"inline-block h-2 w-2 animate-pulse rounded-full bg-cyan-400",title:l.status==="starting"?"Starting…":"Running…","aria-label":l.status==="starting"?"Starting":"Running"}):v.jsx("span",{className:`text-base font-bold ${c?"text-emerald-400":"text-red-400"}`,children:c?"✓":"✗"})}),v.jsx("td",{className:"px-4 py-3",children:t?v.jsx(Se,{to:"/projects/$projectId/runs/$runId",params:{projectId:t,runId:l.filename},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:h}):v.jsx(Se,{to:"/runs/$runId",params:{runId:l.filename},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:h})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-emerald-300",children:m}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-red-400",children:p>0?p:v.jsx("span",{className:"text-gray-600",children:"0"})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:l.test_count}),v.jsx("td",{className:"px-4 py-3",children:v.jsx(wn,{rate:l.pass_rate})}),v.jsx("td",{className:"px-4 py-3 text-gray-400",title:u.full,children:u.date})]},l.filename)})})]})})}function Zte(e){if(!e)return"Never synced";const t=new Date(e);return Number.isNaN(t.getTime())?"Never synced":`Last synced ${t.toLocaleString()}`}function C3({filter:e,onFilterChange:t,remoteStatus:r,syncInFlight:n,onSync:i}){const l=(r==null?void 0:r.configured)===!0,u=l&&(r==null?void 0:r.available)!==!0;return v.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-gray-800 bg-gray-900/40 p-4",children:[v.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[v.jsx("div",{className:"flex flex-wrap items-center gap-2",children:["all","local","remote"].map(c=>{const d=c==="remote"&&!l;return v.jsx("button",{type:"button",onClick:()=>t(c),title:d?"Remote results are not configured":void 0,className:`rounded-full px-3 py-1 text-sm font-medium transition-colors ${e===c?"bg-cyan-500/20 text-cyan-300":d?"bg-gray-800 text-gray-600":"bg-gray-800 text-gray-400 hover:text-gray-200"}`,children:c==="all"?"All Sources":c==="local"?"Local Only":"Remote Only"},c)})}),l&&i?v.jsx("button",{type:"button",onClick:i,disabled:n,className:"rounded-md border border-cyan-800 bg-cyan-950/40 px-3 py-1.5 text-sm font-medium text-cyan-300 transition-colors hover:bg-cyan-900/50 disabled:cursor-not-allowed disabled:opacity-60",children:n?"Syncing…":"Sync Remote Results"}):null]}),l?v.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-gray-400",children:[v.jsx("span",{children:Zte(r==null?void 0:r.last_synced_at)}),r!=null&&r.repo?v.jsxs("span",{children:["Repo: ",r.repo]}):null,u?v.jsx("span",{className:"text-yellow-400",children:"Remote cache unavailable"}):null]}):e==="all"?v.jsxs("p",{className:"text-sm text-gray-500",children:["Remote results are not configured. Add"," ",v.jsx("code",{className:"rounded bg-gray-800 px-1 text-gray-400",children:"results"})," to"," ",v.jsx("code",{className:"rounded bg-gray-800 px-1 text-gray-400",children:".agentv/config.yaml"})," to enable."]}):null,r!=null&&r.last_error?v.jsx("div",{className:"rounded-md border border-yellow-900/50 bg-yellow-950/20 px-3 py-2 text-sm text-yellow-300",children:r.last_error}):null]})}function M3({projectId:e}={}){var p,g;const[t,r]=j.useState(null),n=Fe(e?$$(e):w$),i=Fe(e?fb(e):ub),l=((p=n.data)==null?void 0:p.targets)??[],u=((g=i.data)==null?void 0:g.runs)??[],c=n.error??i.error,d=n.isLoading||i.isLoading,h=j.useMemo(()=>l.find(x=>x.name===t)??null,[t,l]);j.useEffect(()=>{t&&!l.some(x=>x.name===t)&&r(null)},[t,l]);const m=j.useMemo(()=>{if(!h)return[];const x=new Map;for(const S of u){if((S.target??"default")!==h.name)continue;const O=S.experiment??"default",_=x.get(O)??[];_.push(S),x.set(O,_)}return[...x.entries()].map(([S,w])=>Wte(S,w)).sort((S,w)=>S.latestTimestamp&&w.latestTimestamp&&S.latestTimestamp!==w.latestTimestamp?w.latestTimestamp.localeCompare(S.latestTimestamp):S.latestTimestamp?-1:w.latestTimestamp?1:S.name.localeCompare(w.name))},[u,h]);return d?v.jsx(tre,{}):c?v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load targets: ",c.message]}):l.length===0?v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No targets found"}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"Targets will appear here once evaluations are run with target labels."})]}):h?v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"space-y-3",children:[v.jsx("button",{type:"button",onClick:()=>r(null),className:"rounded-md px-3 py-1.5 text-sm text-gray-400 transition-colors hover:text-gray-200",children:"← Back to targets"}),v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900/50 p-4",children:v.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[v.jsxs("div",{children:[v.jsx("h2",{className:"text-xl font-semibold text-white",children:h.name}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:[h.run_count," run",h.run_count===1?"":"s"," ·"," ",h.experiment_count," experiment",h.experiment_count===1?"":"s"," ·"," ",v.jsx("span",{className:"text-emerald-400",children:h.passed_count}),v.jsx("span",{className:"text-gray-600",children:" / "}),h.eval_count," evals passed"]})]}),v.jsx("div",{className:"w-full max-w-52",children:v.jsx(wn,{rate:h.pass_rate})})]})})]}),m.length===0?v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No runs found for this target"}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"This target summary exists, but there are no matching runs to group by experiment."})]}):v.jsx("div",{className:"space-y-6",children:m.map(x=>v.jsxs("section",{className:"space-y-3",children:[v.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-gray-800 bg-gray-900/40 p-4 sm:flex-row sm:items-center sm:justify-between",children:[v.jsxs("div",{children:[v.jsx("h3",{className:"text-lg font-medium text-gray-200",children:Jte(x.name)}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:[x.runs.length," run",x.runs.length===1?"":"s"," ·"," ",v.jsx("span",{className:"text-emerald-400",children:x.passedCount}),v.jsx("span",{className:"text-gray-600",children:" / "}),x.evalCount," evals passed",x.latestTimestamp&&v.jsxs("span",{className:"ml-2 text-gray-500",children:["· Last run ",ere(x.latestTimestamp)]})]})]}),v.jsx("div",{className:"w-full max-w-52",children:v.jsx(wn,{rate:x.passRate})})]}),v.jsx(pp,{runs:x.runs,projectId:e})]},x.name))})]}):v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Target"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Runs"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Experiments"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Pass Rate"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Evals"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:l.map(x=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3",children:v.jsx("button",{type:"button",onClick:()=>r(x.name),className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:x.name})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:x.run_count}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:x.experiment_count}),v.jsx("td",{className:"px-4 py-3",children:v.jsx(wn,{rate:x.pass_rate})}),v.jsxs("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:[v.jsx("span",{className:"text-emerald-400",children:x.passed_count}),v.jsx("span",{className:"text-gray-600",children:" / "}),v.jsx("span",{children:x.eval_count})]})]},x.name))})]})})}function Wte(e,t){let r=0,n=0,i=null;for(const l of t)r+=l.test_count,n+=Math.round(l.pass_rate*l.test_count),l.timestamp&&(!i||l.timestamp>i)&&(i=l.timestamp);return{name:e,runs:t,latestTimestamp:i,evalCount:r,passedCount:n,passRate:r>0?n/r:0}}function Jte(e){return e==="default"?"Default experiment":e}function ere(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return e;const r=Date.now()-t.getTime(),n=Math.floor(r/6e4),i=Math.floor(r/36e5);return n<1?"just now":n<60?`${n} min ago`:i<24?`${i} hour${i===1?"":"s"} ago`:t.toLocaleDateString()}function tre(){return v.jsxs("div",{className:"space-y-4",children:[v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900/50 p-4",children:[v.jsx("div",{className:"h-6 w-40 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"mt-3 h-4 w-72 animate-pulse rounded bg-gray-800"})]}),v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("div",{className:"animate-pulse",children:[v.jsx("div",{className:"border-b border-gray-800 bg-gray-900/50 px-4 py-3",children:v.jsx("div",{className:"h-4 w-48 rounded bg-gray-800"})}),["sk-1","sk-2","sk-3","sk-4","sk-5"].map(e=>v.jsxs("div",{className:"flex gap-4 border-b border-gray-800/50 px-4 py-3",children:[v.jsx("div",{className:"h-4 w-32 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-12 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-12 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-48 rounded bg-gray-800"}),v.jsx("div",{className:"h-4 w-20 rounded bg-gray-800"})]},e))]})}),v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900/40 p-4",children:[v.jsx("div",{className:"h-5 w-48 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"mt-3 h-4 w-56 animate-pulse rounded bg-gray-800"})]})]})}const GP=[{id:"runs",label:"🏃 Recent Runs"},{id:"experiments",label:"🧪 Experiments"},{id:"analytics",label:"📊 Analytics"},{id:"targets",label:"🤖 Targets"}],rre=_r("/")({component:nre});function nre(){const e=il(),n=lb().location.search.tab,{data:i,isLoading:l}=cb(),{data:u,isLoading:c}=bt(),d=(i==null?void 0:i.projects)??[],h=d$(d.map(m=>m.id),u==null?void 0:u.project_dashboard,n);return j.useEffect(()=>{h.kind==="redirect"&&h.redirectPath&&e({to:h.redirectPath,replace:!0})},[h,e]),l||c?v.jsx(Gx,{}):h.kind==="redirect"?v.jsx(Gx,{}):h.kind==="dashboard"?v.jsx(are,{}):v.jsx(ire,{})}function are(){const{data:e}=cb(),{data:t}=bt(),r=Fa(),[n,i]=j.useState(""),[l,u]=j.useState(null),[c,d]=j.useState(!1),[h,m]=j.useState(!1),p=(e==null?void 0:e.projects)??[],g=(t==null?void 0:t.read_only)===!0;async function x(S){if(S.preventDefault(),!!n.trim()){u(null);try{await k$(n.trim()),i(""),d(!1),r.invalidateQueries({queryKey:["projects"]})}catch(w){u(w.message)}}}return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:"Projects"}),v.jsx("div",{className:"flex gap-2",children:!g&&v.jsxs(v.Fragment,{children:[v.jsx("button",{type:"button",onClick:()=>m(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run Eval"}),v.jsx("button",{type:"button",onClick:()=>d(!c),className:"rounded-md bg-cyan-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-cyan-500",children:c?"Cancel":"Add Project"})]})})]}),l&&v.jsx("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-3 text-sm text-red-400",children:l}),!g&&c&&v.jsx("div",{className:"space-y-3 rounded-lg border border-gray-800 bg-gray-900/50 p-4",children:v.jsxs("form",{onSubmit:x,className:"flex gap-2",children:[v.jsx("input",{type:"text",value:n,onChange:S=>i(S.target.value),placeholder:"Project path (e.g., /home/user/projects/my-evals)",className:"flex-1 rounded-md border border-gray-700 bg-gray-800 px-3 py-1.5 text-sm text-white placeholder-gray-500 focus:border-cyan-600 focus:outline-none"}),v.jsx("button",{type:"submit",className:"rounded-md bg-cyan-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-cyan-500",children:"Add"})]})}),p.length===0?v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900/50 p-8 text-center",children:[v.jsx("p",{className:"text-lg text-gray-300",children:"No projects registered yet."}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"Add a project path to start browsing runs, experiments, analytics, and targets."})]}):v.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:p.map(S=>v.jsx(Yte,{project:S},S.id))}),!g&&v.jsx(hl,{open:h,onClose:()=>m(!1)})]})}function ire(){const r=lb().location.search.tab,n=il(),i=Fa(),{data:l,isLoading:u,error:c}=WC(),{data:d}=tM(),{data:h}=bt(),[m,p]=j.useState(!1),[g,x]=j.useState("all"),[S,w]=j.useState(!1),O=(h==null?void 0:h.read_only)===!0,_=GP.some(A=>A.id===r)?r:"experiments",E=g==="all"?(l==null?void 0:l.runs)??[]:((l==null?void 0:l.runs)??[]).filter(A=>A.source===g);async function T(){w(!0);try{await iM(),await Promise.all([i.invalidateQueries({queryKey:["runs"]}),i.invalidateQueries({queryKey:["experiments"]}),i.invalidateQueries({queryKey:["compare"]}),i.invalidateQueries({queryKey:["targets"]}),i.invalidateQueries({queryKey:["remote-status",""]})])}finally{w(!1)}}return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:"Evaluation Runs"}),(h==null?void 0:h.project_name)&&v.jsx("p",{className:"mt-0.5 text-sm text-gray-500",children:h.project_name})]}),!O&&v.jsx("button",{type:"button",onClick:()=>p(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run Eval"})]}),v.jsx("div",{className:"border-b border-gray-800",children:v.jsx("div",{className:"flex gap-1",children:GP.map(A=>v.jsx("button",{type:"button",onClick:()=>n({to:"/",search:{tab:A.id}}),className:`px-4 py-2 text-sm font-medium transition-colors ${_===A.id?"border-b-2 border-cyan-400 text-cyan-400":"text-gray-400 hover:text-gray-300"}`,children:A.label},A.id))})}),_==="runs"&&v.jsx(lre,{runs:E,isLoading:u,error:c,sourceFilter:g,onSourceFilterChange:x,remoteStatus:d,syncInFlight:S,onSyncRemote:T}),_==="experiments"&&v.jsx(P3,{}),_==="analytics"&&v.jsx(sre,{readOnly:O}),_==="targets"&&v.jsx(M3,{}),!O&&v.jsx(hl,{open:m,onClose:()=>p(!1)})]})}function sre({readOnly:e}){const{data:t,isLoading:r,isError:n,error:i}=T$();return v.jsx(A3,{data:t,isLoading:r,isError:n,error:i,readOnly:e})}function lre({runs:e,isLoading:t,error:r,sourceFilter:n,onSourceFilterChange:i,remoteStatus:l,syncInFlight:u,onSyncRemote:c}){return t?v.jsx(Gx,{}):r?v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load runs: ",r.message]}):v.jsxs("div",{className:"space-y-4",children:[v.jsx(ore,{}),v.jsx(C3,{filter:n,onFilterChange:i,remoteStatus:l,syncInFlight:u,onSync:c}),v.jsx(pp,{runs:e,emptyMessage:n==="remote"?l!=null&&l.configured?v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No remote runs found."}),v.jsxs("p",{className:"mt-2 text-sm text-gray-500",children:["Sync remote results or run an eval with"," ",v.jsx("code",{className:"rounded bg-gray-800 px-2 py-1 text-cyan-400",children:"auto_push: true"})," ","in your config."]})]}):v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"text-lg text-gray-400",children:"Remote results are not configured."}),v.jsxs("p",{className:"mt-2 text-sm text-gray-500",children:["Add ",v.jsx("code",{className:"rounded bg-gray-800 px-2 py-1 text-cyan-400",children:"results"})," ","to"," ",v.jsx("code",{className:"rounded bg-gray-800 px-2 py-1 text-cyan-400",children:".agentv/config.yaml"})," ","to enable remote result syncing."]})]}):void 0})]})}function ore(){const{data:e}=mb(),t=((e==null?void 0:e.runs)??[]).filter(r=>r.status==="starting"||r.status==="running");return t.length===0?null:v.jsxs("div",{className:"rounded-lg border border-cyan-900/40 bg-cyan-950/10",children:[v.jsx("div",{className:"border-b border-cyan-900/30 px-4 py-2.5",children:v.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-cyan-400",children:"Active"})}),v.jsx("ul",{className:"divide-y divide-gray-800/50",children:t.map(r=>v.jsxs("li",{className:"flex items-center justify-between px-4 py-3",children:[v.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[v.jsx("span",{className:"inline-block h-2 w-2 flex-shrink-0 animate-pulse rounded-full bg-cyan-400"}),v.jsx("span",{className:"truncate font-mono text-sm text-gray-300",children:r.id}),v.jsx("span",{className:"flex-shrink-0 text-xs text-gray-500",children:new Date(r.started_at).toLocaleTimeString()})]}),v.jsx(Se,{to:"/jobs/$runId",params:{runId:r.id},className:"ml-4 flex-shrink-0 text-xs text-cyan-400 hover:text-cyan-300",children:"View Log →"})]},r.id))})]})}function Gx(){return v.jsx("div",{className:"space-y-2",children:["s1","s2","s3","s4","s5"].map(e=>v.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-gray-900"},e))})}function ure(e,t,r){return t?!1:!!(e.some(n=>n.executionStatus==="execution_error")||r!==void 0&&e.length<r)}function cre(e){const t={suite_filter:e.suiteFilter,output:e.runDir};return e.target&&(t.target=e.target),e.mode==="resume"?t.resume=!0:t.rerun_failed=!0,t}function R3({results:e,runDir:t,suiteFilter:r,target:n,projectId:i,isReadOnly:l,plannedTestCount:u}){const c=il(),[d,h]=j.useState(null),[m,p]=j.useState(null);if(!ure(e,l,u))return null;const g=!!t&&!!r,x=t?r?"":"Original eval file path missing from benchmark.json — cannot determine what to resume":"Run directory unavailable (remote run cannot be resumed in place)";async function S(w){if(!(!g||!t||!r)){h(w),p(null);try{const O=cre({mode:w,runDir:t,suiteFilter:r,target:n}),_=await sM(O,i);c(i?{to:"/projects/$projectId/jobs/$runId",params:{projectId:i,runId:_.id}}:{to:"/jobs/$runId",params:{runId:_.id}})}catch(O){p(O instanceof Error?O.message:"Failed to launch resume"),h(null)}}}return v.jsxs("div",{className:"flex flex-col items-end gap-1",children:[v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("button",{type:"button",onClick:()=>S("resume"),disabled:!g||d!==null,title:g?"Skip already-completed tests, run the rest":x,className:"rounded-md bg-amber-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-amber-500 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"resume-run-button",children:d==="resume"?"Resuming…":"↻ Resume run"}),v.jsx("button",{type:"button",onClick:()=>S("rerun"),disabled:!g||d!==null,title:g?"Re-run failed/errored tests, keep passing results":x,className:"rounded-md border border-amber-600/60 bg-transparent px-3 py-1.5 text-sm font-medium text-amber-300 hover:bg-amber-950/40 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"rerun-failed-button",children:d==="rerun"?"Re-running…":"Rerun failed cases"})]}),m&&v.jsx("p",{className:"text-xs text-red-400",children:m})]})}function qo({total:e,passed:t,failed:r,passRate:n,totalCost:i}){const l=Math.round(n*100),u=l>=80?"text-cyan-400":l>=60?"text-amber-400":"text-red-400";return v.jsxs("div",{className:"flex flex-wrap items-center gap-6 rounded-lg border border-gray-800 bg-gray-900/60 px-5 py-3",children:[v.jsx(fc,{label:"Pass Rate",value:`${l}%`,accent:u,large:!0}),v.jsx("div",{className:"h-6 w-px bg-gray-700"}),v.jsx(fc,{label:"Passed",value:String(t),accent:"text-emerald-400"}),v.jsx(fc,{label:"Failed",value:String(r),accent:"text-red-400"}),v.jsx(fc,{label:"Total",value:String(e)}),i!==void 0&&v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"h-6 w-px bg-gray-700"}),v.jsx(fc,{label:"Cost",value:`$${i.toFixed(4)}`,accent:"text-amber-400"})]})]})}function fc({label:e,value:t,accent:r,large:n}){return v.jsxs("div",{className:"flex flex-col",children:[v.jsx("span",{className:"text-xs text-gray-500",children:e}),v.jsx("span",{className:`tabular-nums font-semibold ${n?"text-2xl":"text-lg"} ${r??"text-white"}`,children:t})]})}function fre(e,t){const r=new Map;for(const n of e){const i=n.category??"Uncategorized",l=n.suite??"Uncategorized";r.has(i)||r.set(i,new Map);const u=r.get(i),c=u.get(l)??{passed:0,failed:0,total:0,scoreSum:0};c.total+=1,c.scoreSum+=n.score,Jr(n.score,t)?c.passed+=1:c.failed+=1,u.set(l,c)}return Array.from(r.entries()).map(([n,i])=>{const l=Array.from(i.entries()).map(([m,p])=>({name:m,...p,avgScore:p.total>0?p.scoreSum/p.total:0})).sort((m,p)=>m.name.localeCompare(p.name)),u=l.reduce((m,p)=>m+p.total,0),c=l.reduce((m,p)=>m+p.passed,0),d=l.reduce((m,p)=>m+p.failed,0),h=l.reduce((m,p)=>m+p.avgScore*p.total,0);return{name:n,suites:l,total:u,passed:c,failed:d,avgScore:u>0?h/u:0}}).sort((n,i)=>n.name.localeCompare(i.name))}function D3({results:e,runId:t,projectId:r}){const{data:n}=bt(r),i=(n==null?void 0:n.threshold)??(n==null?void 0:n.pass_threshold)??.8,l=e.length,u=e.filter(p=>Jr(p.score,i)).length,c=l-u,d=l>0?u/l:0,h=e.reduce((p,g)=>p+(g.costUsd??0),0),m=fre(e,i);return l===0?v.jsxs("div",{className:"space-y-6",children:[v.jsx(qo,{total:0,passed:0,failed:0,passRate:0}),v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No evaluations found"}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"This run has no results yet."})]})]}):v.jsxs("div",{className:"space-y-6",children:[v.jsx(qo,{total:l,passed:u,failed:c,passRate:d,totalCost:h>0?h:void 0}),v.jsxs("div",{children:[v.jsx("h3",{className:"mb-3 text-sm font-medium text-gray-400",children:"Category Breakdown"}),v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-2.5 font-medium text-gray-400",children:"Category"}),v.jsx("th",{className:"px-4 py-2.5 font-medium text-gray-400",children:"Pass Rate"}),v.jsx("th",{className:"px-4 py-2.5 text-right font-medium text-gray-400",children:"Passed"}),v.jsx("th",{className:"px-4 py-2.5 text-right font-medium text-gray-400",children:"Failed"}),v.jsx("th",{className:"px-4 py-2.5 text-right font-medium text-gray-400",children:"Total"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:m.map(p=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-2.5 font-medium text-gray-200",children:r?v.jsx(Se,{to:"/projects/$projectId/runs/$runId/category/$category",params:{projectId:r,runId:t,category:p.name},className:"text-cyan-400 hover:text-cyan-300 hover:underline",children:p.name}):v.jsx(Se,{to:"/runs/$runId/category/$category",params:{runId:t,category:p.name},className:"text-cyan-400 hover:text-cyan-300 hover:underline",children:p.name})}),v.jsx("td",{className:"px-4 py-2.5",children:v.jsx(wn,{rate:p.total>0?p.passed/p.total:0})}),v.jsx("td",{className:"px-4 py-2.5 text-right tabular-nums text-emerald-400",children:p.passed}),v.jsx("td",{className:"px-4 py-2.5 text-right tabular-nums text-red-400",children:p.failed>0?p.failed:v.jsx("span",{className:"text-gray-600",children:"0"})}),v.jsx("td",{className:"px-4 py-2.5 text-right tabular-nums text-gray-400",children:p.total})]},p.name))})]})})]}),v.jsxs("div",{children:[v.jsx("h3",{className:"mb-3 text-sm font-medium text-gray-400",children:"All Evals"}),v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"w-8 px-4 py-3"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Test ID"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Target"}),v.jsx("th",{className:"w-48 px-4 py-3 font-medium text-gray-400",children:"Score"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Duration"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Cost"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:e.map((p,g)=>{const x=p.executionStatus==="execution_error",S=Jr(p.score,i);return v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3 text-center",children:x?v.jsx("span",{className:"text-base font-bold text-red-400",children:"!"}):v.jsx("span",{className:`text-base font-bold ${S?"text-emerald-400":"text-red-400"}`,children:S?"✓":"✗"})}),v.jsx("td",{className:"px-4 py-3",children:r?v.jsx(Se,{to:"/projects/$projectId/evals/$runId/$evalId",params:{projectId:r,runId:t,evalId:p.testId},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:p.testId}):v.jsx(Se,{to:"/evals/$runId/$evalId",params:{runId:t,evalId:p.testId},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:p.testId})}),v.jsx("td",{className:"px-4 py-3 text-gray-400",children:p.target??"-"}),v.jsx("td",{className:"px-4 py-3",children:x?v.jsx("span",{className:"inline-flex rounded-full bg-red-900/50 px-2 py-0.5 text-xs font-medium text-red-400",children:"ERR"}):v.jsx(wn,{rate:p.score})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:p.durationMs!=null?`${(p.durationMs/1e3).toFixed(1)}s`:"-"}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:p.costUsd!=null?`$${p.costUsd.toFixed(4)}`:"-"})]},`${p.testId}-${g}`)})})]})})]}),v.jsx(dre,{runId:t,projectId:r})]})}function dre({runId:e,projectId:t}){const[r,n]=j.useState(!1),{data:i,isLoading:l,error:u}=g$(e,t);return!l&&!u&&i==null?null:v.jsxs("div",{children:[v.jsxs("button",{type:"button",onClick:()=>n(c=>!c),className:"flex w-full items-center justify-between rounded-lg border border-gray-800 bg-gray-900/50 px-4 py-2 text-left text-sm font-medium text-gray-300 transition-colors hover:bg-gray-900","aria-expanded":r,children:[v.jsxs("span",{className:"flex items-center gap-2",children:[v.jsx("span",{"aria-hidden":"true",children:r?"▾":"▸"}),"Run Log"]}),v.jsx("span",{className:"text-xs text-gray-500",children:l?"Loading…":u?"Failed to load":i?`${i.length} chars`:""})]}),r&&v.jsx("div",{className:"mt-2 overflow-hidden rounded-lg border border-gray-800 bg-black",children:u?v.jsxs("div",{className:"p-4 text-sm text-red-400",children:["Failed to load run log: ",u.message]}):v.jsx("pre",{className:"max-h-[480px] overflow-auto whitespace-pre-wrap break-words p-4 font-mono text-xs leading-relaxed text-gray-200",children:i??""})})]})}const k3=_r("/runs/$runId")({component:hre});function hre(){var w;const{runId:e}=k3.useParams(),{data:t,isLoading:r,error:n}=Gc(e),{data:i}=bt(),[l,u]=j.useState(!1),c=(i==null?void 0:i.read_only)===!0;if(r)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-5 gap-4",children:["s1","s2","s3","s4","s5"].map(O=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},O))})]});if(n)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load run: ",n.message]});const d=(w=t==null?void 0:t.results)==null?void 0:w[0],h=d==null?void 0:d.target,m=d==null?void 0:d.experiment,p=d==null?void 0:d.timestamp,g=h?{target:h}:void 0,x=(()=>{const O=[m,h].filter(_=>_&&_!=="default");return O.length>0?O.join(" · "):e})(),S=[h,m&&m!=="default"?m:null,p?new Date(p).toLocaleString():null,t==null?void 0:t.source].filter(Boolean).join(" · ");return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:x}),v.jsx("p",{className:"mt-1 text-sm text-gray-500",children:S})]}),v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsx(R3,{results:(t==null?void 0:t.results)??[],runDir:t==null?void 0:t.run_dir,suiteFilter:t==null?void 0:t.suite_filter,target:h??void 0,isReadOnly:c,plannedTestCount:t==null?void 0:t.planned_test_count}),!c&&v.jsx("button",{type:"button",onClick:()=>u(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run evals"})]})]}),v.jsx(D3,{results:(t==null?void 0:t.results)??[],runId:e}),!c&&v.jsx(hl,{open:l,onClose:()=>u(!1),prefill:g})]})}const VP=[{id:"runs",label:"🏃 Recent Runs"},{id:"experiments",label:"🧪 Experiments"},{id:"analytics",label:"📊 Analytics"},{id:"targets",label:"🤖 Targets"}],I3=_r("/projects/$projectId")({component:mre});function mre(){const{projectId:e}=I3.useParams(),n=lb().location.search.tab,i=il(),[l,u]=j.useState(!1),{data:c}=bt(e),d=(c==null?void 0:c.read_only)===!0,h=VP.some(m=>m.id===n)?n:"experiments";return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:e}),!d&&v.jsx("button",{type:"button",onClick:()=>u(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run Eval"})]}),v.jsx("div",{className:"border-b border-gray-800",children:v.jsx("div",{className:"flex gap-1",children:VP.map(m=>v.jsx("button",{type:"button",onClick:()=>i({to:"/projects/$projectId",params:{projectId:e},search:{tab:m.id}}),className:`px-4 py-2 text-sm font-medium transition-colors ${h===m.id?"border-b-2 border-cyan-400 text-cyan-400":"text-gray-400 hover:text-gray-300"}`,children:m.label},m.id))})}),h==="runs"&&v.jsx(pre,{projectId:e}),h==="experiments"&&v.jsx(P3,{projectId:e}),h==="analytics"&&v.jsx(vre,{projectId:e,readOnly:d}),h==="targets"&&v.jsx(M3,{projectId:e}),!d&&v.jsx(hl,{open:l,onClose:()=>u(!1),projectId:e})]})}function pre({projectId:e}){const t=Fa(),{data:r,isLoading:n,error:i}=rM(e),{data:l}=mb(e),{data:u}=tM(e),[c,d]=j.useState("all"),[h,m]=j.useState(!1),p=((l==null?void 0:l.runs)??[]).filter(S=>S.status==="starting"||S.status==="running"),g=c==="all"?(r==null?void 0:r.runs)??[]:((r==null?void 0:r.runs)??[]).filter(S=>S.source===c);async function x(){m(!0);try{await iM(e),await Promise.all([t.invalidateQueries({queryKey:["projects",e,"runs"]}),t.invalidateQueries({queryKey:["projects",e,"experiments"]}),t.invalidateQueries({queryKey:["projects",e,"compare"]}),t.invalidateQueries({queryKey:["projects",e,"targets"]}),t.invalidateQueries({queryKey:["remote-status",e]})])}finally{m(!1)}}return n?v.jsx("div",{className:"space-y-2",children:["s1","s2","s3"].map(S=>v.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-gray-900"},S))}):i?v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load runs: ",i.message]}):v.jsxs("div",{className:"space-y-4",children:[p.length>0&&v.jsxs("div",{className:"rounded-lg border border-cyan-900/40 bg-cyan-950/10",children:[v.jsx("div",{className:"border-b border-cyan-900/30 px-4 py-2.5",children:v.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-cyan-400",children:"Active"})}),v.jsx("ul",{className:"divide-y divide-gray-800/50",children:p.map(S=>v.jsxs("li",{className:"flex items-center justify-between gap-4 px-4 py-3",children:[v.jsxs("div",{className:"min-w-0 flex items-center gap-3",children:[v.jsx("span",{className:"inline-block h-2 w-2 flex-shrink-0 animate-pulse rounded-full bg-cyan-400"}),v.jsx("span",{className:"truncate font-mono text-sm text-gray-300",children:S.id}),v.jsx("span",{className:"flex-shrink-0 text-xs text-gray-500",children:new Date(S.started_at).toLocaleTimeString()})]}),v.jsx(Se,{to:"/projects/$projectId/jobs/$runId",params:{projectId:e,runId:S.id},className:"flex-shrink-0 text-xs text-cyan-400 hover:text-cyan-300",children:"View Log →"})]},S.id))})]}),v.jsx(C3,{filter:c,onFilterChange:d,remoteStatus:u,syncInFlight:h,onSync:x}),v.jsx(pp,{runs:g,projectId:e})]})}function vre({projectId:e,readOnly:t}){const{data:r,isLoading:n,isError:i,error:l}=Fe(aM(e));return v.jsx(A3,{data:r,isLoading:n,isError:i,error:l,projectId:e,readOnly:t})}function yre(e){return e==="finished"||e==="failed"}function gre(e,t){return t||!e?!1:!yre(e)}function L3({runId:e,status:t,isReadOnly:r,projectId:n}){const[i,l]=j.useState(!1),[u,c]=j.useState(null);if(!gre(t,r))return null;async function d(){l(!0),c(null);try{await V$(e,n)}catch(h){c(h instanceof Error?h.message:"Failed to stop run"),l(!1)}}return v.jsxs("div",{className:"flex flex-col items-end gap-1",children:[v.jsx("button",{type:"button",onClick:d,disabled:i,className:"rounded-md border border-gray-700 bg-transparent px-3 py-1.5 text-sm font-medium text-gray-300 hover:bg-gray-800 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"stop-run-button",children:i?"Stopping…":"⏸ Stop"}),u&&v.jsx("p",{className:"text-xs text-red-400",children:u})]})}const z3=_r("/jobs/$runId")({component:xre});function xre(){const{runId:e}=z3.useParams(),{data:t,isLoading:r,error:n}=hb(e),{data:i}=bt(),l=(i==null?void 0:i.read_only)===!0;if(r)return v.jsxs("div",{className:"space-y-4",children:[v.jsx(E0,{}),v.jsx("div",{className:"h-8 w-48 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"h-64 animate-pulse rounded-lg bg-gray-900"})]});if(n||!t)return v.jsxs("div",{className:"space-y-4",children:[v.jsx(E0,{}),v.jsx("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-4 text-sm text-red-400",children:n?`Failed to load run: ${n.message}`:"Run not found."})]});const u=t.status==="finished"||t.status==="failed",d={starting:"text-yellow-400",running:"text-cyan-400",finished:"text-emerald-400",failed:"text-red-400"}[t.status]??"text-gray-400";return v.jsxs("div",{className:"space-y-4",children:[v.jsx(E0,{}),v.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-4",children:[v.jsxs("div",{className:"min-w-0",children:[v.jsx("h1",{className:"truncate font-mono text-base font-semibold text-white",children:e}),v.jsxs("p",{className:"mt-0.5 text-xs text-gray-500",children:["Started ",new Date(t.started_at).toLocaleString(),t.finished_at&&v.jsxs(v.Fragment,{children:[" · ","Finished ",new Date(t.finished_at).toLocaleString()," · ",Math.round((new Date(t.finished_at).getTime()-new Date(t.started_at).getTime())/1e3),"s"]})]})]}),v.jsxs("div",{className:"flex flex-shrink-0 items-center gap-3",children:[v.jsx(L3,{runId:e,status:t.status,isReadOnly:l}),v.jsx("span",{className:`text-sm font-medium ${d}`,children:t.status.charAt(0).toUpperCase()+t.status.slice(1)}),!u&&v.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-cyan-400 border-t-transparent"})]})]}),v.jsxs("div",{className:"rounded-md border border-gray-700 bg-gray-950 px-4 py-3",children:[v.jsx("p",{className:"mb-1 text-xs font-medium uppercase tracking-wider text-gray-500",children:"Command"}),v.jsx("code",{className:"break-all text-xs text-cyan-300",children:t.command})]}),t.stdout?v.jsxs("div",{children:[v.jsx("p",{className:"mb-1 text-xs font-medium uppercase tracking-wider text-gray-500",children:"Output"}),v.jsx("div",{className:"max-h-[60vh] overflow-y-auto rounded-lg border border-gray-700 bg-gray-950 p-4",children:v.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs text-gray-200",children:t.stdout})})]}):!u&&v.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[v.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-spin rounded-full border-2 border-gray-500 border-t-transparent"}),"Waiting for output…"]}),t.stderr&&v.jsxs("div",{children:[v.jsx("p",{className:"mb-1 text-xs font-medium uppercase tracking-wider text-red-500",children:"Stderr"}),v.jsx("div",{className:"max-h-48 overflow-y-auto rounded-lg border border-red-900/40 bg-red-950/20 p-4",children:v.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs text-red-300",children:t.stderr})})]}),u&&v.jsxs("p",{className:"text-xs text-gray-500",children:["Exit code:"," ",v.jsx("span",{className:t.exit_code===0?"text-emerald-400":"text-red-400",children:t.exit_code})]})]})}function E0(){return v.jsx(Se,{to:"/",search:{tab:"runs"},className:"text-xs text-gray-400 hover:text-cyan-400",children:"← Back to Runs"})}function $3({experimentName:e,projectId:t}){var g;const{data:r,isLoading:n}=Fe(t?db(t):ZC),{data:i,isLoading:l}=Fe(t?fb(t):ub);if(n||l)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-4 gap-4",children:["s1","s2","s3","s4"].map(x=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},x))})]});const c=(g=r==null?void 0:r.experiments)==null?void 0:g.find(x=>x.name===e),d=((i==null?void 0:i.runs)??[]).filter(x=>(x.experiment??"default")===e),h=(c==null?void 0:c.pass_rate)??0,m=(c==null?void 0:c.run_count)??d.length,p=(c==null?void 0:c.target_count)??0;return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:e}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:[m," run",m!==1?"s":""," · ",p," target",p!==1?"s":"",(c==null?void 0:c.last_run)&&v.jsxs("span",{className:"ml-2",children:["· Last run: ",QP(c.last_run)]})]})]}),c&&v.jsxs("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-4",children:[v.jsx(rh,{label:"Runs",value:String(m)}),v.jsx(rh,{label:"Targets",value:String(p)}),v.jsx(rh,{label:"Pass Rate",value:`${Math.round(h*100)}%`,accent:"text-cyan-400"}),v.jsx(rh,{label:"Last Run",value:QP(c.last_run)})]}),v.jsxs("div",{children:[v.jsx("h2",{className:"mb-4 text-lg font-medium text-gray-200",children:"All Runs"}),v.jsx(pp,{runs:d,projectId:t,emptyMessage:v.jsxs("div",{children:[v.jsx("p",{className:"text-lg text-gray-400",children:"No evaluation runs found for this experiment."}),v.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"Runs will appear here once this experiment has execution results."})]})})]})]})}function rh({label:e,value:t,accent:r}){return v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-4",children:[v.jsx("p",{className:"text-sm text-gray-400",children:e}),v.jsx("p",{className:`mt-1 text-2xl font-semibold tabular-nums ${r??"text-white"}`,children:t})]})}function QP(e){if(!e)return"N/A";try{const t=new Date(e);return Number.isNaN(t.getTime())?"N/A":t.toLocaleString()}catch{return"N/A"}}const B3=_r("/experiments/$experimentName")({component:bre});function bre(){const{experimentName:e}=B3.useParams();return v.jsx($3,{experimentName:e})}async function Sre(e,t){const r=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reviews:[{test_id:e,comment:t}]})});if(!r.ok)throw new Error(`Failed to save feedback: ${r.status}`);return r.json()}function wre({testId:e}){var m;const{data:t}=A$(),r=Fa(),n=(m=t==null?void 0:t.reviews)==null?void 0:m.find(p=>p.test_id===e),[i,l]=j.useState((n==null?void 0:n.comment)??""),[u,c]=j.useState(!1);j.useEffect(()=>{l((n==null?void 0:n.comment)??""),c(!1)},[n==null?void 0:n.comment]);const d=H0({mutationFn:()=>Sre(e,i),onSuccess:()=>{r.invalidateQueries({queryKey:["feedback"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),h=j.useCallback(()=>{d.mutate()},[d]);return v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-4",children:[v.jsx("h4",{className:"mb-2 text-sm font-medium text-gray-400",children:"Feedback"}),v.jsx("textarea",{value:i,onChange:p=>{l(p.target.value),c(!1)},placeholder:"Add feedback for this test...",className:"w-full rounded-md border border-gray-700 bg-gray-800 p-3 text-sm text-gray-200 placeholder-gray-500 focus:border-cyan-400 focus:outline-none",rows:3}),v.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[v.jsx("button",{type:"button",onClick:h,disabled:d.isPending,className:"rounded-md bg-cyan-600 px-4 py-1.5 text-sm font-medium text-white hover:bg-cyan-500 disabled:opacity-50",children:d.isPending?"Saving...":"Save Feedback"}),u&&v.jsx("span",{className:"text-sm text-emerald-400",children:"Saved"}),d.isError&&v.jsx("span",{className:"text-sm text-red-400",children:"Error saving feedback"})]})]})}function jre(e){var r;switch((r=e.split(".").pop())==null?void 0:r.toLowerCase()){case"ts":case"tsx":return"📘";case"json":return"📋";case"log":case"txt":return"📜";case"md":return"📝";default:return"📄"}}function U3(e){const t=[];for(const r of e)r.type==="dir"&&(t.push(r.path),r.children&&t.push(...U3(r.children)));return t}function q3({node:e,selectedPath:t,onSelect:r,openFolders:n,toggleFolder:i,depth:l=0}){const u=e.type==="dir",c=n.has(e.path),d=t===e.path;return v.jsxs("div",{children:[v.jsxs("button",{type:"button",onClick:()=>{u?i(e.path):r(e.path)},className:`flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm transition-colors ${d?"bg-cyan-400/20 text-cyan-400":"text-gray-300 hover:bg-gray-800/50 hover:text-gray-200"}`,style:{paddingLeft:`${l*16+8}px`},children:[v.jsx("span",{className:"flex-shrink-0 text-xs",children:u?c?"📂":"📁":jre(e.name)}),v.jsx("span",{className:"truncate",children:e.name})]}),u&&c&&e.children&&v.jsx("div",{children:e.children.map(h=>v.jsx(q3,{node:h,selectedPath:t,onSelect:r,openFolders:n,toggleFolder:i,depth:l+1},h.path))})]})}function Ore({files:e,selectedPath:t,onSelect:r}){const[n,i]=j.useState(()=>new Set(U3(e))),l=u=>{i(c=>{const d=new Set(c);return d.has(u)?d.delete(u):d.add(u),d})};return v.jsxs("div",{className:"w-64 overflow-y-auto rounded-lg border border-gray-800 bg-gray-900 py-2",children:[e.length===0&&v.jsx("p",{className:"px-4 py-2 text-sm text-gray-500",children:"No files."}),e.map(u=>v.jsx(q3,{node:u,selectedPath:t,onSelect:r,openFolders:n,toggleFolder:l},u.path))]})}const _re="modulepreload",Nre=function(e){return"/"+e},XP={},Ere=function(t,r,n){let i=Promise.resolve();if(r&&r.length>0){let u=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));i=u(r.map(h=>{if(h=Nre(h),h in XP)return;XP[h]=!0;const m=h.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":_re,m||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),m)return new Promise((x,S)=>{g.addEventListener("load",x),g.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${h}`)))})}))}function l(u){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=u,window.dispatchEvent(c),!c.defaultPrevented)throw u}return i.then(u=>{for(const c of u||[])c.status==="rejected"&&l(c.reason);return t().catch(l)})},Are=j.lazy(()=>Ere(()=>import("./index-Bh_LwYWq.js"),[]));function Tre({value:e,language:t="json",height:r="400px"}){return v.jsx(j.Suspense,{fallback:v.jsx("div",{className:"flex items-center justify-center rounded-lg bg-gray-900 p-8 text-gray-500",children:"Loading editor..."}),children:v.jsx(Are,{height:r,language:t,value:e,theme:"vs-dark",options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:"on",wordWrap:"on",padding:{top:12}}})})}function vm({score:e,className:t=""}){const r=Math.round(Math.max(0,Math.min(1,e))*100);return v.jsxs("div",{className:`flex items-center gap-3 ${t}`,children:[v.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-gray-800",children:v.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-cyan-400 to-blue-500 transition-all duration-300",style:{width:`${r}%`}})}),v.jsxs("span",{className:"w-12 text-right text-sm font-medium tabular-nums text-gray-300",children:[r,"%"]})]})}function H3(e){for(const t of e){if(t.type==="file")return t.path;if(t.children){const r=H3(t.children);if(r)return r}}return null}function K3({eval:e,runId:t,projectId:r}){const[n,i]=j.useState("checks"),{data:l}=bt(r),u=(l==null?void 0:l.read_only)===!0,c=[{id:"checks",label:"Checks"},{id:"files",label:"Files"},...u?[]:[{id:"feedback",label:"Feedback"}]];return v.jsxs("div",{className:"flex min-h-full flex-col",children:[v.jsx("div",{className:"border-b border-gray-800",children:v.jsx("div",{className:"flex gap-1 px-4",children:c.map(d=>v.jsx("button",{type:"button",onClick:()=>i(d.id),className:`px-4 py-2 text-sm font-medium transition-colors ${n===d.id?"border-b-2 border-cyan-400 text-cyan-400":"text-gray-400 hover:text-gray-300"}`,children:d.label},d.id))})}),v.jsxs("div",{className:"min-h-0 flex-1",children:[n==="checks"&&v.jsx("div",{className:"overflow-auto p-4",children:v.jsx(Pre,{result:e,projectId:r})}),n==="files"&&v.jsx("div",{className:"h-full p-4",children:v.jsx(Cre,{result:e,runId:t,projectId:r})}),!u&&n==="feedback"&&v.jsx("div",{className:"p-4",children:v.jsx(wre,{testId:e.testId})})]})]})}function ZP({assertion:e}){return v.jsxs("div",{className:`flex items-start gap-3 rounded-lg border p-3 ${e.passed?"border-emerald-900/50 bg-emerald-950/20":"border-red-900/50 bg-red-950/20"}`,children:[v.jsx("span",{className:`mt-0.5 text-lg ${e.passed?"text-emerald-400":"text-red-400"}`,children:e.passed?"✓":"✗"}),v.jsxs("div",{className:"min-w-0 flex-1",children:[v.jsxs("p",{className:"text-sm text-gray-200",children:[e.text,e.durationMs!=null&&v.jsxs("span",{className:"ml-2 text-xs text-gray-500",children:["(",(e.durationMs/1e3).toFixed(1),"s)"]})]}),e.evidence&&v.jsx("p",{className:"mt-1 text-xs text-gray-400",children:e.evidence})]})]})}function Pre({result:e,projectId:t}){const{data:r}=bt(t),n=(r==null?void 0:r.threshold)??(r==null?void 0:r.pass_threshold)??.8,i=!Jr(e.score,n)||e.executionStatus==="error"||e.executionStatus==="failed",l=(e.scores??[]).filter(m=>Array.isArray(m.assertions)&&m.assertions.length>0),u=l.length>0,c=e.assertions??[],d=[];e.error&&d.push(e.error),(e.executionStatus==="error"||e.executionStatus==="failed")&&d.push(`Execution status: ${e.executionStatus}`);const h=u?l.flatMap(m=>m.assertions):c;for(const m of h.filter(p=>!p.passed)){const p=m.evidence?`${m.text}: ${m.evidence}`:m.text;d.push(p)}if(e.scores){for(const m of e.scores)if(!Jr(m.score,n)&&m.details){const p=typeof m.details=="string"?m.details:JSON.stringify(m.details,null,2);d.push(`[${m.name??m.type??"evaluator"}] ${p}`)}}return v.jsxs("div",{className:"space-y-6",children:[v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-4",children:v.jsxs("div",{className:"flex items-center gap-4",children:[v.jsx("span",{className:"text-sm font-medium text-gray-400",children:"Overall score"}),v.jsx("div",{className:"flex-1",children:v.jsx(vm,{score:e.score})})]})}),e.scores&&e.scores.length>0&&v.jsxs("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-4",children:[v.jsx("h4",{className:"mb-3 text-sm font-medium text-gray-400",children:"Grader Scores"}),v.jsx("div",{className:"space-y-3",children:e.scores.map((m,p)=>v.jsxs("div",{className:"flex items-center gap-4",children:[v.jsx("span",{className:"w-40 truncate text-sm text-gray-300",children:m.name??m.type??`Score ${p+1}`}),v.jsx("div",{className:"flex-1",children:v.jsx(vm,{score:m.score})})]},`${m.name??m.type??p}`))})]}),u?v.jsx("div",{className:"space-y-6",children:l.map((m,p)=>{const g=m.name??m.type??`Grader ${p+1}`;return v.jsxs("div",{className:"space-y-2",children:[v.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-300",children:g}),m.assertions.map((x,S)=>v.jsx(ZP,{assertion:x},`${x.text}-${S}`))]},`${m.name??m.type??p}`)})}):c.length>0?v.jsx("div",{className:"space-y-2",children:c.map((m,p)=>v.jsx(ZP,{assertion:m},`${m.text}-${p}`))}):v.jsx("p",{className:"text-sm text-gray-500",children:"No assertion steps recorded."}),i&&d.length>0&&v.jsxs("div",{className:"rounded-lg border border-red-500/30 bg-red-500/10 p-4",children:[v.jsx("h4",{className:"mb-2 text-sm font-medium text-red-400",children:"Failure Reason"}),v.jsx("div",{className:"space-y-2",children:d.map(m=>v.jsx("p",{className:"text-sm text-gray-300",children:m},m))})]})]})}function Cre({result:e,runId:t,projectId:r}){const n=e.testId,{data:i}=r?Fe(L$(r,t,n)):P$(t,n),l=(i==null?void 0:i.files)??[],[u,c]=j.useState(null),d=u??(l.length>0?H3(l):null),{data:h,isLoading:m}=r?Fe(z$(r,t,n,d??"")):C$(t,n,d??"");if(l.length===0)return v.jsx("p",{className:"text-sm text-gray-500",children:"No artifact files available."});const p=d?m?"Loading...":(h==null?void 0:h.content)??"":"",g=d?(h==null?void 0:h.language)??"plaintext":"plaintext";return v.jsxs("div",{className:"flex h-full min-h-[400px] gap-4",children:[v.jsx(Ore,{files:l,selectedPath:d,onSelect:c}),v.jsx("div",{className:"flex-1",children:v.jsx(Tre,{value:p,language:g,height:"100%"})})]})}const F3=_r("/evals/$runId/$evalId")({component:Mre});function Mre(){const{runId:e,evalId:t}=F3.useParams(),{data:r,isLoading:n,error:i}=Gc(e),{data:l}=bt(),[u,c]=j.useState(!1),d=(l==null?void 0:l.read_only)===!0;if(n)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"h-48 animate-pulse rounded-lg bg-gray-900"})]});if(i)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load eval: ",i.message]});const h=r==null?void 0:r.results.find(g=>g.testId===t);if(!h)return v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-6 text-center",children:v.jsxs("p",{className:"text-gray-400",children:["Eval ",v.jsx("code",{className:"text-cyan-400",children:t})," not found in run"," ",v.jsx("code",{className:"text-cyan-400",children:e}),"."]})});const m=(l==null?void 0:l.threshold)??(l==null?void 0:l.pass_threshold)??.8,p=Jr(h.score,m)&&h.executionStatus!=="error"&&h.executionStatus!=="failed";return v.jsxs("div",{className:"flex h-full flex-col gap-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsxs("p",{className:"text-sm text-gray-400",children:["Run: ",e," / Eval: ",t]}),v.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-semibold text-white",children:[v.jsx("span",{className:`text-2xl font-bold leading-none ${p?"text-emerald-400":"text-red-400"}`,children:p?"✓":"✗"}),t]})]}),!d&&v.jsx("button",{type:"button",onClick:()=>c(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run this Test"})]}),v.jsx(K3,{eval:h,runId:e}),!d&&v.jsx(hl,{open:u,onClose:()=>c(!1),prefill:{testIds:[t],target:h.target}})]})}const Y3=_r("/runs/$runId_/suite/$suite")({component:Rre});function Rre(){const{runId:e,suite:t}=Y3.useParams(),{data:r,isLoading:n,error:i}=Gc(e),{data:l}=bt(),u=(l==null?void 0:l.threshold)??(l==null?void 0:l.pass_threshold)??.8;if(n)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-5 gap-4",children:["s1","s2","s3","s4","s5"].map(x=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},x))})]});if(i)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load run: ",i.message]});const c=((r==null?void 0:r.results)??[]).filter(x=>(x.suite??"Uncategorized")===t),d=c.length,h=c.filter(x=>Jr(x.score,u)).length,m=d-h,p=d>0?h/d:0,g=c.reduce((x,S)=>x+(S.costUsd??0),0);return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:t}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:["Suite in run: ",e]})]}),v.jsx(qo,{total:d,passed:h,failed:m,passRate:p,totalCost:g>0?g:void 0}),d===0?v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:v.jsx("p",{className:"text-lg text-gray-400",children:"No evaluations in this suite"})}):v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Test ID"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Target"}),v.jsx("th",{className:"w-48 px-4 py-3 font-medium text-gray-400",children:"Score"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Duration"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Cost"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:c.map((x,S)=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3",children:v.jsx(Se,{to:"/evals/$runId/$evalId",params:{runId:e,evalId:x.testId},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:x.testId})}),v.jsx("td",{className:"px-4 py-3 text-gray-400",children:x.target??"-"}),v.jsx("td",{className:"px-4 py-3",children:x.executionStatus==="execution_error"?v.jsx("span",{className:"inline-flex rounded-full px-2 py-0.5 text-xs font-medium bg-red-900/50 text-red-400",children:"ERR"}):v.jsx(wn,{rate:x.score})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:x.durationMs!=null?`${(x.durationMs/1e3).toFixed(1)}s`:"-"}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:x.costUsd!=null?`$${x.costUsd.toFixed(4)}`:"-"})]},`${x.testId}-${S}`))})]})})]})}const G3=_r("/runs/$runId_/category/$category")({component:Dre});function Dre(){const{runId:e,category:t}=G3.useParams(),{data:r,isLoading:n,error:i}=eM(e,t);if(n)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-5 gap-4",children:["s1","s2","s3","s4","s5"].map(m=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},m))})]});if(i)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load category: ",i.message]});const l=(r==null?void 0:r.suites)??[],u=l.reduce((m,p)=>m+p.total,0),c=l.reduce((m,p)=>m+p.passed,0),d=u-c,h=u>0?c/u:0;return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:t}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:["Category in run: ",e]})]}),v.jsx(qo,{total:u,passed:c,failed:d,passRate:h}),l.length===0?v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:v.jsx("p",{className:"text-lg text-gray-400",children:"No suites in this category"})}):v.jsxs("div",{className:"space-y-3",children:[v.jsx("h3",{className:"text-sm font-medium text-gray-400",children:"Suites"}),v.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:l.map(m=>v.jsxs(Se,{to:"/runs/$runId/suite/$suite",params:{runId:e,suite:m.name},className:"rounded-lg border border-gray-800 bg-gray-900 p-3 text-left transition-colors hover:border-gray-700",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("span",{className:"text-sm font-medium text-gray-200 truncate",children:m.name}),v.jsxs("span",{className:"ml-2 text-xs text-gray-500",children:[m.passed,"/",m.total]})]}),v.jsx("div",{className:"mt-2",children:v.jsx(vm,{score:m.avg_score})}),v.jsxs("div",{className:"mt-1 flex gap-3 text-xs",children:[v.jsxs("span",{className:"text-emerald-400",children:[m.passed," passed"]}),m.failed>0&&v.jsxs("span",{className:"text-red-400",children:[m.failed," failed"]})]})]},m.name))})]})]})}const V3=_r("/projects/$projectId_/runs/$runId")({component:kre});function kre(){var O;const{projectId:e,runId:t}=V3.useParams(),{data:r,isLoading:n,error:i}=Vc(e,t),{data:l}=bt(e),[u,c]=j.useState(!1),d=(l==null?void 0:l.read_only)===!0;if(n)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-5 gap-4",children:["s1","s2","s3","s4","s5"].map(_=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},_))})]});if(i)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load run: ",i.message]});const h=(O=r==null?void 0:r.results)==null?void 0:O[0],m=h==null?void 0:h.target,p=h==null?void 0:h.experiment,g=h==null?void 0:h.timestamp,x=m?{target:m}:void 0,S=(()=>{const _=[p,m].filter(E=>E&&E!=="default");return _.length>0?_.join(" · "):t})(),w=[m,p&&p!=="default"?p:null,g?new Date(g).toLocaleString():null,r==null?void 0:r.source].filter(Boolean).join(" · ");return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:S}),v.jsx("p",{className:"mt-1 text-sm text-gray-500",children:w})]}),v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsx(R3,{results:(r==null?void 0:r.results)??[],runDir:r==null?void 0:r.run_dir,suiteFilter:r==null?void 0:r.suite_filter,target:m??void 0,projectId:e,isReadOnly:d,plannedTestCount:r==null?void 0:r.planned_test_count}),!d&&v.jsx("button",{type:"button",onClick:()=>c(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run evals"})]})]}),v.jsx(D3,{results:(r==null?void 0:r.results)??[],runId:t,projectId:e}),!d&&v.jsx(hl,{open:u,onClose:()=>c(!1),projectId:e,prefill:x})]})}const Q3=_r("/projects/$projectId_/jobs/$runId")({component:Ire});function Ire(){const{projectId:e,runId:t}=Q3.useParams(),{data:r,isLoading:n,error:i}=hb(t,e),{data:l}=bt(e),u=(l==null?void 0:l.read_only)===!0;if(n)return v.jsxs("div",{className:"space-y-4",children:[v.jsx(A0,{projectId:e}),v.jsx("div",{className:"h-8 w-48 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"h-64 animate-pulse rounded-lg bg-gray-900"})]});if(i||!r)return v.jsxs("div",{className:"space-y-4",children:[v.jsx(A0,{projectId:e}),v.jsx("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-4 text-sm text-red-400",children:i?`Failed to load run: ${i.message}`:"Run not found."})]});const c=r.status==="finished"||r.status==="failed",h={starting:"text-yellow-400",running:"text-cyan-400",finished:"text-emerald-400",failed:"text-red-400"}[r.status]??"text-gray-400";return v.jsxs("div",{className:"space-y-4",children:[v.jsx(A0,{projectId:e}),v.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-4",children:[v.jsxs("div",{className:"min-w-0",children:[v.jsx("h1",{className:"truncate font-mono text-base font-semibold text-white",children:t}),v.jsxs("p",{className:"mt-0.5 text-xs text-gray-500",children:["Started ",new Date(r.started_at).toLocaleString(),r.finished_at&&v.jsxs(v.Fragment,{children:[" · ","Finished ",new Date(r.finished_at).toLocaleString()," · ",Math.round((new Date(r.finished_at).getTime()-new Date(r.started_at).getTime())/1e3),"s"]})]})]}),v.jsxs("div",{className:"flex flex-shrink-0 items-center gap-3",children:[v.jsx(L3,{runId:t,status:r.status,isReadOnly:u,projectId:e}),v.jsx("span",{className:`text-sm font-medium ${h}`,children:r.status.charAt(0).toUpperCase()+r.status.slice(1)}),!c&&v.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-cyan-400 border-t-transparent"})]})]}),v.jsxs("div",{className:"rounded-md border border-gray-700 bg-gray-950 px-4 py-3",children:[v.jsx("p",{className:"mb-1 text-xs font-medium uppercase tracking-wider text-gray-500",children:"Command"}),v.jsx("code",{className:"break-all text-xs text-cyan-300",children:r.command})]}),r.stdout?v.jsxs("div",{children:[v.jsx("p",{className:"mb-1 text-xs font-medium uppercase tracking-wider text-gray-500",children:"Output"}),v.jsx("div",{className:"max-h-[60vh] overflow-y-auto rounded-lg border border-gray-700 bg-gray-950 p-4",children:v.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs text-gray-200",children:r.stdout})})]}):!c&&v.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[v.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-spin rounded-full border-2 border-gray-500 border-t-transparent"}),"Waiting for output…"]}),r.stderr&&v.jsxs("div",{children:[v.jsx("p",{className:"mb-1 text-xs font-medium uppercase tracking-wider text-red-500",children:"Stderr"}),v.jsx("div",{className:"max-h-48 overflow-y-auto rounded-lg border border-red-900/40 bg-red-950/20 p-4",children:v.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs text-red-300",children:r.stderr})})]}),c&&v.jsxs("p",{className:"text-xs text-gray-500",children:["Exit code:"," ",v.jsx("span",{className:r.exit_code===0?"text-emerald-400":"text-red-400",children:r.exit_code})]})]})}function A0({projectId:e}){return v.jsx(Se,{to:"/projects/$projectId",params:{projectId:e},search:{tab:"runs"},className:"text-xs text-gray-400 hover:text-cyan-400",children:"← Back to Runs"})}const X3=_r("/projects/$projectId_/experiments/$experimentName")({component:Lre});function Lre(){const{projectId:e,experimentName:t}=X3.useParams();return v.jsx($3,{experimentName:t,projectId:e})}const Z3=_r("/projects/$projectId_/evals/$runId/$evalId")({component:zre});function zre(){const{projectId:e,runId:t,evalId:r}=Z3.useParams(),{data:n,isLoading:i,error:l}=Vc(e,t),{data:u}=bt(e),[c,d]=j.useState(!1),h=(u==null?void 0:u.read_only)===!0;if(i)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"h-48 animate-pulse rounded-lg bg-gray-900"})]});if(l)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load eval: ",l.message]});const m=n==null?void 0:n.results.find(x=>x.testId===r);if(!m)return v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-6 text-center",children:v.jsxs("p",{className:"text-gray-400",children:["Eval ",v.jsx("code",{className:"text-cyan-400",children:r})," not found in run"," ",v.jsx("code",{className:"text-cyan-400",children:t}),"."]})});const p=(u==null?void 0:u.threshold)??(u==null?void 0:u.pass_threshold)??.8,g=Jr(m.score,p)&&m.executionStatus!=="error"&&m.executionStatus!=="failed";return v.jsxs("div",{className:"flex h-full flex-col gap-6",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{children:[v.jsxs("p",{className:"text-sm text-gray-400",children:["Run: ",t," / Eval: ",r]}),v.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-semibold text-white",children:[v.jsx("span",{className:`text-2xl font-bold leading-none ${g?"text-emerald-400":"text-red-400"}`,children:g?"✓":"✗"}),r]})]}),!h&&v.jsx("button",{type:"button",onClick:()=>d(!0),className:"rounded-md bg-emerald-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-emerald-500",children:"▶ Run this Test"})]}),v.jsx(K3,{eval:m,runId:t,projectId:e}),!h&&v.jsx(hl,{open:c,onClose:()=>d(!1),projectId:e,prefill:{testIds:[r],target:m.target}})]})}const W3=_r("/projects/$projectId_/runs/$runId_/suite/$suite")({component:$re});function $re(){const{projectId:e,runId:t,suite:r}=W3.useParams(),{data:n,isLoading:i,error:l}=Vc(e,t),{data:u}=bt(e),c=(u==null?void 0:u.threshold)??(u==null?void 0:u.pass_threshold)??.8;if(i)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-5 gap-4",children:["s1","s2","s3","s4","s5"].map(S=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},S))})]});if(l)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load run: ",l.message]});const d=((n==null?void 0:n.results)??[]).filter(S=>(S.suite??"Uncategorized")===r),h=d.length,m=d.filter(S=>Jr(S.score,c)).length,p=h-m,g=h>0?m/h:0,x=d.reduce((S,w)=>S+(w.costUsd??0),0);return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:r}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:["Suite in run: ",t]})]}),v.jsx(qo,{total:h,passed:m,failed:p,passRate:g,totalCost:x>0?x:void 0}),h===0?v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:v.jsx("p",{className:"text-lg text-gray-400",children:"No evaluations in this suite"})}):v.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-800",children:v.jsxs("table",{className:"w-full text-left text-sm",children:[v.jsx("thead",{className:"border-b border-gray-800 bg-gray-900/50",children:v.jsxs("tr",{children:[v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Test ID"}),v.jsx("th",{className:"px-4 py-3 font-medium text-gray-400",children:"Target"}),v.jsx("th",{className:"w-48 px-4 py-3 font-medium text-gray-400",children:"Score"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Duration"}),v.jsx("th",{className:"px-4 py-3 text-right font-medium text-gray-400",children:"Cost"})]})}),v.jsx("tbody",{className:"divide-y divide-gray-800/50",children:d.map((S,w)=>v.jsxs("tr",{className:"transition-colors hover:bg-gray-900/30",children:[v.jsx("td",{className:"px-4 py-3",children:v.jsx(Se,{to:"/projects/$projectId/evals/$runId/$evalId",params:{projectId:e,runId:t,evalId:S.testId},className:"font-medium text-cyan-400 hover:text-cyan-300 hover:underline",children:S.testId})}),v.jsx("td",{className:"px-4 py-3 text-gray-400",children:S.target??"-"}),v.jsx("td",{className:"px-4 py-3",children:S.executionStatus==="execution_error"?v.jsx("span",{className:"inline-flex rounded-full bg-red-900/50 px-2 py-0.5 text-xs font-medium text-red-400",children:"ERR"}):v.jsx(wn,{rate:S.score})}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:S.durationMs!=null?`${(S.durationMs/1e3).toFixed(1)}s`:"-"}),v.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-gray-400",children:S.costUsd!=null?`$${S.costUsd.toFixed(4)}`:"-"})]},`${S.testId}-${w}`))})]})})]})}const J3=_r("/projects/$projectId_/runs/$runId_/category/$category")({component:Bre});function Bre(){const{projectId:e,runId:t,category:r}=J3.useParams(),{data:n,isLoading:i,error:l}=Fe(nM(e,t,r));if(i)return v.jsxs("div",{className:"space-y-4",children:[v.jsx("div",{className:"h-8 w-64 animate-pulse rounded bg-gray-800"}),v.jsx("div",{className:"grid grid-cols-5 gap-4",children:["s1","s2","s3","s4","s5"].map(p=>v.jsx("div",{className:"h-20 animate-pulse rounded-lg bg-gray-900"},p))})]});if(l)return v.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/20 p-6 text-red-400",children:["Failed to load category: ",l.message]});const u=(n==null?void 0:n.suites)??[],c=u.reduce((p,g)=>p+g.total,0),d=u.reduce((p,g)=>p+g.passed,0),h=c-d,m=c>0?d/c:0;return v.jsxs("div",{className:"space-y-6",children:[v.jsxs("div",{children:[v.jsx("h1",{className:"text-2xl font-semibold text-white",children:r}),v.jsxs("p",{className:"mt-1 text-sm text-gray-400",children:["Category in run: ",t]})]}),v.jsx(qo,{total:c,passed:d,failed:h,passRate:m}),u.length===0?v.jsx("div",{className:"rounded-lg border border-gray-800 bg-gray-900 p-8 text-center",children:v.jsx("p",{className:"text-lg text-gray-400",children:"No suites in this category"})}):v.jsxs("div",{className:"space-y-3",children:[v.jsx("h3",{className:"text-sm font-medium text-gray-400",children:"Suites"}),v.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:u.map(p=>v.jsxs(Se,{to:"/projects/$projectId/runs/$runId/suite/$suite",params:{projectId:e,runId:t,suite:p.name},className:"rounded-lg border border-gray-800 bg-gray-900 p-3 text-left transition-colors hover:border-gray-700",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx("span",{className:"truncate text-sm font-medium text-gray-200",children:p.name}),v.jsxs("span",{className:"ml-2 text-xs text-gray-500",children:[p.passed,"/",p.total]})]}),v.jsx("div",{className:"mt-2",children:v.jsx(vm,{score:p.avg_score})}),v.jsxs("div",{className:"mt-1 flex gap-3 text-xs",children:[v.jsxs("span",{className:"text-emerald-400",children:[p.passed," passed"]}),p.failed>0&&v.jsxs("span",{className:"text-red-400",children:[p.failed," failed"]})]})]},p.name))})]})]})}const Ure=f8.update({id:"/settings",path:"/settings",getParentRoute:()=>mr}),qre=rre.update({id:"/",path:"/",getParentRoute:()=>mr}),Hre=k3.update({id:"/runs/$runId",path:"/runs/$runId",getParentRoute:()=>mr}),Kre=I3.update({id:"/projects/$projectId",path:"/projects/$projectId",getParentRoute:()=>mr}),Fre=z3.update({id:"/jobs/$runId",path:"/jobs/$runId",getParentRoute:()=>mr}),Yre=B3.update({id:"/experiments/$experimentName",path:"/experiments/$experimentName",getParentRoute:()=>mr}),Gre=F3.update({id:"/evals/$runId/$evalId",path:"/evals/$runId/$evalId",getParentRoute:()=>mr}),Vre=Y3.update({id:"/runs/$runId_/suite/$suite",path:"/runs/$runId/suite/$suite",getParentRoute:()=>mr}),Qre=G3.update({id:"/runs/$runId_/category/$category",path:"/runs/$runId/category/$category",getParentRoute:()=>mr}),Xre=V3.update({id:"/projects/$projectId_/runs/$runId",path:"/projects/$projectId/runs/$runId",getParentRoute:()=>mr}),Zre=Q3.update({id:"/projects/$projectId_/jobs/$runId",path:"/projects/$projectId/jobs/$runId",getParentRoute:()=>mr}),Wre=X3.update({id:"/projects/$projectId_/experiments/$experimentName",path:"/projects/$projectId/experiments/$experimentName",getParentRoute:()=>mr}),Jre=Z3.update({id:"/projects/$projectId_/evals/$runId/$evalId",path:"/projects/$projectId/evals/$runId/$evalId",getParentRoute:()=>mr}),ene=W3.update({id:"/projects/$projectId_/runs/$runId_/suite/$suite",path:"/projects/$projectId/runs/$runId/suite/$suite",getParentRoute:()=>mr}),tne=J3.update({id:"/projects/$projectId_/runs/$runId_/category/$category",path:"/projects/$projectId/runs/$runId/category/$category",getParentRoute:()=>mr}),rne={IndexRoute:qre,SettingsRoute:Ure,ExperimentsExperimentNameRoute:Yre,JobsRunIdRoute:Fre,ProjectsProjectIdRoute:Kre,RunsRunIdRoute:Hre,EvalsRunIdEvalIdRoute:Gre,ProjectsProjectIdExperimentsExperimentNameRoute:Wre,ProjectsProjectIdJobsRunIdRoute:Zre,ProjectsProjectIdRunsRunIdRoute:Xre,RunsRunIdCategoryCategoryRoute:Qre,RunsRunIdSuiteSuiteRoute:Vre,ProjectsProjectIdEvalsRunIdEvalIdRoute:Jre,ProjectsProjectIdRunsRunIdCategoryCategoryRoute:tne,ProjectsProjectIdRunsRunIdSuiteSuiteRoute:ene},nne=mr._addFileChildren(rne)._addFileTypes(),ane=new nL({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!0}}}),ine=i$({routeTree:nne}),ek=document.getElementById("root");if(!ek)throw new Error("Root element not found");M5.createRoot(ek).render(v.jsx(j.StrictMode,{children:v.jsx(aL,{client:ane,children:v.jsx(o$,{router:ine})})}));export{Ao as W,j as r};