@statforge/claudestat 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +3 -1
  2. package/dashboard/dist/assets/AnalyticsView-DDGLDoCN.js +7 -0
  3. package/dashboard/dist/assets/HistoryView-DkPfrNrv.js +1 -0
  4. package/dashboard/dist/assets/LineChart-BOWYkkEW.js +2 -0
  5. package/dashboard/dist/assets/ProjectsView-VRoRiEL4.js +6 -0
  6. package/dashboard/dist/assets/SystemView-B2zbIxhY.js +1 -0
  7. package/dashboard/dist/assets/TopView-C2qdsy0Y.js +1 -0
  8. package/dashboard/dist/assets/index-CMhe3KaT.js +84 -0
  9. package/dashboard/dist/assets/shared-BbBtsdh1.js +1 -0
  10. package/dashboard/dist/assets/{vendor-lucide-Cym0q5l_.js → vendor-lucide-ClCW-axQ.js} +79 -64
  11. package/dashboard/dist/assets/{vendor-react-B_Jzs0gY.js → vendor-react-gHSHIE2L.js} +1 -1
  12. package/dashboard/dist/index.html +3 -3
  13. package/dist/daemon.js +58 -2
  14. package/dist/db.d.ts +76 -2
  15. package/dist/db.js +295 -65
  16. package/dist/doctor.js +1 -1
  17. package/dist/enricher.d.ts +3 -2
  18. package/dist/enricher.js +12 -5
  19. package/dist/index.js +12 -1
  20. package/dist/intelligence.d.ts +55 -0
  21. package/dist/intelligence.js +163 -1
  22. package/dist/paths.d.ts +10 -0
  23. package/dist/paths.js +17 -0
  24. package/dist/pricing.d.ts +2 -0
  25. package/dist/pricing.js +12 -1
  26. package/dist/routes/events.js +136 -5
  27. package/dist/routes/history.js +6 -2
  28. package/dist/routes/intents.d.ts +1 -0
  29. package/dist/routes/intents.js +155 -0
  30. package/dist/routes/misc.js +132 -4
  31. package/dist/routes/opencode-reader.js +42 -8
  32. package/dist/routes/projects.js +10 -1
  33. package/dist/routes/replay.d.ts +1 -0
  34. package/dist/routes/replay.js +29 -0
  35. package/dist/routes/reports.js +7 -0
  36. package/dist/routes/stream.js +1 -1
  37. package/dist/routes/top.js +8 -1
  38. package/dist/watchers/adapter.d.ts +1 -0
  39. package/dist/watchers/claude-code.d.ts +16 -1
  40. package/dist/watchers/claude-code.js +201 -76
  41. package/dist/watchers/opencode.d.ts +1 -0
  42. package/dist/watchers/opencode.js +161 -23
  43. package/package.json +1 -1
  44. package/dashboard/dist/assets/AnalyticsView-5bUM3UHp.js +0 -8
  45. package/dashboard/dist/assets/HistoryView-C-AsEqos.js +0 -1
  46. package/dashboard/dist/assets/ProjectsView-D9bZBdY2.js +0 -6
  47. package/dashboard/dist/assets/SystemView-DIYDCCF3.js +0 -1
  48. package/dashboard/dist/assets/TopView-DhdLpsiA.js +0 -1
  49. package/dashboard/dist/assets/index-DgbWvj42.js +0 -84
@@ -1,8 +0,0 @@
1
- import{u as Ut,a as Xt,b as Jt,i as D,c as Zt,d as Qt,e as te,w as Je,g as mt,f as xt,h as vt,C as gt,k as W,l as ke,D as bt,m as He,E as jt,L as R,n as xe,A as Ke,o as I,p as _e,q as K,r as kt,s as Ge,t as ee,v as Ve,G as Ye,x as ue,y as we,z as qt,S as Ze,B as ei,F as ti,H as ii,I as ni,J as St,X as $e,Y as ve,K as wt,M as At,j as n,T as N,R as Qe,N as qe,O as ri}from"./index-DgbWvj42.js";import{x as g,a as T,_ as Pt,d as Ue,y as Se,q as oi,$ as ai,p as si,M as li,a0 as Ot,W as ci,Z as Xe,a1 as di,U as et,f as zt,I as _t,s as ui,a2 as fi,b as $t,a3 as tt,a4 as hi,F as pi,n as it,V as yi,Y as mi,a5 as xi,X as vi}from"./vendor-lucide-Cym0q5l_.js";import"./vendor-react-B_Jzs0gY.js";var gi=["x1","y1","x2","y2","key"],bi=["offset"];function re(e){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},re(e)}function nt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,i)}return r}function C(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?nt(Object(r),!0).forEach(function(i){ji(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):nt(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function ji(e,t,r){return t=ki(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ki(e){var t=Si(e,"string");return re(t)=="symbol"?t:t+""}function Si(e,t){if(re(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t);if(re(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ie(){return ie=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ie.apply(this,arguments)}function rt(e,t){if(e==null)return{};var r=wi(e,t),i,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)i=a[o],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function wi(e,t){if(e==null)return{};var r={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){if(t.indexOf(i)>=0)continue;r[i]=e[i]}return r}var Ai=function(t){var r=t.fill;if(!r||r==="none")return null;var i=t.fillOpacity,o=t.x,a=t.y,s=t.width,l=t.height,d=t.ry;return g.createElement("rect",{x:o,y:a,ry:d,width:s,height:l,stroke:"none",fill:r,fillOpacity:i,className:"recharts-cartesian-grid-bg"})};function Tt(e,t){var r;if(g.isValidElement(e))r=g.cloneElement(e,t);else if(te(e))r=e(t);else{var i=t.x1,o=t.y1,a=t.x2,s=t.y2,l=t.key,d=rt(t,gi),u=W(d,!1);u.offset;var c=rt(u,bi);r=g.createElement("line",ie({},c,{x1:i,y1:o,x2:a,y2:s,fill:"none",key:l}))}return r}function Pi(e){var t=e.x,r=e.width,i=e.horizontal,o=i===void 0?!0:i,a=e.horizontalPoints;if(!o||!a||!a.length)return null;var s=a.map(function(l,d){var u=C(C({},e),{},{x1:t,y1:l,x2:t+r,y2:l,key:"line-".concat(d),index:d});return Tt(o,u)});return g.createElement("g",{className:"recharts-cartesian-grid-horizontal"},s)}function Oi(e){var t=e.y,r=e.height,i=e.vertical,o=i===void 0?!0:i,a=e.verticalPoints;if(!o||!a||!a.length)return null;var s=a.map(function(l,d){var u=C(C({},e),{},{x1:l,y1:t,x2:l,y2:t+r,key:"line-".concat(d),index:d});return Tt(o,u)});return g.createElement("g",{className:"recharts-cartesian-grid-vertical"},s)}function zi(e){var t=e.horizontalFill,r=e.fillOpacity,i=e.x,o=e.y,a=e.width,s=e.height,l=e.horizontalPoints,d=e.horizontal,u=d===void 0?!0:d;if(!u||!t||!t.length)return null;var c=l.map(function(f){return Math.round(f+o-o)}).sort(function(f,p){return f-p});o!==c[0]&&c.unshift(0);var h=c.map(function(f,p){var m=!c[p+1],y=m?o+s-f:c[p+1]-f;if(y<=0)return null;var j=p%t.length;return g.createElement("rect",{key:"react-".concat(p),y:f,x:i,height:y,width:a,stroke:"none",fill:t[j],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return g.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},h)}function _i(e){var t=e.vertical,r=t===void 0?!0:t,i=e.verticalFill,o=e.fillOpacity,a=e.x,s=e.y,l=e.width,d=e.height,u=e.verticalPoints;if(!r||!i||!i.length)return null;var c=u.map(function(f){return Math.round(f+a-a)}).sort(function(f,p){return f-p});a!==c[0]&&c.unshift(0);var h=c.map(function(f,p){var m=!c[p+1],y=m?a+l-f:c[p+1]-f;if(y<=0)return null;var j=p%i.length;return g.createElement("rect",{key:"react-".concat(p),x:f,y:s,width:y,height:d,stroke:"none",fill:i[j],fillOpacity:o,className:"recharts-cartesian-grid-bg"})});return g.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},h)}var $i=function(t,r){var i=t.xAxis,o=t.width,a=t.height,s=t.offset;return mt(xt(C(C(C({},gt.defaultProps),i),{},{ticks:vt(i,!0),viewBox:{x:0,y:0,width:o,height:a}})),s.left,s.left+s.width,r)},Ti=function(t,r){var i=t.yAxis,o=t.width,a=t.height,s=t.offset;return mt(xt(C(C(C({},gt.defaultProps),i),{},{ticks:vt(i,!0),viewBox:{x:0,y:0,width:o,height:a}})),s.top,s.top+s.height,r)},se={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function Be(e){var t,r,i,o,a,s,l=Ut(),d=Xt(),u=Jt(),c=C(C({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:se.stroke,fill:(r=e.fill)!==null&&r!==void 0?r:se.fill,horizontal:(i=e.horizontal)!==null&&i!==void 0?i:se.horizontal,horizontalFill:(o=e.horizontalFill)!==null&&o!==void 0?o:se.horizontalFill,vertical:(a=e.vertical)!==null&&a!==void 0?a:se.vertical,verticalFill:(s=e.verticalFill)!==null&&s!==void 0?s:se.verticalFill,x:D(e.x)?e.x:u.left,y:D(e.y)?e.y:u.top,width:D(e.width)?e.width:u.width,height:D(e.height)?e.height:u.height}),h=c.x,f=c.y,p=c.width,m=c.height,y=c.syncWithTicks,j=c.horizontalValues,k=c.verticalValues,x=Zt(),b=Qt();if(!D(p)||p<=0||!D(m)||m<=0||!D(h)||h!==+h||!D(f)||f!==+f)return null;var w=c.verticalCoordinatesGenerator||$i,A=c.horizontalCoordinatesGenerator||Ti,P=c.horizontalPoints,O=c.verticalPoints;if((!P||!P.length)&&te(A)){var z=j&&j.length,_=A({yAxis:b?C(C({},b),{},{ticks:z?j:b.ticks}):void 0,width:l,height:d,offset:u},z?!0:y);Je(Array.isArray(_),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(re(_),"]")),Array.isArray(_)&&(P=_)}if((!O||!O.length)&&te(w)){var $=k&&k.length,v=w({xAxis:x?C(C({},x),{},{ticks:$?k:x.ticks}):void 0,width:l,height:d,offset:u},$?!0:y);Je(Array.isArray(v),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(re(v),"]")),Array.isArray(v)&&(O=v)}return g.createElement("g",{className:"recharts-cartesian-grid"},g.createElement(Ai,{fill:c.fill,fillOpacity:c.fillOpacity,x:c.x,y:c.y,width:c.width,height:c.height,ry:c.ry}),g.createElement(Pi,ie({},c,{offset:u,horizontalPoints:P,xAxis:x,yAxis:b})),g.createElement(Oi,ie({},c,{offset:u,verticalPoints:O,xAxis:x,yAxis:b})),g.createElement(zi,ie({},c,{horizontalPoints:P})),g.createElement(_i,ie({},c,{verticalPoints:O})))}Be.displayName="CartesianGrid";var Ci=["type","layout","connectNulls","ref"],Ei=["key"];function fe(e){"@babel/helpers - typeof";return fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fe(e)}function ot(e,t){if(e==null)return{};var r=Ii(e,t),i,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)i=a[o],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function Ii(e,t){if(e==null)return{};var r={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){if(t.indexOf(i)>=0)continue;r[i]=e[i]}return r}function ge(){return ge=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ge.apply(this,arguments)}function at(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,i)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?at(Object(r),!0).forEach(function(i){H(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):at(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function le(e){return Ri(e)||Bi(e)||Wi(e)||Di()}function Di(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Wi(e,t){if(e){if(typeof e=="string")return Re(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Re(e,t)}}function Bi(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Ri(e){if(Array.isArray(e))return Re(e)}function Re(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function Li(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function st(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,Et(i.key),i)}}function Ni(e,t,r){return t&&st(e.prototype,t),r&&st(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Mi(e,t,r){return t=Te(t),Fi(e,Ct()?Reflect.construct(t,r||[],Te(e).constructor):t.apply(e,r))}function Fi(e,t){if(t&&(fe(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Hi(e)}function Hi(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ct=function(){return!!e})()}function Te(e){return Te=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Te(e)}function Ki(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Le(e,t)}function Le(e,t){return Le=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},Le(e,t)}function H(e,t,r){return t=Et(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Et(e){var t=Gi(e,"string");return fe(t)=="symbol"?t:t+""}function Gi(e,t){if(fe(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t);if(fe(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var oe=(function(e){function t(){var r;Li(this,t);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return r=Mi(this,t,[].concat(o)),H(r,"state",{isAnimationFinished:!0,totalLength:0}),H(r,"generateSimpleStrokeDasharray",function(s,l){return"".concat(l,"px ").concat(s-l,"px")}),H(r,"getStrokeDasharray",function(s,l,d){var u=d.reduce(function(k,x){return k+x});if(!u)return r.generateSimpleStrokeDasharray(l,s);for(var c=Math.floor(s/u),h=s%u,f=l-s,p=[],m=0,y=0;m<d.length;y+=d[m],++m)if(y+d[m]>h){p=[].concat(le(d.slice(0,m)),[h-y]);break}var j=p.length%2===0?[0,f]:[f];return[].concat(le(t.repeat(d,c)),le(p),j).map(function(k){return"".concat(k,"px")}).join(", ")}),H(r,"id",Ve("recharts-line-")),H(r,"pathRef",function(s){r.mainCurve=s}),H(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),H(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return Ki(t,e),Ni(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var i=this.getTotalLength();this.setState({totalLength:i})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var i=this.getTotalLength();i!==this.state.totalLength&&this.setState({totalLength:i})}}},{key:"getTotalLength",value:function(){var i=this.mainCurve;try{return i&&i.getTotalLength&&i.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(i,o){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var a=this.props,s=a.points,l=a.xAxis,d=a.yAxis,u=a.layout,c=a.children,h=He(c,jt);if(!h)return null;var f=function(y,j){return{x:y.x,y:y.y,value:y.value,errorVal:ee(y.payload,j)}},p={clipPath:i?"url(#clipPath-".concat(o,")"):null};return g.createElement(R,p,h.map(function(m){return g.cloneElement(m,{key:"bar-".concat(m.props.dataKey),data:s,xAxis:l,yAxis:d,layout:u,dataPointFormatter:f})}))}},{key:"renderDots",value:function(i,o,a){var s=this.props.isAnimationActive;if(s&&!this.state.isAnimationFinished)return null;var l=this.props,d=l.dot,u=l.points,c=l.dataKey,h=W(this.props,!1),f=W(d,!0),p=u.map(function(y,j){var k=B(B(B({key:"dot-".concat(j),r:3},h),f),{},{index:j,cx:y.x,cy:y.y,value:y.value,dataKey:c,payload:y.payload,points:u});return t.renderDotItem(d,k)}),m={clipPath:i?"url(#clipPath-".concat(o?"":"dots-").concat(a,")"):null};return g.createElement(R,ge({className:"recharts-line-dots",key:"dots"},m),p)}},{key:"renderCurveStatically",value:function(i,o,a,s){var l=this.props,d=l.type,u=l.layout,c=l.connectNulls;l.ref;var h=ot(l,Ci),f=B(B(B({},W(h,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:o?"url(#clipPath-".concat(a,")"):null,points:i},s),{},{type:d,layout:u,connectNulls:c});return g.createElement(xe,ge({},f,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(i,o){var a=this,s=this.props,l=s.points,d=s.strokeDasharray,u=s.isAnimationActive,c=s.animationBegin,h=s.animationDuration,f=s.animationEasing,p=s.animationId,m=s.animateNewValues,y=s.width,j=s.height,k=this.state,x=k.prevPoints,b=k.totalLength;return g.createElement(Ke,{begin:c,duration:h,isActive:u,easing:f,from:{t:0},to:{t:1},key:"line-".concat(p),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(w){var A=w.t;if(x){var P=x.length/l.length,O=l.map(function(S,E){var J=Math.floor(E*P);if(x[J]){var Z=x[J],F=I(Z.x,S.x),Gt=I(Z.y,S.y);return B(B({},S),{},{x:F(A),y:Gt(A)})}if(m){var Vt=I(y*2,S.x),Yt=I(j/2,S.y);return B(B({},S),{},{x:Vt(A),y:Yt(A)})}return B(B({},S),{},{x:S.x,y:S.y})});return a.renderCurveStatically(O,i,o)}var z=I(0,b),_=z(A),$;if(d){var v="".concat(d).split(/[,\s]+/gim).map(function(S){return parseFloat(S)});$=a.getStrokeDasharray(_,b,v)}else $=a.generateSimpleStrokeDasharray(b,_);return a.renderCurveStatically(l,i,o,{strokeDasharray:$})})}},{key:"renderCurve",value:function(i,o){var a=this.props,s=a.points,l=a.isAnimationActive,d=this.state,u=d.prevPoints,c=d.totalLength;return l&&s&&s.length&&(!u&&c>0||!_e(u,s))?this.renderCurveWithAnimation(i,o):this.renderCurveStatically(s,i,o)}},{key:"render",value:function(){var i,o=this.props,a=o.hide,s=o.dot,l=o.points,d=o.className,u=o.xAxis,c=o.yAxis,h=o.top,f=o.left,p=o.width,m=o.height,y=o.isAnimationActive,j=o.id;if(a||!l||!l.length)return null;var k=this.state.isAnimationFinished,x=l.length===1,b=ke("recharts-line",d),w=u&&u.allowDataOverflow,A=c&&c.allowDataOverflow,P=w||A,O=K(j)?this.id:j,z=(i=W(s,!1))!==null&&i!==void 0?i:{r:3,strokeWidth:2},_=z.r,$=_===void 0?3:_,v=z.strokeWidth,S=v===void 0?2:v,E=kt(s)?s:{},J=E.clipDot,Z=J===void 0?!0:J,F=$*2+S;return g.createElement(R,{className:b},w||A?g.createElement("defs",null,g.createElement("clipPath",{id:"clipPath-".concat(O)},g.createElement("rect",{x:w?f:f-p/2,y:A?h:h-m/2,width:w?p:p*2,height:A?m:m*2})),!Z&&g.createElement("clipPath",{id:"clipPath-dots-".concat(O)},g.createElement("rect",{x:f-F/2,y:h-F/2,width:p+F,height:m+F}))):null,!x&&this.renderCurve(P,O),this.renderErrorBar(P,O),(x||s)&&this.renderDots(P,Z,O),(!y||k)&&Ge.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(i,o){return i.animationId!==o.prevAnimationId?{prevAnimationId:i.animationId,curPoints:i.points,prevPoints:o.curPoints}:i.points!==o.curPoints?{curPoints:i.points}:null}},{key:"repeat",value:function(i,o){for(var a=i.length%2!==0?[].concat(le(i),[0]):i,s=[],l=0;l<o;++l)s=[].concat(le(s),le(a));return s}},{key:"renderDotItem",value:function(i,o){var a;if(g.isValidElement(i))a=g.cloneElement(i,o);else if(te(i))a=i(o);else{var s=o.key,l=ot(o,Ei),d=ke("recharts-line-dot",typeof i!="boolean"?i.className:"");a=g.createElement(bt,ge({key:s},l,{className:d}))}return a}}])})(T.PureComponent);H(oe,"displayName","Line");H(oe,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Ye.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});H(oe,"getComposedData",function(e){var t=e.props,r=e.xAxis,i=e.yAxis,o=e.xAxisTicks,a=e.yAxisTicks,s=e.dataKey,l=e.bandSize,d=e.displayedData,u=e.offset,c=t.layout,h=d.map(function(f,p){var m=ee(f,s);return c==="horizontal"?{x:ue({axis:r,ticks:o,bandSize:l,entry:f,index:p}),y:K(m)?null:i.scale(m),value:m,payload:f}:{x:K(m)?null:r.scale(m),y:ue({axis:i,ticks:a,bandSize:l,entry:f,index:p}),value:m,payload:f}});return B({points:h,layout:c},u)});var Vi=["layout","type","stroke","connectNulls","isRange","ref"],Yi=["key"],It;function he(e){"@babel/helpers - typeof";return he=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},he(e)}function Dt(e,t){if(e==null)return{};var r=Ui(e,t),i,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)i=a[o],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function Ui(e,t){if(e==null)return{};var r={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){if(t.indexOf(i)>=0)continue;r[i]=e[i]}return r}function ne(){return ne=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ne.apply(this,arguments)}function lt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,i)}return r}function Q(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?lt(Object(r),!0).forEach(function(i){V(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):lt(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Xi(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ct(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,Bt(i.key),i)}}function Ji(e,t,r){return t&&ct(e.prototype,t),r&&ct(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Zi(e,t,r){return t=Ce(t),Qi(e,Wt()?Reflect.construct(t,r||[],Ce(e).constructor):t.apply(e,r))}function Qi(e,t){if(t&&(he(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return qi(e)}function qi(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Wt(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Wt=function(){return!!e})()}function Ce(e){return Ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ce(e)}function en(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ne(e,t)}function Ne(e,t){return Ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},Ne(e,t)}function V(e,t,r){return t=Bt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Bt(e){var t=tn(e,"string");return he(t)=="symbol"?t:t+""}function tn(e,t){if(he(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t);if(he(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ae=(function(e){function t(){var r;Xi(this,t);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return r=Zi(this,t,[].concat(o)),V(r,"state",{isAnimationFinished:!0}),V(r,"id",Ve("recharts-area-")),V(r,"handleAnimationEnd",function(){var s=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),te(s)&&s()}),V(r,"handleAnimationStart",function(){var s=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),te(s)&&s()}),r}return en(t,e),Ji(t,[{key:"renderDots",value:function(i,o,a){var s=this.props.isAnimationActive,l=this.state.isAnimationFinished;if(s&&!l)return null;var d=this.props,u=d.dot,c=d.points,h=d.dataKey,f=W(this.props,!1),p=W(u,!0),m=c.map(function(j,k){var x=Q(Q(Q({key:"dot-".concat(k),r:3},f),p),{},{index:k,cx:j.x,cy:j.y,dataKey:h,value:j.value,payload:j.payload,points:c});return t.renderDotItem(u,x)}),y={clipPath:i?"url(#clipPath-".concat(o?"":"dots-").concat(a,")"):null};return g.createElement(R,ne({className:"recharts-area-dots"},y),m)}},{key:"renderHorizontalRect",value:function(i){var o=this.props,a=o.baseLine,s=o.points,l=o.strokeWidth,d=s[0].x,u=s[s.length-1].x,c=i*Math.abs(d-u),h=we(s.map(function(f){return f.y||0}));return D(a)&&typeof a=="number"?h=Math.max(a,h):a&&Array.isArray(a)&&a.length&&(h=Math.max(we(a.map(function(f){return f.y||0})),h)),D(h)?g.createElement("rect",{x:d<u?d:d-c,y:0,width:c,height:Math.floor(h+(l?parseInt("".concat(l),10):1))}):null}},{key:"renderVerticalRect",value:function(i){var o=this.props,a=o.baseLine,s=o.points,l=o.strokeWidth,d=s[0].y,u=s[s.length-1].y,c=i*Math.abs(d-u),h=we(s.map(function(f){return f.x||0}));return D(a)&&typeof a=="number"?h=Math.max(a,h):a&&Array.isArray(a)&&a.length&&(h=Math.max(we(a.map(function(f){return f.x||0})),h)),D(h)?g.createElement("rect",{x:0,y:d<u?d:d-c,width:h+(l?parseInt("".concat(l),10):1),height:Math.floor(c)}):null}},{key:"renderClipRect",value:function(i){var o=this.props.layout;return o==="vertical"?this.renderVerticalRect(i):this.renderHorizontalRect(i)}},{key:"renderAreaStatically",value:function(i,o,a,s){var l=this.props,d=l.layout,u=l.type,c=l.stroke,h=l.connectNulls,f=l.isRange;l.ref;var p=Dt(l,Vi);return g.createElement(R,{clipPath:a?"url(#clipPath-".concat(s,")"):null},g.createElement(xe,ne({},W(p,!0),{points:i,connectNulls:h,type:u,baseLine:o,layout:d,stroke:"none",className:"recharts-area-area"})),c!=="none"&&g.createElement(xe,ne({},W(this.props,!1),{className:"recharts-area-curve",layout:d,type:u,connectNulls:h,fill:"none",points:i})),c!=="none"&&f&&g.createElement(xe,ne({},W(this.props,!1),{className:"recharts-area-curve",layout:d,type:u,connectNulls:h,fill:"none",points:o})))}},{key:"renderAreaWithAnimation",value:function(i,o){var a=this,s=this.props,l=s.points,d=s.baseLine,u=s.isAnimationActive,c=s.animationBegin,h=s.animationDuration,f=s.animationEasing,p=s.animationId,m=this.state,y=m.prevPoints,j=m.prevBaseLine;return g.createElement(Ke,{begin:c,duration:h,isActive:u,easing:f,from:{t:0},to:{t:1},key:"area-".concat(p),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(k){var x=k.t;if(y){var b=y.length/l.length,w=l.map(function(z,_){var $=Math.floor(_*b);if(y[$]){var v=y[$],S=I(v.x,z.x),E=I(v.y,z.y);return Q(Q({},z),{},{x:S(x),y:E(x)})}return z}),A;if(D(d)&&typeof d=="number"){var P=I(j,d);A=P(x)}else if(K(d)||qt(d)){var O=I(j,0);A=O(x)}else A=d.map(function(z,_){var $=Math.floor(_*b);if(j[$]){var v=j[$],S=I(v.x,z.x),E=I(v.y,z.y);return Q(Q({},z),{},{x:S(x),y:E(x)})}return z});return a.renderAreaStatically(w,A,i,o)}return g.createElement(R,null,g.createElement("defs",null,g.createElement("clipPath",{id:"animationClipPath-".concat(o)},a.renderClipRect(x))),g.createElement(R,{clipPath:"url(#animationClipPath-".concat(o,")")},a.renderAreaStatically(l,d,i,o)))})}},{key:"renderArea",value:function(i,o){var a=this.props,s=a.points,l=a.baseLine,d=a.isAnimationActive,u=this.state,c=u.prevPoints,h=u.prevBaseLine,f=u.totalLength;return d&&s&&s.length&&(!c&&f>0||!_e(c,s)||!_e(h,l))?this.renderAreaWithAnimation(i,o):this.renderAreaStatically(s,l,i,o)}},{key:"render",value:function(){var i,o=this.props,a=o.hide,s=o.dot,l=o.points,d=o.className,u=o.top,c=o.left,h=o.xAxis,f=o.yAxis,p=o.width,m=o.height,y=o.isAnimationActive,j=o.id;if(a||!l||!l.length)return null;var k=this.state.isAnimationFinished,x=l.length===1,b=ke("recharts-area",d),w=h&&h.allowDataOverflow,A=f&&f.allowDataOverflow,P=w||A,O=K(j)?this.id:j,z=(i=W(s,!1))!==null&&i!==void 0?i:{r:3,strokeWidth:2},_=z.r,$=_===void 0?3:_,v=z.strokeWidth,S=v===void 0?2:v,E=kt(s)?s:{},J=E.clipDot,Z=J===void 0?!0:J,F=$*2+S;return g.createElement(R,{className:b},w||A?g.createElement("defs",null,g.createElement("clipPath",{id:"clipPath-".concat(O)},g.createElement("rect",{x:w?c:c-p/2,y:A?u:u-m/2,width:w?p:p*2,height:A?m:m*2})),!Z&&g.createElement("clipPath",{id:"clipPath-dots-".concat(O)},g.createElement("rect",{x:c-F/2,y:u-F/2,width:p+F,height:m+F}))):null,x?null:this.renderArea(P,O),(s||x)&&this.renderDots(P,Z,O),(!y||k)&&Ge.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(i,o){return i.animationId!==o.prevAnimationId?{prevAnimationId:i.animationId,curPoints:i.points,curBaseLine:i.baseLine,prevPoints:o.curPoints,prevBaseLine:o.curBaseLine}:i.points!==o.curPoints||i.baseLine!==o.curBaseLine?{curPoints:i.points,curBaseLine:i.baseLine}:null}}])})(T.PureComponent);It=ae;V(ae,"displayName","Area");V(ae,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!Ye.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});V(ae,"getBaseValue",function(e,t,r,i){var o=e.layout,a=e.baseValue,s=t.props.baseValue,l=s??a;if(D(l)&&typeof l=="number")return l;var d=o==="horizontal"?i:r,u=d.scale.domain();if(d.type==="number"){var c=Math.max(u[0],u[1]),h=Math.min(u[0],u[1]);return l==="dataMin"?h:l==="dataMax"||c<0?c:Math.max(Math.min(u[0],u[1]),0)}return l==="dataMin"?u[0]:l==="dataMax"?u[1]:u[0]});V(ae,"getComposedData",function(e){var t=e.props,r=e.item,i=e.xAxis,o=e.yAxis,a=e.xAxisTicks,s=e.yAxisTicks,l=e.bandSize,d=e.dataKey,u=e.stackedData,c=e.dataStartIndex,h=e.displayedData,f=e.offset,p=t.layout,m=u&&u.length,y=It.getBaseValue(t,r,i,o),j=p==="horizontal",k=!1,x=h.map(function(w,A){var P;m?P=u[c+A]:(P=ee(w,d),Array.isArray(P)?k=!0:P=[y,P]);var O=P[1]==null||m&&ee(w,d)==null;return j?{x:ue({axis:i,ticks:a,bandSize:l,entry:w,index:A}),y:O?null:o.scale(P[1]),value:P,payload:w}:{x:O?null:i.scale(P[1]),y:ue({axis:o,ticks:s,bandSize:l,entry:w,index:A}),value:P,payload:w}}),b;return m||k?b=x.map(function(w){var A=Array.isArray(w.value)?w.value[0]:null;return j?{x:w.x,y:A!=null&&w.y!=null?o.scale(A):null}:{x:A!=null?i.scale(A):null,y:w.y}}):b=j?o.scale(y):i.scale(y),Q({points:x,baseLine:b,layout:p,isRange:k},f)});V(ae,"renderDotItem",function(e,t){var r;if(g.isValidElement(e))r=g.cloneElement(e,t);else if(te(e))r=e(t);else{var i=ke("recharts-area-dot",typeof e!="boolean"?e.className:""),o=t.key,a=Dt(t,Yi);r=g.createElement(bt,ne({},a,{key:o,className:i}))}return r});function pe(e){"@babel/helpers - typeof";return pe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pe(e)}function nn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function rn(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,Nt(i.key),i)}}function on(e,t,r){return t&&rn(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function an(e,t,r){return t=Ee(t),sn(e,Rt()?Reflect.construct(t,r||[],Ee(e).constructor):t.apply(e,r))}function sn(e,t){if(t&&(pe(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ln(e)}function ln(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Rt(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Rt=function(){return!!e})()}function Ee(e){return Ee=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ee(e)}function cn(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Me(e,t)}function Me(e,t){return Me=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},Me(e,t)}function Lt(e,t,r){return t=Nt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Nt(e){var t=dn(e,"string");return pe(t)=="symbol"?t:t+""}function dn(e,t){if(pe(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t);if(pe(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var De=(function(e){function t(){return nn(this,t),an(this,t,arguments)}return cn(t,e),on(t,[{key:"render",value:function(){return null}}])})(T.Component);Lt(De,"displayName","ZAxis");Lt(De,"defaultProps",{zAxisId:0,range:[64,64],scale:"auto",type:"number"});var un=["option","isActive"];function be(){return be=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},be.apply(this,arguments)}function fn(e,t){if(e==null)return{};var r=hn(e,t),i,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)i=a[o],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function hn(e,t){if(e==null)return{};var r={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){if(t.indexOf(i)>=0)continue;r[i]=e[i]}return r}function pn(e){var t=e.option,r=e.isActive,i=fn(e,un);return typeof t=="string"?T.createElement(Ze,be({option:T.createElement(ei,be({type:t},i)),isActive:r,shapeType:"symbols"},i)):T.createElement(Ze,be({option:t,isActive:r,shapeType:"symbols"},i))}function ye(e){"@babel/helpers - typeof";return ye=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ye(e)}function je(){return je=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},je.apply(this,arguments)}function dt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,i)}return r}function L(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?dt(Object(r),!0).forEach(function(i){q(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dt(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function yn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ut(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,Ft(i.key),i)}}function mn(e,t,r){return t&&ut(e.prototype,t),r&&ut(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function xn(e,t,r){return t=Ie(t),vn(e,Mt()?Reflect.construct(t,r||[],Ie(e).constructor):t.apply(e,r))}function vn(e,t){if(t&&(ye(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return gn(e)}function gn(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Mt(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Mt=function(){return!!e})()}function Ie(e){return Ie=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ie(e)}function bn(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Fe(e,t)}function Fe(e,t){return Fe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},Fe(e,t)}function q(e,t,r){return t=Ft(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ft(e){var t=jn(e,"string");return ye(t)=="symbol"?t:t+""}function jn(e,t){if(ye(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t);if(ye(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var We=(function(e){function t(){var r;yn(this,t);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return r=xn(this,t,[].concat(o)),q(r,"state",{isAnimationFinished:!1}),q(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0})}),q(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1})}),q(r,"id",Ve("recharts-scatter-")),r}return bn(t,e),mn(t,[{key:"renderSymbolsStatically",value:function(i){var o=this,a=this.props,s=a.shape,l=a.activeShape,d=a.activeIndex,u=W(this.props,!1);return i.map(function(c,h){var f=d===h,p=f?l:s,m=L(L({},u),c);return g.createElement(R,je({className:"recharts-scatter-symbol",key:"symbol-".concat(c==null?void 0:c.cx,"-").concat(c==null?void 0:c.cy,"-").concat(c==null?void 0:c.size,"-").concat(h)},ti(o.props,c,h),{role:"img"}),g.createElement(pn,je({option:p,isActive:f,key:"symbol-".concat(h)},m)))})}},{key:"renderSymbolsWithAnimation",value:function(){var i=this,o=this.props,a=o.points,s=o.isAnimationActive,l=o.animationBegin,d=o.animationDuration,u=o.animationEasing,c=o.animationId,h=this.state.prevPoints;return g.createElement(Ke,{begin:l,duration:d,isActive:s,easing:u,from:{t:0},to:{t:1},key:"pie-".concat(c),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(f){var p=f.t,m=a.map(function(y,j){var k=h&&h[j];if(k){var x=I(k.cx,y.cx),b=I(k.cy,y.cy),w=I(k.size,y.size);return L(L({},y),{},{cx:x(p),cy:b(p),size:w(p)})}var A=I(0,y.size);return L(L({},y),{},{size:A(p)})});return g.createElement(R,null,i.renderSymbolsStatically(m))})}},{key:"renderSymbols",value:function(){var i=this.props,o=i.points,a=i.isAnimationActive,s=this.state.prevPoints;return a&&o&&o.length&&(!s||!_e(s,o))?this.renderSymbolsWithAnimation():this.renderSymbolsStatically(o)}},{key:"renderErrorBar",value:function(){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var o=this.props,a=o.points,s=o.xAxis,l=o.yAxis,d=o.children,u=He(d,jt);return u?u.map(function(c,h){var f=c.props,p=f.direction,m=f.dataKey;return g.cloneElement(c,{key:"".concat(p,"-").concat(m,"-").concat(a[h]),data:a,xAxis:s,yAxis:l,layout:p==="x"?"vertical":"horizontal",dataPointFormatter:function(j,k){return{x:j.cx,y:j.cy,value:p==="x"?+j.node.x:+j.node.y,errorVal:ee(j,k)}}})}):null}},{key:"renderLine",value:function(){var i=this.props,o=i.points,a=i.line,s=i.lineType,l=i.lineJointType,d=W(this.props,!1),u=W(a,!1),c,h;if(s==="joint")c=o.map(function(b){return{x:b.cx,y:b.cy}});else if(s==="fitting"){var f=ii(o),p=f.xmin,m=f.xmax,y=f.a,j=f.b,k=function(w){return y*w+j};c=[{x:p,y:k(p)},{x:m,y:k(m)}]}var x=L(L(L({},d),{},{fill:"none",stroke:d&&d.fill},u),{},{points:c});return g.isValidElement(a)?h=g.cloneElement(a,x):te(a)?h=a(x):h=g.createElement(xe,je({},x,{type:l})),g.createElement(R,{className:"recharts-scatter-line",key:"recharts-scatter-line"},h)}},{key:"render",value:function(){var i=this.props,o=i.hide,a=i.points,s=i.line,l=i.className,d=i.xAxis,u=i.yAxis,c=i.left,h=i.top,f=i.width,p=i.height,m=i.id,y=i.isAnimationActive;if(o||!a||!a.length)return null;var j=this.state.isAnimationFinished,k=ke("recharts-scatter",l),x=d&&d.allowDataOverflow,b=u&&u.allowDataOverflow,w=x||b,A=K(m)?this.id:m;return g.createElement(R,{className:k,clipPath:w?"url(#clipPath-".concat(A,")"):null},x||b?g.createElement("defs",null,g.createElement("clipPath",{id:"clipPath-".concat(A)},g.createElement("rect",{x:x?c:c-f/2,y:b?h:h-p/2,width:x?f:f*2,height:b?p:p*2}))):null,s&&this.renderLine(),this.renderErrorBar(),g.createElement(R,{key:"recharts-scatter-symbols"},this.renderSymbols()),(!y||j)&&Ge.renderCallByParent(this.props,a))}}],[{key:"getDerivedStateFromProps",value:function(i,o){return i.animationId!==o.prevAnimationId?{prevAnimationId:i.animationId,curPoints:i.points,prevPoints:o.curPoints}:i.points!==o.curPoints?{curPoints:i.points}:null}}])})(T.PureComponent);q(We,"displayName","Scatter");q(We,"defaultProps",{xAxisId:0,yAxisId:0,zAxisId:0,legendType:"circle",lineType:"joint",lineJointType:"linear",data:[],shape:"circle",hide:!1,isAnimationActive:!Ye.isSsr,animationBegin:0,animationDuration:400,animationEasing:"linear"});q(We,"getComposedData",function(e){var t=e.xAxis,r=e.yAxis,i=e.zAxis,o=e.item,a=e.displayedData,s=e.xAxisTicks,l=e.yAxisTicks,d=e.offset,u=o.props.tooltipType,c=He(o.props.children,ni),h=K(t.dataKey)?o.props.dataKey:t.dataKey,f=K(r.dataKey)?o.props.dataKey:r.dataKey,p=i&&i.dataKey,m=i?i.range:De.defaultProps.range,y=m&&m[0],j=t.scale.bandwidth?t.scale.bandwidth():0,k=r.scale.bandwidth?r.scale.bandwidth():0,x=a.map(function(b,w){var A=ee(b,h),P=ee(b,f),O=!K(p)&&ee(b,p)||"-",z=[{name:K(t.dataKey)?o.props.name:t.name||t.dataKey,unit:t.unit||"",value:A,payload:b,dataKey:h,type:u},{name:K(r.dataKey)?o.props.name:r.name||r.dataKey,unit:r.unit||"",value:P,payload:b,dataKey:f,type:u}];O!=="-"&&z.push({name:i.name||i.dataKey,unit:i.unit||"",value:O,payload:b,dataKey:p,type:u});var _=ue({axis:t,ticks:s,bandSize:j,entry:b,index:w,dataKey:h}),$=ue({axis:r,ticks:l,bandSize:k,entry:b,index:w,dataKey:f}),v=O!=="-"?i.scale(O):y,S=Math.sqrt(Math.max(v,0)/Math.PI);return L(L({},b),{},{cx:_,cy:$,x:_-S,y:$-S,xAxis:t,yAxis:r,zAxis:i,width:2*S,height:2*S,size:v,node:{x:A,y:P,z:O},tooltipPayload:z,tooltipPosition:{x:_,y:$},payload:b},c&&c[w]&&c[w].props)});return L({points:x},d)});var kn=St({chartName:"LineChart",GraphicalChild:oe,axisComponents:[{axisType:"xAxis",AxisComp:$e},{axisType:"yAxis",AxisComp:ve}],formatAxisMap:wt}),Sn=St({chartName:"ComposedChart",GraphicalChild:[oe,ae,At,We],axisComponents:[{axisType:"xAxis",AxisComp:$e},{axisType:"yAxis",AxisComp:ve},{axisType:"zAxis",AxisComp:De}],formatAxisMap:wt});const U={sonnet:6.6,haiku:1.76,opus:33};function Ht(e){return e!=null&&e.includes("opus")?13.5:e!=null&&e.includes("haiku")?.22:2.7}function wn(e){return e.includes("opus")?U.opus:e.includes("haiku")?U.haiku:U.sonnet}function An(e){return e.includes("opus")?"Opus":e.includes("haiku")?"Haiku":"Sonnet"}function X(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function Y(e){return e===0?"$0.00":e<.001?"<$0.001":e<.01?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function Pn(e,t=5){const r=[];let i=0,o=[];function a(s,l){if(l.length===0)return;let d=0;for(;d<l.length;){const u=l[d].tool_name;let c=d+1;for(;c<l.length&&l[c].tool_name===u;)c++;const h=c-d;if(h>=t){const f=l.slice(d,c);let p,m=!1;if(["Read","Edit","Write","Glob","Grep"].includes(u)){const y=new Set;for(const j of f)try{const k=JSON.parse(j.tool_input||"{}"),x=k.file_path||k.pattern||k.path||"";x&&y.add(x.split("/").pop()||x)}catch{}if(m=y.size>1,p=y.size===1?[...y][0]:y.size>1?`${y.size} different files`:void 0,m&&h<6){d=c;continue}}else if(u.includes("mem_save")){const y=new Set;for(const j of f)try{const k=JSON.parse(j.tool_input||"{}");k.topic&&y.add(k.topic)}catch{}if(m=y.size>1,p=y.size===1?[...y][0]:void 0,m){d=c;continue}}else if(u==="Bash")try{const y=JSON.parse(f[0].tool_input||"{}").command||"";p=y.length>50?y.slice(0,48)+"…":y}catch{}r.push({blockIndex:s+1,toolName:u,count:h,detail:p,multiFile:m})}d=c}}for(const s of e)s.type==="Stop"?(a(i,o),i++,o=[]):(s.type==="Done"||s.type==="PreToolUse")&&s.tool_name&&o.push(s);return o.length>0&&a(i,o),r}function ft(e,t,r){switch(e){case"Read":return t?"Claude is reading different files in sequence without processing information between reads. Group exploration with Glob/Grep first to reduce the number of Reads.":`"${r||"the file"}" was read multiple times in a row. Use offset+limit to read only the necessary section, or Grep to search without reading the entire file. Re-reading the same file wastes context tokens.`;case"Edit":return`"${r||"the file"}" was edited multiple times in a row. This happens when instructions are imprecise — Claude attempts the edit, fails or it doesn't match expectations, and retries. Be more specific: indicate the exact change (old_string → new_string) instead of describing the result.`;case"Write":return`"${r||"the file"}" was overwritten multiple times. Consolidate all changes into a single instruction instead of writing intermediate versions.`;case"Bash":return`Repeated command: "${r||"…"}". Bash loops are usually retries due to error. Verify that the previous command succeeded before continuing, or ask Claude to show the error output.`;case"Grep":case"Glob":return"Repeated searches with similar patterns. Claude is searching for something it can't find. Try a broader pattern or use Read to see the directory structure directly.";default:return e.includes("mem_save")?`The same topic "${r||"…"}" was saved in Engram multiple times in a row. Use mem_update to edit an existing observation instead of creating duplicates.`:`The tool ${e} was executed multiple times in a row. Check if Claude is ignoring previous results.`}}function On(e,t,r,i){var a;const o=[];if(r&&r.length>0){const s=Pn(r,5),l=new Map;for(const d of s){const u=l.get(d.toolName)||[];u.push(d),l.set(d.toolName,u)}for(const[d,u]of l){const c=u.map(m=>`#${m.blockIndex}`).join(", "),h=u.reduce((m,y)=>m+y.count,0),f=u[0],p=(a=i==null?void 0:i.find(m=>m.index===f.blockIndex))==null?void 0:a.text;o.push({level:"error",title:`Loop: ${d} ×${h} — bloques ${c}`,text:ft(d,f.multiFile,f.detail),prompt:p,blockIndex:f.blockIndex})}}else if(e!=null&&e.loops&&e.loops.length>0)for(const s of e.loops)o.push({level:"error",title:`Loop: ${s.toolName} ×${s.count}`,text:ft(s.toolName,!1)});if(r&&r.length>0){const s=new Map;for(const d of r)if(d.tool_name==="Read"&&d.type==="Done"&&d.tool_input)try{const u=JSON.parse(d.tool_input).file_path||"";u&&s.set(u,(s.get(u)||0)+1)}catch{}const l=[...s.entries()].filter(([,d])=>d>=5);if(l.length>0){const d=l.map(([u,c])=>`${u.split("/").pop()} (×${c})`).join(", ");o.push({level:"warning",title:`Scattered re-reads: ${l.length} file${l.length>1?"s":""}`,text:`${d}. These reads are not consecutive but add up to many context tokens. Consider saving the structure mentally before continuing to edit, or use Grep instead of reading the entire file.`})}}if(e){const s=e.input_tokens+e.cache_read+e.cache_creation,l=s>5e3?e.cache_read/s:-1;l>=0&&l<.3&&o.push({level:"warning",title:`Low cache hit: ${Math.round(l*100)}%`,text:"Claude caches context automatically in long sessions. Avoid manually clearing history and work in continuous sessions to accumulate cache."})}if(e&&e.efficiency_score>0&&e.efficiency_score<70&&o.push({level:"warning",title:`Low efficiency: ${e.efficiency_score}/100`,text:"Loops and re-reads are consuming tokens unnecessarily. Check if Claude is repeating steps or if instructions are ambiguous."}),t&&t.burnRateTokensPerMin>6e3&&o.push({level:"info",title:`High burn rate: ${t.burnRateTokensPerMin.toLocaleString()} tok/min`,text:"You are consuming tokens very quickly. Consider asking for more concise responses, avoid attaching large complete files, or break the task into steps."}),r&&r.length>0){const s=r.filter(c=>c.type==="Done"),l=s.filter(c=>c.tool_name==="Bash").length,d=s.filter(c=>c.tool_name==="Read").length,u=s.filter(c=>c.tool_name==="Grep").length;l>6&&u<Math.floor(l*.3)&&d>4&&o.push({level:"info",title:`Bash+Read without Grep (${l} Bash, ${d} Read)`,text:"You are combining Bash and Read to search for information. Grep is more efficient for searching within files — use Grep before Read when you don't know what line something is on."})}if(t&&t.cyclePct>70&&o.push({level:t.cyclePct>85?"error":"warning",title:`Quota at ${t.cyclePct}%`,text:`You used ${t.cyclePrompts}/${t.cycleLimit} prompts in the 5h window. Group several changes in a single message instead of sending one by one.`}),e&&e.cache_read>3e4){const s=e.cache_read/1e6*Ht(e.model);s>.02&&o.push({level:"success",title:`Optimal cache — saving ${Y(s)}`,text:"You are making good use of prompt cache. Long and continuous sessions maximize savings."})}return e&&e.efficiency_score>=90&&o.push({level:"success",title:`Excellent efficiency: ${e.efficiency_score}/100`,text:"No loops detected in this session. Good work pace."}),o}function M({children:e,style:t}){return n.jsx("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"14px 16px",...t},children:e})}function G({icon:e,title:t,subtitle:r,color:i="#58a6ff"}){return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:12},children:[n.jsx(e,{size:13,color:i}),n.jsx("span",{style:{fontSize:12,color:"#e6edf3",fontWeight:700},children:t}),r&&n.jsx("span",{style:{fontSize:10,color:"#484f58",marginLeft:2},children:r})]})}function ze({content:e,position:t="bottom",align:r="left",style:i}){return n.jsx(N,{position:t,align:r,content:e,children:n.jsx(_t,{size:9,color:"#3d444d",style:{cursor:"help",...i}})})}function zn({quota:e,cost:t}){const r=(t==null?void 0:t.context_used)??0,i=(t==null?void 0:t.context_window)??2e5,o=Math.round(i*.85),a=r>0&&o>0?Math.min(100,Math.round(r/o*100)):null,s=a!==null?100-a:null,l=s===null?"#484f58":s<20?"#f85149":s<40?"#d29922":"#3fb950",d=(t==null?void 0:t.cost_usd)??0,u=(t==null?void 0:t.input_tokens)??0,c=(t==null?void 0:t.output_tokens)??0,h=(t==null?void 0:t.cache_read)??0,f=(t==null?void 0:t.model)??null,p=e.burnRateTokensPerMin??0,m=f?f.replace("claude-","").replace(/-\d{8}$/,""):null;return n.jsxs(M,{style:{borderColor:"#30363d"},children:[n.jsx(G,{icon:Se,title:"Current status",subtitle:"real-time",color:"#58a6ff"}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:12},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6},children:[n.jsx(oi,{size:10,color:"#484f58"}),n.jsx("span",{style:{fontSize:10,color:"#484f58",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Context"}),n.jsx(ze,{position:"bottom",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:4},children:"Free context space"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.6},children:["Percentage available before Claude activates auto-compact.",n.jsx("br",{}),"Compact occurs at 85% of the window limit (normally 200K tokens).",n.jsx("br",{}),n.jsx("span",{style:{color:"#d29922"},children:"Below 20%: consider using /clear."})]})]})})]}),s!==null?n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{fontSize:26,fontWeight:700,color:l,lineHeight:1,fontVariantNumeric:"tabular-nums"},children:[s,"%"]}),n.jsx("div",{style:{fontSize:9,color:l,opacity:.7,lineHeight:1,marginBottom:4},children:"free"}),n.jsxs("div",{style:{fontSize:9,color:"#484f58",marginBottom:6},children:[Math.round(r/1e3),"k used · limit ",Math.round(o/1e3),"k"]}),n.jsx("div",{style:{width:"100%",height:4,background:"#21262d",borderRadius:2,overflow:"hidden"},children:n.jsx("div",{style:{width:`${a}%`,height:"100%",background:l,borderRadius:2,transition:"width 0.5s"}})}),n.jsx("div",{style:{fontSize:9,color:"#3d444d",marginTop:4},children:s<20?"⚠ Consider /clear soon":s<40?"Moderate — ok for now":"No context pressure"})]}):n.jsx("div",{style:{fontSize:12,color:"#484f58"},children:"Waiting for data…"})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6},children:[n.jsx(Se,{size:10,color:"#484f58"}),n.jsx("span",{style:{fontSize:10,color:"#484f58",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Current session"}),n.jsx(ze,{position:"bottom",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:4},children:"Cost of this session"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.6},children:["Accumulated from the first message of the active session.",n.jsx("br",{}),n.jsx("span",{style:{color:"#79c0ff"},children:"in"})," = tokens sent to Claude (context + message).",n.jsx("br",{}),n.jsx("span",{style:{color:"#56d364"},children:"out"})," = tokens generated by Claude.",n.jsx("br",{}),"cache = tokens reused (~10× cheaper than fresh input)."]})]})})]}),d>0?n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:26,fontWeight:700,color:"#e6edf3",lineHeight:1,fontVariantNumeric:"tabular-nums"},children:Y(d)}),n.jsxs("div",{style:{fontSize:9,color:"#484f58",marginTop:6,lineHeight:2},children:[n.jsx("span",{style:{color:"#79c0ff"},children:"in"})," ",X(u),h>0&&n.jsxs("span",{style:{color:"#3d444d"},children:[" · ",X(h)," cache"]}),n.jsx("br",{}),n.jsx("span",{style:{color:"#56d364"},children:"out"})," ",X(c)]})]}):n.jsx("div",{style:{fontSize:12,color:"#484f58"},children:"No active session"})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6},children:[n.jsx(ai,{size:10,color:"#484f58"}),n.jsx("span",{style:{fontSize:10,color:"#484f58",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Model"}),n.jsx(ze,{position:"bottom",align:"right",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:4},children:"Active model"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.6},children:["Claude model used in the current session.",n.jsx("br",{}),"The ",n.jsx("span",{style:{color:"#d29922"},children:"burn rate"})," indicates tokens consumed per minute in real time — useful for estimating how long the quota will last before the next 5h reset."]})]})})]}),m?n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:15,fontWeight:700,color:"#e6edf3",lineHeight:1.3},children:m}),n.jsx("div",{style:{fontSize:9,color:"#3d444d",marginTop:3,wordBreak:"break-all"},children:f})]}):n.jsx("div",{style:{fontSize:12,color:"#484f58"},children:"—"}),p>0&&n.jsx(N,{position:"top",align:"right",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#d29922",fontWeight:700,fontSize:11,marginBottom:3},children:"Current burn rate"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Tokens consumed per minute in this session.",n.jsx("br",{}),"High burn rate = large context or long responses.",n.jsx("br",{}),"More than 6,000 tok/min can drain quota quickly."]})]}),children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:8,cursor:"help"},children:[n.jsx(si,{size:9,color:"#d29922"}),n.jsxs("span",{style:{fontSize:10,color:"#d29922",fontWeight:600,fontVariantNumeric:"tabular-nums"},children:[p.toLocaleString()," tok/min"]})]})})]})]})]})}function _n({stats:e}){const t=e.today,r=e.todayLabel,i=e.last7;if(!t&&i.messages===0)return n.jsxs(M,{children:[n.jsx(G,{icon:Se,title:"Activity (stats-cache.json)"}),n.jsx("span",{style:{fontSize:12,color:"#484f58"},children:"No data yet in stats-cache.json"})]});const o=[{label:"Messages",icon:li,today:(t==null?void 0:t.messages)??0,week:i.messages,color:"#58a6ff",tooltip:`Total messages (human + assistant).
3
- Divide by 2 to estimate real prompts.
4
- Source: ~/.claude/stats-cache.json`},{label:"Sessions",icon:Ot,today:(t==null?void 0:t.sessions)??0,week:i.sessions,color:"#3fb950",tooltip:`Different conversations started with Claude Code.
5
- Each time you run "claude" in a directory counts as a session.`},{label:"Tools",icon:ci,today:(t==null?void 0:t.tools)??0,week:i.tools,color:"#d29922",tooltip:`Tool calls executed (Read, Edit, Bash, Grep…).
6
- High number indicates code-intensive sessions.`},{label:"Out tokens",icon:Xe,today:(t==null?void 0:t.outputTokens)??0,week:i.outputTokens,color:"#a371f7",fmt:X,tooltip:`Tokens generated by Claude in responses.
7
- These most influence session cost.`}];return n.jsxs(M,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx(di,{size:13,color:"#58a6ff"}),n.jsx("span",{style:{fontSize:12,color:"#e6edf3",fontWeight:700},children:"Activity"}),r&&n.jsxs("span",{style:{fontSize:10,color:"#484f58",marginLeft:2},children:[r," / 7 days"]})]}),e.cacheDate&&n.jsxs("span",{style:{fontSize:9,color:"#3d444d"},children:["cache: ",e.cacheDate]})]}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:10,justifyItems:"center"},children:o.map(a=>{const s=a.fmt??(l=>l.toLocaleString());return n.jsx(N,{position:"bottom",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:a.color,fontWeight:700,fontSize:11,marginBottom:4},children:a.label}),n.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5,whiteSpace:"pre-line"},children:a.tooltip})]}),children:n.jsxs("div",{style:{textAlign:"center",cursor:"help"},children:[n.jsx(a.icon,{size:11,color:a.color,style:{marginBottom:4}}),n.jsx("div",{style:{fontSize:9,color:"#6e7681",marginBottom:2,fontWeight:600},children:a.label}),n.jsx("div",{style:{fontSize:16,fontWeight:700,color:a.color,lineHeight:1,fontVariantNumeric:"tabular-nums"},children:s(a.today)}),n.jsx("div",{style:{fontSize:9,color:"#484f58",marginBottom:4},children:r??"—"}),n.jsx("div",{style:{fontSize:11,color:"#6e7681",fontVariantNumeric:"tabular-nums"},children:s(a.week)}),n.jsx("div",{style:{fontSize:9,color:"#3d444d"},children:"7 days"})]})},a.label)})}),n.jsxs("div",{style:{fontSize:9,color:"#3d444d",marginTop:10},children:["Source: ~/.claude/stats-cache.json · Messages include human + assistant (÷2 ≈ real prompts) · ",e.allTime.sessions," total sessions"]}),e.cacheIsStale&&n.jsxs("div",{style:{fontSize:9,color:"#d29922",marginTop:4},children:["⚠ Stale cache (",e.cacheDate,") — Claude Code updates this file when each CLI session ends"]})]})}function $n({quota:e}){const t=[{label:"Sonnet",color:"#58a6ff",hours:e.weeklyHoursSonnet,limit:e.weeklyLimitSonnet,tokens:e.weeklyTokensSonnet??0,price:U.sonnet},{label:"Haiku",color:"#3fb950",hours:e.weeklyHoursHaiku,limit:0,tokens:e.weeklyTokensHaiku??0,price:U.haiku},{label:"Opus",color:"#d29922",hours:e.weeklyHoursOpus,limit:e.weeklyLimitOpus,tokens:e.weeklyTokensOpus??0,price:U.opus}].filter(o=>o.hours>0||o.tokens>0),r=t.reduce((o,a)=>o+a.tokens/1e6*a.price,0),i=t.reduce((o,a)=>o+a.tokens,0);return n.jsxs(M,{children:[n.jsx(G,{icon:fi,title:"Models this week"}),t.length===0?n.jsx("span",{style:{fontSize:12,color:"#484f58"},children:"No activity this week"}):n.jsxs(n.Fragment,{children:[t.map(o=>{const a=o.limit>0?Math.min(100,o.hours/o.limit*100):0,s=o.tokens/1e6*o.price,l=i>0?Math.round(o.tokens/i*100):0;return n.jsxs("div",{style:{marginBottom:10},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[n.jsx(N,{position:"bottom",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:o.color,fontWeight:700,fontSize:11,marginBottom:3},children:o.label}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Estimated price: ~$",o.price,"/M tokens (blended input/output)",n.jsx("br",{}),"Hours = 5 min windows where Claude used this model",n.jsx("br",{}),o.limit>0?`Max weekly limit: ${o.limit}h`:"No weekly limit configured"]})]}),children:n.jsx("span",{style:{width:46,fontSize:11,color:o.color,fontWeight:700,flexShrink:0,cursor:"help"},children:o.label})}),n.jsx("span",{style:{fontSize:13,color:"#e6edf3",fontWeight:600},children:o.hours>0?`${o.hours}h`:"—"}),o.limit>0&&n.jsxs("span",{style:{fontSize:10,color:"#484f58"},children:["/ ",o.limit,"h"]}),n.jsx("div",{style:{flex:1}}),n.jsx("span",{style:{fontSize:10,color:"#6e7681"},children:X(o.tokens)}),n.jsx("span",{style:{fontSize:10,color:"#3d444d"},children:"·"}),n.jsxs("span",{style:{fontSize:10,color:"#484f58"},children:[l,"%"]}),n.jsxs("span",{style:{fontSize:10,color:"#3fb950",marginLeft:4},children:["~",Y(s)]})]}),o.limit>0&&o.hours>0&&n.jsx("div",{style:{height:3,background:"#21262d",borderRadius:2,overflow:"hidden"},children:n.jsx("div",{style:{width:`${a}%`,height:"100%",background:a>85?"#f85149":a>65?"#d29922":o.color,borderRadius:2}})}),o.limit===0&&o.tokens>0&&n.jsx("div",{style:{height:3,background:"#21262d",borderRadius:2,overflow:"hidden"},children:n.jsx("div",{style:{width:`${l}%`,height:"100%",background:o.color+"aa",borderRadius:2}})})]},o.label)}),n.jsxs("div",{style:{borderTop:"1px solid #21262d",paddingTop:8,marginTop:4,display:"flex",gap:16},children:[n.jsxs("div",{children:[n.jsxs("div",{style:{fontSize:11,color:"#8b949e"},children:[X(i)," tokens"]}),n.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"total week"})]}),n.jsxs("div",{children:[n.jsxs("div",{style:{fontSize:11,color:"#3fb950"},children:["~",Y(r)]}),n.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"estimated cost"})]})]}),n.jsx("div",{style:{fontSize:9,color:"#3d444d",marginTop:6},children:"Hours = 5 min active windows · Tokens = input + output · Estimated blended price"})]})]})}const Tn={"cache hit":'Tokens served from prompt cache. They are ~10× cheaper than fresh input. Indicates how much context Claude already "remembered" without reprocessing.',"cache create":"Tokens written to cache for the first time. Paid once and reused in subsequent reads. More expensive than fresh input but amortize over time.","input fresh":"New context that Claude processed without prior cache — full input price.",output:"Tokens generated by Claude in responses. They are the most expensive (~3× more than input in Sonnet)."};function Cn({cost:e}){const{input_tokens:t,cache_read:r,cache_creation:i,output_tokens:o}=e,a=t+r+i+o,s=a>0?Math.round(r/(t+r+i)*100):0,l=r/1e6*Ht(e.model),d=s>=70?"#3fb950":s>=40?"#d29922":"#f85149",u=[{label:"cache hit",color:"#3fb95099",tokens:r,pct:a>0?r/a*100:0},{label:"cache create",color:"#58a6ff55",tokens:i,pct:a>0?i/a*100:0},{label:"input fresh",color:"#8b949e55",tokens:t,pct:a>0?t/a*100:0},{label:"output",color:"#d2992255",tokens:o,pct:a>0?o/a*100:0}].filter(c=>c.tokens>0);return n.jsxs(M,{children:[n.jsx(G,{icon:Pt,title:"Cache efficiency",subtitle:"current session",color:d}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:10},children:[n.jsxs("span",{style:{fontSize:28,fontWeight:700,color:d,fontVariantNumeric:"tabular-nums",lineHeight:1},children:[s,"%"]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,color:"#e6edf3"},children:"cache hit rate"}),l>.001&&n.jsxs("div",{style:{fontSize:10,color:"#3fb950"},children:["~",Y(l)," saved"]}),n.jsx(N,{position:"bottom",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:3},children:"Why 70%?"}),n.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:"Below 70% cache savings are marginal. In long and continuous sessions hit rate naturally rises. Avoid using /clear in the middle of a session to not lose accumulated cache."})]}),children:n.jsx("span",{style:{fontSize:9,color:"#484f58",cursor:"help",textDecoration:"underline dotted"},children:"target ≥70%"})})]})]}),n.jsx("div",{style:{height:8,background:"#21262d",borderRadius:4,overflow:"hidden",display:"flex",marginBottom:10},children:u.map(c=>n.jsx("div",{style:{width:`${c.pct}%`,height:"100%",background:c.color}},c.label))}),n.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 14px"},children:u.map(c=>n.jsx(N,{position:"top",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:c.color.substring(0,7),fontWeight:700,fontSize:11,marginBottom:3},children:c.label}),n.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:Tn[c.label]??""})]}),children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,cursor:"help"},children:[n.jsx("div",{style:{width:8,height:8,borderRadius:2,background:c.color,flexShrink:0}}),n.jsx("span",{style:{fontSize:10,color:"#6e7681"},children:X(c.tokens)}),n.jsx("span",{style:{fontSize:10,color:"#484f58"},children:c.label})]})},c.label))})]})}function En({cost:e}){const{loops:t,efficiency_score:r}=e,i=(t==null?void 0:t.reduce((s,l)=>s+l.count,0))??0,o=i*1200/1e6*U.sonnet,a=r>=90?"#3fb950":r>=70?"#d29922":"#f85149";return n.jsxs(M,{children:[n.jsx(G,{icon:Ue,title:"Loops and efficiency",subtitle:"current session",color:i>0?"#f85149":"#3fb950"}),n.jsxs("div",{style:{display:"flex",gap:16,marginBottom:i>0?10:0},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:26,fontWeight:700,color:i>0?"#f85149":"#3fb950",lineHeight:1},children:i}),n.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"loops detected"})]}),n.jsx(N,{position:"bottom",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:a,fontWeight:700,fontSize:11,marginBottom:3},children:"Efficiency score"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["100 = no loops detected.",n.jsx("br",{}),"~5 points deducted for each repeated tool in a block.",n.jsx("br",{}),"Below 70 indicates inefficient session with wasted tokens."]})]}),children:n.jsxs("div",{style:{cursor:"help"},children:[n.jsx("div",{style:{fontSize:26,fontWeight:700,color:a,lineHeight:1},children:r}),n.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"efficiency /100"})]})}),i>0&&n.jsx(N,{position:"bottom",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#d29922",fontWeight:700,fontSize:11,marginBottom:3},children:"Lost cost estimate"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Calculated as: loops × ~1,200 tokens × blended Sonnet price.",n.jsx("br",{}),"This is a conservative estimate — actual cost may be higher if loops involve large files."]})]}),children:n.jsxs("div",{style:{cursor:"help"},children:[n.jsxs("div",{style:{fontSize:16,fontWeight:600,color:"#d29922",lineHeight:1},children:["~",Y(o)]}),n.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"wasted tokens"})]})})]}),i>0&&t&&n.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5,marginBottom:8},children:t.map((s,l)=>n.jsxs("span",{style:{fontSize:11,color:"#f85149",background:"#f8514914",border:"1px solid #f8514930",borderRadius:4,padding:"2px 7px"},children:[s.toolName," ×",s.count]},l))}),n.jsx("div",{style:{height:3,background:"#21262d",borderRadius:2,overflow:"hidden"},children:n.jsx("div",{style:{width:`${r}%`,height:"100%",background:a,borderRadius:2,transition:"width 0.5s"}})})]})}const In={Reading:"Read, Grep, Glob — tools for reading and searching files. High % may indicate excessive exploration before editing.",Editing:"Edit, Write, NotebookEdit — tools that modify files. This is the real productive work.",Terminal:"Bash — shell commands executed directly. Many Bash + few Grep may indicate inefficient searches.",Search:"WebFetch, WebSearch — internet and web page searches.",Agents:"Agent, Task, SendMessage — sub-agents launched for parallel tasks. They consume their own context quota.",Others:"Tools that don't fit in previous categories (Config, ToolSearch, etc.)."},de=[{label:"Reading",tools:["Read","Grep","Glob"],color:"#58a6ff"},{label:"Editing",tools:["Edit","Write","NotebookEdit"],color:"#3fb950"},{label:"Terminal",tools:["Bash"],color:"#d29922"},{label:"Search",tools:["WebFetch","WebSearch"],color:"#bc8cff"},{label:"Agents",tools:["Agent","Task","SendMessage"],color:"#f0883e"}];function Dn(e){for(let t=0;t<de.length;t++)if(de[t].tools.some(r=>e.startsWith(r)))return t;return de.length}function Wn({events:e,cost:t}){const r=e.filter(l=>l.type==="Done"&&l.tool_name);if(r.length===0)return null;const i=new Array(de.length+1).fill(0);for(const l of r)i[Dn(l.tool_name)]++;const o=r.length,a=(t==null?void 0:t.output_tokens)??0,s=[...de.map((l,d)=>({...l,count:i[d]})),{label:"Others",color:"#484f58",count:i[de.length]}].filter(l=>l.count>0).sort((l,d)=>d.count-l.count);return n.jsxs(M,{children:[n.jsx(G,{icon:Se,title:"Activity distribution",subtitle:"current session"}),n.jsx("div",{style:{height:8,background:"#21262d",borderRadius:4,overflow:"hidden",display:"flex",marginBottom:12},children:s.map(l=>n.jsx("div",{style:{width:`${l.count/o*100}%`,height:"100%",background:l.color}},l.label))}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[s.map(l=>{const d=Math.round(l.count/o*100),u=a>0?Math.round(a*l.count/o):0;return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("div",{style:{width:8,height:8,borderRadius:2,background:l.color,flexShrink:0}}),n.jsx("span",{style:{fontSize:11,color:"#8b949e",minWidth:70},children:l.label}),n.jsx("div",{style:{flex:1,height:3,background:"#21262d",borderRadius:2,overflow:"hidden"},children:n.jsx("div",{style:{width:`${d}%`,height:"100%",background:l.color,opacity:.7,borderRadius:2}})}),n.jsxs("span",{style:{fontSize:10,color:"#6e7681",fontVariantNumeric:"tabular-nums",minWidth:28,textAlign:"right"},children:[d,"%"]}),n.jsx("span",{style:{fontSize:10,color:"#484f58",fontVariantNumeric:"tabular-nums",minWidth:42,textAlign:"right"},children:u>0?`~${X(u)}`:`${l.count}×`}),n.jsx(ze,{position:"top",align:"right",style:{flexShrink:0},content:n.jsxs("div",{children:[n.jsx("div",{style:{color:l.color,fontWeight:700,fontSize:11,marginBottom:3},children:l.label}),n.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:In[l.label]??""})]})})]},l.label)}),n.jsxs("div",{style:{fontSize:9,color:"#3d444d",marginTop:2},children:[o," tool calls · ",a>0?`~${X(a)} estimated output tokens`:"tokens pending from active session"]})]})]})}function Bn({quota:e,cost:t}){const r=(e.weeklyTokensSonnet??0)+(e.weeklyTokensOpus??0)+(e.weeklyTokensHaiku??0),i=(e.weeklyTokensSonnet??0)/1e6*U.sonnet+(e.weeklyTokensOpus??0)/1e6*U.opus+(e.weeklyTokensHaiku??0)/1e6*U.haiku,o=i*4.3,a=i/7,s=wn((t==null?void 0:t.model)??""),l=An((t==null?void 0:t.model)??""),d=e.burnRateTokensPerMin>0?e.burnRateTokensPerMin*60/1e6*s:0;return n.jsxs(M,{children:[n.jsx(G,{icon:$t,title:"Monthly projection",subtitle:"based on this week"}),n.jsxs("div",{style:{display:"flex",gap:20,flexWrap:"wrap",marginBottom:10},children:[n.jsx(N,{position:"top",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:3},children:"Monthly projection"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Weekly consumption × 4.3 (weeks/month).",n.jsx("br",{}),"Assumes upcoming weeks will have the same pace.",n.jsx("br",{}),"Based on actual Sonnet, Opus, and Haiku tokens with blended prices."]})]}),children:n.jsxs("div",{style:{cursor:"help"},children:[n.jsx("div",{style:{fontSize:24,fontWeight:700,color:"#e6edf3",fontVariantNumeric:"tabular-nums",lineHeight:1},children:i>0?`~${Y(o)}`:"—"}),n.jsxs("div",{style:{fontSize:9,color:"#484f58"},children:["/month · ",i>0?`${Y(i)}/week · ${Y(a)}/day`:"no data"]})]})}),d>0&&n.jsx(N,{position:"top",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#d29922",fontWeight:700,fontSize:11,marginBottom:3},children:"Cost per hour (now)"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Calculated with active model (",l,") at blended price.",n.jsx("br",{}),e.burnRateTokensPerMin.toLocaleString()," tok/min × 60 ÷ 1M × price/M"]})]}),children:n.jsxs("div",{style:{cursor:"help"},children:[n.jsxs("div",{style:{fontSize:18,fontWeight:700,color:"#d29922",fontVariantNumeric:"tabular-nums",lineHeight:1},children:["~",Y(d),"/h"]}),n.jsxs("div",{style:{fontSize:9,color:"#484f58"},children:["now · ",e.burnRateTokensPerMin.toLocaleString()," tok/min"]})]})})]}),r>0&&n.jsxs("div",{style:{fontSize:10,color:"#484f58"},children:[X(r)," tokens this week · estimated blended input/output prices"]})]})}const Rn={error:{color:"#f85149",bg:"#3d1717",border:"#f8514940",Icon:ui},warning:{color:"#d29922",bg:"#2d2008",border:"#d2992240",Icon:Ue},info:{color:"#58a6ff",bg:"#0d1e33",border:"#58a6ff30",Icon:_t},success:{color:"#3fb950",bg:"#0d1f10",border:"#3fb95030",Icon:zt}};function Ln({tips:e}){return e.length===0?n.jsxs(M,{children:[n.jsx(G,{icon:et,title:"Real-time optimizer",color:"#d29922"}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#484f58",fontSize:12},children:[n.jsx(zt,{size:14,color:"#3fb950"}),"Clean session — no optimization suggestions at this time"]})]}):n.jsxs(M,{children:[n.jsx(G,{icon:et,title:"Real-time optimizer",subtitle:`${e.length} suggestion${e.length>1?"s":""}`,color:"#d29922"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:e.map((t,r)=>{const i=Rn[t.level];return n.jsxs("div",{style:{background:i.bg,border:`1px solid ${i.border}`,borderLeft:`3px solid ${i.color}`,borderRadius:6,padding:"8px 10px"},children:[n.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-start"},children:[n.jsx(i.Icon,{size:13,color:i.color,style:{flexShrink:0,marginTop:2}}),n.jsxs("div",{style:{flex:1},children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:i.color,marginBottom:3},children:t.title}),n.jsx("div",{style:{fontSize:11,color:"#8b949e",lineHeight:1.5},children:t.text})]})]}),t.prompt&&n.jsxs("div",{style:{marginTop:8,padding:"6px 10px",background:"#0d1117",border:"1px solid #30363d",borderRadius:5},children:[n.jsxs("div",{style:{fontSize:9,color:"#484f58",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em",marginBottom:4},children:["Prompt that caused it — Block #",t.blockIndex]}),n.jsxs("div",{style:{fontSize:11,color:"#7d8590",fontStyle:"italic",lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:80,overflow:"hidden",WebkitMaskImage:"linear-gradient(to bottom, black 60%, transparent 100%)"},children:['"',t.prompt,'"']})]})]},r)})})]})}function Nn({quota:e,cost:t,events:r,prompts:i,claudeStats:o}){if(!e)return n.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#484f58",fontSize:13},children:"Loading usage data…"});const a=On(t,e,r,i);return n.jsx("div",{style:{padding:"16px 20px"},children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gridTemplateRows:"auto",gap:12,maxWidth:1200,margin:"0 auto"},children:[n.jsx("div",{style:{gridColumn:"1 / -1"},children:n.jsx(zn,{quota:e,cost:t})}),o&&n.jsx("div",{style:{gridColumn:"1 / -1"},children:n.jsx(_n,{stats:o})}),n.jsx("div",{style:{gridColumn:"1 / -1"},children:n.jsx(Ln,{tips:a})}),r&&r.length>0?n.jsx(Wn,{events:r,cost:t}):n.jsx("div",{}),t?n.jsx(Cn,{cost:t}):n.jsxs(M,{children:[n.jsx(G,{icon:Pt,title:"Cache efficiency"}),n.jsx("span",{style:{fontSize:12,color:"#484f58"},children:"No active session data"})]}),n.jsx($n,{quota:e}),t?n.jsx(En,{cost:t}):n.jsxs(M,{children:[n.jsx(G,{icon:Ue,title:"Loops and efficiency"}),n.jsx("span",{style:{fontSize:12,color:"#484f58"},children:"No active session data"})]}),n.jsx("div",{style:{gridColumn:"1 / -1"},children:n.jsx(Bn,{quota:e,cost:t})})]})})}const Ae={7:"7 days",30:"30 days",90:"90 days"},ht={haiku:"#3fb950",sonnet:"#58a6ff",opus:"#d29922"};function Kt(e){return e.includes("haiku")?"haiku":e.includes("opus")?"opus":"sonnet"}function Pe(e){return e>=10?`$${e.toFixed(2)}`:`$${e.toFixed(3)}`}function me(e){if(e>=1e6)return`${(e/1e6).toFixed(1)}M`;if(e>=1e3){const t=Math.round(e/1e3);return t>=1e3?`${(t/1e3).toFixed(1)}M`:`${t}K`}return String(e)}function pt(e){return e<1?`${Math.round(e*60)}m`:`${e.toFixed(1)}h`}function Mn(e){return e==="No project"?e:e.split("/").filter(Boolean).pop()??e}function Fn(e){const t=new Map;for(const r of e){const i=Kt(r.model),o=t.get(r.date)??{date:r.date,haiku:0,sonnet:0,opus:0};o[i]=o[i]+r.tokens,t.set(r.date,o)}return[...t.values()]}function Hn(e){const t={};for(const i of e){const o=Kt(i.model);t[o]||(t[o]={tokens:0,cost:0}),t[o].tokens+=i.tokens,t[o].cost+=i.cost}const r={sonnet:"Sonnet",haiku:"Haiku",opus:"Opus"};return Object.entries(t).map(([i,o])=>({key:i,label:r[i]??i,...o})).filter(i=>i.tokens>0).sort((i,o)=>o.tokens-i.tokens)}const Oe={fontSize:11,fontWeight:600,color:"#6e7681",marginBottom:14,textTransform:"uppercase",letterSpacing:"0.05em"},yt={contentStyle:{background:"#161b22",border:"1px solid #30363d",borderRadius:6,fontSize:11},labelStyle:{color:"#e6edf3",fontWeight:600},itemStyle:{color:"#8b949e"}};function ce({icon:e,label:t,value:r,sub:i,color:o="#58a6ff",tip:a}){return n.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"14px 16px",flex:1,minWidth:140},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[n.jsx("span",{style:{color:o,opacity:.8},children:e}),n.jsx(N,{content:a,position:"bottom",align:"left",children:n.jsx("span",{style:{fontSize:10,color:"#6e7681",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",cursor:"default",borderBottom:"1px dotted #484f58"},children:t})})]}),n.jsx("div",{style:{fontSize:22,fontWeight:700,color:"#e6edf3",lineHeight:1},children:r}),i&&n.jsx("div",{style:{fontSize:10,color:"#484f58",marginTop:4},children:i})]})}function Kn({content:e}){return n.jsx("div",{style:{fontFamily:"inherit",lineHeight:1.7,color:"#c9d1d9"},children:e.split(`
8
- `).map((t,r)=>t.startsWith("# ")?n.jsx("h1",{style:{fontSize:18,fontWeight:700,color:"#e6edf3",margin:"20px 0 8px",borderBottom:"1px solid #21262d",paddingBottom:6},children:t.slice(2)},r):t.startsWith("## ")?n.jsx("h2",{style:{fontSize:15,fontWeight:600,color:"#e6edf3",margin:"16px 0 6px"},children:t.slice(3)},r):t.startsWith("### ")?n.jsx("h3",{style:{fontSize:13,fontWeight:600,color:"#8b949e",margin:"12px 0 4px"},children:t.slice(4)},r):t.startsWith("- [x] ")?n.jsxs("div",{style:{display:"flex",gap:8,margin:"3px 0",color:"#3fb950",fontSize:12},children:["✅ ",n.jsx("span",{style:{textDecoration:"line-through",color:"#6e7681"},children:t.slice(6)})]},r):t.startsWith("- [ ] ")?n.jsxs("div",{style:{display:"flex",gap:8,margin:"3px 0",fontSize:12},children:["⬜ ",n.jsx("span",{children:t.slice(6)})]},r):t.startsWith("- ")?n.jsxs("div",{style:{margin:"3px 0",paddingLeft:16,fontSize:12},children:["· ",t.slice(2)]},r):t.startsWith("> ")?n.jsx("blockquote",{style:{margin:"8px 0",paddingLeft:12,borderLeft:"3px solid #30363d",color:"#8b949e",fontSize:12},children:t.slice(2)},r):t.startsWith("---")?n.jsx("hr",{style:{border:"none",borderTop:"1px solid #21262d",margin:"14px 0"}},r):t.trim()===""?n.jsx("div",{style:{height:6}},r):n.jsx("p",{style:{margin:"3px 0",fontSize:12},children:t},r))})}function Gn(){const[e,t]=T.useState([]),[r,i]=T.useState(!1),[o,a]=T.useState(null),[s,l]=T.useState(!1),[d,u]=T.useState(!1),[c,h]=T.useState(null);function f(){fetch("/api/weekly-reports").then(x=>x.json()).then(t).catch(()=>{})}T.useEffect(()=>{f()},[]);async function p(){l(!0),h(null);try{const x=await fetch("/api/weekly-reports/generate-now",{method:"POST"}).then(b=>b.json());h(x.skipped?`Ya existe: ${x.date}`:`Generado: ${x.date}`),x.skipped||f()}catch{h("Error generating")}l(!1)}async function m(){u(!0),h(null);try{const x=await fetch("/api/weekly-reports/import-local",{method:"POST"}).then(b=>b.json());h(`${x.imported} imported, ${x.skipped} already existed`),x.imported>0&&f()}catch{h("Error importing")}u(!1)}async function y(x){const b=await fetch(`/api/weekly-reports/${x}`);b.ok&&(a(await b.json()),i(!1))}async function j(x,b){b.stopPropagation(),await fetch(`/api/weekly-reports/${x}`,{method:"DELETE"}).catch(()=>{}),(o==null?void 0:o.date)===x&&a(null),f()}const k={display:"inline-flex",alignItems:"center",gap:5,padding:"4px 10px",borderRadius:5,fontSize:11,fontWeight:600,cursor:"pointer",border:"1px solid #30363d",background:"none",color:"#8b949e",transition:"color 0.15s, border-color 0.15s"};return n.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,marginBottom:0},children:[n.jsxs("div",{style:{padding:"10px 14px",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[n.jsx(it,{size:12,color:"#6e7681"}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#8b949e"},children:"Weekly reports"}),c&&n.jsx("span",{style:{fontSize:11,color:"#3fb950"},children:c}),n.jsx("div",{style:{flex:1}}),n.jsxs("button",{style:{...k,color:s?"#484f58":"#58a6ff",borderColor:s?"#30363d":"#58a6ff30"},onClick:p,disabled:s,children:[n.jsx(Xe,{size:11}),s?"Generating…":"Generate"]}),n.jsx("button",{style:k,onClick:m,disabled:d,children:d?"Importing…":"Import"}),n.jsxs("button",{style:{...k,color:r?"#e6edf3":"#6e7681",borderColor:r?"#30363d":"#21262d"},onClick:()=>i(x=>!x),children:[e.length," reports",r?n.jsx(yi,{size:11}):n.jsx(mi,{size:11})]})]}),r&&n.jsx("div",{style:{borderTop:"1px solid #21262d",padding:"8px 10px",display:"flex",flexDirection:"column",gap:4,maxHeight:200,overflowY:"auto"},children:e.length===0?n.jsx("span",{style:{fontSize:11,color:"#484f58",padding:"4px 4px"},children:'No reports — use "Generate" to create one'}):e.map(x=>n.jsxs("div",{style:{border:"1px solid #21262d",borderRadius:5,display:"flex",alignItems:"center",transition:"background 0.1s"},onMouseEnter:b=>{b.currentTarget.style.background="#21262d"},onMouseLeave:b=>{b.currentTarget.style.background="none"},children:[n.jsxs("button",{onClick:()=>y(x.date),style:{background:"none",border:"none",padding:"7px 10px",cursor:"pointer",textAlign:"left",display:"flex",gap:10,alignItems:"center",color:"inherit",flex:1,minWidth:0},children:[n.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#58a6ff",minWidth:90,flexShrink:0},children:x.date}),n.jsx("span",{style:{fontSize:11,color:"#6e7681",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.preview})]}),n.jsx("button",{onClick:b=>j(x.date,b),title:"Delete report",style:{background:"none",border:"none",cursor:"pointer",padding:"7px 10px",display:"flex",alignItems:"center",color:"#6e7681",flexShrink:0},onMouseEnter:b=>{b.currentTarget.style.color="#f85149"},onMouseLeave:b=>{b.currentTarget.style.color="#6e7681"},children:n.jsx(xi,{size:12})})]},x.id))}),o&&n.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"#00000088",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>a(null),children:n.jsxs("div",{style:{background:"#161b22",border:"1px solid #30363d",borderRadius:10,width:"80%",maxWidth:820,maxHeight:"82vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 20px 60px #00000088"},onClick:x=>x.stopPropagation(),children:[n.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid #21262d",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx(it,{size:13,color:"#58a6ff"}),n.jsxs("span",{style:{fontSize:13,fontWeight:600,color:"#e6edf3"},children:["Informe semanal — ",o.date]})]}),n.jsx("button",{onClick:()=>a(null),style:{background:"none",border:"none",cursor:"pointer",color:"#6e7681",padding:4},children:n.jsx(vi,{size:16})})]}),n.jsx("div",{style:{flex:1,overflow:"auto",padding:"16px 24px"},children:n.jsx(Kn,{content:o.report_markdown})})]})})]})}function Xn({quota:e,cost:t,events:r,prompts:i,claudeStats:o}){const[a,s]=T.useState("30"),[l,d]=T.useState("30"),[u,c]=T.useState([]),[h,f]=T.useState([]),[p,m]=T.useState([]),[y,j]=T.useState(null),[k,x]=T.useState(!0);T.useEffect(()=>{x(!0),fetch(`/api/analytics?days=${a}&project_days=${l}`).then(v=>v.json()).then(v=>{c(v.daily??[]),f(v.by_model??[]),m(v.project_hours??[]),j(v.kpis??null)}).catch(()=>{}).finally(()=>x(!1))},[a,l]),Fn(h);const b=Hn(h),w=u.reduce((v,S)=>v+S.input_tokens,0),A=u.reduce((v,S)=>v+S.output_tokens,0),P=u.reduce((v,S)=>v+S.cache_read,0),O=w+A+P,z=w+P>0?Math.round(P/(w+P)*100):0,_=p.reduce((v,S)=>v+S.hours,0),$=u.map(v=>({date:v.date,tokens:v.input_tokens+v.output_tokens+v.cache_read,sessions:v.sessions}));return n.jsxs("div",{style:{height:"100%",overflowY:"auto",background:"#0d1117"},children:[n.jsx("div",{style:{padding:"16px 20px 12px"},children:n.jsx(Gn,{})}),n.jsx("div",{style:{padding:"0 20px 2px"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[n.jsx("span",{style:{fontSize:10,fontWeight:600,color:"#484f58",textTransform:"uppercase",letterSpacing:"0.08em"},children:"Real time"}),n.jsx("div",{style:{flex:1,height:1,background:"#21262d"}})]})}),n.jsx(Nn,{quota:e,cost:t,events:r,prompts:i,claudeStats:o}),n.jsxs("div",{style:{padding:"0 20px 20px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 0 16px",borderTop:"1px solid #21262d"},children:[n.jsx($t,{size:12,color:"#484f58"}),n.jsx("span",{style:{fontSize:10,fontWeight:600,color:"#484f58",textTransform:"uppercase",letterSpacing:"0.08em"},children:"Historical analysis"}),n.jsx("div",{style:{flex:1}}),n.jsx("div",{style:{display:"flex",gap:4},children:["7","30","90"].map(v=>n.jsx("button",{onClick:()=>s(v),style:{padding:"3px 9px",borderRadius:4,fontSize:11,cursor:"pointer",background:a===v?"#1f6feb":"none",border:`1px solid ${a===v?"#1f6feb":"#30363d"}`,color:a===v?"#fff":"#8b949e",transition:"all 0.15s"},children:Ae[v]},v))})]}),k&&n.jsx("div",{style:{color:"#484f58",fontSize:12,textAlign:"center",padding:"20px 0"},children:"Loading…"}),!k&&y&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:10,marginBottom:20,flexWrap:"wrap"},children:[n.jsx(ce,{icon:n.jsx(tt,{size:13}),label:"Real spend 7d",value:Pe(y.week_cost),sub:`${y.week_sessions} sessions · DB`,color:"#58a6ff",tip:"Real spend in the last 7 days from the claudestat database. Complements the projection above that uses stats-cache."}),n.jsx(ce,{icon:n.jsx(tt,{size:13}),label:"Real spend 30d",value:Pe(y.month_cost),sub:`${y.month_sessions} sessions`,color:"#a371f7",tip:"Real spend in the last 30 days recorded in the claudestat database."}),n.jsx(ce,{icon:n.jsx(Se,{size:13}),label:`Tokens ${Ae[a]}`,value:me(O),sub:`In+Out: ${me(w+A)}`,color:"#d29922",tip:"Total tokens for the period (input + output + cache read). Cache is ~10× cheaper than fresh tokens."}),n.jsx(ce,{icon:n.jsx(Ot,{size:13}),label:`Hours ${Ae[a]}`,value:pt(_),sub:`${p.length} projects`,color:"#3fb950",tip:"Total estimated work time in Claude Code (sum of durations of all sessions in the period)."}),n.jsx(ce,{icon:n.jsx(hi,{size:13}),label:"Loops 7d",value:String(y.week_loops),sub:y.week_loops>20?"High — review":"Normal",color:y.week_loops>20?"#f85149":"#3fb950",tip:"Loops detected in the last week (same tool repeated ≥4 times without progress). Each loop wastes tokens and cost."}),n.jsx(ce,{icon:n.jsx(Xe,{size:13}),label:"Avg efficiency",value:`${y.avg_efficiency}%`,sub:`Cache: ${z}%`,color:y.avg_efficiency>=80?"#3fb950":y.avg_efficiency>=60?"#d29922":"#f85149",tip:`Average efficiency for the period (100% = no loops or redundancy). Cache: ${z}% of tokens come from cache (cheaper).`})]}),n.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"16px 20px",marginBottom:14},children:[n.jsx("div",{style:Oe,children:"Daily cost (USD)"}),n.jsx(Qe,{width:"100%",height:130,children:n.jsxs(kn,{data:u,margin:{top:4,right:4,left:-24,bottom:0},children:[n.jsx(Be,{strokeDasharray:"3 3",stroke:"#21262d"}),n.jsx($e,{dataKey:"date",tick:{fontSize:9,fill:"#6e7681"},tickFormatter:v=>v.slice(5),axisLine:!1,tickLine:!1,interval:"preserveStartEnd"}),n.jsx(ve,{tick:{fontSize:9,fill:"#6e7681"},axisLine:!1,tickLine:!1,tickFormatter:v=>`$${v.toFixed(1)}`}),n.jsx(qe,{...yt,cursor:{stroke:"#30363d"},formatter:v=>[Pe(v),"Cost"]}),n.jsx(oe,{type:"monotone",dataKey:"cost",stroke:"#58a6ff",dot:!1,strokeWidth:2})]})})]}),n.jsxs("div",{style:{display:"flex",gap:14,marginBottom:14},children:[n.jsxs("div",{style:{flex:1,background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"16px 20px"},children:[n.jsx("div",{style:Oe,children:"Tokens per day · fluctuation"}),n.jsx(Qe,{width:"100%",height:130,children:n.jsxs(Sn,{data:$,margin:{top:4,right:14,left:-24,bottom:0},children:[n.jsx(Be,{strokeDasharray:"3 3",stroke:"#21262d"}),n.jsx($e,{dataKey:"date",tick:{fontSize:9,fill:"#6e7681"},tickFormatter:v=>v.slice(5),axisLine:!1,tickLine:!1,interval:"preserveStartEnd"}),n.jsx(ve,{yAxisId:"left",tick:{fontSize:9,fill:"#6e7681"},axisLine:!1,tickLine:!1,tickFormatter:me}),n.jsx(ve,{yAxisId:"right",orientation:"right",tick:{fontSize:9,fill:"#6e7681"},axisLine:!1,tickLine:!1}),n.jsx(qe,{...yt,cursor:{fill:"#21262d"},formatter:(v,S)=>[S==="Tokens"?me(v):v,S]}),n.jsx(ri,{iconSize:8,wrapperStyle:{fontSize:10,color:"#8b949e"}}),n.jsx(At,{yAxisId:"left",dataKey:"tokens",name:"Tokens",fill:"#1f6feb88",radius:[2,2,0,0]}),n.jsx(oe,{yAxisId:"right",dataKey:"sessions",name:"Sessions",stroke:"#3fb950",dot:!1,strokeWidth:2})]})})]}),n.jsxs("div",{style:{flex:1,background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"16px 20px"},children:[n.jsx("div",{style:Oe,children:"Token share by model"}),(()=>{const v=b.reduce((S,E)=>S+E.tokens,0);return n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:b.map(S=>{const E=v>0?S.tokens/v*100:0;return n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4},children:[n.jsx("span",{style:{fontSize:11,fontWeight:600,color:ht[S.key]??"#8b949e"},children:S.label}),n.jsxs("span",{style:{fontSize:11,color:"#8b949e"},children:[me(S.tokens)," · ",E.toFixed(1),"%"]})]}),n.jsx("div",{style:{height:6,background:"#21262d",borderRadius:3},children:n.jsx("div",{style:{height:"100%",width:`${E}%`,background:ht[S.key]??"#8b949e",borderRadius:3,minWidth:E>0?3:0}})})]},S.key)})})})()]})]}),p.length>0&&n.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"16px 20px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:14},children:[n.jsx(pi,{size:11,color:"#6e7681"}),n.jsx(N,{content:"Only includes sessions tracked by claudestat (since install). Full project history available in the Projects tab.",children:n.jsx("span",{style:Oe,children:"Hours by project ⓘ"})}),n.jsx("div",{style:{flex:1}}),n.jsx("div",{style:{display:"flex",gap:4},children:["7","30","90"].map(v=>n.jsx("button",{onClick:()=>d(v),style:{padding:"2px 7px",borderRadius:4,fontSize:10,cursor:"pointer",background:l===v?"#1f6feb":"none",border:`1px solid ${l===v?"#1f6feb":"#30363d"}`,color:l===v?"#fff":"#8b949e",transition:"all 0.15s"},children:Ae[v]},v))})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:p.map(v=>{const S=_>0?v.hours/_*100:0;return n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4},children:[n.jsx("span",{style:{fontSize:11,color:"#c9d1d9",fontWeight:500},children:Mn(v.project)}),n.jsxs("div",{style:{display:"flex",gap:12},children:[n.jsxs("span",{style:{fontSize:10,color:"#6e7681"},children:[v.sessions," sessions"]}),n.jsx("span",{style:{fontSize:10,color:"#d29922",minWidth:40,textAlign:"right"},children:Pe(v.cost)}),n.jsx("span",{style:{fontSize:11,color:"#e6edf3",fontWeight:600,minWidth:36,textAlign:"right"},children:pt(v.hours)})]})]}),n.jsx("div",{style:{height:4,background:"#21262d",borderRadius:2,overflow:"hidden"},children:n.jsx("div",{style:{height:"100%",width:`${S}%`,background:"#58a6ff",borderRadius:2,transition:"width 0.3s"}})})]},v.project)})})]})]}),!k&&u.length===0&&n.jsx("div",{style:{color:"#484f58",fontSize:12,textAlign:"center",padding:"40px 0"},children:"No data for the selected period"})]})]})}export{Xn as AnalyticsView};
@@ -1 +0,0 @@
1
- import{j as e,T as l}from"./index-DgbWvj42.js";import{a as u,E as F,c as E,d as G,J as P,K as L,H as N,j as C,X as _,N as V,O as q,Q as R}from"./vendor-lucide-Cym0q5l_.js";import"./vendor-react-B_Jzs0gY.js";const v={Read:"#58a6ff",Write:"#3fb950",Edit:"#3fb950",Bash:"#d29922",Glob:"#79c0ff",Grep:"#79c0ff",WebSearch:"#56d364",WebFetch:"#56d364",Agent:"#bc8cff",Skill:"#58a6ff",TodoWrite:"#8b949e",TodoRead:"#8b949e",Task:"#8b949e",default:"#6e7681"},T={directo:"direct",agentes:"agents",skills:"skills","agentes+skills":"agents+skills"},K={directo:"#7d8590",agentes:"#d29922",skills:"#58a6ff","agentes+skills":"#d29922"},Q={directo:"Claude responded directly, without launching sub-agents or invoking skills",agentes:"Sub-agents (Agent tool) were launched during the session",skills:"Skills (Skill tool) were invoked during the session","agentes+skills":"Both sub-agents and skills were used in this session"};function D(t){return new Date(t).toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit"})}function Y(t){const o=Math.floor(t/36e5),n=Math.floor(t%36e5/6e4);return o>0?`${o}h ${n}m`:n>0?`${n}m`:"<1m"}function J(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:String(t)}const a={card:(t,o)=>({background:o?"#1a2332":t?"#1c2128":"#161b22",border:`1px solid ${o?"#58a6ff80":t?"#1f6feb":"#21262d"}`,borderRadius:8,padding:"10px 14px",display:"flex",flexDirection:"column",gap:6,cursor:"pointer",transition:"border-color 0.15s, background 0.15s"}),row:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},dim:{color:"#7d8590",fontSize:11},badge:t=>({color:t,background:t+"18",border:`1px solid ${t}30`,borderRadius:4,padding:"1px 6px",fontSize:10,fontWeight:600,display:"inline-flex",alignItems:"center",gap:3}),sep:{color:"#21262d",userSelect:"none",fontSize:11}};function X({session:t,isActive:o,selectable:n,selected:r=!1,onSelect:f}){const m=K[t.mode]??"#7d8590",d=t.efficiency_score>=90?"#3fb950":t.efficiency_score>=70?"#d29922":"#f85149";return e.jsxs("div",{style:a.card(!!o,r),onClick:()=>n&&(f==null?void 0:f(t.id)),children:[e.jsxs("div",{style:a.row,children:[n&&e.jsx("div",{style:{width:15,height:15,borderRadius:3,flexShrink:0,border:`2px solid ${r?"#58a6ff":"#484f58"}`,background:r?"#58a6ff":"transparent",display:"flex",alignItems:"center",justifyContent:"center"},children:r&&e.jsx(F,{size:9,color:"#0d1117",strokeWidth:3})}),o&&e.jsxs("span",{style:{color:"#3fb950",fontSize:10,fontWeight:700,display:"inline-flex",alignItems:"center",gap:4},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#3fb950",animation:"livePulse 1.2s ease-in-out infinite",display:"inline-block"}}),"LIVE"]}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Session interval"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Time of first event → last recorded event"})]}),children:e.jsxs("span",{style:a.dim,children:[D(t.started_at)," → ",D(t.last_event_at)]})}),e.jsx("span",{style:a.dim,children:"·"}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Duration"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Elapsed time from the first to the last event in the session"})]}),children:e.jsx("span",{style:{...a.dim,fontWeight:600},children:Y(t.duration_ms)})}),t.project_name&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:a.sep,children:"│"}),e.jsxs("span",{style:{color:"#79c0ff",fontSize:11,display:"inline-flex",alignItems:"center",gap:3},children:[e.jsx(E,{size:10})," ",t.project_name]})]}),e.jsx("div",{style:{flex:1}}),e.jsx(l,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:m,fontWeight:700,fontSize:12,marginBottom:4},children:T[t.mode]??t.mode}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:Q[t.mode]??t.mode})]}),children:e.jsx("span",{style:a.badge(m),children:T[t.mode]??t.mode})})]}),e.jsxs("div",{style:a.row,children:[e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:"API Cost"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Sum of all session blocks at Anthropic pricing"})]}),children:e.jsxs("span",{style:a.badge("#3fb950"),children:["$",t.total_cost_usd.toFixed(4)]})}),e.jsx("span",{style:a.dim,children:"·"}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#79c0ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Total tokens"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:["Input + Output + Cache read.",e.jsx("br",{}),"Cache read dominates in long sessions — it's the context resent on each API call."]})]}),children:e.jsxs("span",{style:{color:"#79c0ff",background:"#79c0ff22",border:"1px solid #79c0ff50",borderRadius:4,padding:"2px 8px",fontSize:11,fontWeight:700,display:"inline-flex",alignItems:"center",gap:3},children:[J(t.total_tokens)," tok"]})}),e.jsx("span",{style:a.sep,children:"│"}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:d,fontWeight:700,fontSize:12,marginBottom:4},children:["Efficiency ",t.efficiency_score,"/100"]}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:["Score calculated by the daemon.",e.jsx("br",{}),"Penalizes detected loops, re-reads of the same file, and excessive context use."]})]}),children:e.jsxs("span",{style:a.badge(d),children:["efficiency ",t.efficiency_score,"/100"]})}),t.loops_detected>0&&e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#f85149",fontWeight:700,fontSize:12,marginBottom:4},children:"Detected loops"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:[t.loops_detected," loop",t.loops_detected!==1?"s":""," in this session.",e.jsx("br",{}),"Detected when the same action (tool + input) repeats ≥3 times without real progress."]})]}),children:e.jsxs("span",{style:a.badge("#f85149"),children:[e.jsx(G,{size:9})," ",t.loops_detected," loops"]})}),e.jsx("span",{style:a.sep,children:"│"}),e.jsx(l,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Tool calls"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Number of tools that completed execution (Done type) in this session"})]}),children:e.jsxs("span",{style:a.dim,children:[t.done_count," tools"]})})]}),t.top_tools.length>0&&e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:6},children:"Most used tools"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:t.top_tools.map((c,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,background:v[c]??v.default,flexShrink:0}}),e.jsx("span",{style:{color:"#c9d1d9",fontSize:10},children:c}),h===0&&e.jsx("span",{style:{color:"#484f58",fontSize:9},children:"— most frequent"})]},h))})]}),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[t.top_tools.slice(0,12).map((c,h)=>e.jsx("span",{style:{width:12,height:4,borderRadius:2,flexShrink:0,background:v[c]??v.default,opacity:Math.max(.2,1-h*.07)}},h)),e.jsxs("span",{style:{color:"#484f58",fontSize:9,marginLeft:5},children:[t.top_tools[0],t.top_tools.length>1?` +${t.top_tools.length-1}`:""]})]})}),t.git_branch&&e.jsx("div",{style:a.row,children:e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#8b949e",fontWeight:700,fontSize:12,marginBottom:6},children:"Git status"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsxs("div",{style:{color:"#c9d1d9",fontSize:10},children:["Branch: ",e.jsx("span",{style:{fontFamily:"monospace",color:"#79c0ff"},children:t.git_branch})]}),t.git_dirty&&e.jsx("div",{style:{color:"#d29922",fontSize:10},children:"* Local changes not committed"}),(t.git_ahead??0)>0&&e.jsxs("div",{style:{color:"#58a6ff",fontSize:10},children:["↑ ",t.git_ahead," commit",(t.git_ahead??0)!==1?"s":""," ahead of remote"]}),(t.git_behind??0)>0&&e.jsxs("div",{style:{color:"#d29922",fontSize:10},children:["↓ ",t.git_behind," commit",(t.git_behind??0)!==1?"s":""," behind remote"]}),!t.git_dirty&&!(t.git_ahead??0)&&!(t.git_behind??0)&&e.jsx("div",{style:{color:"#3fb950",fontSize:10},children:"Synced with remote"})]})]}),children:e.jsxs("span",{style:a.badge("#8b949e"),children:[e.jsx(P,{size:9}),t.git_branch,t.git_dirty?e.jsx("span",{style:{color:"#d29922"},children:"*"}):null,(t.git_ahead??0)>0?e.jsxs("span",{style:{color:"#58a6ff"},children:[" ↑",t.git_ahead]}):null,(t.git_behind??0)>0?e.jsxs("span",{style:{color:"#d29922"},children:[" ↓",t.git_behind]}):null]})})}),t.ai_summary&&e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,marginTop:2},children:[e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"AI Summary"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Automatically generated by the daemon when the session ends"})]}),children:e.jsx(L,{size:10,color:"#7d8590",style:{flexShrink:0,marginTop:1}})}),e.jsx("span",{style:{color:"#9198a1",fontSize:11,fontStyle:"italic",lineHeight:1.4},children:t.ai_summary})]})]})}const U=u.memo(X),I={directo:"#7d8590",agentes:"#d29922",skills:"#58a6ff","agentes+skills":"#d29922"};function A(t){const o=new Date(t+"T12:00:00"),n=new Date().toISOString().slice(0,10),r=new Date(Date.now()-864e5).toISOString().slice(0,10);return t===n?"Today":t===r?"Yesterday":o.toLocaleDateString("en",{weekday:"long",day:"numeric",month:"long"})}function z(t){const o=Math.floor(t/36e5),n=Math.floor(t%36e5/6e4);return o>0?`${o}h ${n}m`:`${n}m`}function b(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:String(t)}function x(t,o,n=!1){return t===o?{color:"#8b949e"}:{color:(n?t<o:t>o)?"#3fb950":"#f85149",fontWeight:700}}function Z({a:t,b:o,onClose:n}){const r=[{label:"Cost",tooltip:"Total API cost of the session. Green = cheaper (better).",va:`$${t.total_cost_usd.toFixed(4)}`,vb:`$${o.total_cost_usd.toFixed(4)}`,styleA:x(t.total_cost_usd,o.total_cost_usd,!0),styleB:x(o.total_cost_usd,t.total_cost_usd,!0)},{label:"Tokens",tooltip:"Input + Output + Cache read. Green = fewer tokens consumed (better).",va:b(t.total_tokens),vb:b(o.total_tokens),styleA:x(t.total_tokens,o.total_tokens,!0),styleB:x(o.total_tokens,t.total_tokens,!0)},{label:"Duration",tooltip:"Time between first and last event. Green = shorter session (better).",va:z(t.duration_ms),vb:z(o.duration_ms),styleA:x(t.duration_ms,o.duration_ms,!0),styleB:x(o.duration_ms,t.duration_ms,!0)},{label:"Efficiency",tooltip:"Score 0–100 calculated by the daemon. Penalizes loops, re-reads and excessive context. Green = more efficient (better).",va:`${t.efficiency_score}/100`,vb:`${o.efficiency_score}/100`,styleA:x(t.efficiency_score,o.efficiency_score,!1),styleB:x(o.efficiency_score,t.efficiency_score,!1)},{label:"Tools used",tooltip:"Number of completed tool calls (Done type). Green = fewer calls for the same result (better).",va:`${t.done_count} calls`,vb:`${o.done_count} calls`,styleA:x(t.done_count,o.done_count,!0),styleB:x(o.done_count,t.done_count,!0)},{label:"Loops",tooltip:"Detected loops: same action repeated ≥3 times without real progress. Green = none or fewer (better).",va:`${t.loops_detected} loop${t.loops_detected!==1?"s":""}`,vb:`${o.loops_detected} loop${o.loops_detected!==1?"s":""}`,styleA:x(t.loops_detected,o.loops_detected,!0),styleB:x(o.loops_detected,t.loops_detected,!0)},{label:"Mode",tooltip:"Detected mode: direct (no agents or skills), agents, skills, or both.",va:t.mode,vb:o.mode,styleA:{color:I[t.mode]??"#7d8590",fontWeight:600},styleB:{color:I[o.mode]??"#7d8590",fontWeight:600}}],f=t.project_name||t.id.slice(0,8),m=o.project_name||o.id.slice(0,8);return e.jsxs("div",{style:{margin:"0 0 20px 0",background:"#161b22",border:"1px solid #30363d",borderLeft:"3px solid #58a6ff",borderRadius:8,overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 16px",borderBottom:"1px solid #21262d",background:"#1c2128"},children:[e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Session comparison"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:["Green = better · Red = worse",e.jsx("br",{}),"Metrics are compared against each other. For cost, tokens, duration and loops: less is better. For efficiency: more is better."]})]}),children:e.jsx(R,{size:14,color:"#58a6ff",style:{cursor:"default"}})}),e.jsx("span",{style:{color:"#e6edf3",fontWeight:700,fontSize:13},children:"Session comparison"}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Session A"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10},children:[t.project_name??t.id.slice(0,8)," · ",new Date(t.started_at).toLocaleDateString("en",{day:"numeric",month:"short"})]})]}),children:e.jsx("span",{style:{color:"#58a6ff",fontSize:11,background:"#58a6ff18",borderRadius:4,padding:"1px 7px",border:"1px solid #58a6ff30",cursor:"default"},children:new Date(t.started_at).toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit"})})}),e.jsx("span",{style:{color:"#6e7681",fontSize:11},children:"vs"}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#bc8cff",fontWeight:700,fontSize:12,marginBottom:4},children:"Session B"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10},children:[o.project_name??o.id.slice(0,8)," · ",new Date(o.started_at).toLocaleDateString("en",{day:"numeric",month:"short"})]})]}),children:e.jsx("span",{style:{color:"#bc8cff",fontSize:11,background:"#bc8cff18",borderRadius:4,padding:"1px 7px",border:"1px solid #bc8cff30",cursor:"default"},children:new Date(o.started_at).toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit"})})}),e.jsx("div",{style:{flex:1}}),e.jsx("button",{onClick:n,style:{background:"none",border:"none",cursor:"pointer",color:"#6e7681",display:"flex"},children:e.jsx(_,{size:14})})]}),e.jsxs("div",{style:{padding:"0 0 8px 0"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr 1fr",padding:"6px 16px",borderBottom:"1px solid #21262d"},children:[e.jsx("span",{style:{color:"#484f58",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Metric"}),e.jsx("span",{style:{color:"#58a6ff",fontSize:10,fontWeight:700},children:f}),e.jsx("span",{style:{color:"#bc8cff",fontSize:10,fontWeight:700},children:m})]}),r.map((d,c)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr 1fr",padding:"5px 16px",background:c%2===0?"transparent":"#ffffff08"},children:[e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:d.label}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:d.tooltip})]}),children:e.jsx("span",{style:{color:"#7d8590",fontSize:11,cursor:"default"},children:d.label})}),e.jsx("span",{style:{fontSize:12,...d.styleA},children:d.va}),e.jsx("span",{style:{fontSize:12,...d.styleB},children:d.vb})]},c)),(t.top_tools.length>0||o.top_tools.length>0)&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr 1fr",padding:"5px 16px"},children:[e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Top tools"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Most invoked tools in each session, sorted by frequency"})]}),children:e.jsx("span",{style:{color:"#7d8590",fontSize:11,cursor:"default"},children:"Top tools"})}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:3},children:(t.top_tools.length>0?t.top_tools:["—"]).map((d,c)=>e.jsx("span",{style:{color:"#8b949e",fontSize:10,background:"#ffffff08",borderRadius:3,padding:"1px 5px"},children:d},c))}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:3},children:(o.top_tools.length>0?o.top_tools:["—"]).map((d,c)=>e.jsx("span",{style:{color:"#8b949e",fontSize:10,background:"#ffffff08",borderRadius:3,padding:"1px 5px"},children:d},c))})]})]}),(t.ai_summary||o.ai_summary)&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8,padding:"10px 16px",borderTop:"1px solid #21262d"},children:[{s:t,color:"#58a6ff"},{s:o,color:"#bc8cff"}].map(({s:d,color:c})=>e.jsxs("div",{style:{background:c+"08",border:`1px solid ${c}20`,borderRadius:6,padding:"7px 10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:4},children:[e.jsx(L,{size:10,color:c}),e.jsx("span",{style:{color:c,fontSize:10,fontWeight:700},children:new Date(d.started_at).toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit"})})]}),e.jsx("span",{style:{color:"#9198a1",fontSize:11,fontStyle:"italic",lineHeight:1.4},children:d.ai_summary??e.jsx("span",{style:{color:"#484f58"},children:"No summary"})})]},d.id))})]})}const p={wrap:{padding:"16px 24px",overflowY:"auto",height:"100%"},dayWrap:{marginBottom:28},dayHead:{display:"flex",alignItems:"center",gap:16,marginBottom:10,paddingBottom:6,borderBottom:"1px solid #21262d"},dayLabel:{color:"#e6edf3",fontWeight:700,fontSize:14},dayStat:{color:"#7d8590",fontSize:11},badge:t=>({color:t,background:t+"18",border:`1px solid ${t}30`,borderRadius:4,padding:"1px 7px",fontSize:11,fontWeight:600}),sessions:{display:"flex",flexDirection:"column",gap:8},empty:{padding:"60px 24px",color:"#7d8590",textAlign:"center",fontSize:13}};function ee({days:t,activeSessionId:o}){return e.jsxs("div",{style:{paddingLeft:8},children:[e.jsx("style",{children:"@keyframes livePulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.4;transform:scale(1.5)} }"}),t.map(n=>e.jsxs("div",{style:{marginBottom:28},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:10},children:[e.jsx("div",{style:{width:10,height:10,borderRadius:"50%",background:"#30363d",border:"2px solid #484f58",flexShrink:0}}),e.jsx("div",{style:{height:1,width:12,background:"#21262d"}}),e.jsx("span",{style:{color:"#8b949e",fontSize:12,fontWeight:700},children:A(n.date)}),e.jsxs("span",{style:{color:"#484f58",fontSize:11},children:[n.sessions.length," ses. · $",n.total_cost.toFixed(3)," · ",b(n.total_tokens)]})]}),e.jsxs("div",{style:{position:"relative",paddingLeft:28},children:[e.jsx("div",{style:{position:"absolute",left:4,top:0,bottom:0,width:2,background:"#21262d",borderRadius:1}}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:n.sessions.map(r=>{const f=r.efficiency_score>=90?"#3fb950":r.efficiency_score>=70?"#d29922":"#f85149",m=r.id===o;return e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start"},children:[e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:f,fontWeight:700,fontSize:12,marginBottom:4},children:["Efficiency ",r.efficiency_score,"/100"]}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:["Green ≥90 · Amber ≥70 · Red <70",e.jsx("br",{}),"Penalizes loops, re-reads and excessive context"]})]}),children:e.jsx("div",{style:{width:10,height:10,borderRadius:"50%",flexShrink:0,marginTop:6,background:f,border:"2px solid #0d1117",boxShadow:`0 0 6px ${f}66`,position:"relative",zIndex:1,animation:m?"livePulse 1.5s ease-in-out infinite":void 0,cursor:"default"}})}),e.jsx("div",{style:{flex:1,background:"#161b22",border:`1px solid ${m?"#1f6feb":"#21262d"}`,borderRadius:7,padding:"7px 12px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Start time"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"First recorded event of the session"})]}),children:e.jsx("span",{style:{color:"#6e7681",fontSize:10,fontFamily:"monospace",cursor:"default"},children:new Date(r.started_at).toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit"})})}),r.project_name&&e.jsx("span",{style:{color:"#79c0ff",fontSize:11,fontWeight:600},children:r.project_name}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:"API Cost"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"Sum of all session blocks"})]}),children:e.jsxs("span",{style:{color:"#3fb950",fontSize:10,fontWeight:600,cursor:"default"},children:["$",r.total_cost_usd.toFixed(4)]})}),e.jsx("span",{style:{color:"#484f58",fontSize:10},children:"·"}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:f,fontWeight:700,fontSize:12,marginBottom:4},children:"Efficiency"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Score 0–100. Penalizes loops, re-reads and excessive context"})]}),children:e.jsxs("span",{style:{color:f,fontSize:10,cursor:"default"},children:[r.efficiency_score,"/100"]})}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#79c0ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Total tokens"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"Input + Output + Cache read"})]}),children:e.jsxs("span",{style:{color:"#484f58",fontSize:10,cursor:"default"},children:["· ",b(r.total_tokens)," tok"]})}),r.ai_summary&&e.jsxs("span",{style:{color:"#7d8590",fontSize:10,fontStyle:"italic",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["— ",r.ai_summary]})]})})]},r.id)})})]})]},n.date))]})}const S=[{label:"All",min:null,max:null},{label:"< $0.01",min:null,max:.01},{label:"$0.01+",min:.01,max:null},{label:"$0.10+",min:.1,max:null},{label:"$1+",min:1,max:null}];function se({days:t,activeSessionId:o}){const[n,r]=u.useState([]),[f,m]=u.useState("list"),[d,c]=u.useState(""),[h,H]=u.useState(0),j=u.useMemo(()=>{const i=d.trim().toLowerCase(),s=S[h];return t.map(g=>({...g,sessions:g.sessions.filter(y=>{var B,$;return s.min!==null&&y.total_cost_usd<s.min||s.max!==null&&y.total_cost_usd>=s.max?!1:i?((B=y.project_name)==null?void 0:B.toLowerCase().includes(i))||y.top_tools.some(M=>M.toLowerCase().includes(i))||(($=y.ai_summary)==null?void 0:$.toLowerCase().includes(i))||y.id.includes(i):!0})})).filter(g=>g.sessions.length>0)},[t,d,h]),k=t.flatMap(i=>i.sessions),w=k.find(i=>i.id===n[0]),W=k.find(i=>i.id===n[1]);function O(i){r(s=>s.includes(i)?s.filter(g=>g!==i):s.length>=2?[s[1],i]:[...s,i])}return t.length===0?e.jsxs("div",{style:{...p.empty,display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[e.jsx(N,{size:40,color:"#30363d"}),e.jsxs("div",{children:[e.jsx("div",{style:{color:"#6e7681",fontSize:14,fontWeight:600,marginBottom:4},children:"No sessions recorded"}),e.jsx("div",{style:{fontSize:11,color:"#484f58"},children:"Sessions appear here once the daemon processes them."})]})]}):e.jsxs("div",{style:p.wrap,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8,padding:"5px 10px",background:"#161b22",border:"1px solid #21262d",borderRadius:6},children:[e.jsx(C,{size:12,color:"#484f58"}),e.jsx("input",{type:"text",placeholder:"Search by project, tool or summary…",value:d,onChange:i=>c(i.target.value),style:{flex:1,background:"transparent",border:"none",outline:"none",color:"#c9d1d9",fontSize:12,fontFamily:"inherit"}}),d&&e.jsx("button",{onClick:()=>c(""),style:{background:"none",border:"none",cursor:"pointer",color:"#6e7681",display:"flex"},children:e.jsx(_,{size:12})}),e.jsx("div",{style:{width:1,height:16,background:"#21262d"}}),e.jsx("div",{style:{display:"flex",gap:3},children:S.map((i,s)=>{const g=s===0?"Show all sessions without filtering by cost":s===1?"Only sessions with cost under $0.01 — very short conversations":s===2?"Sessions with cost of $0.01 or more — real work":s===3?"Sessions with cost of $0.10 or more — intensive work":"Sessions with cost of $1 or more — long or high-complexity sessions";return e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:["Filtro: ",i.label]}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:g})]}),children:e.jsx("button",{onClick:()=>H(s),style:{padding:"2px 7px",borderRadius:4,border:`1px solid ${h===s?"#3fb95060":"#21262d"}`,background:h===s?"#1a2d1a":"transparent",color:h===s?"#3fb950":"#6e7681",fontSize:10,fontWeight:600,cursor:"pointer"},children:i.label})},s)})}),(d||h>0)&&e.jsxs("span",{style:{color:"#484f58",fontSize:10},children:[j.reduce((i,s)=>i+s.sessions.length,0)," result",j.reduce((i,s)=>i+s.sessions.length,0)!==1?"s":""]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12,padding:"6px 10px",background:"#161b22",border:"1px solid #21262d",borderRadius:6},children:[e.jsx("div",{style:{display:"flex",gap:2,background:"#0d1117",borderRadius:5,padding:2},children:[["list",V,"List","Card view grouped by day. Shows all details for each session."],["timeline",q,"Timeline","Chronological view with a timeline. Shows the session flow for the day."]].map(([i,s,g,y])=>e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:g}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:y})]}),children:e.jsxs("button",{onClick:()=>m(i),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:4,border:"none",cursor:"pointer",fontSize:10,fontWeight:600,background:f===i?"#21262d":"transparent",color:f===i?"#e6edf3":"#6e7681",transition:"all 0.15s"},children:[e.jsx(s,{size:10}),g]})},i))}),e.jsx("div",{style:{width:1,height:16,background:"#21262d"}}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Compare sessions"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:["Click 2 sessions to compare their metrics.",e.jsx("br",{}),"If 2 are already selected, the new one replaces the oldest."]})]}),children:e.jsx(R,{size:12,color:"#58a6ff",style:{cursor:"default"}})}),e.jsx("span",{style:{color:"#6e7681",fontSize:11},children:n.length===0?"Select 2 sessions to compare":n.length===1?"Select 1 more":"Comparing 2 sessions"}),n.length>0&&e.jsx("button",{onClick:()=>r([]),style:{background:"none",border:"none",cursor:"pointer",color:"#6e7681",display:"flex",marginLeft:"auto"},children:e.jsx(_,{size:12})})]}),w&&W&&e.jsx(Z,{a:w,b:W,onClose:()=>r([])}),j.length===0&&(d||h>0)&&e.jsxs("div",{style:{...p.empty},children:[e.jsx(C,{size:32,color:"#30363d",style:{marginBottom:8}}),e.jsxs("div",{style:{color:"#6e7681",fontSize:13},children:['No results for "',d||S[h].label,'"']})]}),f==="timeline"?e.jsx(ee,{days:j,activeSessionId:o}):j.map(i=>e.jsxs("div",{style:p.dayWrap,children:[e.jsxs("div",{style:p.dayHead,children:[e.jsx("span",{style:p.dayLabel,children:A(i.date)}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Day sessions"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"Number of Claude Code sessions recorded this day"})]}),children:e.jsxs("span",{style:{...p.dayStat,cursor:"default"},children:[i.sessions.length," session",i.sessions.length>1?"s":""]})}),e.jsx("span",{style:p.dayStat,children:"·"}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Accumulated duration"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"Sum of the duration of all sessions in the day"})]}),children:e.jsx("span",{style:{...p.dayStat,cursor:"default"},children:z(i.total_duration_ms)})}),e.jsx("span",{style:p.dayStat,children:"·"}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:"Day cost"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"Sum of API costs of all sessions in the day"})]}),children:e.jsxs("span",{style:{...p.badge("#3fb950"),cursor:"default"},children:["$",i.total_cost.toFixed(3)]})}),e.jsx("span",{style:p.dayStat,children:"·"}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#79c0ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Day tokens"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Sum of tokens (input + output + cache read) of all sessions in the day"})]}),children:e.jsxs("span",{style:{...p.dayStat,cursor:"default"},children:[b(i.total_tokens)," tokens"]})})]}),e.jsx("div",{style:p.sessions,children:i.sessions.map(s=>e.jsx(U,{session:s,isActive:s.id===o,selectable:!0,selected:n.includes(s.id),onSelect:O},s.id))})]},i.date))]})}export{se as HistoryView};
@@ -1,6 +0,0 @@
1
- import{j as e,T as a}from"./index-DgbWvj42.js";import{a as j,c as b,d as m,U as y,V as k,Y as S,f as z,F as w}from"./vendor-lucide-Cym0q5l_.js";import"./vendor-react-B_Jzs0gY.js";function p(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:String(t)}function u(t){return t>0&&t<.01?"<$0.01":`$${t.toFixed(2)}`}function T(t){if(!t)return null;const{opusTokens:n,sonnetTokens:l,haikuTokens:s}=t;return n===0&&l===0&&s===0?null:n>=l&&n>=s?{label:"Opus",color:"#d29922"}:l>=s?{label:"Sonnet",color:"#58a6ff"}:{label:"Haiku",color:"#3fb950"}}function W(t){if(!t)return"never";const n=Date.now()-t;return n<6e4?"just now":n<36e5?`${Math.round(n/6e4)}m ago`:n<864e5?`${Math.round(n/36e5)}h ago`:n<7*864e5?`${Math.round(n/864e5)}d ago`:new Date(t).toLocaleDateString("en",{day:"numeric",month:"short"})}function F({usage:t}){const n=t.opusTokens+t.sonnetTokens+t.haikuTokens;if(n===0)return null;const l=[{label:"Sonnet",tokens:t.sonnetTokens,color:"#58a6ff"},{label:"Opus",tokens:t.opusTokens,color:"#d29922"},{label:"Haiku",tokens:t.haikuTokens,color:"#3fb950"}].filter(s=>s.tokens>0);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[e.jsx(a,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:6},children:"Usage by model"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:l.map(s=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:s.color,flexShrink:0}}),e.jsx("span",{style:{color:s.color,fontSize:10,fontWeight:700,width:42},children:s.label}),e.jsxs("span",{style:{color:"#c9d1d9",fontSize:10},children:[p(s.tokens)," tok"]}),e.jsxs("span",{style:{color:"#484f58",fontSize:9},children:[Math.round(s.tokens/n*100),"%"]})]},s.label))})]}),children:e.jsx("span",{style:{color:"#7d8590",fontSize:10,marginBottom:1},children:"model usage"})}),e.jsx("div",{style:{display:"flex",height:5,borderRadius:3,overflow:"hidden",gap:1},children:l.map(s=>e.jsx("div",{style:{height:"100%",width:`${Math.round(s.tokens/n*100)}%`,background:s.color,minWidth:s.tokens>0?2:0}},s.label))}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:l.map(s=>e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:3},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:s.color,flexShrink:0}}),e.jsx("span",{style:{color:s.color,fontSize:9,fontWeight:700},children:s.label}),e.jsx("span",{style:{color:"#7d8590",fontSize:9},children:p(s.tokens)})]},s.label))})]})}const I={tip:"#58a6ff",warning:"#d29922",positive:"#3fb950"},H={tip:y,warning:m,positive:z};function C({insights:t}){const[n,l]=j.useState(!1);if(t.length===0)return null;const s=t.filter(r=>r.level==="warning").length,h=s>0?"#d29922":"#58a6ff";return e.jsxs("div",{style:{borderTop:"1px solid #21262d",paddingTop:8},children:[e.jsxs("button",{onClick:()=>l(r=>!r),style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",background:"none",border:"none",cursor:"pointer",padding:"4px 0"},children:[e.jsxs("span",{style:{color:h,fontSize:11,fontWeight:700,display:"flex",alignItems:"center",gap:5},children:[s>0?e.jsx(m,{size:12}):e.jsx(y,{size:12}),t.length," insight",t.length>1?"s":"",s>0&&e.jsxs("span",{style:{color:"#d29922",fontSize:10},children:["· ",s," warning",s>1?"s":""]})]}),n?e.jsx(k,{size:14,color:"#484f58"}):e.jsx(S,{size:14,color:"#484f58"})]}),n&&e.jsx("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:6},children:t.map((r,x)=>{const c=I[r.level];return e.jsxs("div",{style:{background:c+"0d",border:`1px solid ${c}30`,borderRadius:6,padding:"7px 10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:3},children:[(()=>{const g=H[r.level];return e.jsx(g,{size:11,color:c})})(),e.jsx("span",{style:{color:c,fontSize:11,fontWeight:700},children:r.title}),r.metric&&e.jsx("span",{style:{color:"#7d8590",fontSize:9,marginLeft:"auto"},children:r.metric})]}),e.jsx("p",{style:{color:"#8b949e",fontSize:10,margin:0,lineHeight:1.5},children:r.description})]},x)})})]})}const i={card:t=>({background:t?"#1c2128":"#161b22",border:`1px solid ${t?"#1f6feb":"#21262d"}`,borderRadius:10,padding:"14px 16px",display:"flex",flexDirection:"column",gap:10,cursor:"default",transition:"border-color 0.2s"}),header:{display:"flex",alignItems:"center",gap:8},name:{color:"#e6edf3",fontWeight:700,fontSize:15,flex:1},activeBadge:{color:"#3fb950",background:"#3fb95018",border:"1px solid #3fb95030",borderRadius:4,padding:"1px 7px",fontSize:10,fontWeight:700},autoBadge:{color:"#7d8590",background:"#7d859015",border:"1px solid #7d859030",borderRadius:4,padding:"1px 6px",fontSize:9},path:{color:"#7d8590",fontSize:10,marginTop:-4},progressWrap:{display:"flex",flexDirection:"column",gap:4},progressRow:{display:"flex",alignItems:"center",justifyContent:"space-between"},progressLabel:{color:"#7d8590",fontSize:11},progressPct:t=>({color:t>=80?"#3fb950":t>=50?"#d29922":"#7d8590",fontWeight:700,fontSize:12}),barTrack:{height:6,background:"#21262d",borderRadius:3,overflow:"hidden"},barFill:t=>({height:"100%",width:`${t}%`,background:t>=80?"#3fb950":t>=50?"#d29922":"#58a6ff",borderRadius:3,transition:"width 0.5s ease",boxShadow:`0 0 4px ${t>=80?"#3fb95088":t>=50?"#d2992288":"#58a6ff88"}`}),nextTask:{color:"#58a6ff",fontSize:10,fontStyle:"italic",opacity:.85,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},stats:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8,marginTop:2},stat:{display:"flex",flexDirection:"column",gap:1},statVal:{color:"#e6edf3",fontWeight:700,fontSize:12},statLbl:{color:"#7d8590",fontSize:10}};function B({project:t,isActive:n}){const l=!!t.auto_handoff,s=T(t.model_usage);return e.jsxs("div",{style:i.card(!!n),children:[e.jsxs("div",{children:[e.jsxs("div",{style:i.header,children:[e.jsxs("span",{style:{...i.name,display:"flex",alignItems:"center",gap:6},children:[e.jsx(b,{size:14,color:"#6e7681",style:{flexShrink:0}}),t.name]}),n&&e.jsx(a,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:"Active project"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Claude Code is currently working in this directory"})]}),children:e.jsx("span",{style:i.activeBadge,children:"● active"})}),l&&e.jsx(a,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#7d8590",fontWeight:700,fontSize:12,marginBottom:4},children:"Auto-generated HANDOFF"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"The daemon generated an automatic HANDOFF.md. Edit it to record your pending tasks."})]}),children:e.jsx("span",{style:i.autoBadge,children:"HANDOFF auto"})})]}),e.jsx(a,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Project path"}),e.jsx("div",{style:{color:"#79c0ff",fontSize:10,fontFamily:"monospace",wordBreak:"break-all"},children:t.path})]}),children:e.jsx("div",{style:i.path,children:t.path.split("/").slice(-3).join("/")})})]}),t.has_handoff?e.jsx("div",{style:i.progressWrap,children:t.progress.total===0?e.jsx("span",{style:{...i.progressLabel,fontStyle:"italic"},children:l?"→ Auto-generated HANDOFF — fill in the sections with your tasks":"no tasks recorded"}):t.progress.done===0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:i.progressLabel,children:[t.progress.total," pending task",t.progress.total>1?"s":""]}),t.progress.nextTask&&e.jsxs("div",{style:i.nextTask,children:["→ next: ",t.progress.nextTask]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:i.progressRow,children:[e.jsxs("span",{style:i.progressLabel,children:[t.progress.done,"/",t.progress.total," tasks"]}),e.jsx(a,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"HANDOFF progress"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:[t.progress.done," completed task",t.progress.done!==1?"s":""," out of ",t.progress.total," in HANDOFF.md"]})]}),children:e.jsxs("span",{style:i.progressPct(t.progress.pct),children:[t.progress.pct,"%"]})})]}),e.jsx("div",{style:i.barTrack,children:e.jsx("div",{style:i.barFill(t.progress.pct)})}),t.progress.nextTask&&e.jsxs("div",{style:i.nextTask,children:["→ next: ",t.progress.nextTask]})]})}):null,t.model_usage&&e.jsx(F,{usage:t.model_usage}),e.jsxs("div",{style:i.stats,children:[e.jsx(a,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:"Total cost"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Sum of all API costs of the sessions in this project"})]}),children:e.jsxs("div",{style:i.stat,children:[e.jsx("span",{style:i.statVal,children:u(t.total_cost_usd)}),e.jsxs("span",{style:i.statLbl,children:["total cost",t.session_count>1&&e.jsxs("span",{style:{color:"#484f58",marginLeft:3},children:["· ",u(t.total_cost_usd/t.session_count),"/ses"]})]})]})}),e.jsx(a,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#79c0ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Total tokens"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:["Input + Output + Cache read accumulated.",e.jsx("br",{}),s?e.jsxs(e.Fragment,{children:["Dominant model: ",e.jsx("span",{style:{color:s.color,fontWeight:700},children:s.label})]}):"No model data"]})]}),children:e.jsxs("div",{style:i.stat,children:[e.jsx("span",{style:i.statVal,children:p(t.total_tokens)}),e.jsxs("span",{style:i.statLbl,children:["tokens",s&&e.jsxs("span",{style:{color:s.color,marginLeft:3},children:["· ",s.label]})]})]})}),e.jsx(a,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Sessions"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Total recorded sessions, including those before claudestat was installed (read from Claude Code JSONL files)."})]}),children:e.jsxs("div",{style:i.stat,children:[e.jsx("span",{style:i.statVal,children:t.session_count}),e.jsx("span",{style:i.statLbl,children:"sessions"})]})}),e.jsx(a,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Last activity"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:t.last_active?new Date(t.last_active).toLocaleString("en",{dateStyle:"medium",timeStyle:"short"}):"No activity recorded"})]}),children:e.jsxs("div",{style:i.stat,children:[e.jsx("span",{style:i.statVal,children:W(t.last_active)}),e.jsx("span",{style:i.statLbl,children:"last seen"})]})})]}),t.insights&&t.insights.length>0&&e.jsx(C,{insights:t.insights})]})}const _=j.memo(B);function v(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:String(t)}function L({data:t}){if(t.length===0)return null;const n=Math.max(...t.map(s=>s.tokens),1),l=["M","T","W","T","F","S","S"];return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3},children:[e.jsx("div",{style:{display:"flex",gap:3},children:t.slice(-7).map((s,h)=>{const r=s.tokens/n,x=r<.05?"#1c2128":r<.3?"#0e4429":r<.6?"#006d32":r<.85?"#26a641":"#39d353";return e.jsx(a,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:3},children:s.date}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10},children:[v(s.tokens)," tokens that day"]})]}),children:e.jsx("div",{style:{width:12,height:12,borderRadius:2,background:x,border:"1px solid #21262d"}})},h)})}),e.jsx("div",{style:{display:"flex",gap:3},children:t.slice(-7).map((s,h)=>e.jsx("span",{style:{width:12,fontSize:8,color:"#484f58",textAlign:"center"},children:l[h]},h))})]})}function D(){return e.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:10,padding:"14px 16px",display:"flex",flexDirection:"column",gap:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{width:120,height:14,borderRadius:4,background:"#21262d",animation:"skeletonShimmer 1.4s ease-in-out infinite"}}),e.jsx("div",{style:{width:40,height:14,borderRadius:4,background:"#21262d",animation:"skeletonShimmer 1.4s ease-in-out infinite 0.2s"}})]}),e.jsx("div",{style:{width:"70%",height:10,borderRadius:3,background:"#21262d",animation:"skeletonShimmer 1.4s ease-in-out infinite 0.1s"}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8},children:[0,1,2,3].map(t=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx("div",{style:{height:12,borderRadius:3,background:"#21262d",animation:`skeletonShimmer 1.4s ease-in-out infinite ${t*.1}s`}}),e.jsx("div",{style:{height:8,borderRadius:2,background:"#21262d",animation:`skeletonShimmer 1.4s ease-in-out infinite ${t*.1+.1}s`}})]},t))})]})}const o={wrap:{padding:"16px 24px",overflowY:"auto",height:"100%"},summary:{display:"flex",alignItems:"center",gap:20,padding:"12px 16px",marginBottom:20,background:"#161b22",borderRadius:8,border:"1px solid #21262d",flexWrap:"wrap"},sumItem:{display:"flex",flexDirection:"column",gap:2},sumVal:{color:"#e6edf3",fontWeight:700,fontSize:16},sumLbl:{color:"#7d8590",fontSize:11},grid:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:12},sep:{width:1,height:32,background:"#21262d",flexShrink:0}};function A({projects:t,activeProject:n,weeklyData:l=[],loading:s=!1}){const h=t.reduce((d,f)=>d+f.total_cost_usd,0),r=t.reduce((d,f)=>d+f.total_tokens,0),x=t.reduce((d,f)=>d+f.session_count,0),c=t.filter(d=>d.has_handoff&&!d.auto_handoff),g=c.length>0?Math.round(c.reduce((d,f)=>d+f.progress.pct,0)/c.length):0;return e.jsxs("div",{style:o.wrap,children:[e.jsx("style",{children:`
2
- @keyframes skeletonShimmer {
3
- 0%,100% { opacity: 1 }
4
- 50% { opacity: 0.4 }
5
- }
6
- `}),e.jsxs("div",{style:o.summary,children:[e.jsx(a,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Projects"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:["Number of projects detected by claudestat in ",e.jsx("code",{children:"~/.claude/projects/"})]})]}),children:e.jsxs("div",{style:o.sumItem,children:[e.jsx("span",{style:o.sumVal,children:t.length}),e.jsx("span",{style:o.sumLbl,children:"projects"})]})}),e.jsx("div",{style:o.sep}),e.jsx(a,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:"Total cost"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Sum of all API costs of all sessions across all projects"})]}),children:e.jsxs("div",{style:o.sumItem,children:[e.jsxs("span",{style:o.sumVal,children:["$",h.toFixed(2)]}),e.jsx("span",{style:o.sumLbl,children:"total cost"})]})}),e.jsx("div",{style:o.sep}),e.jsx(a,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#79c0ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Total tokens"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Input + Output + Cache read accumulated across all projects"})]}),children:e.jsxs("div",{style:o.sumItem,children:[e.jsx("span",{style:o.sumVal,children:v(r)}),e.jsx("span",{style:o.sumLbl,children:"total tokens"})]})}),e.jsx("div",{style:o.sep}),e.jsx(a,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Historical sessions"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Total sessions recorded by claudestat across all projects"})]}),children:e.jsxs("div",{style:o.sumItem,children:[e.jsx("span",{style:o.sumVal,children:x}),e.jsx("span",{style:o.sumLbl,children:"historical sessions"})]})}),c.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:o.sep}),e.jsx(a,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Average progress"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:["% of completed tasks averaged across ",c.length," project",c.length!==1?"s":""," with HANDOFF.md"]})]}),children:e.jsxs("div",{style:o.sumItem,children:[e.jsxs("span",{style:{...o.sumVal,color:g>=70?"#3fb950":"#d29922"},children:[g,"%"]}),e.jsx("span",{style:o.sumLbl,children:"average progress"})]})})]}),l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:o.sep}),e.jsx(L,{data:l})]})]}),s&&e.jsx("div",{style:o.grid,children:[0,1,2].map(d=>e.jsx(D,{},d))}),!s&&t.length===0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"60px 0",gap:16,color:"#484f58"},children:[e.jsx(w,{size:48,strokeWidth:1.2,color:"#30363d"}),e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{color:"#6e7681",fontWeight:600,fontSize:14,marginBottom:6},children:"No projects detected"}),e.jsxs("div",{style:{color:"#484f58",fontSize:12,lineHeight:1.6},children:["Projects appear automatically when",e.jsx("br",{}),"Claude Code accesses files in their directories."]})]})]}),!s&&t.length>0&&e.jsx("div",{style:o.grid,children:t.map(d=>e.jsx(_,{project:d,isActive:d.path===n},d.path))})]})}export{A as ProjectsView};
@@ -1 +0,0 @@
1
- import{j as e,T as r}from"./index-DgbWvj42.js";import{L as T,a as h,Z as y,B as M,a8 as v,n as O,S as E,f as L,s as S,a9 as W,Y as R,aa as $}from"./vendor-lucide-Cym0q5l_.js";import"./vendor-react-B_Jzs0gY.js";function N(t,s){return s>0?Math.round(t/s*100):0}function b(t){if(!t)return"";const s=t.match(/(?:node|python3?|bash|sh|deno|bun)\s+[~\w/.]+\/([\w.-]+)/);return s?`…/${s[1]}`:t.slice(0,50)}function f({children:t,style:s}){return e.jsx("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"14px 16px",...s},children:t})}function x({icon:t,title:s,subtitle:l,color:n="#58a6ff",open:o,onToggle:i,badge:d}){return e.jsxs("button",{onClick:i,style:{display:"flex",alignItems:"center",gap:8,width:"100%",background:"none",border:"none",cursor:"pointer",padding:0,marginBottom:o?12:0},children:[e.jsx(t,{size:13,color:n}),e.jsx("span",{style:{fontSize:12,color:"#e6edf3",fontWeight:700,flex:1,textAlign:"left"},children:s}),l&&e.jsx("span",{style:{fontSize:10,color:"#484f58"},children:l}),d,o?e.jsx(R,{size:12,color:"#484f58"}):e.jsx($,{size:12,color:"#484f58"})]})}function a({label:t,value:s,last:l=!1,color:n="#8b949e",tip:o}){const i=e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,paddingLeft:16,position:"relative"},children:[e.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:l?"50%":0,width:1,background:"#21262d"}}),e.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:10,height:1,background:"#21262d"}}),e.jsx("span",{style:{fontSize:11,color:n,fontWeight:500},children:t}),s!==void 0&&e.jsx("span",{style:{fontSize:10,color:"#484f58",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:s})]});return o?e.jsx(r,{position:"top",align:"left",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:o}),children:i}):i}function p({text:t,color:s}){return e.jsx("span",{style:{fontSize:10,fontWeight:600,color:s,background:s+"18",border:`1px solid ${s}35`,borderRadius:4,padding:"1px 6px"},children:t})}const I={SessionStart:{label:"SessionStart",tip:"Runs when each Claude Code session starts. Loads Engram context and the project HANDOFF."},PreToolUse:{label:"PreToolUse",tip:"Runs before each tool call. claudestat uses it to check the kill-switch and record the event start."},PostToolUse:{label:"PostToolUse",tip:"Runs after each tool call with the result. claudestat sends the event to the daemon to enrich it with cost and duration."},Stop:{label:"Stop",tip:"Runs when Claude finishes responding. claudestat records the full block and emits the stop event for SSE."}};function A({hooks:t}){const[s,l]=h.useState(!0),n=Object.keys(t),o=n.length;return e.jsxs(f,{children:[e.jsx(x,{icon:y,title:"Active hooks",color:"#d29922",subtitle:o>0?void 0:"none configured",badge:o>0?e.jsx(p,{text:`${o} hooks`,color:"#d29922"}):void 0,open:s,onToggle:()=>l(i=>!i)}),s&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:o===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No hooks in ~/.claude/settings.json — claudestat is not active"}):n.map((i,d)=>{var m;const u=t[i],c=I[i];return e.jsx(r,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#d29922",fontWeight:700,fontSize:11,marginBottom:3},children:(c==null?void 0:c.label)??i}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:(c==null?void 0:c.tip)??""}),u.map((w,C)=>e.jsx("div",{style:{color:"#3d444d",fontFamily:"monospace",fontSize:9,marginTop:4},children:b(w.command)},C))]}),children:e.jsx(a,{label:(c==null?void 0:c.label)??i,value:e.jsx("span",{style:{fontFamily:"monospace",color:"#3d444d"},children:b(((m=u[0])==null?void 0:m.command)??"")}),last:d===n.length-1,color:"#d29922"})},i)})})]})}function B({agents:t}){const[s,l]=h.useState(!0);return e.jsxs(f,{children:[e.jsx(x,{icon:M,title:"Available agents",color:"#bc8cff",subtitle:"~/.claude/agents/",badge:t.length>0?e.jsx(p,{text:`${t.length}`,color:"#bc8cff"}):void 0,open:s,onToggle:()=>l(n=>!n)}),s&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:t.length===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No agents in ~/.claude/agents/"}):t.map((n,o)=>e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#bc8cff",fontWeight:700,fontSize:11,marginBottom:3},children:n.name}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:n.description||"No description in the .md file frontmatter"})]}),children:e.jsx(a,{label:n.name,last:o===t.length-1,color:"#bc8cff",value:n.description?e.jsxs("span",{style:{color:"#3d444d",maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"inline-block"},children:[n.description.slice(0,40),n.description.length>40?"…":""]}):void 0})},n.name))})]})}const g=500;function F({skills:t}){const[s,l]=h.useState(!0),n=t.filter(o=>o.lines>=g*.9).length;return e.jsxs(f,{children:[e.jsx(x,{icon:y,title:"Available skills",color:"#3fb950",subtitle:"~/.claude/commands/",badge:t.length>0?e.jsx(p,{text:`${t.length}${n>0?` · ${n} ⚠`:""}`,color:n>0?"#d29922":"#3fb950"}):void 0,open:s,onToggle:()=>l(o=>!o)}),s&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:t.length===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No skills in ~/.claude/commands/"}):t.map((o,i)=>{const d=o.lines/g,u=z(d),c=d>=.7;return e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:"#3fb950",fontWeight:700,fontSize:11,marginBottom:3},children:["/",o.name]}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:o.description||"No description in the .md file frontmatter"}),e.jsxs("div",{style:{color:u,fontSize:9,marginTop:4},children:[o.lines," lines ",c?`— recommended limit: ${g}`:`/ ${g} recommended`]})]}),children:e.jsx(a,{label:`/${o.name}`,last:i===t.length-1,color:"#3fb950",value:e.jsxs("span",{style:{color:u,fontVariantNumeric:"tabular-nums"},children:[o.lines," ln ",c?"⚠":""]})})},o.name)})})]})}function D({memoryFiles:t}){const[s,l]=h.useState(!0),n=t.length>0;return e.jsxs(f,{children:[e.jsx(x,{icon:W,title:"Memory system",color:"#58a6ff",badge:n?e.jsx(p,{text:`${t.length} files`,color:"#58a6ff"}):void 0,open:s,onToggle:()=>l(o=>!o)}),s&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:n?t.map((o,i)=>e.jsx(a,{label:o,last:i===t.length-1,color:o==="MEMORY.md"?"#79c0ff":"#58a6ff",tip:o==="MEMORY.md"?"Auto-loaded index — every session reads this file automatically.":`Memory file: ~/.claude/projects/…/memory/${o}`},o)):e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"Engram not detected. Optional MCP plugin for persistent memory between sessions."})})]})}function H({workflows:t}){const[s,l]=h.useState(!0);return e.jsxs(f,{children:[e.jsx(x,{icon:v,title:"Workflows / pipelines",color:"#56d364",subtitle:"~/.claude/agents/workflows/",badge:t.length>0?e.jsx(p,{text:`${t.length}`,color:"#56d364"}):void 0,open:s,onToggle:()=>l(n=>!n)}),s&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:t.length===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No workflows in ~/.claude/agents/workflows/"}):t.map((n,o)=>e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#56d364",fontWeight:700,fontSize:11,marginBottom:3},children:n.name}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:n.description||"No description in the .md file frontmatter"})]}),children:e.jsx(a,{label:n.name,last:o===t.length-1,color:"#56d364",value:n.description?e.jsxs("span",{style:{color:"#3d444d"},children:[n.description.slice(0,40),n.description.length>40?"…":""]}):void 0})},n.name))})]})}const P={"CLAUDE.md global":"Permanent instructions for Claude: profile, response style, code rules and project protocol. Loaded every session.","MEMORY.md":"Engram auto-memory index. Auto-loaded into every session via system prompt. Keep under 200 lines — content after line 200 is truncated.","settings.json":"Claude Code configuration: installed hooks, permissions, default model. claudestat needs the hooks here to work.","config claudestat":"Active claudestat configuration: plan, kill switch and quota thresholds. Read on every PreToolUse hook evaluation."},k={"CLAUDE.md global":{lines:200},"MEMORY.md":{lines:200}};function z(t){return t>=.9?"#f85149":t>=.7?"#d29922":"#3fb950"}function K(t,s,l){const n=k[l];if(!n)return null;const o=n.lines?t/n.lines:0,i=n.kb?s/n.kb:0;return z(Math.max(o,i))}function U({f:t}){if(!t.exists)return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:"#f85149"},children:[e.jsx(S,{size:9})," not found"]});const s=K(t.lines,t.sizeKb,t.key),l=s??"#3fb950",n=k[t.key],o=n!=null&&n.lines?`${t.lines} ln / ${n.lines}`:t.sizeKb>0?`${t.sizeKb} KB`:"< 1 KB";return e.jsxs("span",{style:{color:l},children:[o," ",s?"⚠":"✓"]})}function _({files:t}){const[s,l]=h.useState(!0),n=t.filter(o=>o.exists).length;return e.jsxs(f,{children:[e.jsx(x,{icon:O,title:"Context files",color:"#3fb950",badge:e.jsx(p,{text:`${n}/${t.length}`,color:"#3fb950"}),open:s,onToggle:()=>l(o=>!o)}),s&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:t.map((o,i)=>e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:11,marginBottom:3},children:o.key}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:P[o.key]??"System configuration file."})]}),children:e.jsx(a,{label:o.key,last:i===t.length-1,color:o.exists?"#e6edf3":"#484f58",value:e.jsx(U,{f:o})})},o.key))})]})}const Y={free:"Free",pro:"Pro",max5:"Max 5×",max20:"Max 20×"},j=[{key:"direct",label:"Claude direct",when:"≤ 2 files, no new endpoints",color:"#3fb950",tip:"Claude works alone. Ideal for small changes: CSS, text, simple bugs. No agents or pipeline."},{key:"mini",label:"Mini-pipeline",when:"3–5 files or 1–2 new endpoints",color:"#58a6ff",tip:"3 agents: implementer → quality-docs → tester. Git is not automatic — invoke with /git when the user decides."},{key:"pipeline",label:"Full pipeline",when:"≥ 6 files or new feature",color:"#d29922",tip:"Full agent team. Scrum master, backend, frontend, quality-docs, tester. Git separate — invoke /git when you decide. For large features."}];function q({dist:t}){const[s,l]=h.useState(!0),n=t.total>0?j.reduce((o,i)=>t[i.key]>t[o.key]?i:o,j[0]):null;return e.jsxs(f,{children:[e.jsx(x,{icon:v,title:"Work modes",color:"#f0883e",subtitle:"last 7 days",badge:n&&t.total>0?e.jsx(p,{text:`most used: ${n.label}`,color:n.color}):void 0,open:s,onToggle:()=>l(o=>!o)}),s&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[j.map(o=>{const i=t[o.key],d=N(i,t.total);return e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:o.color,fontWeight:700,fontSize:11,marginBottom:3},children:o.label}),e.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:[e.jsx("span",{style:{color:"#6e7681"},children:"When: "}),o.when,e.jsx("br",{}),o.tip]})]}),children:e.jsxs("div",{style:{cursor:"help"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[e.jsx("span",{style:{fontSize:11,color:o.color,fontWeight:600,width:130,flexShrink:0},children:o.label}),e.jsx("span",{style:{fontSize:10,color:"#484f58",flex:1},children:o.when}),e.jsx("span",{style:{fontSize:11,color:"#e6edf3",fontVariantNumeric:"tabular-nums",fontWeight:600},children:t.total>0?`${i} (${d}%)`:"—"})]}),e.jsx("div",{style:{height:4,background:"#21262d",borderRadius:2,overflow:"hidden"},children:e.jsx("div",{style:{width:`${d}%`,height:"100%",background:o.color,borderRadius:2,transition:"width 0.5s"}})})]})},o.key)}),t.total===0&&e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No sessions recorded in the last 7 days"}),t.total>0&&e.jsxs("div",{style:{fontSize:9,color:"#3d444d",marginTop:2},children:[t.total," sessions analyzed · Mode inferred by number of Agent tool calls per session"]})]})]})}function V({cfg:t}){const[s,l]=h.useState(!0),n=t.plan??"pro",o=t.killSwitchEnabled??!0,[i,d,u]=t.warnThresholds??[70,85,95];return e.jsxs(f,{children:[e.jsx(x,{icon:E,title:"claudestat config",color:"#8b949e",subtitle:"~/.claudestat/config.json",open:s,onToggle:()=>l(c=>!c)}),s&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e.jsx(a,{label:"Plan",value:e.jsx(p,{text:Y[n]??n,color:"#58a6ff"}),tip:"Claude Max plan that determines weekly hour limits per model."}),e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:o?"#3fb950":"#f85149",fontWeight:700,fontSize:11,marginBottom:3},children:["Kill switch ",o?"enabled":"disabled"]}),e.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["When ON, blocks new tool calls if the 5h quota exceeds the red threshold.",e.jsx("br",{}),"Configure with: ",e.jsx("code",{style:{color:"#d29922"},children:"claudestat config"})]})]}),children:e.jsx(a,{label:"Kill switch",value:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,color:o?"#3fb950":"#f85149"},children:[o?e.jsx(L,{size:10}):e.jsx(S,{size:10}),o?"ON":"OFF"]}),color:o?"#3fb950":"#f85149"})}),e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:3},children:"Quota alert thresholds"}),e.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Percentage of the 5h quota that triggers each SSE alert level.",e.jsx("br",{}),"🟡 warning → 🟠 orange → 🔴 red (kill switch)"]})]}),children:e.jsx(a,{label:"Thresholds",last:!0,value:e.jsxs("span",{style:{display:"inline-flex",gap:6},children:[e.jsxs("span",{style:{color:"#d29922"},children:[i,"%"]}),e.jsxs("span",{style:{color:"#f0883e"},children:[d,"%"]}),e.jsxs("span",{style:{color:"#f85149"},children:[u,"%"]})]})})})]})]})}function Q({config:t,error:s,onRetry:l}){return t?e.jsxs("div",{style:{height:"100%",overflow:"auto",padding:"16px 20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:16},children:[e.jsx(T,{size:16,color:"#58a6ff"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"#e6edf3"},children:"System map"}),e.jsx("div",{style:{fontSize:11,color:"#484f58"},children:"How Claude Code is configured on this machine"})]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8,alignItems:"center"},children:[e.jsx(r,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Active Claude Code hooks in settings.json"}),children:e.jsxs("span",{style:{fontSize:10,color:"#d29922",background:"#d2992215",border:"1px solid #d2992235",borderRadius:4,padding:"2px 7px",cursor:"help"},children:[Object.keys(t.hooks).length," hooks"]})}),e.jsx(r,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Available agents in ~/.claude/agents/"}),children:e.jsxs("span",{style:{fontSize:10,color:"#bc8cff",background:"#bc8cff15",border:"1px solid #bc8cff35",borderRadius:4,padding:"2px 7px",cursor:"help"},children:[t.agents.length," agents"]})}),e.jsx(r,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Workflows in ~/.claude/agents/workflows/"}),children:e.jsxs("span",{style:{fontSize:10,color:"#56d364",background:"#56d36415",border:"1px solid #56d36435",borderRadius:4,padding:"2px 7px",cursor:"help"},children:[t.workflows.length," workflows"]})}),e.jsx(r,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Skills in ~/.claude/commands/"}),children:e.jsxs("span",{style:{fontSize:10,color:"#3fb950",background:"#3fb95015",border:"1px solid #3fb95035",borderRadius:4,padding:"2px 7px",cursor:"help"},children:[t.skills.length," skills"]})}),e.jsx(r,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Memory files in Engram"}),children:e.jsxs("span",{style:{fontSize:10,color:"#58a6ff",background:"#58a6ff15",border:"1px solid #58a6ff35",borderRadius:4,padding:"2px 7px",cursor:"help"},children:[t.memoryFiles.length," memories"]})}),l&&e.jsx(r,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Refresh system configuration"}),children:e.jsx("button",{onClick:l,style:{background:"none",border:"1px solid #30363d",borderRadius:4,padding:"2px 7px",cursor:"pointer",color:"#6e7681",fontSize:12,lineHeight:1,transition:"color 0.15s, border-color 0.15s"},onMouseEnter:n=>{n.currentTarget.style.color="#e6edf3",n.currentTarget.style.borderColor="#6e7681"},onMouseLeave:n=>{n.currentTarget.style.color="#6e7681",n.currentTarget.style.borderColor="#30363d"},children:"↺"})})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,maxWidth:1200,margin:"0 auto"},children:[e.jsx(F,{skills:t.skills}),e.jsx(B,{agents:t.agents}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(H,{workflows:t.workflows??[]})}),e.jsx(q,{dist:t.modeDistribution}),e.jsx(A,{hooks:t.hooks}),e.jsx(_,{files:t.contextFiles}),e.jsx(V,{cfg:t.claudestatConfig}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(D,{memoryFiles:t.memoryFiles})})]})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:12},children:s?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#f85149",fontSize:13},children:"Error loading system configuration"}),l&&e.jsx("button",{onClick:l,style:{padding:"5px 14px",fontSize:12,fontWeight:600,cursor:"pointer",background:"none",border:"1px solid #f8514966",borderRadius:5,color:"#f85149",transition:"background 0.15s"},children:"Retry"})]}):e.jsx("span",{style:{color:"#6e7681",fontSize:13},children:"Loading system configuration…"})})}export{Q as SystemView};
@@ -1 +0,0 @@
1
- import{j as t,T as l}from"./index-DgbWvj42.js";import{a as c,a3 as S,a6 as C,a0 as W,a7 as z,W as k}from"./vendor-lucide-Cym0q5l_.js";import"./vendor-react-B_Jzs0gY.js";function g(o){return o<.001?"$0":o<.01?`$${o.toFixed(4)}`:o<1?`$${o.toFixed(3)}`:`$${o.toFixed(2)}`}function $(o){return o<1e3?`${o}ms`:o<6e4?`${(o/1e3).toFixed(1)}s`:`${(o/6e4).toFixed(1)}m`}const a=["#58a6ff","#3fb950","#d29922","#f0883e","#bc8cff","#f778ba","#79c0ff","#56d364","#e3b341","#ff7b72"];function w(){const[o,h]=c.useState(),[s,p]=c.useState(),[i,j]=c.useState("cost"),[r,m]=c.useState(30);c.useEffect(()=>{fetch(`/api/top?by=${i}&limit=10&days=${r}`).then(e=>e.ok?e.json():void 0).then(e=>e&&h(e)).catch(()=>{}),fetch("/cost-projection").then(e=>e.ok?e.json():void 0).then(e=>e&&p(e)).catch(()=>{})},[i,r]);const d=(o==null?void 0:o.tools)??[],u=Math.max(...d.map(e=>e.estimatedCostUsd),.001),b=Math.max(...d.map(e=>e.count),1);return t.jsxs("div",{style:{height:"100%",overflow:"auto",padding:"20px 24px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:20,flexWrap:"wrap"},children:[t.jsx("h2",{style:{margin:0,fontSize:18,fontWeight:700,color:"#e6edf3"},children:"Tool Rankings"}),t.jsx("div",{style:{display:"flex",gap:6},children:[{key:"cost",label:"Cost",icon:S,color:"#3fb950",tip:"Estimated USD cost per tool, calculated from each tool's share of total token usage"},{key:"count",label:"Calls",icon:C,color:"#58a6ff",tip:"Total number of invocations in the selected period"},{key:"duration",label:"Duration",icon:W,color:"#e3b341",tip:"Cumulative execution time (sum of all calls)"}].map(({key:e,label:n,icon:x,color:f,tip:v})=>t.jsx(l,{position:"bottom",align:"left",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsxs("div",{style:{fontWeight:700,color:f,marginBottom:4},children:["Sort by ",n.toLowerCase()]}),t.jsx("div",{style:{color:"#7d8590"},children:v})]}),children:t.jsxs("button",{onClick:()=>j(e),style:{display:"flex",alignItems:"center",gap:5,padding:"4px 10px",fontSize:11,fontWeight:i===e?600:400,color:i===e?"#e6edf3":"#8b949e",background:i===e?"#21262d":"transparent",border:`1px solid ${i===e?"#30363d":"transparent"}`,borderRadius:5,cursor:"pointer"},children:[t.jsx(x,{size:11})," ",n]})},e))}),t.jsx("div",{style:{display:"flex",gap:4},children:[7,30,90].map(e=>t.jsxs("button",{onClick:()=>m(e),style:{padding:"4px 8px",fontSize:11,fontWeight:r===e?600:400,color:r===e?"#e6edf3":"#8b949e",background:r===e?"#21262d":"transparent",border:`1px solid ${r===e?"#30363d":"transparent"}`,borderRadius:5,cursor:"pointer"},children:[e,"d"]},e))})]}),s&&t.jsxs("div",{style:{display:"flex",gap:12,marginBottom:20},children:[t.jsx(y,{label:"This week",tooltip:"Cost accumulated since Monday of the current week, extrapolated to 7 days",costSoFar:s.weekly.costSoFar,projected:s.weekly.projected,daysWithData:s.weekly.daysWithData}),t.jsx(y,{label:"This month",tooltip:"Cost accumulated since the 1st of the current month, extrapolated to 30 days",costSoFar:s.monthly.costSoFar,projected:s.monthly.projected,daysWithData:s.monthly.daysWithData})]}),d.length===0?t.jsx("div",{style:{color:"#8b949e",fontSize:13,textAlign:"center",marginTop:40},children:"No tool usage data for this period."}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"32px 140px 70px 80px 80px",gap:8,padding:"0 8px",fontSize:10,fontWeight:600,color:"#8b949e",textTransform:"uppercase",letterSpacing:"0.5px"},children:[t.jsx("span",{children:"#"}),t.jsx("span",{children:"Tool"}),t.jsx("span",{style:{textAlign:"right"},children:t.jsx(l,{position:"bottom",align:"right",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsx("div",{style:{fontWeight:700,color:"#58a6ff",marginBottom:4},children:"Calls"}),t.jsx("div",{style:{color:"#7d8590"},children:"Total invocations in the selected period"})]}),children:"Calls"})}),t.jsx("span",{style:{textAlign:"right"},children:t.jsx(l,{position:"bottom",align:"right",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsx("div",{style:{fontWeight:700,color:"#e3b341",marginBottom:4},children:"Duration"}),t.jsx("div",{style:{color:"#7d8590"},children:"Cumulative execution time across all calls"})]}),children:"Duration"})}),t.jsx("span",{style:{textAlign:"right"},children:t.jsx(l,{position:"bottom",align:"right",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsx("div",{style:{fontWeight:700,color:"#3fb950",marginBottom:4},children:"Est. Cost"}),t.jsxs("div",{style:{color:"#7d8590"},children:["Proportion of total session cost",t.jsx("br",{}),"attributed to each tool by call count"]})]}),children:"Est. Cost"})})]}),d.map((e,n)=>{const x=i==="cost"?e.estimatedCostUsd/u:i==="count"?e.count/b:e.totalDurationMs/Math.max(...d.map(f=>f.totalDurationMs),1);return t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"32px 140px 70px 80px 80px",gap:8,padding:"8px",fontSize:12,color:"#e6edf3",background:"#161b22",border:"1px solid #21262d",borderRadius:6,position:"relative",overflow:"hidden"},children:[t.jsx("div",{style:{position:"absolute",top:0,left:0,bottom:0,width:`${Math.max(x*100,2)}%`,background:`${a[n%a.length]}12`,transition:"width 0.3s ease"}}),t.jsx("span",{style:{color:"#8b949e",fontWeight:600,position:"relative"},children:n+1}),t.jsx("span",{style:{display:"flex",alignItems:"center",gap:6,position:"relative"},children:e.tool==="Other"?t.jsx(l,{position:"top",align:"left",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsx("div",{style:{fontWeight:700,color:"#8b949e",marginBottom:4},children:"Other tools"}),t.jsxs("div",{style:{color:"#7d8590"},children:["Remaining cost not attributed to the",t.jsx("br",{}),"top tools listed above"]})]}),children:t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx(z,{size:11,color:"#8b949e"}),e.tool]})}):t.jsxs(t.Fragment,{children:[t.jsx(k,{size:11,color:a[n%a.length]}),e.tool]})}),t.jsx("span",{style:{textAlign:"right",color:"#8b949e",position:"relative"},children:e.tool==="Other"?"—":e.count.toLocaleString()}),t.jsx("span",{style:{textAlign:"right",color:"#8b949e",position:"relative"},children:e.tool==="Other"?"—":$(e.totalDurationMs)}),t.jsx("span",{style:{textAlign:"right",fontWeight:600,color:a[n%a.length],position:"relative"},children:g(e.estimatedCostUsd)})]},e.tool)})]})]})}function y({label:o,tooltip:h,costSoFar:s,projected:p,daysWithData:i}){return t.jsxs("div",{style:{flex:1,background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"14px 16px"},children:[t.jsx(l,{position:"top",align:"left",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsx("div",{style:{fontWeight:700,color:"#e6edf3",marginBottom:4},children:o}),t.jsx("div",{style:{color:"#7d8590"},children:h})]}),children:t.jsx("div",{style:{fontSize:11,fontWeight:600,color:"#8b949e",marginBottom:8,cursor:"default"},children:o})}),t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,marginBottom:4},children:[t.jsx("span",{style:{fontSize:22,fontWeight:700,color:"#e6edf3"},children:g(p)}),t.jsx(l,{position:"top",align:"left",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsx("div",{style:{fontWeight:700,color:"#58a6ff",marginBottom:4},children:"Projected spend"}),t.jsxs("div",{style:{color:"#7d8590"},children:["Extrapolated from daily average based on ",i.toFixed(1)," days of data"]})]}),children:t.jsx("span",{style:{fontSize:11,color:"#8b949e",cursor:"default"},children:"projected"})})]}),t.jsxs("div",{style:{fontSize:11,color:"#484f58"},children:[g(s)," spent over ",i.toFixed(1)," days"]})]})}export{w as TopView};