tokenrace 0.3.1 → 0.3.3

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.
Binary file
@@ -229,4 +229,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
229
229
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function AG(e,t){if(e){if(typeof e=="string")return Bb(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Bb(e,t)}}function wG(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function TG(e){if(Array.isArray(e))return Bb(e)}function Bb(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function EG(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function G2(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,rD(r.key),r)}}function jG(e,t,n){return t&&G2(e.prototype,t),n&&G2(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function MG(e,t,n){return t=wf(t),CG(e,nD()?Reflect.construct(t,n||[],wf(e).constructor):t.apply(e,n))}function CG(e,t){if(t&&(Mo(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return NG(e)}function NG(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function nD(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(nD=function(){return!!e})()}function wf(e){return wf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},wf(e)}function DG(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&&Lb(e,t)}function Lb(e,t){return Lb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Lb(e,t)}function Yn(e,t,n){return t=rD(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rD(e){var t=PG(e,"string");return Mo(t)=="symbol"?t:t+""}function PG(e,t){if(Mo(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Mo(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var Fl=(function(e){function t(){var n;EG(this,t);for(var r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];return n=MG(this,t,[].concat(o)),Yn(n,"state",{isAnimationFinished:!0,totalLength:0}),Yn(n,"generateSimpleStrokeDasharray",function(c,f){return"".concat(f,"px ").concat(c-f,"px")}),Yn(n,"getStrokeDasharray",function(c,f,d){var h=d.reduce(function(T,w){return T+w});if(!h)return n.generateSimpleStrokeDasharray(f,c);for(var y=Math.floor(c/h),v=c%h,g=f-c,b=[],_=0,S=0;_<d.length;S+=d[_],++_)if(S+d[_]>v){b=[].concat(to(d.slice(0,_)),[v-S]);break}var x=b.length%2===0?[0,g]:[g];return[].concat(to(t.repeat(d,y)),to(b),x).map(function(T){return"".concat(T,"px")}).join(", ")}),Yn(n,"id",ko("recharts-line-")),Yn(n,"pathRef",function(c){n.mainCurve=c}),Yn(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0}),n.props.onAnimationEnd&&n.props.onAnimationEnd()}),Yn(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1}),n.props.onAnimationStart&&n.props.onAnimationStart()}),n}return DG(t,e),jG(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var r=this.getTotalLength();this.setState({totalLength:r})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var r=this.getTotalLength();r!==this.state.totalLength&&this.setState({totalLength:r})}}},{key:"getTotalLength",value:function(){var r=this.mainCurve;try{return r&&r.getTotalLength&&r.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(r,o){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var l=this.props,c=l.points,f=l.xAxis,d=l.yAxis,h=l.layout,y=l.children,v=$n(y,Kl);if(!v)return null;var g=function(S,x){return{x:S.x,y:S.y,value:S.value,errorVal:Vt(S.payload,x)}},b={clipPath:r?"url(#clipPath-".concat(o,")"):null};return B.createElement(et,b,v.map(function(_){return B.cloneElement(_,{key:"bar-".concat(_.props.dataKey),data:c,xAxis:f,yAxis:d,layout:h,dataPointFormatter:g})}))}},{key:"renderDots",value:function(r,o,l){var c=this.props.isAnimationActive;if(c&&!this.state.isAnimationFinished)return null;var f=this.props,d=f.dot,h=f.points,y=f.dataKey,v=Ee(this.props,!1),g=Ee(d,!0),b=h.map(function(S,x){var T=pn(pn(pn({key:"dot-".concat(x),r:3},v),g),{},{index:x,cx:S.x,cy:S.y,value:S.value,dataKey:y,payload:S.payload,points:h});return t.renderDotItem(d,T)}),_={clipPath:r?"url(#clipPath-".concat(o?"":"dots-").concat(l,")"):null};return B.createElement(et,rl({className:"recharts-line-dots",key:"dots"},_),b)}},{key:"renderCurveStatically",value:function(r,o,l,c){var f=this.props,d=f.type,h=f.layout,y=f.connectNulls;f.ref;var v=I2(f,xG),g=pn(pn(pn({},Ee(v,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:o?"url(#clipPath-".concat(l,")"):null,points:r},c),{},{type:d,layout:h,connectNulls:y});return B.createElement(co,rl({},g,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(r,o){var l=this,c=this.props,f=c.points,d=c.strokeDasharray,h=c.isAnimationActive,y=c.animationBegin,v=c.animationDuration,g=c.animationEasing,b=c.animationId,_=c.animateNewValues,S=c.width,x=c.height,T=this.state,w=T.prevPoints,M=T.totalLength;return B.createElement(or,{begin:y,duration:v,isActive:h,easing:g,from:{t:0},to:{t:1},key:"line-".concat(b),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(C){var A=C.t;if(w){var E=w.length/f.length,D=f.map(function(k,Z){var Q=Math.floor(Z*E);if(w[Q]){var W=w[Q],$=kt(W.x,k.x),Y=kt(W.y,k.y);return pn(pn({},k),{},{x:$(A),y:Y(A)})}if(_){var ee=kt(S*2,k.x),oe=kt(x/2,k.y);return pn(pn({},k),{},{x:ee(A),y:oe(A)})}return pn(pn({},k),{},{x:k.x,y:k.y})});return l.renderCurveStatically(D,r,o)}var P=kt(0,M),q=P(A),V;if(d){var U="".concat(d).split(/[,\s]+/gim).map(function(k){return parseFloat(k)});V=l.getStrokeDasharray(q,M,U)}else V=l.generateSimpleStrokeDasharray(M,q);return l.renderCurveStatically(f,r,o,{strokeDasharray:V})})}},{key:"renderCurve",value:function(r,o){var l=this.props,c=l.points,f=l.isAnimationActive,d=this.state,h=d.prevPoints,y=d.totalLength;return f&&c&&c.length&&(!h&&y>0||!bo(h,c))?this.renderCurveWithAnimation(r,o):this.renderCurveStatically(c,r,o)}},{key:"render",value:function(){var r,o=this.props,l=o.hide,c=o.dot,f=o.points,d=o.className,h=o.xAxis,y=o.yAxis,v=o.top,g=o.left,b=o.width,_=o.height,S=o.isAnimationActive,x=o.id;if(l||!f||!f.length)return null;var T=this.state.isAnimationFinished,w=f.length===1,M=qe("recharts-line",d),C=h&&h.allowDataOverflow,A=y&&y.allowDataOverflow,E=C||A,D=je(x)?this.id:x,P=(r=Ee(c,!1))!==null&&r!==void 0?r:{r:3,strokeWidth:2},q=P.r,V=q===void 0?3:q,U=P.strokeWidth,k=U===void 0?2:U,Z=gM(c)?c:{},Q=Z.clipDot,W=Q===void 0?!0:Q,$=V*2+k;return B.createElement(et,{className:M},C||A?B.createElement("defs",null,B.createElement("clipPath",{id:"clipPath-".concat(D)},B.createElement("rect",{x:C?g:g-b/2,y:A?v:v-_/2,width:C?b:b*2,height:A?_:_*2})),!W&&B.createElement("clipPath",{id:"clipPath-dots-".concat(D)},B.createElement("rect",{x:g-$/2,y:v-$/2,width:b+$,height:_+$}))):null,!w&&this.renderCurve(E,D),this.renderErrorBar(E,D),(w||c)&&this.renderDots(E,W,D),(!S||T)&&$r.renderCallByParent(this.props,f))}}],[{key:"getDerivedStateFromProps",value:function(r,o){return r.animationId!==o.prevAnimationId?{prevAnimationId:r.animationId,curPoints:r.points,prevPoints:o.curPoints}:r.points!==o.curPoints?{curPoints:r.points}:null}},{key:"repeat",value:function(r,o){for(var l=r.length%2!==0?[].concat(to(r),[0]):r,c=[],f=0;f<o;++f)c=[].concat(to(c),to(l));return c}},{key:"renderDotItem",value:function(r,o){var l;if(B.isValidElement(r))l=B.cloneElement(r,o);else if(Ae(r))l=r(o);else{var c=o.key,f=I2(o,SG),d=qe("recharts-line-dot",typeof r!="boolean"?r.className:"");l=B.createElement(Qf,rl({key:c},f,{className:d}))}return l}}])})(H.PureComponent);Yn(Fl,"displayName","Line");Yn(Fl,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!ci.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});Yn(Fl,"getComposedData",function(e){var t=e.props,n=e.xAxis,r=e.yAxis,o=e.xAxisTicks,l=e.yAxisTicks,c=e.dataKey,f=e.bandSize,d=e.displayedData,h=e.offset,y=t.layout,v=d.map(function(g,b){var _=Vt(g,c);return y==="horizontal"?{x:rf({axis:n,ticks:o,bandSize:f,entry:g,index:b}),y:je(_)?null:r.scale(_),value:_,payload:g}:{x:je(_)?null:n.scale(_),y:rf({axis:r,ticks:l,bandSize:f,entry:g,index:b}),value:_,payload:g}});return pn({points:v,layout:y},h)});var RG=["layout","type","stroke","connectNulls","isRange","ref"],$G=["key"],aD;function Co(e){"@babel/helpers - typeof";return Co=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},Co(e)}function iD(e,t){if(e==null)return{};var n=qG(e,t),r,o;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o<l.length;o++)r=l[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function qG(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function ei(){return ei=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ei.apply(this,arguments)}function Y2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function ya(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Y2(Object(n),!0).forEach(function(r){nr(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Y2(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function zG(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function X2(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,uD(r.key),r)}}function kG(e,t,n){return t&&X2(e.prototype,t),n&&X2(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function BG(e,t,n){return t=Tf(t),LG(e,oD()?Reflect.construct(t,n||[],Tf(e).constructor):t.apply(e,n))}function LG(e,t){if(t&&(Co(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return UG(e)}function UG(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function oD(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(oD=function(){return!!e})()}function Tf(e){return Tf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Tf(e)}function IG(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&&Ub(e,t)}function Ub(e,t){return Ub=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Ub(e,t)}function nr(e,t,n){return t=uD(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function uD(e){var t=HG(e,"string");return Co(t)=="symbol"?t:t+""}function HG(e,t){if(Co(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Co(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var Vn=(function(e){function t(){var n;zG(this,t);for(var r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];return n=BG(this,t,[].concat(o)),nr(n,"state",{isAnimationFinished:!0}),nr(n,"id",ko("recharts-area-")),nr(n,"handleAnimationEnd",function(){var c=n.props.onAnimationEnd;n.setState({isAnimationFinished:!0}),Ae(c)&&c()}),nr(n,"handleAnimationStart",function(){var c=n.props.onAnimationStart;n.setState({isAnimationFinished:!1}),Ae(c)&&c()}),n}return IG(t,e),kG(t,[{key:"renderDots",value:function(r,o,l){var c=this.props.isAnimationActive,f=this.state.isAnimationFinished;if(c&&!f)return null;var d=this.props,h=d.dot,y=d.points,v=d.dataKey,g=Ee(this.props,!1),b=Ee(h,!0),_=y.map(function(x,T){var w=ya(ya(ya({key:"dot-".concat(T),r:3},g),b),{},{index:T,cx:x.x,cy:x.y,dataKey:v,value:x.value,payload:x.payload,points:y});return t.renderDotItem(h,w)}),S={clipPath:r?"url(#clipPath-".concat(o?"":"dots-").concat(l,")"):null};return B.createElement(et,ei({className:"recharts-area-dots"},S),_)}},{key:"renderHorizontalRect",value:function(r){var o=this.props,l=o.baseLine,c=o.points,f=o.strokeWidth,d=c[0].x,h=c[c.length-1].x,y=r*Math.abs(d-h),v=ba(c.map(function(g){return g.y||0}));return fe(l)&&typeof l=="number"?v=Math.max(l,v):l&&Array.isArray(l)&&l.length&&(v=Math.max(ba(l.map(function(g){return g.y||0})),v)),fe(v)?B.createElement("rect",{x:d<h?d:d-y,y:0,width:y,height:Math.floor(v+(f?parseInt("".concat(f),10):1))}):null}},{key:"renderVerticalRect",value:function(r){var o=this.props,l=o.baseLine,c=o.points,f=o.strokeWidth,d=c[0].y,h=c[c.length-1].y,y=r*Math.abs(d-h),v=ba(c.map(function(g){return g.x||0}));return fe(l)&&typeof l=="number"?v=Math.max(l,v):l&&Array.isArray(l)&&l.length&&(v=Math.max(ba(l.map(function(g){return g.x||0})),v)),fe(v)?B.createElement("rect",{x:0,y:d<h?d:d-y,width:v+(f?parseInt("".concat(f),10):1),height:Math.floor(y)}):null}},{key:"renderClipRect",value:function(r){var o=this.props.layout;return o==="vertical"?this.renderVerticalRect(r):this.renderHorizontalRect(r)}},{key:"renderAreaStatically",value:function(r,o,l,c){var f=this.props,d=f.layout,h=f.type,y=f.stroke,v=f.connectNulls,g=f.isRange;f.ref;var b=iD(f,RG);return B.createElement(et,{clipPath:l?"url(#clipPath-".concat(c,")"):null},B.createElement(co,ei({},Ee(b,!0),{points:r,connectNulls:v,type:h,baseLine:o,layout:d,stroke:"none",className:"recharts-area-area"})),y!=="none"&&B.createElement(co,ei({},Ee(this.props,!1),{className:"recharts-area-curve",layout:d,type:h,connectNulls:v,fill:"none",points:r})),y!=="none"&&g&&B.createElement(co,ei({},Ee(this.props,!1),{className:"recharts-area-curve",layout:d,type:h,connectNulls:v,fill:"none",points:o})))}},{key:"renderAreaWithAnimation",value:function(r,o){var l=this,c=this.props,f=c.points,d=c.baseLine,h=c.isAnimationActive,y=c.animationBegin,v=c.animationDuration,g=c.animationEasing,b=c.animationId,_=this.state,S=_.prevPoints,x=_.prevBaseLine;return B.createElement(or,{begin:y,duration:v,isActive:h,easing:g,from:{t:0},to:{t:1},key:"area-".concat(b),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(T){var w=T.t;if(S){var M=S.length/f.length,C=f.map(function(P,q){var V=Math.floor(q*M);if(S[V]){var U=S[V],k=kt(U.x,P.x),Z=kt(U.y,P.y);return ya(ya({},P),{},{x:k(w),y:Z(w)})}return P}),A;if(fe(d)&&typeof d=="number"){var E=kt(x,d);A=E(w)}else if(je(d)||zo(d)){var D=kt(x,0);A=D(w)}else A=d.map(function(P,q){var V=Math.floor(q*M);if(x[V]){var U=x[V],k=kt(U.x,P.x),Z=kt(U.y,P.y);return ya(ya({},P),{},{x:k(w),y:Z(w)})}return P});return l.renderAreaStatically(C,A,r,o)}return B.createElement(et,null,B.createElement("defs",null,B.createElement("clipPath",{id:"animationClipPath-".concat(o)},l.renderClipRect(w))),B.createElement(et,{clipPath:"url(#animationClipPath-".concat(o,")")},l.renderAreaStatically(f,d,r,o)))})}},{key:"renderArea",value:function(r,o){var l=this.props,c=l.points,f=l.baseLine,d=l.isAnimationActive,h=this.state,y=h.prevPoints,v=h.prevBaseLine,g=h.totalLength;return d&&c&&c.length&&(!y&&g>0||!bo(y,c)||!bo(v,f))?this.renderAreaWithAnimation(r,o):this.renderAreaStatically(c,f,r,o)}},{key:"render",value:function(){var r,o=this.props,l=o.hide,c=o.dot,f=o.points,d=o.className,h=o.top,y=o.left,v=o.xAxis,g=o.yAxis,b=o.width,_=o.height,S=o.isAnimationActive,x=o.id;if(l||!f||!f.length)return null;var T=this.state.isAnimationFinished,w=f.length===1,M=qe("recharts-area",d),C=v&&v.allowDataOverflow,A=g&&g.allowDataOverflow,E=C||A,D=je(x)?this.id:x,P=(r=Ee(c,!1))!==null&&r!==void 0?r:{r:3,strokeWidth:2},q=P.r,V=q===void 0?3:q,U=P.strokeWidth,k=U===void 0?2:U,Z=gM(c)?c:{},Q=Z.clipDot,W=Q===void 0?!0:Q,$=V*2+k;return B.createElement(et,{className:M},C||A?B.createElement("defs",null,B.createElement("clipPath",{id:"clipPath-".concat(D)},B.createElement("rect",{x:C?y:y-b/2,y:A?h:h-_/2,width:C?b:b*2,height:A?_:_*2})),!W&&B.createElement("clipPath",{id:"clipPath-dots-".concat(D)},B.createElement("rect",{x:y-$/2,y:h-$/2,width:b+$,height:_+$}))):null,w?null:this.renderArea(E,D),(c||w)&&this.renderDots(E,W,D),(!S||T)&&$r.renderCallByParent(this.props,f))}}],[{key:"getDerivedStateFromProps",value:function(r,o){return r.animationId!==o.prevAnimationId?{prevAnimationId:r.animationId,curPoints:r.points,curBaseLine:r.baseLine,prevPoints:o.curPoints,prevBaseLine:o.curBaseLine}:r.points!==o.curPoints||r.baseLine!==o.curBaseLine?{curPoints:r.points,curBaseLine:r.baseLine}:null}}])})(H.PureComponent);aD=Vn;nr(Vn,"displayName","Area");nr(Vn,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ci.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});nr(Vn,"getBaseValue",function(e,t,n,r){var o=e.layout,l=e.baseValue,c=t.props.baseValue,f=c??l;if(fe(f)&&typeof f=="number")return f;var d=o==="horizontal"?r:n,h=d.scale.domain();if(d.type==="number"){var y=Math.max(h[0],h[1]),v=Math.min(h[0],h[1]);return f==="dataMin"?v:f==="dataMax"||y<0?y:Math.max(Math.min(h[0],h[1]),0)}return f==="dataMin"?h[0]:f==="dataMax"?h[1]:h[0]});nr(Vn,"getComposedData",function(e){var t=e.props,n=e.item,r=e.xAxis,o=e.yAxis,l=e.xAxisTicks,c=e.yAxisTicks,f=e.bandSize,d=e.dataKey,h=e.stackedData,y=e.dataStartIndex,v=e.displayedData,g=e.offset,b=t.layout,_=h&&h.length,S=aD.getBaseValue(t,n,r,o),x=b==="horizontal",T=!1,w=v.map(function(C,A){var E;_?E=h[y+A]:(E=Vt(C,d),Array.isArray(E)?T=!0:E=[S,E]);var D=E[1]==null||_&&Vt(C,d)==null;return x?{x:rf({axis:r,ticks:l,bandSize:f,entry:C,index:A}),y:D?null:o.scale(E[1]),value:E,payload:C}:{x:D?null:r.scale(E[1]),y:rf({axis:o,ticks:c,bandSize:f,entry:C,index:A}),value:E,payload:C}}),M;return _||T?M=w.map(function(C){var A=Array.isArray(C.value)?C.value[0]:null;return x?{x:C.x,y:A!=null&&C.y!=null?o.scale(A):null}:{x:A!=null?r.scale(A):null,y:C.y}}):M=x?o.scale(S):r.scale(S),ya({points:w,baseLine:M,layout:b,isRange:T},g)});nr(Vn,"renderDotItem",function(e,t){var n;if(B.isValidElement(e))n=B.cloneElement(e,t);else if(Ae(e))n=e(t);else{var r=qe("recharts-area-dot",typeof e!="boolean"?e.className:""),o=t.key,l=iD(t,$G);n=B.createElement(Qf,ei({},l,{key:o,className:r}))}return n});function No(e){"@babel/helpers - typeof";return No=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},No(e)}function GG(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function YG(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,sD(r.key),r)}}function XG(e,t,n){return t&&YG(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function KG(e,t,n){return t=Ef(t),VG(e,lD()?Reflect.construct(t,n||[],Ef(e).constructor):t.apply(e,n))}function VG(e,t){if(t&&(No(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return FG(e)}function FG(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function lD(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(lD=function(){return!!e})()}function Ef(e){return Ef=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Ef(e)}function ZG(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&&Ib(e,t)}function Ib(e,t){return Ib=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Ib(e,t)}function cD(e,t,n){return t=sD(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sD(e){var t=WG(e,"string");return No(t)=="symbol"?t:t+""}function WG(e,t){if(No(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(No(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function Hb(){return Hb=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Hb.apply(this,arguments)}function QG(e){var t=e.xAxisId,n=J0(),r=ex(),o=GN(t);return o==null?null:H.createElement(Ho,Hb({},o,{className:qe("recharts-".concat(o.axisType," ").concat(o.axisType),o.className),viewBox:{x:0,y:0,width:n,height:r},ticksGenerator:function(c){return Cr(c,!0)}}))}var Ir=(function(e){function t(){return GG(this,t),KG(this,t,arguments)}return ZG(t,e),XG(t,[{key:"render",value:function(){return H.createElement(QG,this.props)}}])})(H.Component);cD(Ir,"displayName","XAxis");cD(Ir,"defaultProps",{allowDecimals:!0,hide:!1,orientation:"bottom",width:0,height:30,mirror:!1,xAxisId:0,tickCount:5,type:"category",padding:{left:0,right:0},allowDataOverflow:!1,scale:"auto",reversed:!1,allowDuplicatedCategory:!0});function Do(e){"@babel/helpers - typeof";return Do=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},Do(e)}function JG(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function eY(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,hD(r.key),r)}}function tY(e,t,n){return t&&eY(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function nY(e,t,n){return t=jf(t),rY(e,fD()?Reflect.construct(t,n||[],jf(e).constructor):t.apply(e,n))}function rY(e,t){if(t&&(Do(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return aY(e)}function aY(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function fD(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(fD=function(){return!!e})()}function jf(e){return jf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},jf(e)}function iY(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&&Gb(e,t)}function Gb(e,t){return Gb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Gb(e,t)}function dD(e,t,n){return t=hD(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function hD(e){var t=oY(e,"string");return Do(t)=="symbol"?t:t+""}function oY(e,t){if(Do(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Do(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function Yb(){return Yb=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Yb.apply(this,arguments)}var uY=function(t){var n=t.yAxisId,r=J0(),o=ex(),l=YN(n);return l==null?null:H.createElement(Ho,Yb({},l,{className:qe("recharts-".concat(l.axisType," ").concat(l.axisType),l.className),viewBox:{x:0,y:0,width:r,height:o},ticksGenerator:function(f){return Cr(f,!0)}}))},Hr=(function(e){function t(){return JG(this,t),nY(this,t,arguments)}return iY(t,e),tY(t,[{key:"render",value:function(){return H.createElement(uY,this.props)}}])})(H.Component);dD(Hr,"displayName","YAxis");dD(Hr,"defaultProps",{allowDuplicatedCategory:!0,allowDecimals:!0,hide:!1,orientation:"left",width:60,height:0,mirror:!1,yAxisId:0,tickCount:5,type:"number",padding:{top:0,bottom:0},allowDataOverflow:!1,scale:"auto",reversed:!1});function K2(e){return fY(e)||sY(e)||cY(e)||lY()}function lY(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
230
230
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function cY(e,t){if(e){if(typeof e=="string")return Xb(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Xb(e,t)}}function sY(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function fY(e){if(Array.isArray(e))return Xb(e)}function Xb(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Kb=function(t,n,r,o,l){var c=$n(t,nd),f=$n(t,ad),d=[].concat(K2(c),K2(f)),h=$n(t,od),y="".concat(o,"Id"),v=o[0],g=n;if(d.length&&(g=d.reduce(function(S,x){if(x.props[y]===r&&ar(x.props,"extendDomain")&&fe(x.props[v])){var T=x.props[v];return[Math.min(S[0],T),Math.max(S[1],T)]}return S},g)),h.length){var b="".concat(v,"1"),_="".concat(v,"2");g=h.reduce(function(S,x){if(x.props[y]===r&&ar(x.props,"extendDomain")&&fe(x.props[b])&&fe(x.props[_])){var T=x.props[b],w=x.props[_];return[Math.min(S[0],T,w),Math.max(S[1],T,w)]}return S},g)}return l&&l.length&&(g=l.reduce(function(S,x){return fe(x)?[Math.min(S[0],x),Math.max(S[1],x)]:S},g)),g},wg={exports:{}},V2;function dY(){return V2||(V2=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function o(d,h,y){this.fn=d,this.context=h,this.once=y||!1}function l(d,h,y,v,g){if(typeof y!="function")throw new TypeError("The listener must be a function");var b=new o(y,v||d,g),_=n?n+h:h;return d._events[_]?d._events[_].fn?d._events[_]=[d._events[_],b]:d._events[_].push(b):(d._events[_]=b,d._eventsCount++),d}function c(d,h){--d._eventsCount===0?d._events=new r:delete d._events[h]}function f(){this._events=new r,this._eventsCount=0}f.prototype.eventNames=function(){var h=[],y,v;if(this._eventsCount===0)return h;for(v in y=this._events)t.call(y,v)&&h.push(n?v.slice(1):v);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(y)):h},f.prototype.listeners=function(h){var y=n?n+h:h,v=this._events[y];if(!v)return[];if(v.fn)return[v.fn];for(var g=0,b=v.length,_=new Array(b);g<b;g++)_[g]=v[g].fn;return _},f.prototype.listenerCount=function(h){var y=n?n+h:h,v=this._events[y];return v?v.fn?1:v.length:0},f.prototype.emit=function(h,y,v,g,b,_){var S=n?n+h:h;if(!this._events[S])return!1;var x=this._events[S],T=arguments.length,w,M;if(x.fn){switch(x.once&&this.removeListener(h,x.fn,void 0,!0),T){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,y),!0;case 3:return x.fn.call(x.context,y,v),!0;case 4:return x.fn.call(x.context,y,v,g),!0;case 5:return x.fn.call(x.context,y,v,g,b),!0;case 6:return x.fn.call(x.context,y,v,g,b,_),!0}for(M=1,w=new Array(T-1);M<T;M++)w[M-1]=arguments[M];x.fn.apply(x.context,w)}else{var C=x.length,A;for(M=0;M<C;M++)switch(x[M].once&&this.removeListener(h,x[M].fn,void 0,!0),T){case 1:x[M].fn.call(x[M].context);break;case 2:x[M].fn.call(x[M].context,y);break;case 3:x[M].fn.call(x[M].context,y,v);break;case 4:x[M].fn.call(x[M].context,y,v,g);break;default:if(!w)for(A=1,w=new Array(T-1);A<T;A++)w[A-1]=arguments[A];x[M].fn.apply(x[M].context,w)}}return!0},f.prototype.on=function(h,y,v){return l(this,h,y,v,!1)},f.prototype.once=function(h,y,v){return l(this,h,y,v,!0)},f.prototype.removeListener=function(h,y,v,g){var b=n?n+h:h;if(!this._events[b])return this;if(!y)return c(this,b),this;var _=this._events[b];if(_.fn)_.fn===y&&(!g||_.once)&&(!v||_.context===v)&&c(this,b);else{for(var S=0,x=[],T=_.length;S<T;S++)(_[S].fn!==y||g&&!_[S].once||v&&_[S].context!==v)&&x.push(_[S]);x.length?this._events[b]=x.length===1?x[0]:x:c(this,b)}return this},f.prototype.removeAllListeners=function(h){var y;return h?(y=n?n+h:h,this._events[y]&&c(this,y)):(this._events=new r,this._eventsCount=0),this},f.prototype.off=f.prototype.removeListener,f.prototype.addListener=f.prototype.on,f.prefixed=n,f.EventEmitter=f,e.exports=f})(wg)),wg.exports}var hY=dY();const pY=Qe(hY);var Tg=new pY,Eg="recharts.syncMouseEvents";function kl(e){"@babel/helpers - typeof";return kl=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},kl(e)}function vY(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function yY(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,pD(r.key),r)}}function mY(e,t,n){return t&&yY(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function jg(e,t,n){return t=pD(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function pD(e){var t=gY(e,"string");return kl(t)=="symbol"?t:t+""}function gY(e,t){if(kl(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(kl(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var bY=(function(){function e(){vY(this,e),jg(this,"activeIndex",0),jg(this,"coordinateList",[]),jg(this,"layout","horizontal")}return mY(e,[{key:"setDetails",value:function(n){var r,o=n.coordinateList,l=o===void 0?null:o,c=n.container,f=c===void 0?null:c,d=n.layout,h=d===void 0?null:d,y=n.offset,v=y===void 0?null:y,g=n.mouseHandlerCallback,b=g===void 0?null:g;this.coordinateList=(r=l??this.coordinateList)!==null&&r!==void 0?r:[],this.container=f??this.container,this.layout=h??this.layout,this.offset=v??this.offset,this.mouseHandlerCallback=b??this.mouseHandlerCallback,this.activeIndex=Math.min(Math.max(this.activeIndex,0),this.coordinateList.length-1)}},{key:"focus",value:function(){this.spoofMouse()}},{key:"keyboardEvent",value:function(n){if(this.coordinateList.length!==0)switch(n.key){case"ArrowRight":{if(this.layout!=="horizontal")return;this.activeIndex=Math.min(this.activeIndex+1,this.coordinateList.length-1),this.spoofMouse();break}case"ArrowLeft":{if(this.layout!=="horizontal")return;this.activeIndex=Math.max(this.activeIndex-1,0),this.spoofMouse();break}}}},{key:"setIndex",value:function(n){this.activeIndex=n}},{key:"spoofMouse",value:function(){var n,r;if(this.layout==="horizontal"&&this.coordinateList.length!==0){var o=this.container.getBoundingClientRect(),l=o.x,c=o.y,f=o.height,d=this.coordinateList[this.activeIndex].coordinate,h=((n=window)===null||n===void 0?void 0:n.scrollX)||0,y=((r=window)===null||r===void 0?void 0:r.scrollY)||0,v=l+d+h,g=c+this.offset.top+f/2+y;this.mouseHandlerCallback({pageX:v,pageY:g})}}}])})();function xY(e,t,n){if(n==="number"&&t===!0&&Array.isArray(e)){var r=e==null?void 0:e[0],o=e==null?void 0:e[1];if(r&&o&&fe(r)&&fe(o))return!0}return!1}function SY(e,t,n,r){var o=r/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-o:n.left+.5,y:e==="horizontal"?n.top+.5:t.y-o,width:e==="horizontal"?r:n.width-1,height:e==="horizontal"?n.height-1:r}}function vD(e){var t=e.cx,n=e.cy,r=e.radius,o=e.startAngle,l=e.endAngle,c=Bt(t,n,r,o),f=Bt(t,n,r,l);return{points:[c,f],cx:t,cy:n,radius:r,startAngle:o,endAngle:l}}function OY(e,t,n){var r,o,l,c;if(e==="horizontal")r=t.x,l=r,o=n.top,c=n.top+n.height;else if(e==="vertical")o=t.y,c=o,r=n.left,l=n.left+n.width;else if(t.cx!=null&&t.cy!=null)if(e==="centric"){var f=t.cx,d=t.cy,h=t.innerRadius,y=t.outerRadius,v=t.angle,g=Bt(f,d,h,v),b=Bt(f,d,y,v);r=g.x,o=g.y,l=b.x,c=b.y}else return vD(t);return[{x:r,y:o},{x:l,y:c}]}function Bl(e){"@babel/helpers - typeof";return Bl=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},Bl(e)}function F2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Ts(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?F2(Object(n),!0).forEach(function(r){_Y(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):F2(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function _Y(e,t,n){return t=AY(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function AY(e){var t=wY(e,"string");return Bl(t)=="symbol"?t:t+""}function wY(e,t){if(Bl(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Bl(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function TY(e){var t,n,r=e.element,o=e.tooltipEventType,l=e.isActive,c=e.activeCoordinate,f=e.activePayload,d=e.offset,h=e.activeTooltipIndex,y=e.tooltipAxisBandSize,v=e.layout,g=e.chartName,b=(t=r.props.cursor)!==null&&t!==void 0?t:(n=r.type.defaultProps)===null||n===void 0?void 0:n.cursor;if(!r||!b||!l||!c||g!=="ScatterChart"&&o!=="axis")return null;var _,S=co;if(g==="ScatterChart")_=c,S=p9;else if(g==="BarChart")_=SY(v,c,d,y),S=V0;else if(v==="radial"){var x=vD(c),T=x.cx,w=x.cy,M=x.radius,C=x.startAngle,A=x.endAngle;_={cx:T,cy:w,startAngle:C,endAngle:A,innerRadius:M,outerRadius:M},S=xN}else _={points:OY(v,c,d)},S=co;var E=Ts(Ts(Ts(Ts({stroke:"#ccc",pointerEvents:"none"},d),_),Ee(b,!1)),{},{payload:f,payloadIndex:h,className:qe("recharts-tooltip-cursor",b.className)});return H.isValidElement(b)?H.cloneElement(b,E):H.createElement(S,E)}var EY=["item"],jY=["children","className","width","height","style","compact","title","desc"];function Po(e){"@babel/helpers - typeof";return Po=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},Po(e)}function io(){return io=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},io.apply(this,arguments)}function Z2(e,t){return NY(e)||CY(e,t)||mD(e,t)||MY()}function MY(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
231
231
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function CY(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,l,c,f=[],d=!0,h=!1;try{if(l=(n=n.call(e)).next,t!==0)for(;!(d=(r=l.call(n)).done)&&(f.push(r.value),f.length!==t);d=!0);}catch(y){h=!0,o=y}finally{try{if(!d&&n.return!=null&&(c=n.return(),Object(c)!==c))return}finally{if(h)throw o}}return f}}function NY(e){if(Array.isArray(e))return e}function W2(e,t){if(e==null)return{};var n=DY(e,t),r,o;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o<l.length;o++)r=l[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function DY(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function PY(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function RY(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,gD(r.key),r)}}function $Y(e,t,n){return t&&RY(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function qY(e,t,n){return t=Mf(t),zY(e,yD()?Reflect.construct(t,n||[],Mf(e).constructor):t.apply(e,n))}function zY(e,t){if(t&&(Po(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return kY(e)}function kY(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function yD(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(yD=function(){return!!e})()}function Mf(e){return Mf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Mf(e)}function BY(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&&Vb(e,t)}function Vb(e,t){return Vb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Vb(e,t)}function Ro(e){return IY(e)||UY(e)||mD(e)||LY()}function LY(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
232
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mD(e,t){if(e){if(typeof e=="string")return Fb(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Fb(e,t)}}function UY(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function IY(e){if(Array.isArray(e))return Fb(e)}function Fb(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Q2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function ne(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Q2(Object(n),!0).forEach(function(r){be(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Q2(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function be(e,t,n){return t=gD(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gD(e){var t=HY(e,"string");return Po(t)=="symbol"?t:t+""}function HY(e,t){if(Po(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Po(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var GY={xAxis:["bottom","top"],yAxis:["left","right"]},YY={width:"100%",height:"100%"},bD={x:0,y:0};function Es(e){return e}var XY=function(t,n){return n==="horizontal"?t.x:n==="vertical"?t.y:n==="centric"?t.angle:t.radius},KY=function(t,n,r,o){var l=n.find(function(y){return y&&y.index===r});if(l){if(t==="horizontal")return{x:l.coordinate,y:o.y};if(t==="vertical")return{x:o.x,y:l.coordinate};if(t==="centric"){var c=l.coordinate,f=o.radius;return ne(ne(ne({},o),Bt(o.cx,o.cy,f,c)),{},{angle:c,radius:f})}var d=l.coordinate,h=o.angle;return ne(ne(ne({},o),Bt(o.cx,o.cy,d,h)),{},{angle:h,radius:d})}return bD},ud=function(t,n){var r=n.graphicalItems,o=n.dataStartIndex,l=n.dataEndIndex,c=(r??[]).reduce(function(f,d){var h=d.props.data;return h&&h.length?[].concat(Ro(f),Ro(h)):f},[]);return c.length>0?c:t&&t.length&&fe(o)&&fe(l)?t.slice(o,l+1):[]};function xD(e){return e==="number"?[0,"auto"]:void 0}var Zb=function(t,n,r,o){var l=t.graphicalItems,c=t.tooltipAxis,f=ud(n,t);return r<0||!l||!l.length||r>=f.length?null:l.reduce(function(d,h){var y,v=(y=h.props.data)!==null&&y!==void 0?y:n;v&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=r&&(v=v.slice(t.dataStartIndex,t.dataEndIndex+1));var g;if(c.dataKey&&!c.allowDuplicatedCategory){var b=v===void 0?f:v;g=Ms(b,c.dataKey,o)}else g=v&&v[r]||f[r];return g?[].concat(Ro(d),[mN(h,g)]):d},[])},J2=function(t,n,r,o){var l=o||{x:t.chartX,y:t.chartY},c=XY(l,r),f=t.orderedTooltipTicks,d=t.tooltipAxis,h=t.tooltipTicks,y=K5(c,f,h,d);if(y>=0&&h){var v=h[y]&&h[y].value,g=Zb(t,n,y,v),b=KY(r,f,y,l);return{activeTooltipIndex:y,activeLabel:v,activePayload:g,activeCoordinate:b}}return null},VY=function(t,n){var r=n.axes,o=n.graphicalItems,l=n.axisType,c=n.axisIdKey,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,y=t.layout,v=t.children,g=t.stackOffset,b=pN(y,l);return r.reduce(function(_,S){var x,T=S.type.defaultProps!==void 0?ne(ne({},S.type.defaultProps),S.props):S.props,w=T.type,M=T.dataKey,C=T.allowDataOverflow,A=T.allowDuplicatedCategory,E=T.scale,D=T.ticks,P=T.includeHidden,q=T[c];if(_[q])return _;var V=ud(t.data,{graphicalItems:o.filter(function(I){var re,se=c in I.props?I.props[c]:(re=I.type.defaultProps)===null||re===void 0?void 0:re[c];return se===q}),dataStartIndex:d,dataEndIndex:h}),U=V.length,k,Z,Q;xY(T.domain,C,w)&&(k=hb(T.domain,null,C),b&&(w==="number"||E!=="auto")&&(Q=tl(V,M,"category")));var W=xD(w);if(!k||k.length===0){var $,Y=($=T.domain)!==null&&$!==void 0?$:W;if(M){if(k=tl(V,M,w),w==="category"&&b){var ee=B$(k);A&&ee?(Z=k,k=vf(0,U)):A||(k=fj(Y,k,S).reduce(function(I,re){return I.indexOf(re)>=0?I:[].concat(Ro(I),[re])},[]))}else if(w==="category")A?k=k.filter(function(I){return I!==""&&!je(I)}):k=fj(Y,k,S).reduce(function(I,re){return I.indexOf(re)>=0||re===""||je(re)?I:[].concat(Ro(I),[re])},[]);else if(w==="number"){var oe=Q5(V,o.filter(function(I){var re,se,pe=c in I.props?I.props[c]:(re=I.type.defaultProps)===null||re===void 0?void 0:re[c],me="hide"in I.props?I.props.hide:(se=I.type.defaultProps)===null||se===void 0?void 0:se.hide;return pe===q&&(P||!me)}),M,l,y);oe&&(k=oe)}b&&(w==="number"||E!=="auto")&&(Q=tl(V,M,"category"))}else b?k=vf(0,U):f&&f[q]&&f[q].hasStack&&w==="number"?k=g==="expand"?[0,1]:yN(f[q].stackGroups,d,h):k=hN(V,o.filter(function(I){var re=c in I.props?I.props[c]:I.type.defaultProps[c],se="hide"in I.props?I.props.hide:I.type.defaultProps.hide;return re===q&&(P||!se)}),w,y,!0);if(w==="number")k=Kb(v,k,q,l,D),Y&&(k=hb(Y,k,C));else if(w==="category"&&Y){var le=Y,R=k.every(function(I){return le.indexOf(I)>=0});R&&(k=le)}}return ne(ne({},_),{},be({},q,ne(ne({},T),{},{axisType:l,domain:k,categoricalDomain:Q,duplicateDomain:Z,originalDomain:(x=T.domain)!==null&&x!==void 0?x:W,isCategorical:b,layout:y})))},{})},FY=function(t,n){var r=n.graphicalItems,o=n.Axis,l=n.axisType,c=n.axisIdKey,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,y=t.layout,v=t.children,g=ud(t.data,{graphicalItems:r,dataStartIndex:d,dataEndIndex:h}),b=g.length,_=pN(y,l),S=-1;return r.reduce(function(x,T){var w=T.type.defaultProps!==void 0?ne(ne({},T.type.defaultProps),T.props):T.props,M=w[c],C=xD("number");if(!x[M]){S++;var A;return _?A=vf(0,b):f&&f[M]&&f[M].hasStack?(A=yN(f[M].stackGroups,d,h),A=Kb(v,A,M,l)):(A=hb(C,hN(g,r.filter(function(E){var D,P,q=c in E.props?E.props[c]:(D=E.type.defaultProps)===null||D===void 0?void 0:D[c],V="hide"in E.props?E.props.hide:(P=E.type.defaultProps)===null||P===void 0?void 0:P.hide;return q===M&&!V}),"number",y),o.defaultProps.allowDataOverflow),A=Kb(v,A,M,l)),ne(ne({},x),{},be({},M,ne(ne({axisType:l},o.defaultProps),{},{hide:!0,orientation:Rn(GY,"".concat(l,".").concat(S%2),null),domain:A,originalDomain:C,isCategorical:_,layout:y})))}return x},{})},ZY=function(t,n){var r=n.axisType,o=r===void 0?"xAxis":r,l=n.AxisComp,c=n.graphicalItems,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,y=t.children,v="".concat(o,"Id"),g=$n(y,l),b={};return g&&g.length?b=VY(t,{axes:g,graphicalItems:c,axisType:o,axisIdKey:v,stackGroups:f,dataStartIndex:d,dataEndIndex:h}):c&&c.length&&(b=FY(t,{Axis:l,graphicalItems:c,axisType:o,axisIdKey:v,stackGroups:f,dataStartIndex:d,dataEndIndex:h})),b},WY=function(t){var n=ga(t),r=Cr(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:S0(r,function(o){return o.coordinate}),tooltipAxis:n,tooltipAxisBandSize:af(n,r)}},eM=function(t){var n=t.children,r=t.defaultShowTooltip,o=yn(n,_o),l=0,c=0;return t.data&&t.data.length!==0&&(c=t.data.length-1),o&&o.props&&(o.props.startIndex>=0&&(l=o.props.startIndex),o.props.endIndex>=0&&(c=o.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:l,dataEndIndex:c,activeTooltipIndex:-1,isTooltipActive:!!r}},QY=function(t){return!t||!t.length?!1:t.some(function(n){var r=Nr(n&&n.type);return r&&r.indexOf("Bar")>=0})},tM=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},JY=function(t,n){var r=t.props,o=t.graphicalItems,l=t.xAxisMap,c=l===void 0?{}:l,f=t.yAxisMap,d=f===void 0?{}:f,h=r.width,y=r.height,v=r.children,g=r.margin||{},b=yn(v,_o),_=yn(v,Pr),S=Object.keys(d).reduce(function(A,E){var D=d[E],P=D.orientation;return!D.mirror&&!D.hide?ne(ne({},A),{},be({},P,A[P]+D.width)):A},{left:g.left||0,right:g.right||0}),x=Object.keys(c).reduce(function(A,E){var D=c[E],P=D.orientation;return!D.mirror&&!D.hide?ne(ne({},A),{},be({},P,Rn(A,"".concat(P))+D.height)):A},{top:g.top||0,bottom:g.bottom||0}),T=ne(ne({},x),S),w=T.bottom;b&&(T.bottom+=b.props.height||_o.defaultProps.height),_&&n&&(T=Z5(T,o,r,n));var M=h-T.left-T.right,C=y-T.top-T.bottom;return ne(ne({brushBottom:w},T),{},{width:Math.max(M,0),height:Math.max(C,0)})},eX=function(t,n){if(n==="xAxis")return t[n].width;if(n==="yAxis")return t[n].height},ax=function(t){var n=t.chartName,r=t.GraphicalChild,o=t.defaultTooltipEventType,l=o===void 0?"axis":o,c=t.validateTooltipEventTypes,f=c===void 0?["axis"]:c,d=t.axisComponents,h=t.legendContent,y=t.formatAxisMap,v=t.defaultProps,g=function(T,w){var M=w.graphicalItems,C=w.stackGroups,A=w.offset,E=w.updateId,D=w.dataStartIndex,P=w.dataEndIndex,q=T.barSize,V=T.layout,U=T.barGap,k=T.barCategoryGap,Z=T.maxBarSize,Q=tM(V),W=Q.numericAxisName,$=Q.cateAxisName,Y=QY(M),ee=[];return M.forEach(function(oe,le){var R=ud(T.data,{graphicalItems:[oe],dataStartIndex:D,dataEndIndex:P}),I=oe.type.defaultProps!==void 0?ne(ne({},oe.type.defaultProps),oe.props):oe.props,re=I.dataKey,se=I.maxBarSize,pe=I["".concat(W,"Id")],me=I["".concat($,"Id")],Me={},Ue=d.reduce(function(Bn,lr){var Yo=w["".concat(lr.axisType,"Map")],Ut=I["".concat(lr.axisType,"Id")];Yo&&Yo[Ut]||lr.axisType==="zAxis"||oi();var Zl=Yo[Ut];return ne(ne({},Bn),{},be(be({},lr.axisType,Zl),"".concat(lr.axisType,"Ticks"),Cr(Zl)))},Me),ce=Ue[$],xe=Ue["".concat($,"Ticks")],Se=C&&C[pe]&&C[pe].hasStack&&sL(oe,C[pe].stackGroups),ue=Nr(oe.type).indexOf("Bar")>=0,tt=af(ce,xe),we=[],ut=Y&&V5({barSize:q,stackGroups:C,totalSize:eX(Ue,$)});if(ue){var lt,Lt,kn=je(se)?Z:se,Zn=(lt=(Lt=af(ce,xe,!0))!==null&&Lt!==void 0?Lt:kn)!==null&&lt!==void 0?lt:0;we=F5({barGap:U,barCategoryGap:k,bandSize:Zn!==tt?Zn:tt,sizeList:ut[me],maxBarSize:kn}),Zn!==tt&&(we=we.map(function(Bn){return ne(ne({},Bn),{},{position:ne(ne({},Bn.position),{},{offset:Bn.position.offset-Zn/2})})}))}var Gr=oe&&oe.type&&oe.type.getComposedData;Gr&&ee.push({props:ne(ne({},Gr(ne(ne({},Ue),{},{displayedData:R,props:T,dataKey:re,item:oe,bandSize:tt,barPosition:we,offset:A,stackedData:Se,layout:V,dataStartIndex:D,dataEndIndex:P}))),{},be(be(be({key:oe.key||"item-".concat(le)},W,Ue[W]),$,Ue[$]),"animationId",E)),childIndex:W$(oe,T.children),item:oe})}),ee},b=function(T,w){var M=T.props,C=T.dataStartIndex,A=T.dataEndIndex,E=T.updateId;if(!TA({props:M}))return null;var D=M.children,P=M.layout,q=M.stackOffset,V=M.data,U=M.reverseStackOrder,k=tM(P),Z=k.numericAxisName,Q=k.cateAxisName,W=$n(D,r),$=uL(V,W,"".concat(Z,"Id"),"".concat(Q,"Id"),q,U),Y=d.reduce(function(I,re){var se="".concat(re.axisType,"Map");return ne(ne({},I),{},be({},se,ZY(M,ne(ne({},re),{},{graphicalItems:W,stackGroups:re.axisType===Z&&$,dataStartIndex:C,dataEndIndex:A}))))},{}),ee=JY(ne(ne({},Y),{},{props:M,graphicalItems:W}),w==null?void 0:w.legendBBox);Object.keys(Y).forEach(function(I){Y[I]=y(M,Y[I],ee,I.replace("Map",""),n)});var oe=Y["".concat(Q,"Map")],le=WY(oe),R=g(M,ne(ne({},Y),{},{dataStartIndex:C,dataEndIndex:A,updateId:E,graphicalItems:W,stackGroups:$,offset:ee}));return ne(ne({formattedGraphicalItems:R,graphicalItems:W,offset:ee,stackGroups:$},le),Y)},_=(function(x){function T(w){var M,C,A;return PY(this,T),A=qY(this,T,[w]),be(A,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),be(A,"accessibilityManager",new bY),be(A,"handleLegendBBoxUpdate",function(E){if(E){var D=A.state,P=D.dataStartIndex,q=D.dataEndIndex,V=D.updateId;A.setState(ne({legendBBox:E},b({props:A.props,dataStartIndex:P,dataEndIndex:q,updateId:V},ne(ne({},A.state),{},{legendBBox:E}))))}}),be(A,"handleReceiveSyncEvent",function(E,D,P){if(A.props.syncId===E){if(P===A.eventEmitterSymbol&&typeof A.props.syncMethod!="function")return;A.applySyncEvent(D)}}),be(A,"handleBrushChange",function(E){var D=E.startIndex,P=E.endIndex;if(D!==A.state.dataStartIndex||P!==A.state.dataEndIndex){var q=A.state.updateId;A.setState(function(){return ne({dataStartIndex:D,dataEndIndex:P},b({props:A.props,dataStartIndex:D,dataEndIndex:P,updateId:q},A.state))}),A.triggerSyncEvent({dataStartIndex:D,dataEndIndex:P})}}),be(A,"handleMouseEnter",function(E){var D=A.getMouseInfo(E);if(D){var P=ne(ne({},D),{},{isTooltipActive:!0});A.setState(P),A.triggerSyncEvent(P);var q=A.props.onMouseEnter;Ae(q)&&q(P,E)}}),be(A,"triggeredAfterMouseMove",function(E){var D=A.getMouseInfo(E),P=D?ne(ne({},D),{},{isTooltipActive:!0}):{isTooltipActive:!1};A.setState(P),A.triggerSyncEvent(P);var q=A.props.onMouseMove;Ae(q)&&q(P,E)}),be(A,"handleItemMouseEnter",function(E){A.setState(function(){return{isTooltipActive:!0,activeItem:E,activePayload:E.tooltipPayload,activeCoordinate:E.tooltipPosition||{x:E.cx,y:E.cy}}})}),be(A,"handleItemMouseLeave",function(){A.setState(function(){return{isTooltipActive:!1}})}),be(A,"handleMouseMove",function(E){E.persist(),A.throttleTriggeredAfterMouseMove(E)}),be(A,"handleMouseLeave",function(E){A.throttleTriggeredAfterMouseMove.cancel();var D={isTooltipActive:!1};A.setState(D),A.triggerSyncEvent(D);var P=A.props.onMouseLeave;Ae(P)&&P(D,E)}),be(A,"handleOuterEvent",function(E){var D=Z$(E),P=Rn(A.props,"".concat(D));if(D&&Ae(P)){var q,V;/.*touch.*/i.test(D)?V=A.getMouseInfo(E.changedTouches[0]):V=A.getMouseInfo(E),P((q=V)!==null&&q!==void 0?q:{},E)}}),be(A,"handleClick",function(E){var D=A.getMouseInfo(E);if(D){var P=ne(ne({},D),{},{isTooltipActive:!0});A.setState(P),A.triggerSyncEvent(P);var q=A.props.onClick;Ae(q)&&q(P,E)}}),be(A,"handleMouseDown",function(E){var D=A.props.onMouseDown;if(Ae(D)){var P=A.getMouseInfo(E);D(P,E)}}),be(A,"handleMouseUp",function(E){var D=A.props.onMouseUp;if(Ae(D)){var P=A.getMouseInfo(E);D(P,E)}}),be(A,"handleTouchMove",function(E){E.changedTouches!=null&&E.changedTouches.length>0&&A.throttleTriggeredAfterMouseMove(E.changedTouches[0])}),be(A,"handleTouchStart",function(E){E.changedTouches!=null&&E.changedTouches.length>0&&A.handleMouseDown(E.changedTouches[0])}),be(A,"handleTouchEnd",function(E){E.changedTouches!=null&&E.changedTouches.length>0&&A.handleMouseUp(E.changedTouches[0])}),be(A,"handleDoubleClick",function(E){var D=A.props.onDoubleClick;if(Ae(D)){var P=A.getMouseInfo(E);D(P,E)}}),be(A,"handleContextMenu",function(E){var D=A.props.onContextMenu;if(Ae(D)){var P=A.getMouseInfo(E);D(P,E)}}),be(A,"triggerSyncEvent",function(E){A.props.syncId!==void 0&&Tg.emit(Eg,A.props.syncId,E,A.eventEmitterSymbol)}),be(A,"applySyncEvent",function(E){var D=A.props,P=D.layout,q=D.syncMethod,V=A.state.updateId,U=E.dataStartIndex,k=E.dataEndIndex;if(E.dataStartIndex!==void 0||E.dataEndIndex!==void 0)A.setState(ne({dataStartIndex:U,dataEndIndex:k},b({props:A.props,dataStartIndex:U,dataEndIndex:k,updateId:V},A.state)));else if(E.activeTooltipIndex!==void 0){var Z=E.chartX,Q=E.chartY,W=E.activeTooltipIndex,$=A.state,Y=$.offset,ee=$.tooltipTicks;if(!Y)return;if(typeof q=="function")W=q(ee,E);else if(q==="value"){W=-1;for(var oe=0;oe<ee.length;oe++)if(ee[oe].value===E.activeLabel){W=oe;break}}var le=ne(ne({},Y),{},{x:Y.left,y:Y.top}),R=Math.min(Z,le.x+le.width),I=Math.min(Q,le.y+le.height),re=ee[W]&&ee[W].value,se=Zb(A.state,A.props.data,W),pe=ee[W]?{x:P==="horizontal"?ee[W].coordinate:R,y:P==="horizontal"?I:ee[W].coordinate}:bD;A.setState(ne(ne({},E),{},{activeLabel:re,activeCoordinate:pe,activePayload:se,activeTooltipIndex:W}))}else A.setState(E)}),be(A,"renderCursor",function(E){var D,P=A.state,q=P.isTooltipActive,V=P.activeCoordinate,U=P.activePayload,k=P.offset,Z=P.activeTooltipIndex,Q=P.tooltipAxisBandSize,W=A.getTooltipEventType(),$=(D=E.props.active)!==null&&D!==void 0?D:q,Y=A.props.layout,ee=E.key||"_recharts-cursor";return B.createElement(TY,{key:ee,activeCoordinate:V,activePayload:U,activeTooltipIndex:Z,chartName:n,element:E,isActive:$,layout:Y,offset:k,tooltipAxisBandSize:Q,tooltipEventType:W})}),be(A,"renderPolarAxis",function(E,D,P){var q=Rn(E,"type.axisType"),V=Rn(A.state,"".concat(q,"Map")),U=E.type.defaultProps,k=U!==void 0?ne(ne({},U),E.props):E.props,Z=V&&V[k["".concat(q,"Id")]];return H.cloneElement(E,ne(ne({},Z),{},{className:qe(q,Z.className),key:E.key||"".concat(D,"-").concat(P),ticks:Cr(Z,!0)}))}),be(A,"renderPolarGrid",function(E){var D=E.props,P=D.radialLines,q=D.polarAngles,V=D.polarRadius,U=A.state,k=U.radiusAxisMap,Z=U.angleAxisMap,Q=ga(k),W=ga(Z),$=W.cx,Y=W.cy,ee=W.innerRadius,oe=W.outerRadius;return H.cloneElement(E,{polarAngles:Array.isArray(q)?q:Cr(W,!0).map(function(le){return le.coordinate}),polarRadius:Array.isArray(V)?V:Cr(Q,!0).map(function(le){return le.coordinate}),cx:$,cy:Y,innerRadius:ee,outerRadius:oe,key:E.key||"polar-grid",radialLines:P})}),be(A,"renderLegend",function(){var E=A.state.formattedGraphicalItems,D=A.props,P=D.children,q=D.width,V=D.height,U=A.props.margin||{},k=q-(U.left||0)-(U.right||0),Z=fN({children:P,formattedGraphicalItems:E,legendWidth:k,legendContent:h});if(!Z)return null;var Q=Z.item,W=W2(Z,EY);return H.cloneElement(Q,ne(ne({},W),{},{chartWidth:q,chartHeight:V,margin:U,onBBoxUpdate:A.handleLegendBBoxUpdate}))}),be(A,"renderTooltip",function(){var E,D=A.props,P=D.children,q=D.accessibilityLayer,V=yn(P,Dn);if(!V)return null;var U=A.state,k=U.isTooltipActive,Z=U.activeCoordinate,Q=U.activePayload,W=U.activeLabel,$=U.offset,Y=(E=V.props.active)!==null&&E!==void 0?E:k;return H.cloneElement(V,{viewBox:ne(ne({},$),{},{x:$.left,y:$.top}),active:Y,label:W,payload:Y?Q:[],coordinate:Z,accessibilityLayer:q})}),be(A,"renderBrush",function(E){var D=A.props,P=D.margin,q=D.data,V=A.state,U=V.offset,k=V.dataStartIndex,Z=V.dataEndIndex,Q=V.updateId;return H.cloneElement(E,{key:E.key||"_recharts-brush",onChange:Os(A.handleBrushChange,E.props.onChange),data:q,x:fe(E.props.x)?E.props.x:U.left,y:fe(E.props.y)?E.props.y:U.top+U.height+U.brushBottom-(P.bottom||0),width:fe(E.props.width)?E.props.width:U.width,startIndex:k,endIndex:Z,updateId:"brush-".concat(Q)})}),be(A,"renderReferenceElement",function(E,D,P){if(!E)return null;var q=A,V=q.clipPathId,U=A.state,k=U.xAxisMap,Z=U.yAxisMap,Q=U.offset,W=E.type.defaultProps||{},$=E.props,Y=$.xAxisId,ee=Y===void 0?W.xAxisId:Y,oe=$.yAxisId,le=oe===void 0?W.yAxisId:oe;return H.cloneElement(E,{key:E.key||"".concat(D,"-").concat(P),xAxis:k[ee],yAxis:Z[le],viewBox:{x:Q.left,y:Q.top,width:Q.width,height:Q.height},clipPathId:V})}),be(A,"renderActivePoints",function(E){var D=E.item,P=E.activePoint,q=E.basePoint,V=E.childIndex,U=E.isRange,k=[],Z=D.props.key,Q=D.item.type.defaultProps!==void 0?ne(ne({},D.item.type.defaultProps),D.item.props):D.item.props,W=Q.activeDot,$=Q.dataKey,Y=ne(ne({index:V,dataKey:$,cx:P.x,cy:P.y,r:4,fill:K0(D.item),strokeWidth:2,stroke:"#fff",payload:P.payload,value:P.value},Ee(W,!1)),Cs(W));return k.push(T.renderActiveDot(W,Y,"".concat(Z,"-activePoint-").concat(V))),q?k.push(T.renderActiveDot(W,ne(ne({},Y),{},{cx:q.x,cy:q.y}),"".concat(Z,"-basePoint-").concat(V))):U&&k.push(null),k}),be(A,"renderGraphicChild",function(E,D,P){var q=A.filterFormatItem(E,D,P);if(!q)return null;var V=A.getTooltipEventType(),U=A.state,k=U.isTooltipActive,Z=U.tooltipAxis,Q=U.activeTooltipIndex,W=U.activeLabel,$=A.props.children,Y=yn($,Dn),ee=q.props,oe=ee.points,le=ee.isRange,R=ee.baseLine,I=q.item.type.defaultProps!==void 0?ne(ne({},q.item.type.defaultProps),q.item.props):q.item.props,re=I.activeDot,se=I.hide,pe=I.activeBar,me=I.activeShape,Me=!!(!se&&k&&Y&&(re||pe||me)),Ue={};V!=="axis"&&Y&&Y.props.trigger==="click"?Ue={onClick:Os(A.handleItemMouseEnter,E.props.onClick)}:V!=="axis"&&(Ue={onMouseLeave:Os(A.handleItemMouseLeave,E.props.onMouseLeave),onMouseEnter:Os(A.handleItemMouseEnter,E.props.onMouseEnter)});var ce=H.cloneElement(E,ne(ne({},q.props),Ue));function xe(lr){return typeof Z.dataKey=="function"?Z.dataKey(lr.payload):null}if(Me)if(Q>=0){var Se,ue;if(Z.dataKey&&!Z.allowDuplicatedCategory){var tt=typeof Z.dataKey=="function"?xe:"payload.".concat(Z.dataKey.toString());Se=Ms(oe,tt,W),ue=le&&R&&Ms(R,tt,W)}else Se=oe==null?void 0:oe[Q],ue=le&&R&&R[Q];if(me||pe){var we=E.props.activeIndex!==void 0?E.props.activeIndex:Q;return[H.cloneElement(E,ne(ne(ne({},q.props),Ue),{},{activeIndex:we})),null,null]}if(!je(Se))return[ce].concat(Ro(A.renderActivePoints({item:q,activePoint:Se,basePoint:ue,childIndex:Q,isRange:le})))}else{var ut,lt=(ut=A.getItemByXY(A.state.activeCoordinate))!==null&&ut!==void 0?ut:{graphicalItem:ce},Lt=lt.graphicalItem,kn=Lt.item,Zn=kn===void 0?E:kn,Gr=Lt.childIndex,Bn=ne(ne(ne({},q.props),Ue),{},{activeIndex:Gr});return[H.cloneElement(Zn,Bn),null,null]}return le?[ce,null,null]:[ce,null]}),be(A,"renderCustomized",function(E,D,P){return H.cloneElement(E,ne(ne({key:"recharts-customized-".concat(P)},A.props),A.state))}),be(A,"renderMap",{CartesianGrid:{handler:Es,once:!0},ReferenceArea:{handler:A.renderReferenceElement},ReferenceLine:{handler:Es},ReferenceDot:{handler:A.renderReferenceElement},XAxis:{handler:Es},YAxis:{handler:Es},Brush:{handler:A.renderBrush,once:!0},Bar:{handler:A.renderGraphicChild},Line:{handler:A.renderGraphicChild},Area:{handler:A.renderGraphicChild},Radar:{handler:A.renderGraphicChild},RadialBar:{handler:A.renderGraphicChild},Scatter:{handler:A.renderGraphicChild},Pie:{handler:A.renderGraphicChild},Funnel:{handler:A.renderGraphicChild},Tooltip:{handler:A.renderCursor,once:!0},PolarGrid:{handler:A.renderPolarGrid,once:!0},PolarAngleAxis:{handler:A.renderPolarAxis},PolarRadiusAxis:{handler:A.renderPolarAxis},Customized:{handler:A.renderCustomized}}),A.clipPathId="".concat((M=w.id)!==null&&M!==void 0?M:ko("recharts"),"-clip"),A.throttleTriggeredAfterMouseMove=fC(A.triggeredAfterMouseMove,(C=w.throttleDelay)!==null&&C!==void 0?C:1e3/60),A.state={},A}return BY(T,x),$Y(T,[{key:"componentDidMount",value:function(){var M,C;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(M=this.props.margin.left)!==null&&M!==void 0?M:0,top:(C=this.props.margin.top)!==null&&C!==void 0?C:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var M=this.props,C=M.children,A=M.data,E=M.height,D=M.layout,P=yn(C,Dn);if(P){var q=P.props.defaultIndex;if(!(typeof q!="number"||q<0||q>this.state.tooltipTicks.length-1)){var V=this.state.tooltipTicks[q]&&this.state.tooltipTicks[q].value,U=Zb(this.state,A,q,V),k=this.state.tooltipTicks[q].coordinate,Z=(this.state.offset.top+E)/2,Q=D==="horizontal",W=Q?{x:k,y:Z}:{y:k,x:Z},$=this.state.formattedGraphicalItems.find(function(ee){var oe=ee.item;return oe.type.name==="Scatter"});$&&(W=ne(ne({},W),$.props.points[q].tooltipPosition),U=$.props.points[q].tooltipPayload);var Y={activeTooltipIndex:q,isTooltipActive:!0,activeLabel:V,activePayload:U,activeCoordinate:W};this.setState(Y),this.renderCursor(P),this.accessibilityManager.setIndex(q)}}}},{key:"getSnapshotBeforeUpdate",value:function(M,C){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==C.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==M.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==M.margin){var A,E;this.accessibilityManager.setDetails({offset:{left:(A=this.props.margin.left)!==null&&A!==void 0?A:0,top:(E=this.props.margin.top)!==null&&E!==void 0?E:0}})}return null}},{key:"componentDidUpdate",value:function(M){$g([yn(M.children,Dn)],[yn(this.props.children,Dn)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var M=yn(this.props.children,Dn);if(M&&typeof M.props.shared=="boolean"){var C=M.props.shared?"axis":"item";return f.indexOf(C)>=0?C:l}return l}},{key:"getMouseInfo",value:function(M){if(!this.container)return null;var C=this.container,A=C.getBoundingClientRect(),E=z6(A),D={chartX:Math.round(M.pageX-E.left),chartY:Math.round(M.pageY-E.top)},P=A.width/C.offsetWidth||1,q=this.inRange(D.chartX,D.chartY,P);if(!q)return null;var V=this.state,U=V.xAxisMap,k=V.yAxisMap,Z=this.getTooltipEventType(),Q=J2(this.state,this.props.data,this.props.layout,q);if(Z!=="axis"&&U&&k){var W=ga(U).scale,$=ga(k).scale,Y=W&&W.invert?W.invert(D.chartX):null,ee=$&&$.invert?$.invert(D.chartY):null;return ne(ne({},D),{},{xValue:Y,yValue:ee},Q)}return Q?ne(ne({},D),Q):null}},{key:"inRange",value:function(M,C){var A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,E=this.props.layout,D=M/A,P=C/A;if(E==="horizontal"||E==="vertical"){var q=this.state.offset,V=D>=q.left&&D<=q.left+q.width&&P>=q.top&&P<=q.top+q.height;return V?{x:D,y:P}:null}var U=this.state,k=U.angleAxisMap,Z=U.radiusAxisMap;if(k&&Z){var Q=ga(k);return pj({x:D,y:P},Q)}return null}},{key:"parseEventsOfWrapper",value:function(){var M=this.props.children,C=this.getTooltipEventType(),A=yn(M,Dn),E={};A&&C==="axis"&&(A.props.trigger==="click"?E={onClick:this.handleClick}:E={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var D=Cs(this.props,this.handleOuterEvent);return ne(ne({},D),E)}},{key:"addListener",value:function(){Tg.on(Eg,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Tg.removeListener(Eg,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(M,C,A){for(var E=this.state.formattedGraphicalItems,D=0,P=E.length;D<P;D++){var q=E[D];if(q.item===M||q.props.key===M.key||C===Nr(q.item.type)&&A===q.childIndex)return q}return null}},{key:"renderClipPath",value:function(){var M=this.clipPathId,C=this.state.offset,A=C.left,E=C.top,D=C.height,P=C.width;return B.createElement("defs",null,B.createElement("clipPath",{id:M},B.createElement("rect",{x:A,y:E,height:D,width:P})))}},{key:"getXScales",value:function(){var M=this.state.xAxisMap;return M?Object.entries(M).reduce(function(C,A){var E=Z2(A,2),D=E[0],P=E[1];return ne(ne({},C),{},be({},D,P.scale))},{}):null}},{key:"getYScales",value:function(){var M=this.state.yAxisMap;return M?Object.entries(M).reduce(function(C,A){var E=Z2(A,2),D=E[0],P=E[1];return ne(ne({},C),{},be({},D,P.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(M){var C;return(C=this.state.xAxisMap)===null||C===void 0||(C=C[M])===null||C===void 0?void 0:C.scale}},{key:"getYScaleByAxisId",value:function(M){var C;return(C=this.state.yAxisMap)===null||C===void 0||(C=C[M])===null||C===void 0?void 0:C.scale}},{key:"getItemByXY",value:function(M){var C=this.state,A=C.formattedGraphicalItems,E=C.activeItem;if(A&&A.length)for(var D=0,P=A.length;D<P;D++){var q=A[D],V=q.props,U=q.item,k=U.type.defaultProps!==void 0?ne(ne({},U.type.defaultProps),U.props):U.props,Z=Nr(U.type);if(Z==="Bar"){var Q=(V.data||[]).find(function(ee){return a9(M,ee)});if(Q)return{graphicalItem:q,payload:Q}}else if(Z==="RadialBar"){var W=(V.data||[]).find(function(ee){return pj(M,ee)});if(W)return{graphicalItem:q,payload:W}}else if(Jf(q,E)||ed(q,E)||Pl(q,E)){var $=V9({graphicalItem:q,activeTooltipItem:E,itemData:k.data}),Y=k.activeIndex===void 0?$:k.activeIndex;return{graphicalItem:ne(ne({},q),{},{childIndex:Y}),payload:Pl(q,E)?k.data[$]:q.props.data[$]}}}return null}},{key:"render",value:function(){var M=this;if(!TA(this))return null;var C=this.props,A=C.children,E=C.className,D=C.width,P=C.height,q=C.style,V=C.compact,U=C.title,k=C.desc,Z=W2(C,jY),Q=Ee(Z,!1);if(V)return B.createElement(M2,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},B.createElement(zg,io({},Q,{width:D,height:P,title:U,desc:k}),this.renderClipPath(),jA(A,this.renderMap)));if(this.props.accessibilityLayer){var W,$;Q.tabIndex=(W=this.props.tabIndex)!==null&&W!==void 0?W:0,Q.role=($=this.props.role)!==null&&$!==void 0?$:"application",Q.onKeyDown=function(ee){M.accessibilityManager.keyboardEvent(ee)},Q.onFocus=function(){M.accessibilityManager.focus()}}var Y=this.parseEventsOfWrapper();return B.createElement(M2,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},B.createElement("div",io({className:qe("recharts-wrapper",E),style:ne({position:"relative",cursor:"default",width:D,height:P},q)},Y,{ref:function(oe){M.container=oe}}),B.createElement(zg,io({},Q,{width:D,height:P,title:U,desc:k,style:YY}),this.renderClipPath(),jA(A,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])})(H.Component);be(_,"displayName",n),be(_,"defaultProps",ne({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},v)),be(_,"getDerivedStateFromProps",function(x,T){var w=x.dataKey,M=x.data,C=x.children,A=x.width,E=x.height,D=x.layout,P=x.stackOffset,q=x.margin,V=T.dataStartIndex,U=T.dataEndIndex;if(T.updateId===void 0){var k=eM(x);return ne(ne(ne({},k),{},{updateId:0},b(ne(ne({props:x},k),{},{updateId:0}),T)),{},{prevDataKey:w,prevData:M,prevWidth:A,prevHeight:E,prevLayout:D,prevStackOffset:P,prevMargin:q,prevChildren:C})}if(w!==T.prevDataKey||M!==T.prevData||A!==T.prevWidth||E!==T.prevHeight||D!==T.prevLayout||P!==T.prevStackOffset||!oo(q,T.prevMargin)){var Z=eM(x),Q={chartX:T.chartX,chartY:T.chartY,isTooltipActive:T.isTooltipActive},W=ne(ne({},J2(T,M,D)),{},{updateId:T.updateId+1}),$=ne(ne(ne({},Z),Q),W);return ne(ne(ne({},$),b(ne({props:x},$),T)),{},{prevDataKey:w,prevData:M,prevWidth:A,prevHeight:E,prevLayout:D,prevStackOffset:P,prevMargin:q,prevChildren:C})}if(!$g(C,T.prevChildren)){var Y,ee,oe,le,R=yn(C,_o),I=R&&(Y=(ee=R.props)===null||ee===void 0?void 0:ee.startIndex)!==null&&Y!==void 0?Y:V,re=R&&(oe=(le=R.props)===null||le===void 0?void 0:le.endIndex)!==null&&oe!==void 0?oe:U,se=I!==V||re!==U,pe=!je(M),me=pe&&!se?T.updateId:T.updateId+1;return ne(ne({updateId:me},b(ne(ne({props:x},T),{},{updateId:me,dataStartIndex:I,dataEndIndex:re}),T)),{},{prevChildren:C,dataStartIndex:I,dataEndIndex:re})}return null}),be(_,"renderActiveDot",function(x,T,w){var M;return H.isValidElement(x)?M=H.cloneElement(x,T):Ae(x)?M=x(T):M=B.createElement(Qf,T),B.createElement(et,{className:"recharts-active-dot",key:w},M)});var S=H.forwardRef(function(T,w){return B.createElement(_,io({},T,{ref:w}))});return S.displayName=_.displayName,S},tX=ax({chartName:"LineChart",GraphicalChild:Fl,axisComponents:[{axisType:"xAxis",AxisComp:Ir},{axisType:"yAxis",AxisComp:Hr}],formatAxisMap:F0}),nX=ax({chartName:"BarChart",GraphicalChild:hi,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:Ir},{axisType:"yAxis",AxisComp:Hr}],formatAxisMap:F0}),SD=ax({chartName:"AreaChart",GraphicalChild:Vn,axisComponents:[{axisType:"xAxis",AxisComp:Ir},{axisType:"yAxis",AxisComp:Hr}],formatAxisMap:F0});const Oa="#2a3947",Ll="#8fa3b0",_a={fill:Ll,fontSize:11},ix={background:"#141d26",border:"1px solid #2a3947",borderRadius:"6px"},al="#00a8e8",Mg="#6bcb77",nM=["#c592f0","#00a8e8","#6bcb77","#f5d36b","#ff5e5e","#74cff7","#ff8266","#84cc16","#ec4899","#8b5cf6"];function rX(e){return new Date(e).toLocaleString("es",{hour:"2-digit",minute:"2-digit",day:"numeric",month:"short"})}function aX({timeRange:e,sseVersion:t,compact:n=!1}){const[r,o]=H.useState([]),[l,c]=H.useState([]);H.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([Ce.timeseries("claude_code.tokens.input",e,v),Ce.timeseries("claude_code.tokens.output",e,v)]).then(([g,b])=>{o(g),c(b)}).catch(()=>{})},[e,t]);const f=new Set([...r.map(v=>v.timestamp),...l.map(v=>v.timestamp)]),d=new Map(r.map(v=>[v.timestamp,v.value])),h=new Map(l.map(v=>[v.timestamp,v.value])),y=Array.from(f).sort().map(v=>({ts:v,label:rX(v),input:d.get(v)??0,output:h.get(v)??0}));return y.length===0?j.jsx("div",{className:`bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center ${n?"h-full min-h-[180px]":"h-48"}`,children:j.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de tokens"})}):j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Tokens por período"}),j.jsx(If,{width:"100%",height:n?140:220,children:j.jsxs(SD,{data:y,margin:{top:4,right:8,left:0,bottom:0},children:[j.jsxs("defs",{children:[j.jsxs("linearGradient",{id:"colorInput",x1:"0",y1:"0",x2:"0",y2:"1",children:[j.jsx("stop",{offset:"5%",stopColor:al,stopOpacity:.3}),j.jsx("stop",{offset:"95%",stopColor:al,stopOpacity:0})]}),j.jsxs("linearGradient",{id:"colorOutput",x1:"0",y1:"0",x2:"0",y2:"1",children:[j.jsx("stop",{offset:"5%",stopColor:Mg,stopOpacity:.3}),j.jsx("stop",{offset:"95%",stopColor:Mg,stopOpacity:0})]})]}),j.jsx(Vl,{strokeDasharray:"3 3",stroke:Oa}),j.jsx(Ir,{dataKey:"label",tick:_a,tickLine:!1,axisLine:{stroke:Oa}}),j.jsx(Hr,{tick:_a,tickLine:!1,axisLine:!1,tickFormatter:v=>v>=1e3?`${(v/1e3).toFixed(0)}K`:String(v)}),j.jsx(Dn,{contentStyle:ix,labelStyle:{color:Ll,fontSize:12},itemStyle:{fontSize:12}}),!n&&j.jsx(Pr,{wrapperStyle:{fontSize:12,color:Ll}}),j.jsx(Vn,{type:"monotone",dataKey:"input",name:"Input",stroke:al,fill:"url(#colorInput)",strokeWidth:2}),j.jsx(Vn,{type:"monotone",dataKey:"output",name:"Output",stroke:Mg,fill:"url(#colorOutput)",strokeWidth:2})]})})]})}const js=864e5,iX=["#11202c","#16384c","#1b5675","#0e7fb0","#00a8e8"],no=11,Wb=3,Cg=no+Wb,rM=28;function aM(e){return Math.floor(e/js)}function oX({sseVersion:e}){const[t,n]=H.useState(new Map),[r,o]=H.useState(null),l=H.useRef(null);H.useEffect(()=>{const w=l.current;w&&(w.scrollLeft=w.scrollWidth)},[t]),H.useEffect(()=>{Promise.all([Ce.timeseries("claude_code.tokens.input","now-365d","1d"),Ce.timeseries("claude_code.tokens.output","now-365d","1d"),Ce.timeseries("claude_code.cost","now-365d","1d")]).then(([w,M,C])=>{const A=new Map,E=(D,P)=>{for(const q of D){const V=aM(q.timestamp),U=A.get(V)??{tokens:0,cost:0};U[P]+=q.value,A.set(V,U)}};E(w,"tokens"),E(M,"tokens"),E(C,"cost"),n(A)}).catch(()=>{})},[e]);const c=[...t.values()];if(!c.some(w=>w.tokens>0))return j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-32",children:j.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de actividad"})});const f=Math.max(...c.map(w=>w.tokens),1),d=aM(Date.now()),h=d-364,y=(new Date(h*js).getUTCDay()+6)%7,v=h-y,g=[];for(let w=v;w<=d;w++)g.push(w);const b=[];let _=-1;for(let w=0;v+w*7<=d;w++){const M=new Date((v+w*7)*js),C=M.getUTCMonth();C!==_&&(b.push({col:w,label:M.toLocaleDateString("es",{month:"short",timeZone:"UTC"})}),_=C)}function S(w){return w<=0?0:Math.min(4,Math.max(1,Math.ceil(w/f*4)))}const x=110;function T(w,M){const C=w.currentTarget.getBoundingClientRect(),A=t.get(M),E=C.left+no/2,D=Math.min(Math.max(E,x+8),window.innerWidth-x-8),P=C.top<70;o({x:D,y:P?C.bottom+8:C.top-8,below:P,label:new Date(M*js).toLocaleDateString("es",{weekday:"long",day:"numeric",month:"short",year:"numeric",timeZone:"UTC"}),tokens:(A==null?void 0:A.tokens)??0,cost:(A==null?void 0:A.cost)??0})}return j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Actividad — últimos 12 meses"}),j.jsx("div",{ref:l,className:"overflow-x-auto pb-1",onScroll:()=>o(null),children:j.jsxs("div",{className:"relative inline-block","data-heatmap":!0,onMouseLeave:()=>o(null),children:[j.jsx("div",{className:"relative h-4 mb-1",style:{marginLeft:rM},children:b.map(w=>j.jsx("span",{className:"absolute text-[10px] text-text-secondary capitalize",style:{left:w.col*Cg},children:w.label},`${w.col}-${w.label}`))}),j.jsxs("div",{className:"flex",children:[j.jsx("div",{className:"relative shrink-0",style:{width:rM,height:7*Cg-Wb},children:[["Lun",0],["Mié",2],["Vie",4]].map(([w,M])=>j.jsx("span",{className:"absolute text-[10px] text-text-secondary leading-none",style:{top:M*Cg+1},children:w},w))}),j.jsx("div",{className:"grid grid-flow-col",style:{gridTemplateRows:`repeat(7, ${no}px)`,gridAutoColumns:`${no}px`,gap:Wb},children:g.map(w=>{var M;return j.jsx("div",{className:"rounded-[2px]",style:{width:no,height:no,background:iX[S(((M=t.get(w))==null?void 0:M.tokens)??0)]},onMouseEnter:C=>T(C,w)},w)})})]}),r&&j.jsxs("div",{className:"fixed z-50 pointer-events-none px-3 py-2 rounded-md text-xs whitespace-nowrap",style:{left:r.x,top:r.y,transform:r.below?"translate(-50%, 0)":"translate(-50%, -100%)",background:"#141d26",border:"1px solid #2a3947"},children:[j.jsx("div",{className:"text-text-primary font-medium capitalize",children:r.label}),j.jsxs("div",{className:"text-text-secondary mt-0.5",children:[At(r.tokens)," tokens · ",Mt(r.cost)]})]})]})})]})}function uX(e){return new Date(e).toLocaleDateString("es",{day:"numeric",month:"short"})}function lX({timeRange:e,sseVersion:t,compact:n=!1}){const[r,o]=H.useState([]);H.useEffect(()=>{Ce.timeseriesByProject("claude_code.cost",e,"1d").then(o).catch(()=>{})},[e,t]);const l=H.useMemo(()=>{const f=new Set;for(const d of r)Object.keys(d.projects).forEach(h=>f.add(h));return Array.from(f).sort()},[r]),c=r.map(f=>({label:uX(f.timestamp),...Object.fromEntries(l.map(d=>[d,Number((f.projects[d]??0).toFixed(4))]))}));return c.length===0?j.jsx("div",{className:`bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center ${n?"h-full min-h-[180px]":"h-48"}`,children:j.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de coste"})}):j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Coste por día ($)"}),j.jsx(If,{width:"100%",height:n?140:220,children:j.jsxs(nX,{data:c,margin:{top:4,right:8,left:0,bottom:0},children:[j.jsx(Vl,{strokeDasharray:"3 3",stroke:Oa,vertical:!1}),j.jsx(Ir,{dataKey:"label",tick:_a,tickLine:!1,axisLine:{stroke:Oa}}),j.jsx(Hr,{tick:_a,tickLine:!1,axisLine:!1,tickFormatter:f=>`$${f.toFixed(2)}`}),!n&&j.jsx(Pr,{wrapperStyle:{fontSize:11,color:Ll,paddingTop:8},iconType:"square",iconSize:8}),l.map((f,d)=>j.jsx(hi,{dataKey:f,stackId:"cost",fill:nM[d%nM.length],radius:d===l.length-1?[3,3,0,0]:[0,0,0,0]},f))]})})]})}function cX({timeRange:e,sseVersion:t}){const[n,r]=H.useState([]),[o,l]=H.useState([]);H.useEffect(()=>{const y=e==="now-24h"?"1h":"1d";Promise.all([Ce.timeseries("claude_code.tokens.cache.read",e,y),Ce.timeseries("claude_code.tokens.cache.creation",e,y)]).then(([v,g])=>{r(v),l(g)}).catch(()=>{})},[e,t]);const c=new Set([...n.map(y=>y.timestamp),...o.map(y=>y.timestamp)]),f=new Map(n.map(y=>[y.timestamp,y.value])),d=new Map(o.map(y=>[y.timestamp,y.value])),h=Array.from(c).sort().map(y=>({label:new Date(y).toLocaleString("es",{hour:"2-digit",day:"numeric",month:"short"}),read:f.get(y)??0,create:d.get(y)??0}));return h.length===0?j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-48",children:j.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de caché"})}):j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Tokens de caché"}),j.jsx(If,{width:"100%",height:220,children:j.jsxs(SD,{data:h,margin:{top:4,right:8,left:0,bottom:0},children:[j.jsx(Vl,{strokeDasharray:"3 3",stroke:Oa}),j.jsx(Ir,{dataKey:"label",tick:_a,tickLine:!1,axisLine:{stroke:Oa}}),j.jsx(Hr,{tick:_a,tickLine:!1,axisLine:!1,tickFormatter:y=>y>=1e3?`${(y/1e3).toFixed(0)}K`:String(y)}),j.jsx(Dn,{contentStyle:ix}),j.jsx(Pr,{wrapperStyle:{fontSize:12,color:Ll}}),j.jsx(Vn,{type:"monotone",dataKey:"read",name:"Leído",stroke:"#00d4aa",fill:"#00d4aa",fillOpacity:.2,strokeWidth:2}),j.jsx(Vn,{type:"monotone",dataKey:"create",name:"Creado",stroke:al,fill:al,fillOpacity:.2,strokeWidth:2})]})})]})}function sX({timeRange:e,sseVersion:t}){const[n,r]=H.useState([]),[o,l]=H.useState([]);H.useEffect(()=>{const y=e==="now-24h"?"1h":"1d";Promise.all([Ce.timeseries("claude_code.tokens.input",e,y),Ce.timeseries("claude_code.tokens.output",e,y)]).then(([v,g])=>{r(v),l(g)}).catch(()=>{})},[e,t]);const c=new Set([...n.map(y=>y.timestamp),...o.map(y=>y.timestamp)]),f=new Map(n.map(y=>[y.timestamp,y.value])),d=new Map(o.map(y=>[y.timestamp,y.value])),h=Array.from(c).sort().map(y=>{const v=f.get(y)??0,g=d.get(y)??0;return{label:new Date(y).toLocaleString("es",{hour:"2-digit",day:"numeric",month:"short"}),efficiency:v>0?Number((g/v).toFixed(3)):0}});return h.length===0?j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-48",children:j.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de eficiencia"})}):j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Ratio output/input"}),j.jsx(If,{width:"100%",height:220,children:j.jsxs(tX,{data:h,margin:{top:4,right:8,left:0,bottom:0},children:[j.jsx(Vl,{strokeDasharray:"3 3",stroke:Oa}),j.jsx(Ir,{dataKey:"label",tick:_a,tickLine:!1,axisLine:{stroke:Oa}}),j.jsx(Hr,{tick:_a,tickLine:!1,axisLine:!1,domain:[0,"auto"]}),j.jsx(Dn,{contentStyle:ix,formatter:y=>[y.toFixed(3),"Eficiencia"]}),j.jsx(nd,{y:.5,stroke:"#3b4d5e",strokeDasharray:"4 4",label:{value:"0.5",fill:"#5a6e7a",fontSize:10}}),j.jsx(Fl,{type:"monotone",dataKey:"efficiency",stroke:"#c592f0",strokeWidth:2,dot:!1})]})})]})}function OD(e,t=null){const[n,r]=H.useState(t),[o,l]=H.useState("desc");function c(h){h===n?l(y=>y==="desc"?"asc":"desc"):(r(h),l("desc"))}const f=H.useMemo(()=>{if(!n)return e;const h=o==="desc"?-1:1;return[...e].sort((y,v)=>{const g=y[n],b=v[n];return typeof g=="number"&&typeof b=="number"?(g-b)*h:String(g??"").localeCompare(String(b??""))*h})},[e,n,o]);function d(h){return h!==n?"":o==="desc"?" ↓":" ↑"}return{sorted:f,toggle:c,indicator:d}}function Go({stats:e}){return e.length===0?null:j.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 mb-4",children:e.map(t=>j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg px-4 py-3",children:[j.jsx("div",{className:"text-xs text-text-secondary uppercase tracking-wider mb-1",children:t.label}),j.jsx("div",{className:`text-xl font-mono font-bold ${t.accent??"text-text-primary"}`,children:t.value})]},t.label))})}function fX({timeRange:e,sseVersion:t}){const[n,r]=H.useState([]),[o,l]=H.useState(null),[c,f]=H.useState([]),[d,h]=H.useState(null),[y,v]=H.useState(""),[g,b]=H.useState(""),[_,S]=H.useState([]),{sorted:x,toggle:T,indicator:w}=OD(n,"startTime");H.useEffect(()=>{Ce.sessions(50,g||void 0).then(r).catch(()=>{})},[e,t,g]),H.useEffect(()=>{Ce.projects(e).then(P=>S(P.map(q=>q.project))).catch(()=>{})},[e,t]);function M(P){o===P?(l(null),f([])):(f([]),l(P),Ce.sessionEvents(P).then(f).catch(()=>{}))}function C(P,q,V){V.stopPropagation(),h(P),v(q??"")}async function A(P){y.trim()&&(await Ce.labelSession(P,y.trim()).catch(()=>{}),r(q=>q.map(V=>V.sessionId===P?{...V,project:y.trim()}:V))),h(null)}if(n.length===0&&!g)return j.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin sesiones registradas"});const E=n.reduce((P,q)=>P+q.cost,0),D=n.length>0?n.reduce((P,q)=>P+q.durationActiveMs,0)/n.length:0;return j.jsxs("div",{className:"flex flex-col gap-3",children:[j.jsx(Go,{stats:[{label:"Sesiones",value:String(n.length),accent:"text-accent-purple"},{label:"Coste total",value:Mt(E),accent:"text-accent-yellow"},{label:"Duración media",value:Dg(D),accent:"text-accent-blue"}]}),_.length>0&&j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-xs text-text-muted uppercase tracking-wider",children:"Proyecto"}),j.jsxs("select",{value:g,onChange:P=>b(P.target.value),className:"bg-bg-card border border-bg-border rounded px-2 py-1 text-xs text-text-primary outline-none focus:border-accent-green cursor-pointer",children:[j.jsx("option",{value:"",children:"Todos"}),_.map(P=>j.jsx("option",{value:P,children:P},P))]})]}),n.length===0?j.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin sesiones para este proyecto"}):j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg",children:j.jsx("div",{className:"overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm min-w-[720px] whitespace-nowrap",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"border-b border-bg-border",children:[j.jsx("th",{className:"w-6 px-3 py-2"}),j.jsx("th",{className:"text-left px-3 py-2 text-text-muted font-medium",children:"ID"}),j.jsxs("th",{className:"text-left px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("project"),children:["Proyecto",w("project")]}),j.jsxs("th",{className:"text-left px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("model"),children:["Modelo",w("model")]}),j.jsxs("th",{className:"text-left px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("startTime"),children:["Inicio",w("startTime")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("durationActiveMs"),children:["Duración",w("durationActiveMs")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("tokensInput"),children:["Input",w("tokensInput")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("tokensOutput"),children:["Output",w("tokensOutput")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("cost"),children:["Coste",w("cost")]})]})}),j.jsx("tbody",{children:x.map(P=>j.jsxs(H.Fragment,{children:[j.jsxs("tr",{className:"border-b border-bg-border hover:bg-bg-card-hover cursor-pointer",onClick:()=>M(P.sessionId),children:[j.jsx("td",{className:"px-3 py-2 text-text-muted",children:o===P.sessionId?j.jsx(c3,{size:14}):j.jsx(f3,{size:14})}),j.jsxs("td",{className:"px-3 py-2 font-mono text-text-secondary text-xs",children:[P.sessionId.slice(0,8),"…"]}),j.jsx("td",{className:"px-3 py-2",onClick:q=>q.stopPropagation(),children:d===P.sessionId?j.jsxs("span",{className:"flex items-center gap-1",children:[j.jsx("input",{autoFocus:!0,value:y,onChange:q=>v(q.target.value),onKeyDown:q=>{q.key==="Enter"&&A(P.sessionId),q.key==="Escape"&&h(null)},className:"bg-bg-base border border-bg-border rounded px-1 py-0.5 text-xs text-text-primary w-24 outline-none focus:border-accent-green"}),j.jsx("button",{onClick:()=>A(P.sessionId),className:"text-accent-green",children:j.jsx(Jb,{size:12})}),j.jsx("button",{onClick:()=>h(null),className:"text-accent-orange",children:j.jsx(lM,{size:12})})]}):j.jsxs("span",{onClick:q=>C(P.sessionId,P.project,q),className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-bg-base border border-bg-border text-text-secondary hover:border-accent-green cursor-pointer transition-colors",children:[P.project??"—",j.jsx(E3,{size:10,className:"opacity-50"})]})}),j.jsx("td",{className:"px-3 py-2 text-text-secondary font-mono text-xs",children:P.model??"—"}),j.jsx("td",{className:"px-3 py-2 text-text-secondary",children:e0(P.startTime)}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-text-secondary",children:Dg(P.durationActiveMs)}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-blue",children:At(P.tokensInput)}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-green",children:At(P.tokensOutput)}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-purple",children:Mt(P.cost)})]}),o===P.sessionId&&j.jsx("tr",{children:j.jsx("td",{colSpan:9,className:"bg-bg-subtle px-6 py-3",children:j.jsx("div",{className:"text-xs font-mono space-y-0.5 max-h-40 overflow-y-auto",children:c.length===0?j.jsx("span",{className:"text-text-muted",children:"Sin eventos"}):c.slice(-20).map((q,V)=>j.jsxs("div",{className:"flex gap-2 text-text-secondary",children:[j.jsx("span",{className:"text-text-muted shrink-0",children:new Date(q.timestamp).toLocaleTimeString()}),j.jsx("span",{className:"text-accent-teal",children:q.eventName})]},`${q.timestamp}-${q.eventName}-${V}`))})})})]},P.sessionId))})]})})})]})}function dX({timeRange:e,sseVersion:t}){const[n,r]=H.useState([]),[o,l]=H.useState(null),{sorted:c,toggle:f,indicator:d}=OD(n,"cost"),h=H.useCallback(()=>{Ce.projects(e).then(r).catch(()=>{})},[e]);H.useEffect(()=>{h()},[h,t]);const y=async g=>{if(confirm(`¿Resetear todos los datos del proyecto "${g}"?`)){l(g);try{await Ce.resetProject(g),h()}finally{l(null)}}};if(n.length===0)return j.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin proyectos registrados"});const v=Math.max(...n.map(g=>g.cost),1e-4);return j.jsxs("div",{className:"flex flex-col gap-4",children:[j.jsx(Go,{stats:[{label:"Proyectos",value:String(n.length),accent:"text-accent-cyan"},{label:"Coste total",value:Mt(n.reduce((g,b)=>g+b.cost,0)),accent:"text-accent-yellow"},{label:"Más caro",value:n.length>0?[...n].sort((g,b)=>b.cost-g.cost)[0].project:"—",accent:"text-accent-orange"}]}),j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4 space-y-3",children:n.map(g=>j.jsxs("div",{children:[j.jsxs("div",{className:"flex justify-between text-xs mb-1",children:[j.jsx("span",{className:"text-text-primary font-medium",children:g.project}),j.jsx("span",{className:"text-accent-purple font-mono",children:Mt(g.cost)})]}),j.jsx("div",{className:"h-2 bg-bg-base rounded-full overflow-hidden",children:j.jsx("div",{className:"h-full bg-accent-purple rounded-full",style:{width:`${g.cost/v*100}%`}})})]},g.project))}),j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm min-w-[640px]",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"border-b border-bg-border",children:[j.jsxs("th",{className:"text-left px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("project"),children:["Proyecto",d("project")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("sessions"),children:["Sesiones",d("sessions")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("tokensInput"),children:["Input",d("tokensInput")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("tokensOutput"),children:["Output",d("tokensOutput")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("cacheHitRate"),children:["Caché %",d("cacheHitRate")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("cost"),children:["Coste",d("cost")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("commits"),children:["Commits",d("commits")]}),j.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"LOC +/-"}),j.jsx("th",{className:"px-3 py-2"})]})}),j.jsx("tbody",{children:c.map(g=>j.jsxs("tr",{className:"border-b border-bg-border hover:bg-bg-card-hover",children:[j.jsx("td",{className:"px-3 py-2 text-text-primary font-medium",children:g.project}),j.jsx("td",{className:"px-3 py-2 text-right text-text-secondary",children:g.sessions}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-blue",children:At(g.tokensInput)}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-green",children:At(g.tokensOutput)}),j.jsxs("td",{className:"px-3 py-2 text-right font-mono text-accent-teal",children:[(g.cacheHitRate*100).toFixed(1),"%"]}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-purple",children:Mt(g.cost)}),j.jsx("td",{className:"px-3 py-2 text-right text-text-secondary",children:g.commits}),j.jsxs("td",{className:"px-3 py-2 text-right font-mono text-xs",children:[j.jsxs("span",{className:"text-accent-green",children:["+",g.linesAdded]}),j.jsx("span",{className:"text-text-muted",children:" / "}),j.jsxs("span",{className:"text-accent-orange",children:["-",g.linesRemoved]})]}),j.jsx("td",{className:"px-3 py-2 text-right",children:j.jsx("button",{onClick:()=>y(g.project),disabled:o===g.project,title:"Resetear proyecto",className:"p-1 rounded text-text-muted hover:text-accent-orange hover:bg-bg-base transition-colors disabled:opacity-40",children:j.jsx(P3,{size:13})})})]},g.project))})]})})]})}function hX({timeRange:e,sseVersion:t}){const[n,r]=H.useState(null);if(H.useEffect(()=>{Ce.tools(e).then(r).catch(()=>{})},[e,t]),!n||n.usage.length===0)return j.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin datos de herramientas"});const o=Math.max(...n.usage.map(f=>f.count),1),l=n.decisionRate.approved+n.decisionRate.rejected,c=l>0?(n.decisionRate.approved/l*100).toFixed(1):"—";return j.jsxs("div",{className:"flex flex-col gap-4",children:[j.jsx(Go,{stats:[{label:"Herramientas",value:String(n.usage.length),accent:"text-accent-cyan"},{label:"Invocaciones",value:At(n.usage.reduce((f,d)=>f+d.count,0)),accent:"text-accent-green"},{label:"Más usada",value:n.usage.length>0?[...n.usage].sort((f,d)=>d.count-f.count)[0].toolName:"—",accent:"text-accent-purple"}]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("span",{className:"text-text-secondary text-sm",children:"Tasa de aprobación: "}),j.jsxs("span",{className:"text-accent-green font-mono font-bold",children:[c,"%"]}),j.jsxs("span",{className:"text-text-muted text-xs ml-2",children:["(",n.decisionRate.approved," aprobadas / ",n.decisionRate.rejected," rechazadas)"]})]}),j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4 space-y-2",children:n.usage.map(f=>j.jsxs("div",{children:[j.jsxs("div",{className:"flex justify-between text-xs mb-1",children:[j.jsx("span",{className:"font-mono text-text-primary",children:f.toolName}),j.jsxs("span",{className:"text-text-secondary",children:[f.count," usos · ",(f.successRate*100).toFixed(0),"% éxito"]})]}),j.jsx("div",{className:"h-1.5 bg-bg-base rounded-full overflow-hidden",children:j.jsx("div",{className:"h-full bg-accent-teal rounded-full",style:{width:`${f.count/o*100}%`}})})]},f.toolName))})]})}const pX={"now-24h":"últimas 24 h","now-7d":"últimos 7 días","now-30d":"últimos 30 días",all:"acumulado total"};function vX({timeRange:e,sseVersion:t}){const[n,r]=H.useState([]);if(H.useEffect(()=>{Ce.models(e).then(r).catch(()=>{})},[e,t]),n.length===0)return j.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin datos de modelos"});const o=Math.max(...n.map(c=>c.cost),1e-6),l=n.reduce((c,f)=>c+f.cost,0);return j.jsxs(j.Fragment,{children:[j.jsx(Go,{stats:[{label:"Modelos",value:String(n.length),accent:"text-accent-cyan"},{label:"Coste total",value:Mt(n.reduce((c,f)=>c+f.cost,0)),accent:"text-accent-yellow"},{label:"Dominante",value:n.length>0?[...n].sort((c,f)=>f.cost-c.cost)[0].model:"—",accent:"text-accent-purple"}]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsxs("div",{className:"flex justify-between items-baseline mb-4",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary",children:"Coste por modelo"}),j.jsx("span",{className:"text-xs text-text-muted",children:pX[e]})]}),j.jsxs("table",{className:"w-full text-sm",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"text-xs text-text-muted uppercase tracking-wider text-left",children:[j.jsx("th",{className:"pb-2 font-medium",children:"Modelo"}),j.jsx("th",{className:"pb-2 font-medium text-right",children:"Requests"}),j.jsx("th",{className:"pb-2 font-medium text-right",children:"Tokens In"}),j.jsx("th",{className:"pb-2 font-medium text-right",children:"Tokens Out"}),j.jsx("th",{className:"pb-2 font-medium text-right",children:"Coste"}),j.jsx("th",{className:"pb-2 font-medium text-right",children:"% gasto"})]})}),j.jsx("tbody",{children:n.map(c=>j.jsxs("tr",{className:"border-t border-bg-border",children:[j.jsxs("td",{className:"py-2 pr-4",children:[j.jsx("div",{className:"font-mono text-text-primary",children:c.model}),j.jsx("div",{className:"h-1.5 bg-bg-base rounded-full overflow-hidden mt-1",children:j.jsx("div",{className:"h-full bg-accent-purple rounded-full",style:{width:`${c.cost/o*100}%`}})})]}),j.jsx("td",{className:"py-2 text-right font-mono text-text-secondary",children:c.requests}),j.jsx("td",{className:"py-2 text-right font-mono text-accent-blue",children:At(c.tokensInput)}),j.jsx("td",{className:"py-2 text-right font-mono text-accent-green",children:At(c.tokensOutput)}),j.jsx("td",{className:"py-2 text-right font-mono font-bold text-accent-purple",children:Mt(c.cost)}),j.jsx("td",{className:"py-2 text-right font-mono text-text-secondary",children:l>0?`${(c.cost/l*100).toFixed(1)}%`:"—"})]},c.model))})]})]})]})}const Qu={"claude-fable-5":{input:10,output:50,cacheWrite:12.5,cacheRead:1},"claude-opus-4-8":{input:5,output:25,cacheWrite:6.25,cacheRead:.5},"claude-sonnet-4-6":{input:3,output:15,cacheWrite:3.75,cacheRead:.3},"claude-haiku-4-5":{input:1,output:5,cacheWrite:1.25,cacheRead:.1}},iM=Qu["claude-sonnet-4-6"];function _D(e){if(!e)return iM;const t=e.toLowerCase();return t.includes("fable")?Qu["claude-fable-5"]:t.includes("opus")?Qu["claude-opus-4-8"]:t.includes("haiku")?Qu["claude-haiku-4-5"]:t.includes("sonnet")?Qu["claude-sonnet-4-6"]:iM}function AD(e,t){const n=_D(t);return e*(n.input-n.cacheRead)/1e6}const yX=[{id:"all",label:"Todos"},{id:"api",label:"API"},{id:"tools",label:"Tools"},{id:"prompts",label:"Prompts"},{id:"errors",label:"Errores"}];function mX(e){return e>=1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(4)}`}function gX(e){const t=e.attributes;if(typeof t.cost=="number"&&t.cost>0)return t.cost;const n=Number(t.input_tokens??t["tokens.input"]??0),r=Number(t.output_tokens??t["tokens.output"]??0),o=Number(t.cache_read_input_tokens??t["tokens.cache_read"]??0),l=Number(t.cache_creation_input_tokens??t["tokens.cache_creation"]??0);if(n===0&&r===0)return null;const c=_D(e.model);return n*c.input/1e6+r*c.output/1e6+o*c.cacheRead/1e6+l*c.cacheWrite/1e6}function bX(e){return e.includes("error")?"text-accent-orange":e==="user_prompt"?"text-accent-blue":e==="api_request"?"text-accent-green":e==="tool_use"?"text-accent-teal":e.startsWith("hook_")?"text-accent-yellow":"text-text-secondary"}function xX(e,t){return t==="all"?!0:t==="api"?e.eventName.includes("api"):t==="tools"?e.eventName.includes("tool"):t==="prompts"?e.eventName.includes("prompt"):t==="errors"?e.eventName.includes("error"):!0}function SX({timeRange:e,sseVersion:t}){const[n,r]=H.useState([]),[o,l]=H.useState("all"),[c,f]=H.useState(!1);H.useEffect(()=>{c||Ce.events(500).then(r).catch(()=>{})},[e,t,c]);const d=n.filter(h=>xX(h,o));return j.jsxs(j.Fragment,{children:[j.jsx(Go,{stats:[{label:"Eventos",value:At(n.length),accent:"text-accent-cyan"},{label:"Errores",value:String(n.filter(h=>h.eventName.includes("error")).length),accent:"text-accent-red"},{label:"Último evento",value:n.length>0?e0(n[0].timestamp):"—",accent:"text-accent-blue"}]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg flex flex-col h-[600px]",children:[j.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-bg-border flex-wrap",children:[yX.map(({id:h,label:y})=>j.jsx("button",{onClick:()=>l(h),className:`px-2 py-1 rounded text-xs transition-colors ${o===h?"bg-accent-cyan text-bg-base font-medium":"text-text-secondary hover:text-text-primary"}`,children:y},h)),j.jsx("div",{className:"flex-1"}),j.jsxs("button",{onClick:()=>f(h=>!h),className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-text-secondary hover:text-text-primary",children:[c?j.jsx(M3,{size:12}):j.jsx(w3,{size:12}),j.jsx("span",{children:c?"Reanudar":"Pausar"})]})]}),j.jsx("div",{className:"flex-1 overflow-y-auto p-3 font-mono text-xs space-y-0.5",children:d.length===0?j.jsx("span",{className:"text-text-muted",children:"Sin eventos"}):d.map((h,y)=>{const v=gX(h);return j.jsxs("div",{className:"flex gap-2 hover:bg-bg-base px-1 rounded",children:[j.jsx("span",{className:"text-text-muted shrink-0",children:new Date(h.timestamp).toLocaleTimeString()}),j.jsx("span",{className:`shrink-0 ${bX(h.eventName)}`,children:h.eventName}),h.sessionId&&j.jsxs("span",{className:"text-text-muted",children:[h.sessionId.slice(0,6),"…"]}),v!==null&&j.jsx("span",{className:"text-accent-purple ml-auto shrink-0",children:mX(v)})]},`${h.sessionId??""}-${h.timestamp}-${h.eventName}-${y}`)})})]})]})}function OX({sseVersion:e}){const[t,n]=H.useState([]);return H.useEffect(()=>{Ce.agents().then(n).catch(()=>{})},[e]),t.length===0?j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-8 flex items-center justify-center",children:j.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de agentes. Aparece cuando Claude Code delega tareas a subagentes (herramienta Task)."})}):j.jsxs(j.Fragment,{children:[j.jsx(Go,{stats:[{label:"Agentes",value:String(t.length),accent:"text-accent-cyan"},{label:"Tokens totales",value:At(t.reduce((r,o)=>r+o.tokensInput+o.tokensOutput,0)),accent:"text-accent-green"},{label:"Más activo",value:t.length>0?[...t].sort((r,o)=>o.tokensInput+o.tokensOutput-(r.tokensInput+r.tokensOutput))[0].name:"—",accent:"text-accent-purple"}]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg overflow-hidden",children:[j.jsxs("div",{className:"px-3 py-2 border-b border-bg-border grid grid-cols-4 text-xs text-text-muted",children:[j.jsx("span",{children:"Agente"}),j.jsx("span",{children:"Input"}),j.jsx("span",{children:"Output"}),j.jsx("span",{children:"Coste"})]}),t.map(r=>j.jsxs("div",{className:"grid grid-cols-4 items-center py-2 border-b border-bg-border text-sm hover:bg-bg-card-hover px-3",children:[j.jsx("span",{className:"text-text-secondary",children:r.name}),j.jsx("span",{className:"font-mono text-accent-blue",children:At(r.tokensInput)}),j.jsx("span",{className:"font-mono text-accent-green",children:At(r.tokensOutput)}),j.jsx("span",{className:"font-mono text-accent-purple",children:Mt(r.cost)})]},r.name))]})]})}function ld({title:e,onViewAll:t,children:n}){return j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4 flex flex-col",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-3",children:e}),j.jsx("div",{className:"flex-1",children:n}),t&&j.jsx("button",{onClick:t,className:"self-start mt-3 text-xs text-link-subtle hover:text-accent-cyan transition-colors",children:"Ver todo →"})]})}function _X({sseVersion:e,onViewAll:t}){const[n,r]=H.useState([]);return H.useEffect(()=>{Ce.sessions(3).then(r).catch(()=>{})},[e]),j.jsx(ld,{title:"Sesiones recientes",onViewAll:t,children:n.length===0?j.jsx("span",{className:"text-xs text-text-muted",children:"Sin sesiones"}):j.jsx("ul",{className:"flex flex-col gap-2",children:n.map(o=>j.jsxs("li",{className:"flex items-baseline justify-between gap-2 text-xs",children:[j.jsxs("span",{className:"text-text-primary truncate",children:[j.jsx("span",{className:"text-accent-cyan",children:"●"})," ",o.project??"sin proyecto"]}),j.jsxs("span",{className:"font-mono text-text-secondary whitespace-nowrap",children:[Mt(o.cost)," · ",At(o.tokensInput+o.tokensOutput)," tok"]})]},o.sessionId))})})}function AX({timeRange:e,sseVersion:t,onViewAll:n}){const[r,o]=H.useState([]);return H.useEffect(()=>{Ce.projects(e).then(l=>o([...l].sort((c,f)=>f.cost-c.cost).slice(0,3))).catch(()=>{})},[e,t]),j.jsx(ld,{title:"Top proyectos",onViewAll:n,children:r.length===0?j.jsx("span",{className:"text-xs text-text-muted",children:"Sin proyectos"}):j.jsx("ul",{className:"flex flex-col gap-2",children:r.map((l,c)=>j.jsxs("li",{className:"flex items-baseline justify-between gap-2 text-xs",children:[j.jsxs("span",{className:"text-text-primary truncate",children:[j.jsxs("span",{className:"text-text-muted",children:[c+1,"."]})," ",l.project]}),j.jsx("span",{className:"font-mono text-accent-yellow whitespace-nowrap",children:Mt(l.cost)})]},l.project))})})}function wX(e){return e.includes("error")?"text-accent-red":e==="user_prompt"?"text-accent-blue":e==="api_request"?"text-accent-green":e==="tool_use"?"text-accent-teal":e.startsWith("hook_")?"text-accent-yellow":"text-text-secondary"}function TX({sseVersion:e,onViewAll:t}){const[n,r]=H.useState([]);return H.useEffect(()=>{Ce.events(3).then(r).catch(()=>{})},[e]),j.jsx(ld,{title:"Eventos recientes",onViewAll:t,children:n.length===0?j.jsx("span",{className:"text-xs text-text-muted",children:"Sin eventos"}):j.jsx("ul",{className:"flex flex-col gap-2",children:n.map((o,l)=>j.jsxs("li",{className:"flex items-baseline justify-between gap-2 text-xs",children:[j.jsxs("span",{className:`truncate ${wX(o.eventName)}`,children:["● ",o.eventName]}),j.jsx("span",{className:"text-text-muted whitespace-nowrap",children:e0(o.timestamp)})]},`${o.timestamp}-${l}`))})})}function EX({summary:e}){return j.jsx(ld,{title:"Ahorro caché",children:j.jsxs("div",{className:"flex flex-col justify-center h-full gap-1",children:[j.jsx("span",{className:"text-3xl font-mono font-bold text-accent-green",children:Mt(AD(e.tokens.cache))}),j.jsxs("span",{className:"text-xs text-text-muted",children:["est. período · ",At(e.tokens.cache)," tokens de caché"]})]})})}function jX(){const[e,t]=H.useState("now-24h");return{timeRange:e,setTimeRange:t}}function MX(e){const[t,n]=H.useState({connected:!1,lastSeen:null,sessionCount:0,totalEvents:0,uptime:0}),[r,o]=H.useState(null),[l,c]=H.useState(0),f=H.useRef(0),d=H.useRef(0),h=H.useCallback(async()=>{f.current=Date.now();try{const[v,g]=await Promise.all([Ce.status(),Ce.summary(e)]);n(v),o(g)}catch{}},[e]);H.useEffect(()=>{h()},[h]);const y=H.useCallback((v,g)=>{Date.now()-f.current>5e3?h():Ce.status().then(n).catch(()=>{});const b=Date.now();b-d.current>5e3&&(d.current=b,c(_=>_+1))},[h]);return cM(y),{status:t,summary:r,refetch:h,sseVersion:l}}const Ng=e=>e.reduce((t,n)=>t+n.value,0);function CX(e){const[t,n]=H.useState({tokensPerMin:0,costPerHour:0}),r=H.useCallback(async()=>{try{const[o,l,c]=await Promise.all([Ce.timeseries("claude_code.tokens.input","now-5m","5m"),Ce.timeseries("claude_code.tokens.output","now-5m","5m"),Ce.timeseries("claude_code.cost","now-5m","5m")]);n({tokensPerMin:(Ng(o)+Ng(l))/5,costPerHour:Ng(c)*12})}catch{}},[]);return H.useEffect(()=>{r()},[r,e]),H.useEffect(()=>{const o=setInterval(r,3e4);return()=>clearInterval(o)},[r]),t}const NX={overview:"Overview",sessions:"Sessions",projects:"Projects",tools:"Tools",agents:"Agents",models:"Models",events:"Events",costs:"Costs"},oM="__new__";function DX({autoDetected:e,userSelected:t,knownProjects:n,onChange:r}){const[o,l]=H.useState(!1),[c,f]=H.useState(""),d=t??e;if(!d&&n.length===0)return null;const h=[...new Set([...n,...d?[d]:[]])];if(h.length===0)return null;function y(g){g.target.value===oM?(l(!0),f("")):r(g.target.value||null)}function v(){const g=c.trim();g&&r(g),l(!1),f("")}return j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-xs text-text-muted uppercase tracking-wider",children:"Proyecto"}),o?j.jsxs(j.Fragment,{children:[j.jsx("input",{autoFocus:!0,value:c,onChange:g=>f(g.target.value),onKeyDown:g=>{g.key==="Enter"&&v(),g.key==="Escape"&&(l(!1),f(""))},placeholder:"nombre del proyecto",className:"bg-bg-base border border-bg-border rounded px-2 py-0.5 text-lg font-semibold text-text-primary outline-none focus:border-accent-cyan w-44"}),j.jsx("button",{onClick:v,className:"text-xs text-accent-green hover:opacity-80 transition-opacity",children:"✓"}),j.jsx("button",{onClick:()=>{l(!1),f("")},className:"text-xs text-text-muted hover:text-accent-red transition-colors",children:"✕"})]}):j.jsxs(j.Fragment,{children:[j.jsxs("select",{value:d??"",onChange:y,className:"bg-bg-card border border-bg-border rounded px-2 py-0.5 text-lg font-semibold text-text-primary outline-none focus:border-accent-cyan cursor-pointer",children:[h.map(g=>j.jsx("option",{value:g,children:g},g)),j.jsx("option",{disabled:!0,children:"──────────"}),j.jsx("option",{value:oM,children:"+ Nuevo proyecto"})]}),t&&t!==e&&j.jsx("button",{onClick:()=>r(null),className:"text-xs text-text-muted hover:text-text-secondary transition-colors",title:"Volver al proyecto auto-detectado",children:"↩ auto"})]})]})}function PX(){const[e,t]=H.useState("overview"),{timeRange:n,setTimeRange:r}=jX(),{status:o,summary:l,refetch:c,sseVersion:f}=MX(n),d=CX(f),[h,y]=H.useState(null),[v,g]=H.useState([]),[b,_]=H.useState([]);H.useEffect(()=>{Ce.projects(n).then(w=>{g(w.map(M=>M.project)),_(w)}).catch(()=>{})},[f,n]),H.useEffect(()=>{Ce.summary("now-24h").then(w=>{document.title=w.cost>0?`${Mt(w.cost)} hoy · tokenrace`:"tokenrace"}).catch(()=>{})},[f]);const S=H.useCallback(async()=>{await Ce.reset(),c()},[c]);if(!o.connected&&o.totalEvents===0)return j.jsxs("div",{className:"min-h-screen bg-bg-base text-text-primary flex flex-col",children:[j.jsx(y_,{sectionTitle:"Setup",timeRange:n,onTimeRangeChange:r,connected:!1,lastSeen:null,onReset:S,liveRate:d}),j.jsx(G3,{})]});const x=h??(l==null?void 0:l.currentProject)??null,T=b.find(w=>w.project===x)??null;return j.jsxs("div",{className:"min-h-screen bg-bg-base text-text-primary flex",children:[j.jsx(H3,{activeTab:e,onTabChange:t}),j.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[j.jsx(y_,{sectionTitle:NX[e],timeRange:n,onTimeRangeChange:r,connected:o.connected,lastSeen:o.lastSeen,onReset:S,liveRate:d}),j.jsx(K3,{onLabeled:c}),j.jsxs("main",{className:"flex-1 p-4 max-w-screen-2xl mx-auto w-full",children:[e==="overview"&&j.jsxs("div",{className:"flex flex-col gap-4",children:[j.jsx(DX,{autoDetected:(l==null?void 0:l.currentProject)??null,userSelected:h,knownProjects:v,onChange:y}),l&&j.jsx(Z3,{summary:l,selectedProjectData:T,timeRange:n,sseVersion:f,onNavigate:t}),j.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[j.jsx(aX,{compact:!0,timeRange:n,sseVersion:f}),j.jsx(lX,{compact:!0,timeRange:n,sseVersion:f}),l&&j.jsx(EX,{summary:l}),j.jsx(_X,{sseVersion:f,onViewAll:()=>t("sessions")}),j.jsx(AX,{timeRange:n,sseVersion:f,onViewAll:()=>t("projects")}),j.jsx(TX,{sseVersion:f,onViewAll:()=>t("events")})]}),j.jsx(oX,{sseVersion:f})]}),e==="sessions"&&j.jsx(fX,{timeRange:n,sseVersion:f}),e==="projects"&&j.jsx(dX,{timeRange:n,sseVersion:f}),e==="tools"&&j.jsx(hX,{timeRange:n,sseVersion:f}),e==="agents"&&j.jsx(OX,{sseVersion:f}),e==="models"&&j.jsx(vX,{timeRange:n,sseVersion:f}),e==="events"&&j.jsx(SX,{timeRange:n,sseVersion:f}),e==="costs"&&j.jsxs("div",{className:"flex flex-col gap-4",children:[l&&j.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Coste período"}),j.jsx("div",{className:"text-2xl font-mono font-bold text-accent-purple",children:Mt(l.cost)})]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Eficiencia"}),j.jsxs("div",{className:"text-2xl font-mono font-bold text-accent-green",children:[(l.efficiency*100).toFixed(1),"%"]})]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Tokens caché"}),j.jsx("div",{className:"text-2xl font-mono font-bold text-accent-teal",children:At(l.tokens.cache)})]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Ahorro caché est."}),j.jsx("div",{className:"text-2xl font-mono font-bold text-accent-yellow",children:Mt(AD(l.tokens.cache))})]})]}),j.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[j.jsx(cX,{timeRange:n,sseVersion:f}),j.jsx(sX,{timeRange:n,sseVersion:f})]})]})]})]})]})}JR.createRoot(document.getElementById("root")).render(j.jsx(H.StrictMode,{children:j.jsx(PX,{})}));
232
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mD(e,t){if(e){if(typeof e=="string")return Fb(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Fb(e,t)}}function UY(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function IY(e){if(Array.isArray(e))return Fb(e)}function Fb(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Q2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function ne(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Q2(Object(n),!0).forEach(function(r){be(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Q2(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function be(e,t,n){return t=gD(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gD(e){var t=HY(e,"string");return Po(t)=="symbol"?t:t+""}function HY(e,t){if(Po(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Po(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var GY={xAxis:["bottom","top"],yAxis:["left","right"]},YY={width:"100%",height:"100%"},bD={x:0,y:0};function Es(e){return e}var XY=function(t,n){return n==="horizontal"?t.x:n==="vertical"?t.y:n==="centric"?t.angle:t.radius},KY=function(t,n,r,o){var l=n.find(function(y){return y&&y.index===r});if(l){if(t==="horizontal")return{x:l.coordinate,y:o.y};if(t==="vertical")return{x:o.x,y:l.coordinate};if(t==="centric"){var c=l.coordinate,f=o.radius;return ne(ne(ne({},o),Bt(o.cx,o.cy,f,c)),{},{angle:c,radius:f})}var d=l.coordinate,h=o.angle;return ne(ne(ne({},o),Bt(o.cx,o.cy,d,h)),{},{angle:h,radius:d})}return bD},ud=function(t,n){var r=n.graphicalItems,o=n.dataStartIndex,l=n.dataEndIndex,c=(r??[]).reduce(function(f,d){var h=d.props.data;return h&&h.length?[].concat(Ro(f),Ro(h)):f},[]);return c.length>0?c:t&&t.length&&fe(o)&&fe(l)?t.slice(o,l+1):[]};function xD(e){return e==="number"?[0,"auto"]:void 0}var Zb=function(t,n,r,o){var l=t.graphicalItems,c=t.tooltipAxis,f=ud(n,t);return r<0||!l||!l.length||r>=f.length?null:l.reduce(function(d,h){var y,v=(y=h.props.data)!==null&&y!==void 0?y:n;v&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=r&&(v=v.slice(t.dataStartIndex,t.dataEndIndex+1));var g;if(c.dataKey&&!c.allowDuplicatedCategory){var b=v===void 0?f:v;g=Ms(b,c.dataKey,o)}else g=v&&v[r]||f[r];return g?[].concat(Ro(d),[mN(h,g)]):d},[])},J2=function(t,n,r,o){var l=o||{x:t.chartX,y:t.chartY},c=XY(l,r),f=t.orderedTooltipTicks,d=t.tooltipAxis,h=t.tooltipTicks,y=K5(c,f,h,d);if(y>=0&&h){var v=h[y]&&h[y].value,g=Zb(t,n,y,v),b=KY(r,f,y,l);return{activeTooltipIndex:y,activeLabel:v,activePayload:g,activeCoordinate:b}}return null},VY=function(t,n){var r=n.axes,o=n.graphicalItems,l=n.axisType,c=n.axisIdKey,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,y=t.layout,v=t.children,g=t.stackOffset,b=pN(y,l);return r.reduce(function(_,S){var x,T=S.type.defaultProps!==void 0?ne(ne({},S.type.defaultProps),S.props):S.props,w=T.type,M=T.dataKey,C=T.allowDataOverflow,A=T.allowDuplicatedCategory,E=T.scale,D=T.ticks,P=T.includeHidden,q=T[c];if(_[q])return _;var V=ud(t.data,{graphicalItems:o.filter(function(I){var re,se=c in I.props?I.props[c]:(re=I.type.defaultProps)===null||re===void 0?void 0:re[c];return se===q}),dataStartIndex:d,dataEndIndex:h}),U=V.length,k,Z,Q;xY(T.domain,C,w)&&(k=hb(T.domain,null,C),b&&(w==="number"||E!=="auto")&&(Q=tl(V,M,"category")));var W=xD(w);if(!k||k.length===0){var $,Y=($=T.domain)!==null&&$!==void 0?$:W;if(M){if(k=tl(V,M,w),w==="category"&&b){var ee=B$(k);A&&ee?(Z=k,k=vf(0,U)):A||(k=fj(Y,k,S).reduce(function(I,re){return I.indexOf(re)>=0?I:[].concat(Ro(I),[re])},[]))}else if(w==="category")A?k=k.filter(function(I){return I!==""&&!je(I)}):k=fj(Y,k,S).reduce(function(I,re){return I.indexOf(re)>=0||re===""||je(re)?I:[].concat(Ro(I),[re])},[]);else if(w==="number"){var oe=Q5(V,o.filter(function(I){var re,se,pe=c in I.props?I.props[c]:(re=I.type.defaultProps)===null||re===void 0?void 0:re[c],me="hide"in I.props?I.props.hide:(se=I.type.defaultProps)===null||se===void 0?void 0:se.hide;return pe===q&&(P||!me)}),M,l,y);oe&&(k=oe)}b&&(w==="number"||E!=="auto")&&(Q=tl(V,M,"category"))}else b?k=vf(0,U):f&&f[q]&&f[q].hasStack&&w==="number"?k=g==="expand"?[0,1]:yN(f[q].stackGroups,d,h):k=hN(V,o.filter(function(I){var re=c in I.props?I.props[c]:I.type.defaultProps[c],se="hide"in I.props?I.props.hide:I.type.defaultProps.hide;return re===q&&(P||!se)}),w,y,!0);if(w==="number")k=Kb(v,k,q,l,D),Y&&(k=hb(Y,k,C));else if(w==="category"&&Y){var le=Y,R=k.every(function(I){return le.indexOf(I)>=0});R&&(k=le)}}return ne(ne({},_),{},be({},q,ne(ne({},T),{},{axisType:l,domain:k,categoricalDomain:Q,duplicateDomain:Z,originalDomain:(x=T.domain)!==null&&x!==void 0?x:W,isCategorical:b,layout:y})))},{})},FY=function(t,n){var r=n.graphicalItems,o=n.Axis,l=n.axisType,c=n.axisIdKey,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,y=t.layout,v=t.children,g=ud(t.data,{graphicalItems:r,dataStartIndex:d,dataEndIndex:h}),b=g.length,_=pN(y,l),S=-1;return r.reduce(function(x,T){var w=T.type.defaultProps!==void 0?ne(ne({},T.type.defaultProps),T.props):T.props,M=w[c],C=xD("number");if(!x[M]){S++;var A;return _?A=vf(0,b):f&&f[M]&&f[M].hasStack?(A=yN(f[M].stackGroups,d,h),A=Kb(v,A,M,l)):(A=hb(C,hN(g,r.filter(function(E){var D,P,q=c in E.props?E.props[c]:(D=E.type.defaultProps)===null||D===void 0?void 0:D[c],V="hide"in E.props?E.props.hide:(P=E.type.defaultProps)===null||P===void 0?void 0:P.hide;return q===M&&!V}),"number",y),o.defaultProps.allowDataOverflow),A=Kb(v,A,M,l)),ne(ne({},x),{},be({},M,ne(ne({axisType:l},o.defaultProps),{},{hide:!0,orientation:Rn(GY,"".concat(l,".").concat(S%2),null),domain:A,originalDomain:C,isCategorical:_,layout:y})))}return x},{})},ZY=function(t,n){var r=n.axisType,o=r===void 0?"xAxis":r,l=n.AxisComp,c=n.graphicalItems,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,y=t.children,v="".concat(o,"Id"),g=$n(y,l),b={};return g&&g.length?b=VY(t,{axes:g,graphicalItems:c,axisType:o,axisIdKey:v,stackGroups:f,dataStartIndex:d,dataEndIndex:h}):c&&c.length&&(b=FY(t,{Axis:l,graphicalItems:c,axisType:o,axisIdKey:v,stackGroups:f,dataStartIndex:d,dataEndIndex:h})),b},WY=function(t){var n=ga(t),r=Cr(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:S0(r,function(o){return o.coordinate}),tooltipAxis:n,tooltipAxisBandSize:af(n,r)}},eM=function(t){var n=t.children,r=t.defaultShowTooltip,o=yn(n,_o),l=0,c=0;return t.data&&t.data.length!==0&&(c=t.data.length-1),o&&o.props&&(o.props.startIndex>=0&&(l=o.props.startIndex),o.props.endIndex>=0&&(c=o.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:l,dataEndIndex:c,activeTooltipIndex:-1,isTooltipActive:!!r}},QY=function(t){return!t||!t.length?!1:t.some(function(n){var r=Nr(n&&n.type);return r&&r.indexOf("Bar")>=0})},tM=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},JY=function(t,n){var r=t.props,o=t.graphicalItems,l=t.xAxisMap,c=l===void 0?{}:l,f=t.yAxisMap,d=f===void 0?{}:f,h=r.width,y=r.height,v=r.children,g=r.margin||{},b=yn(v,_o),_=yn(v,Pr),S=Object.keys(d).reduce(function(A,E){var D=d[E],P=D.orientation;return!D.mirror&&!D.hide?ne(ne({},A),{},be({},P,A[P]+D.width)):A},{left:g.left||0,right:g.right||0}),x=Object.keys(c).reduce(function(A,E){var D=c[E],P=D.orientation;return!D.mirror&&!D.hide?ne(ne({},A),{},be({},P,Rn(A,"".concat(P))+D.height)):A},{top:g.top||0,bottom:g.bottom||0}),T=ne(ne({},x),S),w=T.bottom;b&&(T.bottom+=b.props.height||_o.defaultProps.height),_&&n&&(T=Z5(T,o,r,n));var M=h-T.left-T.right,C=y-T.top-T.bottom;return ne(ne({brushBottom:w},T),{},{width:Math.max(M,0),height:Math.max(C,0)})},eX=function(t,n){if(n==="xAxis")return t[n].width;if(n==="yAxis")return t[n].height},ax=function(t){var n=t.chartName,r=t.GraphicalChild,o=t.defaultTooltipEventType,l=o===void 0?"axis":o,c=t.validateTooltipEventTypes,f=c===void 0?["axis"]:c,d=t.axisComponents,h=t.legendContent,y=t.formatAxisMap,v=t.defaultProps,g=function(T,w){var M=w.graphicalItems,C=w.stackGroups,A=w.offset,E=w.updateId,D=w.dataStartIndex,P=w.dataEndIndex,q=T.barSize,V=T.layout,U=T.barGap,k=T.barCategoryGap,Z=T.maxBarSize,Q=tM(V),W=Q.numericAxisName,$=Q.cateAxisName,Y=QY(M),ee=[];return M.forEach(function(oe,le){var R=ud(T.data,{graphicalItems:[oe],dataStartIndex:D,dataEndIndex:P}),I=oe.type.defaultProps!==void 0?ne(ne({},oe.type.defaultProps),oe.props):oe.props,re=I.dataKey,se=I.maxBarSize,pe=I["".concat(W,"Id")],me=I["".concat($,"Id")],Me={},Ue=d.reduce(function(Bn,lr){var Yo=w["".concat(lr.axisType,"Map")],Ut=I["".concat(lr.axisType,"Id")];Yo&&Yo[Ut]||lr.axisType==="zAxis"||oi();var Zl=Yo[Ut];return ne(ne({},Bn),{},be(be({},lr.axisType,Zl),"".concat(lr.axisType,"Ticks"),Cr(Zl)))},Me),ce=Ue[$],xe=Ue["".concat($,"Ticks")],Se=C&&C[pe]&&C[pe].hasStack&&sL(oe,C[pe].stackGroups),ue=Nr(oe.type).indexOf("Bar")>=0,tt=af(ce,xe),we=[],ut=Y&&V5({barSize:q,stackGroups:C,totalSize:eX(Ue,$)});if(ue){var lt,Lt,kn=je(se)?Z:se,Zn=(lt=(Lt=af(ce,xe,!0))!==null&&Lt!==void 0?Lt:kn)!==null&&lt!==void 0?lt:0;we=F5({barGap:U,barCategoryGap:k,bandSize:Zn!==tt?Zn:tt,sizeList:ut[me],maxBarSize:kn}),Zn!==tt&&(we=we.map(function(Bn){return ne(ne({},Bn),{},{position:ne(ne({},Bn.position),{},{offset:Bn.position.offset-Zn/2})})}))}var Gr=oe&&oe.type&&oe.type.getComposedData;Gr&&ee.push({props:ne(ne({},Gr(ne(ne({},Ue),{},{displayedData:R,props:T,dataKey:re,item:oe,bandSize:tt,barPosition:we,offset:A,stackedData:Se,layout:V,dataStartIndex:D,dataEndIndex:P}))),{},be(be(be({key:oe.key||"item-".concat(le)},W,Ue[W]),$,Ue[$]),"animationId",E)),childIndex:W$(oe,T.children),item:oe})}),ee},b=function(T,w){var M=T.props,C=T.dataStartIndex,A=T.dataEndIndex,E=T.updateId;if(!TA({props:M}))return null;var D=M.children,P=M.layout,q=M.stackOffset,V=M.data,U=M.reverseStackOrder,k=tM(P),Z=k.numericAxisName,Q=k.cateAxisName,W=$n(D,r),$=uL(V,W,"".concat(Z,"Id"),"".concat(Q,"Id"),q,U),Y=d.reduce(function(I,re){var se="".concat(re.axisType,"Map");return ne(ne({},I),{},be({},se,ZY(M,ne(ne({},re),{},{graphicalItems:W,stackGroups:re.axisType===Z&&$,dataStartIndex:C,dataEndIndex:A}))))},{}),ee=JY(ne(ne({},Y),{},{props:M,graphicalItems:W}),w==null?void 0:w.legendBBox);Object.keys(Y).forEach(function(I){Y[I]=y(M,Y[I],ee,I.replace("Map",""),n)});var oe=Y["".concat(Q,"Map")],le=WY(oe),R=g(M,ne(ne({},Y),{},{dataStartIndex:C,dataEndIndex:A,updateId:E,graphicalItems:W,stackGroups:$,offset:ee}));return ne(ne({formattedGraphicalItems:R,graphicalItems:W,offset:ee,stackGroups:$},le),Y)},_=(function(x){function T(w){var M,C,A;return PY(this,T),A=qY(this,T,[w]),be(A,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),be(A,"accessibilityManager",new bY),be(A,"handleLegendBBoxUpdate",function(E){if(E){var D=A.state,P=D.dataStartIndex,q=D.dataEndIndex,V=D.updateId;A.setState(ne({legendBBox:E},b({props:A.props,dataStartIndex:P,dataEndIndex:q,updateId:V},ne(ne({},A.state),{},{legendBBox:E}))))}}),be(A,"handleReceiveSyncEvent",function(E,D,P){if(A.props.syncId===E){if(P===A.eventEmitterSymbol&&typeof A.props.syncMethod!="function")return;A.applySyncEvent(D)}}),be(A,"handleBrushChange",function(E){var D=E.startIndex,P=E.endIndex;if(D!==A.state.dataStartIndex||P!==A.state.dataEndIndex){var q=A.state.updateId;A.setState(function(){return ne({dataStartIndex:D,dataEndIndex:P},b({props:A.props,dataStartIndex:D,dataEndIndex:P,updateId:q},A.state))}),A.triggerSyncEvent({dataStartIndex:D,dataEndIndex:P})}}),be(A,"handleMouseEnter",function(E){var D=A.getMouseInfo(E);if(D){var P=ne(ne({},D),{},{isTooltipActive:!0});A.setState(P),A.triggerSyncEvent(P);var q=A.props.onMouseEnter;Ae(q)&&q(P,E)}}),be(A,"triggeredAfterMouseMove",function(E){var D=A.getMouseInfo(E),P=D?ne(ne({},D),{},{isTooltipActive:!0}):{isTooltipActive:!1};A.setState(P),A.triggerSyncEvent(P);var q=A.props.onMouseMove;Ae(q)&&q(P,E)}),be(A,"handleItemMouseEnter",function(E){A.setState(function(){return{isTooltipActive:!0,activeItem:E,activePayload:E.tooltipPayload,activeCoordinate:E.tooltipPosition||{x:E.cx,y:E.cy}}})}),be(A,"handleItemMouseLeave",function(){A.setState(function(){return{isTooltipActive:!1}})}),be(A,"handleMouseMove",function(E){E.persist(),A.throttleTriggeredAfterMouseMove(E)}),be(A,"handleMouseLeave",function(E){A.throttleTriggeredAfterMouseMove.cancel();var D={isTooltipActive:!1};A.setState(D),A.triggerSyncEvent(D);var P=A.props.onMouseLeave;Ae(P)&&P(D,E)}),be(A,"handleOuterEvent",function(E){var D=Z$(E),P=Rn(A.props,"".concat(D));if(D&&Ae(P)){var q,V;/.*touch.*/i.test(D)?V=A.getMouseInfo(E.changedTouches[0]):V=A.getMouseInfo(E),P((q=V)!==null&&q!==void 0?q:{},E)}}),be(A,"handleClick",function(E){var D=A.getMouseInfo(E);if(D){var P=ne(ne({},D),{},{isTooltipActive:!0});A.setState(P),A.triggerSyncEvent(P);var q=A.props.onClick;Ae(q)&&q(P,E)}}),be(A,"handleMouseDown",function(E){var D=A.props.onMouseDown;if(Ae(D)){var P=A.getMouseInfo(E);D(P,E)}}),be(A,"handleMouseUp",function(E){var D=A.props.onMouseUp;if(Ae(D)){var P=A.getMouseInfo(E);D(P,E)}}),be(A,"handleTouchMove",function(E){E.changedTouches!=null&&E.changedTouches.length>0&&A.throttleTriggeredAfterMouseMove(E.changedTouches[0])}),be(A,"handleTouchStart",function(E){E.changedTouches!=null&&E.changedTouches.length>0&&A.handleMouseDown(E.changedTouches[0])}),be(A,"handleTouchEnd",function(E){E.changedTouches!=null&&E.changedTouches.length>0&&A.handleMouseUp(E.changedTouches[0])}),be(A,"handleDoubleClick",function(E){var D=A.props.onDoubleClick;if(Ae(D)){var P=A.getMouseInfo(E);D(P,E)}}),be(A,"handleContextMenu",function(E){var D=A.props.onContextMenu;if(Ae(D)){var P=A.getMouseInfo(E);D(P,E)}}),be(A,"triggerSyncEvent",function(E){A.props.syncId!==void 0&&Tg.emit(Eg,A.props.syncId,E,A.eventEmitterSymbol)}),be(A,"applySyncEvent",function(E){var D=A.props,P=D.layout,q=D.syncMethod,V=A.state.updateId,U=E.dataStartIndex,k=E.dataEndIndex;if(E.dataStartIndex!==void 0||E.dataEndIndex!==void 0)A.setState(ne({dataStartIndex:U,dataEndIndex:k},b({props:A.props,dataStartIndex:U,dataEndIndex:k,updateId:V},A.state)));else if(E.activeTooltipIndex!==void 0){var Z=E.chartX,Q=E.chartY,W=E.activeTooltipIndex,$=A.state,Y=$.offset,ee=$.tooltipTicks;if(!Y)return;if(typeof q=="function")W=q(ee,E);else if(q==="value"){W=-1;for(var oe=0;oe<ee.length;oe++)if(ee[oe].value===E.activeLabel){W=oe;break}}var le=ne(ne({},Y),{},{x:Y.left,y:Y.top}),R=Math.min(Z,le.x+le.width),I=Math.min(Q,le.y+le.height),re=ee[W]&&ee[W].value,se=Zb(A.state,A.props.data,W),pe=ee[W]?{x:P==="horizontal"?ee[W].coordinate:R,y:P==="horizontal"?I:ee[W].coordinate}:bD;A.setState(ne(ne({},E),{},{activeLabel:re,activeCoordinate:pe,activePayload:se,activeTooltipIndex:W}))}else A.setState(E)}),be(A,"renderCursor",function(E){var D,P=A.state,q=P.isTooltipActive,V=P.activeCoordinate,U=P.activePayload,k=P.offset,Z=P.activeTooltipIndex,Q=P.tooltipAxisBandSize,W=A.getTooltipEventType(),$=(D=E.props.active)!==null&&D!==void 0?D:q,Y=A.props.layout,ee=E.key||"_recharts-cursor";return B.createElement(TY,{key:ee,activeCoordinate:V,activePayload:U,activeTooltipIndex:Z,chartName:n,element:E,isActive:$,layout:Y,offset:k,tooltipAxisBandSize:Q,tooltipEventType:W})}),be(A,"renderPolarAxis",function(E,D,P){var q=Rn(E,"type.axisType"),V=Rn(A.state,"".concat(q,"Map")),U=E.type.defaultProps,k=U!==void 0?ne(ne({},U),E.props):E.props,Z=V&&V[k["".concat(q,"Id")]];return H.cloneElement(E,ne(ne({},Z),{},{className:qe(q,Z.className),key:E.key||"".concat(D,"-").concat(P),ticks:Cr(Z,!0)}))}),be(A,"renderPolarGrid",function(E){var D=E.props,P=D.radialLines,q=D.polarAngles,V=D.polarRadius,U=A.state,k=U.radiusAxisMap,Z=U.angleAxisMap,Q=ga(k),W=ga(Z),$=W.cx,Y=W.cy,ee=W.innerRadius,oe=W.outerRadius;return H.cloneElement(E,{polarAngles:Array.isArray(q)?q:Cr(W,!0).map(function(le){return le.coordinate}),polarRadius:Array.isArray(V)?V:Cr(Q,!0).map(function(le){return le.coordinate}),cx:$,cy:Y,innerRadius:ee,outerRadius:oe,key:E.key||"polar-grid",radialLines:P})}),be(A,"renderLegend",function(){var E=A.state.formattedGraphicalItems,D=A.props,P=D.children,q=D.width,V=D.height,U=A.props.margin||{},k=q-(U.left||0)-(U.right||0),Z=fN({children:P,formattedGraphicalItems:E,legendWidth:k,legendContent:h});if(!Z)return null;var Q=Z.item,W=W2(Z,EY);return H.cloneElement(Q,ne(ne({},W),{},{chartWidth:q,chartHeight:V,margin:U,onBBoxUpdate:A.handleLegendBBoxUpdate}))}),be(A,"renderTooltip",function(){var E,D=A.props,P=D.children,q=D.accessibilityLayer,V=yn(P,Dn);if(!V)return null;var U=A.state,k=U.isTooltipActive,Z=U.activeCoordinate,Q=U.activePayload,W=U.activeLabel,$=U.offset,Y=(E=V.props.active)!==null&&E!==void 0?E:k;return H.cloneElement(V,{viewBox:ne(ne({},$),{},{x:$.left,y:$.top}),active:Y,label:W,payload:Y?Q:[],coordinate:Z,accessibilityLayer:q})}),be(A,"renderBrush",function(E){var D=A.props,P=D.margin,q=D.data,V=A.state,U=V.offset,k=V.dataStartIndex,Z=V.dataEndIndex,Q=V.updateId;return H.cloneElement(E,{key:E.key||"_recharts-brush",onChange:Os(A.handleBrushChange,E.props.onChange),data:q,x:fe(E.props.x)?E.props.x:U.left,y:fe(E.props.y)?E.props.y:U.top+U.height+U.brushBottom-(P.bottom||0),width:fe(E.props.width)?E.props.width:U.width,startIndex:k,endIndex:Z,updateId:"brush-".concat(Q)})}),be(A,"renderReferenceElement",function(E,D,P){if(!E)return null;var q=A,V=q.clipPathId,U=A.state,k=U.xAxisMap,Z=U.yAxisMap,Q=U.offset,W=E.type.defaultProps||{},$=E.props,Y=$.xAxisId,ee=Y===void 0?W.xAxisId:Y,oe=$.yAxisId,le=oe===void 0?W.yAxisId:oe;return H.cloneElement(E,{key:E.key||"".concat(D,"-").concat(P),xAxis:k[ee],yAxis:Z[le],viewBox:{x:Q.left,y:Q.top,width:Q.width,height:Q.height},clipPathId:V})}),be(A,"renderActivePoints",function(E){var D=E.item,P=E.activePoint,q=E.basePoint,V=E.childIndex,U=E.isRange,k=[],Z=D.props.key,Q=D.item.type.defaultProps!==void 0?ne(ne({},D.item.type.defaultProps),D.item.props):D.item.props,W=Q.activeDot,$=Q.dataKey,Y=ne(ne({index:V,dataKey:$,cx:P.x,cy:P.y,r:4,fill:K0(D.item),strokeWidth:2,stroke:"#fff",payload:P.payload,value:P.value},Ee(W,!1)),Cs(W));return k.push(T.renderActiveDot(W,Y,"".concat(Z,"-activePoint-").concat(V))),q?k.push(T.renderActiveDot(W,ne(ne({},Y),{},{cx:q.x,cy:q.y}),"".concat(Z,"-basePoint-").concat(V))):U&&k.push(null),k}),be(A,"renderGraphicChild",function(E,D,P){var q=A.filterFormatItem(E,D,P);if(!q)return null;var V=A.getTooltipEventType(),U=A.state,k=U.isTooltipActive,Z=U.tooltipAxis,Q=U.activeTooltipIndex,W=U.activeLabel,$=A.props.children,Y=yn($,Dn),ee=q.props,oe=ee.points,le=ee.isRange,R=ee.baseLine,I=q.item.type.defaultProps!==void 0?ne(ne({},q.item.type.defaultProps),q.item.props):q.item.props,re=I.activeDot,se=I.hide,pe=I.activeBar,me=I.activeShape,Me=!!(!se&&k&&Y&&(re||pe||me)),Ue={};V!=="axis"&&Y&&Y.props.trigger==="click"?Ue={onClick:Os(A.handleItemMouseEnter,E.props.onClick)}:V!=="axis"&&(Ue={onMouseLeave:Os(A.handleItemMouseLeave,E.props.onMouseLeave),onMouseEnter:Os(A.handleItemMouseEnter,E.props.onMouseEnter)});var ce=H.cloneElement(E,ne(ne({},q.props),Ue));function xe(lr){return typeof Z.dataKey=="function"?Z.dataKey(lr.payload):null}if(Me)if(Q>=0){var Se,ue;if(Z.dataKey&&!Z.allowDuplicatedCategory){var tt=typeof Z.dataKey=="function"?xe:"payload.".concat(Z.dataKey.toString());Se=Ms(oe,tt,W),ue=le&&R&&Ms(R,tt,W)}else Se=oe==null?void 0:oe[Q],ue=le&&R&&R[Q];if(me||pe){var we=E.props.activeIndex!==void 0?E.props.activeIndex:Q;return[H.cloneElement(E,ne(ne(ne({},q.props),Ue),{},{activeIndex:we})),null,null]}if(!je(Se))return[ce].concat(Ro(A.renderActivePoints({item:q,activePoint:Se,basePoint:ue,childIndex:Q,isRange:le})))}else{var ut,lt=(ut=A.getItemByXY(A.state.activeCoordinate))!==null&&ut!==void 0?ut:{graphicalItem:ce},Lt=lt.graphicalItem,kn=Lt.item,Zn=kn===void 0?E:kn,Gr=Lt.childIndex,Bn=ne(ne(ne({},q.props),Ue),{},{activeIndex:Gr});return[H.cloneElement(Zn,Bn),null,null]}return le?[ce,null,null]:[ce,null]}),be(A,"renderCustomized",function(E,D,P){return H.cloneElement(E,ne(ne({key:"recharts-customized-".concat(P)},A.props),A.state))}),be(A,"renderMap",{CartesianGrid:{handler:Es,once:!0},ReferenceArea:{handler:A.renderReferenceElement},ReferenceLine:{handler:Es},ReferenceDot:{handler:A.renderReferenceElement},XAxis:{handler:Es},YAxis:{handler:Es},Brush:{handler:A.renderBrush,once:!0},Bar:{handler:A.renderGraphicChild},Line:{handler:A.renderGraphicChild},Area:{handler:A.renderGraphicChild},Radar:{handler:A.renderGraphicChild},RadialBar:{handler:A.renderGraphicChild},Scatter:{handler:A.renderGraphicChild},Pie:{handler:A.renderGraphicChild},Funnel:{handler:A.renderGraphicChild},Tooltip:{handler:A.renderCursor,once:!0},PolarGrid:{handler:A.renderPolarGrid,once:!0},PolarAngleAxis:{handler:A.renderPolarAxis},PolarRadiusAxis:{handler:A.renderPolarAxis},Customized:{handler:A.renderCustomized}}),A.clipPathId="".concat((M=w.id)!==null&&M!==void 0?M:ko("recharts"),"-clip"),A.throttleTriggeredAfterMouseMove=fC(A.triggeredAfterMouseMove,(C=w.throttleDelay)!==null&&C!==void 0?C:1e3/60),A.state={},A}return BY(T,x),$Y(T,[{key:"componentDidMount",value:function(){var M,C;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(M=this.props.margin.left)!==null&&M!==void 0?M:0,top:(C=this.props.margin.top)!==null&&C!==void 0?C:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var M=this.props,C=M.children,A=M.data,E=M.height,D=M.layout,P=yn(C,Dn);if(P){var q=P.props.defaultIndex;if(!(typeof q!="number"||q<0||q>this.state.tooltipTicks.length-1)){var V=this.state.tooltipTicks[q]&&this.state.tooltipTicks[q].value,U=Zb(this.state,A,q,V),k=this.state.tooltipTicks[q].coordinate,Z=(this.state.offset.top+E)/2,Q=D==="horizontal",W=Q?{x:k,y:Z}:{y:k,x:Z},$=this.state.formattedGraphicalItems.find(function(ee){var oe=ee.item;return oe.type.name==="Scatter"});$&&(W=ne(ne({},W),$.props.points[q].tooltipPosition),U=$.props.points[q].tooltipPayload);var Y={activeTooltipIndex:q,isTooltipActive:!0,activeLabel:V,activePayload:U,activeCoordinate:W};this.setState(Y),this.renderCursor(P),this.accessibilityManager.setIndex(q)}}}},{key:"getSnapshotBeforeUpdate",value:function(M,C){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==C.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==M.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==M.margin){var A,E;this.accessibilityManager.setDetails({offset:{left:(A=this.props.margin.left)!==null&&A!==void 0?A:0,top:(E=this.props.margin.top)!==null&&E!==void 0?E:0}})}return null}},{key:"componentDidUpdate",value:function(M){$g([yn(M.children,Dn)],[yn(this.props.children,Dn)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var M=yn(this.props.children,Dn);if(M&&typeof M.props.shared=="boolean"){var C=M.props.shared?"axis":"item";return f.indexOf(C)>=0?C:l}return l}},{key:"getMouseInfo",value:function(M){if(!this.container)return null;var C=this.container,A=C.getBoundingClientRect(),E=z6(A),D={chartX:Math.round(M.pageX-E.left),chartY:Math.round(M.pageY-E.top)},P=A.width/C.offsetWidth||1,q=this.inRange(D.chartX,D.chartY,P);if(!q)return null;var V=this.state,U=V.xAxisMap,k=V.yAxisMap,Z=this.getTooltipEventType(),Q=J2(this.state,this.props.data,this.props.layout,q);if(Z!=="axis"&&U&&k){var W=ga(U).scale,$=ga(k).scale,Y=W&&W.invert?W.invert(D.chartX):null,ee=$&&$.invert?$.invert(D.chartY):null;return ne(ne({},D),{},{xValue:Y,yValue:ee},Q)}return Q?ne(ne({},D),Q):null}},{key:"inRange",value:function(M,C){var A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,E=this.props.layout,D=M/A,P=C/A;if(E==="horizontal"||E==="vertical"){var q=this.state.offset,V=D>=q.left&&D<=q.left+q.width&&P>=q.top&&P<=q.top+q.height;return V?{x:D,y:P}:null}var U=this.state,k=U.angleAxisMap,Z=U.radiusAxisMap;if(k&&Z){var Q=ga(k);return pj({x:D,y:P},Q)}return null}},{key:"parseEventsOfWrapper",value:function(){var M=this.props.children,C=this.getTooltipEventType(),A=yn(M,Dn),E={};A&&C==="axis"&&(A.props.trigger==="click"?E={onClick:this.handleClick}:E={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var D=Cs(this.props,this.handleOuterEvent);return ne(ne({},D),E)}},{key:"addListener",value:function(){Tg.on(Eg,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Tg.removeListener(Eg,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(M,C,A){for(var E=this.state.formattedGraphicalItems,D=0,P=E.length;D<P;D++){var q=E[D];if(q.item===M||q.props.key===M.key||C===Nr(q.item.type)&&A===q.childIndex)return q}return null}},{key:"renderClipPath",value:function(){var M=this.clipPathId,C=this.state.offset,A=C.left,E=C.top,D=C.height,P=C.width;return B.createElement("defs",null,B.createElement("clipPath",{id:M},B.createElement("rect",{x:A,y:E,height:D,width:P})))}},{key:"getXScales",value:function(){var M=this.state.xAxisMap;return M?Object.entries(M).reduce(function(C,A){var E=Z2(A,2),D=E[0],P=E[1];return ne(ne({},C),{},be({},D,P.scale))},{}):null}},{key:"getYScales",value:function(){var M=this.state.yAxisMap;return M?Object.entries(M).reduce(function(C,A){var E=Z2(A,2),D=E[0],P=E[1];return ne(ne({},C),{},be({},D,P.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(M){var C;return(C=this.state.xAxisMap)===null||C===void 0||(C=C[M])===null||C===void 0?void 0:C.scale}},{key:"getYScaleByAxisId",value:function(M){var C;return(C=this.state.yAxisMap)===null||C===void 0||(C=C[M])===null||C===void 0?void 0:C.scale}},{key:"getItemByXY",value:function(M){var C=this.state,A=C.formattedGraphicalItems,E=C.activeItem;if(A&&A.length)for(var D=0,P=A.length;D<P;D++){var q=A[D],V=q.props,U=q.item,k=U.type.defaultProps!==void 0?ne(ne({},U.type.defaultProps),U.props):U.props,Z=Nr(U.type);if(Z==="Bar"){var Q=(V.data||[]).find(function(ee){return a9(M,ee)});if(Q)return{graphicalItem:q,payload:Q}}else if(Z==="RadialBar"){var W=(V.data||[]).find(function(ee){return pj(M,ee)});if(W)return{graphicalItem:q,payload:W}}else if(Jf(q,E)||ed(q,E)||Pl(q,E)){var $=V9({graphicalItem:q,activeTooltipItem:E,itemData:k.data}),Y=k.activeIndex===void 0?$:k.activeIndex;return{graphicalItem:ne(ne({},q),{},{childIndex:Y}),payload:Pl(q,E)?k.data[$]:q.props.data[$]}}}return null}},{key:"render",value:function(){var M=this;if(!TA(this))return null;var C=this.props,A=C.children,E=C.className,D=C.width,P=C.height,q=C.style,V=C.compact,U=C.title,k=C.desc,Z=W2(C,jY),Q=Ee(Z,!1);if(V)return B.createElement(M2,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},B.createElement(zg,io({},Q,{width:D,height:P,title:U,desc:k}),this.renderClipPath(),jA(A,this.renderMap)));if(this.props.accessibilityLayer){var W,$;Q.tabIndex=(W=this.props.tabIndex)!==null&&W!==void 0?W:0,Q.role=($=this.props.role)!==null&&$!==void 0?$:"application",Q.onKeyDown=function(ee){M.accessibilityManager.keyboardEvent(ee)},Q.onFocus=function(){M.accessibilityManager.focus()}}var Y=this.parseEventsOfWrapper();return B.createElement(M2,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},B.createElement("div",io({className:qe("recharts-wrapper",E),style:ne({position:"relative",cursor:"default",width:D,height:P},q)},Y,{ref:function(oe){M.container=oe}}),B.createElement(zg,io({},Q,{width:D,height:P,title:U,desc:k,style:YY}),this.renderClipPath(),jA(A,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])})(H.Component);be(_,"displayName",n),be(_,"defaultProps",ne({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},v)),be(_,"getDerivedStateFromProps",function(x,T){var w=x.dataKey,M=x.data,C=x.children,A=x.width,E=x.height,D=x.layout,P=x.stackOffset,q=x.margin,V=T.dataStartIndex,U=T.dataEndIndex;if(T.updateId===void 0){var k=eM(x);return ne(ne(ne({},k),{},{updateId:0},b(ne(ne({props:x},k),{},{updateId:0}),T)),{},{prevDataKey:w,prevData:M,prevWidth:A,prevHeight:E,prevLayout:D,prevStackOffset:P,prevMargin:q,prevChildren:C})}if(w!==T.prevDataKey||M!==T.prevData||A!==T.prevWidth||E!==T.prevHeight||D!==T.prevLayout||P!==T.prevStackOffset||!oo(q,T.prevMargin)){var Z=eM(x),Q={chartX:T.chartX,chartY:T.chartY,isTooltipActive:T.isTooltipActive},W=ne(ne({},J2(T,M,D)),{},{updateId:T.updateId+1}),$=ne(ne(ne({},Z),Q),W);return ne(ne(ne({},$),b(ne({props:x},$),T)),{},{prevDataKey:w,prevData:M,prevWidth:A,prevHeight:E,prevLayout:D,prevStackOffset:P,prevMargin:q,prevChildren:C})}if(!$g(C,T.prevChildren)){var Y,ee,oe,le,R=yn(C,_o),I=R&&(Y=(ee=R.props)===null||ee===void 0?void 0:ee.startIndex)!==null&&Y!==void 0?Y:V,re=R&&(oe=(le=R.props)===null||le===void 0?void 0:le.endIndex)!==null&&oe!==void 0?oe:U,se=I!==V||re!==U,pe=!je(M),me=pe&&!se?T.updateId:T.updateId+1;return ne(ne({updateId:me},b(ne(ne({props:x},T),{},{updateId:me,dataStartIndex:I,dataEndIndex:re}),T)),{},{prevChildren:C,dataStartIndex:I,dataEndIndex:re})}return null}),be(_,"renderActiveDot",function(x,T,w){var M;return H.isValidElement(x)?M=H.cloneElement(x,T):Ae(x)?M=x(T):M=B.createElement(Qf,T),B.createElement(et,{className:"recharts-active-dot",key:w},M)});var S=H.forwardRef(function(T,w){return B.createElement(_,io({},T,{ref:w}))});return S.displayName=_.displayName,S},tX=ax({chartName:"LineChart",GraphicalChild:Fl,axisComponents:[{axisType:"xAxis",AxisComp:Ir},{axisType:"yAxis",AxisComp:Hr}],formatAxisMap:F0}),nX=ax({chartName:"BarChart",GraphicalChild:hi,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:Ir},{axisType:"yAxis",AxisComp:Hr}],formatAxisMap:F0}),SD=ax({chartName:"AreaChart",GraphicalChild:Vn,axisComponents:[{axisType:"xAxis",AxisComp:Ir},{axisType:"yAxis",AxisComp:Hr}],formatAxisMap:F0});const Oa="#2a3947",Ll="#8fa3b0",_a={fill:Ll,fontSize:11},ix={background:"#141d26",border:"1px solid #2a3947",borderRadius:"6px"},al="#00a8e8",Mg="#6bcb77",nM=["#c592f0","#00a8e8","#6bcb77","#f5d36b","#ff5e5e","#74cff7","#ff8266","#84cc16","#ec4899","#8b5cf6"];function rX(e){return new Date(e).toLocaleString("es",{hour:"2-digit",minute:"2-digit",day:"numeric",month:"short"})}function aX({timeRange:e,sseVersion:t,compact:n=!1}){const[r,o]=H.useState([]),[l,c]=H.useState([]);H.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([Ce.timeseries("claude_code.tokens.input",e,v),Ce.timeseries("claude_code.tokens.output",e,v)]).then(([g,b])=>{o(g),c(b)}).catch(()=>{})},[e,t]);const f=new Set([...r.map(v=>v.timestamp),...l.map(v=>v.timestamp)]),d=new Map(r.map(v=>[v.timestamp,v.value])),h=new Map(l.map(v=>[v.timestamp,v.value])),y=Array.from(f).sort().map(v=>({ts:v,label:rX(v),input:d.get(v)??0,output:h.get(v)??0}));return y.length===0?j.jsx("div",{className:`bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center ${n?"h-full min-h-[180px]":"h-48"}`,children:j.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de tokens"})}):j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Tokens por período"}),j.jsx(If,{width:"100%",height:n?140:220,children:j.jsxs(SD,{data:y,margin:{top:4,right:8,left:0,bottom:0},children:[j.jsxs("defs",{children:[j.jsxs("linearGradient",{id:"colorInput",x1:"0",y1:"0",x2:"0",y2:"1",children:[j.jsx("stop",{offset:"5%",stopColor:al,stopOpacity:.3}),j.jsx("stop",{offset:"95%",stopColor:al,stopOpacity:0})]}),j.jsxs("linearGradient",{id:"colorOutput",x1:"0",y1:"0",x2:"0",y2:"1",children:[j.jsx("stop",{offset:"5%",stopColor:Mg,stopOpacity:.3}),j.jsx("stop",{offset:"95%",stopColor:Mg,stopOpacity:0})]})]}),j.jsx(Vl,{strokeDasharray:"3 3",stroke:Oa}),j.jsx(Ir,{dataKey:"label",tick:_a,tickLine:!1,axisLine:{stroke:Oa}}),j.jsx(Hr,{tick:_a,tickLine:!1,axisLine:!1,tickFormatter:v=>v>=1e3?`${(v/1e3).toFixed(0)}K`:String(v)}),j.jsx(Dn,{contentStyle:ix,labelStyle:{color:Ll,fontSize:12},itemStyle:{fontSize:12}}),!n&&j.jsx(Pr,{wrapperStyle:{fontSize:12,color:Ll}}),j.jsx(Vn,{type:"monotone",dataKey:"input",name:"Input",stroke:al,fill:"url(#colorInput)",strokeWidth:2}),j.jsx(Vn,{type:"monotone",dataKey:"output",name:"Output",stroke:Mg,fill:"url(#colorOutput)",strokeWidth:2})]})})]})}const js=864e5,iX=["#11202c","#16384c","#1b5675","#0e7fb0","#00a8e8"],no=11,Wb=3,Cg=no+Wb,rM=28;function aM(e){return Math.floor(e/js)}function oX({sseVersion:e}){const[t,n]=H.useState(new Map),[r,o]=H.useState(null),l=H.useRef(null);H.useEffect(()=>{const w=l.current;w&&(w.scrollLeft=w.scrollWidth)},[t]),H.useEffect(()=>{Promise.all([Ce.timeseries("claude_code.tokens.input","now-365d","1d"),Ce.timeseries("claude_code.tokens.output","now-365d","1d"),Ce.timeseries("claude_code.cost","now-365d","1d")]).then(([w,M,C])=>{const A=new Map,E=(D,P)=>{for(const q of D){const V=aM(q.timestamp),U=A.get(V)??{tokens:0,cost:0};U[P]+=q.value,A.set(V,U)}};E(w,"tokens"),E(M,"tokens"),E(C,"cost"),n(A)}).catch(()=>{})},[e]);const c=[...t.values()];if(!c.some(w=>w.tokens>0))return j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-32",children:j.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de actividad"})});const f=Math.max(...c.map(w=>w.tokens),1),d=aM(Date.now()),h=d-364,y=(new Date(h*js).getUTCDay()+6)%7,v=h-y,g=[];for(let w=v;w<=d;w++)g.push(w);const b=[];let _=-1;for(let w=0;v+w*7<=d;w++){const M=new Date((v+w*7)*js),C=M.getUTCMonth();C!==_&&(b.push({col:w,label:M.toLocaleDateString("es",{month:"short",timeZone:"UTC"})}),_=C)}function S(w){return w<=0?0:Math.min(4,Math.max(1,Math.ceil(w/f*4)))}const x=110;function T(w,M){const C=w.currentTarget.getBoundingClientRect(),A=t.get(M),E=C.left+no/2,D=Math.min(Math.max(E,x+8),window.innerWidth-x-8),P=C.top<70;o({x:D,y:P?C.bottom+8:C.top-8,below:P,label:new Date(M*js).toLocaleDateString("es",{weekday:"long",day:"numeric",month:"short",year:"numeric",timeZone:"UTC"}),tokens:(A==null?void 0:A.tokens)??0,cost:(A==null?void 0:A.cost)??0})}return j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Actividad — últimos 12 meses"}),j.jsx("div",{ref:l,className:"overflow-x-auto pb-1",onScroll:()=>o(null),children:j.jsxs("div",{className:"relative inline-block","data-heatmap":!0,onMouseLeave:()=>o(null),children:[j.jsx("div",{className:"relative h-4 mb-1",style:{marginLeft:rM},children:b.map(w=>j.jsx("span",{className:"absolute text-[10px] text-text-secondary capitalize",style:{left:w.col*Cg},children:w.label},`${w.col}-${w.label}`))}),j.jsxs("div",{className:"flex",children:[j.jsx("div",{className:"relative shrink-0",style:{width:rM,height:7*Cg-Wb},children:[["Lun",0],["Mié",2],["Vie",4]].map(([w,M])=>j.jsx("span",{className:"absolute text-[10px] text-text-secondary leading-none",style:{top:M*Cg+1},children:w},w))}),j.jsx("div",{className:"grid grid-flow-col",style:{gridTemplateRows:`repeat(7, ${no}px)`,gridAutoColumns:`${no}px`,gap:Wb},children:g.map(w=>{var M;return j.jsx("div",{className:"rounded-[2px]",style:{width:no,height:no,background:iX[S(((M=t.get(w))==null?void 0:M.tokens)??0)]},onMouseEnter:C=>T(C,w)},w)})})]}),r&&j.jsxs("div",{className:"fixed z-50 pointer-events-none px-3 py-2 rounded-md text-xs whitespace-nowrap",style:{left:r.x,top:r.y,transform:r.below?"translate(-50%, 0)":"translate(-50%, -100%)",background:"#141d26",border:"1px solid #2a3947"},children:[j.jsx("div",{className:"text-text-primary font-medium capitalize",children:r.label}),j.jsxs("div",{className:"text-text-secondary mt-0.5",children:[At(r.tokens)," tokens · ",Mt(r.cost)]})]})]})})]})}function uX(e){return new Date(e).toLocaleDateString("es",{day:"numeric",month:"short"})}function lX({timeRange:e,sseVersion:t,compact:n=!1}){const[r,o]=H.useState([]);H.useEffect(()=>{Ce.timeseriesByProject("claude_code.cost",e,"1d").then(o).catch(()=>{})},[e,t]);const l=H.useMemo(()=>{const f=new Set;for(const d of r)Object.keys(d.projects).forEach(h=>f.add(h));return Array.from(f).sort()},[r]),c=r.map(f=>({label:uX(f.timestamp),...Object.fromEntries(l.map(d=>[d,Number((f.projects[d]??0).toFixed(4))]))}));return c.length===0?j.jsx("div",{className:`bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center ${n?"h-full min-h-[180px]":"h-48"}`,children:j.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de coste"})}):j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Coste por día ($)"}),j.jsx(If,{width:"100%",height:n?140:220,children:j.jsxs(nX,{data:c,margin:{top:4,right:8,left:0,bottom:0},children:[j.jsx(Vl,{strokeDasharray:"3 3",stroke:Oa,vertical:!1}),j.jsx(Ir,{dataKey:"label",tick:_a,tickLine:!1,axisLine:{stroke:Oa}}),j.jsx(Hr,{tick:_a,tickLine:!1,axisLine:!1,tickFormatter:f=>`$${f.toFixed(2)}`}),!n&&j.jsx(Pr,{wrapperStyle:{fontSize:11,color:Ll,paddingTop:8},iconType:"square",iconSize:8}),l.map((f,d)=>j.jsx(hi,{dataKey:f,stackId:"cost",fill:nM[d%nM.length],radius:d===l.length-1?[3,3,0,0]:[0,0,0,0]},f))]})})]})}function cX({timeRange:e,sseVersion:t}){const[n,r]=H.useState([]),[o,l]=H.useState([]);H.useEffect(()=>{const y=e==="now-24h"?"1h":"1d";Promise.all([Ce.timeseries("claude_code.tokens.cache.read",e,y),Ce.timeseries("claude_code.tokens.cache.creation",e,y)]).then(([v,g])=>{r(v),l(g)}).catch(()=>{})},[e,t]);const c=new Set([...n.map(y=>y.timestamp),...o.map(y=>y.timestamp)]),f=new Map(n.map(y=>[y.timestamp,y.value])),d=new Map(o.map(y=>[y.timestamp,y.value])),h=Array.from(c).sort().map(y=>({label:new Date(y).toLocaleString("es",{hour:"2-digit",day:"numeric",month:"short"}),read:f.get(y)??0,create:d.get(y)??0}));return h.length===0?j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-48",children:j.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de caché"})}):j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Tokens de caché"}),j.jsx(If,{width:"100%",height:220,children:j.jsxs(SD,{data:h,margin:{top:4,right:8,left:0,bottom:0},children:[j.jsx(Vl,{strokeDasharray:"3 3",stroke:Oa}),j.jsx(Ir,{dataKey:"label",tick:_a,tickLine:!1,axisLine:{stroke:Oa}}),j.jsx(Hr,{tick:_a,tickLine:!1,axisLine:!1,tickFormatter:y=>y>=1e3?`${(y/1e3).toFixed(0)}K`:String(y)}),j.jsx(Dn,{contentStyle:ix}),j.jsx(Pr,{wrapperStyle:{fontSize:12,color:Ll}}),j.jsx(Vn,{type:"monotone",dataKey:"read",name:"Leído",stroke:"#00d4aa",fill:"#00d4aa",fillOpacity:.2,strokeWidth:2}),j.jsx(Vn,{type:"monotone",dataKey:"create",name:"Creado",stroke:al,fill:al,fillOpacity:.2,strokeWidth:2})]})})]})}function sX({timeRange:e,sseVersion:t}){const[n,r]=H.useState([]),[o,l]=H.useState([]);H.useEffect(()=>{const y=e==="now-24h"?"1h":"1d";Promise.all([Ce.timeseries("claude_code.tokens.input",e,y),Ce.timeseries("claude_code.tokens.output",e,y)]).then(([v,g])=>{r(v),l(g)}).catch(()=>{})},[e,t]);const c=new Set([...n.map(y=>y.timestamp),...o.map(y=>y.timestamp)]),f=new Map(n.map(y=>[y.timestamp,y.value])),d=new Map(o.map(y=>[y.timestamp,y.value])),h=Array.from(c).sort().map(y=>{const v=f.get(y)??0,g=d.get(y)??0;return{label:new Date(y).toLocaleString("es",{hour:"2-digit",day:"numeric",month:"short"}),efficiency:v>0?Number((g/v).toFixed(3)):0}});return h.length===0?j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-48",children:j.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de eficiencia"})}):j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Ratio output/input"}),j.jsx(If,{width:"100%",height:220,children:j.jsxs(tX,{data:h,margin:{top:4,right:8,left:0,bottom:0},children:[j.jsx(Vl,{strokeDasharray:"3 3",stroke:Oa}),j.jsx(Ir,{dataKey:"label",tick:_a,tickLine:!1,axisLine:{stroke:Oa}}),j.jsx(Hr,{tick:_a,tickLine:!1,axisLine:!1,domain:[0,"auto"]}),j.jsx(Dn,{contentStyle:ix,formatter:y=>[y.toFixed(3),"Eficiencia"]}),j.jsx(nd,{y:.5,stroke:"#3b4d5e",strokeDasharray:"4 4",label:{value:"0.5",fill:"#5a6e7a",fontSize:10}}),j.jsx(Fl,{type:"monotone",dataKey:"efficiency",stroke:"#c592f0",strokeWidth:2,dot:!1})]})})]})}function OD(e,t=null){const[n,r]=H.useState(t),[o,l]=H.useState("desc");function c(h){h===n?l(y=>y==="desc"?"asc":"desc"):(r(h),l("desc"))}const f=H.useMemo(()=>{if(!n)return e;const h=o==="desc"?-1:1;return[...e].sort((y,v)=>{const g=y[n],b=v[n];return typeof g=="number"&&typeof b=="number"?(g-b)*h:String(g??"").localeCompare(String(b??""))*h})},[e,n,o]);function d(h){return h!==n?"":o==="desc"?" ↓":" ↑"}return{sorted:f,toggle:c,indicator:d}}function Go({stats:e}){return e.length===0?null:j.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 mb-4",children:e.map(t=>j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg px-4 py-3",children:[j.jsx("div",{className:"text-xs text-text-secondary uppercase tracking-wider mb-1",children:t.label}),j.jsx("div",{className:`text-xl font-mono font-bold ${t.accent??"text-text-primary"}`,children:t.value})]},t.label))})}function fX({timeRange:e,sseVersion:t}){const[n,r]=H.useState([]),[o,l]=H.useState(null),[c,f]=H.useState([]),[d,h]=H.useState(null),[y,v]=H.useState(""),[g,b]=H.useState(""),[_,S]=H.useState([]),{sorted:x,toggle:T,indicator:w}=OD(n,"startTime");H.useEffect(()=>{Ce.sessions(50,g||void 0).then(r).catch(()=>{})},[e,t,g]),H.useEffect(()=>{Ce.projects(e).then(P=>S(P.map(q=>q.project))).catch(()=>{})},[e,t]);function M(P){o===P?(l(null),f([])):(f([]),l(P),Ce.sessionEvents(P).then(f).catch(()=>{}))}function C(P,q,V){V.stopPropagation(),h(P),v(q??"")}async function A(P){y.trim()&&(await Ce.labelSession(P,y.trim()).catch(()=>{}),r(q=>q.map(V=>V.sessionId===P?{...V,project:y.trim()}:V))),h(null)}if(n.length===0&&!g)return j.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin sesiones registradas"});const E=n.reduce((P,q)=>P+q.cost,0),D=n.length>0?n.reduce((P,q)=>P+q.durationActiveMs,0)/n.length:0;return j.jsxs("div",{className:"flex flex-col gap-3",children:[j.jsx(Go,{stats:[{label:"Sesiones",value:String(n.length),accent:"text-accent-purple"},{label:"Coste total",value:Mt(E),accent:"text-accent-yellow"},{label:"Duración media",value:Dg(D),accent:"text-accent-blue"}]}),_.length>0&&j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-xs text-text-muted uppercase tracking-wider",children:"Proyecto"}),j.jsxs("select",{value:g,onChange:P=>b(P.target.value),className:"bg-bg-card border border-bg-border rounded px-2 py-1 text-xs text-text-primary outline-none focus:border-accent-green cursor-pointer",children:[j.jsx("option",{value:"",children:"Todos"}),_.map(P=>j.jsx("option",{value:P,children:P},P))]})]}),n.length===0?j.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin sesiones para este proyecto"}):j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg",children:j.jsx("div",{className:"overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm min-w-[720px] whitespace-nowrap",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"border-b border-bg-border",children:[j.jsx("th",{className:"w-6 px-3 py-2"}),j.jsx("th",{className:"text-left px-3 py-2 text-text-muted font-medium",children:"ID"}),j.jsxs("th",{className:"text-left px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("project"),children:["Proyecto",w("project")]}),j.jsxs("th",{className:"text-left px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("model"),children:["Modelo",w("model")]}),j.jsxs("th",{className:"text-left px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("startTime"),children:["Inicio",w("startTime")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("durationActiveMs"),children:["Duración",w("durationActiveMs")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("tokensInput"),children:["Input",w("tokensInput")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("tokensOutput"),children:["Output",w("tokensOutput")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>T("cost"),children:["Coste",w("cost")]})]})}),j.jsx("tbody",{children:x.map(P=>j.jsxs(H.Fragment,{children:[j.jsxs("tr",{className:"border-b border-bg-border hover:bg-bg-card-hover cursor-pointer",onClick:()=>M(P.sessionId),children:[j.jsx("td",{className:"px-3 py-2 text-text-muted",children:o===P.sessionId?j.jsx(c3,{size:14}):j.jsx(f3,{size:14})}),j.jsxs("td",{className:"px-3 py-2 font-mono text-text-secondary text-xs",children:[P.sessionId.slice(0,8),"…"]}),j.jsx("td",{className:"px-3 py-2",onClick:q=>q.stopPropagation(),children:d===P.sessionId?j.jsxs("span",{className:"flex items-center gap-1",children:[j.jsx("input",{autoFocus:!0,value:y,onChange:q=>v(q.target.value),onKeyDown:q=>{q.key==="Enter"&&A(P.sessionId),q.key==="Escape"&&h(null)},className:"bg-bg-base border border-bg-border rounded px-1 py-0.5 text-xs text-text-primary w-24 outline-none focus:border-accent-green"}),j.jsx("button",{onClick:()=>A(P.sessionId),className:"text-accent-green",children:j.jsx(Jb,{size:12})}),j.jsx("button",{onClick:()=>h(null),className:"text-accent-orange",children:j.jsx(lM,{size:12})})]}):j.jsxs("span",{onClick:q=>C(P.sessionId,P.project,q),className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-bg-base border border-bg-border text-text-secondary hover:border-accent-green cursor-pointer transition-colors",children:[P.project??"—",j.jsx(E3,{size:10,className:"opacity-50"})]})}),j.jsx("td",{className:"px-3 py-2 text-text-secondary font-mono text-xs",children:P.model??"—"}),j.jsx("td",{className:"px-3 py-2 text-text-secondary",children:e0(P.startTime)}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-text-secondary",children:Dg(P.durationActiveMs)}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-blue",children:At(P.tokensInput)}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-green",children:At(P.tokensOutput)}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-purple",children:Mt(P.cost)})]}),o===P.sessionId&&j.jsx("tr",{children:j.jsx("td",{colSpan:9,className:"bg-bg-subtle px-6 py-3",children:j.jsx("div",{className:"text-xs font-mono space-y-0.5 max-h-40 overflow-y-auto",children:c.length===0?j.jsx("span",{className:"text-text-muted",children:"Sin eventos"}):c.slice(-20).map((q,V)=>j.jsxs("div",{className:"flex gap-2 text-text-secondary",children:[j.jsx("span",{className:"text-text-muted shrink-0",children:new Date(q.timestamp).toLocaleTimeString()}),j.jsx("span",{className:"text-accent-teal",children:q.eventName})]},`${q.timestamp}-${q.eventName}-${V}`))})})})]},P.sessionId))})]})})})]})}function dX({timeRange:e,sseVersion:t}){const[n,r]=H.useState([]),[o,l]=H.useState(null),{sorted:c,toggle:f,indicator:d}=OD(n,"cost"),h=H.useCallback(()=>{Ce.projects(e).then(r).catch(()=>{})},[e]);H.useEffect(()=>{h()},[h,t]);const y=async g=>{if(confirm(`¿Resetear todos los datos del proyecto "${g}"?`)){l(g);try{await Ce.resetProject(g),h()}finally{l(null)}}};if(n.length===0)return j.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin proyectos registrados"});const v=Math.max(...n.map(g=>g.cost),1e-4);return j.jsxs("div",{className:"flex flex-col gap-4",children:[j.jsx(Go,{stats:[{label:"Proyectos",value:String(n.length),accent:"text-accent-cyan"},{label:"Coste total",value:Mt(n.reduce((g,b)=>g+b.cost,0)),accent:"text-accent-yellow"},{label:"Más caro",value:n.length>0?[...n].sort((g,b)=>b.cost-g.cost)[0].project:"—",accent:"text-accent-orange"}]}),j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4 space-y-3",children:n.map(g=>j.jsxs("div",{children:[j.jsxs("div",{className:"flex justify-between text-xs mb-1",children:[j.jsx("span",{className:"text-text-primary font-medium",children:g.project}),j.jsx("span",{className:"text-accent-purple font-mono",children:Mt(g.cost)})]}),j.jsx("div",{className:"h-2 bg-bg-base rounded-full overflow-hidden",children:j.jsx("div",{className:"h-full bg-accent-purple rounded-full",style:{width:`${g.cost/v*100}%`}})})]},g.project))}),j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg overflow-x-auto",children:j.jsxs("table",{className:"w-full text-sm min-w-[640px]",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"border-b border-bg-border",children:[j.jsxs("th",{className:"text-left px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("project"),children:["Proyecto",d("project")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("sessions"),children:["Sesiones",d("sessions")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("tokensInput"),children:["Input",d("tokensInput")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("tokensOutput"),children:["Output",d("tokensOutput")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("cacheHitRate"),children:["Caché %",d("cacheHitRate")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("cost"),children:["Coste",d("cost")]}),j.jsxs("th",{className:"text-right px-3 py-2 text-text-muted font-medium cursor-pointer hover:text-text-secondary select-none",onClick:()=>f("commits"),children:["Commits",d("commits")]}),j.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"LOC +/-"}),j.jsx("th",{className:"px-3 py-2"})]})}),j.jsx("tbody",{children:c.map(g=>j.jsxs("tr",{className:"border-b border-bg-border hover:bg-bg-card-hover",children:[j.jsx("td",{className:"px-3 py-2 text-text-primary font-medium",children:g.project}),j.jsx("td",{className:"px-3 py-2 text-right text-text-secondary",children:g.sessions}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-blue",children:At(g.tokensInput)}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-green",children:At(g.tokensOutput)}),j.jsxs("td",{className:"px-3 py-2 text-right font-mono text-accent-teal",children:[(g.cacheHitRate*100).toFixed(1),"%"]}),j.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-purple",children:Mt(g.cost)}),j.jsx("td",{className:"px-3 py-2 text-right text-text-secondary",children:g.commits}),j.jsxs("td",{className:"px-3 py-2 text-right font-mono text-xs",children:[j.jsxs("span",{className:"text-accent-green",children:["+",g.linesAdded]}),j.jsx("span",{className:"text-text-muted",children:" / "}),j.jsxs("span",{className:"text-accent-orange",children:["-",g.linesRemoved]})]}),j.jsx("td",{className:"px-3 py-2 text-right",children:j.jsx("button",{onClick:()=>y(g.project),disabled:o===g.project,title:"Resetear proyecto",className:"p-1 rounded text-text-muted hover:text-accent-orange hover:bg-bg-base transition-colors disabled:opacity-40",children:j.jsx(P3,{size:13})})})]},g.project))})]})})]})}function hX({timeRange:e,sseVersion:t}){const[n,r]=H.useState(null);if(H.useEffect(()=>{Ce.tools(e).then(r).catch(()=>{})},[e,t]),!n||n.usage.length===0)return j.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin datos de herramientas"});const o=Math.max(...n.usage.map(f=>f.count),1),l=n.decisionRate.approved+n.decisionRate.rejected,c=l>0?(n.decisionRate.approved/l*100).toFixed(1):"—";return j.jsxs("div",{className:"flex flex-col gap-4",children:[j.jsx(Go,{stats:[{label:"Herramientas",value:String(n.usage.length),accent:"text-accent-cyan"},{label:"Invocaciones",value:At(n.usage.reduce((f,d)=>f+d.count,0)),accent:"text-accent-green"},{label:"Más usada",value:n.usage.length>0?[...n.usage].sort((f,d)=>d.count-f.count)[0].toolName:"—",accent:"text-accent-purple"}]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("span",{className:"text-text-secondary text-sm",children:"Tasa de aprobación: "}),j.jsxs("span",{className:"text-accent-green font-mono font-bold",children:[c,"%"]}),j.jsxs("span",{className:"text-text-muted text-xs ml-2",children:["(",n.decisionRate.approved," aprobadas / ",n.decisionRate.rejected," rechazadas)"]})]}),j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4 space-y-2",children:n.usage.map(f=>j.jsxs("div",{children:[j.jsxs("div",{className:"flex justify-between text-xs mb-1",children:[j.jsx("span",{className:"font-mono text-text-primary",children:f.toolName}),j.jsxs("span",{className:"text-text-secondary",children:[f.count," usos · ",(f.successRate*100).toFixed(0),"% éxito"]})]}),j.jsx("div",{className:"h-1.5 bg-bg-base rounded-full overflow-hidden",children:j.jsx("div",{className:"h-full bg-accent-teal rounded-full",style:{width:`${f.count/o*100}%`}})})]},f.toolName))})]})}const pX={"now-24h":"últimas 24 h","now-7d":"últimos 7 días","now-30d":"últimos 30 días",all:"acumulado total"};function vX({timeRange:e,sseVersion:t}){const[n,r]=H.useState([]);if(H.useEffect(()=>{Ce.models(e).then(r).catch(()=>{})},[e,t]),n.length===0)return j.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin datos de modelos"});const o=Math.max(...n.map(c=>c.cost),1e-6),l=n.reduce((c,f)=>c+f.cost,0);return j.jsxs(j.Fragment,{children:[j.jsx(Go,{stats:[{label:"Modelos",value:String(n.length),accent:"text-accent-cyan"},{label:"Coste total",value:Mt(n.reduce((c,f)=>c+f.cost,0)),accent:"text-accent-yellow"},{label:"Dominante",value:n.length>0?[...n].sort((c,f)=>f.cost-c.cost)[0].model:"—",accent:"text-accent-purple"}]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsxs("div",{className:"flex justify-between items-baseline mb-4",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary",children:"Coste por modelo"}),j.jsx("span",{className:"text-xs text-text-muted",children:pX[e]})]}),j.jsxs("table",{className:"w-full text-sm",children:[j.jsx("thead",{children:j.jsxs("tr",{className:"text-xs text-text-muted uppercase tracking-wider text-left",children:[j.jsx("th",{className:"pb-2 font-medium",children:"Modelo"}),j.jsx("th",{className:"pb-2 font-medium text-right",children:"Requests"}),j.jsx("th",{className:"pb-2 font-medium text-right",children:"Tokens In"}),j.jsx("th",{className:"pb-2 font-medium text-right",children:"Tokens Out"}),j.jsx("th",{className:"pb-2 font-medium text-right",children:"Coste"}),j.jsx("th",{className:"pb-2 font-medium text-right",children:"% gasto"})]})}),j.jsx("tbody",{children:n.map(c=>j.jsxs("tr",{className:"border-t border-bg-border",children:[j.jsxs("td",{className:"py-2 pr-4",children:[j.jsx("div",{className:"font-mono text-text-primary",children:c.model}),j.jsx("div",{className:"h-1.5 bg-bg-base rounded-full overflow-hidden mt-1",children:j.jsx("div",{className:"h-full bg-accent-purple rounded-full",style:{width:`${c.cost/o*100}%`}})})]}),j.jsx("td",{className:"py-2 text-right font-mono text-text-secondary",children:c.requests}),j.jsx("td",{className:"py-2 text-right font-mono text-accent-blue",children:At(c.tokensInput)}),j.jsx("td",{className:"py-2 text-right font-mono text-accent-green",children:At(c.tokensOutput)}),j.jsx("td",{className:"py-2 text-right font-mono font-bold text-accent-purple",children:Mt(c.cost)}),j.jsx("td",{className:"py-2 text-right font-mono text-text-secondary",children:l>0?`${(c.cost/l*100).toFixed(1)}%`:"—"})]},c.model))})]})]})]})}const Qu={"claude-fable-5":{input:10,output:50,cacheWrite:12.5,cacheRead:1},"claude-opus-4-8":{input:5,output:25,cacheWrite:6.25,cacheRead:.5},"claude-sonnet-4-6":{input:3,output:15,cacheWrite:3.75,cacheRead:.3},"claude-haiku-4-5":{input:1,output:5,cacheWrite:1.25,cacheRead:.1}},iM=Qu["claude-sonnet-4-6"];function _D(e){if(!e)return iM;const t=e.toLowerCase();return t.includes("fable")?Qu["claude-fable-5"]:t.includes("opus")?Qu["claude-opus-4-8"]:t.includes("haiku")?Qu["claude-haiku-4-5"]:t.includes("sonnet")?Qu["claude-sonnet-4-6"]:iM}function AD(e,t){const n=_D(t);return e*(n.input-n.cacheRead)/1e6}const yX=[{id:"all",label:"Todos"},{id:"api",label:"API"},{id:"tools",label:"Tools"},{id:"prompts",label:"Prompts"},{id:"errors",label:"Errores"}];function mX(e){return e>=1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(4)}`}function gX(e){const t=e.attributes;if(typeof t.cost=="number"&&t.cost>0)return t.cost;const n=Number(t.input_tokens??t["tokens.input"]??0),r=Number(t.output_tokens??t["tokens.output"]??0),o=Number(t.cache_read_input_tokens??t["tokens.cache_read"]??0),l=Number(t.cache_creation_input_tokens??t["tokens.cache_creation"]??0);if(n===0&&r===0)return null;const c=_D(e.model);return n*c.input/1e6+r*c.output/1e6+o*c.cacheRead/1e6+l*c.cacheWrite/1e6}function bX(e){return e.includes("error")?"text-accent-orange":e==="user_prompt"?"text-accent-blue":e==="api_request"?"text-accent-green":e==="tool_use"?"text-accent-teal":e.startsWith("hook_")?"text-accent-yellow":"text-text-secondary"}function xX(e,t){return t==="all"?!0:t==="api"?e.eventName.includes("api"):t==="tools"?e.eventName.includes("tool"):t==="prompts"?e.eventName.includes("prompt"):t==="errors"?e.eventName.includes("error"):!0}function SX({timeRange:e,sseVersion:t}){const[n,r]=H.useState([]),[o,l]=H.useState("all"),[c,f]=H.useState(!1);H.useEffect(()=>{c||Ce.events(500).then(r).catch(()=>{})},[e,t,c]);const d=n.filter(h=>xX(h,o));return j.jsxs(j.Fragment,{children:[j.jsx(Go,{stats:[{label:"Eventos",value:At(n.length),accent:"text-accent-cyan"},{label:"Errores",value:String(n.filter(h=>h.eventName.includes("error")).length),accent:"text-accent-red"},{label:"Último evento",value:n.length>0?e0(n[0].timestamp):"—",accent:"text-accent-blue"}]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg flex flex-col h-[600px]",children:[j.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-bg-border flex-wrap",children:[yX.map(({id:h,label:y})=>j.jsx("button",{onClick:()=>l(h),className:`px-2 py-1 rounded text-xs transition-colors ${o===h?"bg-accent-cyan text-bg-base font-medium":"text-text-secondary hover:text-text-primary"}`,children:y},h)),j.jsx("div",{className:"flex-1"}),j.jsxs("button",{onClick:()=>f(h=>!h),className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-text-secondary hover:text-text-primary",children:[c?j.jsx(M3,{size:12}):j.jsx(w3,{size:12}),j.jsx("span",{children:c?"Reanudar":"Pausar"})]})]}),j.jsx("div",{className:"flex-1 overflow-y-auto p-3 font-mono text-xs space-y-0.5",children:d.length===0?j.jsx("span",{className:"text-text-muted",children:"Sin eventos"}):d.map((h,y)=>{const v=gX(h);return j.jsxs("div",{className:"flex gap-2 hover:bg-bg-base px-1 rounded",children:[j.jsx("span",{className:"text-text-muted shrink-0",children:new Date(h.timestamp).toLocaleTimeString()}),j.jsx("span",{className:`shrink-0 ${bX(h.eventName)}`,children:h.eventName}),h.sessionId&&j.jsxs("span",{className:"text-text-muted",children:[h.sessionId.slice(0,6),"…"]}),v!==null&&j.jsx("span",{className:"text-accent-purple ml-auto shrink-0",children:mX(v)})]},`${h.sessionId??""}-${h.timestamp}-${h.eventName}-${y}`)})})]})]})}function OX({sseVersion:e}){const[t,n]=H.useState([]);return H.useEffect(()=>{Ce.agents().then(n).catch(()=>{})},[e]),t.length===0?j.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-8 flex items-center justify-center",children:j.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de agentes. Aparece cuando Claude Code delega tareas a subagentes (herramienta Task)."})}):j.jsxs(j.Fragment,{children:[j.jsx(Go,{stats:[{label:"Agentes",value:String(t.length),accent:"text-accent-cyan"},{label:"Tokens totales",value:At(t.reduce((r,o)=>r+o.tokensInput+o.tokensOutput,0)),accent:"text-accent-green"},{label:"Más activo",value:t.length>0?[...t].sort((r,o)=>o.tokensInput+o.tokensOutput-(r.tokensInput+r.tokensOutput))[0].name:"—",accent:"text-accent-purple"}]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg overflow-hidden",children:[j.jsxs("div",{className:"px-3 py-2 border-b border-bg-border grid grid-cols-4 text-xs text-text-muted",children:[j.jsx("span",{children:"Agente"}),j.jsx("span",{children:"Input"}),j.jsx("span",{children:"Output"}),j.jsx("span",{children:"Coste"})]}),t.map(r=>j.jsxs("div",{className:"grid grid-cols-4 items-center py-2 border-b border-bg-border text-sm hover:bg-bg-card-hover px-3",children:[j.jsx("span",{className:"text-text-secondary",children:r.name}),j.jsx("span",{className:"font-mono text-accent-blue",children:At(r.tokensInput)}),j.jsx("span",{className:"font-mono text-accent-green",children:At(r.tokensOutput)}),j.jsx("span",{className:"font-mono text-accent-purple",children:Mt(r.cost)})]},r.name))]})]})}function ld({title:e,onViewAll:t,children:n}){return j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4 flex flex-col",children:[j.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-3",children:e}),j.jsx("div",{className:"flex-1",children:n}),t&&j.jsx("button",{onClick:t,className:"self-start mt-3 text-xs text-link-subtle hover:text-accent-cyan transition-colors",children:"Ver todo →"})]})}function _X({sseVersion:e,onViewAll:t}){const[n,r]=H.useState([]);return H.useEffect(()=>{Ce.sessions(3).then(r).catch(()=>{})},[e]),j.jsx(ld,{title:"Sesiones recientes",onViewAll:t,children:n.length===0?j.jsx("span",{className:"text-xs text-text-muted",children:"Sin sesiones"}):j.jsx("ul",{className:"flex flex-col gap-2",children:n.map(o=>j.jsxs("li",{className:"flex items-baseline justify-between gap-2 text-xs",children:[j.jsxs("span",{className:"text-text-primary truncate",children:[j.jsx("span",{className:"text-accent-cyan",children:"●"})," ",o.project??"sin proyecto"]}),j.jsxs("span",{className:"font-mono text-text-secondary whitespace-nowrap",children:[Mt(o.cost)," · ",At(o.tokensInput+o.tokensOutput)," tok"]})]},o.sessionId))})})}function AX({timeRange:e,sseVersion:t,onViewAll:n}){const[r,o]=H.useState([]);return H.useEffect(()=>{Ce.projects(e).then(l=>o([...l].sort((c,f)=>f.cost-c.cost).slice(0,3))).catch(()=>{})},[e,t]),j.jsx(ld,{title:"Top proyectos",onViewAll:n,children:r.length===0?j.jsx("span",{className:"text-xs text-text-muted",children:"Sin proyectos"}):j.jsx("ul",{className:"flex flex-col gap-2",children:r.map((l,c)=>j.jsxs("li",{className:"flex items-baseline justify-between gap-2 text-xs",children:[j.jsxs("span",{className:"text-text-primary truncate",children:[j.jsxs("span",{className:"text-text-muted",children:[c+1,"."]})," ",l.project]}),j.jsx("span",{className:"font-mono text-accent-yellow whitespace-nowrap",children:Mt(l.cost)})]},l.project))})})}function wX(e){return e.includes("error")?"text-accent-red":e==="user_prompt"?"text-accent-blue":e==="api_request"?"text-accent-green":e==="tool_use"?"text-accent-teal":e.startsWith("hook_")?"text-accent-yellow":"text-text-secondary"}function TX({sseVersion:e,onViewAll:t}){const[n,r]=H.useState([]);return H.useEffect(()=>{Ce.events(3).then(r).catch(()=>{})},[e]),j.jsx(ld,{title:"Eventos recientes",onViewAll:t,children:n.length===0?j.jsx("span",{className:"text-xs text-text-muted",children:"Sin eventos"}):j.jsx("ul",{className:"flex flex-col gap-2",children:n.map((o,l)=>j.jsxs("li",{className:"flex items-baseline justify-between gap-2 text-xs",children:[j.jsxs("span",{className:`truncate ${wX(o.eventName)}`,children:["● ",o.eventName]}),j.jsx("span",{className:"text-text-muted whitespace-nowrap",children:e0(o.timestamp)})]},`${o.timestamp}-${l}`))})})}function EX({summary:e}){return j.jsx(ld,{title:"Ahorro caché",children:j.jsxs("div",{className:"flex flex-col justify-center h-full gap-1",children:[j.jsx("span",{className:"text-3xl font-mono font-bold text-accent-green",children:Mt(AD(e.tokens.cache))}),j.jsxs("span",{className:"text-xs text-text-muted",children:["est. período · ",At(e.tokens.cache)," tokens de caché"]})]})})}function jX(){const[e,t]=H.useState("now-24h");return{timeRange:e,setTimeRange:t}}function MX(e){const[t,n]=H.useState({connected:!1,lastSeen:null,sessionCount:0,totalEvents:0,uptime:0}),[r,o]=H.useState(null),[l,c]=H.useState(0),f=H.useRef(0),d=H.useRef(0),h=H.useCallback(async()=>{f.current=Date.now();try{const[v,g]=await Promise.all([Ce.status(),Ce.summary(e)]);n(v),o(g)}catch{}},[e]);H.useEffect(()=>{h()},[h]);const y=H.useCallback((v,g)=>{Date.now()-f.current>5e3?h():Ce.status().then(n).catch(()=>{});const b=Date.now();b-d.current>5e3&&(d.current=b,c(_=>_+1))},[h]);return cM(y),{status:t,summary:r,refetch:h,sseVersion:l}}const Ng=e=>e.reduce((t,n)=>t+n.value,0);function CX(e){const[t,n]=H.useState({tokensPerMin:0,costPerHour:0}),r=H.useCallback(async()=>{try{const[o,l,c]=await Promise.all([Ce.timeseries("claude_code.tokens.input","now-5m","5m"),Ce.timeseries("claude_code.tokens.output","now-5m","5m"),Ce.timeseries("claude_code.cost","now-5m","5m")]);n({tokensPerMin:(Ng(o)+Ng(l))/5,costPerHour:Ng(c)*12})}catch{}},[]);return H.useEffect(()=>{r()},[r,e]),H.useEffect(()=>{const o=setInterval(r,3e4);return()=>clearInterval(o)},[r]),t}const NX={overview:"Overview",sessions:"Sessions",projects:"Projects",tools:"Tools",agents:"Agents",models:"Models",events:"Events",costs:"Costs"},oM="__new__";function DX({autoDetected:e,userSelected:t,knownProjects:n,onChange:r}){const[o,l]=H.useState(!1),[c,f]=H.useState(""),d=t??e;if(!d&&n.length===0)return null;const h=[...new Set([...n,...d?[d]:[]])];if(h.length===0)return null;function y(g){g.target.value===oM?(l(!0),f("")):r(g.target.value||null)}function v(){const g=c.trim();g&&r(g),l(!1),f("")}return j.jsxs("div",{className:"flex items-center gap-2",children:[j.jsx("span",{className:"text-xs text-text-muted uppercase tracking-wider",children:"Proyecto"}),o?j.jsxs(j.Fragment,{children:[j.jsx("input",{autoFocus:!0,value:c,onChange:g=>f(g.target.value),onKeyDown:g=>{g.key==="Enter"&&v(),g.key==="Escape"&&(l(!1),f(""))},placeholder:"nombre del proyecto",className:"bg-bg-base border border-bg-border rounded px-2 py-0.5 text-lg font-semibold text-text-primary outline-none focus:border-accent-cyan w-44"}),j.jsx("button",{onClick:v,className:"text-xs text-accent-green hover:opacity-80 transition-opacity",children:"✓"}),j.jsx("button",{onClick:()=>{l(!1),f("")},className:"text-xs text-text-muted hover:text-accent-red transition-colors",children:"✕"})]}):j.jsxs(j.Fragment,{children:[j.jsxs("select",{value:d??"",onChange:y,className:"bg-bg-card border border-bg-border rounded px-2 py-0.5 text-lg font-semibold text-text-primary outline-none focus:border-accent-cyan cursor-pointer",children:[h.map(g=>j.jsx("option",{value:g,children:g},g)),j.jsx("option",{disabled:!0,children:"──────────"}),j.jsx("option",{value:oM,children:"+ Nuevo proyecto"})]}),t&&t!==e&&j.jsx("button",{onClick:()=>r(null),className:"text-xs text-text-muted hover:text-text-secondary transition-colors",title:"Volver al proyecto auto-detectado",children:"↩ auto"})]})]})}function PX(){const[e,t]=H.useState("overview"),{timeRange:n,setTimeRange:r}=jX(),{status:o,summary:l,refetch:c,sseVersion:f}=MX(n),d=CX(f),[h,y]=H.useState(null),[v,g]=H.useState([]),[b,_]=H.useState([]);H.useEffect(()=>{Ce.projects(n).then(w=>{g(w.map(M=>M.project)),_(w)}).catch(()=>{})},[f,n]),H.useEffect(()=>{Ce.summary("now-24h").then(w=>{document.title=w.cost>0?`${Mt(w.cost)} hoy · tokenrace`:"tokenrace"}).catch(()=>{})},[f]);const S=H.useCallback(async()=>{await Ce.reset(),c()},[c]);if(!o.connected&&o.totalEvents===0)return j.jsxs("div",{className:"min-h-screen bg-bg-base text-text-primary flex flex-col",children:[j.jsx(y_,{sectionTitle:"Setup",timeRange:n,onTimeRangeChange:r,connected:!1,lastSeen:null,onReset:S,liveRate:d}),j.jsx(G3,{})]});const x=h??(l==null?void 0:l.currentProject)??null,T=b.find(w=>w.project===x)??null;return j.jsxs("div",{className:"min-h-screen bg-bg-base text-text-primary flex",children:[j.jsx(H3,{activeTab:e,onTabChange:t}),j.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[j.jsx(y_,{sectionTitle:NX[e],timeRange:n,onTimeRangeChange:r,connected:o.connected,lastSeen:o.lastSeen,onReset:S,liveRate:d}),j.jsx(K3,{onLabeled:c}),j.jsxs("main",{className:"flex-1 p-4 max-w-screen-2xl mx-auto w-full",children:[e==="overview"&&j.jsxs("div",{className:"flex flex-col gap-4",children:[j.jsx(DX,{autoDetected:(l==null?void 0:l.currentProject)??null,userSelected:h,knownProjects:v,onChange:y}),l&&j.jsx(Z3,{summary:l,selectedProjectData:T,timeRange:n,sseVersion:f,onNavigate:t}),j.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[j.jsx(aX,{compact:!0,timeRange:n,sseVersion:f}),j.jsx(lX,{compact:!0,timeRange:n,sseVersion:f}),l&&j.jsx(EX,{summary:l}),j.jsx(_X,{sseVersion:f,onViewAll:()=>t("sessions")}),j.jsx(AX,{timeRange:n,sseVersion:f,onViewAll:()=>t("projects")}),j.jsx(TX,{sseVersion:f,onViewAll:()=>t("events")})]}),j.jsx(oX,{sseVersion:f})]}),e==="sessions"&&j.jsx(fX,{timeRange:n,sseVersion:f}),e==="projects"&&j.jsx(dX,{timeRange:n,sseVersion:f}),e==="tools"&&j.jsx(hX,{timeRange:n,sseVersion:f}),e==="agents"&&j.jsx(OX,{sseVersion:f}),e==="models"&&j.jsx(vX,{timeRange:n,sseVersion:f}),e==="events"&&j.jsx(SX,{timeRange:n,sseVersion:f}),e==="costs"&&j.jsxs("div",{className:"flex flex-col gap-4",children:[l&&j.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Coste período"}),j.jsx("div",{className:"text-2xl font-mono font-bold text-accent-purple",children:Mt(l.cost)})]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Eficiencia"}),j.jsxs("div",{className:"text-2xl font-mono font-bold text-accent-green",children:[(l.efficiency*100).toFixed(1),"%"]})]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Tokens caché"}),j.jsx("div",{className:"text-2xl font-mono font-bold text-accent-teal",children:At(l.tokens.cache)})]}),j.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[j.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Ahorro caché est."}),j.jsx("div",{className:"text-2xl font-mono font-bold text-accent-yellow",children:Mt(AD(l.tokens.cache))})]})]}),j.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[j.jsx(cX,{timeRange:n,sseVersion:f}),j.jsx(sX,{timeRange:n,sseVersion:f})]})]})]})]})]})}JR.createRoot(document.getElementById("root")).render(j.jsx(H.StrictMode,{children:j.jsx(PX,{})}));document.addEventListener("visibilitychange",()=>{if(document.visibilityState!=="visible")return;const e=document.getElementById("root");e&&(e.style.display="none",e.offsetHeight,e.style.display="")});
Binary file
Binary file
package/dist/index.html CHANGED
@@ -3,10 +3,12 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <meta name="theme-color" content="#0b1218" />
7
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
6
8
  <title>tokenrace</title>
7
- <script type="module" crossorigin src="/assets/index-UHFJCd1U.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-BEYu98YA.js"></script>
8
10
  <link rel="stylesheet" crossorigin href="/assets/index-C2s9cKqk.css">
9
- </head>
11
+ <link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
10
12
  <body>
11
13
  <div id="root"></div>
12
14
  </body>
@@ -0,0 +1 @@
1
+ {"name":"tokenrace","short_name":"tokenrace","description":"Monitor en tiempo real para Claude Code","start_url":"/","display":"standalone","background_color":"#0b1218","theme_color":"#0b1218","lang":"en","scope":"/","icons":[{"src":"/icon-192.png","sizes":"192x192","type":"image/png"},{"src":"/icon-512.png","sizes":"512x512","type":"image/png"},{"src":"/maskable-icon-512.png","sizes":"512x512","type":"image/png","purpose":"maskable"}]}
Binary file
@@ -0,0 +1 @@
1
+ if('serviceWorker' in navigator) {window.addEventListener('load', () => {navigator.serviceWorker.register('/sw.js', { scope: '/' })})}
package/dist/sw.js ADDED
@@ -0,0 +1 @@
1
+ if(!self.define){let e,i={};const n=(n,s)=>(n=new URL(n+".js",s).href,i[n]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=i,document.head.appendChild(e)}else e=n,importScripts(n),i()}).then(()=>{let e=i[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e}));self.define=(s,r)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(i[o])return;let c={};const t=e=>n(e,o),l={module:{uri:o},exports:c,require:t};i[o]=Promise.all(s.map(e=>l[e]||t(e))).then(e=>(r(...e),c))}}define(["./workbox-abeb32eb"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"34593429d46967b1cf401411baa0306b"},{url:"assets/index-C2s9cKqk.css",revision:null},{url:"assets/index-BEYu98YA.js",revision:null},{url:"apple-touch-icon.png",revision:"07a78e01ea9791e1b5fd66c073c5dc3b"},{url:"icon-192.png",revision:"fb2329e12f070bde166224320bf94f57"},{url:"icon-512.png",revision:"c3f7cc749dba1a36efb6e29df955647b"},{url:"maskable-icon-512.png",revision:"de6bf2ac07c6c027be8e279499fb9d39"},{url:"manifest.webmanifest",revision:"c489f5cbb345eb419b60c33624a0d239"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html"),{denylist:[/^\/api/,/^\/v1/]})),e.registerRoute(/^\/(api|v1)\//,new e.NetworkOnly,"GET")});
@@ -0,0 +1 @@
1
+ define(["exports"],function(t){"use strict";try{self["workbox:core:7.4.0"]&&_()}catch(t){}const e=(t,...e)=>{let s=t;return e.length>0&&(s+=` :: ${JSON.stringify(e)}`),s};class s extends Error{constructor(t,s){super(e(t,s)),this.name=t,this.details=s}}try{self["workbox:routing:7.4.0"]&&_()}catch(t){}const n=t=>t&&"object"==typeof t?t:{handle:t};class r{constructor(t,e,s="GET"){this.handler=n(e),this.match=t,this.method=s}setCatchHandler(t){this.catchHandler=n(t)}}class i extends r{constructor(t,e,s){super(({url:e})=>{const s=t.exec(e.href);if(s&&(e.origin===location.origin||0===s.index))return s.slice(1)},e,s)}}class o{constructor(){this.t=new Map,this.i=new Map}get routes(){return this.t}addFetchListener(){self.addEventListener("fetch",t=>{const{request:e}=t,s=this.handleRequest({request:e,event:t});s&&t.respondWith(s)})}addCacheListener(){self.addEventListener("message",t=>{if(t.data&&"CACHE_URLS"===t.data.type){const{payload:e}=t.data,s=Promise.all(e.urlsToCache.map(e=>{"string"==typeof e&&(e=[e]);const s=new Request(...e);return this.handleRequest({request:s,event:t})}));t.waitUntil(s),t.ports&&t.ports[0]&&s.then(()=>t.ports[0].postMessage(!0))}})}handleRequest({request:t,event:e}){const s=new URL(t.url,location.href);if(!s.protocol.startsWith("http"))return;const n=s.origin===location.origin,{params:r,route:i}=this.findMatchingRoute({event:e,request:t,sameOrigin:n,url:s});let o=i&&i.handler;const c=t.method;if(!o&&this.i.has(c)&&(o=this.i.get(c)),!o)return;let a;try{a=o.handle({url:s,request:t,event:e,params:r})}catch(t){a=Promise.reject(t)}const h=i&&i.catchHandler;return a instanceof Promise&&(this.o||h)&&(a=a.catch(async n=>{if(h)try{return await h.handle({url:s,request:t,event:e,params:r})}catch(t){t instanceof Error&&(n=t)}if(this.o)return this.o.handle({url:s,request:t,event:e});throw n})),a}findMatchingRoute({url:t,sameOrigin:e,request:s,event:n}){const r=this.t.get(s.method)||[];for(const i of r){let r;const o=i.match({url:t,sameOrigin:e,request:s,event:n});if(o)return r=o,(Array.isArray(r)&&0===r.length||o.constructor===Object&&0===Object.keys(o).length||"boolean"==typeof o)&&(r=void 0),{route:i,params:r}}return{}}setDefaultHandler(t,e="GET"){this.i.set(e,n(t))}setCatchHandler(t){this.o=n(t)}registerRoute(t){this.t.has(t.method)||this.t.set(t.method,[]),this.t.get(t.method).push(t)}unregisterRoute(t){if(!this.t.has(t.method))throw new s("unregister-route-but-not-found-with-method",{method:t.method});const e=this.t.get(t.method).indexOf(t);if(!(e>-1))throw new s("unregister-route-route-not-registered");this.t.get(t.method).splice(e,1)}}let c;const a=()=>(c||(c=new o,c.addFetchListener(),c.addCacheListener()),c);function h(t,e,n){let o;if("string"==typeof t){const s=new URL(t,location.href);o=new r(({url:t})=>t.href===s.href,e,n)}else if(t instanceof RegExp)o=new i(t,e,n);else if("function"==typeof t)o=new r(t,e,n);else{if(!(t instanceof r))throw new s("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});o=t}return a().registerRoute(o),o}function u(t){return new Promise(e=>setTimeout(e,t))}const l={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},f=t=>[l.prefix,t,l.suffix].filter(t=>t&&t.length>0).join("-"),w=t=>t||f(l.precache),d=t=>t||f(l.runtime);function p(t,e){const s=new URL(t);for(const t of e)s.searchParams.delete(t);return s.href}class y{constructor(){this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}}const g=new Set;try{self["workbox:strategies:7.4.0"]&&_()}catch(t){}function R(t){return"string"==typeof t?new Request(t):t}class m{constructor(t,e){this.h={},Object.assign(this,e),this.event=e.event,this.u=t,this.l=new y,this.p=[],this.R=[...t.plugins],this.m=new Map;for(const t of this.R)this.m.set(t,{});this.event.waitUntil(this.l.promise)}async fetch(t){const{event:e}=this;let n=R(t);if("navigate"===n.mode&&e instanceof FetchEvent&&e.preloadResponse){const t=await e.preloadResponse;if(t)return t}const r=this.hasCallback("fetchDidFail")?n.clone():null;try{for(const t of this.iterateCallbacks("requestWillFetch"))n=await t({request:n.clone(),event:e})}catch(t){if(t instanceof Error)throw new s("plugin-error-request-will-fetch",{thrownErrorMessage:t.message})}const i=n.clone();try{let t;t=await fetch(n,"navigate"===n.mode?void 0:this.u.fetchOptions);for(const s of this.iterateCallbacks("fetchDidSucceed"))t=await s({event:e,request:i,response:t});return t}catch(t){throw r&&await this.runCallbacks("fetchDidFail",{error:t,event:e,originalRequest:r.clone(),request:i.clone()}),t}}async fetchAndCachePut(t){const e=await this.fetch(t),s=e.clone();return this.waitUntil(this.cachePut(t,s)),e}async cacheMatch(t){const e=R(t);let s;const{cacheName:n,matchOptions:r}=this.u,i=await this.getCacheKey(e,"read"),o=Object.assign(Object.assign({},r),{cacheName:n});s=await caches.match(i,o);for(const t of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await t({cacheName:n,matchOptions:r,cachedResponse:s,request:i,event:this.event})||void 0;return s}async cachePut(t,e){const n=R(t);await u(0);const r=await this.getCacheKey(n,"write");if(!e)throw new s("cache-put-with-no-response",{url:(i=r.url,new URL(String(i),location.href).href.replace(new RegExp(`^${location.origin}`),""))});var i;const o=await this.v(e);if(!o)return!1;const{cacheName:c,matchOptions:a}=this.u,h=await self.caches.open(c),l=this.hasCallback("cacheDidUpdate"),f=l?await async function(t,e,s,n){const r=p(e.url,s);if(e.url===r)return t.match(e,n);const i=Object.assign(Object.assign({},n),{ignoreSearch:!0}),o=await t.keys(e,i);for(const e of o)if(r===p(e.url,s))return t.match(e,n)}(h,r.clone(),["__WB_REVISION__"],a):null;try{await h.put(r,l?o.clone():o)}catch(t){if(t instanceof Error)throw"QuotaExceededError"===t.name&&await async function(){for(const t of g)await t()}(),t}for(const t of this.iterateCallbacks("cacheDidUpdate"))await t({cacheName:c,oldResponse:f,newResponse:o.clone(),request:r,event:this.event});return!0}async getCacheKey(t,e){const s=`${t.url} | ${e}`;if(!this.h[s]){let n=t;for(const t of this.iterateCallbacks("cacheKeyWillBeUsed"))n=R(await t({mode:e,request:n,event:this.event,params:this.params}));this.h[s]=n}return this.h[s]}hasCallback(t){for(const e of this.u.plugins)if(t in e)return!0;return!1}async runCallbacks(t,e){for(const s of this.iterateCallbacks(t))await s(e)}*iterateCallbacks(t){for(const e of this.u.plugins)if("function"==typeof e[t]){const s=this.m.get(e),n=n=>{const r=Object.assign(Object.assign({},n),{state:s});return e[t](r)};yield n}}waitUntil(t){return this.p.push(t),t}async doneWaiting(){for(;this.p.length;){const t=this.p.splice(0),e=(await Promise.allSettled(t)).find(t=>"rejected"===t.status);if(e)throw e.reason}}destroy(){this.l.resolve(null)}async v(t){let e=t,s=!1;for(const t of this.iterateCallbacks("cacheWillUpdate"))if(e=await t({request:this.request,response:e,event:this.event})||void 0,s=!0,!e)break;return s||e&&200!==e.status&&(e=void 0),e}}class v{constructor(t={}){this.cacheName=d(t.cacheName),this.plugins=t.plugins||[],this.fetchOptions=t.fetchOptions,this.matchOptions=t.matchOptions}handle(t){const[e]=this.handleAll(t);return e}handleAll(t){t instanceof FetchEvent&&(t={event:t,request:t.request});const e=t.event,s="string"==typeof t.request?new Request(t.request):t.request,n="params"in t?t.params:void 0,r=new m(this,{event:e,request:s,params:n}),i=this.q(r,s,e);return[i,this.U(i,r,s,e)]}async q(t,e,n){let r;await t.runCallbacks("handlerWillStart",{event:n,request:e});try{if(r=await this.L(e,t),!r||"error"===r.type)throw new s("no-response",{url:e.url})}catch(s){if(s instanceof Error)for(const i of t.iterateCallbacks("handlerDidError"))if(r=await i({error:s,event:n,request:e}),r)break;if(!r)throw s}for(const s of t.iterateCallbacks("handlerWillRespond"))r=await s({event:n,request:e,response:r});return r}async U(t,e,s,n){let r,i;try{r=await t}catch(i){}try{await e.runCallbacks("handlerDidRespond",{event:n,request:s,response:r}),await e.doneWaiting()}catch(t){t instanceof Error&&(i=t)}if(await e.runCallbacks("handlerDidComplete",{event:n,request:s,response:r,error:i}),e.destroy(),i)throw i}}function q(t,e){const s=e();return t.waitUntil(s),s}try{self["workbox:precaching:7.4.0"]&&_()}catch(t){}function U(t){if(!t)throw new s("add-to-cache-list-unexpected-type",{entry:t});if("string"==typeof t){const e=new URL(t,location.href);return{cacheKey:e.href,url:e.href}}const{revision:e,url:n}=t;if(!n)throw new s("add-to-cache-list-unexpected-type",{entry:t});if(!e){const t=new URL(n,location.href);return{cacheKey:t.href,url:t.href}}const r=new URL(n,location.href),i=new URL(n,location.href);return r.searchParams.set("__WB_REVISION__",e),{cacheKey:r.href,url:i.href}}class L{constructor(){this.updatedURLs=[],this.notUpdatedURLs=[],this.handlerWillStart=async({request:t,state:e})=>{e&&(e.originalRequest=t)},this.cachedResponseWillBeUsed=async({event:t,state:e,cachedResponse:s})=>{if("install"===t.type&&e&&e.originalRequest&&e.originalRequest instanceof Request){const t=e.originalRequest.url;s?this.notUpdatedURLs.push(t):this.updatedURLs.push(t)}return s}}}class b{constructor({precacheController:t}){this.cacheKeyWillBeUsed=async({request:t,params:e})=>{const s=(null==e?void 0:e.cacheKey)||this._.getCacheKeyForURL(t.url);return s?new Request(s,{headers:t.headers}):t},this._=t}}let E,C;async function x(t,e){let n=null;if(t.url){n=new URL(t.url).origin}if(n!==self.location.origin)throw new s("cross-origin-copy-response",{origin:n});const r=t.clone(),i={headers:new Headers(r.headers),status:r.status,statusText:r.statusText},o=function(){if(void 0===E){const t=new Response("");if("body"in t)try{new Response(t.body),E=!0}catch(t){E=!1}E=!1}return E}()?r.body:await r.blob();return new Response(o,i)}class O extends v{constructor(t={}){t.cacheName=w(t.cacheName),super(t),this.C=!1!==t.fallbackToNetwork,this.plugins.push(O.copyRedirectedCacheableResponsesPlugin)}async L(t,e){const s=await e.cacheMatch(t);return s||(e.event&&"install"===e.event.type?await this.O(t,e):await this.N(t,e))}async N(t,e){let n;const r=e.params||{};if(!this.C)throw new s("missing-precache-entry",{cacheName:this.cacheName,url:t.url});{const s=r.integrity,i=t.integrity,o=!i||i===s;n=await e.fetch(new Request(t,{integrity:"no-cors"!==t.mode?i||s:void 0})),s&&o&&"no-cors"!==t.mode&&(this.P(),await e.cachePut(t,n.clone()))}return n}async O(t,e){this.P();const n=await e.fetch(t);if(!await e.cachePut(t,n.clone()))throw new s("bad-precaching-response",{url:t.url,status:n.status});return n}P(){let t=null,e=0;for(const[s,n]of this.plugins.entries())n!==O.copyRedirectedCacheableResponsesPlugin&&(n===O.defaultPrecacheCacheabilityPlugin&&(t=s),n.cacheWillUpdate&&e++);0===e?this.plugins.push(O.defaultPrecacheCacheabilityPlugin):e>1&&null!==t&&this.plugins.splice(t,1)}}O.defaultPrecacheCacheabilityPlugin={cacheWillUpdate:async({response:t})=>!t||t.status>=400?null:t},O.copyRedirectedCacheableResponsesPlugin={cacheWillUpdate:async({response:t})=>t.redirected?await x(t):t};class N{constructor({cacheName:t,plugins:e=[],fallbackToNetwork:s=!0}={}){this.k=new Map,this.T=new Map,this.j=new Map,this.u=new O({cacheName:w(t),plugins:[...e,new b({precacheController:this})],fallbackToNetwork:s}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this.u}precache(t){this.addToCacheList(t),this.K||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this.K=!0)}addToCacheList(t){const e=[];for(const n of t){"string"==typeof n?e.push(n):n&&void 0===n.revision&&e.push(n.url);const{cacheKey:t,url:r}=U(n),i="string"!=typeof n&&n.revision?"reload":"default";if(this.k.has(r)&&this.k.get(r)!==t)throw new s("add-to-cache-list-conflicting-entries",{firstEntry:this.k.get(r),secondEntry:t});if("string"!=typeof n&&n.integrity){if(this.j.has(t)&&this.j.get(t)!==n.integrity)throw new s("add-to-cache-list-conflicting-integrities",{url:r});this.j.set(t,n.integrity)}if(this.k.set(r,t),this.T.set(r,i),e.length>0){const t=`Workbox is precaching URLs without revision info: ${e.join(", ")}\nThis is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(t)}}}install(t){return q(t,async()=>{const e=new L;this.strategy.plugins.push(e);for(const[e,s]of this.k){const n=this.j.get(s),r=this.T.get(e),i=new Request(e,{integrity:n,cache:r,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:s},request:i,event:t}))}const{updatedURLs:s,notUpdatedURLs:n}=e;return{updatedURLs:s,notUpdatedURLs:n}})}activate(t){return q(t,async()=>{const t=await self.caches.open(this.strategy.cacheName),e=await t.keys(),s=new Set(this.k.values()),n=[];for(const r of e)s.has(r.url)||(await t.delete(r),n.push(r.url));return{deletedURLs:n}})}getURLsToCacheKeys(){return this.k}getCachedURLs(){return[...this.k.keys()]}getCacheKeyForURL(t){const e=new URL(t,location.href);return this.k.get(e.href)}getIntegrityForCacheKey(t){return this.j.get(t)}async matchPrecache(t){const e=t instanceof Request?t.url:t,s=this.getCacheKeyForURL(e);if(s){return(await self.caches.open(this.strategy.cacheName)).match(s)}}createHandlerBoundToURL(t){const e=this.getCacheKeyForURL(t);if(!e)throw new s("non-precached-url",{url:t});return s=>(s.request=new Request(t),s.params=Object.assign({cacheKey:e},s.params),this.strategy.handle(s))}}const P=()=>(C||(C=new N),C);class k extends r{constructor(t,e){super(({request:s})=>{const n=t.getURLsToCacheKeys();for(const r of function*(t,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:s="index.html",cleanURLs:n=!0,urlManipulation:r}={}){const i=new URL(t,location.href);i.hash="",yield i.href;const o=function(t,e=[]){for(const s of[...t.searchParams.keys()])e.some(t=>t.test(s))&&t.searchParams.delete(s);return t}(i,e);if(yield o.href,s&&o.pathname.endsWith("/")){const t=new URL(o.href);t.pathname+=s,yield t.href}if(n){const t=new URL(o.href);t.pathname+=".html",yield t.href}if(r){const t=r({url:i});for(const e of t)yield e.href}}(s.url,e)){const e=n.get(r);if(e){return{cacheKey:e,integrity:t.getIntegrityForCacheKey(e)}}}},t.strategy)}}t.NavigationRoute=class extends r{constructor(t,{allowlist:e=[/./],denylist:s=[]}={}){super(t=>this.W(t),t),this.M=e,this.S=s}W({url:t,request:e}){if(e&&"navigate"!==e.mode)return!1;const s=t.pathname+t.search;for(const t of this.S)if(t.test(s))return!1;return!!this.M.some(t=>t.test(s))}},t.NetworkOnly=class extends v{constructor(t={}){super(t),this.D=t.networkTimeoutSeconds||0}async L(t,e){let n,r;try{const s=[e.fetch(t)];if(this.D){const t=u(1e3*this.D);s.push(t)}if(r=await Promise.race(s),!r)throw new Error(`Timed out the network response after ${this.D} seconds.`)}catch(t){t instanceof Error&&(n=t)}if(!r)throw new s("no-response",{url:t.url,error:n});return r}},t.cleanupOutdatedCaches=function(){self.addEventListener("activate",t=>{const e=w();t.waitUntil((async(t,e="-precache-")=>{const s=(await self.caches.keys()).filter(s=>s.includes(e)&&s.includes(self.registration.scope)&&s!==t);return await Promise.all(s.map(t=>self.caches.delete(t))),s})(e).then(t=>{}))})},t.clientsClaim=function(){self.addEventListener("activate",()=>self.clients.claim())},t.createHandlerBoundToURL=function(t){return P().createHandlerBoundToURL(t)},t.precacheAndRoute=function(t,e){!function(t){P().precache(t)}(t),function(t){const e=P();h(new k(e,t))}(e)},t.registerRoute=h});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenrace",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Monitor en tiempo real para Claude Code",
5
5
  "bin": {
6
6
  "tokenrace": "bin/cli.js"