codexmeter 1.0.25 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/codexmeter.js CHANGED
@@ -7,20 +7,6 @@ import { createServer } from '../server/index.js';
7
7
 
8
8
  const defaultCodexHome = process.env.CODEX_HOME || path.join(os.homedir(), '.codex');
9
9
 
10
- function parseBooleanEnv(name, defaultValue = false) {
11
- const value = process.env[name];
12
- if (value == null || value === '') return defaultValue;
13
- const normalized = String(value).toLowerCase();
14
- if (['1', 'true', 'yes', 'on'].includes(normalized)) return true;
15
- if (['0', 'false', 'no', 'off'].includes(normalized)) return false;
16
- return defaultValue;
17
- }
18
-
19
- function parseNumberEnv(name, defaultValue = undefined) {
20
- const value = Number(process.env[name]);
21
- return Number.isFinite(value) && value > 0 ? value : defaultValue;
22
- }
23
-
24
10
  function parseIsoDateOption(name, value) {
25
11
  if (!value) return null;
26
12
  if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
@@ -52,29 +38,6 @@ if (from && to && from > to) {
52
38
  program.error('--from must be earlier than or equal to --to');
53
39
  }
54
40
 
55
- const ingestToggles = {
56
- ingestTiming: parseBooleanEnv('CODEXMETER_INGEST_TIMING'),
57
- workerThreads: parseNumberEnv('CODEXMETER_WORKER_THREADS'),
58
- batchSize: parseNumberEnv('CODEXMETER_BATCH_SIZE'),
59
- fastRolloutReader: parseBooleanEnv('CODEXMETER_FAST_ROLLOUT_READER'),
60
- rgRolloutReader: parseBooleanEnv('CODEXMETER_RG_ROLLOUT_READER', true),
61
- rgMinBytes: parseNumberEnv('CODEXMETER_RG_MIN_BYTES'),
62
- streamRolloutChunks: parseBooleanEnv('CODEXMETER_STREAM_ROLLOUT_CHUNKS', true),
63
- forkCorrectionConcurrency: parseNumberEnv('CODEXMETER_FORK_CORRECTION_CONCURRENCY', 32),
64
- resultChunkSize: parseNumberEnv('CODEXMETER_RESULT_CHUNK_SIZE'),
65
- recentFirstDays: parseNumberEnv('CODEXMETER_RECENT_FIRST_DAYS'),
66
- warmupOldestCount: parseNumberEnv('CODEXMETER_WARMUP_OLDEST_COUNT'),
67
- };
68
-
69
- const activeIngestToggles = Object.entries(ingestToggles)
70
- .filter(([, value]) => value !== false && value !== undefined);
71
- if (activeIngestToggles.length) {
72
- const label = activeIngestToggles
73
- .map(([key, value]) => `${key}=${value}`)
74
- .join(', ');
75
- console.log(`codexmeter ingest toggles: ${label}`);
76
- }
77
-
78
41
  const app = createServer(opts.codexHome, {
79
42
  from,
80
43
  to,
@@ -83,7 +46,6 @@ const app = createServer(opts.codexHome, {
83
46
  timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
84
47
  devApiOnly: process.env.CODEXMETER_DEV_API_ONLY === '1',
85
48
  frontendBaseUrl: process.env.CODEXMETER_FRONTEND_URL || null,
86
- ...ingestToggles,
87
49
  });
88
50
 
89
51
  const port = parseInt(opts.port, 10) || 0;
@@ -0,0 +1 @@
1
+ import{c as e,p as t,t as n}from"./index-Bxd44dxc.js";import{$ as r,$n as i,$t as a,A as o,An as s,At as c,B as l,Bn as u,Bt as d,C as f,Ct as p,D as m,Dn as h,Dt as g,E as _,En as v,Et as y,F as b,Fn as x,Ft as S,G as C,Gn as w,Gt as T,Hn as E,Ht as D,I as O,In as k,It as A,J as j,Jn as M,Jt as N,K as P,Kn as F,Kt as I,L,Ln as R,Lt as ee,M as z,Mn as B,Mt as te,N as ne,Nn as V,Nt as re,O as ie,On as ae,Ot as oe,P as se,Pn as ce,Pt as le,Q as ue,Qn as de,Qt as fe,R as pe,Rn as me,Rt as he,S as ge,Sn as _e,St as ve,T as ye,Tn as be,Tt as xe,U as Se,Un as Ce,Ut as we,V as Te,Vn as Ee,Vt as De,W as Oe,Wn as ke,Wt as Ae,X as je,Xn as Me,Xt as Ne,Y as Pe,Yn as Fe,Yt as Ie,Z as Le,Zn as Re,_ as ze,_n as Be,_t as Ve,an as He,at as Ue,b as We,bn as Ge,bt as Ke,cn as qe,ct as Je,dn as H,en as Ye,er as U,et as W,fn as Xe,ft as Ze,gn as Qe,gt as $e,h as et,hn as tt,ht as nt,in as rt,it,j as at,jn as G,jt as ot,k as st,kn as ct,kt as lt,ln as ut,lt as dt,mn as ft,mt as pt,nn as mt,nt as ht,on as gt,ot as _t,pn as vt,q as yt,qn as bt,qt as xt,rn as St,s as Ct,sn as wt,st as Tt,t as Et,tr as K,tt as Dt,un as Ot,ut as kt,v as At,vn as jt,vt as Mt,w as Nt,wt as Pt,x as Ft,xn as It,xt as Lt,y as Rt,yn as zt,z as Bt,zn as q,zt as Vt}from"./animationsDefault-C_urdfl6.js";import{c as Ht,l as Ut,t as Wt,u as Gt}from"./useDailyStackPresentationTween-BWv0dKwE.js";import{t as Kt}from"./formatters-lxlIPan_.js";import{n as qt,t as Jt}from"./subcharts-CA6MYRo3.js";K();var Yt=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.hasSymbolVisual=!0,n}return t.prototype.getInitialData=function(e){return Bt(null,this,{useEncodeDefaulter:!0})},t.prototype.getLegendIcon=function(e){var t=new zt,n=Se(`line`,0,e.itemHeight/2,e.itemWidth,0,e.lineStyle.stroke,!1);t.add(n),n.setStyle(e.lineStyle);var r=this.getData().getVisual(`symbol`),i=this.getData().getVisual(`symbolRotate`),a=r===`none`?`circle`:r,o=e.itemHeight*.8,s=Se(a,(e.itemWidth-o)/2,(e.itemHeight-o)/2,o,o,e.itemStyle.fill);return t.add(s),s.setStyle(e.itemStyle),s.rotation=(e.iconRotate===`inherit`?i:e.iconRotate||0)*Math.PI/180,s.setOrigin([e.itemWidth/2,e.itemHeight/2]),a.indexOf(`empty`)>-1&&(s.style.stroke=s.style.fill,s.style.fill=W.color.neutral00,s.style.lineWidth=2),t},t.type=`series.line`,t.dependencies=[`grid`,`polar`],t.defaultOption={z:3,coordinateSystem:`cartesian2d`,legendHoverLink:!0,clip:!0,label:{position:`top`},endLabel:{show:!1,valueAnimation:!0,distance:8},lineStyle:{width:2,type:`solid`},emphasis:{scale:!0},step:!1,smooth:!1,smoothMonotone:null,symbol:`emptyCircle`,symbolSize:6,symbolRotate:null,showSymbol:!0,showAllSymbol:`auto`,connectNulls:!1,sampling:`none`,animationEasing:`linear`,progressive:0,hoverLayerThreshold:1/0,universalTransition:{divideShape:`clone`},triggerLineEvent:!1,triggerEvent:!1},t}(r);K();var Xt=function(e){U(t,e);function t(t,n,r,i){var a=e.call(this)||this;return a.updateData(t,n,r,i),a}return t.prototype._createSymbol=function(e,t,n,r,i,a){this.removeAll();var o=Se(e,-1,-1,2,2,null,a);o.attr({z2:de(i,100),culling:!0,scaleX:r[0]/2,scaleY:r[1]/2}),o.drift=Zt,this._symbolType=e,this.add(o)},t.prototype.stopSymbolAnimation=function(e){this.childAt(0).stopAnimation(null,e)},t.prototype.getSymbolType=function(){return this._symbolType},t.prototype.getSymbolPath=function(){return this.childAt(0)},t.prototype.highlight=function(){A(this.childAt(0))},t.prototype.downplay=function(){ee(this.childAt(0))},t.prototype.setZ=function(e,t){var n=this.childAt(0);n.zlevel=e,n.z=t},t.prototype.setDraggable=function(e,t){var n=this.childAt(0);n.draggable=e,n.cursor=!t&&e?`move`:n.cursor},t.prototype.updateData=function(e,n,r,i){this.silent=!1;var a=e.getItemVisual(n,`symbol`)||`circle`,o=e.hostModel,s=t.getSymbolSize(e,n),l=t.getSymbolZ2(e,n),u=a!==this._symbolType,d=i&&i.disableAnimation;if(u){var f=e.getItemVisual(n,`symbolKeepAspect`);this._createSymbol(a,e,n,s,l,f)}else{var p=this.childAt(0);p.silent=!1;var m={scaleX:s[0]/2,scaleY:s[1]/2};d?p.attr(m):c(p,m,o,n),lt(p)}if(this._updateCommon(e,n,s,r,i),u){var p=this.childAt(0);if(!d){var m={scaleX:this._sizeX,scaleY:this._sizeY,style:{opacity:p.style.opacity}};p.scaleX=p.scaleY=0,p.style.opacity=0,g(p,m,o,n)}}d&&this.childAt(0).stopAnimation(`leave`)},t.prototype._updateCommon=function(e,t,n,r,i){var a=this.childAt(0),o=e.hostModel,s,c,l,u,f,p,m,h,g;if(r&&(s=r.emphasisItemStyle,c=r.blurItemStyle,l=r.selectItemStyle,u=r.focus,f=r.blurScope,m=r.labelStatesModels,h=r.hoverScale,g=r.cursorStyle,p=r.emphasisDisabled),!r||e.hasItemOption){var _=r&&r.itemModel?r.itemModel:e.getItemModel(t),v=_.getModel(`emphasis`);s=v.getModel(`itemStyle`).getItemStyle(),l=_.getModel([`select`,`itemStyle`]).getItemStyle(),c=_.getModel([`blur`,`itemStyle`]).getItemStyle(),u=v.get(`focus`),f=v.get(`blurScope`),p=v.get(`disabled`),m=nt(_),h=v.getShallow(`scale`),g=_.getShallow(`cursor`)}var y=e.getItemVisual(t,`symbolRotate`);a.attr(`rotation`,(y||0)*Math.PI/180||0);var b=Oe(e.getItemVisual(t,`symbolOffset`),n);b&&(a.x=b[0],a.y=b[1]),g&&a.attr(`cursor`,g);var x=e.getItemVisual(t,`style`),S=x.fill;if(a instanceof Ae){var C=a.style;a.useStyle(R({image:C.image,x:C.x,y:C.y,width:C.width,height:C.height},x))}else a.__isEmptyBrush?a.useStyle(R({},x)):a.useStyle(x),a.style.decal=null,a.setColor(S,i&&i.symbolInnerColor),a.style.strokeNoScale=!0;var w=e.getItemVisual(t,`liftZ`),T=this._z2;w==null?T!=null&&(a.z2=T,this._z2=null):T??(this._z2=a.z2,a.z2+=w);var E=i&&i.useNameLabel;Ve(a,m,{labelFetcher:o,labelDataIndex:t,defaultText:D,inheritColor:S,defaultOpacity:x.opacity});function D(t){return E?e.getName(t):z(e,t)}this._sizeX=n[0]/2,this._sizeY=n[1]/2;var O=a.ensureState(`emphasis`);O.style=s,a.ensureState(`select`).style=l,a.ensureState(`blur`).style=c;var k=h==null||h===!0?Math.max(1.1,3/this._sizeY):isFinite(h)&&h>0?+h:1;O.scaleX=this._sizeX*k,O.scaleY=this._sizeY*k,this.setSymbolScale(1),d(this,u,f,p)},t.prototype.setSymbolScale=function(e){this.scaleX=this.scaleY=e},t.prototype.fadeOut=function(e,t,n){var r=this.childAt(0),i=De(this).dataIndex,a=n&&n.animation;if(this.silent=r.silent=!0,n&&n.fadeLabel){var o=r.getTextContent();o&&oe(o,{style:{opacity:0}},t,{dataIndex:i,removeOpt:a,cb:function(){r.removeTextContent()}})}else r.removeTextContent();oe(r,{style:{opacity:0},scaleX:0,scaleY:0},t,{dataIndex:i,cb:e,removeOpt:a})},t.getSymbolSize=function(e,t){return C(e.getItemVisual(t,`symbolSize`))},t.getSymbolZ2=function(e,t){return e.getItemVisual(t,`z2`)},t}(zt);function Zt(e,t){this.parent.drift(e,t)}function Qt(e,t,n,r){return t&&!isNaN(t[0])&&!isNaN(t[1])&&!(r&&r.isIgnore&&r.isIgnore(n))&&!(r&&r.clipShape&&!r.clipShape.contain(t[0],t[1]))&&e.getItemVisual(n,`symbol`)!==`none`}function $t(e){return e!=null&&!w(e)&&(e={isIgnore:e}),e||{}}function en(e){var t=e.hostModel,n=t.getModel(`emphasis`);return{emphasisItemStyle:n.getModel(`itemStyle`).getItemStyle(),blurItemStyle:t.getModel([`blur`,`itemStyle`]).getItemStyle(),selectItemStyle:t.getModel([`select`,`itemStyle`]).getItemStyle(),focus:n.get(`focus`),blurScope:n.get(`blurScope`),emphasisDisabled:n.get(`disabled`),hoverScale:n.get(`scale`),labelStatesModels:nt(t),cursorStyle:t.get(`cursor`)}}function tn(e,t,n,r,i,a,o){var s=new e(t,n,r,i);return s.setPosition(a),t.setItemGraphicEl(n,s),o.add(s),s}var nn=function(){function e(e){this.group=new zt,this._SymbolCtor=e||Xt}return e.prototype.updateData=function(e,t){this._progressiveEls=null,t=$t(t);var n=this.group,r=e.hostModel,i=this._data,a=this._SymbolCtor,o=t.disableAnimation,s=this._seriesScope=en(e),l={disableAnimation:o},u=t.getSymbolPoint||function(t){return e.getItemLayout(t)};i||n.removeAll(),e.diff(i).add(function(r){var i=u(r);Qt(e,i,r,t)&&tn(a,e,r,s,l,i,n)}).update(function(d,f){var p=i.getItemGraphicEl(f),m=u(d);if(!Qt(e,m,d,t)){n.remove(p);return}var h=e.getItemVisual(d,`symbol`)||`circle`,g=p&&p.getSymbolType&&p.getSymbolType();if(!p||g&&g!==h)n.remove(p),p=new a(e,d,s,l),p.setPosition(m);else{p.updateData(e,d,s,l);var _={x:m[0],y:m[1]};o?p.attr(_):c(p,_,r)}n.add(p),e.setItemGraphicEl(d,p)}).remove(function(e){var t=i.getItemGraphicEl(e);t&&t.fadeOut(function(){n.remove(t)},r)}).execute(),this._getSymbolPoint=u,this._data=e},e.prototype.updateLayout=function(e){var t=this._data;if(t)for(var n=this,r=t.getStore(),i=0,a=r.count();i<a;i++){var o=t.getItemGraphicEl(i),s=n._getSymbolPoint(i);Qt(t,s,i,e)?(o||=tn(n._SymbolCtor,t,i,n._seriesScope,{disableAnimation:!0},s,n.group),o.stopAnimation(),o.setPosition(s),o.markRedraw()):o&&(n.group.remove(o),t.setItemGraphicEl(i,null))}},e.prototype.incrementalPrepareUpdate=function(e){this._seriesScope=en(e),this._data=null,this.group.removeAll()},e.prototype.incrementalUpdate=function(e,t,n,r){this._progressiveEls=[],r=$t(r);function i(e){e.isGroup||(e.incremental=n,e.ensureState(`emphasis`).hoverLayer=2)}for(var a=e.start;a<e.end;a++){var o=t.getItemLayout(a);if(Qt(t,o,a,r)){var s=new this._SymbolCtor(t,a,this._seriesScope);s.traverse(i),s.setPosition(o),this.group.add(s),t.setItemGraphicEl(a,s),this._progressiveEls.push(s)}}},e.prototype.eachRendered=function(e){xe(this._progressiveEls||this.group,e)},e.prototype.remove=function(e){var t=this.group,n=this._data;n&&e?n.eachItemGraphicEl(function(e){e.fadeOut(function(){t.remove(e)},n.hostModel)}):t.removeAll()},e}();function rn(e,t,n){var r=e.getBaseAxis(),i=e.getOtherAxis(r),a=an(i,n),o=r.dim,s=i.dim,c=t.mapDimension(s),u=t.mapDimension(o),d=+(s===`x`||s===`radius`),f=M(e.dimensions,function(e){return t.mapDimension(e)}),p=!1,m=t.getCalculationInfo(`stackResultDimension`);return l(t,f[0])&&(p=!0,f[0]=m),l(t,f[1])&&(p=!0,f[1]=m),{dataDimsForPoint:f,valueStart:a,valueAxisDim:s,baseAxisDim:o,stacked:!!p,valueDim:c,baseDim:u,baseDataOffset:d,stackedOverDimension:t.getCalculationInfo(`stackedOverDimension`)}}function an(e,t){var n=0,r=e.scale.getExtent();return t===`start`?n=r[0]:t===`end`?n=r[1]:ke(t)&&!isNaN(t)?n=t:r[0]>0?n=r[0]:r[1]<0&&(n=r[1]),n}function on(e,t,n,r){var i=NaN;e.stacked&&(i=n.get(n.getCalculationInfo(`stackedOverDimension`),r)),isNaN(i)&&(i=e.valueStart);var a=e.baseDataOffset,o=[];return o[a]=n.get(e.baseDim,r),o[1-a]=i,t.dataToPoint(o)}function J(e,t){return!isFinite(e)||!isFinite(t)}function sn(e,t){var n=[];return t.diff(e).add(function(e){n.push({cmd:`+`,idx:e})}).update(function(e,t){n.push({cmd:`=`,idx:t,idx1:e})}).remove(function(e){n.push({cmd:`-`,idx:e})}).execute(),n}function cn(e,t,n,r,i,a,s,c){for(var l=sn(e,t),u=[],d=[],f=[],p=[],m=[],h=[],g=[],_=rn(i,t,s),v=e.getLayout(`points`)||[],y=t.getLayout(`points`)||[],b=0;b<l.length;b++){var x=l[b],S=!0,C=void 0,w=void 0;switch(x.cmd){case`=`:C=x.idx*2,w=x.idx1*2;var T=v[C],E=v[C+1],D=y[w],O=y[w+1];(isNaN(T)||isNaN(E))&&(T=D,E=O),u.push(T,E),d.push(D,O),f.push(n[C],n[C+1]),p.push(r[w],r[w+1]),g.push(t.getRawIndex(x.idx1));break;case`+`:var k=x.idx,A=_.dataDimsForPoint,j=i.dataToPoint([t.get(A[0],k),t.get(A[1],k)]);w=k*2,u.push(j[0],j[1]),d.push(y[w],y[w+1]);var M=on(_,i,t,k);f.push(M[0],M[1]),p.push(r[w],r[w+1]),g.push(t.getRawIndex(k));break;case`-`:S=!1}S&&(m.push(x),h.push(h.length))}h.sort(function(e,t){return g[e]-g[t]});for(var N=u.length,P=o(N),F=o(N),I=o(N),L=o(N),R=[],b=0;b<h.length;b++){var ee=h[b],z=b*2,B=ee*2;P[z]=u[B],P[z+1]=u[B+1],F[z]=d[B],F[z+1]=d[B+1],I[z]=f[B],I[z+1]=f[B+1],L[z]=p[B],L[z+1]=p[B+1],R[b]=m[ee]}return{current:P,next:F,stackedOnCurrent:I,stackedOnNext:L,status:R}}K();var ln=Math.min,un=Math.max;function dn(e,t,n,r,i,a,o,s,c){for(var l,u,d,f,p,m,h=n,g=0;g<r;g++){var _=t[h*2],v=t[h*2+1];if(h>=i||h<0)break;if(J(_,v)){if(c){h+=a;continue}break}if(h===n)e[a>0?`moveTo`:`lineTo`](_,v),d=_,f=v;else{var y=_-l,b=v-u;if(y*y+b*b<.5){h+=a;continue}if(o>0){for(var x=h+a,S=t[x*2],C=t[x*2+1];S===_&&C===v&&g<r;)g++,x+=a,h+=a,S=t[x*2],C=t[x*2+1],_=t[h*2],v=t[h*2+1],y=_-l,b=v-u;var w=g+1;if(c)for(;J(S,C)&&w<r;)w++,x+=a,S=t[x*2],C=t[x*2+1];var T=.5,E=0,D=0,O=void 0,k=void 0;if(w>=r||J(S,C))p=_,m=v;else{E=S-l,D=C-u;var A=_-l,j=S-_,M=v-u,N=C-v,P=void 0,F=void 0;if(s===`x`){P=Math.abs(A),F=Math.abs(j);var I=E>0?1:-1;p=_-I*P*o,m=v,O=_+I*F*o,k=v}else if(s===`y`){P=Math.abs(M),F=Math.abs(N);var L=D>0?1:-1;p=_,m=v-L*P*o,O=_,k=v+L*F*o}else P=Math.sqrt(A*A+M*M),F=Math.sqrt(j*j+N*N),T=F/(F+P),p=_-E*o*(1-T),m=v-D*o*(1-T),O=_+E*o*T,k=v+D*o*T,O=ln(O,un(S,_)),k=ln(k,un(C,v)),O=un(O,ln(S,_)),k=un(k,ln(C,v)),E=O-_,D=k-v,p=_-E*P/F,m=v-D*P/F,p=ln(p,un(l,_)),m=ln(m,un(u,v)),p=un(p,ln(l,_)),m=un(m,ln(u,v)),E=_-p,D=v-m,O=_+E*F/P,k=v+D*F/P}e.bezierCurveTo(d,f,p,m,_,v),d=O,f=k}else e.lineTo(_,v)}l=_,u=v,h+=a}return g}var fn=function(){function e(){this.smooth=0,this.smoothConstraint=!0}return e}(),pn=function(e){U(t,e);function t(t){var n=e.call(this,t)||this;return n.type=`ec-polyline`,n}return t.prototype.getDefaultStyle=function(){return{stroke:W.color.neutral99,fill:null}},t.prototype.getDefaultShape=function(){return new fn},t.prototype.buildPath=function(e,t){var n=t.points,r=0,i=n.length/2;if(t.connectNulls){for(;i>0&&J(n[i*2-2],n[i*2-1]);i--);for(;r<i&&J(n[r*2],n[r*2+1]);r++);}for(;r<i;)r+=dn(e,n,r,i,i,1,t.smooth,t.smoothMonotone,t.connectNulls)+1},t.prototype.getPointOn=function(e,t){this.path||(this.createPathProxy(),this.buildPath(this.path,this.shape));for(var n=this.path.data,r=I.CMD,i,a,o=t===`x`,s=[],c=0;c<n.length;){var l=n[c++],u=void 0,d=void 0,f=void 0,p=void 0,m=void 0,h=void 0,g=void 0;switch(l){case r.M:i=n[c++],a=n[c++];break;case r.L:if(u=n[c++],d=n[c++],g=o?(e-i)/(u-i):(e-a)/(d-a),g<=1&&g>=0){var _=o?(d-a)*g+a:(u-i)*g+i;return o?[e,_]:[_,e]}i=u,a=d;break;case r.C:u=n[c++],d=n[c++],f=n[c++],p=n[c++],m=n[c++],h=n[c++];var y=o?v(i,u,f,m,e,s):v(a,d,p,h,e,s);if(y>0)for(var b=0;b<y;b++){var x=s[b];if(x<=1&&x>=0){var _=o?be(a,d,p,h,x):be(i,u,f,m,x);return o?[e,_]:[_,e]}}i=m,a=h;break}}},t}(T),mn=function(e){U(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(fn),hn=function(e){U(t,e);function t(t){var n=e.call(this,t)||this;return n.type=`ec-polygon`,n}return t.prototype.getDefaultShape=function(){return new mn},t.prototype.buildPath=function(e,t){var n=t.points,r=t.stackedOnPoints,i=0,a=n.length/2,o=t.smoothMonotone;if(t.connectNulls){for(;a>0&&J(n[a*2-2],n[a*2-1]);a--);for(;i<a&&J(n[i*2],n[i*2+1]);i++);}for(;i<a;){var s=dn(e,n,i,a,a,1,t.smooth,o,t.connectNulls);dn(e,r,i+s-1,s,a,-1,t.stackedOnSmooth,o,t.connectNulls),i+=s+1,e.closePath()}},t}(T);function gn(e,t,n,r){return e&&(e.legacy||e.legacy!==!1&&!n&&!r&&t!==`tspan`&&(t===`text`||q(e,`text`)))}function _n(e,t,n){var r=e,i,a,o;if(t===`text`)o=r;else{o={},q(r,`text`)&&(o.text=r.text),q(r,`rich`)&&(o.rich=r.rich),q(r,`textFill`)&&(o.fill=r.textFill),q(r,`textStroke`)&&(o.stroke=r.textStroke),q(r,`fontFamily`)&&(o.fontFamily=r.fontFamily),q(r,`fontSize`)&&(o.fontSize=r.fontSize),q(r,`fontStyle`)&&(o.fontStyle=r.fontStyle),q(r,`fontWeight`)&&(o.fontWeight=r.fontWeight),a={type:`text`,style:o,silent:!0},i={};var s=q(r,`textPosition`);n?i.position=s?r.textPosition:`inside`:s&&(i.position=r.textPosition),q(r,`textPosition`)&&(i.position=r.textPosition),q(r,`textOffset`)&&(i.offset=r.textOffset),q(r,`textRotation`)&&(i.rotation=r.textRotation),q(r,`textDistance`)&&(i.distance=r.textDistance)}return vn(o,e),k(o.rich,function(e){vn(e,e)}),{textConfig:i,textContent:a}}function vn(e,t){t&&(t.font=t.textFont||t.font,q(t,`textStrokeWidth`)&&(e.lineWidth=t.textStrokeWidth),q(t,`textAlign`)&&(e.align=t.textAlign),q(t,`textVerticalAlign`)&&(e.verticalAlign=t.textVerticalAlign),q(t,`textLineHeight`)&&(e.lineHeight=t.textLineHeight),q(t,`textWidth`)&&(e.width=t.textWidth),q(t,`textHeight`)&&(e.height=t.textHeight),q(t,`textBackgroundColor`)&&(e.backgroundColor=t.textBackgroundColor),q(t,`textPadding`)&&(e.padding=t.textPadding),q(t,`textBorderColor`)&&(e.borderColor=t.textBorderColor),q(t,`textBorderWidth`)&&(e.borderWidth=t.textBorderWidth),q(t,`textBorderRadius`)&&(e.borderRadius=t.textBorderRadius),q(t,`textBoxShadowColor`)&&(e.shadowColor=t.textBoxShadowColor),q(t,`textBoxShadowBlur`)&&(e.shadowBlur=t.textBoxShadowBlur),q(t,`textBoxShadowOffsetX`)&&(e.shadowOffsetX=t.textBoxShadowOffsetX),q(t,`textBoxShadowOffsetY`)&&(e.shadowOffsetY=t.textBoxShadowOffsetY))}K();function yn(e,t){if(e.length===t.length){for(var n=0;n<e.length;n++)if(e[n]!==t[n])return;return!0}}function bn(e){for(var t=a(),n=a(),r=0;r<e.length;){var i=e[r++],o=e[r++];J(i,o)||(wt(t,i),wt(n,o))}return[t,n]}function xn(e,t){var n=bn(e),r=n[0],i=n[1],a=bn(t),o=a[0],s=a[1];return Math.max(Math.abs(r[0]-o[0]),Math.abs(i[0]-s[0]),Math.abs(r[1]-o[1]),Math.abs(i[1]-s[1]))}function Sn(e){return ke(e)?e:e?.5:0}function Cn(e,t,n){if(n.valueDim==null)return[];for(var r=t.count(),i=o(r*2),a=0;a<r;a++){var s=on(n,e,t,a);i[a*2]=s[0],i[a*2+1]=s[1]}return i}function wn(e,t,n,r,i){var a=n.getBaseAxis(),o=a.dim===`x`||a.dim===`radius`?0:1,s=[],c=0,l=[],u=[],d=[],f=[];if(i){for(c=0;c<e.length;c+=2){var p=t||e;J(p[c],p[c+1])||f.push(e[c],e[c+1])}e=f}for(c=0;c<e.length-2;c+=2)switch(d[0]=e[c+2],d[1]=e[c+3],u[0]=e[c],u[1]=e[c+1],s.push(u[0],u[1]),r){case`end`:l[o]=d[o],l[1-o]=u[1-o],s.push(l[0],l[1]);break;case`middle`:var m=(u[o]+d[o])/2,h=[];l[o]=h[o]=m,l[1-o]=u[1-o],h[1-o]=d[1-o],s.push(l[0],l[1]),s.push(h[0],h[1]);break;default:l[o]=u[o],l[1-o]=d[1-o],s.push(l[0],l[1])}return s.push(e[c++],e[c++]),s}function Tn(e,t){var n=[],r=e.length,i,a;function o(e,t,n){var r=e.coord;return{coord:n,color:_e((n-r)/(t.coord-r),[e.color,t.color])}}for(var s=0;s<r;s++){var c=e[s],l=c.coord;if(l<0)i=c;else if(l>t){a?n.push(o(a,c,t)):i&&n.push(o(i,c,0),o(i,c,t));break}else i&&=(n.push(o(i,c,0)),null),n.push(c),a=c}return n}function En(e,t,n){var r=e.getVisual(`visualMeta`);if(!(!r||!r.length||!e.count())&&t.type===`cartesian2d`){for(var i,a,o=r.length-1;o>=0;o--){var s=e.getDimensionInfo(r[o].dimension);if(i=s&&s.coordDim,i===`x`||i===`y`){a=r[o];break}}if(a){var c=t.getAxis(i),l=M(a.stops,function(e){return{coord:c.toGlobalCoord(c.dataToCoord(e.value)),color:e.color}}),u=l.length,d=a.outerColors.slice();u&&l[0].coord>l[u-1].coord&&(l.reverse(),d.reverse());var f=Tn(l,i===`x`?n.getWidth():n.getHeight()),p=f.length;if(!p&&u)return l[0].coord<0?d[1]?d[1]:l[u-1].color:d[0]?d[0]:l[0].color;var m=10,h=f[0].coord-m,g=f[p-1].coord+m,_=g-h;if(_<.001)return`transparent`;k(f,function(e){e.offset=(e.coord-h)/_}),f.push({offset:p?f[p-1].offset:.5,color:d[1]||`transparent`}),f.unshift({offset:p?f[0].offset:.5,color:d[0]||`transparent`});var v=new ot(0,0,0,0,f,!0);return v[i]=h,v[i+`2`]=g,v}}}function Dn(e,t,n){var r=e.get(`showAllSymbol`),i=r===`auto`;if(!(r&&!i)){var a=n.getAxesByScale(`ordinal`)[0];if(a&&!(i&&On(a,t))){var o=t.mapDimension(a.dim),s={};return k(a.getViewLabels(),function(e){e.tick.offInterval||(s[O(a.scale,e.tick)]=1)}),function(e){return!s.hasOwnProperty(t.get(o,e))}}}}function On(e,t){var n=e.getExtent(),r=Math.abs(n[1]-n[0])/e.scale.count();isNaN(r)&&(r=0);for(var i=t.count(),a=Math.max(1,Math.round(i/5)),o=0;o<i;o+=a)if(Xt.getSymbolSize(t,o)[+!!e.isHorizontal()]*1.5>r)return!1;return!0}function kn(e){for(var t=e.length/2;t>0&&J(e[t*2-2],e[t*2-1]);t--);return t-1}function An(e,t){return[e[t*2],e[t*2+1]]}function jn(e,t,n){for(var r=e.length/2,i=n===`x`?0:1,a,o,s=0,c=-1,l=0;l<r;l++)if(o=e[l*2+i],!J(o,e[l*2+1-i])){if(l===0){a=o;continue}if(a<=t&&o>=t||a>=t&&o<=t){c=l;break}s=l,a=o}return{range:[s,c],t:(t-a)/(o-a)}}function Mn(e){if(e.get([`endLabel`,`show`]))return!0;for(var t=0;t<le.length;t++)if(e.get([le[t],`endLabel`,`show`]))return!0;return!1}function Nn(e,t,n,r){if(m(t,`cartesian2d`)){var i=r.getModel(`endLabel`),a=i.get(`valueAnimation`),o=r.getData(),s={lastFrameIndex:0},c=Mn(r)?function(n,r){e._endLabelOnDuring(n,r,o,s,a,i,t)}:null,l=t.getBaseAxis().isHorizontal(),u=ie(t,n,r,function(){var t=e._endLabel;t&&n&&s.originalX!=null&&t.attr({x:s.originalX,y:s.originalY})},c);if(!r.get(`clip`,!0)){var d=u.shape,f=Math.max(d.width,d.height);l?(d.y-=f,d.height+=f*2):(d.x-=f,d.width+=f*2)}return c&&c(1,u),u}else return st(t,n,r)}function Pn(e,t){var n=t.getBaseAxis(),r=n.isHorizontal(),i=n.inverse,a=r?i?`right`:`left`:`center`,o=r?`middle`:i?`top`:`bottom`;return{normal:{align:e.get(`align`)||a,verticalAlign:e.get(`verticalAlign`)||o}}}var Fn=function(e){U(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.init=function(){var e=new zt,t=new nn;this.group.add(t.group),this._symbolDraw=t,this._lineGroup=e,this._changePolyState=G(this._changePolyState,this)},t.prototype.render=function(e,t,n){var r=e.coordinateSystem,i=this.group,a=e.getData(),o=e.getModel(`lineStyle`),s=e.getModel(`areaStyle`),c=a.getLayout(`points`)||[],l=r.type===`polar`,u=this._coordSys,f=this._symbolDraw,p=this._polyline,m=this._polygon,h=this._lineGroup,_=!t.ssr&&e.get(`animation`),v=!s.isEmpty(),y=s.get(`origin`),b=rn(r,a,y),S=v&&Cn(r,a,b),C=e.get(`showSymbol`),w=e.get(`connectNulls`),T=C&&!l&&Dn(e,a,r),E=this._data;E&&E.eachItemGraphicEl(function(e,t){e.__temp&&(i.remove(e),E.setItemGraphicEl(t,null))}),C||f.remove(),i.add(h);var D=l?!1:e.get(`step`),O;r&&r.getArea&&e.get(`clip`,!0)&&(O=r.getArea(),O.width==null?O.r0&&(O.r0-=.5,O.r+=.5):(O.x-=.1,O.y-=.1,O.width+=.2,O.height+=.2)),this._clipShapeForSymbol=O;var k=En(a,r,n)||a.getVisual(`style`)[a.getVisual(`drawType`)];if(!(p&&u.type===r.type&&D===this._step))C&&f.updateData(a,{isIgnore:T,clipShape:O,disableAnimation:!0,getSymbolPoint:function(e){return[c[e*2],c[e*2+1]]}}),_&&this._initSymbolLabelAnimation(a,r,O),D&&(S&&=wn(S,c,r,D,w),c=wn(c,null,r,D,w)),p=this._newPolyline(c),v?m=this._newPolygon(c,S):m&&=(h.remove(m),this._polygon=null),l||this._initOrUpdateEndLabel(e,r,kt(k)),h.setClipPath(Nn(this,r,!0,e));else{v&&!m?m=this._newPolygon(c,S):m&&!v&&(h.remove(m),m=this._polygon=null),l||this._initOrUpdateEndLabel(e,r,kt(k));var A=h.getClipPath();A?g(A,{shape:Nn(this,r,!1,e).shape},e):h.setClipPath(Nn(this,r,!0,e)),C&&f.updateData(a,{isIgnore:T,clipShape:O,disableAnimation:!0,getSymbolPoint:function(e){return[c[e*2],c[e*2+1]]}}),(!yn(this._stackedOnPoints,S)||!yn(this._points,c))&&(_?this._doUpdateAnimation(a,S,r,n,D,y,w):(D&&(S&&=wn(S,c,r,D,w),c=wn(c,null,r,D,w)),p.setShape({points:c}),m&&m.setShape({points:c,stackedOnPoints:S})))}var j=e.getModel(`emphasis`),M=j.get(`focus`),N=j.get(`blurScope`),P=j.get(`disabled`);if(p.useStyle(x(o.getLineStyle(),{fill:`none`,stroke:k,lineJoin:`bevel`})),Vt(p,e,`lineStyle`),p.style.lineWidth>0&&e.get([`emphasis`,`lineStyle`,`width`])===`bolder`){var F=p.getState(`emphasis`).style;F.lineWidth=+p.style.lineWidth+1}De(p).seriesIndex=e.seriesIndex,d(p,M,N,P);var I=Sn(e.get(`smooth`)),L=e.get(`smoothMonotone`);if(p.setShape({smooth:I,smoothMonotone:L,connectNulls:w}),m){var R=a.getCalculationInfo(`stackedOnSeries`),ee=0;m.useStyle(x(s.getAreaStyle(),{fill:k,opacity:.7,lineJoin:`bevel`,decal:a.getVisual(`style`).decal})),R&&(ee=Sn(R.get(`smooth`))),m.setShape({smooth:I,stackedOnSmooth:ee,smoothMonotone:L,connectNulls:w}),Vt(m,e,`areaStyle`),De(m).seriesIndex=e.seriesIndex,d(m,M,N,P)}var z=this._changePolyState;a.eachItemGraphicEl(function(e){e&&(e.onHoverStateChange=z)}),this._polyline.onHoverStateChange=z,this._data=a,this._coordSys=r,this._stackedOnPoints=S,this._points=c,this._step=D,this._valueOrigin=y;var B=e.get(`triggerEvent`),te=e.get(`triggerLineEvent`),ne=te===!0||B===!0||B===`line`,V=te===!0||B===!0||B===`area`;this.packEventData(e,p,ne),m&&this.packEventData(e,m,V)},t.prototype.packEventData=function(e,t,n){De(t).eventData=n?{componentType:`series`,componentSubType:`line`,componentIndex:e.componentIndex,seriesIndex:e.seriesIndex,seriesName:e.name,seriesType:`line`,selfType:t===this._polygon?`area`:`line`}:null},t.prototype.highlight=function(e,t,n,r){var i=e.getData(),a=gt(i,r);if(this._changePolyState(`emphasis`),!(a instanceof Array)&&a!=null&&a>=0){var o=i.getLayout(`points`),s=i.getItemGraphicEl(a);if(!s){var c=o[a*2],l=o[a*2+1];if(J(c,l)||this._clipShapeForSymbol&&!this._clipShapeForSymbol.contain(c,l))return;var u=e.get(`zlevel`)||0,d=e.get(`z`)||0;s=new Xt(i,a),s.x=c,s.y=l,s.setZ(u,d);var f=s.getSymbolPath().getTextContent();f&&(f.zlevel=u,f.z=d,f.z2=this._polyline.z2+1),s.__temp=!0,i.setItemGraphicEl(a,s),s.stopSymbolAnimation(!0),this.group.add(s)}s.highlight()}else je.prototype.highlight.call(this,e,t,n,r)},t.prototype.downplay=function(e,t,n,r){var i=e.getData(),a=gt(i,r);if(this._changePolyState(`normal`),a!=null&&a>=0){var o=i.getItemGraphicEl(a);o&&(o.__temp?(i.setItemGraphicEl(a,null),this.group.remove(o)):o.downplay())}else je.prototype.downplay.call(this,e,t,n,r)},t.prototype._changePolyState=function(e){var t=this._polygon;he(this._polyline,e),t&&he(t,e)},t.prototype._newPolyline=function(e){var t=this._polyline;return t&&this._lineGroup.remove(t),t=new pn({shape:{points:e},segmentIgnoreThreshold:2,z2:10}),this._lineGroup.add(t),this._polyline=t,t},t.prototype._newPolygon=function(e,t){var n=this._polygon;return n&&this._lineGroup.remove(n),n=new hn({shape:{points:e,stackedOnPoints:t},segmentIgnoreThreshold:2}),this._lineGroup.add(n),this._polygon=n,n},t.prototype._initSymbolLabelAnimation=function(e,t,n){var r,i,a=t.getBaseAxis(),o=a.inverse;t.type===`cartesian2d`?(r=a.isHorizontal(),i=!1):t.type===`polar`&&(r=a.dim===`angle`,i=!0);var s=e.hostModel,c=s.get(`animationDuration`);Ce(c)&&(c=c(null));var l=s.get(`animationDelay`)||0,u=Ce(l)?l(null):l;e.eachItemGraphicEl(function(e,a){var s=e;if(s){var d=[e.x,e.y],f=void 0,p=void 0,m=void 0;if(n)if(i){var h=n,g=t.pointToCoord(d);r?(f=h.startAngle,p=h.endAngle,m=-g[1]/180*Math.PI):(f=h.r0,p=h.r,m=g[0])}else{var _=n;r?(f=_.x,p=_.x+_.width,m=e.x):(f=_.y+_.height,p=_.y,m=e.y)}var v=p===f?0:(m-f)/(p-f);o&&(v=1-v);var y=Ce(l)?l(a):c*v+u,b=s.getSymbolPath(),x=b.getTextContent();s.attr({scaleX:0,scaleY:0}),s.animateTo({scaleX:1,scaleY:1},{duration:200,setToFinal:!0,delay:y}),x&&x.animateFrom({style:{opacity:0}},{duration:300,delay:y}),b.disableLabelAnimation=!0}})},t.prototype._initOrUpdateEndLabel=function(e,t,n){var r=e.getModel(`endLabel`);if(Mn(e)){var i=e.getData(),a=this._polyline,o=i.getLayout(`points`);if(!o){a.removeTextContent(),this._endLabel=null;return}var s=this._endLabel;s||(s=this._endLabel=new D({z2:200}),s.ignoreClip=!0,a.setTextContent(this._endLabel),a.disableLabelAnimation=!0);var c=kn(o);c>=0&&(Ve(a,nt(e,`endLabel`),{inheritColor:n,labelFetcher:e,labelDataIndex:c,defaultText:function(e,t,n){return n==null?z(i,e):at(i,n)},enableTextSetter:!0},Pn(r,t)),a.textConfig.position=null)}else this._endLabel&&=(this._polyline.removeTextContent(),null)},t.prototype._endLabelOnDuring=function(e,t,n,r,i,a,o){var s=this._endLabel,c=this._polyline;if(s){e<1&&r.originalX==null&&(r.originalX=s.x,r.originalY=s.y);var l=n.getLayout(`points`),u=n.hostModel,d=u.get(`connectNulls`),f=a.get(`precision`),p=a.get(`distance`)||0,m=o.getBaseAxis(),h=m.isHorizontal(),g=m.inverse,_=t.shape,v=g?h?_.x:_.y+_.height:h?_.x+_.width:_.y,y=(h?p:0)*(g?-1:1),b=(h?0:-p)*(g?-1:1),x=h?`x`:`y`,S=jn(l,v,x),C=S.range,w=C[1]-C[0],T=void 0;if(w>=1){if(w>1&&!d){var E=An(l,C[0]);s.attr({x:E[0]+y,y:E[1]+b}),i&&(T=u.getRawValue(C[0]))}else{var E=c.getPointOn(v,x);E&&s.attr({x:E[0]+y,y:E[1]+b});var D=u.getRawValue(C[0]),O=u.getRawValue(C[1]);i&&(T=Ye(n,f,D,O,S.t))}r.lastFrameIndex=C[0]}else{var k=e===1||r.lastFrameIndex>0?C[0]:0,E=An(l,k);i&&(T=u.getRawValue(k)),s.attr({x:E[0]+y,y:E[1]+b})}if(i){var A=$e(s);typeof A.setLabelText==`function`&&A.setLabelText(T)}}},t.prototype._doUpdateAnimation=function(e,t,n,r,i,a,o){var s=this._polyline,l=this._polygon,u=e.hostModel,d=cn(this._data,e,this._stackedOnPoints,t,this._coordSys,n,this._valueOrigin,a),f=d.current,p=d.stackedOnCurrent,m=d.next,h=d.stackedOnNext;if(i&&(p=wn(d.stackedOnCurrent,d.current,n,i,o),f=wn(d.current,null,n,i,o),h=wn(d.stackedOnNext,d.next,n,i,o),m=wn(d.next,null,n,i,o)),xn(f,m)>3e3||l&&xn(p,h)>3e3){s.stopAnimation(),s.setShape({points:m}),l&&(l.stopAnimation(),l.setShape({points:m,stackedOnPoints:h}));return}s.shape.__points=d.current,s.shape.points=f;var g={shape:{points:m}};d.current!==f&&(g.shape.__points=d.next),s.stopAnimation(),c(s,g,u),l&&(l.setShape({points:f,stackedOnPoints:p}),l.stopAnimation(),c(l,{shape:{stackedOnPoints:h}},u),s.shape.points!==l.shape.points&&(l.shape.points=s.shape.points));for(var _=[],v=d.status,y=0;y<v.length;y++)if(v[y].cmd===`=`){var b=e.getItemGraphicEl(v[y].idx1);b&&_.push({el:b,ptIdx:y})}s.animators&&s.animators.length&&s.animators[0].during(function(){l&&l.dirtyShape();for(var e=s.shape.__points,t=0;t<_.length;t++){var n=_[t].el,r=_[t].ptIdx*2;n.x=e[r],n.y=e[r+1],n.markRedraw()}})},t.prototype.remove=function(e){var t=this.group,n=this._data;this._lineGroup.removeAll(),this._symbolDraw.remove(!0),n&&n.eachItemGraphicEl(function(e,r){e.__temp&&(t.remove(e),n.setItemGraphicEl(r,null))}),this._polyline=this._polygon=this._coordSys=this._points=this._stackedOnPoints=this._endLabel=this._data=null},t.type=`line`,t}(je);function In(e,t){return{seriesType:e,plan:Le(),reset:function(e){var n=e.getData(),r=e.coordinateSystem,i=e.pipelineContext,a=t||i.large;if(r){var s=M(r.dimensions,function(e){return n.mapDimension(e)}).slice(0,2),c=s.length,u=n.getCalculationInfo(`stackResultDimension`);l(n,s[0])&&(s[0]=u),l(n,s[1])&&(s[1]=u);var d=n.getStore(),f=n.getDimensionIndex(s[0]),p=n.getDimensionIndex(s[1]);return c&&{progress:function(e,t){for(var n=e.end-e.start,i=a&&o(n*c),s=[],l=[],u=e.start,m=0;u<e.end;u++){var h=void 0;if(c===1){var g=d.get(f,u);h=r.dataToPoint(g,null,l)}else s[0]=d.get(f,u),s[1]=d.get(p,u),h=r.dataToPoint(s,null,l);a?(i[m++]=h[0],i[m++]=h[1]):t.setItemLayout(u,h.slice())}a&&(t.setLayout(`points`,i),t.setLayout(`pointsRange`,{start:e.start,end:e.end}))}}}}}}function Ln(e){e.registerChartView(Fn),e.registerSeriesModel(Yt),e.registerLayout(In(`line`,!0)),e.registerVisual({seriesType:`line`,reset:function(e){var t=e.getData(),n=e.getModel(`lineStyle`).getLineStyle();n&&!n.stroke&&(n.stroke=t.getVisual(`style`).fill),t.setVisual(`legendLineStyle`,n)}}),e.registerProcessor(e.PRIORITY.PROCESSOR.STATISTIC,_(`line`))}var Rn=St();function zn(e,t){return!!Rn(e)[t]}Te({type:`takeGlobalCursor`,event:`globalCursorTaken`,update:`update`},Me);var Bn={axisPointer:1,tooltip:1,brush:1};function Vn(e,t,n){var r=t.getComponentByElement(e.topTarget);if(!r||r===n||Bn.hasOwnProperty(r.mainType))return!1;var i=r.coordinateSystem;if(!i||i.model===n)return!1;var a=ve(r),o=ve(n);return!((a.zlevel-o.zlevel||a.z-o.z)<=0)}K();var Hn=function(e){U(t,e);function t(t){var n=e.call(this)||this;n._zr=t;var r=G(n._mousedownHandler,n),i=G(n._mousemoveHandler,n),a=G(n._mouseupHandler,n),o=G(n._mousewheelHandler,n),s=G(n._pinchHandler,n);return n.enable=function(e,n){var c=n.zInfo,l=ve(c.component),u=l.z,d=l.zlevel,f={component:c.component,z:u,zlevel:d,z2:de(c.z2,-1/0)},p=R({},n.triggerInfo);this._opt=x(R({},n),{zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!1,preventDefaultMouseMove:!0,zInfoParsed:f,triggerInfo:p,cursorGrab:`grab`,cursorGrabbing:`grabbing`}),e??=!0,(!this._enabled||this._controlType!==e)&&(this.disable(),this._enabled=!0,(e===!0||e===`move`||e===`pan`)&&(Kn(t,`mousedown`,r,f),Kn(t,`mousemove`,i,f),Kn(t,`mouseup`,a,f)),(e===!0||e===`scale`||e===`zoom`)&&(Kn(t,`mousewheel`,o,f),Kn(t,`pinch`,s,f)))},n.disable=function(){this._enabled&&(this._enabled=!1,qn(t,`mousedown`,r),qn(t,`mousemove`,i),qn(t,`mouseup`,a),qn(t,`mousewheel`,o),qn(t,`pinch`,s))},n}return t.prototype.isDragging=function(){return this._dragging},t.prototype.isPinching=function(){return this._pinching},t.prototype._checkPointer=function(e,t,n){var r=this._opt,i=r.zInfoParsed;if(Vn(e,r.api,i.component))return!1;var a=r.triggerInfo,o=a.roamTrigger,s=!1;return o===`global`&&(s=!0),s||=a.isInSelf(e,t,n),s&&a.isInClip&&!a.isInClip(e,t,n)&&(s=!1),s},t.prototype._decideCursorStyle=function(e,t,n,r){var i=e.target;if(!i&&this._checkPointer(e,t,n))return this._opt.cursorGrab;if(r)return i&&i.cursor||`default`},t.prototype.dispose=function(){this.disable()},t.prototype._mousedownHandler=function(e){if(!(ae(e)||Un(e))){for(var t=e.target;t;){if(t.draggable)return;t=t.__hostTarget||t.parent}var n=e.offsetX,r=e.offsetY;this._checkPointer(e,n,r)&&(this._x=n,this._y=r,this._dragging=!0)}},t.prototype._mousemoveHandler=function(e){var t=this._zr;if(!(e.gestureEvent===`pinch`||zn(t,`globalPan`)||Un(e))){var n=e.offsetX,r=e.offsetY;if(!this._dragging||!Zn(`moveOnMouseMove`,e,this._opt)){var i=this._decideCursorStyle(e,n,r,!1);i&&t.setCursorStyle(i);return}t.setCursorStyle(this._opt.cursorGrabbing);var a=this._x,o=this._y,s=n-a,c=r-o;this._x=n,this._y=r,this._opt.preventDefaultMouseMove&&ct(e.event),e.__ecRoamConsumed=!0,Xn(this,`pan`,`moveOnMouseMove`,e,{dx:s,dy:c,oldX:a,oldY:o,newX:n,newY:r,isAvailableBehavior:null})}},t.prototype._mouseupHandler=function(e){if(!Un(e)){var t=this._zr;if(!ae(e)){this._dragging=!1;var n=this._decideCursorStyle(e,e.offsetX,e.offsetY,!0);n&&t.setCursorStyle(n)}}},t.prototype._mousewheelHandler=function(e){if(!Un(e)){var t=Zn(`zoomOnMouseWheel`,e,this._opt),n=Zn(`moveOnMouseWheel`,e,this._opt),r=e.wheelDelta,i=Math.abs(r),a=e.offsetX,o=e.offsetY;if(!(r===0||!t&&!n)){if(t){var s=i>3?1.4:i>1?1.2:1.1,c=r>0?s:1/s;this._checkTriggerMoveZoom(this,`zoom`,`zoomOnMouseWheel`,e,{scale:c,originX:a,originY:o,isAvailableBehavior:null})}if(n){var l=Math.abs(r),u=(r>0?1:-1)*(l>3?.4:l>1?.15:.05);this._checkTriggerMoveZoom(this,`scrollMove`,`moveOnMouseWheel`,e,{scrollDelta:u,originX:a,originY:o,isAvailableBehavior:null})}}}},t.prototype._pinchHandler=function(e){if(!(zn(this._zr,`globalPan`)||Un(e))){var t=e.pinchScale>1?1.1:1/1.1;this._checkTriggerMoveZoom(this,`zoom`,null,e,{scale:t,originX:e.pinchX,originY:e.pinchY,isAvailableBehavior:null})}},t.prototype._checkTriggerMoveZoom=function(e,t,n,r,i){e._checkPointer(r,i.originX,i.originY)&&(ct(r.event),r.__ecRoamConsumed=!0,Xn(e,t,n,r,i))},t}(s);function Un(e){return e.__ecRoamConsumed}var Wn=St();function Gn(e){var t=Wn(e);return t.roam=t.roam||{},t.uniform=t.uniform||{},t}function Kn(e,t,n,r){for(var i=Gn(e).roam,a=i[t]=i[t]||[],o=0;o<a.length;o++){var s=a[o].zInfoParsed;if((s.zlevel-r.zlevel||s.z-r.z||s.z2-r.z2)<=0)break}a.splice(o,0,{listener:n,zInfoParsed:r}),Jn(e,t)}function qn(e,t,n){for(var r=Gn(e).roam[t]||[],i=0;i<r.length;i++)if(r[i].listener===n){r.splice(i,1),r.length||Yn(e,t);return}}function Jn(e,t){var n=Gn(e);n.uniform[t]||e.on(t,n.uniform[t]=function(e){var r=n.roam[t];if(r)for(var i=0;i<r.length;i++)r[i].listener(e)})}function Yn(e,t){var n=Gn(e).uniform;n[t]&&(e.off(t,n[t]),n[t]=null)}function Xn(e,t,n,r,i){i.isAvailableBehavior=G(Zn,null,n,r),e.trigger(t,i)}function Zn(e,t,n){var r=n[e];return!e||r&&(!F(r)||t.event[r+`Key`])}function Qn(e,t,n,r,i,a){e||=0;var o=qe(n[1],-n[0]);if(i!=null&&(i=er(i,[0,o])),a!=null&&(a=Math.max(a,i??0)),r===`all`){var s=Math.abs(qe(t[1],-t[0]));s=er(s,[0,o]),i=a=er(s,[i,a]),r=0}t[0]=er(t[0],n),t[1]=er(t[1],n);var c=$n(t,r);t[r]+=e;var l=i||0,u=n.slice();c.sign<0?u[0]=qe(u[0],l):u[1]=qe(u[1],-l),t[r]=er(t[r],u);var d=$n(t,r);return i!=null&&(d.sign!==c.sign||d.span<i)&&(t[1-r]=qe(t[r],c.sign*i)),d=$n(t,r),a!=null&&d.span>a&&(t[1-r]=qe(t[r],d.sign*a)),t}function $n(e,t){var n=e[t]-e[1-t];return{span:Math.abs(n),sign:n>0?-1:n<0?1:t?-1:1}}function er(e,t){return Math.min(t[1]==null?1/0:t[1],Math.max(t[0]==null?-1/0:t[0],e))}var tr={position:[`x`,`y`],scale:[`scaleX`,`scaleY`],origin:[`originX`,`originY`]},nr=bt(tr);Re(Ge,function(e,t){return e[t]=1,e},{}),Ge.join(`, `);var rr=[``,`style`,`shape`,`extra`],ir=St();function ar(e,t,n,r,i){var a=e+`Animation`,o=y(e,r,i)||{},s=ir(t).userDuring;return o.duration>0&&(o.during=s?G(mr,{el:t,userDuring:s}):null,o.setToFinal=!0,o.scope=e),R(o,n[a]),o}function or(e,t,n,r){r||={};var i=r.dataIndex,a=r.isInit,o=r.clearStyle,s=n.isAnimationEnabled(),c=ir(e),l=t.style;c.userDuring=t.during;var u={},d={};if(vr(e,t,d),e.type===`compound`)for(var f=e.shape.paths,p=t.shape.paths,m=0;m<p.length;m++){var h=p[m];gr(`shape`,h,f[m])}else gr(`shape`,t,d),gr(`extra`,t,d);if(!a&&s&&(_r(e,t,u),hr(`shape`,e,t,u),hr(`extra`,e,t,u),yr(e,t,l,u)),d.style=l,ur(e,d,o),fr(e,t),s)if(a){var g={};k(rr,function(e){var n=e?t[e]:t;n&&n.enterFrom&&(e&&(g[e]=g[e]||{}),R(e?g[e]:g,n.enterFrom))});var _=ar(`enter`,e,t,n,i);_.duration>0&&e.animateFrom(g,_)}else dr(e,t,i||0,n,u);sr(e,t),l?e.dirty():e.markRedraw()}function sr(e,t){for(var n=ir(e).leaveToProps,r=0;r<rr.length;r++){var i=rr[r],a=i?t[i]:t;a&&a.leaveTo&&(n||=ir(e).leaveToProps={},i&&(n[i]=n[i]||{}),R(i?n[i]:n,a.leaveTo))}}function cr(e,t,n,r){if(e){var i=e.parent,a=ir(e).leaveToProps;if(a){var o=ar(`update`,e,t,n,0);o.done=function(){i&&i.remove(e),r&&r()},e.animateTo(a,o)}else i&&i.remove(e),r&&r()}}function lr(e){return e===`all`}function ur(e,t,n){var r=t.style;if(!e.isGroup&&r){if(n){e.useStyle({});for(var i=e.animators,a=0;a<i.length;a++){var o=i[a];o.targetName===`style`&&o.changeTarget(e.style)}}e.setStyle(r)}t&&(t.style=null,t&&e.attr(t),t.style=r)}function dr(e,t,n,r,i){if(i){var a=ar(`update`,e,t,r,n);a.duration>0&&e.animateFrom(i,a)}}function fr(e,t){q(t,`silent`)&&(e.silent=t.silent),q(t,`ignore`)&&(e.ignore=t.ignore),e instanceof xt&&q(t,`invisible`)&&(e.invisible=t.invisible),e instanceof T&&q(t,`autoBatch`)&&(e.autoBatch=t.autoBatch)}var Y={},pr={setTransform:function(e,t){return Y.el[e]=t,this},getTransform:function(e){return Y.el[e]},setShape:function(e,t){var n=Y.el,r=n.shape||={};return r[e]=t,n.dirtyShape&&n.dirtyShape(),this},getShape:function(e){var t=Y.el.shape;if(t)return t[e]},setStyle:function(e,t){var n=Y.el,r=n.style;return r&&(r[e]=t,n.dirtyStyle&&n.dirtyStyle()),this},getStyle:function(e){var t=Y.el.style;if(t)return t[e]},setExtra:function(e,t){var n=Y.el.extra||(Y.el.extra={});return n[e]=t,this},getExtra:function(e){var t=Y.el.extra;if(t)return t[e]}};function mr(){var e=this,t=e.el;if(t){var n=ir(t).userDuring,r=e.userDuring;if(n!==r){e.el=e.userDuring=null;return}Y.el=t,r(pr)}}function hr(e,t,n,r){var i=n[e];if(i){var a=t[e],o;if(a){var s=n.transition,c=i.transition;if(c)if(!o&&(o=r[e]={}),lr(c))R(o,a);else for(var l=He(c),d=0;d<l.length;d++){var f=l[d],p=a[f];o[f]=p}else if(lr(s)||u(s,e)>=0){!o&&(o=r[e]={});for(var m=bt(a),d=0;d<m.length;d++){var f=m[d],p=a[f];br(i[f],p)&&(o[f]=p)}}}}}function gr(e,t,n){var r=t[e];if(r)for(var i=n[e]={},a=bt(r),o=0;o<a.length;o++){var s=a[o];i[s]=It(r[s])}}function _r(e,t,n){for(var r=t.transition,i=lr(r)?Ge:He(r||[]),a=0;a<i.length;a++){var o=i[a];o===`style`||o===`shape`||o===`extra`||(n[o]=e[o])}}function vr(e,t,n){for(var r=0;r<nr.length;r++){var i=nr[r],a=tr[i],o=t[i];o&&(n[a[0]]=o[0],n[a[1]]=o[1])}for(var r=0;r<Ge.length;r++){var s=Ge[r];t[s]!=null&&(n[s]=t[s])}}function yr(e,t,n,r){if(n){var i=e.style,a;if(i){var o=n.transition,s=t.transition;if(o&&!lr(o)){var c=He(o);!a&&(a=r.style={});for(var l=0;l<c.length;l++){var d=c[l],f=i[d];a[d]=f}}else if(e.getAnimationStyleProps&&(lr(s)||lr(o)||u(s,`style`)>=0)){var p=e.getAnimationStyleProps(),m=p?p.style:null;if(m){!a&&(a=r.style={});for(var h=bt(n),l=0;l<h.length;l++){var d=h[l];if(m[d]){var f=i[d];a[d]=f}}}}}}}function br(e,t){return E(e)?e!==t:e!=null&&isFinite(e)}var xr=St(),Sr=[`percent`,`easing`,`shape`,`style`,`extra`];function Cr(e){e.stopAnimation(`keyframe`),e.attr(xr(e))}function wr(e,t,n){if(!(!n.isAnimationEnabled()||!t)){if(Ee(t)){k(t,function(t){wr(e,t,n)});return}var r=t.keyframes,i=t.duration;if(n&&i==null){var a=y(`enter`,n,0);i=a&&a.duration}if(!(!r||!i)){var o=xr(e);k(rr,function(n){if(!(n&&!e[n])){var a;r.sort(function(e,t){return e.percent-t.percent}),k(r,function(r){var s=e.animators,c=n?r[n]:r;if(c){var l=bt(c);if(n||(l=me(l,function(e){return u(Sr,e)<0})),l.length){a||(a=e.animate(n,t.loop,!0),a.scope=`keyframe`);for(var d=0;d<s.length;d++)s[d]!==a&&s[d].targetName===a.targetName&&s[d].stopTracks(l);n&&(o[n]=o[n]||{});var f=n?o[n]:o;k(l,function(t){f[t]=((n?e[n]:e)||{})[t]}),a.whenWithKeys(i*r.percent,c,l,r.easing)}}}),a&&a.delay(t.delay||0).duration(i).start(t.easing)}})}}}K();function Tr(e,t){var n=e.existing;if(t.id=e.keyInfo.id,!t.type&&n&&(t.type=n.type),t.parentId==null){var r=t.parentOption;r?t.parentId=r.id:n&&(t.parentId=n.parentId)}t.parentOption=null}function Er(e,t){var n;return k(t,function(t){e[t]!=null&&e[t]!==`auto`&&(n=!0)}),n}function Dr(e,t,n){var r=R({},n),i=e[t],a=n.$action||`merge`;a===`merge`?i?(Fe(i,r,!0),Je(i,r,{ignoreSize:!0}),it(n,i),Ar(n,i),Ar(n,i,`shape`),Ar(n,i,`style`),Ar(n,i,`extra`),n.clipPath=i.clipPath):e[t]=r:a===`replace`?e[t]=r:a===`remove`&&i&&(e[t]=null)}var Or=[`transition`,`enterFrom`,`leaveTo`],kr=Or.concat([`enterAnimation`,`updateAnimation`,`leaveAnimation`]);function Ar(e,t,n){if(n&&(!e[n]&&t[n]&&(e[n]={}),e=e[n],t=t[n]),!(!e||!t))for(var r=n?Or:kr,i=0;i<r.length;i++){var a=r[i];e[a]==null&&t[a]!=null&&(e[a]=t[a])}}function jr(e,t){if(e&&(e.hv=t.hv=[Er(t,[`left`,`right`]),Er(t,[`top`,`bottom`])],e.type===`group`)){var n=e,r=t;n.width??=r.width=0,n.height??=r.height=0}}var Mr=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.preventAutoZ=!0,n}return t.prototype.mergeOption=function(t,n){var r=this.option.elements;this.option.elements=null,e.prototype.mergeOption.call(this,t,n),this.option.elements=r},t.prototype.optionUpdated=function(e,t){var n=this.option,r=(t?n:e).elements,i=n.elements=t?[]:n.elements,a=[];this._flatten(r,a,null);var o=rt(i,a,`normalMerge`),s=this._elOptionsToUpdate=[];k(o,function(e,t){var n=e.newOption;n&&(s.push(n),Tr(e,n),Dr(i,t,n),jr(i[t],n))},this),n.elements=me(i,function(e){return e&&delete e.$action,e!=null})},t.prototype._flatten=function(e,t,n){k(e,function(e){if(e){n&&(e.parentOption=n),t.push(e);var r=e.children;r&&r.length&&this._flatten(r,t,e),delete e.children}},this)},t.prototype.useElOptionsToUpdate=function(){var e=this._elOptionsToUpdate;return this._elOptionsToUpdate=null,e},t.type=`graphic`,t.defaultOption={elements:[]},t}(Dt);K();var Nr={path:null,compoundPath:null,group:zt,image:Ae,text:D},X=St(),Pr=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.init=function(){this._elMap=V()},t.prototype.render=function(e,t,n){e!==this._lastGraphicModel&&this._clear(),this._lastGraphicModel=e,this._updateElements(e),this._relocate(e,n)},t.prototype._updateElements=function(e){var t=e.useElOptionsToUpdate();if(t){var n=this._elMap,r=this.group,i=e.get(`z`),a=e.get(`zlevel`);k(t,function(t){var o=Ne(t.id,null),s=o==null?null:n.get(o),c=Ne(t.parentId,null),l=c==null?r:n.get(c),u=t.type,d=t.style;u===`text`&&d&&t.hv&&t.hv[1]&&(d.textVerticalAlign=d.textBaseline=d.verticalAlign=d.align=null);var f=t.textContent,m=t.textConfig;if(d&&gn(d,u,!!m,!!f)){var h=_n(d,u,!0);!m&&h.textConfig&&(m=t.textConfig=h.textConfig),!f&&h.textContent&&(f=h.textContent)}var g=zr(t),_=t.$action||`merge`,v=_===`merge`,y=_===`replace`;if(v){var b=!s,x=s;b?x=Ir(o,l,t.type,n):(x&&(X(x).isNew=!1),Cr(x)),x&&(or(x,g,e,{isInit:b}),Rr(x,t,i,a))}else if(y){Lr(s,t,n,e);var S=Ir(o,l,t.type,n);S&&(or(S,g,e,{isInit:!0}),Rr(S,t,i,a))}else _===`remove`&&(sr(s,t),Lr(s,t,n,e));var C=n.get(o);if(C&&f)if(v){var w=C.getTextContent();w?w.attr(f):C.setTextContent(new D(f))}else y&&C.setTextContent(new D(f));if(C){var T=t.clipPath;if(T){var E=T.type,O=void 0,b=!1;if(v){var k=C.getClipPath();b=!k||X(k).type!==E,O=b?Fr(E):k}else y&&(b=!0,O=Fr(E));C.setClipPath(O),or(O,T,e,{isInit:b}),wr(O,T.keyframeAnimation,e)}var A=X(C);C.setTextConfig(m),A.option=t,Br(C,e,t),p({el:C,componentModel:e,itemName:C.name,itemTooltipOption:t.tooltip}),wr(C,t.keyframeAnimation,e)}})}},t.prototype._relocate=function(e,t){for(var n=e.option.elements,r=this.group,i=this._elMap,a=t.getWidth(),o=t.getHeight(),s=[`x`,`y`],l=0;l<n.length;l++){var d=n[l],f=Ne(d.id,null),p=f==null?null:i.get(f);if(!(!p||!p.isGroup)){var m=p.parent,h=m===r,g=X(p),_=X(m);g.width=Be(g.option.width,h?a:_.width)||0,g.height=Be(g.option.height,h?o:_.height)||0}}for(var l=n.length-1;l>=0;l--){var d=n[l],f=Ne(d.id,null),p=f==null?null:i.get(f);if(p){var m=p.parent,_=X(m),v=m===r?{width:a,height:o}:{width:_.width,height:_.height},y={},b=dt(p,d,v,null,{hv:d.hv,boundingMode:d.bounding},y);if(!X(p).isNew&&b){for(var x=d.transition,S={},C=0;C<s.length;C++){var w=s[C],T=y[w];x&&(lr(x)||u(x,w)>=0)?S[w]=T:p[w]=T}c(p,S,e,0)}else p.attr(y)}}},t.prototype._clear=function(){var e=this,t=this._elMap;t.each(function(n){Lr(n,X(n).option,t,e._lastGraphicModel)}),this._elMap=V()},t.prototype.dispose=function(){this._clear()},t.type=`graphic`,t}(ue);function Fr(e){var t=new(q(Nr,e)?Nr[e]:Ke(e))({});return X(t).type=e,t}function Ir(e,t,n,r){var i=Fr(n);return t.add(i),r.set(e,i),X(i).id=e,X(i).isNew=!0,i}function Lr(e,t,n,r){e&&e.parent&&(e.type===`group`&&e.traverse(function(e){Lr(e,t,n,r)}),cr(e,t,r),n.removeKey(X(e).id))}function Rr(e,t,n,r){e.isGroup||k([[`cursor`,xt.prototype.cursor],[`zlevel`,r||0],[`z`,n||0],[`z2`,0]],function(n){var r=n[0];q(t,r)?e[r]=de(t[r],n[1]):e[r]??(e[r]=n[1])}),k(bt(t),function(n){if(n.indexOf(`on`)===0){var r=t[n];e[n]=Ce(r)?r:null}}),q(t,`draggable`)&&(e.draggable=t.draggable),t.name!=null&&(e.name=t.name),t.id!=null&&(e.id=t.id)}function zr(e){return e=R({},e),k([`id`,`parentId`,`$action`,`hv`,`bounding`,`textContent`,`clipPath`].concat(ht),function(t){delete e[t]}),e}function Br(e,t,n){var r=De(e).eventData;!e.silent&&!e.ignore&&!r&&(r=De(e).eventData={componentType:`graphic`,componentIndex:t.componentIndex,name:e.name}),r&&(r.info=n.info)}function Vr(e){e.registerComponentModel(Mr),e.registerComponentView(Pr),e.registerPreprocessor(function(e){var t=e.graphic;Ee(t)?!t[0]||!t[0].elements?e.graphic=[{elements:t}]:e.graphic=[e.graphic[0]]:t&&!t.elements&&(e.graphic=[{elements:[t]}])})}var Hr=[`x`,`y`,`radius`,`angle`,`single`],Ur=St(),Wr=[`cartesian2d`,`polar`,`singleAxis`];function Gr(e){return u(Wr,e.get(`coordinateSystem`))>=0}function Kr(e){return e+`Axis`}function qr(e,t){var n=V(),r=[],i=V();e.eachComponent({mainType:`dataZoom`,query:t},function(e){i.get(e.uid)||s(e)});var a;do a=!1,e.eachComponent(`dataZoom`,o);while(a);function o(e){!i.get(e.uid)&&c(e)&&(s(e),a=!0)}function s(e){i.set(e.uid,!0),r.push(e),l(e)}function c(e){var t=!1;return e.eachTargetAxis(function(e,r){var i=n.get(e);i&&i[r]&&(t=!0)}),t}function l(e){e.eachTargetAxis(function(e,t){(n.get(e)||n.set(e,[]))[t]=!0})}return r}function Jr(e){var t=e.ecModel,n={infoList:[],infoMap:V()};return e.eachTargetAxis(function(e,r){var i=t.getComponent(Kr(e),r);if(i){var a=i.getCoordSysModel();if(a){var o=a.uid,s=n.infoMap.get(o);s||(s={model:a,axisModels:[]},n.infoList.push(s),n.infoMap.set(o,s)),s.axisModels.push(i)}}}),n}function Yr(e){var t=Ur(yt(e));return t.axisProxyMap||=V()}function Xr(e){if(e)return Yr(e.ecModel).get(e.uid)}function Zr(e,t){Yr(e.ecModel).set(e.uid,t)}function Qr(e,t){var n=t.getAxisModel().axis.__alignTo;return n&&e.getAxisProxy(n.dim,n.model.componentIndex)?Xr(n.model):null}K();var $r=function(){function e(){this.indexList=[],this.indexMap=[]}return e.prototype.add=function(e){this.indexMap[e]||(this.indexList.push(e),this.indexMap[e]=!0)},e}(),ei=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n._autoThrottle=!0,n._noTarget=!0,n._rangePropMode=[`percent`,`percent`],n}return t.prototype.init=function(e,t,n){var r=ti(e);this.settledOption=r,this.mergeDefaultAndTheme(e,n),this._doInit(r)},t.prototype.mergeOption=function(e){var t=ti(e);Fe(this.option,e,!0),Fe(this.settledOption,t,!0),this._doInit(t)},t.prototype._doInit=function(e){var t=this.option;this._setDefaultThrottle(e),this._updateRangeUse(e);var n=this.settledOption;k([[`start`,`startValue`],[`end`,`endValue`]],function(e,r){this._rangePropMode[r]===`value`&&(t[e[0]]=n[e[0]]=null)},this),this._resetTarget()},t.prototype._resetTarget=function(){var e=this.get(`orient`,!0),t=this._targetAxisInfoMap=V();this._fillSpecifiedTargetAxis(t)?this._orient=e||this._makeAutoOrientByTargetAxis():(this._orient=e||`horizontal`,this._fillAutoTargetAxisByOrient(t,this._orient)),this._noTarget=!0,t.each(function(e){e.indexList.length&&(this._noTarget=!1)},this)},t.prototype._fillSpecifiedTargetAxis=function(e){var t=!1;return k(Hr,function(n){var r=this.getReferringComponents(Kr(n),N);if(r.specified){t=!0;var i=new $r;k(r.models,function(e){i.add(e.componentIndex)}),e.set(n,i)}},this),t},t.prototype._fillAutoTargetAxisByOrient=function(e,t){var n=this.ecModel,r=!0;if(r){var i=t===`vertical`?`y`:`x`,a=n.findComponents({mainType:i+`Axis`});o(a,i)}if(r){var a=n.findComponents({mainType:`singleAxis`,filter:function(e){return e.get(`orient`,!0)===t}});o(a,`single`)}function o(t,n){var i=t[0];if(i){var a=new $r;if(a.add(i.componentIndex),e.set(n,a),r=!1,n===`x`||n===`y`){var o=i.getReferringComponents(`grid`,Ie).models[0];o&&k(t,function(e){i.componentIndex!==e.componentIndex&&o===e.getReferringComponents(`grid`,Ie).models[0]&&a.add(e.componentIndex)})}}}r&&k(Hr,function(t){if(r){var i=n.findComponents({mainType:Kr(t),filter:function(e){return e.get(`type`,!0)===`category`}});if(i[0]){var a=new $r;a.add(i[0].componentIndex),e.set(t,a),r=!1}}},this)},t.prototype._makeAutoOrientByTargetAxis=function(){var e;return this.eachTargetAxis(function(t){!e&&(e=t)},this),e===`y`?`vertical`:`horizontal`},t.prototype._setDefaultThrottle=function(e){if(e.hasOwnProperty(`throttle`)&&(this._autoThrottle=!1),this._autoThrottle){var t=this.ecModel.option;this.option.throttle=t.animation&&t.animationDurationUpdate>0?100:20}},t.prototype._updateRangeUse=function(e){var t=this._rangePropMode,n=this.get(`rangeMode`);k([[`start`,`startValue`],[`end`,`endValue`]],function(r,i){var a=e[r[0]]!=null,o=e[r[1]]!=null;a&&!o?t[i]=`percent`:!a&&o?t[i]=`value`:n?t[i]=n[i]:a&&(t[i]=`percent`)})},t.prototype.noTarget=function(){return this._noTarget},t.prototype.getFirstTargetAxisModel=function(){var e;return this.eachTargetAxis(function(t,n){e??=this.ecModel.getComponent(Kr(t),n)},this),e},t.prototype.eachTargetAxis=function(e,t){this._targetAxisInfoMap.each(function(n,r){k(n.indexList,function(n){e.call(t,r,n)})})},t.prototype.getAxisProxy=function(e,t){return Xr(this.getAxisModel(e,t))},t.prototype.getAxisModel=function(e,t){var n=this._targetAxisInfoMap.get(e);if(n&&n.indexMap[t])return this.ecModel.getComponent(Kr(e),t)},t.prototype.setRawRange=function(e){var t=this.option,n=this.settledOption;k([[`start`,`startValue`],[`end`,`endValue`]],function(r){(e[r[0]]!=null||e[r[1]]!=null)&&(t[r[0]]=n[r[0]]=e[r[0]],t[r[1]]=n[r[1]]=e[r[1]])},this),this._updateRangeUse(e)},t.prototype.setCalculatedRange=function(e){var t=this.option;k([`start`,`startValue`,`end`,`endValue`],function(n){t[n]=e[n]})},t.prototype.getPercentRange=function(){var e=this.findRepresentativeAxisProxy();if(e)return e.getWindow().percent},t.prototype.getValueRange=function(e,t){if(e==null&&t==null){var n=this.findRepresentativeAxisProxy();if(n)return n.getWindow().value}else return this.getAxisProxy(e,t).getWindow().value},t.prototype.findRepresentativeAxisProxy=function(e){if(e)return Xr(e);for(var t,n=this._targetAxisInfoMap.keys(),r=0;r<n.length;r++)for(var i=n[r],a=this._targetAxisInfoMap.get(i),o=0;o<a.indexList.length;o++){var s=this.getAxisProxy(i,a.indexList[o]);if(s.hostedBy(this))return s;t||=s}return t},t.prototype.getRangePropMode=function(){return this._rangePropMode.slice()},t.prototype.getOrient=function(){return this._orient},t.type=`dataZoom`,t.dependencies=[`xAxis`,`yAxis`,`radiusAxis`,`angleAxis`,`singleAxis`,`series`,`toolbox`],t.defaultOption={z:4,filterMode:`filter`,start:0,end:100},t}(Dt);function ti(e){var t={};return k([`start`,`end`,`startValue`,`endValue`,`throttle`],function(n){e.hasOwnProperty(n)&&(t[n]=e[n])}),t}K();var ni=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.render=function(e,t,n,r){this.dataZoomModel=e,this.ecModel=t,this.api=n},t.type=`dataZoom`,t}(ue),ri=function(){function e(e,t,n,r){this._dimName=e,this._axisIndex=t,this.ecModel=r,this._dataZoomModel=n}return e.prototype.hostedBy=function(e){return this._dataZoomModel===e},e.prototype.getWindow=function(){return B(this._window)},e.prototype.getTargetSeriesModels=function(){var e=[];return this.ecModel.eachSeries(function(t){if(Gr(t)){var n=Kr(this._dimName),r=t.getReferringComponents(n,Ie).models[0];r&&this._axisIndex===r.componentIndex&&e.push(t)}},this),e},e.prototype.getAxisModel=function(){return this.ecModel.getComponent(this._dimName+`Axis`,this._axisIndex)},e.prototype.getMinMaxSpan=function(){return B(this._minMaxSpan)},e.prototype.calculateDataWindow=function(e){var t=this._extent,n=this.getAxisModel().axis,r=n.scale,i=this._dataZoomModel.getRangePropMode(),a=[0,100],o=[],s=[],c,l=[!1,!1];k([`start`,`end`],function(n,u){var d=e[n],f=e[n+`Value`];i[u]===`percent`?(d??=a[u],f=H(d,a,t),l[u]=!0):(c=!0,f==null?f=t[u]:(f=r.parse(f),r.sanitize&&(f=r.sanitize(f,t))),d=H(f,t,a)),s[u]=f==null||isNaN(f)?t[u]:f,o[u]=d==null||isNaN(d)?a[u]:d}),ut(s),ut(o);var u=this._minMaxSpan;c?d(s,o,t,a,!1):d(o,s,a,t,!0);function d(e,t,n,r,i){var a=i?`Span`:`ValueSpan`;Qn(0,e,n,`all`,u[`min`+a],u[`max`+a]);for(var o=0;o<2;o++)t[o]=H(e[o],n,r,!0),i&&(t[o]=t[o],l[o]=!0);fe(t)}var f=L(r)||pe(r),p=n.getExtent(),m=Xe(p[1]-p[0]),h=f?0:Ot(s,m,.5);k([[0,vt],[1,ft]],function(e){var n=e[0],r=e[1];!l[n]||!isFinite(h)||(s[n]=jt(s[n],h),s[n]=Qe(t[1],tt(t[0],s[n])),o[n]===a[n]&&(s[n]=t[n],f&&(s[n]=r(s[n]))))}),fe(s);var g=[H(s[0],t,a,!0),H(s[1],t,a,!0)];return fe(g),{value:s,percent:o,percentInverted:g,valuePrecision:h}},e.prototype.reset=function(e,t){if(this.hostedBy(e)){var n=this.getAxisModel().axis;b(n,2);var r=n.scale.rawExtentInfo;this._extent=r.makeNoZoom(),this._updateMinMaxSpan();var i=e.settledOption;t&&(i=x({start:t[0],end:t[1]},i));var a=this._window=this.calculateDataWindow(i),o=a.percent,s=a.value;o[0]!==0&&r.setZoomMM(0,s[0]),o[1]!==100&&r.setZoomMM(1,s[1])}},e.prototype.filterData=function(e,t){if(!this.hostedBy(e))return;var n=this._dimName,r=this.getTargetSeriesModels(),i=e.get(`filterMode`),a=this._window.value;if(i===`none`)return;k(r,function(e){var t=e.getData(),r=t.mapDimensionsAll(n);if(r.length){if(i===`weakFilter`){var s=t.getStore(),c=M(r,function(e){return t.getDimensionIndex(e)},t);t.filterSelf(function(e){for(var t,n,i,o=0;o<r.length;o++){var l=s.get(c[o],e),u=!isNaN(l),d=l<a[0],f=l>a[1];if(u&&!d&&!f)return!0;u&&(i=!0),d&&(t=!0),f&&(n=!0)}return i&&t&&n})}else k(r,function(n){if(i===`empty`)e.setData(t=t.map(n,function(e){return o(e)?e:NaN}));else{var r={};r[n]=a,t.selectRange(r)}});k(r,function(e){t.setApproximateExtent(a,e)})}});function o(e){return e>=a[0]&&e<=a[1]}},e.prototype._updateMinMaxSpan=function(){var e=this._minMaxSpan={},t=this._dataZoomModel,n=this._extent;k([`min`,`max`],function(r){var i=t.get(r+`Span`),a=t.get(r+`ValueSpan`);a!=null&&(a=this.getAxisModel().axis.scale.parse(a)),a==null?i!=null&&(a=H(i,[0,100],n,!0)-n[0]):i=H(n[0]+a,n,[0,100],!0),e[r+`Span`]=i,e[r+`ValueSpan`]=a},this)},e}(),ii={dirtyOnOverallProgress:!0,getTargetSeries:function(e){function t(t){e.eachComponent(`dataZoom`,function(n){n.eachTargetAxis(function(r,i){t(r,i,e.getComponent(Kr(r),i),n)})})}var n=[];t(function(t,r,i,a){if(!Xr(i)){var o=new ri(t,r,a,e);n.push(o),Zr(i,o)}});var r=V();return k(n,function(e){k(e.getTargetSeriesModels(),function(e){r.set(e.uid,e)})}),r},overallReset:function(e,t){e.eachComponent(`dataZoom`,function(e){var n=[];e.eachTargetAxis(function(t,r){var i=e.getAxisProxy(t,r),a=Qr(e,i);a?n.push([i,a]):i.reset(e,null)}),k(n,function(t){t[0].reset(e,t[1].getWindow().percentInverted)}),e.eachTargetAxis(function(n,r){e.getAxisProxy(n,r).filterData(e,t)})}),e.eachComponent(`dataZoom`,function(e){var t=e.findRepresentativeAxisProxy();if(t){var n=t.getWindow(),r=n.percent,i=n.value;e.setCalculatedRange({start:r[0],end:r[1],startValue:i[0],endValue:i[1]})}})}};function ai(e){e.registerAction(`dataZoom`,function(e,t){k(qr(t,e),function(t){t.setRawRange({start:e.start,end:e.end,startValue:e.startValue,endValue:e.endValue})})})}var oi=mt();function si(e){oi(e,function(){e.registerProcessor(e.PRIORITY.PROCESSOR.FILTER,ii),ai(e),e.registerSubTypeDefaulter(`dataZoom`,function(){return`slider`})})}K();var ci=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.type=`dataZoom.inside`,t.defaultOption=Ze(ei.defaultOption,{disabled:!1,zoomLock:!1,zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!1,preventDefaultMouseMove:!0}),t}(ei),li=St();function ui(e,t,n){li(e).coordSysRecordMap.each(function(e){var r=e.dataZoomInfoMap.get(t.uid);r&&(r.getRange=n)})}function di(e,t){for(var n=li(e).coordSysRecordMap,r=n.keys(),i=0;i<r.length;i++){var a=r[i],o=n.get(a),s=o.dataZoomInfoMap;if(s){var c=t.uid;s.get(c)&&(s.removeKey(c),s.keys().length||fi(n,o))}}}function fi(e,t){if(t){e.removeKey(t.model.uid);var n=t.controller;n&&n.dispose()}}function pi(e,t){var n={model:t,containsPoint:ce(hi,t),dispatchAction:ce(mi,e),dataZoomInfoMap:null,controller:null},r=n.controller=new Hn(e.getZr());return k([`pan`,`zoom`,`scrollMove`],function(e){r.on(e,function(t){var r=[];n.dataZoomInfoMap.each(function(i){if(t.isAvailableBehavior(i.model.option)){var a=(i.getRange||{})[e],o=a&&a(i.dzReferCoordSysInfo,n.model.mainType,n.controller,t);!i.model.get(`disabled`,!0)&&o&&r.push({dataZoomId:i.model.id,start:o[0],end:o[1]})}}),r.length&&n.dispatchAction(r)})}),n}function mi(e,t){e.isDisposed()||e.dispatchAction({type:`dataZoom`,animation:{easing:`cubicOut`,duration:100},batch:t})}function hi(e,t,n,r){return e.coordinateSystem.containPoint([n,r])}function gi(e,t,n){var r,i=`type_`,a={type_true:2,type_move:1,type_false:0,type_undefined:-1},o=!0,s,c;return e.each(function(e){var t=e.model,n=t.get(`disabled`,!0)?!1:t.get(`zoomLock`,!0)?`move`:!0;a[i+n]>a[i+r]&&(r=n),o&&=t.get(`preventDefaultMouseMove`,!0),s=de(t.get(`cursorGrab`,!0),s),c=de(t.get(`cursorGrabbing`,!0),c)}),{controlType:r,opt:{zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!0,preventDefaultMouseMove:!!o,api:n,zInfo:{component:t.model},triggerInfo:{roamTrigger:null,isInSelf:t.containsPoint},cursorGrab:s,cursorGrabbing:c}}}function _i(e){e.registerUpdateLifecycle(`coordsys:aftercreate`,function(e,t){var n=li(t),r=n.coordSysRecordMap||=V();r.each(function(e){e.dataZoomInfoMap=null}),e.eachComponent({mainType:`dataZoom`,subType:`inside`},function(e){k(Jr(e).infoList,function(n){var i=n.model.uid,a=r.get(i)||r.set(i,pi(t,n.model));(a.dataZoomInfoMap||=V()).set(e.uid,{dzReferCoordSysInfo:n,model:e,getRange:null})})}),r.each(function(e){var n=e.controller,i,a=e.dataZoomInfoMap;if(a){var o=a.keys()[0];o!=null&&(i=a.get(o))}if(!i){fi(r,e);return}var s=gi(a,e,t);n.enable(s.controlType,s.opt),Pe(e,`dispatchAction`,i.model.get(`throttle`,!0),`fixRate`)})})}K();var vi=function(e){U(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;return t.type=`dataZoom.inside`,t}return t.prototype.render=function(t,n,r){if(e.prototype.render.apply(this,arguments),t.noTarget()){this._clear();return}this.range=t.getPercentRange(),ui(r,t,{pan:G(yi.pan,this),zoom:G(yi.zoom,this),scrollMove:G(yi.scrollMove,this)})},t.prototype.dispose=function(){this._clear(),e.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){di(this.api,this.dataZoomModel),this.range=null},t.type=`dataZoom.inside`,t}(ni),yi={zoom:function(e,t,n,r){var i=this.range,a=i.slice(),o=e.axisModels[0];if(o){var s=xi[t](null,[r.originX,r.originY],o,n,e),c=(s.signal>0?s.pixelStart+s.pixelLength-s.pixel:s.pixel-s.pixelStart)/s.pixelLength*(a[1]-a[0])+a[0],l=Math.max(1/r.scale,0);a[0]=(a[0]-c)*l+c,a[1]=(a[1]-c)*l+c;var u=this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();if(Qn(0,a,[0,100],0,u.minSpan,u.maxSpan),this.range=a,i[0]!==a[0]||i[1]!==a[1])return a}},pan:bi(function(e,t,n,r,i,a){var o=xi[r]([a.oldX,a.oldY],[a.newX,a.newY],t,i,n);return o.signal*(e[1]-e[0])*o.pixel/o.pixelLength}),scrollMove:bi(function(e,t,n,r,i,a){return xi[r]([0,0],[a.scrollDelta,a.scrollDelta],t,i,n).signal*(e[1]-e[0])*a.scrollDelta})};function bi(e){return function(t,n,r,i){var a=this.range,o=a.slice(),s=t.axisModels[0];if(s&&(Qn(e(o,s,t,n,r,i),o,[0,100],`all`),this.range=o,a[0]!==o[0]||a[1]!==o[1]))return o}}var xi={grid:function(e,t,n,r,i){var a=n.axis,o={},s=i.model.coordinateSystem.getRect();return e||=[0,0],a.dim===`x`?(o.pixel=t[0]-e[0],o.pixelLength=s.width,o.pixelStart=s.x,o.signal=a.inverse?1:-1):(o.pixel=t[1]-e[1],o.pixelLength=s.height,o.pixelStart=s.y,o.signal=a.inverse?-1:1),o},polar:function(e,t,n,r,i){var a=n.axis,o={},s=i.model.coordinateSystem,c=s.getRadiusAxis().getExtent(),l=s.getAngleAxis().getExtent();return e=e?s.pointToCoord(e):[0,0],t=s.pointToCoord(t),n.mainType===`radiusAxis`?(o.pixel=t[0]-e[0],o.pixelLength=c[1]-c[0],o.pixelStart=c[0],o.signal=a.inverse?1:-1):(o.pixel=t[1]-e[1],o.pixelLength=l[1]-l[0],o.pixelStart=l[0],o.signal=a.inverse?-1:1),o},singleAxis:function(e,t,n,r,i){var a=n.axis,o=i.model.coordinateSystem.getRect(),s={};return e||=[0,0],a.orient===`horizontal`?(s.pixel=t[0]-e[0],s.pixelLength=o.width,s.pixelStart=o.x,s.signal=a.inverse?1:-1):(s.pixel=t[1]-e[1],s.pixelLength=o.height,s.pixelStart=o.y,s.signal=a.inverse?-1:1),s}};function Si(e){si(e),e.registerComponentModel(ci),e.registerComponentView(vi),_i(e)}K();var Ci=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.type=`dataZoom.slider`,t.layoutMode=`box`,t.defaultOption=Ze(ei.defaultOption,{show:!0,right:`ph`,top:`ph`,width:`ph`,height:`ph`,left:null,bottom:null,borderColor:W.color.accent10,borderRadius:0,backgroundColor:W.color.transparent,dataBackground:{lineStyle:{color:W.color.accent30,width:.5},areaStyle:{color:W.color.accent20,opacity:.2}},selectedDataBackground:{lineStyle:{color:W.color.accent40,width:.5},areaStyle:{color:W.color.accent20,opacity:.3}},fillerColor:`rgba(135,175,274,0.2)`,handleIcon:`path://M-9.35,34.56V42m0-40V9.5m-2,0h4a2,2,0,0,1,2,2v21a2,2,0,0,1-2,2h-4a2,2,0,0,1-2-2v-21A2,2,0,0,1-11.35,9.5Z`,handleSize:`100%`,handleStyle:{color:W.color.neutral00,borderColor:W.color.accent20},moveHandleSize:7,moveHandleIcon:`path://M-320.9-50L-320.9-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-348-41-339-50-320.9-50z M-212.3-50L-212.3-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-239.4-41-230.4-50-212.3-50z M-103.7-50L-103.7-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-130.9-41-121.8-50-103.7-50z`,moveHandleStyle:{color:W.color.accent40,opacity:.5},showDetail:!0,showDataShadow:`auto`,realtime:!0,zoomLock:!1,textStyle:{color:W.color.tertiary},brushSelect:!0,brushStyle:{color:W.color.accent30,opacity:.3},emphasis:{handleLabel:{show:!0},handleStyle:{borderColor:W.color.accent40},moveHandleStyle:{opacity:.8}},defaultLocationEdgeGap:15}),t}(ei);K();var wi=we,Ti=1,Ei=30,Di=7,Oi=`horizontal`,ki=`vertical`,Ai=5,ji=[`line`,`bar`,`candlestick`,`scatter`],Mi={easing:`cubicOut`,duration:100,delay:0},Ni=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n._displayables={},n}return t.prototype.init=function(e,t){this.api=t,this._onBrush=G(this._onBrush,this),this._onBrushEnd=G(this._onBrushEnd,this)},t.prototype.render=function(t,n,r,i){if(e.prototype.render.apply(this,arguments),Pe(this,`_dispatchZoomAction`,t.get(`throttle`),`fixRate`),this._orient=t.getOrient(),t.get(`show`)===!1){this.group.removeAll();return}if(t.noTarget()){this._clear(),this.group.removeAll();return}(!i||i.type!==`dataZoom`||i.from!==this.uid)&&this._buildView(),this._updateView()},t.prototype.dispose=function(){this._clear(),e.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){j(this,`_dispatchZoomAction`);var e=this.api.getZr();e.off(`mousemove`,this._onBrush),e.off(`mouseup`,this._onBrushEnd)},t.prototype._buildView=function(){var e=this.group;e.removeAll(),this._brushing=!1,this._displayables.brushRect=null,this._resetLocation(),this._resetInterval();var t=this._displayables.sliderGroup=new zt;this._renderBackground(),this._renderHandle(),this._renderDataShadow(),e.add(t),this._positionGroup()},t.prototype._resetLocation=function(){var e=this.dataZoomModel,t=this.api,n=e.get(`brushSelect`)?Di:0,r=Ue(e,t).refContainer,i=this._findCoordRect(),a=e.get(`defaultLocationEdgeGap`,!0)||0,o=this._orient===Oi?{right:r.width-i.x-i.width,top:r.height-Ei-a-n,width:i.width,height:Ei}:{right:a,top:i.y,width:Ei,height:i.height},s=_t(e.option);k([`right`,`top`,`width`,`height`],function(e){s[e]===`ph`&&(s[e]=o[e])});var c=Tt(s,r);this._location={x:c.x,y:c.y},this._size=[c.width,c.height],this._orient===ki&&this._size.reverse()},t.prototype._positionGroup=function(){var e=this.group,t=this._location,n=this._orient,r=this.dataZoomModel.getFirstTargetAxisModel(),i=r&&r.get(`inverse`),a=this._displayables.sliderGroup,o=(this._dataShadowInfo||{}).otherAxisInverse;a.attr(n===Oi&&!i?{scaleY:o?1:-1,scaleX:1}:n===Oi&&i?{scaleY:o?1:-1,scaleX:-1}:n===ki&&!i?{scaleY:o?-1:1,scaleX:1,rotation:Math.PI/2}:{scaleY:o?-1:1,scaleX:-1,rotation:Math.PI/2});var s=e.getBoundingRect([a]),c=isNaN(s.x)?0:s.x,l=isNaN(s.y)?0:s.y;e.x=t.x-c,e.y=t.y-l,e.markRedraw()},t.prototype._getViewExtent=function(){return[0,this._size[0]]},t.prototype._renderBackground=function(){var e=this.dataZoomModel,t=this._size,n=this._displayables.sliderGroup,r=e.get(`brushSelect`);n.add(new wi({silent:!0,shape:{x:0,y:0,width:t[0],height:t[1]},style:{fill:e.get(`backgroundColor`)},z2:-40}));var i=new wi({shape:{x:0,y:0,width:t[0],height:t[1]},style:{fill:`transparent`},z2:0,onclick:G(this._onClickPanel,this)}),a=this.api.getZr();r?(i.on(`mousedown`,this._onBrushStart,this),i.cursor=`crosshair`,a.on(`mousemove`,this._onBrush),a.on(`mouseup`,this._onBrushEnd)):(a.off(`mousemove`,this._onBrush),a.off(`mouseup`,this._onBrushEnd)),n.add(i)},t.prototype._renderDataShadow=function(){var e=this._dataShadowInfo=this._prepareDataShadowInfo();if(this._displayables.dataShadowSegs=[],!e)return;var t=this._size,n=this._shadowSize||[],r=e.series,i=r.getRawData(),a=r.getShadowDim&&r.getShadowDim(),o=a&&i.getDimensionInfo(a)?r.getShadowDim():e.otherDim;if(o==null)return;var s=this._shadowPolygonPts,c=this._shadowPolylinePts;if(i!==this._shadowData||o!==this._shadowDim||t[0]!==n[0]||t[1]!==n[1]){var l=i.getDataExtent(e.thisDim),u=i.getDataExtent(o),d=(u[1]-u[0])*.3;u=[u[0]-d,u[1]+d];var f=[0,t[1]],p=[0,t[0]],m=[[t[0],0],[0,0]],h=[],g=p[1]/Math.max(1,i.count()-1),_=t[0]/(l[1]-l[0]),v=e.thisAxis.type===`time`,y=-g,b=Math.round(i.count()/t[0]),x;i.each([e.thisDim,o],function(e,t,n){if(b>0&&n%b){v||(y+=g);return}y=v?(+e-l[0])*_:y+g;var r=t==null||isNaN(t)||t===``,i=r?0:H(t,u,f,!0);r&&!x&&n?(m.push([m[m.length-1][0],0]),h.push([h[h.length-1][0],0])):!r&&x&&(m.push([y,0]),h.push([y,0])),r||(m.push([y,i]),h.push([y,i])),x=r}),s=this._shadowPolygonPts=m,c=this._shadowPolylinePts=h}this._shadowData=i,this._shadowDim=o,this._shadowSize=[t[0],t[1]];var S=this.dataZoomModel;function C(e){var t=S.getModel(e?`selectedDataBackground`:`dataBackground`),n=new zt,r=new re({shape:{points:s},segmentIgnoreThreshold:1,style:t.getModel(`areaStyle`).getAreaStyle(),silent:!0,z2:-20}),i=new te({shape:{points:c},segmentIgnoreThreshold:1,style:t.getModel(`lineStyle`).getLineStyle(),silent:!0,z2:-19});return n.add(r),n.add(i),n}for(var w=0;w<3;w++){var T=C(w===1);this._displayables.sliderGroup.add(T),this._displayables.dataShadowSegs.push(T)}},t.prototype._prepareDataShadowInfo=function(){var e=this.dataZoomModel,t=e.get(`showDataShadow`);if(t!==!1){var n,r=this.ecModel;return e.eachTargetAxis(function(i,a){k(e.getAxisProxy(i,a).getTargetSeriesModels(),function(e){if(!n&&!(t!==!0&&u(ji,e.get(`type`))<0)){var o=r.getComponent(Kr(i),a).axis,s=Fi(i),c,l=e.coordinateSystem;s!=null&&l.getOtherAxis&&(c=l.getOtherAxis(o).inverse),s=e.getData().mapDimension(s),n={thisAxis:o,series:e,thisDim:e.getData().mapDimension(i),otherDim:s,otherAxisInverse:c}}},this)},this),n}},t.prototype._renderHandle=function(){var e=this.group,t=this._displayables,n=t.handles=[null,null],r=t.handleLabels=[null,null],i=this._displayables.sliderGroup,a=this._size,o=this.dataZoomModel,s=this.api,c=o.get(`borderRadius`)||0,l=o.get(`brushSelect`),u=t.filler=new wi({silent:l,style:{fill:o.get(`fillerColor`)},textConfig:{position:`inside`}});i.add(u),i.add(new wi({silent:!0,subPixelOptimize:!0,shape:{x:0,y:0,width:a[0],height:a[1],r:c},style:{stroke:o.get(`dataBackgroundColor`)||o.get(`borderColor`),lineWidth:Ti,fill:W.color.transparent}})),k([0,1],function(t){var a=o.get(`handleIcon`);!P[a]&&a.indexOf(`path://`)<0&&a.indexOf(`image://`)<0&&(a=`path://`+a);var s=Se(a,-1,0,2,2,null,!0);s.attr({cursor:Ii(this._orient),draggable:!0,drift:G(this._onDragMove,this,t),ondragend:G(this._onDragEnd,this),onmouseover:G(this._onOverDataInfoTriggerArea,this,!0),onmouseout:G(this._onOverDataInfoTriggerArea,this,!1),z2:5});var c=s.getBoundingRect(),l=o.get(`handleSize`);this._handleHeight=Be(l,this._size[1]),this._handleWidth=c.width/c.height*this._handleHeight,s.setStyle(o.getModel(`handleStyle`).getItemStyle()),s.style.strokeNoScale=!0,s.rectHover=!0,s.ensureState(`emphasis`).style=o.getModel([`emphasis`,`handleStyle`]).getItemStyle(),S(s);var u=o.get(`handleColor`);u!=null&&(s.style.fill=u),i.add(n[t]=s);var d=o.getModel(`textStyle`),f=(o.get(`handleLabel`)||{}).show||!1;e.add(r[t]=new D({silent:!0,invisible:!f,style:pt(d,{x:0,y:0,text:``,verticalAlign:`middle`,align:`center`,fill:d.getTextColor(),font:d.getFont()}),z2:10}))},this);var d=u;if(l){var f=Be(o.get(`moveHandleSize`),a[1]),p=t.moveHandle=new we({style:o.getModel(`moveHandleStyle`).getItemStyle(),silent:!0,shape:{r:[0,0,2,2],y:a[1]-.5,height:f}}),m=f*.8,h=t.moveHandleIcon=Se(o.get(`moveHandleIcon`),-m/2,-m/2,m,m,W.color.neutral00,!0);h.silent=!0,h.y=a[1]+f/2-.5,p.ensureState(`emphasis`).style=o.getModel([`emphasis`,`moveHandleStyle`]).getItemStyle();var g=Math.min(a[1]/2,Math.max(f,10));d=t.moveZone=new we({invisible:!0,shape:{y:a[1]-g,height:f+g}}),d.on(`mouseover`,function(){s.enterEmphasis(p)}).on(`mouseout`,function(){s.leaveEmphasis(p)}),i.add(p),i.add(h),i.add(d)}d.attr({draggable:!0,cursor:`grab`,drift:G(this._onActualMoveZoneDrift,this),ondragstart:G(this._onActualMoveZoneDragStart,this),ondragend:G(this._onActualMoveZoneDragEnd,this),onmouseover:G(this._onOverDataInfoTriggerArea,this,!0),onmouseout:G(this._onOverDataInfoTriggerArea,this,!1)})},t.prototype._resetInterval=function(){var e=this._range=this.dataZoomModel.getPercentRange(),t=this._getViewExtent();this._handleEnds=[H(e[0],[0,100],t,!0),H(e[1],[0,100],t,!0)]},t.prototype._updateInterval=function(e,t){var n=this.dataZoomModel,r=this._handleEnds,i=this._getViewExtent(),a=n.findRepresentativeAxisProxy().getMinMaxSpan(),o=[0,100];Qn(t,r,i,n.get(`zoomLock`)?`all`:e,a.minSpan==null?null:H(a.minSpan,o,i,!0),a.maxSpan==null?null:H(a.maxSpan,o,i,!0));var s=this._range,c=this._range=ut([H(r[0],i,o,!0),H(r[1],i,o,!0)]);return!s||s[0]!==c[0]||s[1]!==c[1]},t.prototype._updateView=function(e){var t=this._displayables,n=this._handleEnds,r=ut(n.slice()),i=this._size;k([0,1],function(e){var r=t.handles[e],a=this._handleHeight;r.attr({scaleX:a/2,scaleY:a/2,x:n[e]+(e?-1:1),y:i[1]/2-a/2})},this),t.filler.setShape({x:r[0],y:0,width:r[1]-r[0],height:i[1]});var a={x:r[0],width:r[1]-r[0]};t.moveHandle&&(t.moveHandle.setShape(a),t.moveZone.setShape(a),t.moveZone.getBoundingRect(),t.moveHandleIcon&&t.moveHandleIcon.attr(`x`,a.x+a.width/2));for(var o=t.dataShadowSegs,s=[0,r[0],r[1],i[0]],c=0;c<o.length;c++){var l=o[c],u=l.getClipPath();u||(u=new we,l.setClipPath(u)),u.setShape({x:s[c],y:0,width:s[c+1]-s[c],height:i[1]})}this._updateDataInfo(e)},t.prototype._updateDataInfo=function(e){var t=this.dataZoomModel,n=this._displayables,r=n.handleLabels,i=this._orient,a=[``,``];if(t.get(`showDetail`)){var o=t.findRepresentativeAxisProxy(),s=o.getAxisModel().axis.scale;if(o){var c=this._range,l;if(e){var u={start:c[0],end:c[1]},d=Qr(t,o);if(d){var f=d.calculateDataWindow(u).percentInverted;u={start:f[0],end:f[1]}}l=o.calculateDataWindow(u)}else l=o.getWindow();a=[Pi(t,0,l,s),Pi(t,1,l,s)]}}var p=ut(this._handleEnds.slice());m.call(this,0),m.call(this,1);function m(e){var t=Lt(n.handles[e].parent,this.group),o=Pt(e===0?`right`:`left`,t),s=this._handleWidth/2+Ai,c=Mt([p[e]+(e===0?-s:s),this._size[1]/2],t);r[e].setStyle({x:c[0],y:c[1],verticalAlign:i===Oi?`middle`:o,align:i===Oi?o:`center`,text:a[e]})}},t.prototype._onOverDataInfoTriggerArea=function(e){this._isOverDataInfoTriggerArea=e,this._showDataInfo(e)},t.prototype._showDataInfo=function(e){var t=(this.dataZoomModel.get(`handleLabel`)||{}).show||!1,n=this.dataZoomModel.getModel([`emphasis`,`handleLabel`]).get(`show`)||!1,r=e||this._dragging?n:t,i=this._displayables,a=i.handleLabels;a[0].attr(`invisible`,!r),a[1].attr(`invisible`,!r),i.moveHandle&&this.api[r?`enterEmphasis`:`leaveEmphasis`](i.moveHandle,1)},t.prototype._onActualMoveZoneDrift=function(e,t,n){this.api.getZr().setCursorStyle(`grabbing`),this._onDragMove(`all`,e,t,n)},t.prototype._onActualMoveZoneDragStart=function(e){e.target.attr(`cursor`,`grabbing`),this._showDataInfo(!0)},t.prototype._onActualMoveZoneDragEnd=function(e){e.target.attr(`cursor`,`grab`),this._onDragEnd()},t.prototype._onDragMove=function(e,t,n,r){this._dragging=!0,ct(r.event);var i=this._displayables.sliderGroup.getLocalTransform(),a=Mt([t,n],i,!0),o=this._updateInterval(e,a[0]),s=this.dataZoomModel.get(`realtime`);this._updateView(!s),o&&s&&this._dispatchZoomAction(!0)},t.prototype._onDragEnd=function(){this._dragging=!1,this._isOverDataInfoTriggerArea||this._showDataInfo(!1),!this.dataZoomModel.get(`realtime`)&&this._dispatchZoomAction(!1)},t.prototype._onClickPanel=function(e){var t=this._size,n=this._displayables.sliderGroup.transformCoordToLocal(e.offsetX,e.offsetY);if(!(n[0]<0||n[0]>t[0]||n[1]<0||n[1]>t[1])){var r=this._handleEnds,i=(r[0]+r[1])/2,a=this._updateInterval(`all`,n[0]-i);this._updateView(),a&&this._dispatchZoomAction(!1)}},t.prototype._onBrushStart=function(e){var t=e.offsetX,n=e.offsetY;this._brushStart=new h(t,n),this._brushing=!0,this._brushStartTime=+new Date},t.prototype._onBrushEnd=function(e){if(this._brushing){var t=this._displayables.brushRect;if(this._brushing=!1,t){t.attr(`ignore`,!0);var n=t.shape;if(!(+new Date-this._brushStartTime<200&&Math.abs(n.width)<5)){var r=this._getViewExtent(),i=[0,100],a=this._handleEnds=[n.x,n.x+n.width],o=this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();Qn(0,a,r,0,o.minSpan==null?null:H(o.minSpan,i,r,!0),o.maxSpan==null?null:H(o.maxSpan,i,r,!0)),this._range=ut([H(a[0],r,i,!0),H(a[1],r,i,!0)]),this._updateView(),this._dispatchZoomAction(!1)}}}},t.prototype._onBrush=function(e){this._brushing&&(ct(e.event),this._updateBrushRect(e.offsetX,e.offsetY))},t.prototype._updateBrushRect=function(e,t){var n=this._displayables,r=this.dataZoomModel,i=n.brushRect;i||(i=n.brushRect=new wi({silent:!0,style:r.getModel(`brushStyle`).getItemStyle()}),n.sliderGroup.add(i)),i.attr(`ignore`,!1);var a=this._brushStart,o=this._displayables.sliderGroup,s=o.transformCoordToLocal(e,t),c=o.transformCoordToLocal(a.x,a.y),l=this._size;s[0]=Math.max(Math.min(l[0],s[0]),0),i.setShape({x:c[0],y:0,width:s[0]-c[0],height:l[1]})},t.prototype._dispatchZoomAction=function(e){var t=this._range;this.api.dispatchAction({type:`dataZoom`,from:this.uid,dataZoomId:this.dataZoomModel.id,animation:e?Mi:null,start:t[0],end:t[1]})},t.prototype._findCoordRect=function(){var e,t=Jr(this.dataZoomModel).infoList;if(!e&&t.length){var n=t[0].model.coordinateSystem;e=n.getRect&&n.getRect()}if(!e){var r=this.api.getWidth(),i=this.api.getHeight();e={x:r*.2,y:i*.2,width:r*.6,height:i*.6}}return e},t.type=`dataZoom.slider`,t}(ni);function Pi(e,t,n,r){var i=e.get(`labelFormatter`),a=e.get(`labelPrecision`);(a==null||a===`auto`)&&(a=n.valuePrecision);var o=n.value[t],s=o==null||isNaN(o)?``:L(r)||pe(r)?r.getLabel({value:Math.round(o)}):isFinite(a)?jt(o,a,!0):o+``;return Ce(i)?i(o,s):F(i)?i.replace(`{value}`,s):s}function Fi(e){return{x:`y`,y:`x`,radius:`angle`,angle:`radius`}[e]}function Ii(e){return e===`vertical`?`ns-resize`:`ew-resize`}function Li(e){e.registerComponentModel(Ci),e.registerComponentView(Ni),si(e)}function Ri(e){se(Si),se(Li)}var Z=t(e(),1),Q=n();se([ye,Ln,Nt,f,ge,Ft,Gt,Ri,Vr,We]);function zi(e){return Kt(e)}function Bi(e){return e==null||e===0?`$0`:`$`+e.toFixed(2)}function Vi(e){return e?(e/3600).toFixed(1)+`h`:`0h`}var Hi=[{key:`tokens`,label:`Tokens`,fn:zi},{key:`elapsed_seconds`,label:`Time`,fn:Vi},{key:`cost`,label:`Cost`,fn:Bi}],Ui=[{key:`model`,label:`By Model`},{key:`family`,label:`By Work`}],Wi=[{key:`absolute`,label:`Absolute`},{key:`relative`,label:`Relative`}];function Gi(e){if(!e.current)return;let t=e.current.getEchartsInstance().getDataURL({type:`png`,pixelRatio:2,backgroundColor:`#06080f`});Object.assign(document.createElement(`a`),{href:t,download:`codexmeter-daily.png`}).click()}function Ki(e,t){if(!t)return{startValue:0,endValue:0};let n=t;return e===`d7`&&(n=7),e===`d30`&&(n=30),{startValue:t-Math.max(1,Math.min(n,t)),endValue:t-1}}var qi=280,$={left:70,right:20,bottom:12,height:24};function Ji(e,t,n){let r=e?.batch?.[0]??e,i=Math.max(0,t.length-1),a,o;return r&&typeof r.startValue==`number`&&typeof r.endValue==`number`?(a=r.startValue,o=r.endValue):r&&typeof r.start==`number`&&typeof r.end==`number`&&t.length?(a=Math.round(r.start/100*i),o=Math.round(r.end/100*i)):r&&typeof r.startValue==`string`&&typeof r.endValue==`string`&&t.length?(a=t.indexOf(r.startValue),o=t.indexOf(r.endValue),a<0&&(a=n.startValue),o<0&&(o=n.endValue)):(a=n.startValue,o=n.endValue),a=Math.max(0,Math.min(i,Math.floor(a))),o=Math.max(0,Math.min(i,Math.floor(o))),a>o?{startValue:o,endValue:a}:{startValue:a,endValue:o}}function Yi(e,t,n,r,i){if(cancelAnimationFrame(r.current),r.current=0,Math.round(e.startValue)===Math.round(t.startValue)&&Math.round(e.endValue)===Math.round(t.endValue))return;let a=0,o=s=>{a||=s;let c=Math.min(1,(s-a)/i),l=1-(1-c)**3;n({startValue:Math.round(e.startValue+(t.startValue-e.startValue)*l),endValue:Math.round(e.endValue+(t.endValue-e.endValue)*l)}),r.current=c<1?requestAnimationFrame(o):0};return r.current=requestAnimationFrame(o),()=>{cancelAnimationFrame(r.current),r.current=0}}function Xi(e,t){return{left:$.left,right:e-$.right,top:t-$.bottom-$.height,bottom:t-$.bottom}}function Zi(e,t,n,r){let i=Xi(e,t),a=Math.max(n-1,1),o=Math.max(0,Math.min(1,(r?.startValue??0)/a)),s=Math.max(0,Math.min(1,(r?.endValue??a)/a)),c=Math.max(0,i.right-i.left);return{...i,selectionLeft:i.left+c*Math.min(o,s),selectionRight:i.left+c*Math.max(o,s)}}function Qi(e,t){return e===`d7`?44:e===`d30`?22:t<=14?36:t<=31?18:14}function $i(e,t){return e===`d7`?8:e===`d30`?3:t<=31?2:+(t<=90)}function ea(e,t){return e===`d7`?`72%`:e===`d30`?`54%`:t<=14?`64%`:t<=31?`48%`:`36%`}function ta(e,t){return e?t===`elapsed_seconds`?e.elapsed_seconds||0:t===`cost`?e.cost||0:e.tokens||0:0}function na(e,t){if(!e)return`Day detail`;let n=Hi.find(e=>e.key===t)||Hi[0],r=new Date(`${e.date}T00:00:00`).toLocaleDateString(`en-US`,{weekday:`long`}),i=n.fn(ta(e,t));return`Day detail: ${r} - ${e.date} - ${n.label}: ${i}`}function ra(e,t){let n=e.length;if(n===0)return null;let r=Array(n),i=Array(n),a=[];for(let t=0;t<n;t++){for(;a.length&&e[a[a.length-1]]>=e[t];)a.pop();r[t]=a.length?a[a.length-1]:-1,a.push(t)}a.length=0;for(let t=n-1;t>=0;t--){for(;a.length&&e[a[a.length-1]]>=e[t];)a.pop();i[t]=a.length?a[a.length-1]:n,a.push(t)}let o=0,s=0;for(let t=0;t<n;t++){let n=(i[t]-r[t]-1)*e[t];n>o&&(o=n,s=t)}return[(r[s]+i[s])/2,t[s]+e[s]/2]}function ia({day:e,chartMode:t}){let n=(0,Z.useMemo)(()=>Jt(e.by_model),[e.by_model]),r=(0,Z.useMemo)(()=>Jt(e.by_repo),[e.by_repo]),a=(0,Z.useMemo)(()=>Jt(e.by_family),[e.by_family]),o=qt({title:`Models`,rows:n,valueKey:`tokens`,colorForKey:At,valueFormatter:zi,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1}),s=qt({title:`Repos`,rows:r,valueKey:`tokens`,colorForKey:Rt,valueFormatter:zi,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1}),c=qt({title:`Work Type`,rows:a,valueKey:`tokens`,colorForKey:ze,valueFormatter:zi,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1});return(0,Q.jsx)(`div`,{className:`model-detail-wrap`,children:(0,Q.jsxs)(`div`,{className:`model-detail-charts`,children:[(0,Q.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,Q.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Repos`}),(0,Q.jsx)(i,{echarts:ne,option:s,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,Q.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,Q.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Models`}),(0,Q.jsx)(i,{echarts:ne,option:o,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,Q.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,Q.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Work Type`}),(0,Q.jsx)(i,{echarts:ne,option:c,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]})]})})}var aa=Z.memo(function({daily:e,range:t,metric:n,split:r,displayMode:a,onSelectDate:o,navigateToDayRequest:s,onNavigateToDayConsumed:c}){let[l,u]=(0,Z.useState)({startValue:0,endValue:0}),d=(0,Z.useRef)(null),f=(0,Z.useRef)(l);f.current=l;let p=(0,Z.useRef)(0),m=(0,Z.useRef)(null),h=(0,Z.useRef)(0),g=(0,Z.useRef)(!1),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useRef)(0),b=(0,Z.useMemo)(()=>e.map(e=>e.date),[e]),x=Hi.find(e=>e.key===n),S=(0,Z.useMemo)(()=>Ki(t,b.length),[t,b.length]);(0,Z.useEffect)(()=>{if(!b.length)return;let e=Ki(t,b.length),n=v.current===null,r=!n&&v.current!==t,i=!n&&y.current!==b.length;if(v.current=t,y.current=b.length,cancelAnimationFrame(h.current),h.current=0,n){u(e);return}if(r)return Yi(f.current,e,u,h,qi);i&&u(e)},[t,b.length]),(0,Z.useEffect)(()=>()=>{cancelAnimationFrame(p.current),p.current=0,_.current?.(),_.current=null},[]);let C=(0,Z.useCallback)(()=>{let e=d.current?.getEchartsInstance?.();if(!e)return;_.current?.();let t=e.getZr(),n=n=>{let r=n?.offsetX??n?.zrX,i=n?.offsetY??n?.zrY;if(!Number.isFinite(r)||!Number.isFinite(i)){t.setCursorStyle(`default`);return}let a=Zi(e.getWidth(),e.getHeight(),b.length,f.current);if(!(r>=a.left&&r<=a.right&&i>=a.top&&i<=a.bottom)){t.setCursorStyle(`default`);return}if(r>=a.selectionLeft&&r<=a.selectionRight){t.setCursorStyle(g.current?`grabbing`:`grab`);return}t.setCursorStyle(`ew-resize`)},r=e=>n(e),i=t=>{let r=t?.offsetX??t?.zrX,i=t?.offsetY??t?.zrY;if(!Number.isFinite(r)||!Number.isFinite(i))return;let a=Zi(e.getWidth(),e.getHeight(),b.length,f.current);g.current=r>=a.selectionLeft&&r<=a.selectionRight&&i>=a.top&&i<=a.bottom,n(t)},a=e=>{g.current=!1,n(e)},o=()=>{g.current=!1,t.setCursorStyle(`default`)};t.on(`mousemove`,r),t.on(`mousedown`,i),t.on(`mouseup`,a),t.on(`globalout`,o),_.current=()=>{t.off(`mousemove`,r),t.off(`mousedown`,i),t.off(`mouseup`,a),t.off(`globalout`,o),t.setCursorStyle(`default`)}},[b.length]),w=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!s){w.current=null;return}let{id:t,centerDate:n}=s;if(!n||!e.length||w.current===t)return;let r=e.map(e=>e.date),i=r.indexOf(n);if(i<0){c?.();return}w.current=t;let a=Math.max(0,i-3),l=Math.min(r.length-1,i+3);cancelAnimationFrame(h.current),h.current=0,u({startValue:a,endValue:l}),o(n),c?.()},[s,e,o,c]);let T=(0,Z.useMemo)(()=>{if(!b.length)return 0;let e=Math.max(0,Math.min(b.length-1,Math.floor(l.startValue??S.startValue??0))),t=Math.max(e,Math.min(b.length-1,Math.floor(l.endValue??S.endValue??b.length-1)));return Math.max(1,t-e+1)},[b.length,l,S]),E=(0,Z.useMemo)(()=>{if(!b.length)return{startIdx:0,endIdx:-1};let e=Math.max(0,Math.min(b.length-1,Math.floor(l.startValue??S.startValue??0)));return{startIdx:e,endIdx:Math.max(e,Math.min(b.length-1,Math.floor(l.endValue??S.endValue??b.length-1)))}},[b.length,l,S]),D=(0,Z.useMemo)(()=>Qi(t,T),[t,T]),O=(0,Z.useMemo)(()=>$i(t,T),[t,T]),k=(0,Z.useMemo)(()=>ea(t,T),[t,T]),A=(0,Z.useMemo)(()=>Ht(e,{split:r,metric:n}),[e,r,n]),j=A.groups,M=(0,Z.useMemo)(()=>A.series.map(e=>({name:e.key,values:e.data})),[A.series]),N=A.dayTotals,P=(0,Z.useMemo)(()=>{if(!N.length||E.endIdx<E.startIdx)return 0;let e=0;for(let t=E.startIdx;t<=E.endIdx;t++)e=Math.max(e,N[t]||0);return e},[N,E]),F=a===`relative`,I=(0,Z.useMemo)(()=>({dates:b,series:M.map(e=>({key:e.name,label:e.name,data:e.values}))}),[b,M]),L=`${n}\0${r}`,R=Wt(I,!F,L),ee=(0,Z.useMemo)(()=>new Map((R?.series||[]).map(e=>[e.key,e])),[R]),z=(0,Z.useMemo)(()=>{if(F)return N;let e=b.length,t=Array(e).fill(0);for(let n of R?.series||[])for(let r=0;r<e;r++)t[r]+=n.data[r]||0;return t},[F,N,R,b.length]),B=(0,Z.useMemo)(()=>{if(a===`relative`)return 100;if(P)return Math.ceil(P*1.1)},[a,P]),te=(0,Z.useMemo)(()=>{if(!F)return null;if(!M.length)return[];let e=M.map(e=>{let t=e.values.map((e,t)=>N[t]>0?e/N[t]*100:0);for(let e=1;e<t.length;e++)N[e]===0&&(t[e]=t[e-1]);return t}),t=e[0].map(()=>0);return e.map((e,n)=>{let r=[...t];return t=t.map((t,n)=>t+e[n]),{values:e,prevStack:r}})},[F,M,N]),V=(0,Z.useMemo)(()=>F?j.map((e,t)=>{let n=r===`model`?At(e):ze(e);if(!M[t])return null;let i=te[t];return i?{id:`daily-${r}-${e}`,name:e,type:`line`,stack:`total`,smooth:.2,areaStyle:{opacity:1},lineStyle:{width:0},symbol:`none`,data:i.values,itemStyle:{color:n}}:null}).filter(Boolean):j.map(e=>{let t=r===`model`?At(e):ze(e),n=ee.get(e)?.data??b.map(()=>0);return{id:`daily-${r}-${e}`,name:e,type:`bar`,stack:`total`,data:n,itemStyle:{color:t},barWidth:k,barMaxWidth:D,barMinWidth:O}}),[F,j,r,te,M,ee,b,k,D,O]),re=(0,Z.useMemo)(()=>!F||!te?[]:te.map((e,t)=>{let n=M[t],i=et(r===`model`?At(n.name):ze(n.name)),a=ra(e.values,e.prevStack);return!a||Math.max(...e.values)<8?null:{name:n.name,labelColor:i,coord:a}}).filter(Boolean),[F,te,M,r]),ie=(0,Z.useCallback)(()=>{if(!d.current)return;let e=d.current.getEchartsInstance();if(!F||re.length===0){e.setOption({graphic:{elements:[]}},{notMerge:!1});return}let t=re.map(t=>{let[n,r]=e.convertToPixel({xAxisIndex:0,yAxisIndex:0},t.coord);return{type:`text`,left:n,top:r,style:{text:t.name,fill:t.labelColor,fontSize:10,fontWeight:500,textAlign:`center`,textVerticalAlign:`middle`},z:10,silent:!0}});e.setOption({graphic:{elements:t}},{notMerge:!1})},[F,re]);(0,Z.useEffect)(()=>{let e=setTimeout(ie,150);return()=>clearTimeout(e)},[F,re,ie]),(0,Z.useEffect)(()=>{let e=()=>ie();return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[ie]),(0,Z.useEffect)(()=>{C()},[C,l]);let ae={backgroundColor:`transparent`,tooltip:{trigger:`axis`,axisPointer:{type:F?`line`:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{if(!e?.length)return``;let t=e[0]?.dataIndex,n=z,r=t==null?0:n[t],i=t;if(a===`relative`&&r===0&&t!=null){for(let e=t-1;e>=0;e--)if(n[e]>0){i=e;break}}let o=a===`relative`&&r===0?n[i]??0:r,s=`<b>${e[0]?.axisValue??``}</b><br/>`,c=[...e].filter(e=>e.value>0).sort((e,t)=>(t.value||0)-(e.value||0));for(let e of c){let t=a===`relative`?M.find(t=>t.name===e.seriesName)?.values[i]??0:e.value;a===`relative`?s+=`${e.marker} ${e.seriesName}: ${e.value.toFixed(1)}% (${x.fn(t)})<br/>`:s+=`${e.marker} ${e.seriesName}: ${x.fn(e.value)}<br/>`}return s+=a===`relative`?`<b>Total: 100% (${x.fn(o)})</b>`:`<b>Total: ${x.fn(r)}</b>`,s}},legend:{data:j,textStyle:{color:`#8b949e`,fontSize:10},top:0,itemWidth:10,itemHeight:10},grid:{left:$.left,right:$.right,top:35,bottom:55},dataZoom:[{type:`slider`,startValue:l.startValue,endValue:l.endValue,left:$.left,right:$.right,bottom:$.bottom,height:$.height,borderColor:`#30363d`,fillerColor:`rgba(99, 102, 241, 0.08)`,handleStyle:{color:`#6366f1`},textStyle:{color:`#484f58`}}],xAxis:{type:`category`,data:b,boundaryGap:a!==`relative`,axisLabel:{color:`#484f58`,fontSize:10,rotate:45},axisTick:{show:!1},axisLine:{lineStyle:{color:`#30363d`}}},yAxis:{type:`value`,min:0,max:a===`relative`?100:B,scale:!1,axisLabel:{formatter:a===`relative`?e=>e+`%`:e=>x.fn(e),color:`#484f58`},splitLine:{lineStyle:{color:`#21262d`}}},series:V,...F?Et:Ct};return(0,Q.jsxs)(`div`,{className:`chart-card`,children:[(0,Q.jsx)(`button`,{className:`export-btn`,onClick:()=>Gi(d),children:`PNG`}),(0,Q.jsx)(i,{ref:d,echarts:ne,option:ae,style:{height:400},theme:`dark`,notMerge:!1,replaceMerge:[`series`,`legend`,`graphic`],lazyUpdate:!1,onChartReady:()=>{ie(),C()},onEvents:{click:e=>{let t=e?.axisValue||e?.name;t&&o(t)},datazoom:e=>{m.current=Ji(e,b,f.current),p.current||=requestAnimationFrame(()=>{p.current=0,m.current&&=(u(m.current),null),F&&ie()})}}})]})});function oa({data:e,range:t=`total`,chartMode:n=`default`,navigateToDayRequest:r=null,onNavigateToDayConsumed:i}){let[a,o]=(0,Z.useState)(`tokens`),[s,c]=(0,Z.useState)(`model`),[l,u]=(0,Z.useState)(`absolute`),[d,f]=(0,Z.useState)(null),p=(0,Z.useMemo)(()=>e?.data?.length?Ut(e):[],[e]);(0,Z.useEffect)(()=>{!d&&p[0]&&f(p[p.length-1]?.date||p[0]?.date)},[p,d]);let m=(0,Z.useCallback)(e=>{e&&f(e)},[]),h=p.find(e=>e.date===d)||null;return p.length?(0,Q.jsxs)(`div`,{className:`animate-in`,children:[(0,Q.jsxs)(`div`,{className:`section-header`,children:[(0,Q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`0.75rem`},children:(0,Q.jsx)(`span`,{className:`section-title`,children:`Daily Usage`})}),(0,Q.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`},children:[(0,Q.jsx)(`div`,{className:`btn-group`,children:Hi.map(e=>(0,Q.jsx)(`button`,{className:`btn ${a===e.key?`active`:``}`,onClick:()=>o(e.key),children:e.label},e.key))}),(0,Q.jsx)(`div`,{className:`btn-group`,children:Ui.map(e=>(0,Q.jsx)(`button`,{className:`btn ${s===e.key?`active`:``}`,onClick:()=>c(e.key),children:e.label},e.key))}),(0,Q.jsx)(`div`,{className:`btn-group`,children:Wi.map(e=>(0,Q.jsx)(`button`,{className:`btn ${l===e.key?`active`:``}`,onClick:()=>u(e.key),children:e.label},e.key))})]})]}),(0,Q.jsx)(aa,{daily:p,range:t,metric:a,split:s,displayMode:l,onSelectDate:m,navigateToDayRequest:r,onNavigateToDayConsumed:i}),h&&(0,Q.jsxs)(`div`,{className:`chart-card`,children:[(0,Q.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.75rem`},children:na(h,a)}),(0,Q.jsx)(ia,{day:h,chartMode:n})]})]}):(0,Q.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem`},children:`No data`})}export{oa as default};
@@ -0,0 +1 @@
1
+ import{c as e,p as t,t as n}from"./index-Bxd44dxc.js";import{$n as r,C as i,N as a,P as o,S as s,T as c,a as l,b as u,g as d,t as f,v as p,w as m,x as h}from"./animationsDefault-C_urdfl6.js";import{t as g}from"./formatters-lxlIPan_.js";import{n as _}from"./subcharts-CA6MYRo3.js";var v=t(e(),1),y=n();o([c,m,i,s,h,u]);function b(e){return g(e)}function x(e){return e==null||e===0?`—`:e>=1e3?`$`+(e/1e3).toFixed(1)+`K`:`$`+e.toFixed(2)}var S=[`low`,`medium`,`high`,`xhigh`,`max`,`unknown`];function C(e){return[...e].sort(([e],[t])=>{let n=S.indexOf((e||``).toLowerCase()),r=S.indexOf((t||``).toLowerCase());return(n===-1?999:n)-(r===-1?999:r)})}function w({model:e,fmt:t,chartMode:n}){let[i,o]=(0,v.useState)(!1),s=(0,v.useMemo)(()=>C(Object.entries(e.by_effort||{})),[e.by_effort]);if(!s.length)return null;let c=s.map(([e,t])=>({effort:e,sessions:t.sessions,tokens:t.tokens,avgTokens:t.sessions?Math.round(t.tokens/t.sessions):0,cost:t.cost,exactPriced:t.exact_priced||0,fallbackPriced:t.heuristic_priced||0})),l=c.map(e=>({key:e.effort,sessions:e.sessions,tokens:e.tokens,avgTokens:e.avgTokens})),u=_({title:`Sessions by effort`,rows:l,valueKey:`sessions`,colorForKey:d,valueFormatter:e=>Math.round(e).toLocaleString(),chartMode:n,defaultMode:`donut`,renderTitleInChart:!1}),f=_({title:`Tokens by effort`,rows:l,valueKey:`tokens`,colorForKey:d,valueFormatter:t,chartMode:n,defaultMode:`donut`,renderTitleInChart:!1}),p=_({title:`Avg tokens per session`,rows:l,valueKey:`avgTokens`,colorForKey:d,valueFormatter:t,chartMode:n,defaultMode:`bar`,renderTitleInChart:!1});return(0,y.jsxs)(`div`,{className:`model-detail-wrap`,children:[(0,y.jsxs)(`div`,{className:`model-detail-charts`,children:[(0,y.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,y.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Sessions by effort`}),(0,y.jsx)(r,{echarts:a,option:u,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,y.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,y.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Tokens by effort`}),(0,y.jsx)(r,{echarts:a,option:f,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,y.jsxs)(`div`,{className:`model-detail-bar`,children:[(0,y.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Avg tokens per session`}),(0,y.jsx)(r,{echarts:a,option:p,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]})]}),(0,y.jsx)(`div`,{className:`model-detail-footer`,children:(0,y.jsxs)(`button`,{type:`button`,className:`model-detail-toggle`,onClick:()=>o(e=>!e),"aria-expanded":i,children:[(0,y.jsx)(`span`,{className:`model-detail-toggle-text`,children:i?`Hide details`:`Show details`}),(0,y.jsx)(`span`,{className:`model-detail-toggle-arrow ${i?`expanded`:``}`,"aria-hidden":!0,children:`▼`})]})}),(0,y.jsx)(`div`,{className:`model-detail-summary-wrap ${i?`expanded`:``}`,children:(0,y.jsx)(`div`,{className:`model-detail-summary`,children:c.map(e=>(0,y.jsxs)(`div`,{className:`model-detail-summary-card`,children:[(0,y.jsxs)(`div`,{className:`model-detail-summary-head`,children:[(0,y.jsx)(`span`,{className:`model-detail-swatch`,style:{background:d(e.effort)}}),(0,y.jsx)(`span`,{className:`model-detail-summary-name`,title:e.effort,children:e.effort})]}),(0,y.jsxs)(`div`,{className:`model-detail-summary-line`,children:[e.sessions,` sessions`]}),(0,y.jsxs)(`div`,{className:`model-detail-summary-line`,children:[t(e.tokens),` tokens`]}),(0,y.jsxs)(`div`,{className:`model-detail-summary-line`,children:[t(e.avgTokens),` avg/session`]}),(0,y.jsxs)(`div`,{className:`model-detail-summary-line`,children:[x(e.cost),` cost`]}),(0,y.jsxs)(`div`,{className:`model-detail-summary-line`,children:[e.exactPriced,` exact · `,e.fallbackPriced,` fallback`]})]},e.effort))})})]})}function T(e){if(!e.current)return;let t=e.current.getEchartsInstance().getDataURL({type:`png`,pixelRatio:2,backgroundColor:`#06080f`});Object.assign(document.createElement(`a`),{href:t,download:`codexmeter-models.png`}).click()}function E(e,t=`total`){let n=e?.data;return Array.isArray(n)?n:n?.[t]||n?.total||[]}function D({data:e,range:t=`total`,chartMode:n=`default`,focusRequest:i=null,onFocusRequestConsumed:o}){let[s,c]=(0,v.useState)(null),u=(0,v.useRef)(null),d=(0,v.useRef)(null),m=(0,v.useMemo)(()=>E(e,t),[e,t]);(0,v.useEffect)(()=>{s&&(m.some(e=>e.model_name===s)||c(null))},[s,m]),(0,v.useEffect)(()=>{if(!i){d.current=null;return}let{id:e,modelName:t}=i;if(!t||d.current===e)return;let n=m.find(e=>e.model_name===t);d.current=e,n&&c(n.model_name),o?.()},[i,m,o]);let h=[...m].reverse(),g=Math.max(...m.map(e=>e.tokens||0),0),_=Math.max(180,m.length*34),S=(0,v.useMemo)(()=>({backgroundColor:`transparent`,...f,tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{let t=m[m.length-1-e[0].dataIndex];return`<b>${t.model_name}</b><br/>Tokens: ${b(t.tokens)}<br/>Cost: ${x(t.cost)}<br/>Sessions: ${t.sessions}`}},grid:{left:160,right:50,top:8,bottom:8},xAxis:{type:`value`,splitNumber:4,max:g||1,axisLabel:{formatter:e=>b(e),color:`#484f58`,fontSize:10,showMinLabel:!0,showMaxLabel:!0},splitLine:{lineStyle:{color:[`transparent`,`#21262d`,`#21262d`,`#21262d`,`transparent`]}}},yAxis:{type:`category`,data:h.map(e=>e.model_name),axisLabel:{color:`#8b949e`,fontSize:11},axisTick:{show:!1},axisLine:{show:!1}},series:[{id:`models-range-bars`,type:`bar`,universalTransition:!0,data:h.map(e=>({id:e.model_name,name:e.model_name,value:e.tokens,itemStyle:{color:p(e.model_name),borderRadius:[0,3,3,0]}})),barMaxWidth:18,label:{show:!0,position:`right`,formatter:e=>b(e.value??0),color:`#8b949e`,fontSize:10,...l}}]}),[g,m,h]),C=(0,v.useMemo)(()=>({click:e=>{if(e?.componentType===`series`&&e?.dataIndex!=null){let t=m[m.length-1-e.dataIndex];t&&c(e=>e===t.model_name?null:t.model_name)}}}),[m]);return m?.length?(0,y.jsxs)(`div`,{className:`animate-in`,children:[(0,y.jsx)(`div`,{className:`section-header`,children:(0,y.jsx)(`span`,{className:`section-title`,children:`Models`})}),(0,y.jsxs)(`div`,{className:`chart-card`,children:[(0,y.jsx)(`button`,{className:`export-btn`,onClick:()=>T(u),children:`PNG`}),(0,y.jsx)(`div`,{style:{height:_,transition:`height 220ms cubic-bezier(0.22, 1, 0.36, 1)`},children:(0,y.jsx)(r,{ref:u,echarts:a,option:S,style:{height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1,onEvents:C})})]}),(0,y.jsx)(`div`,{className:`table-wrap`,children:(0,y.jsxs)(`table`,{children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{children:`Model`}),(0,y.jsx)(`th`,{children:`Tokens`}),(0,y.jsx)(`th`,{children:`Cost`}),(0,y.jsx)(`th`,{children:`Sessions`}),(0,y.jsx)(`th`,{children:`Effort Levels`})]})}),(0,y.jsx)(`tbody`,{children:m.map(e=>(0,y.jsxs)(v.Fragment,{children:[(0,y.jsxs)(`tr`,{onClick:()=>c(s===e.model_name?null:e.model_name),style:{cursor:`pointer`},children:[(0,y.jsxs)(`td`,{style:{fontWeight:500,color:`var(--text-primary)`,fontFamily:`var(--font-mono)`},children:[(0,y.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:2,background:p(e.model_name),marginRight:8}}),e.model_name]}),(0,y.jsx)(`td`,{style:{fontFamily:`var(--font-mono)`},children:b(e.tokens)}),(0,y.jsx)(`td`,{style:{fontFamily:`var(--font-mono)`},children:x(e.cost)}),(0,y.jsx)(`td`,{children:e.sessions}),(0,y.jsx)(`td`,{children:Object.keys(e.by_effort||{}).length})]}),s===e.model_name&&(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:5,style:{background:`var(--bg-surface)`,padding:`0.75rem 1rem`},children:(0,y.jsx)(w,{model:e,fmt:b,chartMode:n})})})]},e.model_name))})]})})]}):(0,y.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem`},children:`No data`})}export{D as default};
@@ -0,0 +1,2 @@
1
+ import{c as e,i as t,n,p as r,r as i,t as a}from"./index-Bxd44dxc.js";import{$n as o,C as s,N as c,P as l,S as u,T as d,_ as f,b as p,c as m,d as h,f as g,h as _,l as v,m as y,o as b,p as x,s as S,u as C,v as w,w as T,x as E,y as D}from"./animationsDefault-C_urdfl6.js";import{a as O,c as k,i as ee,n as te,o as A,r as j,s as ne,t as M,u as N}from"./useDailyStackPresentationTween-BWv0dKwE.js";import{t as P}from"./formatters-lxlIPan_.js";var F=r(e(),1),I=7,L=304,R=.18,re=1.35;function z(e,{seekMs:t=0,startMs:n=0,endMs:r=1}={}){let i=e?.dates||[];if(!i.length)return{dates:[],series:[],cursor:0,xMin:-.5,xMax:I-.5,yMax:1,barWidth:1,barMaxWidth:1};let a=i.length-1,o=Math.min(I-1,a),s=Math.max(0,n||0),c=Math.max(s+1,r||s+1)-s,l=Math.max(0,Math.min(c,(t||0)-s)),u=ie(i.length,l,c),d=u<=I?o:Math.min(a,u-.5),f=Math.max(o,Math.min(a,Math.ceil(u))),p=i.slice(0,f+1),m=-.5,h=Math.max(I-.5,d+.5),g=Math.max(I,h-m),_=ae(e,0,o),v=Math.max(1.8,Math.min(24,L/g*.72)),y=(e.series||[]).map(e=>({...e,data:p.map((t,n)=>[n,Math.max(0,Number(e.data?.[n])||0)*V(n,u,i.length)])}));return{dates:p,series:y,cursor:d,xMin:m,xMax:h,yMax:Math.max(1,_,oe(y)),barWidth:v,barMaxWidth:Math.max(2,Math.min(26,v*1.1))}}function ie(e,t,n){let r=Math.max(1,Math.floor(Number(e)||1)),i=B(r,n),a=Math.max(0,Math.min(n,t||0)),o=0;for(let e=0;e<i.length;e+=1){let t=Math.max(1,i[e]),n=o+t;if(a<=n)return Math.min(r,e+(a-o)/t);o=n}return r}function B(e,t){let n=Math.max(1,Math.floor(Number(e)||1)),r=Math.min(n,Math.max(I,Math.ceil(n*.08))),i=Math.min(n,Math.max(4,Math.ceil(n*.05))),a=Array.from({length:n},(e,t)=>{let a=r<=1?1:t/(r-1),o=t<r?.95*(1-le(a)):0,s=n-1-t,c=i<=1?1:1-s/(i-1),l=s<i?2.2*le(c):0;return 1+o+l}),o=a.reduce((e,t)=>e+t,0)||1,s=Math.max(1,t||1)/o;return a.map(e=>e*s)}function V(e,t,n){return t<=0?0:t>=n?1:ce(se((t-e+R)/re))}function ae(e,t,n){let r=e?.dates||[];if(!r.length)return 1;let i=Math.max(0,Math.min(r.length-1,t||0)),a=Math.max(i,Math.min(r.length-1,n??r.length-1)),o=0;for(let t=i;t<=a;t+=1){let n=0;for(let r of e.series||[])n+=Math.max(0,Number(r?.data?.[t])||0);o=Math.max(o,n)}return Math.max(1,o)}function oe(e){let t=Math.max(0,...e.map(e=>e.data?.length||0)),n=0;for(let r=0;r<t;r+=1){let t=0;for(let n of e)t+=Math.max(0,Number(n.data?.[r]?.[1])||0);n=Math.max(n,t)}return n}function se(e){return Math.max(0,Math.min(1,Number(e)||0))}function ce(e){return 1-(1-se(e))**2.35}function le(e){let t=se(e);return t<.5?4*t*t*t:1-(-2*t+2)**3/2}var H=a();function ue({daily:e,seekMs:t=0,timing:n=null}){let r=(0,F.useRef)(null),[i,a]=(0,F.useState)({width:304,height:104}),o=(0,F.useMemo)(()=>z(e,{seekMs:t,startMs:n?.startMs??0,endMs:n?.endMs??1}),[e,t,n?.startMs,n?.endMs]);if((0,F.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();a(e=>{let n=Math.max(1,Math.round(t.width)),r=Math.max(1,Math.round(t.height));return e.width===n&&e.height===r?e:{width:n,height:r}})};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),!e?.dates?.length)return(0,H.jsxs)(`div`,{className:`overview-daily-spark overview-daily-spark-empty`,children:[(0,H.jsx)(`span`,{className:`overview-daily-spark-title`,children:`Daily Usage`}),(0,H.jsx)(`span`,{className:`overview-daily-spark-empty-text`,children:`No daily data`})]});let s=de(o),c=Math.max(1,o.xMax-o.xMin),l=Math.max(1,Math.ceil(c)),u=W(Math.max(2,Math.min(24,i.width/l*.72)));return(0,H.jsxs)(`div`,{className:`overview-daily-spark`,children:[(0,H.jsx)(`span`,{className:`overview-daily-spark-title`,children:`Daily Usage`}),(0,H.jsx)(`div`,{className:`overview-daily-spark-chart`,children:(0,H.jsx)(`div`,{ref:r,className:`overview-daily-spark-bars`,"aria-hidden":`true`,children:s.map(e=>{let t=W(W((e.index-o.xMin)/c*i.width)-u/2),n=U(e.segments,o.yMax,i.height);return(0,H.jsx)(`div`,{className:`overview-daily-spark-bar`,style:{left:0,transform:`translate3d(${t}px, 0, 0)`,width:`${u}px`},children:n.map(({segment:e,bottomPx:t,heightPx:r},i)=>{let a=i===0,o=i===n.length-1,s=u>=3&&r>=3,c=s?fe({isTop:o,isBottom:a,segmentCount:n.length}):0;return(0,H.jsx)(`span`,{className:`overview-daily-spark-segment`,style:{bottom:`${t}px`,height:`${r}px`,background:e.color,borderRadius:c,boxShadow:s&&o&&!a?`0 -1px 0 rgba(6, 8, 15, 0.45)`:void 0}},e.key)})},e.date)})})})]})}function de(e){return(e?.dates||[]).map((t,n)=>{let r=e.series?.[0]?.data?.[n],i=Array.isArray(r)?r[0]:n,a=0,o=[];for(let t of e.series||[]){let e=t.data?.[n],r=Math.max(0,Number(Array.isArray(e)?e[1]:e)||0);r<=0||(o.push({key:t.key,color:w(t.key),bottom:a,value:r}),a+=r)}return{date:t,index:i,segments:o}})}function U(e,t,n){let r=Math.max(1,n)/Math.max(1,Number(t)||1),i=0,a=[];for(let t of e||[]){let e=Math.max(0,t.value*r);if(e<.5)continue;let n=W(Math.max(.5,e));a.push({segment:t,bottomPx:i,heightPx:n}),i=W(i+n)}return a}function fe({isTop:e,isBottom:t,segmentCount:n}){return e&&t?`2px`:n>1&&!e?0:e?`2px 2px 0 0`:0}function W(e){return Math.round(e*2)/2}function pe(e,{duration:t=h,onSettledChange:n,ingestProgress:r=0,isIngestActive:i=!1,clockNowMs:a=null}={}){let o=(0,F.useMemo)(()=>j(e),[e.overview,e.heatmap,e.daily,e.families,e.repos,e.models,e.range]),[s,c]=(0,F.useState)(o),l=(0,F.useRef)(o),u=(0,F.useRef)(o),d=(0,F.useRef)(0),f=(0,F.useRef)(0),p=(0,F.useRef)(s),m=(0,F.useRef)(!0),_=(0,F.useRef)(n),v=(0,F.useRef)(0),b=(0,F.useRef)(o),S=(0,F.useRef)(o),C=(0,F.useRef)(`smooth`),w=(0,F.useRef)(i);(0,F.useEffect)(()=>{_.current=n},[n]);let T=e=>{m.current!==e&&(m.current=e,_.current?.(e))};(0,F.useEffect)(()=>{p.current=s},[s]);let E=e=>{l.current=e,u.current=e,p.current=e,c(e),T(!0),f.current=0,v.current=0,b.current=e,S.current=e},D=e=>{u.current=e,T(!1);let t=g(r,i)?`tail`:`smooth`;C.current!==t&&(C.current=t,v.current=0),t===`tail`&&(b.current=l.current,S.current=e,v.current=0)},k=(e,n)=>{e<f.current&&(f.current=0,v.current=0,b.current=l.current,S.current=n),f.current||=e;let a=Math.max(1,e-f.current);f.current=e;let o=x(r,i)||t,s=l.current,u=g(r,i)?`tail`:`smooth`;C.current!==u&&(C.current=u,v.current=0);let d,m;if(u===`tail`){S.current!==n&&(b.current=s,S.current=n,v.current=e),v.current||=e;let t=Math.max(0,e-v.current),a=Math.min(1,t/Math.max(o,1)),c=G(a,y(r,i));d=O(b.current,S.current,c),m=a>=1||K(d,n)<=.002}else{let e=G(1-Math.exp(-a/Math.max(o,1)),y(r,i));d=O(s,n,e),m=e>=.999||K(d,n)<=.002}return l.current=d,m?(l.current=n,p.current=n,c(n),T(!0),v.current=0,b.current=n,S.current=n,n):(p.current=d,c(d),d)};return(0,F.useLayoutEffect)(()=>{let e=w.current&&!i;w.current=i,e&&E(o)},[i,o]),(0,F.useLayoutEffect)(()=>{if(a!=null){if(t<=0){E(o);return}D(o),k(a,o)}},[o,t,r,i,a]),(0,F.useEffect)(()=>{if(a!=null)return;if(u.current=o,t<=0){E(o);return}if(l.current===o&&m.current||(D(o),d.current))return;let e=t=>{if(k(t,u.current)===u.current&&m.current){d.current=0,f.current=0;return}d.current=requestAnimationFrame(e)};d.current=requestAnimationFrame(e)},[o,t,r,i,a]),(0,F.useEffect)(()=>()=>{d.current&&cancelAnimationFrame(d.current),d.current=0,f.current=0},[]),s}function G(e,t){let n=Math.min(Math.max(e,0),1);return t===`cubicOut`?1-(1-n)**3:n}function K(e,t){if(!e||!t)return 0;let n=Math.max(Math.abs((e.stats?.tokens||0)-(t.stats?.tokens||0)),Math.abs((e.stats?.elapsed||0)-(t.stats?.elapsed||0)),Math.abs((e.stats?.cost||0)-(t.stats?.cost||0)),Math.abs((e.stats?.sessions||0)-(t.stats?.sessions||0))),r=q(e.topRepos,t.topRepos),i=q(e.topFamilies,t.topFamilies),a=q(e.topModels,t.topModels),o=me(e.daily,t.daily);return Math.max(n,r,i,a,o)/Math.max(1,t.stats?.tokens||1)}function q(e=[],t=[]){let n=new Map(e.map(e=>[e.key,e.tokens||0])),r=0;for(let e of t)r=Math.max(r,Math.abs((n.get(e.key)||0)-(e.tokens||0)));return r}function me(e,t){let n=new Map((e?.series||[]).map(e=>[e.key,e])),r=0;for(let e of t?.series||[]){let t=n.get(e.key);for(let n=0;n<e.data.length;n+=1)r=Math.max(r,Math.abs((t?.data?.[n]||0)-(e.data[n]||0)))}return r}l([d,T,s,u,E,N,p]);function J(e){return P(e)}function he(e){return e==null?`—`:e>=1e3?`$`+(e/1e3).toFixed(1)+`K`:`$`+e.toFixed(2)}function ge(e){return e?(e/3600).toFixed(1)+`h`:`0h`}function _e(e,t=16){if(!e)return``;let n=String(e).split(/([-/])/).filter(Boolean),r=[``];for(let e of n){let n=r[r.length-1];if(!n.length||(n+e).length<=t){r[r.length-1]=n+e;continue}if(r.length===2){r[1]+=e;break}r.push(e)}return r.join(`
2
+ `)}function ve(e){let t=Math.max(1,e||1),n=300/t,r=Math.max(1.25,Math.min(24,n*(t>80?.68:t>45?.78:.88)));return{barWidth:r,barMaxWidth:Math.max(4,Math.min(28,r*1.2))}}function ye(e){let{dates:t,series:n}=k(e,{split:`model`,metric:`tokens`});return{dates:t,series:n}}function Y(e,t,n,r){if(!r)return e;let i=Math.max(0,(n||1)-1),a=Math.max(0,Math.min(i,Number.isFinite(t)?t:0));return a>=i-.01?i:Math.max(e,Math.min(i,a+1.25))}function X(e,t){if(!e?.dates?.length)return{dates:[],series:[]};let n=e.dates.length-1,r=Math.max(0,Math.min(n,t||0)),i=Math.floor(r),a=Math.min(n,Math.ceil(r)),o=r-i,s=Math.max(1,a+1),c=e.dates.slice(0,s);return{dates:c,series:(e.series||[]).map(e=>({...e,data:c.map((t,n)=>{let r=e.data?.[n]||0;return n<=i?r:r*o})}))}}function Z(e,t,n){if(!e?.length||!t?.length)return Math.max(0,Math.min(Math.max((t?.length||1)-1,0),n||0));let r=e.length-1,i=Math.max(0,Math.min(r,Number.isFinite(n)?n:r)),a=Math.floor(i),o=Math.min(r,Math.ceil(i)),s=i-a,c=new Map(t.map((e,t)=>[e,t])),l=c.get(e[a]);if(l==null)return Math.max(0,Math.min(t.length-1,i));if(o===a)return l;let u=c.get(e[o]);return u==null?Math.max(0,Math.min(t.length-1,l+s)):l+(u-l)*s}function be(e,t){return!e||!t?e||{}:Object.fromEntries(Object.entries(e).filter(([e])=>String(e)<=String(t)))}function xe(e,t){if(!t?.dates?.length)return e||{dates:[],series:[]};if(!e?.dates?.length)return t;let n=[...new Set([...e.dates,...t.dates])].sort(),r=new Map(e.dates.map((e,t)=>[e,t])),i=new Map(t.dates.map((e,t)=>[e,t])),a=[],o=new Map,s=new Map;for(let t of e.series||[])o.set(t.key,t);for(let e of t.series||[])s.set(e.key,e),a.push(e.key);for(let t of e.series||[])s.has(t.key)||a.push(t.key);return{dates:n,series:a.map(e=>{let t=s.get(e),a=o.get(e);return{key:e,label:t?.label||a?.label||e,data:n.map(e=>{let n=i.get(e);if(t&&n!==void 0)return t.data?.[n]||0;let o=r.get(e);return a&&o!==void 0&&a.data?.[o]||0})}})}}function Se(e,{ingestProgress:t=0,isIngestActive:n=!1}={}){let r=(0,F.useRef)({dates:[],series:[]}),i=(0,F.useMemo)(()=>n?(r.current=xe(r.current,e),r.current):(r.current=e||{dates:[],series:[]},r.current),[e,n]),a=(0,F.useMemo)(()=>ne(i?.dates||[],n,t),[i?.dates,t,n]),[o,s]=(0,F.useState)(()=>A(i?.dates||[],n)),c=Y(a,o,i?.dates?.length||0,n),l=!!(n&&(i?.dates?.length||0)>0&&o>=i.dates.length-1-.01),[u,d]=(0,F.useState)(0),f=(0,F.useRef)(o),p=(0,F.useRef)(0),m=(0,F.useRef)(i?.dates||[]),h=(0,F.useRef)(0),g=(0,F.useRef)(0);f.current=o;let _=e=>{let t=Math.round(Math.max(0,e||0)*10)/10;Math.abs(p.current-t)<.05||(p.current=t,d(t))};return(0,F.useLayoutEffect)(()=>{let e=i?.dates||[],t=m.current||[];if(t===e||(m.current=e,!n))return;let r=Z(t,e,f.current);Math.abs(r-f.current)<.001||(f.current=r,s(r))},[i?.dates,n]),(0,F.useEffect)(()=>{let e=i?.dates?.length||0;if(!e){_(0);return}if(!n){f.current=c,s(c),_(0);return}cancelAnimationFrame(h.current),h.current=0,g.current=0;let t=r=>{g.current||=r;let i=Math.max(1,r-g.current);g.current=r;let o=f.current,c=Y(a,o,e,n),l=c-o;if(Math.abs(l)<=.01){f.current=c,s(c),_(0),h.current=0;return}let u=Math.min(4.2,Math.max(.65,1.15+Math.max(0,Math.abs(l)-8)*.11));_(u);let d=o+Math.sign(l)*Math.min(Math.abs(l),u*i/1e3);f.current=d,s(d),h.current=requestAnimationFrame(t)};return h.current=requestAnimationFrame(t),()=>{cancelAnimationFrame(h.current),h.current=0}},[i?.dates?.length,a,n]),(0,F.useEffect)(()=>()=>{cancelAnimationFrame(h.current),h.current=0},[]),{daily:(0,F.useMemo)(()=>X(i,o),[i,o]),cursor:o,rawTargetIndex:a,sourceDaily:i,speedDaysPerSecond:u,targetIndex:c,waitingForDailyData:l}}function Ce(e,t,n=null,r=!1){if(!t)return{startValue:0,endValue:0};if(r&&Number.isFinite(n)){let r=t;e===`d7`&&(r=7),e===`d30`&&(r=30);let i=e===`d30`?29:6,a=Math.max(t-1,i),o=Math.max(i,Math.min(a,n)),s=e===`total`?Math.max(7,o+1):Math.max(1,Math.min(r,o+1));return{startValue:e===`total`?0:Math.max(0,o-s+1),endValue:o}}let i=t;return e===`d7`&&(i=7),e===`d30`&&(i=30),{startValue:t-Math.max(1,Math.min(i,t)),endValue:t-1}}function we(e,t,n,r,i){if(cancelAnimationFrame(r.current),r.current=0,Math.abs(e.startValue-t.startValue)<.01&&Math.abs(e.endValue-t.endValue)<.01)return;let a=0,o=s=>{a||=s;let c=Math.min(1,(s-a)/i),l=1-(1-c)**3;n({startValue:e.startValue+(t.startValue-e.startValue)*l,endValue:e.endValue+(t.endValue-e.endValue)*l}),r.current=c<1?requestAnimationFrame(o):0};return r.current=requestAnimationFrame(o),()=>{cancelAnimationFrame(r.current),r.current=0}}function Te(e,t,{hideLabels:n=!1}={}){return e.map(e=>{let r=t(e.key);return{name:e.label,value:e.tokens,itemStyle:{color:r},label:{show:!n,color:r},labelLine:{show:!n}}})}function Ee(e,t){return e.map(e=>({...e,tokens:Math.max(0,(e.tokens||0)*t)}))}function De(e,t){let n=new Map((t||[]).map(e=>[e.key,e])),r=[],i=new Set;for(let t of e||[]){if(!t?.key||i.has(t.key))continue;i.add(t.key);let e=n.get(t.key);r.push({key:t.key,label:e?.label||t.label,tokens:Math.max(0,e?.tokens??t.tokens??0)})}for(let e of t||[])!e?.key||i.has(e.key)||(i.add(e.key),r.push({key:e.key,label:e.label,tokens:Math.max(0,e.tokens||0)}));return r}function Oe(e){return e.length===1?e=>{let t=e.rect||{x:0,y:0,width:0,height:0},n=e.labelRect||{width:0,height:0};return{x:t.x+t.width+14,y:t.y+t.height/2-n.height/2,align:`left`,verticalAlign:`middle`,moveOverlap:`shiftY`,hideOverlap:!1}}:null}function ke({daily:e,fullDaily:t=null,elasticDaily:n=null,range:r=`total`,isIngestActive:i=!1,currentDateBucket:a=null,exportMode:o=!1,exportPlayback:s=!1,onDayClick:c}){let l=t||e;return l?.dates?.length?(0,H.jsx)(Q,{sourceDaily:l,elasticDaily:n,range:r,isIngestActive:i,currentDateBucket:a,exportMode:o,exportPlayback:s,onDayClick:c}):(0,H.jsxs)(`div`,{className:`overview-daily-spark overview-daily-spark-empty`,children:[(0,H.jsx)(`span`,{className:`overview-daily-spark-title`,children:`Daily Usage`}),(0,H.jsx)(`span`,{className:`overview-daily-spark-empty-text`,children:`No daily data`})]})}function Q({sourceDaily:e,elasticDaily:t=null,range:r=`total`,isIngestActive:a=!1,currentDateBucket:s=null,exportMode:l=!1,exportPlayback:u=!1,onDayClick:d}){let f=t||{daily:e,cursor:e.dates.length-1,rawTargetIndex:e.dates.length-1,sourceDaily:e,targetIndex:e.dates.length-1},p=f.daily,m=!l&&!u&&a,h=(0,F.useMemo)(()=>Ce(r,p.dates.length,f.cursor,m),[r,p.dates.length,f.cursor,m]),[g,_]=(0,F.useState)(()=>Ce(r,p.dates.length)),v=(0,F.useRef)(h),y=(0,F.useRef)(m),b=(0,F.useRef)(g),x=(0,F.useRef)(0),C=M(p,m,`overview-daily-spark`),T=m?h:y.current?v.current:g;b.current=T,(0,F.useEffect)(()=>{if(m){v.current=h,y.current=!0;return}let e=Ce(r,p.dates.length);return y.current&&=(b.current=v.current,_(v.current),!1),we(b.current,e,_,x,220)},[m,h,r,p.dates.length]),(0,F.useEffect)(()=>()=>{cancelAnimationFrame(x.current),x.current=0},[]);let{startValue:E,endValue:D}=T,O=Math.max(1,D-E+1||p.dates.length),{barWidth:k,barMaxWidth:ee}=ve(O),te=m,A=Math.max(-.5,E-.5),j=Math.max(A+1,D+.5),ne=e=>p.dates[Math.max(0,Math.min(p.dates.length-1,Math.round(e)))],N=(0,F.useRef)(``);(0,F.useEffect)(()=>{let t=i(e,s),r=i(p,s),a=Math.round(E),o=Math.round(D),c=[s,f.targetIndex,t.days,t.lastNonzero,t.overreachDays,r.days,r.lastNonzero,r.overreachDays,a,o].join(`|`);c!==N.current&&(N.current=c,n(`dailySpark.present`,{currentDateBucket:s,cursor:Number(f.cursor.toFixed(2)),targetIndex:f.targetIndex,rawTargetIndex:f.rawTargetIndex,lagDays:Number((f.targetIndex-f.cursor).toFixed(2)),source:t,presentationSource:i(f.sourceDaily,s),display:r,zoom:{startValue:Number(E.toFixed(2)),endValue:Number(D.toFixed(2)),visibleDateCount:Number(O.toFixed(2))}}))},[s,f.cursor,f.targetIndex,e,p,E,D,O]);let P={backgroundColor:`transparent`,...S,tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{if(!e?.length)return``;let t=`<b>${ne(Array.isArray(e[0].data)?e[0].data[0]:e[0].dataIndex)}</b><br/>`,n=0,r=[...e].filter(e=>(Array.isArray(e.value)?e.value[1]:e.value)>0).sort((e,t)=>((Array.isArray(t.value)?t.value[1]:t.value)||0)-((Array.isArray(e.value)?e.value[1]:e.value)||0));for(let e of r){let r=Array.isArray(e.value)?e.value[1]:e.value;t+=`${e.marker} ${e.seriesName}: ${J(r)}<br/>`,n+=r}return t+=`<b>Total: ${J(n)}</b>`,t}},grid:{left:4,right:4,top:4,bottom:4},xAxis:te?{type:`value`,min:A,max:j,show:!1}:{type:`category`,data:C.dates||p.dates,min:Math.max(0,Math.floor(E)),max:Math.max(0,Math.floor(D)),show:!1},yAxis:{type:`value`,show:!1,scale:!1,min:0},series:C.series.map(e=>({id:`overview-daily-${e.key}`,name:e.label,type:`bar`,stack:`total`,data:te?e.data.map((e,t)=>[t,e]):e.data,itemStyle:{color:w(e.key)},...k?{barWidth:k}:{},barMaxWidth:ee}))},I=d&&!l&&!u?{click:e=>{let t=Array.isArray(e?.data)?e.data[0]:e?.dataIndex,n=Number.isFinite(t)?ne(t):e?.axisValue||e?.name;n&&d(n)}}:void 0;return(0,H.jsxs)(`div`,{className:`overview-daily-spark`,children:[(0,H.jsx)(`span`,{className:`overview-daily-spark-title`,children:`Daily Usage`}),(0,H.jsx)(`div`,{className:`overview-daily-spark-chart`,style:I?{cursor:`pointer`}:void 0,children:(0,H.jsx)(o,{echarts:c,option:P,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!1,notMerge:l,replaceMerge:[`series`],onEvents:I})})]})}var $=[{key:`tokens`,label:`Tokens`,fmt:J},{key:`elapsed`,label:`Time`,fmt:e=>ge(e)},{key:`cost`,label:`Cost`,fmt:he}],Ae=C.heatmap?.popDurationMs??380,je=C.heatmap?.settleThreshold??.998;function Me({heatmapData:e,isIngestActive:r=!1,ingestProgress:i=0,currentDateBucket:a=null,onDayClick:o,interactive:s=!0}){let[c,l]=(0,F.useState)(`tokens`),[u,d]=(0,F.useState)(new Set),[f,p]=(0,F.useState)(new Set),m=(0,F.useRef)({}),h=(0,F.useRef)(1),g=(0,F.useRef)(``),_=e||{};(0,F.useEffect)(()=>{let e=t(_,a),r=[e.currentDateBucket,e.nonzeroDays,e.lastNonzero,e.overreachDays,e.totalTokens].join(`|`);r!==g.current&&(g.current=r,n(`heatmap.present`,e))},[_,a]);let v=new Date,y=[],b=[];for(let e=364;e>=0;e--){let t=new Date(v);t.setDate(t.getDate()-e);let n=t.toLocaleDateString(`en-CA`),r=_[n]&&_[n][c]||0;y.push({key:n,val:r,date:t}),t.getDate()===1&&b.push({idx:364-e,label:t.toLocaleDateString(`en-US`,{month:`short`})})}let x=Math.max(...y.map(e=>e.val),1);(0,F.useEffect)(()=>{if(!r||i>=je){m.current={},h.current=1;return}let e=new Date,t=m.current,n=h.current,a=new Set,o=new Set,s=Math.max(.05,Math.min(n,x)*.002),l=C.heatmap?.intensityRiseThreshold??.08,u=C.heatmap?.whiteThreshold??.88,f=C.heatmap?.nearMaxRatio??.985;for(let r=364;r>=0;r--){let i=new Date(e);i.setDate(i.getDate()-r);let d=i.toLocaleDateString(`en-CA`),p=_[d]&&_[d][c]||0,m=t[d]??0,h=n>0?m/n:0,g=x>0?p/x:0,v=x>n+s&&p>=x*f&&(m<x*f||m===void 0),y=g>=u&&h<u,b=p>m+s,S=g>h+l;v||y||b||S?a.add(d):(p<m-s||p>0&&n>0&&x>n+s&&h>=.85&&g<h-.02)&&o.add(d),t[d]=p}if(h.current=x,a.size>0||o.size>0){d(a),p(o);let e=setTimeout(()=>{d(new Set),p(new Set)},Ae);return()=>clearTimeout(e)}},[_,c,r,i,x]);function S(e){if(e===0)return`var(--bg-elevated)`;let t=e/x,n=1/4;return t<n?`rgba(99, 102, 241, 0.14)`:t<2*n?`rgba(99, 102, 241, 0.38)`:t<3*n?`rgba(99, 102, 241, 0.62)`:t<1?`rgba(99, 102, 241, 0.88)`:`#fff`}let w=y[0]?.date.getDay()||0,T=Array(w).fill(null).concat(y);return(0,H.jsxs)(`div`,{className:`heatmap-wrap`,children:[(0,H.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:`0.75rem`},children:[(0,H.jsx)(`span`,{className:`chart-title`,children:`Activity`}),(0,H.jsx)(`div`,{className:`btn-group`,children:$.map(e=>(0,H.jsx)(`button`,{className:`btn ${c===e.key?`active`:``}`,onClick:()=>l(e.key),children:e.label},e.key))})]}),(0,H.jsx)(`div`,{className:`heatmap-grid`,style:{gridTemplateRows:`repeat(7, 1fr)`},children:T.map((e,t)=>e?(0,H.jsx)(`div`,{role:o&&s?`button`:void 0,tabIndex:o&&s?0:void 0,onClick:o&&s?()=>o(e.key):void 0,onKeyDown:o&&s?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o(e.key))}:void 0,className:`heatmap-cell ${e.val>0?`active`:``} ${u.has(e.key)?`heatmap-cell-pop`:``} ${f.has(e.key)?`heatmap-cell-pop-dim`:``}`,style:{background:S(e.val),cursor:o&&s?`pointer`:void 0},title:`${e.key}: ${$.find(e=>e.key===c).fmt(e.val)}`},e.key):(0,H.jsx)(`div`,{className:`heatmap-cell`,style:{visibility:`hidden`}},`pad-${t}`))}),(0,H.jsx)(`div`,{className:`heatmap-labels`,children:b.slice(-12).map((e,t)=>(0,H.jsx)(`span`,{children:e.label},t))})]})}function Ne(e){return e.presentation?.ready?(0,H.jsx)(Pe,{...e}):null}function Pe({presentation:e,rawPresentation:t=null,fullDaily:n=null,sourceDailyRows:r=null,range:i=`total`,ingestProgress:a=0,isIngestActive:s=!1,currentDateBucket:l=null,exportMode:u=!1,exportPlayback:d=!1,exportPhase:p=null,exportSeekMs:h=0,exportDaily:g=null,exportDailyTiming:y=null,onDailyDebugStatsChange:x=null,onPresentationDateRangeChange:S=null,onNavigateToDailyDay:T,onNavigateToRepo:E,onNavigateToModel:O}){let k=d?Re(h):1,A=d&&p===`replay`&&t?.ready?t:e,j=d&&t?.daily||e.daily,ne=d&&j?.dates?.length?j:n,M=!u&&!d&&s,N=Se(ne,{ingestProgress:a,isIngestActive:M});(0,F.useEffect)(()=>{x?.(M?{speedDaysPerSecond:N.speedDaysPerSecond,waitingForDailyData:N.waitingForDailyData}:null)},[M,N.speedDaysPerSecond,N.waitingForDailyData,x]),(0,F.useEffect)(()=>()=>x?.(null),[x]);let P=N.daily?.dates||[],I=P[P.length-1]||l,L=ee(i,P),R={from:L[0]||I,to:L[L.length-1]||I};(0,F.useEffect)(()=>{S?.(M?R:null)},[M,S,R.from,R.to]),(0,F.useEffect)(()=>()=>S?.(null),[S]);let re=s&&t?.heatmap?t.heatmap:e.heatmap,z=s&&!d?I:l,ie=s&&z&&!d?be(re,z):re||{},B=(0,F.useMemo)(()=>M?te({daily:r,range:i,cursor:N.cursor,fallback:A}):A,[A,M,N.cursor,i,r]),{stats:V,topRepos:ae,topFamilies:oe,topModels:se}=B,ce=d&&p===`replay`?Ee(De(t?.topRepos||A.topRepos||[],e.topRepos||A.topRepos||[]),k):B.topRepos||[],le=d&&p===`replay`?Ee(De(t?.topFamilies||A.topFamilies||[],e.topFamilies||A.topFamilies||[]),k):B.topFamilies||[],de=d&&p===`replay`?Ee(De(t?.topModels||A.topModels||[],e.topModels||A.topModels||[]),k):B.topModels||[],U=[...ce.slice(0,6)].reverse(),fe=Math.max(...ce.slice(0,6).map(e=>e.tokens||0),1),W=[...le].sort((e,t)=>String(e.label).localeCompare(String(t.label))),pe=[...de.slice(0,6)].sort((e,t)=>String(e.label).localeCompare(String(t.label))),G=!u&&!d&&!s,K=Be(h,d),q=!u&&!d&&v,me=d?ze(h,C.videoExport?.barsChartIntroUpdateDurationMs,C.videoExport?.barsChartUpdateDurationMs,p===`tail`||p===`final_hold`?C.videoExport?.barsChartTailUpdateDurationMs:null):0,ve={backgroundColor:`transparent`,...b,...u?{animation:!1}:{},...d?{animation:!0,animationDuration:0,animationDurationUpdate:me,animationEasingUpdate:`cubicOut`}:{},tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>e?.length?`${e[0].axisValue}: ${J(e[0].value)} tokens`:``},grid:{left:100,right:5,top:5,bottom:5},xAxis:{type:`value`,show:!1,max:fe||1},yAxis:{type:`category`,data:U.map(e=>e.label),axisLabel:{color:`#8b949e`,fontSize:11,formatter:e=>_e(e)},axisTick:{show:!1},axisLine:{show:!1}},series:[{id:`overview-top-repos`,type:`bar`,data:U.map(e=>{let t=e.tokens||0,n=t/fe>=.7,r=D(e.label);return{value:t,itemStyle:{color:r,borderRadius:[0,3,3,0]},label:{show:!0,position:n?`insideRight`:`right`,distance:5,offset:[0,1.5],formatter:()=>J(t),color:n?_(r):`#8b949e`,fontSize:10}}}),barWidth:`80%`}]},ye=G&&E?{click:e=>{if(e?.componentType!==`series`||e?.dataIndex==null)return;let t=U[e.dataIndex];t?.label&&E(t.label)}}:void 0,Y=W.reduce((e,t)=>e+(t.tokens||0),0),X=W.filter(e=>Y>0?(e.tokens||0)/Y>=.01:!1),Z=d&&X.length===1,xe=Oe(X),Ce={backgroundColor:`transparent`,...m,...u||d?{animation:!1}:{},tooltip:{trigger:`item`,appendToBody:!0,confine:!0,formatter:e=>`${e.name}: ${J(e.value)} tokens (${e.percent}%)`},series:[{id:`overview-work-type`,type:`pie`,animation:q,avoidLabelOverlap:!xe,radius:K,center:[`50%`,`50%`],label:{show:!Z,color:`#8b949e`,fontSize:11,formatter:`{b}`,alignTo:`edge`,edgeDistance:5,bleedMargin:5,distanceToLabelLine:5},labelLine:{show:!Z,lineStyle:{color:`#30363d`},length:8,length2:6},itemStyle:{borderColor:`#161b22`,borderWidth:2},...!Z&&xe?{labelLayout:xe}:{},data:Te(X,f,{hideLabels:Z})}]},we=pe.reduce((e,t)=>e+(t.tokens||0),0),Q=pe.filter(e=>we>0?(e.tokens||0)/we>=.01:!1),$=d&&Q.length===1,Ae=Oe(Q),je={backgroundColor:`transparent`,...m,...u||d?{animation:!1}:{},tooltip:{trigger:`item`,appendToBody:!0,confine:!0,formatter:e=>`${e.name}: ${J(e.value)} tokens (${e.percent}%)`},series:[{id:`overview-models`,type:`pie`,animation:q,avoidLabelOverlap:!Ae,radius:K,center:[`50%`,`50%`],label:{show:!$,color:`#8b949e`,fontSize:11,formatter:`{b}`,alignTo:`edge`,edgeDistance:5,bleedMargin:5,distanceToLabelLine:5},labelLine:{show:!$,lineStyle:{color:`#30363d`},length:8,length2:6},itemStyle:{borderColor:`#161b22`,borderWidth:2},...!$&&Ae?{labelLayout:Ae}:{},data:Te(Q,w,{hideLabels:$})}]},Ne=G&&O?{click:e=>{if(e?.componentType!==`series`||e?.dataIndex==null)return;let t=Q[e.dataIndex]?.label||e?.name;t&&O(t)}}:void 0;return(0,H.jsxs)(`div`,{className:`animate-in${d?` export-overview-frame`:``}`,children:[(0,H.jsxs)(`div`,{className:`stat-row`,children:[(0,H.jsxs)(`div`,{className:`stat-cards`,children:[(0,H.jsxs)(`div`,{className:`stat-card`,children:[(0,H.jsx)(`div`,{className:`stat-label`,children:`Tokens`}),(0,H.jsx)(`div`,{className:`stat-value`,children:J(V.tokens)}),(0,H.jsxs)(`div`,{className:`stat-per-day`,children:[(0,H.jsx)(`span`,{className:`stat-per-day-value`,children:J(V.tokens/V.days)}),` per day`]})]}),(0,H.jsxs)(`div`,{className:`stat-card`,children:[(0,H.jsx)(`div`,{className:`stat-label`,children:`Agent Time`}),(0,H.jsx)(`div`,{className:`stat-value`,children:ge(V.elapsed)}),(0,H.jsxs)(`div`,{className:`stat-per-day`,children:[(0,H.jsx)(`span`,{className:`stat-per-day-value`,children:ge(V.elapsed/V.days)}),` per day`]})]}),(0,H.jsxs)(`div`,{className:`stat-card`,children:[(0,H.jsx)(`div`,{className:`stat-label`,children:`Est. API Cost`}),(0,H.jsx)(`div`,{className:`stat-value`,children:he(V.cost)}),(0,H.jsxs)(`div`,{className:`stat-per-day`,children:[(0,H.jsx)(`span`,{className:`stat-per-day-value`,children:he(V.cost/V.days)}),` per day`]})]}),(0,H.jsxs)(`div`,{className:`stat-card`,children:[(0,H.jsx)(`div`,{className:`stat-label`,children:`Sessions`}),(0,H.jsx)(`div`,{className:`stat-value`,children:Math.round(V.sessions).toLocaleString()}),(0,H.jsxs)(`div`,{className:`stat-per-day`,children:[(0,H.jsx)(`span`,{className:`stat-per-day-value`,children:(V.sessions/V.days).toFixed(1)}),` per day`]})]})]}),d?(0,H.jsx)(ue,{daily:g||n||j,seekMs:h,timing:y}):(0,H.jsx)(ke,{daily:j,fullDaily:n,elasticDaily:N,range:i,isIngestActive:s,currentDateBucket:l,exportMode:u,exportPlayback:d,onDayClick:G?T:void 0})]}),(0,H.jsx)(Me,{heatmapData:ie,isIngestActive:s,ingestProgress:a,currentDateBucket:z,onDayClick:G?T:void 0,interactive:G}),(0,H.jsxs)(`div`,{className:`grid-3`,children:[(0,H.jsxs)(`div`,{className:`chart-card overview-donut-card`,children:[(0,H.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Top Repos`}),ae.length>0?(0,H.jsx)(o,{echarts:c,option:ve,style:{height:180,cursor:ye?`pointer`:void 0},theme:`dark`,lazyUpdate:!1,notMerge:u,onEvents:ye}):(0,H.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem 0`,textAlign:`center`},children:`No data`})]}),(0,H.jsxs)(`div`,{className:`chart-card overview-donut-card`,children:[(0,H.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Work Type`}),oe.length>0?(0,H.jsx)(o,{echarts:c,option:Ce,style:{height:180},theme:`dark`,lazyUpdate:!1,notMerge:u}):(0,H.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem 0`,textAlign:`center`},children:`No data`})]}),(0,H.jsxs)(`div`,{className:`chart-card`,children:[(0,H.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Models`}),se.length>0?(0,H.jsx)(o,{echarts:c,option:je,style:{height:180,cursor:Ne?`pointer`:void 0},theme:`dark`,lazyUpdate:!1,notMerge:u,onEvents:Ne}):(0,H.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem 0`,textAlign:`center`},children:`No data`})]})]}),(0,H.jsxs)(`div`,{className:`coverage-subtle`,children:[(0,H.jsx)(`span`,{style:{fontWeight:500},children:`Session coverage:`}),(0,H.jsxs)(`span`,{className:`coverage-item`,children:[(0,H.jsx)(`span`,{className:`coverage-dot`,style:{background:`#22c55e`}}),(0,H.jsx)(`span`,{className:`coverage-nums`,children:Math.round(V.exactPriced)}),` `,`exact-priced`]}),(0,H.jsxs)(`span`,{className:`coverage-item`,children:[(0,H.jsx)(`span`,{className:`coverage-dot`,style:{background:`#c084fc`}}),(0,H.jsx)(`span`,{className:`coverage-nums`,children:Math.round(V.fallbackPriced)}),` `,`fallback-priced`]}),(0,H.jsxs)(`span`,{className:`coverage-item`,children:[(0,H.jsx)(`span`,{className:`coverage-dot`,style:{background:`#64748b`}}),(0,H.jsx)(`span`,{className:`coverage-nums`,children:Math.round(V.unpriced)}),` `,`unpriced`]})]})]})}function Fe({data:e,heatmap:t,daily:n,families:r,repos:i,models:a,range:o=`total`,onPresentationSettledChange:s=null,ingestProgress:c=0,isIngestActive:l=!1,currentDateBucket:u=null,clockNowMs:d=null,onDailyDebugStatsChange:f=null,onPresentationDateRangeChange:p=null,onNavigateToDailyDay:m,onNavigateToRepo:g,onNavigateToModel:_}){return(0,H.jsx)(Ne,{presentation:pe({overview:e,heatmap:t,daily:n,families:r,repos:i,models:a,range:o},{duration:h,onSettledChange:s,ingestProgress:c,isIngestActive:l,clockNowMs:d}),rawPresentation:F.useMemo(()=>j({overview:e,heatmap:t,daily:n,families:r,repos:i,models:a,range:o}),[e,t,n,r,i,a,o]),fullDaily:F.useMemo(()=>ye(n),[n]),sourceDailyRows:n,range:o,ingestProgress:c,isIngestActive:l,currentDateBucket:u,onDailyDebugStatsChange:f,onPresentationDateRangeChange:p,onNavigateToDailyDay:m,onNavigateToRepo:g,onNavigateToModel:_})}function Ie(e,t){return e.data===t.data&&e.heatmap===t.heatmap&&e.daily===t.daily&&e.families===t.families&&e.repos===t.repos&&e.models===t.models&&e.range===t.range&&e.onPresentationSettledChange===t.onPresentationSettledChange&&e.ingestProgress===t.ingestProgress&&e.isIngestActive===t.isIngestActive&&e.currentDateBucket===t.currentDateBucket&&e.clockNowMs===t.clockNowMs&&e.onDailyDebugStatsChange===t.onDailyDebugStatsChange&&e.onPresentationDateRangeChange===t.onPresentationDateRangeChange&&e.onNavigateToDailyDay===t.onNavigateToDailyDay&&e.onNavigateToRepo===t.onNavigateToRepo&&e.onNavigateToModel===t.onNavigateToModel}var Le=(0,F.memo)(Fe,Ie);function Re(e){return He(e)}function ze(e,t,n,r=null){if(r!=null)return Math.max(0,Math.round(r));let i=Math.max(0,Math.round(n??0)),a=Math.max(i,Math.round(t??i)),o=He(e);return Math.round(a+(i-a)*o)}function Be(e,t=!1){if(!t)return[`48%`,`72%`];let n=.9+He(e)*.1;return[`${Ve(48*n)}%`,`${Ve(72*n)}%`]}function Ve(e){return Math.round(e*100)/100}function He(e){let t=Math.max(C.videoExport?.chartIntroWindowMs??2200,1),n=Math.max(e||0,0),r=t/3;return Math.min(1,1-Math.exp(-n/Math.max(r,1)))}export{Ne as OverviewFrame,Le as default};
@@ -0,0 +1 @@
1
+ import{a as e,c as t,o as n,p as r,t as i}from"./index-Bxd44dxc.js";import{u as a}from"./animationsDefault-C_urdfl6.js";import{a as o,r as s}from"./useDailyStackPresentationTween-BWv0dKwE.js";import{OverviewFrame as c}from"./Overview-2lHDJwEq.js";var l=r(t(),1);function u(t){let n=t.replay?.bootstrap?.payload||{},r=v(n.progress||{percent:0,complete:!1}),i=e(null,n,`bootstrap`),a=t.replay?.events||[],o=a.findIndex(x),s=o>=0&&a[o].at_ms||0,c=y(t,i,a),l=c[0]?.presentation||D(),u=v(o>=0&&a[o].payload?.progress||r),d=Math.max(t.startHoldDurationMs||0,0),f=Math.max(t.replayDurationMs||t.replay?.duration_ms||1,1),p=Math.max(t.tailDurationMs||0,0),m=Math.max(t.finalHoldDurationMs||0,0),h=Math.max(t.durationMs||d+f+p+m||1,1),g=Math.max(t.replay?.duration_ms||0,0),_=Math.min(Math.max(s,0),g),S=Math.max(1,g-_),C=O(t.tailSourceFraction??.035),k=Math.max(1,Math.round(S*C)),A=Math.max(0,S-k),j=Math.max(_,g-k),M=t.replayEasing||`cubicInOut`,N=t.tailEasing||`cubicInOut`,P=b(t)||c[c.length-1]?.presentation||l,I=E(c,j),L=Math.min(3600,Math.max(1800,Math.round(f*.32))),R=Math.max(0+d,0+d+f-L),z=O((R-(0+d))/Math.max(f,1)),B=Math.round(_+A*F(M,z)),V=T({keyframes:c,startSourceMs:B,endSourceMs:j,startPresentation:E(c,B),endPresentation:I,durationMs:L,startSmoothing:.05,endSmoothing:.14}),H=w({keyframes:c,tailSourceStartMs:j,sourceDurationMs:g,tailStartPresentation:I,finalPresentation:P,tailDurationMs:p});return{renderData:t,totalDurationMs:h,frontloadSettledDurationMs:0,startHoldDurationMs:d,replayDurationMs:f,tailDurationMs:p,finalHoldDurationMs:m,sourceDurationMs:g,sourceStartMs:_,effectiveSourceDurationMs:S,tailSourceDurationMs:k,tailSourceStartMs:j,mainReplaySourceDurationMs:A,replayStartMs:d,lateReplayStartMs:R,lateReplayDurationMs:L,lateReplaySourceStartMs:B,tailStartMs:d+f,finalHoldStartMs:d+f+p,currentSeekMs:0,started:!1,finished:!1,startWallClockMs:0,initialPresentation:l,presentation:l,keyframes:c,keyframeIndex:0,lateReplayFrames:V,tailStartPresentation:I,tailFrames:H,finalPresentation:P,progress:u||{...r,percent:0,complete:!1},bootstrapProgress:r,replayEasing:M,tailEasing:N,debugState:null,debugTrace:[]}}function d(e){return{liveData:{ready:!0},presentation:e.presentation,rawPresentation:e.presentation,progress:e.progress,phase:e.debugState?.phase||`replay`,seekMs:e.currentSeekMs||0}}function f(e,t){let n=Math.min(Math.max(Number(t)||0,0),e.totalDurationMs);e.currentSeekMs=n;let r=`replay`,i=0,a=null;if(n<e.startHoldDurationMs)r=`start_hold`,e.presentation=e.initialPresentation||D();else if(n<e.tailStartMs)if(n<e.lateReplayStartMs)i=p(e,n),e.presentation=S(e,i);else{let t=O((n-e.lateReplayStartMs)/Math.max(e.lateReplayDurationMs,1));i=k(e.lateReplaySourceStartMs,e.tailSourceStartMs,t),e.presentation=C(e.lateReplayFrames,M(t))}else n<e.finalHoldStartMs?(r=`tail`,a=O((n-e.tailStartMs)/Math.max(e.tailDurationMs,1)),e.presentation=C(e.tailFrames,F(e.tailEasing,a))):(r=`final_hold`,e.presentation=e.finalPresentation);n>=e.finalHoldStartMs?((n-e.finalHoldStartMs)/Math.max(e.finalHoldDurationMs||1,1),e.progress={...e.progress||{},percent:1,complete:!0,phase:`complete`}):e.progress={...e.progress||{},complete:!1},n>=e.totalDurationMs&&(e.finished=!0);let o={frame:e.debugTrace.length,seekMs:n,phase:r,sourceMs:i,tailProgress:a,progress:e.progress?.percent??0,complete:!!e.progress?.complete,signature:A(e.presentation)};return e.debugState=o,e.debugTrace.push(o),d(e)}function p(e,t){if(t<=e.replayStartMs)return 0;let n=t-e.replayStartMs;if(n<=e.replayDurationMs){let t=O(n/Math.max(e.replayDurationMs,1));return e.sourceStartMs+e.mainReplaySourceDurationMs*F(e.replayEasing,t)}return e.sourceDurationMs}function m(e,t,n,r){if(!e)return t;let i=a.videoExport||{};if(r<(i.displayTweenStartMs??200))return t;let s=(i.startHoldDurationMs??0)+(i.replayDurationMs??0)+(i.tailDurationMs??0)+(i.finalHoldDurationMs??0)||19e3,c=i.displayTweenLateWindowMs??2200,l=O((r-(s-c))/Math.max(c,1)),u=Math.round(k(i.displayTweenBaseMs??240,i.displayTweenLateMs??420,N(l))),d=N(1-Math.exp(-n/Math.max(u,1))),f=e.progress||{},p=t.progress||{};return{liveData:t.liveData,presentation:o(e.presentation,t.presentation,d),rawPresentation:t.rawPresentation||t.presentation,progress:{...p,percent:k(f.percent||0,p.percent||0,d),complete:p.complete},phase:t.phase,seekMs:t.seekMs||0}}function h(e,t){let n=a.videoExport||{},r=Math.max(n.finalFlashDurationMs??280,0),i=Math.max(n.finalFlashDelayMs??0,0),o=Math.max(n.finalFlashMaxOpacity??.22,0);if(!r||!o||t==null)return{opacity:0,boxShadow:`none`};let s=e-t-i;if(s<0||s>r)return{opacity:0,boxShadow:`none`};let c=o*(1-N(O(s/r)));return{opacity:c,boxShadow:`0 0 120px 50px rgba(255, 255, 255, ${Math.min(1,c*.7)}) inset`}}function g(e){let t=a.videoExport||{};if(!t.introFadeEnabled)return 0;let n=Math.max(0,Math.min(1,t.introFadeStartOpacity??.2)),r=Math.max(0,t.introFadeDelayMs??0),i=Math.max(0,t.introFadeDurationMs??900);if(!n)return 0;if(e<=r)return n;if(!i)return 0;let o=O((e-r)/i);return n*(1-F(t.introFadeEasing||`cubicOut`,o))}function _(e){let t=a.videoExport||{};if(!t.introFadeEnabled)return 1;let n=Math.max(0,Math.min(1,t.introContentStartOpacity??.35)),r=Math.max(0,t.introFadeDelayMs??0),i=Math.max(0,t.introFadeDurationMs??900);if(e<=r)return n;if(!i)return 1;let o=O((e-r)/i);return k(n,1,F(t.introFadeEasing||`cubicOut`,o))}function v(e){return e?{...e}:null}function y(t,n,r){let i=[],a=n;for(let t of r)x(t)&&(a=e(a,t.payload,t.event),i.push({at_ms:Math.max(0,t.at_ms||0),presentation:s({overview:{data:a.overview},heatmap:{data:a.heatmap},daily:{data:Object.entries(a.daily).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({date:e,...t}))},families:{data:a.families},repos:{data:a.repos},models:{data:a.models},range:`total`})}));return i.length||i.push({at_ms:0,presentation:D()}),i}function b(e){let t=e.settledEnvelope;return t?.overview?.data?s({overview:t.overview,heatmap:t.heatmap||{data:{}},daily:t.daily||{data:[]},families:t.families||{data:{total:[],d7:[],d30:[]}},repos:t.repos||{data:{total:[],d7:[],d30:[]}},models:t.models||{data:{total:[],d7:[],d30:[]}},range:`total`}):null}function x(e){return e?.payload?.data&&(e.event===`snapshot`||e.event===`complete`)}function S(e,t){return E(e.keyframes,t,e)}function C(e,t){if(!e?.length)return D();if(t<=e[0].u)return e[0].presentation;for(let n=0;n<e.length-1;n+=1){let r=e[n],i=e[n+1];if(t<=i.u){let e=O((t-r.u)/Math.max(i.u-r.u,1e-6));return o(r.presentation,i.presentation,e)}}return e[e.length-1].presentation}function w({keyframes:e,tailSourceStartMs:t,sourceDurationMs:n,tailStartPresentation:r,finalPresentation:i,tailDurationMs:a}){return T({keyframes:e,startSourceMs:t,endSourceMs:n,startPresentation:r,endPresentation:i,durationMs:a,startSmoothing:.08,endSmoothing:.2,bidirectional:!0})}function T({keyframes:e,startSourceMs:t,endSourceMs:n,startPresentation:r,endPresentation:i,durationMs:a,startSmoothing:s,endSmoothing:c,bidirectional:l=!1}){let u=Math.max(36,Math.min(96,Math.round(a/80))),d=[{u:0,presentation:r}];for(let r=1;r<u-1;r+=1){let i=r/(u-1),a=k(t,n,i);d.push({u:i,presentation:E(e,a)})}d.push({u:1,presentation:i});let f=[{u:0,presentation:r}],p=r;for(let e=1;e<d.length-1;e+=1){let t=d[e],n=k(s,c,t.u);p=o(p,t.presentation,n),f.push({u:t.u,presentation:p})}if(f.push({u:1,presentation:i}),!l)return f;let m=Array(d.length);m[d.length-1]={u:1,presentation:i};let h=i;for(let e=d.length-2;e>0;--e){let t=d[e],n=k(c,s,1-t.u);h=o(h,t.presentation,n),m[e]={u:t.u,presentation:h}}return m[0]={u:0,presentation:r},d.map((e,t)=>t===0?{u:0,presentation:r}:t===d.length-1?{u:1,presentation:i}:{u:e.u,presentation:o(f[t].presentation,m[t].presentation,M(e.u))})}function E(e,t,n=null){if(!e.length)return D();if(t<=e[0].at_ms)return e[0].presentation;let r=n?.keyframeIndex||0;for(;r+1<e.length&&e[r+1].at_ms<=t;)r+=1;n&&(n.keyframeIndex=r);let i=e[r],a=e[Math.min(r+1,e.length-1)];if(!a||a.at_ms<=i.at_ms)return i.presentation;let s=O((t-i.at_ms)/Math.max(a.at_ms-i.at_ms,1));return o(i.presentation,a.presentation,s)}function D(){return s({overview:{data:null},heatmap:{data:{}},daily:{data:[]},families:{data:{total:[],d7:[],d30:[]}},repos:{data:{total:[],d7:[],d30:[]}},models:{data:{total:[],d7:[],d30:[]}},range:`total`})}function O(e){return Math.min(Math.max(e||0,0),1)}function k(e,t,n){return e+(t-e)*n}function A(e){if(!e)return null;let t=e.stats||{},n=e.daily||{dates:[],series:[]},r=Array.isArray(e.topRepos)?e.topRepos:[],i=Array.isArray(e.topModels)?e.topModels:[],a=Math.max(0,(n.dates?.length||0)-1),o=n.dates?.[a]||null,s=(n.series||[]).reduce((e,t)=>e+(Number(t?.data?.[a])||0),0),c=r[0]||null,l=i[0]||null;return{totalTokens:Math.round(Number(t.tokens)||0),totalCost:Number((Number(t.cost)||0).toFixed(4)),totalSessions:Math.round(Number(t.sessions)||0),dailyPoints:n.dates?.length||0,lastDailyDate:o,lastDailyTotal:Math.round(s),topRepo:c?.label||null,topRepoValue:Math.round(Number(c?.tokens)||0),topModel:l?.label||null,topModelValue:Math.round(Number(l?.tokens)||0)}}function j(e){let t=O(e);return t*t*t}function M(e){let t=O(e);return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function N(e){return 1-(1-O(e))**3}function P(e){let t=O(e),n=[[0,0],[.12,.03],[.24,.09],[.4,.22],[.58,.42],[.74,.62],[.86,.77],[.93,.86],[.975,.93],[.992,.975],[1,1]];for(let e=0;e<n.length-1;e+=1){let[r,i]=n[e],[a,o]=n[e+1];if(t<=a)return k(i,o,M(O((t-r)/Math.max(a-r,1e-6))))}return 1}function F(e,t){switch(e){case`trainBrake`:return P(t);case`cubicOut`:return N(t);case`cubicInOut`:return M(t);case`linear`:return O(t);default:return j(t)}}var I=i();function L({jobId:e}){let[t,r]=(0,l.useState)(null),[i,a]=(0,l.useState)(null),[o,s]=(0,l.useState)(null),[p,v]=(0,l.useState)(!1),y=(0,l.useRef)(null),b=(0,l.useRef)(0),x=(0,l.useRef)(null),S=(0,l.useRef)(0),C=(0,l.useRef)(null);if((0,l.useEffect)(()=>{let t=!0;return(async()=>{try{let i=await fetch(n.url(`/api/export/${encodeURIComponent(e)}/render-data`));if(!i.ok)throw Error(`API error: ${i.status}`);let a=await i.json();if(!t)return;r(a),y.current=u(a);let o=d(y.current);x.current=o,S.current=0,s(o),v(!1),C.current=null}catch(e){if(!t)return;a(e.message||String(e))}})(),()=>{t=!1,b.current&&cancelAnimationFrame(b.current)}},[e]),(0,l.useEffect)(()=>{if(!o?.liveData||i)return;let e=!1,t=0,n=0,r=0,a=0,s=0,c=()=>{let t=Array.from(document.querySelectorAll(`.stat-card .stat-value`)),n=Array.from(document.querySelectorAll(`canvas`)),r=t.length>=4&&t.every(e=>String(e.textContent||``).trim().length>0),i=!!document.querySelector(`.overview-daily-spark-chart, .overview-daily-spark-empty`),o=n.length>=3&&i&&n.every(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0}),l=document.querySelectorAll(`.heatmap-cell`).length>=300;if(!(r&&o&&l)){a=requestAnimationFrame(c);return}s=window.setTimeout(()=>{e||v(!0)},180)};return t=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>{r=requestAnimationFrame(()=>{a=requestAnimationFrame(c)})})}),()=>{e=!0,t&&cancelAnimationFrame(t),n&&cancelAnimationFrame(n),r&&cancelAnimationFrame(r),a&&cancelAnimationFrame(a),s&&window.clearTimeout(s)}},[i,o]),(0,l.useEffect)(()=>{if(o){if(o.phase===`final_hold`){C.current??=o.seekMs||0;return}C.current=null}},[o?.phase,o?.seekMs]),(0,l.useEffect)(()=>{let n=()=>{let e=y.current;if(!e||e.started)return;e.started=!0,e.startWallClockMs=Date.now();let t=()=>{let e=y.current;if(!e)return;let n=Date.now(),r=Math.min(e.totalDurationMs,n-e.startWallClockMs),i=f(e,r),a=S.current?Math.max(1,n-S.current):16;S.current=n;let o=m(x.current,i,a,r);if(x.current=o,s(o),r>=e.totalDurationMs){e.finished=!0,b.current=0;return}b.current=requestAnimationFrame(t)};b.current=requestAnimationFrame(t)};return window.__CODEXMETER_EXPORT__={ready:!!(t&&!i&&p),jobId:e,start(){n()},get currentTimeMs(){return y.current?.currentSeekMs||0},get finished(){return!!y.current?.finished},getDebugState(){return y.current?.debugState||null},getDebugTrace(){return y.current?.debugTrace||[]}},()=>{delete window.__CODEXMETER_EXPORT__}},[p,i,e,t]),i)return(0,I.jsx)(`div`,{style:R,children:(0,I.jsxs)(`div`,{style:B,children:[`Export error: `,i]})});if(!o?.liveData)return(0,I.jsx)(`div`,{style:R,children:(0,I.jsx)(`div`,{style:B,children:`CodexMeter exporting…`})});let w=y.current,T=w?{startMs:w.startHoldDurationMs,endMs:w.finalHoldStartMs}:null;return(0,I.jsx)(`div`,{style:R,children:(0,I.jsxs)(`div`,{style:z,children:[(0,I.jsxs)(`div`,{style:{...G,opacity:_(o.seekMs)},children:[(0,I.jsx)(c,{presentation:o.presentation,rawPresentation:o.rawPresentation,ingestProgress:Math.min(Math.max(o.progress?.percent||0,0),1),isIngestActive:!!(o.progress&&!o.progress.complete),exportMode:!1,exportPlayback:!0,exportPhase:o.phase,exportSeekMs:o.seekMs,exportDaily:w?.finalPresentation?.daily||null,exportDailyTiming:T}),(0,I.jsxs)(`div`,{style:V,children:[`Made with `,(0,I.jsx)(`span`,{style:H,children:`♥`}),` by JJ`]})]}),(0,I.jsx)(`div`,{style:{...W,opacity:g(o.seekMs)}}),(0,I.jsx)(`div`,{style:{...U,...h(o.seekMs,C.current)}})]})})}var R={width:`100vw`,minHeight:`100vh`,background:`#06080f`,display:`flex`,alignItems:`center`,justifyContent:`center`,overflow:`hidden`},z={position:`relative`,width:1080,height:864,padding:`24px 28px 20px`,background:`#06080f`,overflow:`hidden`},B={color:`#8b949e`,fontFamily:`'JetBrains Mono', 'Fira Code', monospace`,fontSize:18},V={position:`absolute`,right:18,bottom:10,color:`rgba(139, 148, 158, 0.58)`,fontSize:10,fontFamily:`'JetBrains Mono', 'Fira Code', monospace`,letterSpacing:`0.02em`,opacity:.62,pointerEvents:`none`},H={color:`rgba(244, 63, 94, 0.52)`},U={position:`absolute`,inset:0,background:`linear-gradient(180deg, rgba(255,255,255,1) 0%, rgba(248,250,255,1) 100%)`,pointerEvents:`none`,zIndex:20,mixBlendMode:`screen`},W={position:`absolute`,inset:0,background:`#000000`,pointerEvents:`none`,zIndex:30},G={position:`relative`,zIndex:1};export{L as default};
@@ -0,0 +1 @@
1
+ import{c as e,p as t,t as n}from"./index-Bxd44dxc.js";import{$n as r,C as i,N as a,P as o,S as s,T as c,_ as l,a as u,b as d,t as f,v as p,w as m,x as h,y as g}from"./animationsDefault-C_urdfl6.js";import{t as _}from"./formatters-lxlIPan_.js";import{n as v,t as y}from"./subcharts-CA6MYRo3.js";var b=t(e(),1),x=n();o([c,m,i,s,h,d]);function S(e){return _(e)}function C(e){return e==null||e===0?`—`:e>=1e3?`$`+(e/1e3).toFixed(1)+`K`:`$`+e.toFixed(2)}var w=[`all`,`review`,`exploration`,`planning`,`memory`,`generic`],T=[`review`,`exploration`,`planning`,`memory`,`generic`];function E(e){if(!e.current)return;let t=e.current.getEchartsInstance().getDataURL({type:`png`,pixelRatio:2,backgroundColor:`#06080f`});Object.assign(document.createElement(`a`),{href:t,download:`codexmeter-repos.png`}).click()}function D(e,t=`total`){let n=e?.data;return Array.isArray(n)?n:n?.[t]||n?.total||[]}function O({repo:e,chartMode:t}){let[n,i]=(0,b.useState)(!1),o=(0,b.useMemo)(()=>y(e.by_model),[e.by_model]),s=(0,b.useMemo)(()=>y(e.by_family),[e.by_family]),c=v({title:`Models in repo`,rows:o,valueKey:`tokens`,colorForKey:p,valueFormatter:S,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1}),u=v({title:`Work type in repo`,rows:s,valueKey:`tokens`,colorForKey:l,valueFormatter:S,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1}),d=[...o.slice(0,4).map(e=>({...e,scope:`model`})),...s.slice(0,4).map(e=>({...e,scope:`family`}))];return(0,x.jsxs)(`div`,{className:`model-detail-wrap`,children:[(0,x.jsxs)(`div`,{className:`model-detail-charts`,children:[(0,x.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,x.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Models in repo`}),(0,x.jsx)(r,{echarts:a,option:c,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,x.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,x.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Work type in repo`}),(0,x.jsx)(r,{echarts:a,option:u,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]})]}),(0,x.jsx)(`div`,{className:`model-detail-footer`,children:(0,x.jsxs)(`button`,{type:`button`,className:`model-detail-toggle`,onClick:()=>i(e=>!e),"aria-expanded":n,children:[(0,x.jsx)(`span`,{className:`model-detail-toggle-text`,children:n?`Hide details`:`Show details`}),(0,x.jsx)(`span`,{className:`model-detail-toggle-arrow ${n?`expanded`:``}`,"aria-hidden":!0,children:`▼`})]})}),(0,x.jsx)(`div`,{className:`model-detail-summary-wrap ${n?`expanded`:``}`,children:(0,x.jsx)(`div`,{className:`model-detail-summary`,children:d.map(e=>(0,x.jsxs)(`div`,{className:`model-detail-summary-card`,children:[(0,x.jsxs)(`div`,{className:`model-detail-summary-head`,children:[(0,x.jsx)(`span`,{className:`model-detail-swatch`,style:{background:e.scope===`model`?p(e.key):l(e.key)}}),(0,x.jsx)(`span`,{className:`model-detail-summary-name`,title:e.key,children:e.key})]}),(0,x.jsxs)(`div`,{className:`model-detail-summary-line`,children:[S(e.tokens),` tokens`]}),(0,x.jsxs)(`div`,{className:`model-detail-summary-line`,children:[e.sessions||0,` sessions`]}),(0,x.jsx)(`div`,{className:`model-detail-summary-line`,children:C(e.cost)})]},`${e.scope}-${e.key}`))})})]})}function k({data:e,range:t=`total`,chartMode:n=`default`,focusRequest:i=null,onFocusRequestConsumed:o}){let[s,c]=(0,b.useState)(`all`),[l,d]=(0,b.useState)(null),p=(0,b.useRef)(null),m=(0,b.useRef)(null),h=(0,b.useMemo)(()=>D(e,t),[e,t]),_=(0,b.useMemo)(()=>h?.length?s===`all`?h:h.map(e=>{let t=e.by_family?.[s];return t?{...e,tokens:t.tokens,cost:t.cost,sessions:t.sessions}:null}).filter(Boolean).sort((e,t)=>t.tokens-e.tokens):[],[h,s]);(0,b.useEffect)(()=>{l&&(_.some(e=>e.repo_key===l)||d(null))},[l,_]),(0,b.useEffect)(()=>{if(!i){m.current=null;return}let{id:e,repoLabel:t}=i;if(!t||m.current===e)return;let n=h.find(e=>e.repo_label===t||e.repo_key===t);m.current=e,n&&d(n.repo_key),o?.()},[i,h,o]);let v=_.slice(0,15),y=[...v].reverse(),k=Math.max(...v.map(e=>e.tokens||0),0),A=Math.max(250,v.length*28),j=(0,b.useMemo)(()=>({backgroundColor:`transparent`,...f,tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{let t=v[v.length-1-e[0].dataIndex];return t?`<b>${t.repo_label}</b><br/>Tokens: ${S(t.tokens)}<br/>Cost: ${C(t.cost)}<br/>Sessions: ${t.sessions}`:``}},grid:{left:150,right:50,top:8,bottom:8},xAxis:{type:`value`,splitNumber:4,max:k||1,axisLabel:{formatter:e=>S(e),color:`#484f58`,showMinLabel:!0,showMaxLabel:!0},splitLine:{lineStyle:{color:[`transparent`,`#21262d`,`#21262d`,`#21262d`,`transparent`]}}},yAxis:{type:`category`,data:y.map(e=>e.repo_label),axisLabel:{color:`#8b949e`,fontSize:11},axisTick:{show:!1},axisLine:{show:!1}},series:[{id:`repos-range-bars`,type:`bar`,universalTransition:!0,data:y.map(e=>({id:e.repo_key,name:e.repo_label,value:e.tokens,itemStyle:{color:g(e.repo_label),borderRadius:[0,3,3,0]}})),barMaxWidth:16,label:{show:!0,position:`right`,formatter:e=>S(e.value??0),color:`#8b949e`,fontSize:10,...u}}]}),[k,y,v]),M=(0,b.useMemo)(()=>({click:e=>{if(e?.componentType===`series`&&e?.dataIndex!=null){let t=v[v.length-1-e.dataIndex];t&&d(e=>e===t.repo_key?null:t.repo_key)}}}),[v]);return h?.length?(0,x.jsxs)(`div`,{className:`animate-in`,children:[(0,x.jsxs)(`div`,{className:`section-header`,children:[(0,x.jsx)(`span`,{className:`section-title`,children:`Repos`}),(0,x.jsx)(`div`,{className:`btn-group`,children:w.map(e=>(0,x.jsx)(`button`,{className:`btn ${s===e?`active`:``}`,onClick:()=>c(e),children:e},e))})]}),(0,x.jsxs)(`div`,{className:`chart-card`,children:[(0,x.jsx)(`button`,{className:`export-btn`,onClick:()=>E(p),children:`PNG`}),(0,x.jsx)(`div`,{style:{height:A,transition:`height 220ms cubic-bezier(0.22, 1, 0.36, 1)`},children:(0,x.jsx)(r,{ref:p,echarts:a,option:j,style:{height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1,onEvents:M})})]}),(0,x.jsx)(`div`,{className:`table-wrap`,children:(0,x.jsxs)(`table`,{children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:`Repo`}),(0,x.jsx)(`th`,{children:`Tokens`}),(0,x.jsx)(`th`,{children:`Cost`}),(0,x.jsx)(`th`,{children:`Sessions`}),(0,x.jsx)(`th`,{style:{width:200},children:`Families`})]})}),(0,x.jsx)(`tbody`,{children:_.map(e=>(0,x.jsxs)(b.Fragment,{children:[(0,x.jsxs)(`tr`,{onClick:()=>d(l===e.repo_key?null:e.repo_key),style:{cursor:`pointer`},children:[(0,x.jsxs)(`td`,{style:{fontWeight:500,color:`var(--text-primary)`},children:[(0,x.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:2,background:g(e.repo_label),marginRight:8}}),e.repo_label]}),(0,x.jsx)(`td`,{style:{fontFamily:`var(--font-mono)`},children:S(e.tokens)}),(0,x.jsx)(`td`,{style:{fontFamily:`var(--font-mono)`},children:C(e.cost)}),(0,x.jsx)(`td`,{children:e.sessions}),(0,x.jsx)(`td`,{children:Object.entries(e.by_family||{}).sort(([e],[t])=>{let n=T.indexOf(e),r=T.indexOf(t);return(n===-1?999:n)-(r===-1?999:r)}).slice(0,3).map(([e])=>(0,x.jsx)(`span`,{className:`tag tag-${e}`,style:{marginRight:3},children:e},e))})]}),l===e.repo_key&&(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:5,style:{background:`var(--bg-surface)`,padding:`0.75rem 1rem`},children:(0,x.jsx)(O,{repo:e,chartMode:n})})})]},e.repo_key))})]})})]}):(0,x.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem`},children:`No data`})}export{k as default};