codexmeter 1.0.24 → 1.0.26
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.
|
@@ -24,8 +24,8 @@ yyyy`);var r=kc(t),i=n?`getUTC`:`get`,a=r[i+`FullYear`](),o=r[i+`Month`]()+1,s=r
|
|
|
24
24
|
|
|
25
25
|
`:`<br/>`,m=l.join(p);this._showOrMove(a,function(){this._updateContentNotChangedOnAxis(e,s)?this._updatePosition(a,d,i[0],i[1],this._tooltipContent,s):this._showTooltipContent(a,m,s,Math.random()+``,i[0],i[1],d,null,u)})},t.prototype._showSeriesItemTooltip=function(e,t,n){var r=this._ecModel,i=kf(t),a=i.seriesIndex,o=r.getSeriesByIndex(a),s=i.dataModel||o,c=i.dataIndex,l=i.dataType,u=s.getData(l),d=this._renderMode,f=e.positionDefault,p=YL([u.getItemModel(c),s,o&&(o.coordinateSystem||{}).model],this._tooltipModel,f?{position:f}:null),m=p.get(`trigger`);if(!(m!=null&&m!==`item`)){var h=s.getDataParams(c,l),g=new jx;h.marker=g.makeTooltipMarker(`item`,lv(h.color),d);var _=jb(s.formatTooltip(c,!1,l)),v=p.get(`order`),y=p.get(`valueFormatter`),b=_.frag,x=b?xx(y?B({valueFormatter:y},b):b,g,d,v,r.get(`useUTC`),p.get(`textStyle`)):_.text,S=`item_`+s.name+`_`+c;this._showOrMove(p,function(){this._showTooltipContent(p,x,h,S,e.offsetX,e.offsetY,e.position,e.target,g)}),n({type:`showTip`,dataIndexInside:c,dataIndex:u.getRawIndex(c),seriesIndex:a,from:this.uid})}},t.prototype._showComponentItemTooltip=function(e,t,n){var r=this._renderMode===`html`,i=kf(t),a=i.tooltipConfig.option||{},o=a.encodeHTMLContent;if(G(a)){var s=a;a={content:s,formatter:s},o=!0}o&&r&&a.content&&(a=Rt(a),a.content=vr(a.content));var c=[a],l=this._ecModel.getComponent(i.componentMainType,i.componentIndex);l&&c.push(l),c.push({formatter:a.content});var u=e.positionDefault,d=YL(c,this._tooltipModel,u?{position:u}:null),f=d.get(`content`),p=Math.random()+``,m=new jx;this._showOrMove(d,function(){var n=Rt(d.get(`formatterParams`)||{});this._showTooltipContent(d,f,n,p,e.offsetX,e.offsetY,e.position,t,m)}),n({type:`showTip`,from:this.uid})},t.prototype._showTooltipContent=function(e,t,n,r,i,a,o,s,c){if(this._ticket=``,!(!e.get(`showContent`)||!e.get(`show`))){var l=this._tooltipContent;l.setEnterable(e.get(`enterable`));var u=e.get(`formatter`);o||=e.get(`position`);var d=t,f=this._getNearestPoint([i,a],n,e.get(`trigger`),e.get(`borderColor`),e.get(`defaultBorderColor`,!0)).color;if(u)if(G(u)){var p=e.ecModel.get(`useUTC`),m=W(n)?n[0]:n,h=m&&m.axisType&&m.axisType.indexOf(`time`)>=0;d=u,h&&(d=P_(m.axisValue,d,p)),d=av(d,n,!0)}else if(en(u)){var g=U(function(t,r){t===this._ticket&&(l.setContent(r,c,e,f,o),this._updatePosition(e,o,i,a,l,n,s))},this);this._ticket=r,d=u(n,r,g)}else d=u;l.setContent(d,c,e,f,o),l.show(e,f),this._updatePosition(e,o,i,a,l,n,s)}},t.prototype._getNearestPoint=function(e,t,n,r,i){if(n===`axis`||W(t))return{color:r||i};if(!W(t))return{color:r||t.color||t.borderColor}},t.prototype._updatePosition=function(e,t,n,r,i,a,o){var s=this._api.getWidth(),c=this._api.getHeight();t||=e.get(`position`);var l=i.getSize(),u=e.get(`align`),d=e.get(`verticalAlign`),f=o&&o.getBoundingRect().clone();if(o&&f.applyTransform(o.transform),en(t)&&(t=t([n,r],a,i.el,f,{viewSize:[s,c],contentSize:l.slice()})),W(t))n=dc(t[0],s),r=dc(t[1],c);else if(K(t)){var p=t;p.width=l[0],p.height=l[1];var m=Ov(p,{width:s,height:c});n=m.x,r=m.y,u=null,d=null}else if(G(t)&&o){var h=$L(t,f,l,e.get(`borderWidth`));n=h[0],r=h[1]}else{var h=ZL(n,r,i,s,c,u?null:20,d?null:20);n=h[0],r=h[1]}if(u&&(n-=eR(u)?l[0]/2:u===`right`?l[0]:0),d&&(r-=eR(d)?l[1]/2:d===`bottom`?l[1]:0),EL(e)){var h=QL(n,r,i,s,c);n=h[0],r=h[1]}i.moveTo(n,r)},t.prototype._updateContentNotChangedOnAxis=function(e,t){var n=this._lastDataByCoordSys,r=this._cbParamsList,i=!!n&&n.length===e.length;return i&&V(n,function(n,a){var o=n.dataByAxis||[],s=(e[a]||{}).dataByAxis||[];i&&=o.length===s.length,i&&V(o,function(e,n){var a=s[n]||{},o=e.seriesDataIndices||[],c=a.seriesDataIndices||[];i=i&&e.value===a.value&&e.axisType===a.axisType&&e.axisId===a.axisId&&o.length===c.length,i&&V(o,function(e,t){var n=c[t];i=i&&e.seriesIndex===n.seriesIndex&&e.dataIndex===n.dataIndex}),r&&V(e.seriesDataIndices,function(e){var n=e.seriesIndex,a=t[n],o=r[n];a&&o&&o.data!==a.data&&(i=!1)})})}),this._lastDataByCoordSys=e,this._cbParamsList=t,!!i},t.prototype._hide=function(e){this._lastDataByCoordSys=null,this._cbParamsList=null,e({type:`hideTip`,from:this.uid})},t.prototype.dispose=function(e,t){ft.node||!t.getDom()||(oS(this,`_updatePosition`),this._tooltipContent.dispose(),CI(`itemTooltip`,t),this._tooltipContent=null,this._tooltipModel=null,this._lastDataByCoordSys=null,this._cbParamsList=null)},t.type=`tooltip`,t}(Gx);function YL(e,t,n){var r=t.ecModel,i;n?(i=new qg(n,r,r),i=new qg(t.option,i,r)):i=t;for(var a=e.length-1;a>=0;a--){var o=e[a];o&&(o instanceof qg&&(o=o.get(`tooltip`,!0)),G(o)&&(o={formatter:o}),o&&(i=new qg(o,i,r)))}return i}function XL(e,t){return e.dispatchAction||U(t.dispatchAction,t)}function ZL(e,t,n,r,i,a,o){var s=n.getSize(),c=s[0],l=s[1];return a!=null&&(e+c+a+2>r?e-=c+a:e+=a),o!=null&&(t+l+o>i?t-=l+o:t+=o),[e,t]}function QL(e,t,n,r,i){var a=n.getSize(),o=a[0],s=a[1];return e=Math.min(e+o,r)-o,t=Math.min(t+s,i)-s,e=Math.max(e,0),t=Math.max(t,0),[e,t]}function $L(e,t,n,r){var i=n[0],a=n[1],o=Math.ceil(Math.SQRT2*r)+8,s=0,c=0,l=t.width,u=t.height;switch(e){case`inside`:s=t.x+l/2-i/2,c=t.y+u/2-a/2;break;case`top`:s=t.x+l/2-i/2,c=t.y-a-o;break;case`bottom`:s=t.x+l/2-i/2,c=t.y+u+o;break;case`left`:s=t.x-i-o,c=t.y+u/2-a/2;break;case`right`:s=t.x+l+o,c=t.y+u/2-a/2}return[s,c]}function eR(e){return e===`center`||e===`middle`}function tR(e,t,n){var r=yl(e).queryOptionMap,i=r.keys()[0];if(!(!i||i===`series`)){var a=Sl(t,i,r.get(i),{useDefault:!1,enableAll:!1,enableNone:!1}).models[0];if(a){var o=n.getViewOfComponentModel(a),s;if(o.group.traverse(function(t){var n=kf(t).tooltipConfig;if(n&&n.name===e.name)return s=t,!0}),s)return{componentMainType:i,componentIndex:a.componentIndex,el:s}}}}function nR(e){uk(RI),e.registerComponentModel(TL),e.registerComponentView(JL),e.registerAction({type:`showTip`,event:`showTip`,update:`tooltip:manuallyShowTip`},Dn),e.registerAction({type:`hideTip`,event:`hideTip`,update:`tooltip:manuallyHideTip`},Dn)}R();var rR=function(e){O(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.layoutMode={type:`box`,ignoreSize:!0},n}return t.type=`title`,t.defaultOption={z:6,show:!0,text:``,target:`blank`,subtext:``,subtarget:`blank`,left:`center`,top:Z.size.m,backgroundColor:Z.color.transparent,borderColor:Z.color.primary,borderWidth:0,padding:5,itemGap:10,textStyle:{fontSize:18,fontWeight:`bold`,color:Z.color.primary},subtextStyle:{fontSize:12,color:Z.color.quaternary}},t}(Lv),iR=function(e){O(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){if(this.group.removeAll(),e.get(`show`)){var r=this.group,i=e.getModel(`textStyle`),a=e.getModel(`subtextStyle`),o=e.get(`textAlign`),s=q(e.get(`textBaseline`),e.get(`textVerticalAlign`)),c=new hf({style:Tg(i,{text:e.get(`text`),fill:i.getTextColor()},{disableBox:!0}),z2:10}),l=c.getBoundingRect(),u=e.get(`subtext`),d=new hf({style:Tg(a,{text:u,fill:a.getTextColor(),y:l.height+e.get(`itemGap`),verticalAlign:`top`},{disableBox:!0}),z2:10}),f=e.get(`link`),p=e.get(`sublink`),m=e.get(`triggerEvent`,!0);c.silent=!f&&!m,d.silent=!p&&!m,f&&c.on(`click`,function(){uv(f,`_`+e.get(`target`))}),p&&d.on(`click`,function(){uv(p,`_`+e.get(`subtarget`))}),kf(c).eventData=kf(d).eventData=m?{componentType:`title`,componentIndex:e.componentIndex}:null,r.add(c),u&&r.add(d);var h=r.getBoundingRect(),g=e.getBoxLayoutParams();g.width=h.width,g.height=h.height;var _=Ov(g,Av(e,n).refContainer,e.get(`padding`));o||(o=e.get(`left`)||e.get(`right`),o===`middle`&&(o=`center`),o===`right`?_.x+=_.width:o===`center`&&(_.x+=_.width/2)),s||(s=e.get(`top`)||e.get(`bottom`),s===`center`&&(s=`middle`),s===`bottom`?_.y+=_.height:s===`middle`&&(_.y+=_.height/2),s||=`top`),r.x=_.x,r.y=_.y,r.markRedraw();var v={align:o,verticalAlign:s};c.setStyle(v),d.setStyle(v),h=r.getBoundingRect();var y=_.margin,b=e.getItemStyle([`color`,`opacity`]);b.fill=e.get(`backgroundColor`);var x=new uf({shape:{x:h.x-y[3],y:h.y-y[0],width:h.width+y[1]+y[3],height:h.height+y[0]+y[2],r:e.get(`borderRadius`)},style:b,subPixelOptimize:!0,silent:!0});r.add(x)}},t.type=`title`,t}(Gx);function aR(e){e.registerComponentModel(rR),e.registerComponentView(iR)}R();var oR=function(e,t){if(t===`all`)return{type:`all`,title:e.getLocaleModel().get([`legend`,`selector`,`all`])};if(t===`inverse`)return{type:`inverse`,title:e.getLocaleModel().get([`legend`,`selector`,`inverse`])}},sR=function(e){O(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.layoutMode={type:`box`,ignoreSize:!0},n}return t.prototype.init=function(e,t,n){this.mergeDefaultAndTheme(e,n),e.selected=e.selected||{},this._updateSelector(e)},t.prototype.mergeOption=function(t,n){e.prototype.mergeOption.call(this,t,n),this._updateSelector(t)},t.prototype._updateSelector=function(e){var t=e.selector,n=this.ecModel;t===!0&&(t=e.selector=[`all`,`inverse`]),W(t)&&V(t,function(e,r){G(e)&&(e={type:e}),t[r]=zt(e,oR(n,e.type))})},t.prototype.optionUpdated=function(){this._updateData(this.ecModel);var e=this._data;if(e[0]&&this.get(`selectedMode`)===`single`){for(var t=!1,n=0;n<e.length;n++){var r=e[n].get(`name`);if(this.isSelected(r)){this.select(r),t=!0;break}}!t&&this.select(e[0].get(`name`))}},t.prototype._updateData=function(e){var t=[],n=[];e.eachRawSeries(function(r){var i=r.name;n.push(i);var a;if(r.legendVisualProvider){var o=r.legendVisualProvider.getAllNames();e.isSeriesFiltered(r)||(n=n.concat(o)),o.length?t=t.concat(o):a=!0}else a=!0;a&&dl(r)&&t.push(r.name)}),this._availableNames=n;var r=this.get(`data`)||t,i=J(),a=H(r,function(e){return(G(e)||nn(e))&&(e={name:e}),i.get(e.name)?null:(i.set(e.name,!0),new qg(e,this,this.ecModel))},this);this._data=Yt(a,function(e){return!!e})},t.prototype.getData=function(){return this._data},t.prototype.select=function(e){var t=this.option.selected;if(this.get(`selectedMode`)===`single`){var n=this._data;V(n,function(e){t[e.get(`name`)]=!1})}t[e]=!0},t.prototype.unSelect=function(e){this.get(`selectedMode`)!==`single`&&(this.option.selected[e]=!1)},t.prototype.toggleSelected=function(e){var t=this.option.selected;t.hasOwnProperty(e)||(t[e]=!0),this[t[e]?`unSelect`:`select`](e)},t.prototype.allSelect=function(){var e=this._data,t=this.option.selected;V(e,function(e){t[e.get(`name`,!0)]=!0})},t.prototype.inverseSelect=function(){var e=this._data,t=this.option.selected;V(e,function(e){var n=e.get(`name`,!0);t.hasOwnProperty(n)||(t[n]=!0),t[n]=!t[n]})},t.prototype.isSelected=function(e){var t=this.option.selected;return!(t.hasOwnProperty(e)&&!t[e])&&Wt(this._availableNames,e)>=0},t.prototype.getOrient=function(){return this.get(`orient`)===`vertical`?{index:1,name:`vertical`}:{index:0,name:`horizontal`}},t.type=`legend.plain`,t.dependencies=[`series`],t.defaultOption={z:4,show:!0,orient:`horizontal`,left:`center`,bottom:Z.size.m,align:`auto`,backgroundColor:Z.color.transparent,borderColor:Z.color.border,borderRadius:0,borderWidth:0,padding:5,itemGap:8,itemWidth:25,itemHeight:14,symbolRotate:`inherit`,symbolKeepAspect:!0,inactiveColor:Z.color.disabled,inactiveBorderColor:Z.color.disabled,inactiveBorderWidth:`auto`,itemStyle:{color:`inherit`,opacity:`inherit`,borderColor:`inherit`,borderWidth:`auto`,borderCap:`inherit`,borderJoin:`inherit`,borderDashOffset:`inherit`,borderMiterLimit:`inherit`},lineStyle:{width:`auto`,color:`inherit`,inactiveColor:Z.color.disabled,inactiveWidth:2,opacity:`inherit`,type:`inherit`,cap:`inherit`,join:`inherit`,dashOffset:`inherit`,miterLimit:`inherit`},textStyle:{color:Z.color.secondary},selectedMode:!0,selector:!1,selectorLabel:{show:!0,borderRadius:10,padding:[3,5,3,5],fontSize:12,fontFamily:`sans-serif`,color:Z.color.tertiary,borderWidth:1,borderColor:Z.color.border},emphasis:{selectorLabel:{show:!0,color:Z.color.quaternary}},selectorPosition:`auto`,selectorItemGap:7,selectorButtonGap:10,tooltip:{show:!1},triggerEvent:!1},t}(Lv);R();var cR=$t,lR=V,uR=Ps,dR=function(e){O(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.newlineDisabled=!1,n}return t.prototype.init=function(){this.group.add(this._contentGroup=new uR),this.group.add(this._selectorGroup=new uR),this._isFirstRender=!0},t.prototype.getContentGroup=function(){return this._contentGroup},t.prototype.getSelectorGroup=function(){return this._selectorGroup},t.prototype.render=function(e,t,n){var r=this._isFirstRender;if(this._isFirstRender=!1,this.resetInner(),e.get(`show`,!0)){var i=e.get(`align`),a=e.get(`orient`);(!i||i===`auto`)&&(i=e.get(`left`)===`right`&&a===`vertical`?`right`:`left`);var o=e.get(`selector`,!0),s=e.get(`selectorPosition`,!0);o&&(!s||s===`auto`)&&(s=a===`horizontal`?`end`:`start`),this.renderInner(i,e,t,n,o,a,s);var c=Av(e,n).refContainer,l=e.getBoxLayoutParams(),u=e.get(`padding`),d=Ov(l,c,u),f=this.layoutInner(e,i,d,r,o,s),p=Ov(Ht({width:f.width,height:f.height},l),c,u);this.group.x=p.x-f.x,this.group.y=p.y-f.y,this.group.markRedraw(),this.group.add(this._backgroundEl=wL(f,e))}},t.prototype.resetInner=function(){this.getContentGroup().removeAll(),this._backgroundEl&&this.group.remove(this._backgroundEl),this.getSelectorGroup().removeAll()},t.prototype.renderInner=function(e,t,n,r,i,a,o){var s=this.getContentGroup(),c=J(),l=t.get(`selectedMode`),u=t.get(`triggerEvent`),d=[];n.eachRawSeries(function(e){!e.get(`legendHoverLink`)&&d.push(e.id)}),lR(t.getData(),function(i,a){var o=this,f=i.get(`name`);if(!this.newlineDisabled&&(f===``||f===`
|
|
26
26
|
`)){var p=new uR;p.newline=!0,s.add(p);return}var m=n.getSeriesByName(f)[0];if(!c.get(f))if(m){var h=m.getData(),g=h.getVisual(`legendLineStyle`)||{},_=h.getVisual(`legendIcon`),v=h.getVisual(`style`),y=this._createItem(m,f,a,i,t,e,g,v,_,l,r);y.on(`click`,cR(mR,f,null,r,d)).on(`mouseover`,cR(hR,m.name,null,r,d)).on(`mouseout`,cR(gR,m.name,null,r,d)),n.ssr&&y.eachChild(function(e){var t=kf(e);t.seriesIndex=m.seriesIndex,t.dataIndex=a,t.ssrType=`legend`}),u&&y.eachChild(function(e){o.packEventData(e,t,m,a,f)}),c.set(f,!0)}else n.eachRawSeries(function(o){var s=this;if(!c.get(f)&&o.legendVisualProvider){var p=o.legendVisualProvider;if(!p.containName(f))return;var m=p.indexOfName(f),h=p.getItemVisual(m,`style`),g=p.getItemVisual(m,`legendIcon`),_=ja(h.fill);_&&_[3]===0&&(_[3]=.2,h=B(B({},h),{fill:Ha(_,`rgba`)}));var v=this._createItem(o,f,a,i,t,e,{},h,g,l,r);v.on(`click`,cR(mR,null,f,r,d)).on(`mouseover`,cR(hR,null,f,r,d)).on(`mouseout`,cR(gR,null,f,r,d)),n.ssr&&v.eachChild(function(e){var t=kf(e);t.seriesIndex=o.seriesIndex,t.dataIndex=a,t.ssrType=`legend`}),u&&v.eachChild(function(e){s.packEventData(e,t,o,a,f)}),c.set(f,!0)}},this)},this),i&&this._createSelector(i,t,r,a,o)},t.prototype.packEventData=function(e,t,n,r,i){var a={componentType:`legend`,componentIndex:t.componentIndex,dataIndex:r,value:i,seriesIndex:n.seriesIndex};kf(e).eventData=a},t.prototype._createSelector=function(e,t,n,r,i){var a=this.getSelectorGroup();lR(e,function(e){var r=e.type,i=new hf({style:{x:0,y:0,align:`center`,verticalAlign:`middle`},onclick:function(){n.dispatchAction({type:r===`all`?`legendAllSelect`:`legendInverseSelect`,legendId:t.id})}});a.add(i),Cg(i,{normal:t.getModel(`selectorLabel`),emphasis:t.getModel([`emphasis`,`selectorLabel`])},{defaultText:e.title}),Ip(i)})},t.prototype._createItem=function(e,t,n,r,i,a,o,s,c,l,u){var d=e.visualDrawType,f=i.get(`itemWidth`),p=i.get(`itemHeight`),m=i.isSelected(t),h=r.get(`symbolRotate`),g=r.get(`symbolKeepAspect`),_=r.get(`icon`);c=_||c||`roundRect`;var v=fR(c,r,o,s,d,m,u),y=new uR,b=r.getModel(`textStyle`);if(en(e.getLegendIcon)&&(!_||_===`inherit`))y.add(e.getLegendIcon({itemWidth:f,itemHeight:p,icon:c,iconRotate:h,itemStyle:v.itemStyle,lineStyle:v.lineStyle,symbolKeepAspect:g}));else{var x=_===`inherit`&&e.getData().getVisual(`symbol`)?h===`inherit`?e.getData().getVisual(`symbolRotate`):h:0;y.add(pR({itemWidth:f,itemHeight:p,icon:c,iconRotate:x,itemStyle:v.itemStyle,lineStyle:v.lineStyle,symbolKeepAspect:g}))}var S=a===`left`?f+5:-5,C=a,w=i.get(`formatter`),T=t;G(w)&&w?T=w.replace(`{name}`,t??``):en(w)&&(T=w(t));var E=m?b.getTextColor():r.get(`inactiveColor`);y.add(new hf({style:Tg(b,{text:T,x:S,y:p/2,fill:E,align:C,verticalAlign:`middle`},{inheritColor:E})}));var D=new uf({shape:y.getBoundingRect(),style:{fill:`transparent`}}),O=r.getModel(`tooltip`);return O.get(`show`)&&ag({el:D,componentModel:i,itemName:t,itemTooltipOption:O.option}),y.add(D),y.eachChild(function(e){e.silent=!0}),D.silent=!l,this.getContentGroup().add(y),Ip(y),y.__legendDataIndex=n,y},t.prototype.layoutInner=function(e,t,n,r,i,a){var o=this.getContentGroup(),s=this.getSelectorGroup();wv(e.get(`orient`),o,e.get(`itemGap`),n.width,n.height);var c=o.getBoundingRect(),l=[-c.x,-c.y];if(s.markRedraw(),o.markRedraw(),i){wv(`horizontal`,s,e.get(`selectorItemGap`,!0));var u=s.getBoundingRect(),d=[-u.x,-u.y],f=e.get(`selectorButtonGap`,!0),p=e.getOrient().index,m=p===0?`width`:`height`,h=p===0?`height`:`width`,g=p===0?`y`:`x`;a===`end`?d[p]+=c[m]+f:l[p]+=u[m]+f,d[1-p]+=c[h]/2-u[h]/2,s.x=d[0],s.y=d[1],o.x=l[0],o.y=l[1];var _={x:0,y:0};return _[m]=c[m]+f+u[m],_[h]=Math.max(c[h],u[h]),_[g]=Math.min(0,u[g]+d[1-p]),_}else return o.x=l[0],o.y=l[1],this.group.getBoundingRect()},t.prototype.remove=function(){this.getContentGroup().removeAll(),this._isFirstRender=!0},t.type=`legend.plain`,t}(Gx);function fR(e,t,n,r,i,a,o){function s(e,t){e.lineWidth===`auto`&&(e.lineWidth=t.lineWidth>0?2:0),lR(e,function(n,r){e[r]===`inherit`&&(e[r]=t[r])})}var c=t.getModel(`itemStyle`),l=c.getItemStyle(),u=e.lastIndexOf(`empty`,0)===0?`fill`:`stroke`,d=c.getShallow(`decal`);l.decal=!d||d===`inherit`?r.decal:rw(d,o),l.fill===`inherit`&&(l.fill=r[i]),l.stroke===`inherit`&&(l.stroke=r[u]),l.opacity===`inherit`&&(l.opacity=(i===`fill`?r:n).opacity),s(l,r);var f=t.getModel(`lineStyle`),p=f.getLineStyle();if(s(p,n),l.fill===`auto`&&(l.fill=r.fill),l.stroke===`auto`&&(l.stroke=r.fill),p.stroke===`auto`&&(p.stroke=r.fill),!a){var m=t.get(`inactiveBorderWidth`),h=l[u];l.lineWidth=m===`auto`?r.lineWidth>0&&h?2:0:l.lineWidth,l.fill=t.get(`inactiveColor`),l.stroke=t.get(`inactiveBorderColor`),p.stroke=f.get(`inactiveColor`),p.lineWidth=f.get(`inactiveWidth`)}return{itemStyle:l,lineStyle:p}}function pR(e){var t=e.icon||`roundRect`,n=mC(t,0,0,e.itemWidth,e.itemHeight,e.itemStyle.fill,e.symbolKeepAspect);return n.setStyle(e.itemStyle),n.rotation=(e.iconRotate||0)*Math.PI/180,n.setOrigin([e.itemWidth/2,e.itemHeight/2]),t.indexOf(`empty`)>-1&&(n.style.stroke=n.style.fill,n.style.fill=Z.color.neutral00,n.style.lineWidth=2),n}function mR(e,t,n,r){gR(e,t,n,r),n.dispatchAction({type:`legendToggleSelect`,name:e??t}),hR(e,t,n,r)}function hR(e,t,n,r){n.usingTHL()||n.dispatchAction({type:`highlight`,seriesName:e,name:t,excludeSeriesId:r})}function gR(e,t,n,r){n.usingTHL()||n.dispatchAction({type:`downplay`,seriesName:e,name:t,excludeSeriesId:r})}function _R(e,t,n){var r=e===`allSelect`||e===`inverseSelect`,i={},a=[];n.eachComponent({mainType:`legend`,query:t},function(n){r?n[e]():n[e](t.name),vR(n,i),a.push(n.componentIndex)});var o={};return n.eachComponent(`legend`,function(e){V(i,function(t,n){e[t?`select`:`unSelect`](n)}),vR(e,o)}),r?{selected:o,legendIndex:a}:{name:t.name,selected:o}}function vR(e,t){var n=t||{};return V(e.getData(),function(t){var r=t.get(`name`);if(!(r===`
|
|
27
|
-
`||r===``)){var i=e.isSelected(r);Y(n,r)?n[r]=n[r]&&i:n[r]=i}}),n}function yR(e){e.registerAction(`legendToggleSelect`,`legendselectchanged`,$t(_R,`toggleSelected`)),e.registerAction(`legendAllSelect`,`legendselectall`,$t(_R,`allSelect`)),e.registerAction(`legendInverseSelect`,`legendinverseselect`,$t(_R,`inverseSelect`)),e.registerAction(`legendSelect`,`legendselected`,$t(_R,`select`)),e.registerAction(`legendUnSelect`,`legendunselected`,$t(_R,`unSelect`))}var bR=Gl(xR);function xR(e){var t=e.findComponents({mainType:`legend`});t&&t.length&&e.filterSeries(function(e){for(var n=0;n<t.length;n++)if(!t[n].isSelected(e.name))return!1;return!0})}function SR(e){e.registerComponentModel(sR),e.registerComponentView(dR),e.registerProcessor(e.PRIORITY.PROCESSOR.SERIES_FILTER,bR),e.registerSubTypeDefaulter(`legend`,function(){return`plain`}),yR(e)}R();var CR=function(e){O(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.setScrollDataIndex=function(e){this.option.scrollDataIndex=e},t.prototype.init=function(t,n,r){var i=Pv(t);e.prototype.init.call(this,t,n,r),wR(this,t,i)},t.prototype.mergeOption=function(t,n){e.prototype.mergeOption.call(this,t,n),wR(this,this.option,t)},t.type=`legend.scroll`,t.defaultOption=Qg(sR.defaultOption,{scrollDataIndex:0,pageButtonItemGap:5,pageButtonGap:null,pageButtonPosition:`end`,pageFormatter:`{current}/{total}`,pageIcons:{horizontal:[`M0,0L12,-10L12,10z`,`M0,0L-12,-10L-12,10z`],vertical:[`M0,0L20,0L10,-20z`,`M0,0L20,0L10,20z`]},pageIconColor:Z.color.accent50,pageIconInactiveColor:Z.color.accent10,pageIconSize:15,pageTextStyle:{color:Z.color.tertiary},animationDurationUpdate:800}),t}(sR);function wR(e,t,n){var r=e.getOrient(),i=[1,1];i[r.index]=0,Nv(t,n,{type:`box`,ignoreSize:!!i})}R();var TR=Ps,ER=[`width`,`height`],DR=[`x`,`y`],OR=function(e){O(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.newlineDisabled=!0,n._currentIndex=0,n}return t.prototype.init=function(){e.prototype.init.call(this),this.group.add(this._containerGroup=new TR),this._containerGroup.add(this.getContentGroup()),this.group.add(this._controllerGroup=new TR)},t.prototype.resetInner=function(){e.prototype.resetInner.call(this),this._controllerGroup.removeAll(),this._containerGroup.removeClipPath(),this._containerGroup.__rectSize=null},t.prototype.renderInner=function(t,n,r,i,a,o,s){var c=this;e.prototype.renderInner.call(this,t,n,r,i,a,o,s);var l=this._controllerGroup,u=n.get(`pageIconSize`,!0),d=W(u)?u:[u,u];p(`pagePrev`,0);var f=n.getModel(`pageTextStyle`);l.add(new hf({name:`pageText`,style:{text:`xx/xx`,fill:f.getTextColor(),font:f.getFont(),verticalAlign:`middle`,align:`center`},silent:!0})),p(`pageNext`,1);function p(e,t){var r=e+`DataIndex`,a=Zh(n.get(`pageIcons`,!0)[n.getOrient().name][t],{onclick:U(c._pageGo,c,r,n,i)},{x:-d[0]/2,y:-d[1]/2,width:d[0],height:d[1]});a.name=e,l.add(a)}},t.prototype.layoutInner=function(e,t,n,r,i,a){var o=this.getSelectorGroup(),s=e.getOrient().index,c=ER[s],l=DR[s],u=ER[1-s],d=DR[1-s];i&&wv(`horizontal`,o,e.get(`selectorItemGap`,!0));var f=e.get(`selectorButtonGap`,!0),p=o.getBoundingRect(),m=[-p.x,-p.y],h=Rt(n);i&&(h[c]=n[c]-p[c]-f);var g=this._layoutContentAndController(e,r,h,s,c,u,d,l);if(i){if(a===`end`)m[s]+=g[c]+f;else{var _=p[c]+f;m[s]-=_,g[l]-=_}g[c]+=p[c]+f,m[1-s]+=g[d]+g[u]/2-p[u]/2,g[u]=Math.max(g[u],p[u]),g[d]=Math.min(g[d],p[d]+m[1-s]),o.x=m[0],o.y=m[1],o.markRedraw()}return g},t.prototype._layoutContentAndController=function(e,t,n,r,i,a,o,s){var c=this.getContentGroup(),l=this._containerGroup,u=this._controllerGroup;wv(e.get(`orient`),c,e.get(`itemGap`),r?n.width:null,r?null:n.height),wv(`horizontal`,u,e.get(`pageButtonItemGap`,!0));var d=c.getBoundingRect(),f=u.getBoundingRect(),p=this._showController=d[i]>n[i],m=[-d.x,-d.y];t||(m[r]=c[s]);var h=[0,0],g=[-f.x,-f.y],_=q(e.get(`pageButtonGap`,!0),e.get(`itemGap`,!0));p&&(e.get(`pageButtonPosition`,!0)===`end`?g[r]+=n[i]-f[i]:h[r]+=f[i]+_),g[1-r]+=d[a]/2-f[a]/2,c.setPosition(m),l.setPosition(h),u.setPosition(g);var v={x:0,y:0};if(v[i]=p?n[i]:d[i],v[a]=Math.max(d[a],f[a]),v[o]=Math.min(0,f[o]+g[1-r]),l.__rectSize=n[i],p){var y={x:0,y:0};y[i]=Math.max(n[i]-f[i]-_,0),y[a]=v[a],l.setClipPath(new uf({shape:y})),l.__rectSize=y[i]}else u.eachChild(function(e){e.attr({invisible:!0,silent:!0})});var b=this._getPageInfo(e);return b.pageIndex!=null&&yh(c,{x:b.contentPosition[0],y:b.contentPosition[1]},p?e:null),this._updatePageInfoView(e,b),v},t.prototype._pageGo=function(e,t,n){var r=this._getPageInfo(t)[e];r!=null&&n.dispatchAction({type:`legendScroll`,scrollDataIndex:r,legendId:t.id})},t.prototype._updatePageInfoView=function(e,t){var n=this._controllerGroup;V([`pagePrev`,`pageNext`],function(r){var i=t[r+`DataIndex`]!=null,a=n.childOfName(r);a&&(a.setStyle(`fill`,i?e.get(`pageIconColor`,!0):e.get(`pageIconInactiveColor`,!0)),a.cursor=i?`pointer`:`default`)});var r=n.childOfName(`pageText`),i=e.get(`pageFormatter`),a=t.pageIndex,o=a==null?0:a+1,s=t.pageCount;r&&i&&r.setStyle(`text`,G(i)?i.replace(`{current}`,o==null?``:o+``).replace(`{total}`,s==null?``:s+``):i({current:o,total:s}))},t.prototype._getPageInfo=function(e){var t=e.get(`scrollDataIndex`,!0),n=this.getContentGroup(),r=this._containerGroup.__rectSize,i=e.getOrient().index,a=ER[i],o=DR[i],s=this._findTargetItemIndex(t),c=n.children(),l=c[s],u=c.length,d=+!!u,f={contentPosition:[n.x,n.y],pageCount:d,pageIndex:d-1,pagePrevDataIndex:null,pageNextDataIndex:null};if(!l)return f;var p=v(l);f.contentPosition[i]=-p.s;for(var m=s+1,h=p,g=p,_=null;m<=u;++m)_=v(c[m]),(!_&&g.e>h.s+r||_&&!y(_,h.s))&&(h=g.i>h.i?g:_,h&&(f.pageNextDataIndex??=h.i,++f.pageCount)),g=_;for(var m=s-1,h=p,g=p,_=null;m>=-1;--m)_=v(c[m]),(!_||!y(g,_.s))&&h.i<g.i&&(g=h,f.pagePrevDataIndex??=h.i,++f.pageCount,++f.pageIndex),h=_;return f;function v(e){if(e){var t=e.getBoundingRect(),n=t[o]+e[o];return{s:n,e:n+t[a],i:e.__legendDataIndex}}}function y(e,t){return e.e>=t&&e.s<=t+r}},t.prototype._findTargetItemIndex=function(e){if(!this._showController)return 0;var t,n=this.getContentGroup(),r;return n.eachChild(function(n,i){var a=n.__legendDataIndex;r==null&&a!=null&&(r=i),a===e&&(t=i)}),t??r},t.type=`legend.scroll`,t}(dR);function kR(e){e.registerAction(`legendScroll`,`legendscroll`,function(e,t){var n=e.scrollDataIndex;n!=null&&t.eachComponent({mainType:`legend`,subType:`scroll`,query:e},function(e){e.setScrollDataIndex(n)})})}function AR(e){uk(SR),e.registerComponentModel(CR),e.registerComponentView(OR),kR(e)}function jR(e){uk(SR),uk(AR)}R();var MR=function(e){O(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=Qg(gL.defaultOption,{disabled:!1,zoomLock:!1,zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!1,preventDefaultMouseMove:!0}),t}(gL),NR=gl();function PR(e,t,n){NR(e).coordSysRecordMap.each(function(e){var r=e.dataZoomInfoMap.get(t.uid);r&&(r.getRange=n)})}function FR(e,t){for(var n=NR(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||IR(n,o))}}}function IR(e,t){if(t){e.removeKey(t.model.uid);var n=t.controller;n&&n.dispose()}}function LR(e,t){var n={model:t,containsPoint:$t(zR,t),dispatchAction:$t(RR,e),dataZoomInfoMap:null,controller:null},r=n.controller=new sF(e.getZr());return V([`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 RR(e,t){e.isDisposed()||e.dispatchAction({type:`dataZoom`,animation:{easing:`cubicOut`,duration:100},batch:t})}function zR(e,t,n,r){return e.coordinateSystem.containPoint([n,r])}function BR(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=q(t.get(`cursorGrab`,!0),s),c=q(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 VR(e){e.registerUpdateLifecycle(`coordsys:aftercreate`,function(e,t){var n=NR(t),r=n.coordSysRecordMap||=J();r.each(function(e){e.dataZoomInfoMap=null}),e.eachComponent({mainType:`dataZoom`,subType:`inside`},function(e){V(uL(e).infoList,function(n){var i=n.model.uid,a=r.get(i)||r.set(i,LR(t,n.model));(a.dataZoomInfoMap||=J()).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){IR(r,e);return}var s=BR(a,e,t);n.enable(s.controlType,s.opt),aS(e,`dispatchAction`,i.model.get(`throttle`,!0),`fixRate`)})})}R();var HR=function(e){O(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(),PR(r,t,{pan:U(UR.pan,this),zoom:U(UR.zoom,this),scrollMove:U(UR.scrollMove,this)})},t.prototype.dispose=function(){this._clear(),e.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){FR(this.api,this.dataZoomModel),this.range=null},t.type=`dataZoom.inside`,t}(vL),UR={zoom:function(e,t,n,r){var i=this.range,a=i.slice(),o=e.axisModels[0];if(o){var s=GR[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(_F(0,a,[0,100],0,u.minSpan,u.maxSpan),this.range=a,i[0]!==a[0]||i[1]!==a[1])return a}},pan:WR(function(e,t,n,r,i,a){var o=GR[r]([a.oldX,a.oldY],[a.newX,a.newY],t,i,n);return o.signal*(e[1]-e[0])*o.pixel/o.pixelLength}),scrollMove:WR(function(e,t,n,r,i,a){return GR[r]([0,0],[a.scrollDelta,a.scrollDelta],t,i,n).signal*(e[1]-e[0])*a.scrollDelta})};function WR(e){return function(t,n,r,i){var a=this.range,o=a.slice(),s=t.axisModels[0];if(s&&(_F(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 GR={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 KR(e){CL(e),e.registerComponentModel(MR),e.registerComponentView(HR),VR(e)}R();var qR=function(e){O(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=Qg(gL.defaultOption,{show:!0,right:`ph`,top:`ph`,width:`ph`,height:`ph`,left:null,bottom:null,borderColor:Z.color.accent10,borderRadius:0,backgroundColor:Z.color.transparent,dataBackground:{lineStyle:{color:Z.color.accent30,width:.5},areaStyle:{color:Z.color.accent20,opacity:.2}},selectedDataBackground:{lineStyle:{color:Z.color.accent40,width:.5},areaStyle:{color:Z.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:Z.color.neutral00,borderColor:Z.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:Z.color.accent40,opacity:.5},showDetail:!0,showDataShadow:`auto`,realtime:!0,zoomLock:!1,textStyle:{color:Z.color.tertiary},brushSelect:!0,brushStyle:{color:Z.color.accent30,opacity:.3},emphasis:{handleLabel:{show:!0},handleStyle:{borderColor:Z.color.accent40},moveHandleStyle:{opacity:.8}},defaultLocationEdgeGap:15}),t}(gL);R();var JR=uf,YR=1,XR=30,ZR=7,QR=`horizontal`,$R=`vertical`,ez=5,tz=[`line`,`bar`,`candlestick`,`scatter`],nz={easing:`cubicOut`,duration:100,delay:0},rz=function(e){O(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=U(this._onBrush,this),this._onBrushEnd=U(this._onBrushEnd,this)},t.prototype.render=function(t,n,r,i){if(e.prototype.render.apply(this,arguments),aS(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(){oS(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 Ps;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`)?ZR:0,r=Av(e,t).refContainer,i=this._findCoordRect(),a=e.get(`defaultLocationEdgeGap`,!0)||0,o=this._orient===QR?{right:r.width-i.x-i.width,top:r.height-XR-a-n,width:i.width,height:XR}:{right:a,top:i.y,width:XR,height:i.height},s=Pv(e.option);V([`right`,`top`,`width`,`height`],function(e){s[e]===`ph`&&(s[e]=o[e])});var c=Ov(s,r);this._location={x:c.x,y:c.y},this._size=[c.width,c.height],this._orient===$R&&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===QR&&!i?{scaleY:o?1:-1,scaleX:1}:n===QR&&i?{scaleY:o?1:-1,scaleX:-1}:n===$R&&!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 JR({silent:!0,shape:{x:0,y:0,width:t[0],height:t[1]},style:{fill:e.get(`backgroundColor`)},z2:-40}));var i=new JR({shape:{x:0,y:0,width:t[0],height:t[1]},style:{fill:`transparent`},z2:0,onclick:U(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:uc(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 Ps,r=new Um({shape:{points:s},segmentIgnoreThreshold:1,style:t.getModel(`areaStyle`).getAreaStyle(),silent:!0,z2:-20}),i=new Gm({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){V(e.getAxisProxy(i,a).getTargetSeriesModels(),function(e){if(!n&&!(t!==!0&&Wt(tz,e.get(`type`))<0)){var o=r.getComponent(cL(i),a).axis,s=az(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 JR({silent:l,style:{fill:o.get(`fillerColor`)},textConfig:{position:`inside`}});i.add(u),i.add(new JR({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:YR,fill:Z.color.transparent}})),V([0,1],function(t){var a=o.get(`handleIcon`);!dC[a]&&a.indexOf(`path://`)<0&&a.indexOf(`image://`)<0&&(a=`path://`+a);var s=mC(a,-1,0,2,2,null,!0);s.attr({cursor:oz(this._orient),draggable:!0,drift:U(this._onDragMove,this,t),ondragend:U(this._onDragEnd,this),onmouseover:U(this._onOverDataInfoTriggerArea,this,!0),onmouseout:U(this._onOverDataInfoTriggerArea,this,!1),z2:5});var c=s.getBoundingRect(),l=o.get(`handleSize`);this._handleHeight=dc(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(),Ip(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 hf({silent:!0,invisible:!f,style:Tg(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=dc(o.get(`moveHandleSize`),a[1]),p=t.moveHandle=new uf({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=mC(o.get(`moveHandleIcon`),-m/2,-m/2,m,m,Z.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 uf({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:U(this._onActualMoveZoneDrift,this),ondragstart:U(this._onActualMoveZoneDragStart,this),ondragend:U(this._onActualMoveZoneDragEnd,this),onmouseover:U(this._onOverDataInfoTriggerArea,this,!0),onmouseout:U(this._onOverDataInfoTriggerArea,this,!1)})},t.prototype._resetInterval=function(){var e=this._range=this.dataZoomModel.getPercentRange(),t=this._getViewExtent();this._handleEnds=[uc(e[0],[0,100],t,!0),uc(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];_F(t,r,i,n.get(`zoomLock`)?`all`:e,a.minSpan==null?null:uc(a.minSpan,o,i,!0),a.maxSpan==null?null:uc(a.maxSpan,o,i,!0));var s=this._range,c=this._range=_c([uc(r[0],i,o,!0),uc(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=_c(n.slice()),i=this._size;V([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 uf,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=mL(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=[iz(t,0,l,s),iz(t,1,l,s)]}}var p=_c(this._handleEnds.slice());m.call(this,0),m.call(this,1);function m(e){var t=Uh(n.handles[e].parent,this.group),o=Gh(e===0?`right`:`left`,t),s=this._handleWidth/2+ez,c=Wh([p[e]+(e===0?-s:s),this._size[1]/2],t);r[e].setStyle({x:c[0],y:c[1],verticalAlign:i===QR?`middle`:o,align:i===QR?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,kr(r.event);var i=this._displayables.sliderGroup.getLocalTransform(),a=Wh([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 Gr(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();_F(0,a,r,0,o.minSpan==null?null:uc(o.minSpan,i,r,!0),o.maxSpan==null?null:uc(o.maxSpan,i,r,!0)),this._range=_c([uc(a[0],r,i,!0),uc(a[1],r,i,!0)]),this._updateView(),this._dispatchZoomAction(!1)}}}},t.prototype._onBrush=function(e){this._brushing&&(kr(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 JR({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?nz:null,start:t[0],end:t[1]})},t.prototype._findCoordRect=function(){var e,t=uL(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}(vL);function iz(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)?``:pD(r)||dD(r)?r.getLabel({value:Math.round(o)}):isFinite(a)?hc(o,a,!0):o+``;return en(i)?i(o,s):G(i)?i.replace(`{value}`,s):s}function az(e){return{x:`y`,y:`x`,radius:`angle`,angle:`radius`}[e]}function oz(e){return e===`vertical`?`ns-resize`:`ew-resize`}function sz(e){e.registerComponentModel(qR),e.registerComponentView(rz),CL(e)}function cz(e){uk(KR),uk(sz)}R();function lz(e,t,n){var r=bt.createCanvas(),i=t.getWidth(),a=t.getHeight(),o=r.style;return o&&(o.position=`absolute`,o.left=`0`,o.top=`0`,o.width=i+`px`,o.height=a+`px`,r.setAttribute(`data-zr-dom-id`,e)),r.width=i*n,r.height=a*n,r}function uz(e){return!e.__cursors.get(0)}function dz(e){var t=e.__cursors.get(0);return{startIdx:t?t.startIdx:0,endIdx:t?t.endIdx:0}}var fz=function(e){O(t,e);function t(t,n,r){var i=e.call(this)||this;i.motionBlur=!1,i.lastFrameAlpha=.7,i.dpr=1,i.virtual=!1,i.config={},i.zlevel=0,i.zlevel2=0,i.maxRepaintRectCount=5,i.__dirty=!0,i.__firstTimePaint=!0,i.__prevIdx={startIdx:0,endIdx:0};var a;r||=Vo,typeof t==`string`?a=lz(t,n,r):K(t)&&(a=t,t=a.id),i.id=t,i.dom=a;var o=a.style;return o&&(En(a),a.onselectstart=function(){return!1},o.padding=`0`,o.margin=`0`,o.borderWidth=`0`),i.painter=n,i.dpr=r,i}return t.prototype.afterBrush=function(){this.__prevIdx=dz(this)},t.prototype.initContext=function(){this.ctx=this.dom.getContext(`2d`),this.ctx.dpr=this.dpr},t.prototype.setUnpainted=function(){this.__firstTimePaint=!0},t.prototype.createBackBuffer=function(){var e=this.dpr;this.domBack=lz(`back-`+this.id,this.painter,e),this.ctxBack=this.domBack.getContext(`2d`),e!==1&&this.ctxBack.scale(e,e)},t.prototype.createRepaintRects=function(e,t,n,r){if(this.__firstTimePaint)return this.__firstTimePaint=!1,null;var i=[],a=this.maxRepaintRectCount,o=!1,s=new X(0,0,0,0);function c(e){if(!(!e.isFinite()||e.isZero()))if(i.length===0){var t=new X(0,0,0,0);t.copy(e),i.push(t)}else{for(var n=!1,r=1/0,c=0,l=0;l<i.length;++l){var u=i[l];if(u.intersect(e)){var d=new X(0,0,0,0);d.copy(u),d.union(e),i[l]=d,n=!0;break}else if(o){s.copy(e),s.union(u);var f=e.width*e.height,p=u.width*u.height,m=s.width*s.height-f-p;m<r&&(r=m,c=l)}}if(o&&(i[c].union(e),n=!0),!n){var t=new X(0,0,0,0);t.copy(e),i.push(t)}o||=i.length>=a}}for(var l=dz(this),u=l.startIdx;u<l.endIdx;++u){var d=e[u];if(d){var f=d.shouldBePainted(n,r,!0,!0),p=d.__isRendered&&(d.__dirty&1||!f)?d.getPrevPaintRect():null;p&&c(p);var m=f&&(d.__dirty&1||!d.__isRendered)?d.getPaintRect():null;m&&c(m)}}for(var h=this.__prevIdx,u=h.startIdx;u<h.endIdx;++u){var d=t[u],f=d&&d.shouldBePainted(n,r,!0,!0);if(d&&(!f||!d.__zr)&&d.__isRendered){var p=d.getPrevPaintRect();p&&c(p)}}var g;do{g=!1;for(var u=0;u<i.length;){if(i[u].isZero()){i.splice(u,1);continue}for(var _=u+1;_<i.length;)i[u].intersect(i[_])?(g=!0,i[u].union(i[_]),i.splice(_,1)):_++;u++}}while(g);return this._paintRects=i,i},t.prototype.debugGetPaintRects=function(){return(this._paintRects||[]).slice()},t.prototype.resize=function(e,t){var n=this.dpr,r=this.dom,i=r.style,a=this.domBack;i&&(i.width=e+`px`,i.height=t+`px`),r.width=e*n,r.height=t*n,a&&(a.width=e*n,a.height=t*n,n!==1&&this.ctxBack.scale(n,n))},t.prototype.clear=function(e,t,n){var r=this.dom,i=this.ctx,a=r.width,o=r.height;t||=this.clearColor;var s=this.motionBlur&&!e,c=this.lastFrameAlpha,l=this.dpr,u=this;s&&(this.domBack||this.createBackBuffer(),this.ctxBack.globalCompositeOperation=`copy`,this.ctxBack.drawImage(r,0,0,a/l,o/l));var d=this.domBack;function f(e,n,r,a){if(i.clearRect(e,n,r,a),t&&t!==`transparent`){var o=void 0;sn(t)?(o=(t.global||t.__width===r&&t.__height===a)&&t.__canvasGradient||bC(i,t,{x:0,y:0,width:r,height:a}),t.__canvasGradient=o,t.__width=r,t.__height=a):cn(t)&&(t.scaleX=t.scaleX||l,t.scaleY=t.scaleY||l,o=MC(i,t,{dirty:function(){u.setUnpainted(),u.painter.refresh()}})),i.save(),i.fillStyle=o||t,i.fillRect(e,n,r,a),i.restore()}s&&(i.save(),i.globalAlpha=c,i.drawImage(d,e,n,r,a),i.restore())}!n||s?f(0,0,a,o):n.length&&V(n,function(e){f(e.x*l,e.y*l,e.width*l,e.height*l)})},t}(ir),pz=1e5,mz=314159,hz=void 0,gz=1,_z=2;function vz(e){return e?e.__builtin__?!0:!(typeof e.resize!=`function`||typeof e.refresh!=`function`):!1}function yz(e,t){var n=document.createElement(`div`);return n.style.cssText=[`position:relative`,`width:`+e+`px`,`height:`+t+`px`,`padding:0`,`margin:0`,`border-width:0`].join(`;`)+`;`,n}function bz(e,t,n,r){var i=new fz(e,t,t.dpr);return i.zlevel=n,i.zlevel2=r,i.__builtin__=!0,xz(i),i}function xz(e){e.__cursorStack=[],e.__cursors=J()}function Sz(e){return e.startIdx=e.drawIdx=e.endIdx=e.endIdxNew=0,e.used=!1,e.first=e.last=NaN,e.notClearIdx=-1,e}function Cz(e,t){var n=e.__cursors,r=+t;return n.get(r)||(e.__cursorStack.push(r),n.set(r,Sz({key:r})))}function wz(e,t){for(var n=e.__cursorStack,r=0;r<n.length;r++)t(e.__cursors.get(n[r]))}function Tz(e,t){var n=e.layers;return n[t]||(n[t]=[,,,])}function Ez(e,t,n){for(var r=e.layerStack,i=0;i<r.length;i++){var a=r[i].zl,o=r[i].zl2,s=e.layers[a][o];(!n||(!(n&Dz)||s.__builtin__)&&(!(n&Oz)||!s.__builtin__)&&(!(n&kz)||s!==e.hoverlayer))&&t(s,a,o,i)}}var Dz=1,Oz=2,kz=4,Az=Dz|kz,jz=function(){function e(e,t,n,r){this.type=`canvas`,this._prevDisplayList=[],this._layerConfig={},this._needsManuallyCompositing=!1,this.type=`canvas`,this._i={layerStack:[],layers:[]};var i=!e.nodeName||e.nodeName.toUpperCase()===`CANVAS`;if(this._opts=n=B({},n||{}),this.dpr=n.devicePixelRatio||Vo,this._singleCanvas=i,this.root=e,e.style&&(En(e),e.innerHTML=``),this.storage=t,this._prevDisplayList=[],i){var a=e,o=a.width,s=a.height;n.width!=null&&(o=n.width),n.height!=null&&(s=n.height),this.dpr=n.devicePixelRatio||1,a.width=o*this.dpr,a.height=s*this.dpr,this._width=o,this._height=s;var c=bz(a,this,mz,0);c.initContext(),this._insertLayer(c,mz,0,!0),this._domRoot=e}else{this._width=CC(e,0,n),this._height=CC(e,1,n);var l=this._domRoot=yz(this._width,this._height);e.appendChild(l)}}return e.prototype.getType=function(){return`canvas`},e.prototype.isSingleCanvas=function(){return this._singleCanvas},e.prototype.getViewportRoot=function(){return this._domRoot},e.prototype.getViewportRootOffset=function(){var e=this.getViewportRoot();if(e)return{offsetLeft:e.offsetLeft||0,offsetTop:e.offsetTop||0}},e.prototype.refresh=function(e){var t=e&&!K(e)?{paintAll:!!e}:e||{},n=q(t.refresh,!0),r=q(t.refreshHover,!1);if(r&&(this._hoverLayerDirty=_z),!n)return r&&this._paintHoverList(this.storage.getDisplayList(!1)),this;var i=this.storage.getDisplayList(!0);this._updateLayerStatus(i,t.paintAll),this._redrawId=Math.random();var a=this._prevDisplayList;this._paintList(i,a,this._redrawId);var o=this._backgroundColor;return Ez(this._i,function(e,t,n,r){e.refresh&&e.refresh(r===0?o:null)},Oz),this._opts.useDirtyRect&&(this._prevDisplayList=i.slice()),this},e.prototype._paintHoverList=function(e){var t=this._i.hoverlayer,n=this._hoverLayerDirty;if(this._hoverLayerDirty=hz,n!==hz&&(!t&&n===_z&&(t=this._i.hoverlayer=this._ensureLayer(pz)),t)){t.clear();for(var r={inHover:!0,viewWidth:this._width,viewHeight:this._height,beforeBrushParam:{}},i,a=0,o=e.length;a<o;a++){var s=e[a];if(s.__inHover){i||(i=t.ctx,i.save());var c=s.__hoverStyle,l=void 0;c&&(l=s.style,s.style=c),ZC(i,s,r),c&&(s.style=l)}}i&&(QC(i,r),i.restore())}},e.prototype.getHoverLayer=function(){return this._ensureLayer(pz)},e.prototype.paintOne=function(e,t){XC(e,t)},e.prototype._paintList=function(e,t,n){if(this._redrawId===n){var r=this._doPaintList(e,t);if(this._needsManuallyCompositing&&this._compositeManually(),r)Ez(this._i,function(e){e.afterBrush&&e.afterBrush()},Az),this._paintHoverList(e);else{var i=this;Ri(function(){i._paintList(e,t,n)})}}},e.prototype._compositeManually=function(){var e=this._ensureLayer(mz).ctx,t=this._domRoot.width,n=this._domRoot.height;e.clearRect(0,0,t,n),Ez(this._i,function(r){r.virtual&&e.drawImage(r.dom,0,0,t,n)},Dz)},e.prototype._doPaintList=function(e,t){var n=this,r=!0;return Ez(this._i,function(i){var a=!1;if(wz(i,function(e){(e.drawIdx<e.endIdx||e.notClearIdx>=0)&&(a=!0)}),!(!a&&!i.__dirty)){var o=n._opts.useDirtyRect&&!uz(i)?i.createRepaintRects(e,t,n._width,n._height):null,s=n._i.layerStack[0],c=!0;if(i.__dirty){c=!1,i.__dirty=!1;var l=i.zlevel===s.zl&&i.zlevel2===s.zl2?n._backgroundColor:null;i.clear(!1,l,o)}wz(i,function(t){var a=n._paintPerCursor(i,t,e,o,c);r&&=a})}},Az),ft.wxa&&Ez(this._i,function(e){e&&e.ctx&&e.ctx.draw&&e.ctx.draw()}),r},e.prototype._paintPerCursor=function(e,t,n,r,i){var a=e.ctx;if(r)if(!r.length)t.drawIdx=t.endIdx;else for(var o=this.dpr,s=0;s<r.length;++s){var c=r[s];a.save(),a.beginPath(),a.rect(c.x*o,c.y*o,c.width*o,c.height*o),a.clip(),this._paintPerCursorInRect(e,t,n,c,i),a.restore()}else a.save(),this._paintPerCursorInRect(e,t,n,null,i),a.restore();return t.drawIdx>=t.endIdx},e.prototype._paintPerCursorInRect=function(e,t,n,r,i){for(var a={inHover:!1,allClipped:!1,prevEl:null,viewWidth:this._width,viewHeight:this._height,beforeBrushParam:{contentRetained:i}},o=e.ctx,s=uz(e),c=s&&bt.getTime(),l=t.drawIdx,u=t.notClearIdx,d=u>=0?Math.min(u,l):l;d<t.endIdx;d++){var f=n[d];if(!(d<l&&!f.notClear)){if(f.__inHover&&(this._hoverLayerDirty=_z),r!=null){var p=f.getPaintRect();p&&p.intersect(r)&&(ZC(o,f,a),f.setPrevPaintRect(p))}else ZC(o,f,a);if(s&&bt.getTime()-c>15){d++;break}}}QC(o,a),t.drawIdx=Math.max(d,l)},e.prototype.getLayer=function(e,t){return this._ensureLayer(e,0,t)},e.prototype._ensureLayer=function(e,t,n){t||=0;var r=this._singleCanvas;r&&!this._needsManuallyCompositing&&(e=mz,t=0);var i=Tz(this._i,e)[t];return i||(i=bz(`zr_`+e+`.`+t,this,e,t),this._layerConfig[e]&&zt(i,this._layerConfig[e],!0),(n||r&&e!==mz)&&(i.virtual=!0),this._insertLayer(i,e,t,!1),i.initContext()),i},e.prototype.insertLayer=function(e,t){this._insertLayer(t,e,0,!1)},e.prototype._insertLayer=function(e,t,n,r){var i=this._i,a=i.layers,o=i.layerStack,s=this._domRoot,c=null;if(!(a[t]&&a[t][n])&&vz(e)){for(var l=o.length,u=0;u<l&&(o[u].zl<t||o[u].zl===t&&o[u].zl2<n);)u++;if(u>0&&(c=Tz(i,o[u-1].zl)[o[u-1].zl2]),o.splice(u,0,{zl:t,zl2:n}),Tz(i,t)[n]=e,!r&&!e.virtual)if(c){var d=c.dom;d.nextSibling?s.insertBefore(e.dom,d.nextSibling):s.appendChild(e.dom)}else s.firstChild?s.insertBefore(e.dom,s.firstChild):s.appendChild(e.dom);e.painter||=this}},e.prototype.eachLayer=function(e,t){return Ez(this._i,function(n,r){e.call(t,n,r)})},e.prototype.eachBuiltinLayer=function(e,t){return Ez(this._i,function(n,r){e.call(t,n,r)},Dz)},e.prototype.eachOtherLayer=function(e,t){return Ez(this._i,function(n,r){e.call(t,n,r)},Oz)},e.prototype.getLayers=function(){var e={};return Ez(this._i,function(t,n,r){e[t.id]=t}),e},e.prototype._updateLayerStatus=function(e,t){var n=this;if(n._singleCanvas)for(var r=1;r<e.length;r++){var i=e[r];if(i.zlevel!==e[r-1].zlevel||i.incremental){n._needsManuallyCompositing=!0;break}}Ez(n._i,function(e){e.__dirty=!1,wz(e,function(e){e.used=!1,e.endIdxNew=0,e.notClearIdx=-1})},Az);for(var a,o=null,s=null,c=!1,l=0,u=e.length;l<u;l++){var i=e[l],d=i.zlevel,f=i.incremental,p=void 0;if(a!==d&&(a=d,c=!1),f?(c=!0,p=1):p=c?2:0,(!o||d!==o.zlevel||p!==o.zlevel2)&&(o=n._ensureLayer(d,p),s=null,!o.__builtin__)){Lt(`ZLevel `+d+` has been used by unknown layer `+o.id);continue}if((!s||f!==s.key)&&(s=Cz(o,f),!s.used))if(s.used=!0,!t&&s.first===i.id){var m=l-s.startIdx;s.startIdx=l,s.drawIdx+=m,s.endIdx+=m}else o.__dirty=!0,s.first=i.id,s.startIdx=s.drawIdx=l,s.endIdx=l+1;s.endIdxNew=l+1,i.__dirty&1&&!i.__inHover&&((!f||!i.notClear&&l<s.drawIdx)&&(o.__dirty=!0),f&&i.notClear&&s.notClearIdx<0&&(s.notClearIdx=l))}Ez(n._i,function(t){for(var r=t.__cursorStack,i=t.__cursors,a=r.length-1;a>=0;a--){var o=i.get(r[a]);if(!o.used)t.__dirty=!0,i.removeKey(r[a]),r.splice(a,1);else{var s=o.endIdxNew;(uz(t)?s<o.drawIdx:s!==o.endIdx||!s||e[s-1].id!==o.last)&&(t.__dirty=!0),o.endIdx=o.endIdxNew,o.last=s?e[s-1].id:NaN}}t.__dirty&&(wz(t,function(e){e.drawIdx=e.startIdx}),n._hoverLayerDirty===hz&&(n._hoverLayerDirty=gz))},Az)},e.prototype.clear=function(){return Ez(this._i,function(e){e.clear(),xz(e)},Dz),this},e.prototype.setBackgroundColor=function(e){this._backgroundColor=e,Ez(this._i,function(e){e.setUnpainted()})},e.prototype.configLayer=function(e,t){if(t){var n=this._layerConfig;n[e]?zt(n[e],t,!0):n[e]=t,Ez(this._i,function(e,t){zt(e,n[t],!0)})}},e.prototype.delLayer=function(e){for(var t=this._i.layerStack,n=this._i.layers,r=t.length-1;r>=0;r--){var i=t[r];if(i.zl===e){var a=n[e][i.zl2];if(a.__builtin__)continue;if(t.splice(r,1),n[e][i.zl2]=void 0,!a.virtual){var o=a.dom.parentNode;o&&o.removeChild(a.dom)}}}},e.prototype.resize=function(e,t){if(this._domRoot.style){var n=this._domRoot;n.style.display=`none`;var r=this._opts,i=this.root;e!=null&&(r.width=e),t!=null&&(r.height=t),e=CC(i,0,r),t=CC(i,1,r),n.style.display=``,(this._width!==e||t!==this._height)&&(n.style.width=e+`px`,n.style.height=t+`px`,Ez(this._i,function(n){n.resize(e,t)}),this.refresh({paintAll:!0})),this._width=e,this._height=t}else{if(e==null||t==null)return;this._width=e,this._height=t,this._ensureLayer(mz).resize(e,t)}return this},e.prototype.clearLayer=function(e){V(this._i.layers[e],function(e){e&&!e.__builtin__&&e.clear()})},e.prototype.dispose=function(){this.root.innerHTML=``,this.root=this.storage=this._domRoot=this._i=null},e.prototype.getRenderedCanvas=function(e){if(e||={},this._singleCanvas&&!this._compositeManually)return this._i.layers[mz][0].dom;var t=new fz(`image`,this,e.pixelRatio||this.dpr);t.initContext(),t.clear(!1,e.backgroundColor||this._backgroundColor);var n=t.ctx;if(e.pixelRatio<=this.dpr){this.refresh();var r=t.dom.width,i=t.dom.height;Ez(this._i,function(e){e.__builtin__?n.drawImage(e.dom,0,0,r,i):e.renderToCanvas&&(n.save(),e.renderToCanvas(n),n.restore())})}else{for(var a={inHover:!1,viewWidth:this._width,viewHeight:this._height,beforeBrushParam:{}},o=this.storage.getDisplayList(!0),s=0,c=o.length;s<c;s++){var l=o[s];ZC(n,l,a)}QC(n,a)}return t.dom},e.prototype.getWidth=function(){return this._width},e.prototype.getHeight=function(){return this._height},e}();function Mz(e){e.registerPainter(`canvas`,jz)}function Nz(e){if(e==null||!Number.isFinite(e))return`—`;let t=Math.abs(e);return t>=1e9?Pz(e,1e9,`B`):t>=1e6?Pz(e,1e6,`M`):t>=1e3?Pz(e,1e3,`K`):Math.round(e).toLocaleString()}function Pz(e,t,n){let r=e/t,i=Math.abs(r)>=100?0:1;return`${r.toFixed(i)}${n}`}var Fz=`auto`,Iz={speed:1,live:{frameIntervalMs:33,snapshotHz:12},main:{presentationDurationMs:220,chartAppearDurationMs:0,chartUpdateDurationMs:200,easing:`linear`,easingUpdate:`linear`},tail:{enabled:!0,startPercent:.95,durationMs:Fz,durationScale:10,easing:`cubicOut`},daily:{chartAppearDurationMs:Fz,chartUpdateDurationMs:60,easing:Fz,easingUpdate:Fz},bars:{chartAppearDurationMs:Fz,chartUpdateDurationMs:20,easing:Fz,easingUpdate:Fz},donuts:{chartAppearDurationMs:Fz,chartUpdateDurationMs:Fz,easing:Fz,easingUpdate:`linear`,seriesAnimation:!1},heatmap:{popDurationMs:380,settleThreshold:.998,intensityRiseThreshold:.08,whiteThreshold:.88,nearMaxRatio:.985},videoExport:{width:1080,height:864,fps:60,frontloadSettledFrameCount:1,introFadeEnabled:!0,introFadeStartOpacity:.95,introContentStartOpacity:.05,introFadeDurationMs:400,introFadeDelayMs:0,introFadeEasing:`cubicOut`,startHoldDurationMs:100,replayDurationMs:1e4,tailDurationMs:5e3,replayEasing:`cubicInOut`,tailSourceFraction:.55,tailEasing:`cubicOut`,finalHoldDurationMs:5e3,finalFlashDurationMs:1e3,finalFlashDelayMs:200,finalFlashMaxOpacity:.35,displayTweenStartMs:200,displayTweenBaseMs:240,displayTweenLateMs:420,displayTweenLateWindowMs:2200,chartIntroWindowMs:2200,barsChartIntroUpdateDurationMs:320,barsChartUpdateDurationMs:50,barsChartTailUpdateDurationMs:240,donutsChartIntroUpdateDurationMs:360,donutsChartUpdateDurationMs:50,donutsChartTailUpdateDurationMs:240,supersampleScale:2,captureFormat:`png`,jpegQuality:92,crf:5,encoderPreset:`veryfast`}},Lz={animationDuration:750,animationDurationUpdate:220,animationEasing:`cubicOut`,animationEasingUpdate:`cubicOut`},Rz={show:!0,animationDuration:250,animationDurationUpdate:220,animationDelay:250,animationDelayUpdate:180,animationEasing:`cubicOut`,animationEasingUpdate:`cubicOut`},zz={...Lz,animationDurationUpdate:200,animationDelayUpdate:0,animationEasingUpdate:`cubicOut`},Bz={animationDuration:700,animationDurationUpdate:220,animationDelay:250,animationDelayUpdate:140,animationEasing:`cubicOut`,animationEasingUpdate:`cubicOut`},Vz={...Rz,animationDelay:950,animationDelayUpdate:360};function Hz(e){return Number.isFinite(e)&&e>0?e:1}function Uz(e){return Math.max(0,Math.round(e/Hz(Iz.speed)))}function Wz(e,t){return e===`auto`?Uz(t):e}function Gz(e,t){return e===`auto`?t:e}function Kz(e){return{animation:!0,animationDuration:Wz(e.chartAppearDurationMs,Iz.main.chartAppearDurationMs),animationDurationUpdate:Wz(e.chartUpdateDurationMs,Iz.main.chartUpdateDurationMs),animationEasing:Gz(e.easing,Iz.main.easing),animationEasingUpdate:Gz(e.easingUpdate,Iz.main.easingUpdate)}}var qz=Uz(Iz.main.presentationDurationMs);function Jz(e=0,t=!1){let n=qz,r=Iz.tail;if(!t||!r?.enabled)return n;let i=Math.min(Math.max(r.startPercent??.9,0),.999),a=Math.min(Math.max(e||0,0),1);if(a<=i)return n;let o=(a-i)/Math.max(1-i,.001),s=r.durationMs===`auto`?Math.round(n*Math.max(r.durationScale||1,1)):r.durationMs;return Math.round(n+(s-n)*tB(o))}function Yz(e=0,t=!1){let n=Iz.tail;if(!t||!n?.enabled)return`linear`;let r=Math.min(Math.max(n.startPercent??.9,0),.999);return Math.min(Math.max(e||0,0),1)<=r?`linear`:n.easing||`cubicOut`}function Xz(e=0,t=!1){let n=Iz.tail;if(!t||!n?.enabled)return!1;let r=Math.min(Math.max(n.startPercent??.9,0),.999);return Math.min(Math.max(e||0,0),1)>r}Kz({chartAppearDurationMs:Fz,chartUpdateDurationMs:Fz,easing:Fz,easingUpdate:Fz});var Zz=Kz(Iz.daily),Qz=Kz(Iz.bars),$z=Kz(Iz.donuts),eB=Iz.donuts.seriesAnimation;function tB(e){return 1-(1-Math.min(Math.max(e,0),1))**3}function nB(e){return(Array.isArray(e?.data)?e.data:Array.isArray(e)?e:[]).slice().sort((e,t)=>String(e?.date||``).localeCompare(String(t?.date||``)))}function rB(e,t=`model`){return t===`family`?e?.by_family||{}:t===`repo`?e?.by_repo||{}:e?.by_model||{}}function iB(e,t=`tokens`){return e?t===`elapsed_seconds`?e.elapsed_seconds||0:t===`cost`?e.cost||0:e.tokens||0:0}function aB(e,{split:t=`model`,metric:n=`tokens`,dates:r=null}={}){let i=nB(e);if(!i.length)return{dates:[],groups:[],series:[],dayTotals:[]};let a=r||i.map(e=>e.date),o=new Map(i.map(e=>[e.date,e])),s=[],c=new Set;for(let e of a){let r=rB(o.get(e),t);for(let[e,t]of Object.entries(r))c.has(e)||iB(t,n)<=0||(c.add(e),s.push(e))}let l=s.map(e=>({key:e,label:e,data:a.map(r=>iB(rB(o.get(r),t)[e],n))}));return{dates:a,groups:s,series:l,dayTotals:a.map((e,t)=>l.reduce((e,n)=>e+(n.data[t]||0),0))}}function oB(e,t,n){return e+(t-e)*n}function $(e){return Number.isFinite(e)?e:0}function sB(e,t){return Array.isArray(e?.data)?e.data:Array.isArray(e)?e:e?.data?.[t]||e?.data?.total||[]}function cB(e,t){return t?.length?e===`d7`?t.slice(-7):e===`d30`?t.slice(-30):t:[]}function lB(e,t,n){return e.map(e=>({key:e?.[t]||``,label:e?.[n]||``,tokens:$(e?.tokens)})).filter(e=>e.key)}function uB(e,t){let n=nB(e);if(!n.length)return{dates:[],series:[]};let r=cB(t,n.map(e=>e.date)),{series:i}=aB(e,{split:`model`,metric:`tokens`,dates:r});return{dates:r,series:i}}function dB(e,t){let n=nB(e);if(!n.length)return[];let r=new Set(cB(t,n.map(e=>e.date)));return n.filter(e=>r.has(e.date))}function fB(e,t){let n=dB(e,t);return{tokens:n.reduce((e,t)=>e+$(t?.tokens),0),elapsed:n.reduce((e,t)=>e+$(t?.elapsed_seconds),0),cost:n.reduce((e,t)=>e+$(t?.cost),0),days:n.length||1}}function pB(e,t,n){let r={};for(let[i,a]of Object.entries(e||{})){r[i]={};for(let e of n)r[i][e]=$(a?.[e])*t}return r}function mB(e,t){return t>=.999?e:{...e,tokens:$(e?.tokens)*t,elapsed_seconds:$(e?.elapsed_seconds)*t,cost:$(e?.cost)*t,sessions:$(e?.sessions)*t,by_model:pB(e?.by_model,t,[`tokens`,`cost`,`elapsed_seconds`]),by_family:pB(e?.by_family,t,[`tokens`,`cost`,`elapsed_seconds`,`sessions`]),by_repo:pB(e?.by_repo,t,[`tokens`,`cost`,`elapsed_seconds`,`sessions`])}}function hB(e,t){let n=nB(e);if(!n.length)return[];let r=n.length-1,i=Math.max(0,Math.min(r,Number.isFinite(t)?t:r)),a=Math.floor(i),o=Math.min(r,Math.ceil(i)),s=i-a;return n.slice(0,o+1).map((e,t)=>t<=a?e:mB(e,s))}function gB(e,t,n){let r=new Map;for(let i of e)for(let[e,a]of Object.entries(i?.[t]||{}))r.has(e)||r.set(e,{key:e,label:e,[n]:e,tokens:0}),r.get(e).tokens+=$(a?.tokens);return[...r.values()].sort((e,t)=>t.tokens-e.tokens)}function _B({daily:e,range:t,cursor:n,fallback:r}){let i=hB(e,n),a=t===`d7`?i.slice(-7):t===`d30`?i.slice(-30):i;if(!a.length)return r;let o={...r?.stats||{},tokens:a.reduce((e,t)=>e+$(t?.tokens),0),elapsed:a.reduce((e,t)=>e+$(t?.elapsed_seconds),0),cost:a.reduce((e,t)=>e+$(t?.cost),0),sessions:a.reduce((e,t)=>e+$(t?.sessions),0),days:a.length||1};return{...r||{},ready:!0,stats:o,topRepos:gB(a,`by_repo`,`repo_label`).slice(0,6),topFamilies:gB(a,`by_family`,`family`),topModels:gB(a,`by_model`,`model_name`).slice(0,6)}}function vB(e){let t=e?.data&&typeof e.data==`object`?e.data:{},n={};for(let[e,r]of Object.entries(t))n[e]={tokens:$(r?.tokens),elapsed:$(r?.elapsed),cost:$(r?.cost)};return n}function yB({overview:e,heatmap:t,daily:n,families:r,repos:i,models:a,range:o}){let s=e?.data;if(!s)return{ready:!0,stats:{tokens:0,elapsed:0,cost:0,sessions:0,enriched:0,priced:0,exactPriced:0,fallbackPriced:0,unpriced:0,days:1},topRepos:[],topFamilies:[],topModels:[],daily:{dates:[],series:[]},heatmap:{}};let c=s?.[o]||s?.total||{},l=c.coverage||{},u=$(l.thread_rows??l.total),d=$(l.root_sessions??c.total_sessions),f=$(l.priced),p=$(l.priced_exact),m=$(l.priced_fallback),h=$(l.unpriced??Math.max(u-f,0)),g=c.date_range,_=g?.from!=null&&g?.to!=null?Math.max(1,Math.ceil((g.to-g.from)/86400)):1,v=fB(n,o),y=o===`d7`||o===`d30`;return{ready:!0,stats:{tokens:y?v.tokens:$(c.total_tokens),elapsed:y?v.elapsed:$(c.total_elapsed_seconds),cost:y?v.cost:$(c.total_cost),sessions:d,enriched:$(l.enriched),priced:f,exactPriced:p,fallbackPriced:m,unpriced:h,days:y?v.days:_},topRepos:lB(sB(i,o).slice(0,6),`repo_label`,`repo_label`),topFamilies:lB(sB(r,o),`family`,`family`),topModels:lB(sB(a,o).slice(0,6),`model_name`,`model_name`),daily:uB(n,o),heatmap:vB(t)}}function bB(e,t,n){let r=new Map((e||[]).map(e=>[e.key,e])),i=new Map((t||[]).map(e=>[e.key,e])),a=[],o=new Set;for(let e of t||[])o.has(e.key)||(o.add(e.key),a.push(e.key));for(let t of e||[])o.has(t.key)||(o.add(t.key),a.push(t.key));let s=[];for(let e of a){let t=r.get(e),a=i.get(e),o=a?.label||t?.label||e,c=oB($(t?.tokens),$(a?.tokens),n);c<=.001&&!a||s.push({key:e,label:o,tokens:c})}return s}function xB(e,t,n){let r=(t?.dates?.length?t.dates:e?.dates||[]).slice(),i=new Map((e?.series||[]).map(e=>[e.key,e])),a=new Map((t?.series||[]).map(e=>[e.key,e])),o=new Set([...i.keys(),...a.keys()]),s=[];for(let c of o){let o=i.get(c),l=a.get(c),u=new Map((o?.data||[]).map((t,n)=>[e?.dates?.[n],t])),d=new Map((l?.data||[]).map((e,n)=>[t?.dates?.[n],e])),f=r.map(e=>oB($(u.get(e)),$(d.get(e)),n));f.every(e=>e<=.001)&&!l||s.push({key:c,label:l?.label||o?.label||c,data:f})}return{dates:r,series:s}}function SB(e){return{dates:e.dates,series:(e.series||[]).map(e=>({key:e.key,label:e.label,data:e.data.map(()=>0)}))}}function CB(e,t,n){let r=new Set([...Object.keys(e||{}),...Object.keys(t||{})]),i={};for(let a of r){let r=e?.[a],o=t?.[a];i[a]={tokens:oB($(r?.tokens),$(o?.tokens),n),elapsed:oB($(r?.elapsed),$(o?.elapsed),n),cost:oB($(r?.cost),$(o?.cost),n)}}return i}function wB(e,t,n){return{ready:t.ready,stats:{tokens:oB($(e?.stats?.tokens),$(t?.stats?.tokens),n),elapsed:oB($(e?.stats?.elapsed),$(t?.stats?.elapsed),n),cost:oB($(e?.stats?.cost),$(t?.stats?.cost),n),sessions:oB($(e?.stats?.sessions),$(t?.stats?.sessions),n),enriched:oB($(e?.stats?.enriched),$(t?.stats?.enriched),n),priced:oB($(e?.stats?.priced),$(t?.stats?.priced),n),exactPriced:oB($(e?.stats?.exactPriced),$(t?.stats?.exactPriced),n),fallbackPriced:oB($(e?.stats?.fallbackPriced),$(t?.stats?.fallbackPriced),n),unpriced:oB($(e?.stats?.unpriced),$(t?.stats?.unpriced),n),days:$(t?.stats?.days)||1},topRepos:bB(e?.topRepos,t?.topRepos,n),topFamilies:bB(e?.topFamilies,t?.topFamilies,n),topModels:bB(e?.topModels,t?.topModels,n),daily:xB(e?.daily,t?.daily,n),heatmap:CB(e?.heatmap,t?.heatmap,n)}}function TB(e,{duration:t=qz,onSettledChange:n,ingestProgress:r=0,isIngestActive:i=!1,clockNowMs:a=null}={}){let o=(0,b.useMemo)(()=>yB(e),[e.overview,e.heatmap,e.daily,e.families,e.repos,e.models,e.range]),[s,c]=(0,b.useState)(o),l=(0,b.useRef)(o),u=(0,b.useRef)(o),d=(0,b.useRef)(0),f=(0,b.useRef)(0),p=(0,b.useRef)(s),m=(0,b.useRef)(!0),h=(0,b.useRef)(n),g=(0,b.useRef)(0),_=(0,b.useRef)(o),v=(0,b.useRef)(o),y=(0,b.useRef)(`smooth`);(0,b.useEffect)(()=>{h.current=n},[n]);let x=e=>{m.current!==e&&(m.current=e,h.current?.(e))};(0,b.useEffect)(()=>{p.current=s},[s]);let S=e=>{l.current=e,u.current=e,p.current=e,c(e),x(!0),f.current=0,g.current=0,_.current=e,v.current=e},C=e=>{u.current=e,x(!1);let t=Xz(r,i)?`tail`:`smooth`;y.current!==t&&(y.current=t,g.current=0),t===`tail`&&(_.current=l.current,v.current=e,g.current=0)},w=(e,n)=>{e<f.current&&(f.current=0,g.current=0,_.current=l.current,v.current=n),f.current||=e;let a=Math.max(1,e-f.current);f.current=e;let o=Jz(r,i)||t,s=l.current,u=Xz(r,i)?`tail`:`smooth`;y.current!==u&&(y.current=u,g.current=0);let d,m;if(u===`tail`){v.current!==n&&(_.current=s,v.current=n,g.current=e),g.current||=e;let t=Math.max(0,e-g.current),a=Math.min(1,t/Math.max(o,1)),c=EB(a,Yz(r,i));d=wB(_.current,v.current,c),m=a>=1||DB(d,n)<=.002}else{let e=EB(1-Math.exp(-a/Math.max(o,1)),Yz(r,i));d=wB(s,n,e),m=e>=.999||DB(d,n)<=.002}return l.current=d,m?(l.current=n,p.current=n,c(n),x(!0),g.current=0,_.current=n,v.current=n,n):(p.current=d,c(d),d)};return(0,b.useLayoutEffect)(()=>{if(a!=null){if(t<=0){S(o);return}C(o),w(a,o)}},[o,t,r,i,a]),(0,b.useEffect)(()=>{if(a!=null)return;if(u.current=o,t<=0){S(o);return}if(C(o),d.current)return;let e=t=>{if(w(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,b.useEffect)(()=>()=>{d.current&&cancelAnimationFrame(d.current),d.current=0,f.current=0},[]),s}function EB(e,t){let n=Math.min(Math.max(e,0),1);return t===`cubicOut`?1-(1-n)**3:n}function DB(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=OB(e.topRepos,t.topRepos),i=OB(e.topFamilies,t.topFamilies),a=OB(e.topModels,t.topModels),o=kB(e.daily,t.daily);return Math.max(n,r,i,a,o)/Math.max(1,t.stats?.tokens||1)}function OB(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 kB(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}function AB(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||0);n+=1)r=Math.max(r,Math.abs((t?.data?.[n]||0)-(e.data[n]||0)))}return r}function jB(e){let t=0;for(let n of e?.series||[])for(let e of n.data||[])t=Math.max(t,Math.abs(e||0));return t}function MB(e,t,n=``){let[r,i]=(0,b.useState)(e),a=(0,b.useRef)(e),o=(0,b.useRef)(e),s=(0,b.useRef)(0),c=(0,b.useRef)(0),l=(0,b.useRef)(n),u=(0,b.useRef)(t),d=t&&l.current!==n;return(0,b.useLayoutEffect)(()=>{o.current=e;let r=!u.current&&t;if(u.current=t,!t){s.current&&cancelAnimationFrame(s.current),s.current=0,c.current=0,a.current=e,l.current=n;return}if(l.current!==n){s.current&&cancelAnimationFrame(s.current),s.current=0,c.current=0;let t=SB(e);a.current=t,i(t),l.current=n;return}r&&(a.current=e,i(e))},[e,t,n]),(0,b.useEffect)(()=>{if(o.current=e,!t)return;let n=qz,r=e=>{let t=o.current;c.current||=e;let l=Math.max(1,e-c.current);c.current=e;let u=1-Math.exp(-l/Math.max(n,1)),d=xB(a.current,t,u);a.current=d,i(d);let f=Math.max(1,jB(t));if(AB(d,t)<=f*.002||u>=.999){a.current=t,i(t),s.current=0,c.current=0;return}s.current=requestAnimationFrame(r)};s.current||=(c.current=0,requestAnimationFrame(r))},[e,t,n]),(0,b.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current),s.current=0,c.current=0},[]),t?d?SB(e):r:e}function NB(e,t){if(!e||!t)return null;let n=Date.parse(`${e}T00:00:00Z`),r=Date.parse(`${t}T00:00:00Z`);return!Number.isFinite(n)||!Number.isFinite(r)?null:Math.round((r-n)/864e5)}function PB(){if(typeof window>`u`)return!1;try{return new URLSearchParams(window.location.search).has(`debugLive`)||window.localStorage?.getItem(`codexmeter.debugLive`)===`1`||window.__CODEXMETER_DEBUG_LIVE__===!0}catch{return!1}}function FB(e,t=null){let n=(Array.isArray(e?.dates)&&Array.isArray(e?.series)?e.dates.map((t,n)=>({date:t,tokens:e.series.reduce((e,t)=>e+(t?.data?.[n]||0),0)})):Array.isArray(e?.data)?e.data:Array.isArray(e)?e:Object.entries(e||{}).map(([e,t])=>({date:e,...t}))).filter(e=>e?.date).sort((e,t)=>String(e.date).localeCompare(String(t.date))),r=n.filter(e=>(e.tokens||0)>0||(e.sessions||0)>0),i=n[0]?.date||null,a=n[n.length-1]?.date||null,o=r[r.length-1]?.date||null;return{days:n.length,nonzeroDays:r.length,first:i,last:a,lastNonzero:o,currentDateBucket:t,overreachDays:t&&o?Math.max(0,NB(t,o)||0):0,totalTokens:Math.round(n.reduce((e,t)=>e+(t.tokens||0),0))}}function IB(e,t=null){let n=Object.entries(e||{}).map(([e,t])=>({date:e,tokens:t?.tokens||0,sessions:t?.sessions||0,elapsed:t?.elapsed||0,cost:t?.cost||0})).filter(e=>e.date).sort((e,t)=>String(e.date).localeCompare(String(t.date))),r=n.filter(e=>e.tokens>0||e.sessions>0||e.elapsed>0||e.cost>0),i=n[0]?.date||null,a=n[n.length-1]?.date||null,o=r[r.length-1]?.date||null;return{days:n.length,nonzeroDays:r.length,first:i,last:a,lastNonzero:o,currentDateBucket:t,overreachDays:t&&o?Math.max(0,NB(t,o)||0):0,totalTokens:Math.round(n.reduce((e,t)=>e+t.tokens,0))}}function LB(e){return{seq:e?.seq,phase:e?.progress?.phase,percent:Number(((e?.progress?.percent||0)*100).toFixed(1)),enriched:e?.progress?.enriched,needs:e?.progress?.needs_enrichment,complete:!!e?.progress?.complete,daily:FB(e?.data?.daily||{},e?.progress?.current_date_bucket||null)}}function RB(e,t=null){return{seq:e?.seq,ingestId:e?.ingest_id,daily:FB(e?.daily||{},t?.current_date_bucket||null)}}function zB(e,t){PB()&&console.debug(`[codexmeter:live] ${e}`,t)}uk([FN,iP,zI,nR,aR,jR,Mz]);function BB(e){return Nz(e)}function VB(e){return e==null?`—`:e>=1e3?`$`+(e/1e3).toFixed(1)+`K`:`$`+e.toFixed(2)}function HB(e){return e?(e/3600).toFixed(1)+`h`:`0h`}function UB(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(`
|
|
28
|
-
`)}function WB(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 GB(e){let{dates:t,series:n}=aB(e,{split:`model`,metric:`tokens`});return{dates:t,series:n}}function KB(e){return Math.max(0,Math.min(1,e))}function qB(e,t,n=0){if(!e?.length)return 0;if(!t)return e.length-1;let r=JB(e,t),i=e.length-1,a=KB(((n||0)-.08)/.92)**.82,o=r+(i-r)*a;return Math.max(r,Math.min(i,Math.floor(o+32)))}function JB(e,t){return e?.length?t?Math.min(e.length-1,6):e.length-1:0}function YB(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 XB(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 ZB(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 QB(e,t){return!e||!t?e||{}:Object.fromEntries(Object.entries(e).filter(([e])=>String(e)<=String(t)))}function $B(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 eV(e,{ingestProgress:t=0,isIngestActive:n=!1}={}){let r=(0,b.useRef)({dates:[],series:[]}),i=(0,b.useMemo)(()=>n?(r.current=$B(r.current,e),r.current):(r.current=e||{dates:[],series:[]},r.current),[e,n]),a=(0,b.useMemo)(()=>qB(i?.dates||[],n,t),[i?.dates,t,n]),[o,s]=(0,b.useState)(()=>JB(i?.dates||[],n)),c=YB(a,o,i?.dates?.length||0,n),l=!!(n&&(i?.dates?.length||0)>0&&o>=i.dates.length-1-.01),[u,d]=(0,b.useState)(0),f=(0,b.useRef)(o),p=(0,b.useRef)(0),m=(0,b.useRef)(i?.dates||[]),h=(0,b.useRef)(0),g=(0,b.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,b.useLayoutEffect)(()=>{let e=i?.dates||[],t=m.current||[];if(t===e||(m.current=e,!n))return;let r=ZB(t,e,f.current);Math.abs(r-f.current)<.001||(f.current=r,s(r))},[i?.dates,n]),(0,b.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=YB(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,b.useEffect)(()=>()=>{cancelAnimationFrame(h.current),h.current=0},[]),{daily:(0,b.useMemo)(()=>XB(i,o),[i,o]),cursor:o,rawTargetIndex:a,sourceDaily:i,speedDaysPerSecond:u,targetIndex:c,waitingForDailyData:l}}function tV(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 nV(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 rV(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 iV(e,t){return e.map(e=>({...e,tokens:Math.max(0,(e.tokens||0)*t)}))}function aV(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 oV(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 sV({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;if(!l?.dates?.length)return(0,z.jsxs)(`div`,{className:`overview-daily-spark overview-daily-spark-empty`,children:[(0,z.jsx)(`span`,{className:`overview-daily-spark-title`,children:`Daily Usage`}),(0,z.jsx)(`span`,{className:`overview-daily-spark-empty-text`,children:`No daily data`})]});let u=n||{daily:l,cursor:l.dates.length-1,rawTargetIndex:l.dates.length-1,sourceDaily:l,targetIndex:l.dates.length-1},d=u.daily,f=!o&&!s&&i,p=(0,b.useMemo)(()=>tV(r,d.dates.length,u.cursor,f),[r,d.dates.length,u.cursor,f]),[m,h]=(0,b.useState)(()=>tV(r,d.dates.length)),g=(0,b.useRef)(p),_=(0,b.useRef)(f),v=(0,b.useRef)(m),y=(0,b.useRef)(0),x=MB(d,f,`overview-daily-spark`),S=f?p:_.current?g.current:m;v.current=S,(0,b.useEffect)(()=>{if(f){g.current=p,_.current=!0;return}let e=tV(r,d.dates.length);return _.current&&=(v.current=g.current,h(g.current),!1),nV(v.current,e,h,y,220)},[f,p,r,d.dates.length]),(0,b.useEffect)(()=>()=>{cancelAnimationFrame(y.current),y.current=0},[]);let{startValue:C,endValue:w}=S,T=Math.max(1,w-C+1||d.dates.length),{barWidth:E,barMaxWidth:D}=WB(T),O=f,k=Math.max(-.5,C-.5),A=Math.max(k+1,w+.5),j=e=>d.dates[Math.max(0,Math.min(d.dates.length-1,Math.round(e)))],ee=(0,b.useRef)(``);(0,b.useEffect)(()=>{let e=FB(l,a),t=FB(d,a),n=Math.round(C),r=Math.round(w),i=[a,u.targetIndex,e.days,e.lastNonzero,e.overreachDays,t.days,t.lastNonzero,t.overreachDays,n,r].join(`|`);i!==ee.current&&(ee.current=i,zB(`dailySpark.present`,{currentDateBucket:a,cursor:Number(u.cursor.toFixed(2)),targetIndex:u.targetIndex,rawTargetIndex:u.rawTargetIndex,lagDays:Number((u.targetIndex-u.cursor).toFixed(2)),source:e,presentationSource:FB(u.sourceDaily,a),display:t,zoom:{startValue:Number(C.toFixed(2)),endValue:Number(w.toFixed(2)),visibleDateCount:Number(T.toFixed(2))}}))},[a,u.cursor,u.targetIndex,l,d,C,w,T]);let M={backgroundColor:`transparent`,...Zz,tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{if(!e?.length)return``;let t=`<b>${j(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}: ${BB(r)}<br/>`,n+=r}return t+=`<b>Total: ${BB(n)}</b>`,t}},grid:{left:4,right:4,top:4,bottom:4},xAxis:O?{type:`value`,min:k,max:A,show:!1}:{type:`category`,data:x.dates||d.dates,min:Math.max(0,Math.floor(C)),max:Math.max(0,Math.floor(w)),show:!1},yAxis:{type:`value`,show:!1,scale:!1,min:0},series:x.series.map(e=>({id:`overview-daily-${e.key}`,name:e.label,type:`bar`,stack:`total`,data:O?e.data.map((e,t)=>[t,e]):e.data,itemStyle:{color:Ue(e.key)},...E?{barWidth:E}:{},barMaxWidth:D}))},N=c&&!o&&!s?{click:e=>{let t=Array.isArray(e?.data)?e.data[0]:e?.dataIndex,n=Number.isFinite(t)?j(t):e?.axisValue||e?.name;n&&c(n)}}:void 0;return(0,z.jsxs)(`div`,{className:`overview-daily-spark`,children:[(0,z.jsx)(`span`,{className:`overview-daily-spark-title`,children:`Daily Usage`}),(0,z.jsx)(`div`,{className:`overview-daily-spark-chart`,style:N?{cursor:`pointer`}:void 0,children:(0,z.jsx)(Ae,{echarts:VA,option:M,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!1,notMerge:o,replaceMerge:[`series`],onEvents:N})})]})}var cV=[{key:`tokens`,label:`Tokens`,fmt:BB},{key:`elapsed`,label:`Time`,fmt:e=>HB(e)},{key:`cost`,label:`Cost`,fmt:VB}],lV=Iz.heatmap?.popDurationMs??380,uV=Iz.heatmap?.settleThreshold??.998;function dV({heatmapData:e,isIngestActive:t=!1,ingestProgress:n=0,currentDateBucket:r=null,onDayClick:i,interactive:a=!0}){let[o,s]=(0,b.useState)(`tokens`),[c,l]=(0,b.useState)(new Set),[u,d]=(0,b.useState)(new Set),f=(0,b.useRef)({}),p=(0,b.useRef)(1),m=(0,b.useRef)(``),h=e||{};(0,b.useEffect)(()=>{let e=IB(h,r),t=[e.currentDateBucket,e.nonzeroDays,e.lastNonzero,e.overreachDays,e.totalTokens].join(`|`);t!==m.current&&(m.current=t,zB(`heatmap.present`,e))},[h,r]);let g=new Date,_=[],v=[];for(let e=364;e>=0;e--){let t=new Date(g);t.setDate(t.getDate()-e);let n=t.toLocaleDateString(`en-CA`),r=h[n]&&h[n][o]||0;_.push({key:n,val:r,date:t}),t.getDate()===1&&v.push({idx:364-e,label:t.toLocaleDateString(`en-US`,{month:`short`})})}let y=Math.max(..._.map(e=>e.val),1);(0,b.useEffect)(()=>{if(!t||n>=uV){f.current={},p.current=1;return}let e=new Date,r=f.current,i=p.current,a=new Set,s=new Set,c=Math.max(.05,Math.min(i,y)*.002),u=Iz.heatmap?.intensityRiseThreshold??.08,m=Iz.heatmap?.whiteThreshold??.88,g=Iz.heatmap?.nearMaxRatio??.985;for(let t=364;t>=0;t--){let n=new Date(e);n.setDate(n.getDate()-t);let l=n.toLocaleDateString(`en-CA`),d=h[l]&&h[l][o]||0,f=r[l]??0,p=i>0?f/i:0,_=y>0?d/y:0,v=y>i+c&&d>=y*g&&(f<y*g||f===void 0),b=_>=m&&p<m,x=d>f+c,S=_>p+u;v||b||x||S?a.add(l):(d<f-c||d>0&&i>0&&y>i+c&&p>=.85&&_<p-.02)&&s.add(l),r[l]=d}if(p.current=y,a.size>0||s.size>0){l(a),d(s);let e=setTimeout(()=>{l(new Set),d(new Set)},lV);return()=>clearTimeout(e)}},[h,o,t,n,y]);function x(e){if(e===0)return`var(--bg-elevated)`;let t=e/y,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 S=_[0]?.date.getDay()||0,C=Array(S).fill(null).concat(_);return(0,z.jsxs)(`div`,{className:`heatmap-wrap`,children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:`0.75rem`},children:[(0,z.jsx)(`span`,{className:`chart-title`,children:`Activity`}),(0,z.jsx)(`div`,{className:`btn-group`,children:cV.map(e=>(0,z.jsx)(`button`,{className:`btn ${o===e.key?`active`:``}`,onClick:()=>s(e.key),children:e.label},e.key))})]}),(0,z.jsx)(`div`,{className:`heatmap-grid`,style:{gridTemplateRows:`repeat(7, 1fr)`},children:C.map((e,t)=>e?(0,z.jsx)(`div`,{role:i&&a?`button`:void 0,tabIndex:i&&a?0:void 0,onClick:i&&a?()=>i(e.key):void 0,onKeyDown:i&&a?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),i(e.key))}:void 0,className:`heatmap-cell ${e.val>0?`active`:``} ${c.has(e.key)?`heatmap-cell-pop`:``} ${u.has(e.key)?`heatmap-cell-pop-dim`:``}`,style:{background:x(e.val),cursor:i&&a?`pointer`:void 0},title:`${e.key}: ${cV.find(e=>e.key===o).fmt(e.val)}`},e.key):(0,z.jsx)(`div`,{className:`heatmap-cell`,style:{visibility:`hidden`}},`pad-${t}`))}),(0,z.jsx)(`div`,{className:`heatmap-labels`,children:v.slice(-12).map((e,t)=>(0,z.jsx)(`span`,{children:e.label},t))})]})}function fV({presentation:e,rawPresentation:t=null,fullDaily:n=null,sourceDailyRows:r=null,range:i=`total`,ingestProgress:a=0,isIngestActive:o=!1,currentDateBucket:s=null,exportMode:c=!1,exportPlayback:l=!1,exportPhase:u=null,exportSeekMs:d=0,exportDaily:f=null,exportDailyTiming:p=null,onDailyDebugStatsChange:m=null,onPresentationDateRangeChange:h=null,onNavigateToDailyDay:g,onNavigateToRepo:_,onNavigateToModel:v}){if(!e?.ready)return null;let y=l?gV(d):1,x=l&&u===`replay`&&t?.ready?t:e,S=l&&t?.daily||e.daily,C=l&&S?.dates?.length?S:n,w=!c&&!l&&o,T=eV(C,{ingestProgress:a,isIngestActive:w});(0,b.useEffect)(()=>{m?.(w?{speedDaysPerSecond:T.speedDaysPerSecond,waitingForDailyData:T.waitingForDailyData}:null)},[w,T.speedDaysPerSecond,T.waitingForDailyData,m]),(0,b.useEffect)(()=>()=>m?.(null),[m]);let E=T.daily?.dates||[],D=E[E.length-1]||s,O=cB(i,E),k={from:O[0]||D,to:O[O.length-1]||D};(0,b.useEffect)(()=>{h?.(w?k:null)},[w,h,k.from,k.to]),(0,b.useEffect)(()=>()=>h?.(null),[h]);let A=o&&t?.heatmap?t.heatmap:e.heatmap,j=o&&!l?D:s,ee=o&&j&&!l?QB(A,j):A||{},M=(0,b.useMemo)(()=>w?_B({daily:r,range:i,cursor:T.cursor,fallback:x}):x,[x,w,T.cursor,i,r]),{stats:N,topRepos:P,topFamilies:F,topModels:I}=M,te=l&&u===`replay`?iV(aV(t?.topRepos||x.topRepos||[],e.topRepos||x.topRepos||[]),y):M.topRepos||[],ne=l&&u===`replay`?iV(aV(t?.topFamilies||x.topFamilies||[],e.topFamilies||x.topFamilies||[]),y):M.topFamilies||[],re=l&&u===`replay`?iV(aV(t?.topModels||x.topModels||[],e.topModels||x.topModels||[]),y):M.topModels||[],ie=[...te.slice(0,6)].reverse(),ae=Math.max(...te.slice(0,6).map(e=>e.tokens||0),1),oe=[...ne].sort((e,t)=>String(e.label).localeCompare(String(t.label))),se=[...re.slice(0,6)].sort((e,t)=>String(e.label).localeCompare(String(t.label))),ce=!c&&!l&&!o,L=vV(d,l),le=!c&&!l&&eB,ue=l?_V(d,Iz.videoExport?.barsChartIntroUpdateDurationMs,Iz.videoExport?.barsChartUpdateDurationMs,u===`tail`||u===`final_hold`?Iz.videoExport?.barsChartTailUpdateDurationMs:null):0,de={backgroundColor:`transparent`,...Qz,...c?{animation:!1}:{},...l?{animation:!0,animationDuration:0,animationDurationUpdate:ue,animationEasingUpdate:`cubicOut`}:{},tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>e?.length?`${e[0].axisValue}: ${BB(e[0].value)} tokens`:``},grid:{left:100,right:5,top:5,bottom:5},xAxis:{type:`value`,show:!1,max:ae||1},yAxis:{type:`category`,data:ie.map(e=>e.label),axisLabel:{color:`#8b949e`,fontSize:11,formatter:e=>UB(e)},axisTick:{show:!1},axisLine:{show:!1}},series:[{id:`overview-top-repos`,type:`bar`,data:ie.map(e=>{let t=e.tokens||0,n=t/ae>=.7,r=ze(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:()=>BB(t),color:n?Be(r):`#8b949e`,fontSize:10}}}),barWidth:`80%`}]},fe=ce&&_?{click:e=>{if(e?.componentType!==`series`||e?.dataIndex==null)return;let t=ie[e.dataIndex];t?.label&&_(t.label)}}:void 0,pe=oe.reduce((e,t)=>e+(t.tokens||0),0),me=oe.filter(e=>pe>0?(e.tokens||0)/pe>=.01:!1),he=l&&me.length===1,R=oV(me),ge={backgroundColor:`transparent`,...$z,...c||l?{animation:!1}:{},tooltip:{trigger:`item`,appendToBody:!0,confine:!0,formatter:e=>`${e.name}: ${BB(e.value)} tokens (${e.percent}%)`},series:[{id:`overview-work-type`,type:`pie`,animation:le,avoidLabelOverlap:!R,radius:L,center:[`50%`,`50%`],label:{show:!he,color:`#8b949e`,fontSize:11,formatter:`{b}`,alignTo:`edge`,edgeDistance:5,bleedMargin:5,distanceToLabelLine:5},labelLine:{show:!he,lineStyle:{color:`#30363d`},length:8,length2:6},itemStyle:{borderColor:`#161b22`,borderWidth:2},...!he&&R?{labelLayout:R}:{},data:rV(me,We,{hideLabels:he})}]},_e=se.reduce((e,t)=>e+(t.tokens||0),0),ve=se.filter(e=>_e>0?(e.tokens||0)/_e>=.01:!1),ye=l&&ve.length===1,be=oV(ve),xe={backgroundColor:`transparent`,...$z,...c||l?{animation:!1}:{},tooltip:{trigger:`item`,appendToBody:!0,confine:!0,formatter:e=>`${e.name}: ${BB(e.value)} tokens (${e.percent}%)`},series:[{id:`overview-models`,type:`pie`,animation:le,avoidLabelOverlap:!be,radius:L,center:[`50%`,`50%`],label:{show:!ye,color:`#8b949e`,fontSize:11,formatter:`{b}`,alignTo:`edge`,edgeDistance:5,bleedMargin:5,distanceToLabelLine:5},labelLine:{show:!ye,lineStyle:{color:`#30363d`},length:8,length2:6},itemStyle:{borderColor:`#161b22`,borderWidth:2},...!ye&&be?{labelLayout:be}:{},data:rV(ve,Ue,{hideLabels:ye})}]},Se=ce&&v?{click:e=>{if(e?.componentType!==`series`||e?.dataIndex==null)return;let t=ve[e.dataIndex]?.label||e?.name;t&&v(t)}}:void 0;return(0,z.jsxs)(`div`,{className:`animate-in${l?` export-overview-frame`:``}`,children:[(0,z.jsxs)(`div`,{className:`stat-row`,children:[(0,z.jsxs)(`div`,{className:`stat-cards`,children:[(0,z.jsxs)(`div`,{className:`stat-card`,children:[(0,z.jsx)(`div`,{className:`stat-label`,children:`Tokens`}),(0,z.jsx)(`div`,{className:`stat-value`,children:BB(N.tokens)}),(0,z.jsxs)(`div`,{className:`stat-per-day`,children:[(0,z.jsx)(`span`,{className:`stat-per-day-value`,children:BB(N.tokens/N.days)}),` per day`]})]}),(0,z.jsxs)(`div`,{className:`stat-card`,children:[(0,z.jsx)(`div`,{className:`stat-label`,children:`Agent Time`}),(0,z.jsx)(`div`,{className:`stat-value`,children:HB(N.elapsed)}),(0,z.jsxs)(`div`,{className:`stat-per-day`,children:[(0,z.jsx)(`span`,{className:`stat-per-day-value`,children:HB(N.elapsed/N.days)}),` per day`]})]}),(0,z.jsxs)(`div`,{className:`stat-card`,children:[(0,z.jsx)(`div`,{className:`stat-label`,children:`Est. API Cost`}),(0,z.jsx)(`div`,{className:`stat-value`,children:VB(N.cost)}),(0,z.jsxs)(`div`,{className:`stat-per-day`,children:[(0,z.jsx)(`span`,{className:`stat-per-day-value`,children:VB(N.cost/N.days)}),` per day`]})]}),(0,z.jsxs)(`div`,{className:`stat-card`,children:[(0,z.jsx)(`div`,{className:`stat-label`,children:`Sessions`}),(0,z.jsx)(`div`,{className:`stat-value`,children:Math.round(N.sessions).toLocaleString()}),(0,z.jsxs)(`div`,{className:`stat-per-day`,children:[(0,z.jsx)(`span`,{className:`stat-per-day-value`,children:(N.sessions/N.days).toFixed(1)}),` per day`]})]})]}),l?(0,z.jsx)(ot,{daily:f||n||S,seekMs:d,timing:p}):(0,z.jsx)(sV,{daily:S,fullDaily:n,elasticDaily:T,range:i,isIngestActive:o,currentDateBucket:s,exportMode:c,exportPlayback:l,onDayClick:ce?g:void 0})]}),(0,z.jsx)(dV,{heatmapData:ee,isIngestActive:o,ingestProgress:a,currentDateBucket:j,onDayClick:ce?g:void 0,interactive:ce}),(0,z.jsxs)(`div`,{className:`grid-3`,children:[(0,z.jsxs)(`div`,{className:`chart-card overview-donut-card`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Top Repos`}),P.length>0?(0,z.jsx)(Ae,{echarts:VA,option:de,style:{height:180,cursor:fe?`pointer`:void 0},theme:`dark`,lazyUpdate:!1,notMerge:c,onEvents:fe}):(0,z.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem 0`,textAlign:`center`},children:`No data`})]}),(0,z.jsxs)(`div`,{className:`chart-card overview-donut-card`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Work Type`}),F.length>0?(0,z.jsx)(Ae,{echarts:VA,option:ge,style:{height:180},theme:`dark`,lazyUpdate:!1,notMerge:c}):(0,z.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem 0`,textAlign:`center`},children:`No data`})]}),(0,z.jsxs)(`div`,{className:`chart-card`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Models`}),I.length>0?(0,z.jsx)(Ae,{echarts:VA,option:xe,style:{height:180,cursor:Se?`pointer`:void 0},theme:`dark`,lazyUpdate:!1,notMerge:c,onEvents:Se}):(0,z.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem 0`,textAlign:`center`},children:`No data`})]})]}),(0,z.jsxs)(`div`,{className:`coverage-subtle`,children:[(0,z.jsx)(`span`,{style:{fontWeight:500},children:`Session coverage:`}),(0,z.jsxs)(`span`,{className:`coverage-item`,children:[(0,z.jsx)(`span`,{className:`coverage-dot`,style:{background:`#22c55e`}}),(0,z.jsx)(`span`,{className:`coverage-nums`,children:Math.round(N.exactPriced)}),` `,`exact-priced`]}),(0,z.jsxs)(`span`,{className:`coverage-item`,children:[(0,z.jsx)(`span`,{className:`coverage-dot`,style:{background:`#c084fc`}}),(0,z.jsx)(`span`,{className:`coverage-nums`,children:Math.round(N.fallbackPriced)}),` `,`fallback-priced`]}),(0,z.jsxs)(`span`,{className:`coverage-item`,children:[(0,z.jsx)(`span`,{className:`coverage-dot`,style:{background:`#64748b`}}),(0,z.jsx)(`span`,{className:`coverage-nums`,children:Math.round(N.unpriced)}),` `,`unpriced`]})]})]})}function pV({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:h,onNavigateToModel:g}){return(0,z.jsx)(fV,{presentation:TB({overview:e,heatmap:t,daily:n,families:r,repos:i,models:a,range:o},{duration:qz,onSettledChange:s,ingestProgress:c,isIngestActive:l,clockNowMs:d}),rawPresentation:b.useMemo(()=>yB({overview:e,heatmap:t,daily:n,families:r,repos:i,models:a,range:o}),[e,t,n,r,i,a,o]),fullDaily:b.useMemo(()=>GB(n),[n]),sourceDailyRows:n,range:o,ingestProgress:c,isIngestActive:l,currentDateBucket:u,onDailyDebugStatsChange:f,onPresentationDateRangeChange:p,onNavigateToDailyDay:m,onNavigateToRepo:h,onNavigateToModel:g})}function mV(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 hV=(0,b.memo)(pV,mV);function gV(e){return bV(e)}function _V(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=bV(e);return Math.round(a+(i-a)*o)}function vV(e,t=!1){if(!t)return[`48%`,`72%`];let n=.9+bV(e)*.1;return[`${yV(48*n)}%`,`${yV(72*n)}%`]}function yV(e){return Math.round(e*100)/100}function bV(e){let t=Math.max(Iz.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)))}function xV(e,t){return e==="default"?t:e}function SV(e,t=`tokens`){return Object.entries(e||{}).map(([e,t])=>({key:e,...t})).sort((e,n)=>(n[t]||0)-(e[t]||0))}function CV({title:e,rows:t,valueKey:n=`tokens`,colorForKey:r,valueFormatter:i,chartMode:a=`default`,defaultMode:o=`bar`,emptyLabel:s=`No data`,renderTitleInChart:c=!0,barLabelProgress:l=1}){let u=xV(a,o),d=(t||[]).map((e,t)=>{let n=e?.key??e?.repo_label??e?.model_name??e?.family??null;return n?{...e,key:String(n),_idx:t}:null}).filter(Boolean),f={xAxis:{show:!1},yAxis:{show:!1},series:[],graphic:{type:`text`,left:`center`,top:`60%`,style:{text:s,fill:`#484f58`,fontSize:11}}};if(c&&(f.title={text:e,left:`center`,top:`middle`,textStyle:{fontSize:12,color:`#484f58`,fontWeight:`normal`}}),!d.length)return f;if(u===`donut`){let t=d.reduce((e,t)=>e+(t[n]||0),0),a={backgroundColor:`transparent`,...zz,tooltip:{trigger:`item`,appendToBody:!0,confine:!0,formatter:e=>`${e.name}: ${i(e.value)} (${e.percent}%)`},series:[{type:`pie`,...zz,radius:[`40%`,`62%`],center:[`50%`,`52%`],label:{show:!0,color:`#8b949e`,fontSize:10,formatter:`{b}`,overflow:`truncate`,width:90,...Rz},labelLine:{lineStyle:{color:`#30363d`}},itemStyle:{borderColor:`#161b22`,borderWidth:2},data:d.map(e=>{let i=e[n]||0,a=(t>0?i/t:0)>=.01;return{name:e.key,value:i,itemStyle:{color:r(e.key)},label:{show:a,color:r(e.key)},labelLine:{show:a}}})}]};return c&&(a.title={text:e,left:`center`,top:8,textStyle:{fontSize:11,color:`#8b949e`,fontWeight:`normal`}}),a}let p=[...d].reverse(),m=Math.max(...d.map(e=>e[n]||0),0),h={backgroundColor:`transparent`,...Bz,tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{let t=p[e?.[0]?.dataIndex];return t?`${t.key}: ${i(t[n]||0)}`:``}},grid:{left:65,right:50,top:c?35:20,bottom:20},xAxis:{type:`value`,splitNumber:4,max:m||1,axisLabel:{formatter:e=>i(e),color:`#484f58`,fontSize:10,showMinLabel:!0,showMaxLabel:!0},splitLine:{lineStyle:{color:[`transparent`,`#21262d`,`#21262d`,`#21262d`,`transparent`]}}},yAxis:{type:`category`,data:p.map(e=>e.key),axisLabel:{color:`#8b949e`,fontSize:10,overflow:`truncate`,width:55},axisTick:{show:!1},axisLine:{show:!1}},series:[{type:`bar`,data:p.map(e=>({value:e[n]||0,itemStyle:{color:r(e.key),borderRadius:[0,3,3,0]}})),barMaxWidth:14,label:{show:!0,position:`right`,formatter:e=>i((e.value??0)*l),color:`#8b949e`,fontSize:9,...Vz}}]};return c&&(h.title={text:e,left:`center`,top:8,textStyle:{fontSize:11,color:`#8b949e`,fontWeight:`normal`}}),h}uk([FN,iP,zI,nR,aR,Mz]);function wV(e){return Nz(e)}function TV(e){return e==null||e===0?`—`:e>=1e3?`$`+(e/1e3).toFixed(1)+`K`:`$`+e.toFixed(2)}var EV=[`all`,`review`,`exploration`,`planning`,`memory`,`generic`],DV=[`review`,`exploration`,`planning`,`memory`,`generic`];function OV(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 kV(e,t=`total`){let n=e?.data;return Array.isArray(n)?n:n?.[t]||n?.total||[]}function AV({repo:e,chartMode:t}){let[n,r]=(0,b.useState)(!1),i=(0,b.useMemo)(()=>SV(e.by_model),[e.by_model]),a=(0,b.useMemo)(()=>SV(e.by_family),[e.by_family]),o=CV({title:`Models in repo`,rows:i,valueKey:`tokens`,colorForKey:Ue,valueFormatter:wV,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1}),s=CV({title:`Work type in repo`,rows:a,valueKey:`tokens`,colorForKey:We,valueFormatter:wV,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1}),c=[...i.slice(0,4).map(e=>({...e,scope:`model`})),...a.slice(0,4).map(e=>({...e,scope:`family`}))];return(0,z.jsxs)(`div`,{className:`model-detail-wrap`,children:[(0,z.jsxs)(`div`,{className:`model-detail-charts`,children:[(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Models in repo`}),(0,z.jsx)(Ae,{echarts:VA,option:o,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Work type in repo`}),(0,z.jsx)(Ae,{echarts:VA,option:s,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]})]}),(0,z.jsx)(`div`,{className:`model-detail-footer`,children:(0,z.jsxs)(`button`,{type:`button`,className:`model-detail-toggle`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[(0,z.jsx)(`span`,{className:`model-detail-toggle-text`,children:n?`Hide details`:`Show details`}),(0,z.jsx)(`span`,{className:`model-detail-toggle-arrow ${n?`expanded`:``}`,"aria-hidden":!0,children:`▼`})]})}),(0,z.jsx)(`div`,{className:`model-detail-summary-wrap ${n?`expanded`:``}`,children:(0,z.jsx)(`div`,{className:`model-detail-summary`,children:c.map(e=>(0,z.jsxs)(`div`,{className:`model-detail-summary-card`,children:[(0,z.jsxs)(`div`,{className:`model-detail-summary-head`,children:[(0,z.jsx)(`span`,{className:`model-detail-swatch`,style:{background:e.scope===`model`?Ue(e.key):We(e.key)}}),(0,z.jsx)(`span`,{className:`model-detail-summary-name`,title:e.key,children:e.key})]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[wV(e.tokens),` tokens`]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[e.sessions||0,` sessions`]}),(0,z.jsx)(`div`,{className:`model-detail-summary-line`,children:TV(e.cost)})]},`${e.scope}-${e.key}`))})})]})}function jV({data:e,range:t=`total`,chartMode:n=`default`,focusRequest:r=null,onFocusRequestConsumed:i}){let[a,o]=(0,b.useState)(`all`),[s,c]=(0,b.useState)(null),l=(0,b.useRef)(null),u=(0,b.useRef)(null),d=(0,b.useMemo)(()=>kV(e,t),[e,t]),f=(0,b.useMemo)(()=>d?.length?a===`all`?d:d.map(e=>{let t=e.by_family?.[a];return t?{...e,tokens:t.tokens,cost:t.cost,sessions:t.sessions}:null}).filter(Boolean).sort((e,t)=>t.tokens-e.tokens):[],[d,a]);if((0,b.useEffect)(()=>{s&&(f.some(e=>e.repo_key===s)||c(null))},[s,f]),(0,b.useEffect)(()=>{if(!r){u.current=null;return}let{id:e,repoLabel:t}=r;if(!t||u.current===e)return;let n=d.find(e=>e.repo_label===t||e.repo_key===t);u.current=e,n&&c(n.repo_key),i?.()},[r,d,i]),!d?.length)return(0,z.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem`},children:`No data`});let p=f.slice(0,15),m=[...p].reverse(),h=Math.max(...p.map(e=>e.tokens||0),0),g=Math.max(250,p.length*28),_=(0,b.useMemo)(()=>({backgroundColor:`transparent`,...Lz,tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{let t=p[p.length-1-e[0].dataIndex];return t?`<b>${t.repo_label}</b><br/>Tokens: ${wV(t.tokens)}<br/>Cost: ${TV(t.cost)}<br/>Sessions: ${t.sessions}`:``}},grid:{left:150,right:50,top:8,bottom:8},xAxis:{type:`value`,splitNumber:4,max:h||1,axisLabel:{formatter:e=>wV(e),color:`#484f58`,showMinLabel:!0,showMaxLabel:!0},splitLine:{lineStyle:{color:[`transparent`,`#21262d`,`#21262d`,`#21262d`,`transparent`]}}},yAxis:{type:`category`,data:m.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:m.map(e=>({id:e.repo_key,name:e.repo_label,value:e.tokens,itemStyle:{color:ze(e.repo_label),borderRadius:[0,3,3,0]}})),barMaxWidth:16,label:{show:!0,position:`right`,formatter:e=>wV(e.value??0),color:`#8b949e`,fontSize:10,...Rz}}]}),[h,m,p]),v=(0,b.useMemo)(()=>({click:e=>{if(e?.componentType===`series`&&e?.dataIndex!=null){let t=p[p.length-1-e.dataIndex];t&&c(e=>e===t.repo_key?null:t.repo_key)}}}),[p]);return(0,z.jsxs)(`div`,{className:`animate-in`,children:[(0,z.jsxs)(`div`,{className:`section-header`,children:[(0,z.jsx)(`span`,{className:`section-title`,children:`Repos`}),(0,z.jsx)(`div`,{className:`btn-group`,children:EV.map(e=>(0,z.jsx)(`button`,{className:`btn ${a===e?`active`:``}`,onClick:()=>o(e),children:e},e))})]}),(0,z.jsxs)(`div`,{className:`chart-card`,children:[(0,z.jsx)(`button`,{className:`export-btn`,onClick:()=>OV(l),children:`PNG`}),(0,z.jsx)(`div`,{style:{height:g,transition:`height 220ms cubic-bezier(0.22, 1, 0.36, 1)`},children:(0,z.jsx)(Ae,{ref:l,echarts:VA,option:_,style:{height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1,onEvents:v})})]}),(0,z.jsx)(`div`,{className:`table-wrap`,children:(0,z.jsxs)(`table`,{children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:`Repo`}),(0,z.jsx)(`th`,{children:`Tokens`}),(0,z.jsx)(`th`,{children:`Cost`}),(0,z.jsx)(`th`,{children:`Sessions`}),(0,z.jsx)(`th`,{style:{width:200},children:`Families`})]})}),(0,z.jsx)(`tbody`,{children:f.map(e=>(0,z.jsxs)(b.Fragment,{children:[(0,z.jsxs)(`tr`,{onClick:()=>c(s===e.repo_key?null:e.repo_key),style:{cursor:`pointer`},children:[(0,z.jsxs)(`td`,{style:{fontWeight:500,color:`var(--text-primary)`},children:[(0,z.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:2,background:ze(e.repo_label),marginRight:8}}),e.repo_label]}),(0,z.jsx)(`td`,{style:{fontFamily:`var(--font-mono)`},children:wV(e.tokens)}),(0,z.jsx)(`td`,{style:{fontFamily:`var(--font-mono)`},children:TV(e.cost)}),(0,z.jsx)(`td`,{children:e.sessions}),(0,z.jsx)(`td`,{children:Object.entries(e.by_family||{}).sort(([e],[t])=>{let n=DV.indexOf(e),r=DV.indexOf(t);return(n===-1?999:n)-(r===-1?999:r)}).slice(0,3).map(([e])=>(0,z.jsx)(`span`,{className:`tag tag-${e}`,style:{marginRight:3},children:e},e))})]}),s===e.repo_key&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:5,style:{background:`var(--bg-surface)`,padding:`0.75rem 1rem`},children:(0,z.jsx)(AV,{repo:e,chartMode:n})})})]},e.repo_key))})]})})]})}uk([FN,iP,zI,nR,aR,Mz]);function MV(e){return Nz(e)}function NV(e){return e==null||e===0?`—`:e>=1e3?`$`+(e/1e3).toFixed(1)+`K`:`$`+e.toFixed(2)}var PV=[`low`,`medium`,`high`,`xhigh`,`unknown`];function FV(e){return[...e].sort(([e],[t])=>{let n=PV.indexOf((e||``).toLowerCase()),r=PV.indexOf((t||``).toLowerCase());return(n===-1?999:n)-(r===-1?999:r)})}function IV({model:e,fmt:t,chartMode:n}){let[r,i]=(0,b.useState)(!1),a=(0,b.useMemo)(()=>FV(Object.entries(e.by_effort||{})),[e.by_effort]);if(!a.length)return null;let o=a.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})),s=o.map(e=>({key:e.effort,sessions:e.sessions,tokens:e.tokens,avgTokens:e.avgTokens})),c=CV({title:`Sessions by effort`,rows:s,valueKey:`sessions`,colorForKey:Ge,valueFormatter:e=>Math.round(e).toLocaleString(),chartMode:n,defaultMode:`donut`,renderTitleInChart:!1}),l=CV({title:`Tokens by effort`,rows:s,valueKey:`tokens`,colorForKey:Ge,valueFormatter:t,chartMode:n,defaultMode:`donut`,renderTitleInChart:!1}),u=CV({title:`Avg tokens per session`,rows:s,valueKey:`avgTokens`,colorForKey:Ge,valueFormatter:t,chartMode:n,defaultMode:`bar`,renderTitleInChart:!1});return(0,z.jsxs)(`div`,{className:`model-detail-wrap`,children:[(0,z.jsxs)(`div`,{className:`model-detail-charts`,children:[(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Sessions by effort`}),(0,z.jsx)(Ae,{echarts:VA,option:c,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Tokens by effort`}),(0,z.jsx)(Ae,{echarts:VA,option:l,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,z.jsxs)(`div`,{className:`model-detail-bar`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Avg tokens per session`}),(0,z.jsx)(Ae,{echarts:VA,option:u,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]})]}),(0,z.jsx)(`div`,{className:`model-detail-footer`,children:(0,z.jsxs)(`button`,{type:`button`,className:`model-detail-toggle`,onClick:()=>i(e=>!e),"aria-expanded":r,children:[(0,z.jsx)(`span`,{className:`model-detail-toggle-text`,children:r?`Hide details`:`Show details`}),(0,z.jsx)(`span`,{className:`model-detail-toggle-arrow ${r?`expanded`:``}`,"aria-hidden":!0,children:`▼`})]})}),(0,z.jsx)(`div`,{className:`model-detail-summary-wrap ${r?`expanded`:``}`,children:(0,z.jsx)(`div`,{className:`model-detail-summary`,children:o.map(e=>(0,z.jsxs)(`div`,{className:`model-detail-summary-card`,children:[(0,z.jsxs)(`div`,{className:`model-detail-summary-head`,children:[(0,z.jsx)(`span`,{className:`model-detail-swatch`,style:{background:Ge(e.effort)}}),(0,z.jsx)(`span`,{className:`model-detail-summary-name`,title:e.effort,children:e.effort})]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[e.sessions,` sessions`]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[t(e.tokens),` tokens`]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[t(e.avgTokens),` avg/session`]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[NV(e.cost),` cost`]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[e.exactPriced,` exact · `,e.fallbackPriced,` fallback`]})]},e.effort))})})]})}function LV(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 RV(e,t=`total`){let n=e?.data;return Array.isArray(n)?n:n?.[t]||n?.total||[]}function zV({data:e,range:t=`total`,chartMode:n=`default`,focusRequest:r=null,onFocusRequestConsumed:i}){let[a,o]=(0,b.useState)(null),s=(0,b.useRef)(null),c=(0,b.useRef)(null),l=(0,b.useMemo)(()=>RV(e,t),[e,t]);if((0,b.useEffect)(()=>{a&&(l.some(e=>e.model_name===a)||o(null))},[a,l]),(0,b.useEffect)(()=>{if(!r){c.current=null;return}let{id:e,modelName:t}=r;if(!t||c.current===e)return;let n=l.find(e=>e.model_name===t);c.current=e,n&&o(n.model_name),i?.()},[r,l,i]),!l?.length)return(0,z.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem`},children:`No data`});let u=[...l].reverse(),d=Math.max(...l.map(e=>e.tokens||0),0),f=Math.max(180,l.length*34),p=(0,b.useMemo)(()=>({backgroundColor:`transparent`,...Lz,tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{let t=l[l.length-1-e[0].dataIndex];return`<b>${t.model_name}</b><br/>Tokens: ${MV(t.tokens)}<br/>Cost: ${NV(t.cost)}<br/>Sessions: ${t.sessions}`}},grid:{left:160,right:50,top:8,bottom:8},xAxis:{type:`value`,splitNumber:4,max:d||1,axisLabel:{formatter:e=>MV(e),color:`#484f58`,fontSize:10,showMinLabel:!0,showMaxLabel:!0},splitLine:{lineStyle:{color:[`transparent`,`#21262d`,`#21262d`,`#21262d`,`transparent`]}}},yAxis:{type:`category`,data:u.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:u.map(e=>({id:e.model_name,name:e.model_name,value:e.tokens,itemStyle:{color:Ue(e.model_name),borderRadius:[0,3,3,0]}})),barMaxWidth:18,label:{show:!0,position:`right`,formatter:e=>MV(e.value??0),color:`#8b949e`,fontSize:10,...Rz}}]}),[d,l,u]),m=(0,b.useMemo)(()=>({click:e=>{if(e?.componentType===`series`&&e?.dataIndex!=null){let t=l[l.length-1-e.dataIndex];t&&o(e=>e===t.model_name?null:t.model_name)}}}),[l]);return(0,z.jsxs)(`div`,{className:`animate-in`,children:[(0,z.jsx)(`div`,{className:`section-header`,children:(0,z.jsx)(`span`,{className:`section-title`,children:`Models`})}),(0,z.jsxs)(`div`,{className:`chart-card`,children:[(0,z.jsx)(`button`,{className:`export-btn`,onClick:()=>LV(s),children:`PNG`}),(0,z.jsx)(`div`,{style:{height:f,transition:`height 220ms cubic-bezier(0.22, 1, 0.36, 1)`},children:(0,z.jsx)(Ae,{ref:s,echarts:VA,option:p,style:{height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1,onEvents:m})})]}),(0,z.jsx)(`div`,{className:`table-wrap`,children:(0,z.jsxs)(`table`,{children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:`Model`}),(0,z.jsx)(`th`,{children:`Tokens`}),(0,z.jsx)(`th`,{children:`Cost`}),(0,z.jsx)(`th`,{children:`Sessions`}),(0,z.jsx)(`th`,{children:`Effort Levels`})]})}),(0,z.jsx)(`tbody`,{children:l.map(e=>(0,z.jsxs)(b.Fragment,{children:[(0,z.jsxs)(`tr`,{onClick:()=>o(a===e.model_name?null:e.model_name),style:{cursor:`pointer`},children:[(0,z.jsxs)(`td`,{style:{fontWeight:500,color:`var(--text-primary)`,fontFamily:`var(--font-mono)`},children:[(0,z.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:2,background:Ue(e.model_name),marginRight:8}}),e.model_name]}),(0,z.jsx)(`td`,{style:{fontFamily:`var(--font-mono)`},children:MV(e.tokens)}),(0,z.jsx)(`td`,{style:{fontFamily:`var(--font-mono)`},children:NV(e.cost)}),(0,z.jsx)(`td`,{children:e.sessions}),(0,z.jsx)(`td`,{children:Object.keys(e.by_effort).length})]}),a===e.model_name&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:5,style:{background:`var(--bg-surface)`,padding:`0.75rem 1rem`},children:(0,z.jsx)(IV,{model:e,fmt:MV,chartMode:n})})})]},e.model_name))})]})})]})}uk([FN,Uj,iP,zI,nR,aR,jR,cz,rL,Mz]);function BV(e){return Nz(e)}function VV(e){return e==null||e===0?`$0`:`$`+e.toFixed(2)}function HV(e){return e?(e/3600).toFixed(1)+`h`:`0h`}var UV=[{key:`tokens`,label:`Tokens`,fn:BV},{key:`elapsed_seconds`,label:`Time`,fn:HV},{key:`cost`,label:`Cost`,fn:VV}],WV=[{key:`model`,label:`By Model`},{key:`family`,label:`By Work`}],GV=[{key:`absolute`,label:`Absolute`},{key:`relative`,label:`Relative`}];function KV(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 qV(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 JV=280,YV={left:70,right:20,bottom:12,height:24};function XV(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 ZV(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 QV(e,t){return{left:YV.left,right:e-YV.right,top:t-YV.bottom-YV.height,bottom:t-YV.bottom}}function $V(e,t,n,r){let i=QV(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 eH(e,t){return e===`d7`?44:e===`d30`?22:t<=14?36:t<=31?18:14}function tH(e,t){return e===`d7`?8:e===`d30`?3:t<=31?2:+(t<=90)}function nH(e,t){return e===`d7`?`72%`:e===`d30`?`54%`:t<=14?`64%`:t<=31?`48%`:`36%`}function rH(e,t){return e?t===`elapsed_seconds`?e.elapsed_seconds||0:t===`cost`?e.cost||0:e.tokens||0:0}function iH(e,t){if(!e)return`Day detail`;let n=UV.find(e=>e.key===t)||UV[0],r=new Date(`${e.date}T00:00:00`).toLocaleDateString(`en-US`,{weekday:`long`}),i=n.fn(rH(e,t));return`Day detail: ${r} - ${e.date} - ${n.label}: ${i}`}function aH(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 oH({day:e,chartMode:t}){let n=(0,b.useMemo)(()=>SV(e.by_model),[e.by_model]),r=(0,b.useMemo)(()=>SV(e.by_repo),[e.by_repo]),i=(0,b.useMemo)(()=>SV(e.by_family),[e.by_family]),a=CV({title:`Models`,rows:n,valueKey:`tokens`,colorForKey:Ue,valueFormatter:BV,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1}),o=CV({title:`Repos`,rows:r,valueKey:`tokens`,colorForKey:ze,valueFormatter:BV,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1}),s=CV({title:`Work Type`,rows:i,valueKey:`tokens`,colorForKey:We,valueFormatter:BV,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1});return(0,z.jsx)(`div`,{className:`model-detail-wrap`,children:(0,z.jsxs)(`div`,{className:`model-detail-charts`,children:[(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Repos`}),(0,z.jsx)(Ae,{echarts:VA,option:o,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Models`}),(0,z.jsx)(Ae,{echarts:VA,option:a,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Work Type`}),(0,z.jsx)(Ae,{echarts:VA,option:s,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]})]})})}var sH=b.memo(function({daily:e,range:t,metric:n,split:r,displayMode:i,onSelectDate:a,navigateToDayRequest:o,onNavigateToDayConsumed:s}){let[c,l]=(0,b.useState)({startValue:0,endValue:0}),u=(0,b.useRef)(null),d=(0,b.useRef)(c);d.current=c;let f=(0,b.useRef)(0),p=(0,b.useRef)(null),m=(0,b.useRef)(0),h=(0,b.useRef)(!1),g=(0,b.useRef)(null),_=(0,b.useRef)(null),v=(0,b.useRef)(0),y=(0,b.useMemo)(()=>e.map(e=>e.date),[e]),x=UV.find(e=>e.key===n),S=(0,b.useMemo)(()=>qV(t,y.length),[t,y.length]);(0,b.useEffect)(()=>{if(!y.length)return;let e=qV(t,y.length),n=_.current===null,r=!n&&_.current!==t,i=!n&&v.current!==y.length;if(_.current=t,v.current=y.length,cancelAnimationFrame(m.current),m.current=0,n){l(e);return}if(r)return ZV(d.current,e,l,m,JV);i&&l(e)},[t,y.length]),(0,b.useEffect)(()=>()=>{cancelAnimationFrame(f.current),f.current=0,g.current?.(),g.current=null},[]);let C=(0,b.useCallback)(()=>{let e=u.current?.getEchartsInstance?.();if(!e)return;g.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=$V(e.getWidth(),e.getHeight(),y.length,d.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(h.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=$V(e.getWidth(),e.getHeight(),y.length,d.current);h.current=r>=a.selectionLeft&&r<=a.selectionRight&&i>=a.top&&i<=a.bottom,n(t)},a=e=>{h.current=!1,n(e)},o=()=>{h.current=!1,t.setCursorStyle(`default`)};t.on(`mousemove`,r),t.on(`mousedown`,i),t.on(`mouseup`,a),t.on(`globalout`,o),g.current=()=>{t.off(`mousemove`,r),t.off(`mousedown`,i),t.off(`mouseup`,a),t.off(`globalout`,o),t.setCursorStyle(`default`)}},[y.length]),w=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!o){w.current=null;return}let{id:t,centerDate:n}=o;if(!n||!e.length||w.current===t)return;let r=e.map(e=>e.date),i=r.indexOf(n);if(i<0){s?.();return}w.current=t;let c=Math.max(0,i-3),u=Math.min(r.length-1,i+3);cancelAnimationFrame(m.current),m.current=0,l({startValue:c,endValue:u}),a(n),s?.()},[o,e,a,s]);let T=(0,b.useMemo)(()=>{if(!y.length)return 0;let e=Math.max(0,Math.min(y.length-1,Math.floor(c.startValue??S.startValue??0))),t=Math.max(e,Math.min(y.length-1,Math.floor(c.endValue??S.endValue??y.length-1)));return Math.max(1,t-e+1)},[y.length,c,S]),E=(0,b.useMemo)(()=>{if(!y.length)return{startIdx:0,endIdx:-1};let e=Math.max(0,Math.min(y.length-1,Math.floor(c.startValue??S.startValue??0)));return{startIdx:e,endIdx:Math.max(e,Math.min(y.length-1,Math.floor(c.endValue??S.endValue??y.length-1)))}},[y.length,c,S]),D=(0,b.useMemo)(()=>eH(t,T),[t,T]),O=(0,b.useMemo)(()=>tH(t,T),[t,T]),k=(0,b.useMemo)(()=>nH(t,T),[t,T]),A=(0,b.useMemo)(()=>aB(e,{split:r,metric:n}),[e,r,n]),j=A.groups,ee=(0,b.useMemo)(()=>A.series.map(e=>({name:e.key,values:e.data})),[A.series]),M=A.dayTotals,N=(0,b.useMemo)(()=>{if(!M.length||E.endIdx<E.startIdx)return 0;let e=0;for(let t=E.startIdx;t<=E.endIdx;t++)e=Math.max(e,M[t]||0);return e},[M,E]),P=i===`relative`,F=(0,b.useMemo)(()=>({dates:y,series:ee.map(e=>({key:e.name,label:e.name,data:e.values}))}),[y,ee]),I=`${n}\0${r}`,te=MB(F,!P,I),ne=(0,b.useMemo)(()=>new Map((te?.series||[]).map(e=>[e.key,e])),[te]),re=(0,b.useMemo)(()=>{if(P)return M;let e=y.length,t=Array(e).fill(0);for(let n of te?.series||[])for(let r=0;r<e;r++)t[r]+=n.data[r]||0;return t},[P,M,te,y.length]),ie=(0,b.useMemo)(()=>{if(i===`relative`)return 100;if(N)return Math.ceil(N*1.1)},[i,N]),ae=(0,b.useMemo)(()=>{if(!P)return null;if(!ee.length)return[];let e=ee.map(e=>{let t=e.values.map((e,t)=>M[t]>0?e/M[t]*100:0);for(let e=1;e<t.length;e++)M[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}})},[P,ee,M]),oe=(0,b.useMemo)(()=>P?j.map((e,t)=>{let n=r===`model`?Ue(e):We(e);if(!ee[t])return null;let i=ae[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`?Ue(e):We(e),n=ne.get(e)?.data??y.map(()=>0);return{id:`daily-${r}-${e}`,name:e,type:`bar`,stack:`total`,data:n,itemStyle:{color:t},barWidth:k,barMaxWidth:D,barMinWidth:O}}),[P,j,r,ae,ee,ne,y,k,D,O]),se=(0,b.useMemo)(()=>!P||!ae?[]:ae.map((e,t)=>{let n=ee[t],i=Be(r===`model`?Ue(n.name):We(n.name)),a=aH(e.values,e.prevStack);return!a||Math.max(...e.values)<8?null:{name:n.name,labelColor:i,coord:a}}).filter(Boolean),[P,ae,ee,r]),ce=(0,b.useCallback)(()=>{if(!u.current)return;let e=u.current.getEchartsInstance();if(!P||se.length===0){e.setOption({graphic:{elements:[]}},{notMerge:!1});return}let t=se.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})},[P,se]);(0,b.useEffect)(()=>{let e=setTimeout(ce,150);return()=>clearTimeout(e)},[P,se,ce]),(0,b.useEffect)(()=>{let e=()=>ce();return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[ce]),(0,b.useEffect)(()=>{C()},[C,c]);let L={backgroundColor:`transparent`,tooltip:{trigger:`axis`,axisPointer:{type:P?`line`:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{if(!e?.length)return``;let t=e[0]?.dataIndex,n=re,r=t==null?0:n[t],a=t;if(i===`relative`&&r===0&&t!=null){for(let e=t-1;e>=0;e--)if(n[e]>0){a=e;break}}let o=i===`relative`&&r===0?n[a]??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=i===`relative`?ee.find(t=>t.name===e.seriesName)?.values[a]??0:e.value;i===`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+=i===`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:YV.left,right:YV.right,top:35,bottom:55},dataZoom:[{type:`slider`,startValue:c.startValue,endValue:c.endValue,left:YV.left,right:YV.right,bottom:YV.bottom,height:YV.height,borderColor:`#30363d`,fillerColor:`rgba(99, 102, 241, 0.08)`,handleStyle:{color:`#6366f1`},textStyle:{color:`#484f58`}}],xAxis:{type:`category`,data:y,boundaryGap:i!==`relative`,axisLabel:{color:`#484f58`,fontSize:10,rotate:45},axisTick:{show:!1},axisLine:{lineStyle:{color:`#30363d`}}},yAxis:{type:`value`,min:0,max:i===`relative`?100:ie,scale:!1,axisLabel:{formatter:i===`relative`?e=>e+`%`:e=>x.fn(e),color:`#484f58`},splitLine:{lineStyle:{color:`#21262d`}}},series:oe,...P?Lz:Zz};return(0,z.jsxs)(`div`,{className:`chart-card`,children:[(0,z.jsx)(`button`,{className:`export-btn`,onClick:()=>KV(u),children:`PNG`}),(0,z.jsx)(Ae,{ref:u,echarts:VA,option:L,style:{height:400},theme:`dark`,notMerge:!1,replaceMerge:[`series`,`legend`,`graphic`],lazyUpdate:!1,onChartReady:()=>{ce(),C()},onEvents:{click:e=>{let t=e?.axisValue||e?.name;t&&a(t)},datazoom:e=>{p.current=XV(e,y,d.current),f.current||=requestAnimationFrame(()=>{f.current=0,p.current&&=(l(p.current),null),P&&ce()})}}})]})});function cH({data:e,range:t=`total`,chartMode:n=`default`,navigateToDayRequest:r=null,onNavigateToDayConsumed:i}){let[a,o]=(0,b.useState)(`tokens`),[s,c]=(0,b.useState)(`model`),[l,u]=(0,b.useState)(`absolute`),[d,f]=(0,b.useState)(null);if(!e?.data?.length)return(0,z.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem`},children:`No data`});let p=(0,b.useMemo)(()=>nB(e),[e]);(0,b.useEffect)(()=>{!d&&p[0]&&f(p[p.length-1]?.date||p[0]?.date)},[p,d]);let m=(0,b.useCallback)(e=>{e&&f(e)},[]),h=p.find(e=>e.date===d)||null;return(0,z.jsxs)(`div`,{className:`animate-in`,children:[(0,z.jsxs)(`div`,{className:`section-header`,children:[(0,z.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`0.75rem`},children:(0,z.jsx)(`span`,{className:`section-title`,children:`Daily Usage`})}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`},children:[(0,z.jsx)(`div`,{className:`btn-group`,children:UV.map(e=>(0,z.jsx)(`button`,{className:`btn ${a===e.key?`active`:``}`,onClick:()=>o(e.key),children:e.label},e.key))}),(0,z.jsx)(`div`,{className:`btn-group`,children:WV.map(e=>(0,z.jsx)(`button`,{className:`btn ${s===e.key?`active`:``}`,onClick:()=>c(e.key),children:e.label},e.key))}),(0,z.jsx)(`div`,{className:`btn-group`,children:GV.map(e=>(0,z.jsx)(`button`,{className:`btn ${l===e.key?`active`:``}`,onClick:()=>u(e.key),children:e.label},e.key))})]})]}),(0,z.jsx)(sH,{daily:p,range:t,metric:a,split:s,displayMode:l,onSelectDate:m,navigateToDayRequest:r,onNavigateToDayConsumed:i}),h&&(0,z.jsxs)(`div`,{className:`chart-card`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.75rem`},children:iH(h,a)}),(0,z.jsx)(oH,{day:h,chartMode:n})]})]})}function lH(){return{accessor:(e,t)=>typeof e==`function`?{...t,accessorFn:e}:{...t,accessorKey:e},display:e=>e,group:e=>e}}function uH(e,t){return typeof e==`function`?e(t):e}function dH(e,t){return n=>{t.setState(t=>({...t,[e]:uH(n,t[e])}))}}function fH(e){return e instanceof Function}function pH(e){return Array.isArray(e)&&e.every(e=>typeof e==`number`)}function mH(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i!=null&&i.length&&r(i)})};return r(e),n}function hH(e,t,n){let r=[],i;return a=>{let o;n.key&&n.debug&&(o=Date.now());let s=e(a);if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug&&(c=Date.now()),i=t(...s),n==null||n.onChange==null||n.onChange(i),n.key&&n.debug&&n!=null&&n.debug()){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
27
|
+
`||r===``)){var i=e.isSelected(r);Y(n,r)?n[r]=n[r]&&i:n[r]=i}}),n}function yR(e){e.registerAction(`legendToggleSelect`,`legendselectchanged`,$t(_R,`toggleSelected`)),e.registerAction(`legendAllSelect`,`legendselectall`,$t(_R,`allSelect`)),e.registerAction(`legendInverseSelect`,`legendinverseselect`,$t(_R,`inverseSelect`)),e.registerAction(`legendSelect`,`legendselected`,$t(_R,`select`)),e.registerAction(`legendUnSelect`,`legendunselected`,$t(_R,`unSelect`))}var bR=Gl(xR);function xR(e){var t=e.findComponents({mainType:`legend`});t&&t.length&&e.filterSeries(function(e){for(var n=0;n<t.length;n++)if(!t[n].isSelected(e.name))return!1;return!0})}function SR(e){e.registerComponentModel(sR),e.registerComponentView(dR),e.registerProcessor(e.PRIORITY.PROCESSOR.SERIES_FILTER,bR),e.registerSubTypeDefaulter(`legend`,function(){return`plain`}),yR(e)}R();var CR=function(e){O(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.setScrollDataIndex=function(e){this.option.scrollDataIndex=e},t.prototype.init=function(t,n,r){var i=Pv(t);e.prototype.init.call(this,t,n,r),wR(this,t,i)},t.prototype.mergeOption=function(t,n){e.prototype.mergeOption.call(this,t,n),wR(this,this.option,t)},t.type=`legend.scroll`,t.defaultOption=Qg(sR.defaultOption,{scrollDataIndex:0,pageButtonItemGap:5,pageButtonGap:null,pageButtonPosition:`end`,pageFormatter:`{current}/{total}`,pageIcons:{horizontal:[`M0,0L12,-10L12,10z`,`M0,0L-12,-10L-12,10z`],vertical:[`M0,0L20,0L10,-20z`,`M0,0L20,0L10,20z`]},pageIconColor:Z.color.accent50,pageIconInactiveColor:Z.color.accent10,pageIconSize:15,pageTextStyle:{color:Z.color.tertiary},animationDurationUpdate:800}),t}(sR);function wR(e,t,n){var r=e.getOrient(),i=[1,1];i[r.index]=0,Nv(t,n,{type:`box`,ignoreSize:!!i})}R();var TR=Ps,ER=[`width`,`height`],DR=[`x`,`y`],OR=function(e){O(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.newlineDisabled=!0,n._currentIndex=0,n}return t.prototype.init=function(){e.prototype.init.call(this),this.group.add(this._containerGroup=new TR),this._containerGroup.add(this.getContentGroup()),this.group.add(this._controllerGroup=new TR)},t.prototype.resetInner=function(){e.prototype.resetInner.call(this),this._controllerGroup.removeAll(),this._containerGroup.removeClipPath(),this._containerGroup.__rectSize=null},t.prototype.renderInner=function(t,n,r,i,a,o,s){var c=this;e.prototype.renderInner.call(this,t,n,r,i,a,o,s);var l=this._controllerGroup,u=n.get(`pageIconSize`,!0),d=W(u)?u:[u,u];p(`pagePrev`,0);var f=n.getModel(`pageTextStyle`);l.add(new hf({name:`pageText`,style:{text:`xx/xx`,fill:f.getTextColor(),font:f.getFont(),verticalAlign:`middle`,align:`center`},silent:!0})),p(`pageNext`,1);function p(e,t){var r=e+`DataIndex`,a=Zh(n.get(`pageIcons`,!0)[n.getOrient().name][t],{onclick:U(c._pageGo,c,r,n,i)},{x:-d[0]/2,y:-d[1]/2,width:d[0],height:d[1]});a.name=e,l.add(a)}},t.prototype.layoutInner=function(e,t,n,r,i,a){var o=this.getSelectorGroup(),s=e.getOrient().index,c=ER[s],l=DR[s],u=ER[1-s],d=DR[1-s];i&&wv(`horizontal`,o,e.get(`selectorItemGap`,!0));var f=e.get(`selectorButtonGap`,!0),p=o.getBoundingRect(),m=[-p.x,-p.y],h=Rt(n);i&&(h[c]=n[c]-p[c]-f);var g=this._layoutContentAndController(e,r,h,s,c,u,d,l);if(i){if(a===`end`)m[s]+=g[c]+f;else{var _=p[c]+f;m[s]-=_,g[l]-=_}g[c]+=p[c]+f,m[1-s]+=g[d]+g[u]/2-p[u]/2,g[u]=Math.max(g[u],p[u]),g[d]=Math.min(g[d],p[d]+m[1-s]),o.x=m[0],o.y=m[1],o.markRedraw()}return g},t.prototype._layoutContentAndController=function(e,t,n,r,i,a,o,s){var c=this.getContentGroup(),l=this._containerGroup,u=this._controllerGroup;wv(e.get(`orient`),c,e.get(`itemGap`),r?n.width:null,r?null:n.height),wv(`horizontal`,u,e.get(`pageButtonItemGap`,!0));var d=c.getBoundingRect(),f=u.getBoundingRect(),p=this._showController=d[i]>n[i],m=[-d.x,-d.y];t||(m[r]=c[s]);var h=[0,0],g=[-f.x,-f.y],_=q(e.get(`pageButtonGap`,!0),e.get(`itemGap`,!0));p&&(e.get(`pageButtonPosition`,!0)===`end`?g[r]+=n[i]-f[i]:h[r]+=f[i]+_),g[1-r]+=d[a]/2-f[a]/2,c.setPosition(m),l.setPosition(h),u.setPosition(g);var v={x:0,y:0};if(v[i]=p?n[i]:d[i],v[a]=Math.max(d[a],f[a]),v[o]=Math.min(0,f[o]+g[1-r]),l.__rectSize=n[i],p){var y={x:0,y:0};y[i]=Math.max(n[i]-f[i]-_,0),y[a]=v[a],l.setClipPath(new uf({shape:y})),l.__rectSize=y[i]}else u.eachChild(function(e){e.attr({invisible:!0,silent:!0})});var b=this._getPageInfo(e);return b.pageIndex!=null&&yh(c,{x:b.contentPosition[0],y:b.contentPosition[1]},p?e:null),this._updatePageInfoView(e,b),v},t.prototype._pageGo=function(e,t,n){var r=this._getPageInfo(t)[e];r!=null&&n.dispatchAction({type:`legendScroll`,scrollDataIndex:r,legendId:t.id})},t.prototype._updatePageInfoView=function(e,t){var n=this._controllerGroup;V([`pagePrev`,`pageNext`],function(r){var i=t[r+`DataIndex`]!=null,a=n.childOfName(r);a&&(a.setStyle(`fill`,i?e.get(`pageIconColor`,!0):e.get(`pageIconInactiveColor`,!0)),a.cursor=i?`pointer`:`default`)});var r=n.childOfName(`pageText`),i=e.get(`pageFormatter`),a=t.pageIndex,o=a==null?0:a+1,s=t.pageCount;r&&i&&r.setStyle(`text`,G(i)?i.replace(`{current}`,o==null?``:o+``).replace(`{total}`,s==null?``:s+``):i({current:o,total:s}))},t.prototype._getPageInfo=function(e){var t=e.get(`scrollDataIndex`,!0),n=this.getContentGroup(),r=this._containerGroup.__rectSize,i=e.getOrient().index,a=ER[i],o=DR[i],s=this._findTargetItemIndex(t),c=n.children(),l=c[s],u=c.length,d=+!!u,f={contentPosition:[n.x,n.y],pageCount:d,pageIndex:d-1,pagePrevDataIndex:null,pageNextDataIndex:null};if(!l)return f;var p=v(l);f.contentPosition[i]=-p.s;for(var m=s+1,h=p,g=p,_=null;m<=u;++m)_=v(c[m]),(!_&&g.e>h.s+r||_&&!y(_,h.s))&&(h=g.i>h.i?g:_,h&&(f.pageNextDataIndex??=h.i,++f.pageCount)),g=_;for(var m=s-1,h=p,g=p,_=null;m>=-1;--m)_=v(c[m]),(!_||!y(g,_.s))&&h.i<g.i&&(g=h,f.pagePrevDataIndex??=h.i,++f.pageCount,++f.pageIndex),h=_;return f;function v(e){if(e){var t=e.getBoundingRect(),n=t[o]+e[o];return{s:n,e:n+t[a],i:e.__legendDataIndex}}}function y(e,t){return e.e>=t&&e.s<=t+r}},t.prototype._findTargetItemIndex=function(e){if(!this._showController)return 0;var t,n=this.getContentGroup(),r;return n.eachChild(function(n,i){var a=n.__legendDataIndex;r==null&&a!=null&&(r=i),a===e&&(t=i)}),t??r},t.type=`legend.scroll`,t}(dR);function kR(e){e.registerAction(`legendScroll`,`legendscroll`,function(e,t){var n=e.scrollDataIndex;n!=null&&t.eachComponent({mainType:`legend`,subType:`scroll`,query:e},function(e){e.setScrollDataIndex(n)})})}function AR(e){uk(SR),e.registerComponentModel(CR),e.registerComponentView(OR),kR(e)}function jR(e){uk(SR),uk(AR)}R();var MR=function(e){O(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=Qg(gL.defaultOption,{disabled:!1,zoomLock:!1,zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!1,preventDefaultMouseMove:!0}),t}(gL),NR=gl();function PR(e,t,n){NR(e).coordSysRecordMap.each(function(e){var r=e.dataZoomInfoMap.get(t.uid);r&&(r.getRange=n)})}function FR(e,t){for(var n=NR(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||IR(n,o))}}}function IR(e,t){if(t){e.removeKey(t.model.uid);var n=t.controller;n&&n.dispose()}}function LR(e,t){var n={model:t,containsPoint:$t(zR,t),dispatchAction:$t(RR,e),dataZoomInfoMap:null,controller:null},r=n.controller=new sF(e.getZr());return V([`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 RR(e,t){e.isDisposed()||e.dispatchAction({type:`dataZoom`,animation:{easing:`cubicOut`,duration:100},batch:t})}function zR(e,t,n,r){return e.coordinateSystem.containPoint([n,r])}function BR(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=q(t.get(`cursorGrab`,!0),s),c=q(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 VR(e){e.registerUpdateLifecycle(`coordsys:aftercreate`,function(e,t){var n=NR(t),r=n.coordSysRecordMap||=J();r.each(function(e){e.dataZoomInfoMap=null}),e.eachComponent({mainType:`dataZoom`,subType:`inside`},function(e){V(uL(e).infoList,function(n){var i=n.model.uid,a=r.get(i)||r.set(i,LR(t,n.model));(a.dataZoomInfoMap||=J()).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){IR(r,e);return}var s=BR(a,e,t);n.enable(s.controlType,s.opt),aS(e,`dispatchAction`,i.model.get(`throttle`,!0),`fixRate`)})})}R();var HR=function(e){O(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(),PR(r,t,{pan:U(UR.pan,this),zoom:U(UR.zoom,this),scrollMove:U(UR.scrollMove,this)})},t.prototype.dispose=function(){this._clear(),e.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){FR(this.api,this.dataZoomModel),this.range=null},t.type=`dataZoom.inside`,t}(vL),UR={zoom:function(e,t,n,r){var i=this.range,a=i.slice(),o=e.axisModels[0];if(o){var s=GR[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(_F(0,a,[0,100],0,u.minSpan,u.maxSpan),this.range=a,i[0]!==a[0]||i[1]!==a[1])return a}},pan:WR(function(e,t,n,r,i,a){var o=GR[r]([a.oldX,a.oldY],[a.newX,a.newY],t,i,n);return o.signal*(e[1]-e[0])*o.pixel/o.pixelLength}),scrollMove:WR(function(e,t,n,r,i,a){return GR[r]([0,0],[a.scrollDelta,a.scrollDelta],t,i,n).signal*(e[1]-e[0])*a.scrollDelta})};function WR(e){return function(t,n,r,i){var a=this.range,o=a.slice(),s=t.axisModels[0];if(s&&(_F(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 GR={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 KR(e){CL(e),e.registerComponentModel(MR),e.registerComponentView(HR),VR(e)}R();var qR=function(e){O(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=Qg(gL.defaultOption,{show:!0,right:`ph`,top:`ph`,width:`ph`,height:`ph`,left:null,bottom:null,borderColor:Z.color.accent10,borderRadius:0,backgroundColor:Z.color.transparent,dataBackground:{lineStyle:{color:Z.color.accent30,width:.5},areaStyle:{color:Z.color.accent20,opacity:.2}},selectedDataBackground:{lineStyle:{color:Z.color.accent40,width:.5},areaStyle:{color:Z.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:Z.color.neutral00,borderColor:Z.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:Z.color.accent40,opacity:.5},showDetail:!0,showDataShadow:`auto`,realtime:!0,zoomLock:!1,textStyle:{color:Z.color.tertiary},brushSelect:!0,brushStyle:{color:Z.color.accent30,opacity:.3},emphasis:{handleLabel:{show:!0},handleStyle:{borderColor:Z.color.accent40},moveHandleStyle:{opacity:.8}},defaultLocationEdgeGap:15}),t}(gL);R();var JR=uf,YR=1,XR=30,ZR=7,QR=`horizontal`,$R=`vertical`,ez=5,tz=[`line`,`bar`,`candlestick`,`scatter`],nz={easing:`cubicOut`,duration:100,delay:0},rz=function(e){O(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=U(this._onBrush,this),this._onBrushEnd=U(this._onBrushEnd,this)},t.prototype.render=function(t,n,r,i){if(e.prototype.render.apply(this,arguments),aS(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(){oS(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 Ps;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`)?ZR:0,r=Av(e,t).refContainer,i=this._findCoordRect(),a=e.get(`defaultLocationEdgeGap`,!0)||0,o=this._orient===QR?{right:r.width-i.x-i.width,top:r.height-XR-a-n,width:i.width,height:XR}:{right:a,top:i.y,width:XR,height:i.height},s=Pv(e.option);V([`right`,`top`,`width`,`height`],function(e){s[e]===`ph`&&(s[e]=o[e])});var c=Ov(s,r);this._location={x:c.x,y:c.y},this._size=[c.width,c.height],this._orient===$R&&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===QR&&!i?{scaleY:o?1:-1,scaleX:1}:n===QR&&i?{scaleY:o?1:-1,scaleX:-1}:n===$R&&!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 JR({silent:!0,shape:{x:0,y:0,width:t[0],height:t[1]},style:{fill:e.get(`backgroundColor`)},z2:-40}));var i=new JR({shape:{x:0,y:0,width:t[0],height:t[1]},style:{fill:`transparent`},z2:0,onclick:U(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:uc(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 Ps,r=new Um({shape:{points:s},segmentIgnoreThreshold:1,style:t.getModel(`areaStyle`).getAreaStyle(),silent:!0,z2:-20}),i=new Gm({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){V(e.getAxisProxy(i,a).getTargetSeriesModels(),function(e){if(!n&&!(t!==!0&&Wt(tz,e.get(`type`))<0)){var o=r.getComponent(cL(i),a).axis,s=az(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 JR({silent:l,style:{fill:o.get(`fillerColor`)},textConfig:{position:`inside`}});i.add(u),i.add(new JR({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:YR,fill:Z.color.transparent}})),V([0,1],function(t){var a=o.get(`handleIcon`);!dC[a]&&a.indexOf(`path://`)<0&&a.indexOf(`image://`)<0&&(a=`path://`+a);var s=mC(a,-1,0,2,2,null,!0);s.attr({cursor:oz(this._orient),draggable:!0,drift:U(this._onDragMove,this,t),ondragend:U(this._onDragEnd,this),onmouseover:U(this._onOverDataInfoTriggerArea,this,!0),onmouseout:U(this._onOverDataInfoTriggerArea,this,!1),z2:5});var c=s.getBoundingRect(),l=o.get(`handleSize`);this._handleHeight=dc(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(),Ip(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 hf({silent:!0,invisible:!f,style:Tg(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=dc(o.get(`moveHandleSize`),a[1]),p=t.moveHandle=new uf({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=mC(o.get(`moveHandleIcon`),-m/2,-m/2,m,m,Z.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 uf({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:U(this._onActualMoveZoneDrift,this),ondragstart:U(this._onActualMoveZoneDragStart,this),ondragend:U(this._onActualMoveZoneDragEnd,this),onmouseover:U(this._onOverDataInfoTriggerArea,this,!0),onmouseout:U(this._onOverDataInfoTriggerArea,this,!1)})},t.prototype._resetInterval=function(){var e=this._range=this.dataZoomModel.getPercentRange(),t=this._getViewExtent();this._handleEnds=[uc(e[0],[0,100],t,!0),uc(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];_F(t,r,i,n.get(`zoomLock`)?`all`:e,a.minSpan==null?null:uc(a.minSpan,o,i,!0),a.maxSpan==null?null:uc(a.maxSpan,o,i,!0));var s=this._range,c=this._range=_c([uc(r[0],i,o,!0),uc(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=_c(n.slice()),i=this._size;V([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 uf,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=mL(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=[iz(t,0,l,s),iz(t,1,l,s)]}}var p=_c(this._handleEnds.slice());m.call(this,0),m.call(this,1);function m(e){var t=Uh(n.handles[e].parent,this.group),o=Gh(e===0?`right`:`left`,t),s=this._handleWidth/2+ez,c=Wh([p[e]+(e===0?-s:s),this._size[1]/2],t);r[e].setStyle({x:c[0],y:c[1],verticalAlign:i===QR?`middle`:o,align:i===QR?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,kr(r.event);var i=this._displayables.sliderGroup.getLocalTransform(),a=Wh([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 Gr(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();_F(0,a,r,0,o.minSpan==null?null:uc(o.minSpan,i,r,!0),o.maxSpan==null?null:uc(o.maxSpan,i,r,!0)),this._range=_c([uc(a[0],r,i,!0),uc(a[1],r,i,!0)]),this._updateView(),this._dispatchZoomAction(!1)}}}},t.prototype._onBrush=function(e){this._brushing&&(kr(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 JR({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?nz:null,start:t[0],end:t[1]})},t.prototype._findCoordRect=function(){var e,t=uL(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}(vL);function iz(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)?``:pD(r)||dD(r)?r.getLabel({value:Math.round(o)}):isFinite(a)?hc(o,a,!0):o+``;return en(i)?i(o,s):G(i)?i.replace(`{value}`,s):s}function az(e){return{x:`y`,y:`x`,radius:`angle`,angle:`radius`}[e]}function oz(e){return e===`vertical`?`ns-resize`:`ew-resize`}function sz(e){e.registerComponentModel(qR),e.registerComponentView(rz),CL(e)}function cz(e){uk(KR),uk(sz)}R();function lz(e,t,n){var r=bt.createCanvas(),i=t.getWidth(),a=t.getHeight(),o=r.style;return o&&(o.position=`absolute`,o.left=`0`,o.top=`0`,o.width=i+`px`,o.height=a+`px`,r.setAttribute(`data-zr-dom-id`,e)),r.width=i*n,r.height=a*n,r}function uz(e){return!e.__cursors.get(0)}function dz(e){var t=e.__cursors.get(0);return{startIdx:t?t.startIdx:0,endIdx:t?t.endIdx:0}}var fz=function(e){O(t,e);function t(t,n,r){var i=e.call(this)||this;i.motionBlur=!1,i.lastFrameAlpha=.7,i.dpr=1,i.virtual=!1,i.config={},i.zlevel=0,i.zlevel2=0,i.maxRepaintRectCount=5,i.__dirty=!0,i.__firstTimePaint=!0,i.__prevIdx={startIdx:0,endIdx:0};var a;r||=Vo,typeof t==`string`?a=lz(t,n,r):K(t)&&(a=t,t=a.id),i.id=t,i.dom=a;var o=a.style;return o&&(En(a),a.onselectstart=function(){return!1},o.padding=`0`,o.margin=`0`,o.borderWidth=`0`),i.painter=n,i.dpr=r,i}return t.prototype.afterBrush=function(){this.__prevIdx=dz(this)},t.prototype.initContext=function(){this.ctx=this.dom.getContext(`2d`),this.ctx.dpr=this.dpr},t.prototype.setUnpainted=function(){this.__firstTimePaint=!0},t.prototype.createBackBuffer=function(){var e=this.dpr;this.domBack=lz(`back-`+this.id,this.painter,e),this.ctxBack=this.domBack.getContext(`2d`),e!==1&&this.ctxBack.scale(e,e)},t.prototype.createRepaintRects=function(e,t,n,r){if(this.__firstTimePaint)return this.__firstTimePaint=!1,null;var i=[],a=this.maxRepaintRectCount,o=!1,s=new X(0,0,0,0);function c(e){if(!(!e.isFinite()||e.isZero()))if(i.length===0){var t=new X(0,0,0,0);t.copy(e),i.push(t)}else{for(var n=!1,r=1/0,c=0,l=0;l<i.length;++l){var u=i[l];if(u.intersect(e)){var d=new X(0,0,0,0);d.copy(u),d.union(e),i[l]=d,n=!0;break}else if(o){s.copy(e),s.union(u);var f=e.width*e.height,p=u.width*u.height,m=s.width*s.height-f-p;m<r&&(r=m,c=l)}}if(o&&(i[c].union(e),n=!0),!n){var t=new X(0,0,0,0);t.copy(e),i.push(t)}o||=i.length>=a}}for(var l=dz(this),u=l.startIdx;u<l.endIdx;++u){var d=e[u];if(d){var f=d.shouldBePainted(n,r,!0,!0),p=d.__isRendered&&(d.__dirty&1||!f)?d.getPrevPaintRect():null;p&&c(p);var m=f&&(d.__dirty&1||!d.__isRendered)?d.getPaintRect():null;m&&c(m)}}for(var h=this.__prevIdx,u=h.startIdx;u<h.endIdx;++u){var d=t[u],f=d&&d.shouldBePainted(n,r,!0,!0);if(d&&(!f||!d.__zr)&&d.__isRendered){var p=d.getPrevPaintRect();p&&c(p)}}var g;do{g=!1;for(var u=0;u<i.length;){if(i[u].isZero()){i.splice(u,1);continue}for(var _=u+1;_<i.length;)i[u].intersect(i[_])?(g=!0,i[u].union(i[_]),i.splice(_,1)):_++;u++}}while(g);return this._paintRects=i,i},t.prototype.debugGetPaintRects=function(){return(this._paintRects||[]).slice()},t.prototype.resize=function(e,t){var n=this.dpr,r=this.dom,i=r.style,a=this.domBack;i&&(i.width=e+`px`,i.height=t+`px`),r.width=e*n,r.height=t*n,a&&(a.width=e*n,a.height=t*n,n!==1&&this.ctxBack.scale(n,n))},t.prototype.clear=function(e,t,n){var r=this.dom,i=this.ctx,a=r.width,o=r.height;t||=this.clearColor;var s=this.motionBlur&&!e,c=this.lastFrameAlpha,l=this.dpr,u=this;s&&(this.domBack||this.createBackBuffer(),this.ctxBack.globalCompositeOperation=`copy`,this.ctxBack.drawImage(r,0,0,a/l,o/l));var d=this.domBack;function f(e,n,r,a){if(i.clearRect(e,n,r,a),t&&t!==`transparent`){var o=void 0;sn(t)?(o=(t.global||t.__width===r&&t.__height===a)&&t.__canvasGradient||bC(i,t,{x:0,y:0,width:r,height:a}),t.__canvasGradient=o,t.__width=r,t.__height=a):cn(t)&&(t.scaleX=t.scaleX||l,t.scaleY=t.scaleY||l,o=MC(i,t,{dirty:function(){u.setUnpainted(),u.painter.refresh()}})),i.save(),i.fillStyle=o||t,i.fillRect(e,n,r,a),i.restore()}s&&(i.save(),i.globalAlpha=c,i.drawImage(d,e,n,r,a),i.restore())}!n||s?f(0,0,a,o):n.length&&V(n,function(e){f(e.x*l,e.y*l,e.width*l,e.height*l)})},t}(ir),pz=1e5,mz=314159,hz=void 0,gz=1,_z=2;function vz(e){return e?e.__builtin__?!0:!(typeof e.resize!=`function`||typeof e.refresh!=`function`):!1}function yz(e,t){var n=document.createElement(`div`);return n.style.cssText=[`position:relative`,`width:`+e+`px`,`height:`+t+`px`,`padding:0`,`margin:0`,`border-width:0`].join(`;`)+`;`,n}function bz(e,t,n,r){var i=new fz(e,t,t.dpr);return i.zlevel=n,i.zlevel2=r,i.__builtin__=!0,xz(i),i}function xz(e){e.__cursorStack=[],e.__cursors=J()}function Sz(e){return e.startIdx=e.drawIdx=e.endIdx=e.endIdxNew=0,e.used=!1,e.first=e.last=NaN,e.notClearIdx=-1,e}function Cz(e,t){var n=e.__cursors,r=+t;return n.get(r)||(e.__cursorStack.push(r),n.set(r,Sz({key:r})))}function wz(e,t){for(var n=e.__cursorStack,r=0;r<n.length;r++)t(e.__cursors.get(n[r]))}function Tz(e,t){var n=e.layers;return n[t]||(n[t]=[,,,])}function Ez(e,t,n){for(var r=e.layerStack,i=0;i<r.length;i++){var a=r[i].zl,o=r[i].zl2,s=e.layers[a][o];(!n||(!(n&Dz)||s.__builtin__)&&(!(n&Oz)||!s.__builtin__)&&(!(n&kz)||s!==e.hoverlayer))&&t(s,a,o,i)}}var Dz=1,Oz=2,kz=4,Az=Dz|kz,jz=function(){function e(e,t,n,r){this.type=`canvas`,this._prevDisplayList=[],this._layerConfig={},this._needsManuallyCompositing=!1,this.type=`canvas`,this._i={layerStack:[],layers:[]};var i=!e.nodeName||e.nodeName.toUpperCase()===`CANVAS`;if(this._opts=n=B({},n||{}),this.dpr=n.devicePixelRatio||Vo,this._singleCanvas=i,this.root=e,e.style&&(En(e),e.innerHTML=``),this.storage=t,this._prevDisplayList=[],i){var a=e,o=a.width,s=a.height;n.width!=null&&(o=n.width),n.height!=null&&(s=n.height),this.dpr=n.devicePixelRatio||1,a.width=o*this.dpr,a.height=s*this.dpr,this._width=o,this._height=s;var c=bz(a,this,mz,0);c.initContext(),this._insertLayer(c,mz,0,!0),this._domRoot=e}else{this._width=CC(e,0,n),this._height=CC(e,1,n);var l=this._domRoot=yz(this._width,this._height);e.appendChild(l)}}return e.prototype.getType=function(){return`canvas`},e.prototype.isSingleCanvas=function(){return this._singleCanvas},e.prototype.getViewportRoot=function(){return this._domRoot},e.prototype.getViewportRootOffset=function(){var e=this.getViewportRoot();if(e)return{offsetLeft:e.offsetLeft||0,offsetTop:e.offsetTop||0}},e.prototype.refresh=function(e){var t=e&&!K(e)?{paintAll:!!e}:e||{},n=q(t.refresh,!0),r=q(t.refreshHover,!1);if(r&&(this._hoverLayerDirty=_z),!n)return r&&this._paintHoverList(this.storage.getDisplayList(!1)),this;var i=this.storage.getDisplayList(!0);this._updateLayerStatus(i,t.paintAll),this._redrawId=Math.random();var a=this._prevDisplayList;this._paintList(i,a,this._redrawId);var o=this._backgroundColor;return Ez(this._i,function(e,t,n,r){e.refresh&&e.refresh(r===0?o:null)},Oz),this._opts.useDirtyRect&&(this._prevDisplayList=i.slice()),this},e.prototype._paintHoverList=function(e){var t=this._i.hoverlayer,n=this._hoverLayerDirty;if(this._hoverLayerDirty=hz,n!==hz&&(!t&&n===_z&&(t=this._i.hoverlayer=this._ensureLayer(pz)),t)){t.clear();for(var r={inHover:!0,viewWidth:this._width,viewHeight:this._height,beforeBrushParam:{}},i,a=0,o=e.length;a<o;a++){var s=e[a];if(s.__inHover){i||(i=t.ctx,i.save());var c=s.__hoverStyle,l=void 0;c&&(l=s.style,s.style=c),ZC(i,s,r),c&&(s.style=l)}}i&&(QC(i,r),i.restore())}},e.prototype.getHoverLayer=function(){return this._ensureLayer(pz)},e.prototype.paintOne=function(e,t){XC(e,t)},e.prototype._paintList=function(e,t,n){if(this._redrawId===n){var r=this._doPaintList(e,t);if(this._needsManuallyCompositing&&this._compositeManually(),r)Ez(this._i,function(e){e.afterBrush&&e.afterBrush()},Az),this._paintHoverList(e);else{var i=this;Ri(function(){i._paintList(e,t,n)})}}},e.prototype._compositeManually=function(){var e=this._ensureLayer(mz).ctx,t=this._domRoot.width,n=this._domRoot.height;e.clearRect(0,0,t,n),Ez(this._i,function(r){r.virtual&&e.drawImage(r.dom,0,0,t,n)},Dz)},e.prototype._doPaintList=function(e,t){var n=this,r=!0;return Ez(this._i,function(i){var a=!1;if(wz(i,function(e){(e.drawIdx<e.endIdx||e.notClearIdx>=0)&&(a=!0)}),!(!a&&!i.__dirty)){var o=n._opts.useDirtyRect&&!uz(i)?i.createRepaintRects(e,t,n._width,n._height):null,s=n._i.layerStack[0],c=!0;if(i.__dirty){c=!1,i.__dirty=!1;var l=i.zlevel===s.zl&&i.zlevel2===s.zl2?n._backgroundColor:null;i.clear(!1,l,o)}wz(i,function(t){var a=n._paintPerCursor(i,t,e,o,c);r&&=a})}},Az),ft.wxa&&Ez(this._i,function(e){e&&e.ctx&&e.ctx.draw&&e.ctx.draw()}),r},e.prototype._paintPerCursor=function(e,t,n,r,i){var a=e.ctx;if(r)if(!r.length)t.drawIdx=t.endIdx;else for(var o=this.dpr,s=0;s<r.length;++s){var c=r[s];a.save(),a.beginPath(),a.rect(c.x*o,c.y*o,c.width*o,c.height*o),a.clip(),this._paintPerCursorInRect(e,t,n,c,i),a.restore()}else a.save(),this._paintPerCursorInRect(e,t,n,null,i),a.restore();return t.drawIdx>=t.endIdx},e.prototype._paintPerCursorInRect=function(e,t,n,r,i){for(var a={inHover:!1,allClipped:!1,prevEl:null,viewWidth:this._width,viewHeight:this._height,beforeBrushParam:{contentRetained:i}},o=e.ctx,s=uz(e),c=s&&bt.getTime(),l=t.drawIdx,u=t.notClearIdx,d=u>=0?Math.min(u,l):l;d<t.endIdx;d++){var f=n[d];if(!(d<l&&!f.notClear)){if(f.__inHover&&(this._hoverLayerDirty=_z),r!=null){var p=f.getPaintRect();p&&p.intersect(r)&&(ZC(o,f,a),f.setPrevPaintRect(p))}else ZC(o,f,a);if(s&&bt.getTime()-c>15){d++;break}}}QC(o,a),t.drawIdx=Math.max(d,l)},e.prototype.getLayer=function(e,t){return this._ensureLayer(e,0,t)},e.prototype._ensureLayer=function(e,t,n){t||=0;var r=this._singleCanvas;r&&!this._needsManuallyCompositing&&(e=mz,t=0);var i=Tz(this._i,e)[t];return i||(i=bz(`zr_`+e+`.`+t,this,e,t),this._layerConfig[e]&&zt(i,this._layerConfig[e],!0),(n||r&&e!==mz)&&(i.virtual=!0),this._insertLayer(i,e,t,!1),i.initContext()),i},e.prototype.insertLayer=function(e,t){this._insertLayer(t,e,0,!1)},e.prototype._insertLayer=function(e,t,n,r){var i=this._i,a=i.layers,o=i.layerStack,s=this._domRoot,c=null;if(!(a[t]&&a[t][n])&&vz(e)){for(var l=o.length,u=0;u<l&&(o[u].zl<t||o[u].zl===t&&o[u].zl2<n);)u++;if(u>0&&(c=Tz(i,o[u-1].zl)[o[u-1].zl2]),o.splice(u,0,{zl:t,zl2:n}),Tz(i,t)[n]=e,!r&&!e.virtual)if(c){var d=c.dom;d.nextSibling?s.insertBefore(e.dom,d.nextSibling):s.appendChild(e.dom)}else s.firstChild?s.insertBefore(e.dom,s.firstChild):s.appendChild(e.dom);e.painter||=this}},e.prototype.eachLayer=function(e,t){return Ez(this._i,function(n,r){e.call(t,n,r)})},e.prototype.eachBuiltinLayer=function(e,t){return Ez(this._i,function(n,r){e.call(t,n,r)},Dz)},e.prototype.eachOtherLayer=function(e,t){return Ez(this._i,function(n,r){e.call(t,n,r)},Oz)},e.prototype.getLayers=function(){var e={};return Ez(this._i,function(t,n,r){e[t.id]=t}),e},e.prototype._updateLayerStatus=function(e,t){var n=this;if(n._singleCanvas)for(var r=1;r<e.length;r++){var i=e[r];if(i.zlevel!==e[r-1].zlevel||i.incremental){n._needsManuallyCompositing=!0;break}}Ez(n._i,function(e){e.__dirty=!1,wz(e,function(e){e.used=!1,e.endIdxNew=0,e.notClearIdx=-1})},Az);for(var a,o=null,s=null,c=!1,l=0,u=e.length;l<u;l++){var i=e[l],d=i.zlevel,f=i.incremental,p=void 0;if(a!==d&&(a=d,c=!1),f?(c=!0,p=1):p=c?2:0,(!o||d!==o.zlevel||p!==o.zlevel2)&&(o=n._ensureLayer(d,p),s=null,!o.__builtin__)){Lt(`ZLevel `+d+` has been used by unknown layer `+o.id);continue}if((!s||f!==s.key)&&(s=Cz(o,f),!s.used))if(s.used=!0,!t&&s.first===i.id){var m=l-s.startIdx;s.startIdx=l,s.drawIdx+=m,s.endIdx+=m}else o.__dirty=!0,s.first=i.id,s.startIdx=s.drawIdx=l,s.endIdx=l+1;s.endIdxNew=l+1,i.__dirty&1&&!i.__inHover&&((!f||!i.notClear&&l<s.drawIdx)&&(o.__dirty=!0),f&&i.notClear&&s.notClearIdx<0&&(s.notClearIdx=l))}Ez(n._i,function(t){for(var r=t.__cursorStack,i=t.__cursors,a=r.length-1;a>=0;a--){var o=i.get(r[a]);if(!o.used)t.__dirty=!0,i.removeKey(r[a]),r.splice(a,1);else{var s=o.endIdxNew;(uz(t)?s<o.drawIdx:s!==o.endIdx||!s||e[s-1].id!==o.last)&&(t.__dirty=!0),o.endIdx=o.endIdxNew,o.last=s?e[s-1].id:NaN}}t.__dirty&&(wz(t,function(e){e.drawIdx=e.startIdx}),n._hoverLayerDirty===hz&&(n._hoverLayerDirty=gz))},Az)},e.prototype.clear=function(){return Ez(this._i,function(e){e.clear(),xz(e)},Dz),this},e.prototype.setBackgroundColor=function(e){this._backgroundColor=e,Ez(this._i,function(e){e.setUnpainted()})},e.prototype.configLayer=function(e,t){if(t){var n=this._layerConfig;n[e]?zt(n[e],t,!0):n[e]=t,Ez(this._i,function(e,t){zt(e,n[t],!0)})}},e.prototype.delLayer=function(e){for(var t=this._i.layerStack,n=this._i.layers,r=t.length-1;r>=0;r--){var i=t[r];if(i.zl===e){var a=n[e][i.zl2];if(a.__builtin__)continue;if(t.splice(r,1),n[e][i.zl2]=void 0,!a.virtual){var o=a.dom.parentNode;o&&o.removeChild(a.dom)}}}},e.prototype.resize=function(e,t){if(this._domRoot.style){var n=this._domRoot;n.style.display=`none`;var r=this._opts,i=this.root;e!=null&&(r.width=e),t!=null&&(r.height=t),e=CC(i,0,r),t=CC(i,1,r),n.style.display=``,(this._width!==e||t!==this._height)&&(n.style.width=e+`px`,n.style.height=t+`px`,Ez(this._i,function(n){n.resize(e,t)}),this.refresh({paintAll:!0})),this._width=e,this._height=t}else{if(e==null||t==null)return;this._width=e,this._height=t,this._ensureLayer(mz).resize(e,t)}return this},e.prototype.clearLayer=function(e){V(this._i.layers[e],function(e){e&&!e.__builtin__&&e.clear()})},e.prototype.dispose=function(){this.root.innerHTML=``,this.root=this.storage=this._domRoot=this._i=null},e.prototype.getRenderedCanvas=function(e){if(e||={},this._singleCanvas&&!this._compositeManually)return this._i.layers[mz][0].dom;var t=new fz(`image`,this,e.pixelRatio||this.dpr);t.initContext(),t.clear(!1,e.backgroundColor||this._backgroundColor);var n=t.ctx;if(e.pixelRatio<=this.dpr){this.refresh();var r=t.dom.width,i=t.dom.height;Ez(this._i,function(e){e.__builtin__?n.drawImage(e.dom,0,0,r,i):e.renderToCanvas&&(n.save(),e.renderToCanvas(n),n.restore())})}else{for(var a={inHover:!1,viewWidth:this._width,viewHeight:this._height,beforeBrushParam:{}},o=this.storage.getDisplayList(!0),s=0,c=o.length;s<c;s++){var l=o[s];ZC(n,l,a)}QC(n,a)}return t.dom},e.prototype.getWidth=function(){return this._width},e.prototype.getHeight=function(){return this._height},e}();function Mz(e){e.registerPainter(`canvas`,jz)}function Nz(e){if(e==null||!Number.isFinite(e))return`—`;let t=Math.abs(e);return t>=1e9?Pz(e,1e9,`B`):t>=1e6?Pz(e,1e6,`M`):t>=1e3?Pz(e,1e3,`K`):Math.round(e).toLocaleString()}function Pz(e,t,n){let r=e/t,i=Math.abs(r)>=100?0:1;return`${r.toFixed(i)}${n}`}var Fz=`auto`,Iz={speed:1,live:{frameIntervalMs:33,snapshotHz:12},main:{presentationDurationMs:220,chartAppearDurationMs:0,chartUpdateDurationMs:200,easing:`linear`,easingUpdate:`linear`},tail:{enabled:!0,startPercent:.95,durationMs:Fz,durationScale:10,easing:`cubicOut`},daily:{chartAppearDurationMs:Fz,chartUpdateDurationMs:60,easing:Fz,easingUpdate:Fz},bars:{chartAppearDurationMs:Fz,chartUpdateDurationMs:20,easing:Fz,easingUpdate:Fz},donuts:{chartAppearDurationMs:Fz,chartUpdateDurationMs:Fz,easing:Fz,easingUpdate:`linear`,seriesAnimation:!1},heatmap:{popDurationMs:380,settleThreshold:.998,intensityRiseThreshold:.08,whiteThreshold:.88,nearMaxRatio:.985},videoExport:{width:1080,height:864,fps:60,frontloadSettledFrameCount:1,introFadeEnabled:!0,introFadeStartOpacity:.95,introContentStartOpacity:.05,introFadeDurationMs:400,introFadeDelayMs:0,introFadeEasing:`cubicOut`,startHoldDurationMs:100,replayDurationMs:1e4,tailDurationMs:5e3,replayEasing:`cubicInOut`,tailSourceFraction:.55,tailEasing:`cubicOut`,finalHoldDurationMs:5e3,finalFlashDurationMs:1e3,finalFlashDelayMs:200,finalFlashMaxOpacity:.35,displayTweenStartMs:200,displayTweenBaseMs:240,displayTweenLateMs:420,displayTweenLateWindowMs:2200,chartIntroWindowMs:2200,barsChartIntroUpdateDurationMs:320,barsChartUpdateDurationMs:50,barsChartTailUpdateDurationMs:240,donutsChartIntroUpdateDurationMs:360,donutsChartUpdateDurationMs:50,donutsChartTailUpdateDurationMs:240,supersampleScale:2,captureFormat:`png`,jpegQuality:92,crf:5,encoderPreset:`veryfast`}},Lz={animationDuration:750,animationDurationUpdate:220,animationEasing:`cubicOut`,animationEasingUpdate:`cubicOut`},Rz={show:!0,animationDuration:250,animationDurationUpdate:220,animationDelay:250,animationDelayUpdate:180,animationEasing:`cubicOut`,animationEasingUpdate:`cubicOut`},zz={...Lz,animationDurationUpdate:200,animationDelayUpdate:0,animationEasingUpdate:`cubicOut`},Bz={animationDuration:700,animationDurationUpdate:220,animationDelay:250,animationDelayUpdate:140,animationEasing:`cubicOut`,animationEasingUpdate:`cubicOut`},Vz={...Rz,animationDelay:950,animationDelayUpdate:360};function Hz(e){return Number.isFinite(e)&&e>0?e:1}function Uz(e){return Math.max(0,Math.round(e/Hz(Iz.speed)))}function Wz(e,t){return e===`auto`?Uz(t):e}function Gz(e,t){return e===`auto`?t:e}function Kz(e){return{animation:!0,animationDuration:Wz(e.chartAppearDurationMs,Iz.main.chartAppearDurationMs),animationDurationUpdate:Wz(e.chartUpdateDurationMs,Iz.main.chartUpdateDurationMs),animationEasing:Gz(e.easing,Iz.main.easing),animationEasingUpdate:Gz(e.easingUpdate,Iz.main.easingUpdate)}}var qz=Uz(Iz.main.presentationDurationMs);function Jz(e=0,t=!1){let n=qz,r=Iz.tail;if(!t||!r?.enabled)return n;let i=Math.min(Math.max(r.startPercent??.9,0),.999),a=Math.min(Math.max(e||0,0),1);if(a<=i)return n;let o=(a-i)/Math.max(1-i,.001),s=r.durationMs===`auto`?Math.round(n*Math.max(r.durationScale||1,1)):r.durationMs;return Math.round(n+(s-n)*tB(o))}function Yz(e=0,t=!1){let n=Iz.tail;if(!t||!n?.enabled)return`linear`;let r=Math.min(Math.max(n.startPercent??.9,0),.999);return Math.min(Math.max(e||0,0),1)<=r?`linear`:n.easing||`cubicOut`}function Xz(e=0,t=!1){let n=Iz.tail;if(!t||!n?.enabled)return!1;let r=Math.min(Math.max(n.startPercent??.9,0),.999);return Math.min(Math.max(e||0,0),1)>r}Kz({chartAppearDurationMs:Fz,chartUpdateDurationMs:Fz,easing:Fz,easingUpdate:Fz});var Zz=Kz(Iz.daily),Qz=Kz(Iz.bars),$z=Kz(Iz.donuts),eB=Iz.donuts.seriesAnimation;function tB(e){return 1-(1-Math.min(Math.max(e,0),1))**3}function nB(e){return(Array.isArray(e?.data)?e.data:Array.isArray(e)?e:[]).slice().sort((e,t)=>String(e?.date||``).localeCompare(String(t?.date||``)))}function rB(e,t=`model`){return t===`family`?e?.by_family||{}:t===`repo`?e?.by_repo||{}:e?.by_model||{}}function iB(e,t=`tokens`){return e?t===`elapsed_seconds`?e.elapsed_seconds||0:t===`cost`?e.cost||0:e.tokens||0:0}function aB(e,{split:t=`model`,metric:n=`tokens`,dates:r=null}={}){let i=nB(e);if(!i.length)return{dates:[],groups:[],series:[],dayTotals:[]};let a=r||i.map(e=>e.date),o=new Map(i.map(e=>[e.date,e])),s=[],c=new Set;for(let e of a){let r=rB(o.get(e),t);for(let[e,t]of Object.entries(r))c.has(e)||iB(t,n)<=0||(c.add(e),s.push(e))}let l=s.map(e=>({key:e,label:e,data:a.map(r=>iB(rB(o.get(r),t)[e],n))}));return{dates:a,groups:s,series:l,dayTotals:a.map((e,t)=>l.reduce((e,n)=>e+(n.data[t]||0),0))}}function oB(e,t,n){return e+(t-e)*n}function $(e){return Number.isFinite(e)?e:0}function sB(e){return Math.max(0,Math.min(1,e))}function cB(e,t){return e?.length?t?0:e.length-1:0}function lB(e,t,n=0){if(!e?.length)return 0;if(!t)return e.length-1;let r=cB(e,t),i=e.length-1,a=sB(((n||0)-.08)/.92)**.82,o=r+(i-r)*a;return Math.max(r,Math.min(i,Math.floor(o+32)))}function uB(e,t){return Array.isArray(e?.data)?e.data:Array.isArray(e)?e:e?.data?.[t]||e?.data?.total||[]}function dB(e,t){return t?.length?e===`d7`?t.slice(-7):e===`d30`?t.slice(-30):t:[]}function fB(e,t,n){return e.map(e=>({key:e?.[t]||``,label:e?.[n]||``,tokens:$(e?.tokens)})).filter(e=>e.key)}function pB(e,t){let n=nB(e);if(!n.length)return{dates:[],series:[]};let r=dB(t,n.map(e=>e.date)),{series:i}=aB(e,{split:`model`,metric:`tokens`,dates:r});return{dates:r,series:i}}function mB(e,t){let n=nB(e);if(!n.length)return[];let r=new Set(dB(t,n.map(e=>e.date)));return n.filter(e=>r.has(e.date))}function hB(e,t){let n=mB(e,t);return{tokens:n.reduce((e,t)=>e+$(t?.tokens),0),elapsed:n.reduce((e,t)=>e+$(t?.elapsed_seconds),0),cost:n.reduce((e,t)=>e+$(t?.cost),0),days:n.length||1}}function gB(e,t,n){let r={};for(let[i,a]of Object.entries(e||{})){r[i]={};for(let e of n)r[i][e]=$(a?.[e])*t}return r}function _B(e,t){return t>=.999?e:{...e,tokens:$(e?.tokens)*t,elapsed_seconds:$(e?.elapsed_seconds)*t,cost:$(e?.cost)*t,sessions:$(e?.sessions)*t,by_model:gB(e?.by_model,t,[`tokens`,`cost`,`elapsed_seconds`]),by_family:gB(e?.by_family,t,[`tokens`,`cost`,`elapsed_seconds`,`sessions`]),by_repo:gB(e?.by_repo,t,[`tokens`,`cost`,`elapsed_seconds`,`sessions`])}}function vB(e,t){let n=nB(e);if(!n.length)return[];let r=n.length-1,i=Math.max(0,Math.min(r,Number.isFinite(t)?t:r)),a=Math.floor(i),o=Math.min(r,Math.ceil(i)),s=i-a;return n.slice(0,o+1).map((e,t)=>t<=a?e:_B(e,s))}function yB(e,t,n){let r=new Map;for(let i of e)for(let[e,a]of Object.entries(i?.[t]||{}))r.has(e)||r.set(e,{key:e,label:e,[n]:e,tokens:0}),r.get(e).tokens+=$(a?.tokens);return[...r.values()].sort((e,t)=>t.tokens-e.tokens)}function bB({daily:e,range:t,cursor:n,fallback:r}){let i=vB(e,n),a=t===`d7`?i.slice(-7):t===`d30`?i.slice(-30):i;if(!a.length)return r;let o={...r?.stats||{},tokens:a.reduce((e,t)=>e+$(t?.tokens),0),elapsed:a.reduce((e,t)=>e+$(t?.elapsed_seconds),0),cost:a.reduce((e,t)=>e+$(t?.cost),0),sessions:a.reduce((e,t)=>e+$(t?.sessions),0),days:a.length||1};return{...r||{},ready:!0,stats:o,topRepos:yB(a,`by_repo`,`repo_label`).slice(0,6),topFamilies:yB(a,`by_family`,`family`),topModels:yB(a,`by_model`,`model_name`).slice(0,6)}}function xB(e){let t=e?.data&&typeof e.data==`object`?e.data:{},n={};for(let[e,r]of Object.entries(t))n[e]={tokens:$(r?.tokens),elapsed:$(r?.elapsed),cost:$(r?.cost)};return n}function SB({overview:e,heatmap:t,daily:n,families:r,repos:i,models:a,range:o}){let s=e?.data;if(!s)return{ready:!0,stats:{tokens:0,elapsed:0,cost:0,sessions:0,enriched:0,priced:0,exactPriced:0,fallbackPriced:0,unpriced:0,days:1},topRepos:[],topFamilies:[],topModels:[],daily:{dates:[],series:[]},heatmap:{}};let c=s?.[o]||s?.total||{},l=c.coverage||{},u=$(l.thread_rows??l.total),d=$(l.root_sessions??c.total_sessions),f=$(l.priced),p=$(l.priced_exact),m=$(l.priced_fallback),h=$(l.unpriced??Math.max(u-f,0)),g=c.date_range,_=g?.from!=null&&g?.to!=null?Math.max(1,Math.ceil((g.to-g.from)/86400)):1,v=hB(n,o),y=o===`d7`||o===`d30`;return{ready:!0,stats:{tokens:y?v.tokens:$(c.total_tokens),elapsed:y?v.elapsed:$(c.total_elapsed_seconds),cost:y?v.cost:$(c.total_cost),sessions:d,enriched:$(l.enriched),priced:f,exactPriced:p,fallbackPriced:m,unpriced:h,days:y?v.days:_},topRepos:fB(uB(i,o).slice(0,6),`repo_label`,`repo_label`),topFamilies:fB(uB(r,o),`family`,`family`),topModels:fB(uB(a,o).slice(0,6),`model_name`,`model_name`),daily:pB(n,o),heatmap:xB(t)}}function CB(e,t,n){let r=new Map((e||[]).map(e=>[e.key,e])),i=new Map((t||[]).map(e=>[e.key,e])),a=[],o=new Set;for(let e of t||[])o.has(e.key)||(o.add(e.key),a.push(e.key));for(let t of e||[])o.has(t.key)||(o.add(t.key),a.push(t.key));let s=[];for(let e of a){let t=r.get(e),a=i.get(e),o=a?.label||t?.label||e,c=oB($(t?.tokens),$(a?.tokens),n);c<=.001&&!a||s.push({key:e,label:o,tokens:c})}return s}function wB(e,t,n){let r=(t?.dates?.length?t.dates:e?.dates||[]).slice(),i=new Map((e?.series||[]).map(e=>[e.key,e])),a=new Map((t?.series||[]).map(e=>[e.key,e])),o=new Set([...i.keys(),...a.keys()]),s=[];for(let c of o){let o=i.get(c),l=a.get(c),u=new Map((o?.data||[]).map((t,n)=>[e?.dates?.[n],t])),d=new Map((l?.data||[]).map((e,n)=>[t?.dates?.[n],e])),f=r.map(e=>oB($(u.get(e)),$(d.get(e)),n));f.every(e=>e<=.001)&&!l||s.push({key:c,label:l?.label||o?.label||c,data:f})}return{dates:r,series:s}}function TB(e){return{dates:e.dates,series:(e.series||[]).map(e=>({key:e.key,label:e.label,data:e.data.map(()=>0)}))}}function EB(e,t,n){let r=new Set([...Object.keys(e||{}),...Object.keys(t||{})]),i={};for(let a of r){let r=e?.[a],o=t?.[a];i[a]={tokens:oB($(r?.tokens),$(o?.tokens),n),elapsed:oB($(r?.elapsed),$(o?.elapsed),n),cost:oB($(r?.cost),$(o?.cost),n)}}return i}function DB(e,t,n){return{ready:t.ready,stats:{tokens:oB($(e?.stats?.tokens),$(t?.stats?.tokens),n),elapsed:oB($(e?.stats?.elapsed),$(t?.stats?.elapsed),n),cost:oB($(e?.stats?.cost),$(t?.stats?.cost),n),sessions:oB($(e?.stats?.sessions),$(t?.stats?.sessions),n),enriched:oB($(e?.stats?.enriched),$(t?.stats?.enriched),n),priced:oB($(e?.stats?.priced),$(t?.stats?.priced),n),exactPriced:oB($(e?.stats?.exactPriced),$(t?.stats?.exactPriced),n),fallbackPriced:oB($(e?.stats?.fallbackPriced),$(t?.stats?.fallbackPriced),n),unpriced:oB($(e?.stats?.unpriced),$(t?.stats?.unpriced),n),days:$(t?.stats?.days)||1},topRepos:CB(e?.topRepos,t?.topRepos,n),topFamilies:CB(e?.topFamilies,t?.topFamilies,n),topModels:CB(e?.topModels,t?.topModels,n),daily:wB(e?.daily,t?.daily,n),heatmap:EB(e?.heatmap,t?.heatmap,n)}}function OB(e,{duration:t=qz,onSettledChange:n,ingestProgress:r=0,isIngestActive:i=!1,clockNowMs:a=null}={}){let o=(0,b.useMemo)(()=>SB(e),[e.overview,e.heatmap,e.daily,e.families,e.repos,e.models,e.range]),[s,c]=(0,b.useState)(o),l=(0,b.useRef)(o),u=(0,b.useRef)(o),d=(0,b.useRef)(0),f=(0,b.useRef)(0),p=(0,b.useRef)(s),m=(0,b.useRef)(!0),h=(0,b.useRef)(n),g=(0,b.useRef)(0),_=(0,b.useRef)(o),v=(0,b.useRef)(o),y=(0,b.useRef)(`smooth`),x=(0,b.useRef)(i);(0,b.useEffect)(()=>{h.current=n},[n]);let S=e=>{m.current!==e&&(m.current=e,h.current?.(e))};(0,b.useEffect)(()=>{p.current=s},[s]);let C=e=>{l.current=e,u.current=e,p.current=e,c(e),S(!0),f.current=0,g.current=0,_.current=e,v.current=e},w=e=>{u.current=e,S(!1);let t=Xz(r,i)?`tail`:`smooth`;y.current!==t&&(y.current=t,g.current=0),t===`tail`&&(_.current=l.current,v.current=e,g.current=0)},T=(e,n)=>{e<f.current&&(f.current=0,g.current=0,_.current=l.current,v.current=n),f.current||=e;let a=Math.max(1,e-f.current);f.current=e;let o=Jz(r,i)||t,s=l.current,u=Xz(r,i)?`tail`:`smooth`;y.current!==u&&(y.current=u,g.current=0);let d,m;if(u===`tail`){v.current!==n&&(_.current=s,v.current=n,g.current=e),g.current||=e;let t=Math.max(0,e-g.current),a=Math.min(1,t/Math.max(o,1)),c=kB(a,Yz(r,i));d=DB(_.current,v.current,c),m=a>=1||AB(d,n)<=.002}else{let e=kB(1-Math.exp(-a/Math.max(o,1)),Yz(r,i));d=DB(s,n,e),m=e>=.999||AB(d,n)<=.002}return l.current=d,m?(l.current=n,p.current=n,c(n),S(!0),g.current=0,_.current=n,v.current=n,n):(p.current=d,c(d),d)};return(0,b.useLayoutEffect)(()=>{let e=x.current&&!i;x.current=i,e&&C(o)},[i,o]),(0,b.useLayoutEffect)(()=>{if(a!=null){if(t<=0){C(o);return}w(o),T(a,o)}},[o,t,r,i,a]),(0,b.useEffect)(()=>{if(a!=null)return;if(u.current=o,t<=0){C(o);return}if(l.current===o&&m.current||(w(o),d.current))return;let e=t=>{if(T(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,b.useEffect)(()=>()=>{d.current&&cancelAnimationFrame(d.current),d.current=0,f.current=0},[]),s}function kB(e,t){let n=Math.min(Math.max(e,0),1);return t===`cubicOut`?1-(1-n)**3:n}function AB(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=jB(e.topRepos,t.topRepos),i=jB(e.topFamilies,t.topFamilies),a=jB(e.topModels,t.topModels),o=MB(e.daily,t.daily);return Math.max(n,r,i,a,o)/Math.max(1,t.stats?.tokens||1)}function jB(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 MB(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}function NB(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||0);n+=1)r=Math.max(r,Math.abs((t?.data?.[n]||0)-(e.data[n]||0)))}return r}function PB(e){let t=0;for(let n of e?.series||[])for(let e of n.data||[])t=Math.max(t,Math.abs(e||0));return t}function FB(e,t,n=``){let[r,i]=(0,b.useState)(e),a=(0,b.useRef)(e),o=(0,b.useRef)(e),s=(0,b.useRef)(0),c=(0,b.useRef)(0),l=(0,b.useRef)(n),u=(0,b.useRef)(t),d=t&&l.current!==n;return(0,b.useLayoutEffect)(()=>{o.current=e;let r=!u.current&&t;if(u.current=t,!t){s.current&&cancelAnimationFrame(s.current),s.current=0,c.current=0,a.current=e,l.current=n;return}if(l.current!==n){s.current&&cancelAnimationFrame(s.current),s.current=0,c.current=0;let t=TB(e);a.current=t,i(t),l.current=n;return}r&&(a.current=e,i(e))},[e,t,n]),(0,b.useEffect)(()=>{if(o.current=e,!t)return;let n=qz,r=e=>{let t=o.current;c.current||=e;let l=Math.max(1,e-c.current);c.current=e;let u=1-Math.exp(-l/Math.max(n,1)),d=wB(a.current,t,u);a.current=d,i(d);let f=Math.max(1,PB(t));if(NB(d,t)<=f*.002||u>=.999){a.current=t,i(t),s.current=0,c.current=0;return}s.current=requestAnimationFrame(r)};s.current||=(c.current=0,requestAnimationFrame(r))},[e,t,n]),(0,b.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current),s.current=0,c.current=0},[]),t?d?TB(e):r:e}function IB(e,t){if(!e||!t)return null;let n=Date.parse(`${e}T00:00:00Z`),r=Date.parse(`${t}T00:00:00Z`);return!Number.isFinite(n)||!Number.isFinite(r)?null:Math.round((r-n)/864e5)}function LB(){if(typeof window>`u`)return!1;try{return new URLSearchParams(window.location.search).has(`debugLive`)||window.localStorage?.getItem(`codexmeter.debugLive`)===`1`||window.__CODEXMETER_DEBUG_LIVE__===!0}catch{return!1}}function RB(e,t=null){let n=(Array.isArray(e?.dates)&&Array.isArray(e?.series)?e.dates.map((t,n)=>({date:t,tokens:e.series.reduce((e,t)=>e+(t?.data?.[n]||0),0)})):Array.isArray(e?.data)?e.data:Array.isArray(e)?e:Object.entries(e||{}).map(([e,t])=>({date:e,...t}))).filter(e=>e?.date).sort((e,t)=>String(e.date).localeCompare(String(t.date))),r=n.filter(e=>(e.tokens||0)>0||(e.sessions||0)>0),i=n[0]?.date||null,a=n[n.length-1]?.date||null,o=r[r.length-1]?.date||null;return{days:n.length,nonzeroDays:r.length,first:i,last:a,lastNonzero:o,currentDateBucket:t,overreachDays:t&&o?Math.max(0,IB(t,o)||0):0,totalTokens:Math.round(n.reduce((e,t)=>e+(t.tokens||0),0))}}function zB(e,t=null){let n=Object.entries(e||{}).map(([e,t])=>({date:e,tokens:t?.tokens||0,sessions:t?.sessions||0,elapsed:t?.elapsed||0,cost:t?.cost||0})).filter(e=>e.date).sort((e,t)=>String(e.date).localeCompare(String(t.date))),r=n.filter(e=>e.tokens>0||e.sessions>0||e.elapsed>0||e.cost>0),i=n[0]?.date||null,a=n[n.length-1]?.date||null,o=r[r.length-1]?.date||null;return{days:n.length,nonzeroDays:r.length,first:i,last:a,lastNonzero:o,currentDateBucket:t,overreachDays:t&&o?Math.max(0,IB(t,o)||0):0,totalTokens:Math.round(n.reduce((e,t)=>e+t.tokens,0))}}function BB(e){return{seq:e?.seq,phase:e?.progress?.phase,percent:Number(((e?.progress?.percent||0)*100).toFixed(1)),enriched:e?.progress?.enriched,needs:e?.progress?.needs_enrichment,complete:!!e?.progress?.complete,daily:RB(e?.data?.daily||{},e?.progress?.current_date_bucket||null)}}function VB(e,t=null){return{seq:e?.seq,ingestId:e?.ingest_id,daily:RB(e?.daily||{},t?.current_date_bucket||null)}}function HB(e,t){LB()&&console.debug(`[codexmeter:live] ${e}`,t)}uk([FN,iP,zI,nR,aR,jR,Mz]);function UB(e){return Nz(e)}function WB(e){return e==null?`—`:e>=1e3?`$`+(e/1e3).toFixed(1)+`K`:`$`+e.toFixed(2)}function GB(e){return e?(e/3600).toFixed(1)+`h`:`0h`}function KB(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(`
|
|
28
|
+
`)}function qB(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 JB(e){let{dates:t,series:n}=aB(e,{split:`model`,metric:`tokens`});return{dates:t,series:n}}function YB(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 XB(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 ZB(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 QB(e,t){return!e||!t?e||{}:Object.fromEntries(Object.entries(e).filter(([e])=>String(e)<=String(t)))}function $B(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 eV(e,{ingestProgress:t=0,isIngestActive:n=!1}={}){let r=(0,b.useRef)({dates:[],series:[]}),i=(0,b.useMemo)(()=>n?(r.current=$B(r.current,e),r.current):(r.current=e||{dates:[],series:[]},r.current),[e,n]),a=(0,b.useMemo)(()=>lB(i?.dates||[],n,t),[i?.dates,t,n]),[o,s]=(0,b.useState)(()=>cB(i?.dates||[],n)),c=YB(a,o,i?.dates?.length||0,n),l=!!(n&&(i?.dates?.length||0)>0&&o>=i.dates.length-1-.01),[u,d]=(0,b.useState)(0),f=(0,b.useRef)(o),p=(0,b.useRef)(0),m=(0,b.useRef)(i?.dates||[]),h=(0,b.useRef)(0),g=(0,b.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,b.useLayoutEffect)(()=>{let e=i?.dates||[],t=m.current||[];if(t===e||(m.current=e,!n))return;let r=ZB(t,e,f.current);Math.abs(r-f.current)<.001||(f.current=r,s(r))},[i?.dates,n]),(0,b.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=YB(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,b.useEffect)(()=>()=>{cancelAnimationFrame(h.current),h.current=0},[]),{daily:(0,b.useMemo)(()=>XB(i,o),[i,o]),cursor:o,rawTargetIndex:a,sourceDaily:i,speedDaysPerSecond:u,targetIndex:c,waitingForDailyData:l}}function tV(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 nV(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 rV(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 iV(e,t){return e.map(e=>({...e,tokens:Math.max(0,(e.tokens||0)*t)}))}function aV(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 oV(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 sV({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,z.jsx)(cV,{sourceDaily:l,elasticDaily:n,range:r,isIngestActive:i,currentDateBucket:a,exportMode:o,exportPlayback:s,onDayClick:c}):(0,z.jsxs)(`div`,{className:`overview-daily-spark overview-daily-spark-empty`,children:[(0,z.jsx)(`span`,{className:`overview-daily-spark-title`,children:`Daily Usage`}),(0,z.jsx)(`span`,{className:`overview-daily-spark-empty-text`,children:`No daily data`})]})}function cV({sourceDaily:e,elasticDaily:t=null,range:n=`total`,isIngestActive:r=!1,currentDateBucket:i=null,exportMode:a=!1,exportPlayback:o=!1,onDayClick:s}){let c=t||{daily:e,cursor:e.dates.length-1,rawTargetIndex:e.dates.length-1,sourceDaily:e,targetIndex:e.dates.length-1},l=c.daily,u=!a&&!o&&r,d=(0,b.useMemo)(()=>tV(n,l.dates.length,c.cursor,u),[n,l.dates.length,c.cursor,u]),[f,p]=(0,b.useState)(()=>tV(n,l.dates.length)),m=(0,b.useRef)(d),h=(0,b.useRef)(u),g=(0,b.useRef)(f),_=(0,b.useRef)(0),v=FB(l,u,`overview-daily-spark`),y=u?d:h.current?m.current:f;g.current=y,(0,b.useEffect)(()=>{if(u){m.current=d,h.current=!0;return}let e=tV(n,l.dates.length);return h.current&&=(g.current=m.current,p(m.current),!1),nV(g.current,e,p,_,220)},[u,d,n,l.dates.length]),(0,b.useEffect)(()=>()=>{cancelAnimationFrame(_.current),_.current=0},[]);let{startValue:x,endValue:S}=y,C=Math.max(1,S-x+1||l.dates.length),{barWidth:w,barMaxWidth:T}=qB(C),E=u,D=Math.max(-.5,x-.5),O=Math.max(D+1,S+.5),k=e=>l.dates[Math.max(0,Math.min(l.dates.length-1,Math.round(e)))],A=(0,b.useRef)(``);(0,b.useEffect)(()=>{let t=RB(e,i),n=RB(l,i),r=Math.round(x),a=Math.round(S),o=[i,c.targetIndex,t.days,t.lastNonzero,t.overreachDays,n.days,n.lastNonzero,n.overreachDays,r,a].join(`|`);o!==A.current&&(A.current=o,HB(`dailySpark.present`,{currentDateBucket:i,cursor:Number(c.cursor.toFixed(2)),targetIndex:c.targetIndex,rawTargetIndex:c.rawTargetIndex,lagDays:Number((c.targetIndex-c.cursor).toFixed(2)),source:t,presentationSource:RB(c.sourceDaily,i),display:n,zoom:{startValue:Number(x.toFixed(2)),endValue:Number(S.toFixed(2)),visibleDateCount:Number(C.toFixed(2))}}))},[i,c.cursor,c.targetIndex,e,l,x,S,C]);let j={backgroundColor:`transparent`,...Zz,tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{if(!e?.length)return``;let t=`<b>${k(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}: ${UB(r)}<br/>`,n+=r}return t+=`<b>Total: ${UB(n)}</b>`,t}},grid:{left:4,right:4,top:4,bottom:4},xAxis:E?{type:`value`,min:D,max:O,show:!1}:{type:`category`,data:v.dates||l.dates,min:Math.max(0,Math.floor(x)),max:Math.max(0,Math.floor(S)),show:!1},yAxis:{type:`value`,show:!1,scale:!1,min:0},series:v.series.map(e=>({id:`overview-daily-${e.key}`,name:e.label,type:`bar`,stack:`total`,data:E?e.data.map((e,t)=>[t,e]):e.data,itemStyle:{color:Ue(e.key)},...w?{barWidth:w}:{},barMaxWidth:T}))},ee=s&&!a&&!o?{click:e=>{let t=Array.isArray(e?.data)?e.data[0]:e?.dataIndex,n=Number.isFinite(t)?k(t):e?.axisValue||e?.name;n&&s(n)}}:void 0;return(0,z.jsxs)(`div`,{className:`overview-daily-spark`,children:[(0,z.jsx)(`span`,{className:`overview-daily-spark-title`,children:`Daily Usage`}),(0,z.jsx)(`div`,{className:`overview-daily-spark-chart`,style:ee?{cursor:`pointer`}:void 0,children:(0,z.jsx)(Ae,{echarts:VA,option:j,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!1,notMerge:a,replaceMerge:[`series`],onEvents:ee})})]})}var lV=[{key:`tokens`,label:`Tokens`,fmt:UB},{key:`elapsed`,label:`Time`,fmt:e=>GB(e)},{key:`cost`,label:`Cost`,fmt:WB}],uV=Iz.heatmap?.popDurationMs??380,dV=Iz.heatmap?.settleThreshold??.998;function fV({heatmapData:e,isIngestActive:t=!1,ingestProgress:n=0,currentDateBucket:r=null,onDayClick:i,interactive:a=!0}){let[o,s]=(0,b.useState)(`tokens`),[c,l]=(0,b.useState)(new Set),[u,d]=(0,b.useState)(new Set),f=(0,b.useRef)({}),p=(0,b.useRef)(1),m=(0,b.useRef)(``),h=e||{};(0,b.useEffect)(()=>{let e=zB(h,r),t=[e.currentDateBucket,e.nonzeroDays,e.lastNonzero,e.overreachDays,e.totalTokens].join(`|`);t!==m.current&&(m.current=t,HB(`heatmap.present`,e))},[h,r]);let g=new Date,_=[],v=[];for(let e=364;e>=0;e--){let t=new Date(g);t.setDate(t.getDate()-e);let n=t.toLocaleDateString(`en-CA`),r=h[n]&&h[n][o]||0;_.push({key:n,val:r,date:t}),t.getDate()===1&&v.push({idx:364-e,label:t.toLocaleDateString(`en-US`,{month:`short`})})}let y=Math.max(..._.map(e=>e.val),1);(0,b.useEffect)(()=>{if(!t||n>=dV){f.current={},p.current=1;return}let e=new Date,r=f.current,i=p.current,a=new Set,s=new Set,c=Math.max(.05,Math.min(i,y)*.002),u=Iz.heatmap?.intensityRiseThreshold??.08,m=Iz.heatmap?.whiteThreshold??.88,g=Iz.heatmap?.nearMaxRatio??.985;for(let t=364;t>=0;t--){let n=new Date(e);n.setDate(n.getDate()-t);let l=n.toLocaleDateString(`en-CA`),d=h[l]&&h[l][o]||0,f=r[l]??0,p=i>0?f/i:0,_=y>0?d/y:0,v=y>i+c&&d>=y*g&&(f<y*g||f===void 0),b=_>=m&&p<m,x=d>f+c,S=_>p+u;v||b||x||S?a.add(l):(d<f-c||d>0&&i>0&&y>i+c&&p>=.85&&_<p-.02)&&s.add(l),r[l]=d}if(p.current=y,a.size>0||s.size>0){l(a),d(s);let e=setTimeout(()=>{l(new Set),d(new Set)},uV);return()=>clearTimeout(e)}},[h,o,t,n,y]);function x(e){if(e===0)return`var(--bg-elevated)`;let t=e/y,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 S=_[0]?.date.getDay()||0,C=Array(S).fill(null).concat(_);return(0,z.jsxs)(`div`,{className:`heatmap-wrap`,children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:`0.75rem`},children:[(0,z.jsx)(`span`,{className:`chart-title`,children:`Activity`}),(0,z.jsx)(`div`,{className:`btn-group`,children:lV.map(e=>(0,z.jsx)(`button`,{className:`btn ${o===e.key?`active`:``}`,onClick:()=>s(e.key),children:e.label},e.key))})]}),(0,z.jsx)(`div`,{className:`heatmap-grid`,style:{gridTemplateRows:`repeat(7, 1fr)`},children:C.map((e,t)=>e?(0,z.jsx)(`div`,{role:i&&a?`button`:void 0,tabIndex:i&&a?0:void 0,onClick:i&&a?()=>i(e.key):void 0,onKeyDown:i&&a?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),i(e.key))}:void 0,className:`heatmap-cell ${e.val>0?`active`:``} ${c.has(e.key)?`heatmap-cell-pop`:``} ${u.has(e.key)?`heatmap-cell-pop-dim`:``}`,style:{background:x(e.val),cursor:i&&a?`pointer`:void 0},title:`${e.key}: ${lV.find(e=>e.key===o).fmt(e.val)}`},e.key):(0,z.jsx)(`div`,{className:`heatmap-cell`,style:{visibility:`hidden`}},`pad-${t}`))}),(0,z.jsx)(`div`,{className:`heatmap-labels`,children:v.slice(-12).map((e,t)=>(0,z.jsx)(`span`,{children:e.label},t))})]})}function pV(e){return e.presentation?.ready?(0,z.jsx)(mV,{...e}):null}function mV({presentation:e,rawPresentation:t=null,fullDaily:n=null,sourceDailyRows:r=null,range:i=`total`,ingestProgress:a=0,isIngestActive:o=!1,currentDateBucket:s=null,exportMode:c=!1,exportPlayback:l=!1,exportPhase:u=null,exportSeekMs:d=0,exportDaily:f=null,exportDailyTiming:p=null,onDailyDebugStatsChange:m=null,onPresentationDateRangeChange:h=null,onNavigateToDailyDay:g,onNavigateToRepo:_,onNavigateToModel:v}){let y=l?vV(d):1,x=l&&u===`replay`&&t?.ready?t:e,S=l&&t?.daily||e.daily,C=l&&S?.dates?.length?S:n,w=!c&&!l&&o,T=eV(C,{ingestProgress:a,isIngestActive:w});(0,b.useEffect)(()=>{m?.(w?{speedDaysPerSecond:T.speedDaysPerSecond,waitingForDailyData:T.waitingForDailyData}:null)},[w,T.speedDaysPerSecond,T.waitingForDailyData,m]),(0,b.useEffect)(()=>()=>m?.(null),[m]);let E=T.daily?.dates||[],D=E[E.length-1]||s,O=dB(i,E),k={from:O[0]||D,to:O[O.length-1]||D};(0,b.useEffect)(()=>{h?.(w?k:null)},[w,h,k.from,k.to]),(0,b.useEffect)(()=>()=>h?.(null),[h]);let A=o&&t?.heatmap?t.heatmap:e.heatmap,j=o&&!l?D:s,ee=o&&j&&!l?QB(A,j):A||{},M=(0,b.useMemo)(()=>w?bB({daily:r,range:i,cursor:T.cursor,fallback:x}):x,[x,w,T.cursor,i,r]),{stats:N,topRepos:P,topFamilies:F,topModels:I}=M,te=l&&u===`replay`?iV(aV(t?.topRepos||x.topRepos||[],e.topRepos||x.topRepos||[]),y):M.topRepos||[],ne=l&&u===`replay`?iV(aV(t?.topFamilies||x.topFamilies||[],e.topFamilies||x.topFamilies||[]),y):M.topFamilies||[],re=l&&u===`replay`?iV(aV(t?.topModels||x.topModels||[],e.topModels||x.topModels||[]),y):M.topModels||[],ie=[...te.slice(0,6)].reverse(),ae=Math.max(...te.slice(0,6).map(e=>e.tokens||0),1),oe=[...ne].sort((e,t)=>String(e.label).localeCompare(String(t.label))),se=[...re.slice(0,6)].sort((e,t)=>String(e.label).localeCompare(String(t.label))),ce=!c&&!l&&!o,L=bV(d,l),le=!c&&!l&&eB,ue=l?yV(d,Iz.videoExport?.barsChartIntroUpdateDurationMs,Iz.videoExport?.barsChartUpdateDurationMs,u===`tail`||u===`final_hold`?Iz.videoExport?.barsChartTailUpdateDurationMs:null):0,de={backgroundColor:`transparent`,...Qz,...c?{animation:!1}:{},...l?{animation:!0,animationDuration:0,animationDurationUpdate:ue,animationEasingUpdate:`cubicOut`}:{},tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>e?.length?`${e[0].axisValue}: ${UB(e[0].value)} tokens`:``},grid:{left:100,right:5,top:5,bottom:5},xAxis:{type:`value`,show:!1,max:ae||1},yAxis:{type:`category`,data:ie.map(e=>e.label),axisLabel:{color:`#8b949e`,fontSize:11,formatter:e=>KB(e)},axisTick:{show:!1},axisLine:{show:!1}},series:[{id:`overview-top-repos`,type:`bar`,data:ie.map(e=>{let t=e.tokens||0,n=t/ae>=.7,r=ze(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:()=>UB(t),color:n?Be(r):`#8b949e`,fontSize:10}}}),barWidth:`80%`}]},fe=ce&&_?{click:e=>{if(e?.componentType!==`series`||e?.dataIndex==null)return;let t=ie[e.dataIndex];t?.label&&_(t.label)}}:void 0,pe=oe.reduce((e,t)=>e+(t.tokens||0),0),me=oe.filter(e=>pe>0?(e.tokens||0)/pe>=.01:!1),he=l&&me.length===1,R=oV(me),ge={backgroundColor:`transparent`,...$z,...c||l?{animation:!1}:{},tooltip:{trigger:`item`,appendToBody:!0,confine:!0,formatter:e=>`${e.name}: ${UB(e.value)} tokens (${e.percent}%)`},series:[{id:`overview-work-type`,type:`pie`,animation:le,avoidLabelOverlap:!R,radius:L,center:[`50%`,`50%`],label:{show:!he,color:`#8b949e`,fontSize:11,formatter:`{b}`,alignTo:`edge`,edgeDistance:5,bleedMargin:5,distanceToLabelLine:5},labelLine:{show:!he,lineStyle:{color:`#30363d`},length:8,length2:6},itemStyle:{borderColor:`#161b22`,borderWidth:2},...!he&&R?{labelLayout:R}:{},data:rV(me,We,{hideLabels:he})}]},_e=se.reduce((e,t)=>e+(t.tokens||0),0),ve=se.filter(e=>_e>0?(e.tokens||0)/_e>=.01:!1),ye=l&&ve.length===1,be=oV(ve),xe={backgroundColor:`transparent`,...$z,...c||l?{animation:!1}:{},tooltip:{trigger:`item`,appendToBody:!0,confine:!0,formatter:e=>`${e.name}: ${UB(e.value)} tokens (${e.percent}%)`},series:[{id:`overview-models`,type:`pie`,animation:le,avoidLabelOverlap:!be,radius:L,center:[`50%`,`50%`],label:{show:!ye,color:`#8b949e`,fontSize:11,formatter:`{b}`,alignTo:`edge`,edgeDistance:5,bleedMargin:5,distanceToLabelLine:5},labelLine:{show:!ye,lineStyle:{color:`#30363d`},length:8,length2:6},itemStyle:{borderColor:`#161b22`,borderWidth:2},...!ye&&be?{labelLayout:be}:{},data:rV(ve,Ue,{hideLabels:ye})}]},Se=ce&&v?{click:e=>{if(e?.componentType!==`series`||e?.dataIndex==null)return;let t=ve[e.dataIndex]?.label||e?.name;t&&v(t)}}:void 0;return(0,z.jsxs)(`div`,{className:`animate-in${l?` export-overview-frame`:``}`,children:[(0,z.jsxs)(`div`,{className:`stat-row`,children:[(0,z.jsxs)(`div`,{className:`stat-cards`,children:[(0,z.jsxs)(`div`,{className:`stat-card`,children:[(0,z.jsx)(`div`,{className:`stat-label`,children:`Tokens`}),(0,z.jsx)(`div`,{className:`stat-value`,children:UB(N.tokens)}),(0,z.jsxs)(`div`,{className:`stat-per-day`,children:[(0,z.jsx)(`span`,{className:`stat-per-day-value`,children:UB(N.tokens/N.days)}),` per day`]})]}),(0,z.jsxs)(`div`,{className:`stat-card`,children:[(0,z.jsx)(`div`,{className:`stat-label`,children:`Agent Time`}),(0,z.jsx)(`div`,{className:`stat-value`,children:GB(N.elapsed)}),(0,z.jsxs)(`div`,{className:`stat-per-day`,children:[(0,z.jsx)(`span`,{className:`stat-per-day-value`,children:GB(N.elapsed/N.days)}),` per day`]})]}),(0,z.jsxs)(`div`,{className:`stat-card`,children:[(0,z.jsx)(`div`,{className:`stat-label`,children:`Est. API Cost`}),(0,z.jsx)(`div`,{className:`stat-value`,children:WB(N.cost)}),(0,z.jsxs)(`div`,{className:`stat-per-day`,children:[(0,z.jsx)(`span`,{className:`stat-per-day-value`,children:WB(N.cost/N.days)}),` per day`]})]}),(0,z.jsxs)(`div`,{className:`stat-card`,children:[(0,z.jsx)(`div`,{className:`stat-label`,children:`Sessions`}),(0,z.jsx)(`div`,{className:`stat-value`,children:Math.round(N.sessions).toLocaleString()}),(0,z.jsxs)(`div`,{className:`stat-per-day`,children:[(0,z.jsx)(`span`,{className:`stat-per-day-value`,children:(N.sessions/N.days).toFixed(1)}),` per day`]})]})]}),l?(0,z.jsx)(ot,{daily:f||n||S,seekMs:d,timing:p}):(0,z.jsx)(sV,{daily:S,fullDaily:n,elasticDaily:T,range:i,isIngestActive:o,currentDateBucket:s,exportMode:c,exportPlayback:l,onDayClick:ce?g:void 0})]}),(0,z.jsx)(fV,{heatmapData:ee,isIngestActive:o,ingestProgress:a,currentDateBucket:j,onDayClick:ce?g:void 0,interactive:ce}),(0,z.jsxs)(`div`,{className:`grid-3`,children:[(0,z.jsxs)(`div`,{className:`chart-card overview-donut-card`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Top Repos`}),P.length>0?(0,z.jsx)(Ae,{echarts:VA,option:de,style:{height:180,cursor:fe?`pointer`:void 0},theme:`dark`,lazyUpdate:!1,notMerge:c,onEvents:fe}):(0,z.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem 0`,textAlign:`center`},children:`No data`})]}),(0,z.jsxs)(`div`,{className:`chart-card overview-donut-card`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Work Type`}),F.length>0?(0,z.jsx)(Ae,{echarts:VA,option:ge,style:{height:180},theme:`dark`,lazyUpdate:!1,notMerge:c}):(0,z.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem 0`,textAlign:`center`},children:`No data`})]}),(0,z.jsxs)(`div`,{className:`chart-card`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Models`}),I.length>0?(0,z.jsx)(Ae,{echarts:VA,option:xe,style:{height:180,cursor:Se?`pointer`:void 0},theme:`dark`,lazyUpdate:!1,notMerge:c,onEvents:Se}):(0,z.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem 0`,textAlign:`center`},children:`No data`})]})]}),(0,z.jsxs)(`div`,{className:`coverage-subtle`,children:[(0,z.jsx)(`span`,{style:{fontWeight:500},children:`Session coverage:`}),(0,z.jsxs)(`span`,{className:`coverage-item`,children:[(0,z.jsx)(`span`,{className:`coverage-dot`,style:{background:`#22c55e`}}),(0,z.jsx)(`span`,{className:`coverage-nums`,children:Math.round(N.exactPriced)}),` `,`exact-priced`]}),(0,z.jsxs)(`span`,{className:`coverage-item`,children:[(0,z.jsx)(`span`,{className:`coverage-dot`,style:{background:`#c084fc`}}),(0,z.jsx)(`span`,{className:`coverage-nums`,children:Math.round(N.fallbackPriced)}),` `,`fallback-priced`]}),(0,z.jsxs)(`span`,{className:`coverage-item`,children:[(0,z.jsx)(`span`,{className:`coverage-dot`,style:{background:`#64748b`}}),(0,z.jsx)(`span`,{className:`coverage-nums`,children:Math.round(N.unpriced)}),` `,`unpriced`]})]})]})}function hV({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:h,onNavigateToModel:g}){return(0,z.jsx)(pV,{presentation:OB({overview:e,heatmap:t,daily:n,families:r,repos:i,models:a,range:o},{duration:qz,onSettledChange:s,ingestProgress:c,isIngestActive:l,clockNowMs:d}),rawPresentation:b.useMemo(()=>SB({overview:e,heatmap:t,daily:n,families:r,repos:i,models:a,range:o}),[e,t,n,r,i,a,o]),fullDaily:b.useMemo(()=>JB(n),[n]),sourceDailyRows:n,range:o,ingestProgress:c,isIngestActive:l,currentDateBucket:u,onDailyDebugStatsChange:f,onPresentationDateRangeChange:p,onNavigateToDailyDay:m,onNavigateToRepo:h,onNavigateToModel:g})}function gV(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 _V=(0,b.memo)(hV,gV);function vV(e){return SV(e)}function yV(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=SV(e);return Math.round(a+(i-a)*o)}function bV(e,t=!1){if(!t)return[`48%`,`72%`];let n=.9+SV(e)*.1;return[`${xV(48*n)}%`,`${xV(72*n)}%`]}function xV(e){return Math.round(e*100)/100}function SV(e){let t=Math.max(Iz.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)))}function CV(e,t){return e==="default"?t:e}function wV(e,t=`tokens`){return Object.entries(e||{}).map(([e,t])=>({key:e,...t})).sort((e,n)=>(n[t]||0)-(e[t]||0))}function TV({title:e,rows:t,valueKey:n=`tokens`,colorForKey:r,valueFormatter:i,chartMode:a=`default`,defaultMode:o=`bar`,emptyLabel:s=`No data`,renderTitleInChart:c=!0,barLabelProgress:l=1}){let u=CV(a,o),d=(t||[]).map((e,t)=>{let n=e?.key??e?.repo_label??e?.model_name??e?.family??null;return n?{...e,key:String(n),_idx:t}:null}).filter(Boolean),f={xAxis:{show:!1},yAxis:{show:!1},series:[],graphic:{type:`text`,left:`center`,top:`60%`,style:{text:s,fill:`#484f58`,fontSize:11}}};if(c&&(f.title={text:e,left:`center`,top:`middle`,textStyle:{fontSize:12,color:`#484f58`,fontWeight:`normal`}}),!d.length)return f;if(u===`donut`){let t=d.reduce((e,t)=>e+(t[n]||0),0),a={backgroundColor:`transparent`,...zz,tooltip:{trigger:`item`,appendToBody:!0,confine:!0,formatter:e=>`${e.name}: ${i(e.value)} (${e.percent}%)`},series:[{type:`pie`,...zz,radius:[`40%`,`62%`],center:[`50%`,`52%`],label:{show:!0,color:`#8b949e`,fontSize:10,formatter:`{b}`,overflow:`truncate`,width:90,...Rz},labelLine:{lineStyle:{color:`#30363d`}},itemStyle:{borderColor:`#161b22`,borderWidth:2},data:d.map(e=>{let i=e[n]||0,a=(t>0?i/t:0)>=.01;return{name:e.key,value:i,itemStyle:{color:r(e.key)},label:{show:a,color:r(e.key)},labelLine:{show:a}}})}]};return c&&(a.title={text:e,left:`center`,top:8,textStyle:{fontSize:11,color:`#8b949e`,fontWeight:`normal`}}),a}let p=[...d].reverse(),m=Math.max(...d.map(e=>e[n]||0),0),h={backgroundColor:`transparent`,...Bz,tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{let t=p[e?.[0]?.dataIndex];return t?`${t.key}: ${i(t[n]||0)}`:``}},grid:{left:65,right:50,top:c?35:20,bottom:20},xAxis:{type:`value`,splitNumber:4,max:m||1,axisLabel:{formatter:e=>i(e),color:`#484f58`,fontSize:10,showMinLabel:!0,showMaxLabel:!0},splitLine:{lineStyle:{color:[`transparent`,`#21262d`,`#21262d`,`#21262d`,`transparent`]}}},yAxis:{type:`category`,data:p.map(e=>e.key),axisLabel:{color:`#8b949e`,fontSize:10,overflow:`truncate`,width:55},axisTick:{show:!1},axisLine:{show:!1}},series:[{type:`bar`,data:p.map(e=>({value:e[n]||0,itemStyle:{color:r(e.key),borderRadius:[0,3,3,0]}})),barMaxWidth:14,label:{show:!0,position:`right`,formatter:e=>i((e.value??0)*l),color:`#8b949e`,fontSize:9,...Vz}}]};return c&&(h.title={text:e,left:`center`,top:8,textStyle:{fontSize:11,color:`#8b949e`,fontWeight:`normal`}}),h}uk([FN,iP,zI,nR,aR,Mz]);function EV(e){return Nz(e)}function DV(e){return e==null||e===0?`—`:e>=1e3?`$`+(e/1e3).toFixed(1)+`K`:`$`+e.toFixed(2)}var OV=[`all`,`review`,`exploration`,`planning`,`memory`,`generic`],kV=[`review`,`exploration`,`planning`,`memory`,`generic`];function AV(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 jV(e,t=`total`){let n=e?.data;return Array.isArray(n)?n:n?.[t]||n?.total||[]}function MV({repo:e,chartMode:t}){let[n,r]=(0,b.useState)(!1),i=(0,b.useMemo)(()=>wV(e.by_model),[e.by_model]),a=(0,b.useMemo)(()=>wV(e.by_family),[e.by_family]),o=TV({title:`Models in repo`,rows:i,valueKey:`tokens`,colorForKey:Ue,valueFormatter:EV,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1}),s=TV({title:`Work type in repo`,rows:a,valueKey:`tokens`,colorForKey:We,valueFormatter:EV,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1}),c=[...i.slice(0,4).map(e=>({...e,scope:`model`})),...a.slice(0,4).map(e=>({...e,scope:`family`}))];return(0,z.jsxs)(`div`,{className:`model-detail-wrap`,children:[(0,z.jsxs)(`div`,{className:`model-detail-charts`,children:[(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Models in repo`}),(0,z.jsx)(Ae,{echarts:VA,option:o,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Work type in repo`}),(0,z.jsx)(Ae,{echarts:VA,option:s,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]})]}),(0,z.jsx)(`div`,{className:`model-detail-footer`,children:(0,z.jsxs)(`button`,{type:`button`,className:`model-detail-toggle`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[(0,z.jsx)(`span`,{className:`model-detail-toggle-text`,children:n?`Hide details`:`Show details`}),(0,z.jsx)(`span`,{className:`model-detail-toggle-arrow ${n?`expanded`:``}`,"aria-hidden":!0,children:`▼`})]})}),(0,z.jsx)(`div`,{className:`model-detail-summary-wrap ${n?`expanded`:``}`,children:(0,z.jsx)(`div`,{className:`model-detail-summary`,children:c.map(e=>(0,z.jsxs)(`div`,{className:`model-detail-summary-card`,children:[(0,z.jsxs)(`div`,{className:`model-detail-summary-head`,children:[(0,z.jsx)(`span`,{className:`model-detail-swatch`,style:{background:e.scope===`model`?Ue(e.key):We(e.key)}}),(0,z.jsx)(`span`,{className:`model-detail-summary-name`,title:e.key,children:e.key})]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[EV(e.tokens),` tokens`]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[e.sessions||0,` sessions`]}),(0,z.jsx)(`div`,{className:`model-detail-summary-line`,children:DV(e.cost)})]},`${e.scope}-${e.key}`))})})]})}function NV({data:e,range:t=`total`,chartMode:n=`default`,focusRequest:r=null,onFocusRequestConsumed:i}){let[a,o]=(0,b.useState)(`all`),[s,c]=(0,b.useState)(null),l=(0,b.useRef)(null),u=(0,b.useRef)(null),d=(0,b.useMemo)(()=>jV(e,t),[e,t]),f=(0,b.useMemo)(()=>d?.length?a===`all`?d:d.map(e=>{let t=e.by_family?.[a];return t?{...e,tokens:t.tokens,cost:t.cost,sessions:t.sessions}:null}).filter(Boolean).sort((e,t)=>t.tokens-e.tokens):[],[d,a]);(0,b.useEffect)(()=>{s&&(f.some(e=>e.repo_key===s)||c(null))},[s,f]),(0,b.useEffect)(()=>{if(!r){u.current=null;return}let{id:e,repoLabel:t}=r;if(!t||u.current===e)return;let n=d.find(e=>e.repo_label===t||e.repo_key===t);u.current=e,n&&c(n.repo_key),i?.()},[r,d,i]);let p=f.slice(0,15),m=[...p].reverse(),h=Math.max(...p.map(e=>e.tokens||0),0),g=Math.max(250,p.length*28),_=(0,b.useMemo)(()=>({backgroundColor:`transparent`,...Lz,tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{let t=p[p.length-1-e[0].dataIndex];return t?`<b>${t.repo_label}</b><br/>Tokens: ${EV(t.tokens)}<br/>Cost: ${DV(t.cost)}<br/>Sessions: ${t.sessions}`:``}},grid:{left:150,right:50,top:8,bottom:8},xAxis:{type:`value`,splitNumber:4,max:h||1,axisLabel:{formatter:e=>EV(e),color:`#484f58`,showMinLabel:!0,showMaxLabel:!0},splitLine:{lineStyle:{color:[`transparent`,`#21262d`,`#21262d`,`#21262d`,`transparent`]}}},yAxis:{type:`category`,data:m.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:m.map(e=>({id:e.repo_key,name:e.repo_label,value:e.tokens,itemStyle:{color:ze(e.repo_label),borderRadius:[0,3,3,0]}})),barMaxWidth:16,label:{show:!0,position:`right`,formatter:e=>EV(e.value??0),color:`#8b949e`,fontSize:10,...Rz}}]}),[h,m,p]),v=(0,b.useMemo)(()=>({click:e=>{if(e?.componentType===`series`&&e?.dataIndex!=null){let t=p[p.length-1-e.dataIndex];t&&c(e=>e===t.repo_key?null:t.repo_key)}}}),[p]);return d?.length?(0,z.jsxs)(`div`,{className:`animate-in`,children:[(0,z.jsxs)(`div`,{className:`section-header`,children:[(0,z.jsx)(`span`,{className:`section-title`,children:`Repos`}),(0,z.jsx)(`div`,{className:`btn-group`,children:OV.map(e=>(0,z.jsx)(`button`,{className:`btn ${a===e?`active`:``}`,onClick:()=>o(e),children:e},e))})]}),(0,z.jsxs)(`div`,{className:`chart-card`,children:[(0,z.jsx)(`button`,{className:`export-btn`,onClick:()=>AV(l),children:`PNG`}),(0,z.jsx)(`div`,{style:{height:g,transition:`height 220ms cubic-bezier(0.22, 1, 0.36, 1)`},children:(0,z.jsx)(Ae,{ref:l,echarts:VA,option:_,style:{height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1,onEvents:v})})]}),(0,z.jsx)(`div`,{className:`table-wrap`,children:(0,z.jsxs)(`table`,{children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:`Repo`}),(0,z.jsx)(`th`,{children:`Tokens`}),(0,z.jsx)(`th`,{children:`Cost`}),(0,z.jsx)(`th`,{children:`Sessions`}),(0,z.jsx)(`th`,{style:{width:200},children:`Families`})]})}),(0,z.jsx)(`tbody`,{children:f.map(e=>(0,z.jsxs)(b.Fragment,{children:[(0,z.jsxs)(`tr`,{onClick:()=>c(s===e.repo_key?null:e.repo_key),style:{cursor:`pointer`},children:[(0,z.jsxs)(`td`,{style:{fontWeight:500,color:`var(--text-primary)`},children:[(0,z.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:2,background:ze(e.repo_label),marginRight:8}}),e.repo_label]}),(0,z.jsx)(`td`,{style:{fontFamily:`var(--font-mono)`},children:EV(e.tokens)}),(0,z.jsx)(`td`,{style:{fontFamily:`var(--font-mono)`},children:DV(e.cost)}),(0,z.jsx)(`td`,{children:e.sessions}),(0,z.jsx)(`td`,{children:Object.entries(e.by_family||{}).sort(([e],[t])=>{let n=kV.indexOf(e),r=kV.indexOf(t);return(n===-1?999:n)-(r===-1?999:r)}).slice(0,3).map(([e])=>(0,z.jsx)(`span`,{className:`tag tag-${e}`,style:{marginRight:3},children:e},e))})]}),s===e.repo_key&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:5,style:{background:`var(--bg-surface)`,padding:`0.75rem 1rem`},children:(0,z.jsx)(MV,{repo:e,chartMode:n})})})]},e.repo_key))})]})})]}):(0,z.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem`},children:`No data`})}uk([FN,iP,zI,nR,aR,Mz]);function PV(e){return Nz(e)}function FV(e){return e==null||e===0?`—`:e>=1e3?`$`+(e/1e3).toFixed(1)+`K`:`$`+e.toFixed(2)}var IV=[`low`,`medium`,`high`,`xhigh`,`unknown`];function LV(e){return[...e].sort(([e],[t])=>{let n=IV.indexOf((e||``).toLowerCase()),r=IV.indexOf((t||``).toLowerCase());return(n===-1?999:n)-(r===-1?999:r)})}function RV({model:e,fmt:t,chartMode:n}){let[r,i]=(0,b.useState)(!1),a=(0,b.useMemo)(()=>LV(Object.entries(e.by_effort||{})),[e.by_effort]);if(!a.length)return null;let o=a.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})),s=o.map(e=>({key:e.effort,sessions:e.sessions,tokens:e.tokens,avgTokens:e.avgTokens})),c=TV({title:`Sessions by effort`,rows:s,valueKey:`sessions`,colorForKey:Ge,valueFormatter:e=>Math.round(e).toLocaleString(),chartMode:n,defaultMode:`donut`,renderTitleInChart:!1}),l=TV({title:`Tokens by effort`,rows:s,valueKey:`tokens`,colorForKey:Ge,valueFormatter:t,chartMode:n,defaultMode:`donut`,renderTitleInChart:!1}),u=TV({title:`Avg tokens per session`,rows:s,valueKey:`avgTokens`,colorForKey:Ge,valueFormatter:t,chartMode:n,defaultMode:`bar`,renderTitleInChart:!1});return(0,z.jsxs)(`div`,{className:`model-detail-wrap`,children:[(0,z.jsxs)(`div`,{className:`model-detail-charts`,children:[(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Sessions by effort`}),(0,z.jsx)(Ae,{echarts:VA,option:c,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Tokens by effort`}),(0,z.jsx)(Ae,{echarts:VA,option:l,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,z.jsxs)(`div`,{className:`model-detail-bar`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Avg tokens per session`}),(0,z.jsx)(Ae,{echarts:VA,option:u,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]})]}),(0,z.jsx)(`div`,{className:`model-detail-footer`,children:(0,z.jsxs)(`button`,{type:`button`,className:`model-detail-toggle`,onClick:()=>i(e=>!e),"aria-expanded":r,children:[(0,z.jsx)(`span`,{className:`model-detail-toggle-text`,children:r?`Hide details`:`Show details`}),(0,z.jsx)(`span`,{className:`model-detail-toggle-arrow ${r?`expanded`:``}`,"aria-hidden":!0,children:`▼`})]})}),(0,z.jsx)(`div`,{className:`model-detail-summary-wrap ${r?`expanded`:``}`,children:(0,z.jsx)(`div`,{className:`model-detail-summary`,children:o.map(e=>(0,z.jsxs)(`div`,{className:`model-detail-summary-card`,children:[(0,z.jsxs)(`div`,{className:`model-detail-summary-head`,children:[(0,z.jsx)(`span`,{className:`model-detail-swatch`,style:{background:Ge(e.effort)}}),(0,z.jsx)(`span`,{className:`model-detail-summary-name`,title:e.effort,children:e.effort})]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[e.sessions,` sessions`]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[t(e.tokens),` tokens`]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[t(e.avgTokens),` avg/session`]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[FV(e.cost),` cost`]}),(0,z.jsxs)(`div`,{className:`model-detail-summary-line`,children:[e.exactPriced,` exact · `,e.fallbackPriced,` fallback`]})]},e.effort))})})]})}function zV(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 BV(e,t=`total`){let n=e?.data;return Array.isArray(n)?n:n?.[t]||n?.total||[]}function VV({data:e,range:t=`total`,chartMode:n=`default`,focusRequest:r=null,onFocusRequestConsumed:i}){let[a,o]=(0,b.useState)(null),s=(0,b.useRef)(null),c=(0,b.useRef)(null),l=(0,b.useMemo)(()=>BV(e,t),[e,t]);(0,b.useEffect)(()=>{a&&(l.some(e=>e.model_name===a)||o(null))},[a,l]),(0,b.useEffect)(()=>{if(!r){c.current=null;return}let{id:e,modelName:t}=r;if(!t||c.current===e)return;let n=l.find(e=>e.model_name===t);c.current=e,n&&o(n.model_name),i?.()},[r,l,i]);let u=[...l].reverse(),d=Math.max(...l.map(e=>e.tokens||0),0),f=Math.max(180,l.length*34),p=(0,b.useMemo)(()=>({backgroundColor:`transparent`,...Lz,tooltip:{trigger:`axis`,axisPointer:{type:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{let t=l[l.length-1-e[0].dataIndex];return`<b>${t.model_name}</b><br/>Tokens: ${PV(t.tokens)}<br/>Cost: ${FV(t.cost)}<br/>Sessions: ${t.sessions}`}},grid:{left:160,right:50,top:8,bottom:8},xAxis:{type:`value`,splitNumber:4,max:d||1,axisLabel:{formatter:e=>PV(e),color:`#484f58`,fontSize:10,showMinLabel:!0,showMaxLabel:!0},splitLine:{lineStyle:{color:[`transparent`,`#21262d`,`#21262d`,`#21262d`,`transparent`]}}},yAxis:{type:`category`,data:u.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:u.map(e=>({id:e.model_name,name:e.model_name,value:e.tokens,itemStyle:{color:Ue(e.model_name),borderRadius:[0,3,3,0]}})),barMaxWidth:18,label:{show:!0,position:`right`,formatter:e=>PV(e.value??0),color:`#8b949e`,fontSize:10,...Rz}}]}),[d,l,u]),m=(0,b.useMemo)(()=>({click:e=>{if(e?.componentType===`series`&&e?.dataIndex!=null){let t=l[l.length-1-e.dataIndex];t&&o(e=>e===t.model_name?null:t.model_name)}}}),[l]);return l?.length?(0,z.jsxs)(`div`,{className:`animate-in`,children:[(0,z.jsx)(`div`,{className:`section-header`,children:(0,z.jsx)(`span`,{className:`section-title`,children:`Models`})}),(0,z.jsxs)(`div`,{className:`chart-card`,children:[(0,z.jsx)(`button`,{className:`export-btn`,onClick:()=>zV(s),children:`PNG`}),(0,z.jsx)(`div`,{style:{height:f,transition:`height 220ms cubic-bezier(0.22, 1, 0.36, 1)`},children:(0,z.jsx)(Ae,{ref:s,echarts:VA,option:p,style:{height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1,onEvents:m})})]}),(0,z.jsx)(`div`,{className:`table-wrap`,children:(0,z.jsxs)(`table`,{children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:`Model`}),(0,z.jsx)(`th`,{children:`Tokens`}),(0,z.jsx)(`th`,{children:`Cost`}),(0,z.jsx)(`th`,{children:`Sessions`}),(0,z.jsx)(`th`,{children:`Effort Levels`})]})}),(0,z.jsx)(`tbody`,{children:l.map(e=>(0,z.jsxs)(b.Fragment,{children:[(0,z.jsxs)(`tr`,{onClick:()=>o(a===e.model_name?null:e.model_name),style:{cursor:`pointer`},children:[(0,z.jsxs)(`td`,{style:{fontWeight:500,color:`var(--text-primary)`,fontFamily:`var(--font-mono)`},children:[(0,z.jsx)(`span`,{style:{display:`inline-block`,width:8,height:8,borderRadius:2,background:Ue(e.model_name),marginRight:8}}),e.model_name]}),(0,z.jsx)(`td`,{style:{fontFamily:`var(--font-mono)`},children:PV(e.tokens)}),(0,z.jsx)(`td`,{style:{fontFamily:`var(--font-mono)`},children:FV(e.cost)}),(0,z.jsx)(`td`,{children:e.sessions}),(0,z.jsx)(`td`,{children:Object.keys(e.by_effort||{}).length})]}),a===e.model_name&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:5,style:{background:`var(--bg-surface)`,padding:`0.75rem 1rem`},children:(0,z.jsx)(RV,{model:e,fmt:PV,chartMode:n})})})]},e.model_name))})]})})]}):(0,z.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem`},children:`No data`})}uk([FN,Uj,iP,zI,nR,aR,jR,cz,rL,Mz]);function HV(e){return Nz(e)}function UV(e){return e==null||e===0?`$0`:`$`+e.toFixed(2)}function WV(e){return e?(e/3600).toFixed(1)+`h`:`0h`}var GV=[{key:`tokens`,label:`Tokens`,fn:HV},{key:`elapsed_seconds`,label:`Time`,fn:WV},{key:`cost`,label:`Cost`,fn:UV}],KV=[{key:`model`,label:`By Model`},{key:`family`,label:`By Work`}],qV=[{key:`absolute`,label:`Absolute`},{key:`relative`,label:`Relative`}];function JV(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 YV(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 XV=280,ZV={left:70,right:20,bottom:12,height:24};function QV(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 $V(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 eH(e,t){return{left:ZV.left,right:e-ZV.right,top:t-ZV.bottom-ZV.height,bottom:t-ZV.bottom}}function tH(e,t,n,r){let i=eH(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 nH(e,t){return e===`d7`?44:e===`d30`?22:t<=14?36:t<=31?18:14}function rH(e,t){return e===`d7`?8:e===`d30`?3:t<=31?2:+(t<=90)}function iH(e,t){return e===`d7`?`72%`:e===`d30`?`54%`:t<=14?`64%`:t<=31?`48%`:`36%`}function aH(e,t){return e?t===`elapsed_seconds`?e.elapsed_seconds||0:t===`cost`?e.cost||0:e.tokens||0:0}function oH(e,t){if(!e)return`Day detail`;let n=GV.find(e=>e.key===t)||GV[0],r=new Date(`${e.date}T00:00:00`).toLocaleDateString(`en-US`,{weekday:`long`}),i=n.fn(aH(e,t));return`Day detail: ${r} - ${e.date} - ${n.label}: ${i}`}function sH(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 cH({day:e,chartMode:t}){let n=(0,b.useMemo)(()=>wV(e.by_model),[e.by_model]),r=(0,b.useMemo)(()=>wV(e.by_repo),[e.by_repo]),i=(0,b.useMemo)(()=>wV(e.by_family),[e.by_family]),a=TV({title:`Models`,rows:n,valueKey:`tokens`,colorForKey:Ue,valueFormatter:HV,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1}),o=TV({title:`Repos`,rows:r,valueKey:`tokens`,colorForKey:ze,valueFormatter:HV,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1}),s=TV({title:`Work Type`,rows:i,valueKey:`tokens`,colorForKey:We,valueFormatter:HV,chartMode:t,defaultMode:`donut`,renderTitleInChart:!1});return(0,z.jsx)(`div`,{className:`model-detail-wrap`,children:(0,z.jsxs)(`div`,{className:`model-detail-charts`,children:[(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Repos`}),(0,z.jsx)(Ae,{echarts:VA,option:o,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Models`}),(0,z.jsx)(Ae,{echarts:VA,option:a,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]}),(0,z.jsxs)(`div`,{className:`model-detail-donut`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.5rem`},children:`Work Type`}),(0,z.jsx)(Ae,{echarts:VA,option:s,style:{width:`100%`,height:`100%`},theme:`dark`,lazyUpdate:!0,notMerge:!1})]})]})})}var lH=b.memo(function({daily:e,range:t,metric:n,split:r,displayMode:i,onSelectDate:a,navigateToDayRequest:o,onNavigateToDayConsumed:s}){let[c,l]=(0,b.useState)({startValue:0,endValue:0}),u=(0,b.useRef)(null),d=(0,b.useRef)(c);d.current=c;let f=(0,b.useRef)(0),p=(0,b.useRef)(null),m=(0,b.useRef)(0),h=(0,b.useRef)(!1),g=(0,b.useRef)(null),_=(0,b.useRef)(null),v=(0,b.useRef)(0),y=(0,b.useMemo)(()=>e.map(e=>e.date),[e]),x=GV.find(e=>e.key===n),S=(0,b.useMemo)(()=>YV(t,y.length),[t,y.length]);(0,b.useEffect)(()=>{if(!y.length)return;let e=YV(t,y.length),n=_.current===null,r=!n&&_.current!==t,i=!n&&v.current!==y.length;if(_.current=t,v.current=y.length,cancelAnimationFrame(m.current),m.current=0,n){l(e);return}if(r)return $V(d.current,e,l,m,XV);i&&l(e)},[t,y.length]),(0,b.useEffect)(()=>()=>{cancelAnimationFrame(f.current),f.current=0,g.current?.(),g.current=null},[]);let C=(0,b.useCallback)(()=>{let e=u.current?.getEchartsInstance?.();if(!e)return;g.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=tH(e.getWidth(),e.getHeight(),y.length,d.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(h.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=tH(e.getWidth(),e.getHeight(),y.length,d.current);h.current=r>=a.selectionLeft&&r<=a.selectionRight&&i>=a.top&&i<=a.bottom,n(t)},a=e=>{h.current=!1,n(e)},o=()=>{h.current=!1,t.setCursorStyle(`default`)};t.on(`mousemove`,r),t.on(`mousedown`,i),t.on(`mouseup`,a),t.on(`globalout`,o),g.current=()=>{t.off(`mousemove`,r),t.off(`mousedown`,i),t.off(`mouseup`,a),t.off(`globalout`,o),t.setCursorStyle(`default`)}},[y.length]),w=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!o){w.current=null;return}let{id:t,centerDate:n}=o;if(!n||!e.length||w.current===t)return;let r=e.map(e=>e.date),i=r.indexOf(n);if(i<0){s?.();return}w.current=t;let c=Math.max(0,i-3),u=Math.min(r.length-1,i+3);cancelAnimationFrame(m.current),m.current=0,l({startValue:c,endValue:u}),a(n),s?.()},[o,e,a,s]);let T=(0,b.useMemo)(()=>{if(!y.length)return 0;let e=Math.max(0,Math.min(y.length-1,Math.floor(c.startValue??S.startValue??0))),t=Math.max(e,Math.min(y.length-1,Math.floor(c.endValue??S.endValue??y.length-1)));return Math.max(1,t-e+1)},[y.length,c,S]),E=(0,b.useMemo)(()=>{if(!y.length)return{startIdx:0,endIdx:-1};let e=Math.max(0,Math.min(y.length-1,Math.floor(c.startValue??S.startValue??0)));return{startIdx:e,endIdx:Math.max(e,Math.min(y.length-1,Math.floor(c.endValue??S.endValue??y.length-1)))}},[y.length,c,S]),D=(0,b.useMemo)(()=>nH(t,T),[t,T]),O=(0,b.useMemo)(()=>rH(t,T),[t,T]),k=(0,b.useMemo)(()=>iH(t,T),[t,T]),A=(0,b.useMemo)(()=>aB(e,{split:r,metric:n}),[e,r,n]),j=A.groups,ee=(0,b.useMemo)(()=>A.series.map(e=>({name:e.key,values:e.data})),[A.series]),M=A.dayTotals,N=(0,b.useMemo)(()=>{if(!M.length||E.endIdx<E.startIdx)return 0;let e=0;for(let t=E.startIdx;t<=E.endIdx;t++)e=Math.max(e,M[t]||0);return e},[M,E]),P=i===`relative`,F=(0,b.useMemo)(()=>({dates:y,series:ee.map(e=>({key:e.name,label:e.name,data:e.values}))}),[y,ee]),I=`${n}\0${r}`,te=FB(F,!P,I),ne=(0,b.useMemo)(()=>new Map((te?.series||[]).map(e=>[e.key,e])),[te]),re=(0,b.useMemo)(()=>{if(P)return M;let e=y.length,t=Array(e).fill(0);for(let n of te?.series||[])for(let r=0;r<e;r++)t[r]+=n.data[r]||0;return t},[P,M,te,y.length]),ie=(0,b.useMemo)(()=>{if(i===`relative`)return 100;if(N)return Math.ceil(N*1.1)},[i,N]),ae=(0,b.useMemo)(()=>{if(!P)return null;if(!ee.length)return[];let e=ee.map(e=>{let t=e.values.map((e,t)=>M[t]>0?e/M[t]*100:0);for(let e=1;e<t.length;e++)M[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}})},[P,ee,M]),oe=(0,b.useMemo)(()=>P?j.map((e,t)=>{let n=r===`model`?Ue(e):We(e);if(!ee[t])return null;let i=ae[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`?Ue(e):We(e),n=ne.get(e)?.data??y.map(()=>0);return{id:`daily-${r}-${e}`,name:e,type:`bar`,stack:`total`,data:n,itemStyle:{color:t},barWidth:k,barMaxWidth:D,barMinWidth:O}}),[P,j,r,ae,ee,ne,y,k,D,O]),se=(0,b.useMemo)(()=>!P||!ae?[]:ae.map((e,t)=>{let n=ee[t],i=Be(r===`model`?Ue(n.name):We(n.name)),a=sH(e.values,e.prevStack);return!a||Math.max(...e.values)<8?null:{name:n.name,labelColor:i,coord:a}}).filter(Boolean),[P,ae,ee,r]),ce=(0,b.useCallback)(()=>{if(!u.current)return;let e=u.current.getEchartsInstance();if(!P||se.length===0){e.setOption({graphic:{elements:[]}},{notMerge:!1});return}let t=se.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})},[P,se]);(0,b.useEffect)(()=>{let e=setTimeout(ce,150);return()=>clearTimeout(e)},[P,se,ce]),(0,b.useEffect)(()=>{let e=()=>ce();return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[ce]),(0,b.useEffect)(()=>{C()},[C,c]);let L={backgroundColor:`transparent`,tooltip:{trigger:`axis`,axisPointer:{type:P?`line`:`shadow`},appendToBody:!0,confine:!0,formatter:e=>{if(!e?.length)return``;let t=e[0]?.dataIndex,n=re,r=t==null?0:n[t],a=t;if(i===`relative`&&r===0&&t!=null){for(let e=t-1;e>=0;e--)if(n[e]>0){a=e;break}}let o=i===`relative`&&r===0?n[a]??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=i===`relative`?ee.find(t=>t.name===e.seriesName)?.values[a]??0:e.value;i===`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+=i===`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:ZV.left,right:ZV.right,top:35,bottom:55},dataZoom:[{type:`slider`,startValue:c.startValue,endValue:c.endValue,left:ZV.left,right:ZV.right,bottom:ZV.bottom,height:ZV.height,borderColor:`#30363d`,fillerColor:`rgba(99, 102, 241, 0.08)`,handleStyle:{color:`#6366f1`},textStyle:{color:`#484f58`}}],xAxis:{type:`category`,data:y,boundaryGap:i!==`relative`,axisLabel:{color:`#484f58`,fontSize:10,rotate:45},axisTick:{show:!1},axisLine:{lineStyle:{color:`#30363d`}}},yAxis:{type:`value`,min:0,max:i===`relative`?100:ie,scale:!1,axisLabel:{formatter:i===`relative`?e=>e+`%`:e=>x.fn(e),color:`#484f58`},splitLine:{lineStyle:{color:`#21262d`}}},series:oe,...P?Lz:Zz};return(0,z.jsxs)(`div`,{className:`chart-card`,children:[(0,z.jsx)(`button`,{className:`export-btn`,onClick:()=>JV(u),children:`PNG`}),(0,z.jsx)(Ae,{ref:u,echarts:VA,option:L,style:{height:400},theme:`dark`,notMerge:!1,replaceMerge:[`series`,`legend`,`graphic`],lazyUpdate:!1,onChartReady:()=>{ce(),C()},onEvents:{click:e=>{let t=e?.axisValue||e?.name;t&&a(t)},datazoom:e=>{p.current=QV(e,y,d.current),f.current||=requestAnimationFrame(()=>{f.current=0,p.current&&=(l(p.current),null),P&&ce()})}}})]})});function uH({data:e,range:t=`total`,chartMode:n=`default`,navigateToDayRequest:r=null,onNavigateToDayConsumed:i}){let[a,o]=(0,b.useState)(`tokens`),[s,c]=(0,b.useState)(`model`),[l,u]=(0,b.useState)(`absolute`),[d,f]=(0,b.useState)(null),p=(0,b.useMemo)(()=>e?.data?.length?nB(e):[],[e]);(0,b.useEffect)(()=>{!d&&p[0]&&f(p[p.length-1]?.date||p[0]?.date)},[p,d]);let m=(0,b.useCallback)(e=>{e&&f(e)},[]),h=p.find(e=>e.date===d)||null;return p.length?(0,z.jsxs)(`div`,{className:`animate-in`,children:[(0,z.jsxs)(`div`,{className:`section-header`,children:[(0,z.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`0.75rem`},children:(0,z.jsx)(`span`,{className:`section-title`,children:`Daily Usage`})}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`},children:[(0,z.jsx)(`div`,{className:`btn-group`,children:GV.map(e=>(0,z.jsx)(`button`,{className:`btn ${a===e.key?`active`:``}`,onClick:()=>o(e.key),children:e.label},e.key))}),(0,z.jsx)(`div`,{className:`btn-group`,children:KV.map(e=>(0,z.jsx)(`button`,{className:`btn ${s===e.key?`active`:``}`,onClick:()=>c(e.key),children:e.label},e.key))}),(0,z.jsx)(`div`,{className:`btn-group`,children:qV.map(e=>(0,z.jsx)(`button`,{className:`btn ${l===e.key?`active`:``}`,onClick:()=>u(e.key),children:e.label},e.key))})]})]}),(0,z.jsx)(lH,{daily:p,range:t,metric:a,split:s,displayMode:l,onSelectDate:m,navigateToDayRequest:r,onNavigateToDayConsumed:i}),h&&(0,z.jsxs)(`div`,{className:`chart-card`,children:[(0,z.jsx)(`div`,{className:`chart-title`,style:{marginBottom:`0.75rem`},children:oH(h,a)}),(0,z.jsx)(cH,{day:h,chartMode:n})]})]}):(0,z.jsx)(`div`,{style:{color:`var(--text-muted)`,padding:`2rem`},children:`No data`})}function dH(){return{accessor:(e,t)=>typeof e==`function`?{...t,accessorFn:e}:{...t,accessorKey:e},display:e=>e,group:e=>e}}function fH(e,t){return typeof e==`function`?e(t):e}function pH(e,t){return n=>{t.setState(t=>({...t,[e]:fH(n,t[e])}))}}function mH(e){return e instanceof Function}function hH(e){return Array.isArray(e)&&e.every(e=>typeof e==`number`)}function gH(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i!=null&&i.length&&r(i)})};return r(e),n}function _H(e,t,n){let r=[],i;return a=>{let o;n.key&&n.debug&&(o=Date.now());let s=e(a);if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug&&(c=Date.now()),i=t(...s),n==null||n.onChange==null||n.onChange(i),n.key&&n.debug&&n!=null&&n.debug()){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
29
29
|
font-size: .6rem;
|
|
30
30
|
font-weight: bold;
|
|
31
|
-
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return i}}function gH(e,t,n,r){return{debug:()=>e?.debugAll??e[t],key:!1,onChange:r}}function _H(e,t,n,r){let i={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:()=>i.getValue()??e.options.renderFallbackValue,getContext:hH(()=>[e,n,t,i],(e,t,n,r)=>({table:e,column:t,row:n,cell:r,getValue:r.getValue,renderValue:r.renderValue}),gH(e.options,`debugCells`,`cell.getContext`))};return e._features.forEach(r=>{r.createCell==null||r.createCell(i,n,t,e)},{}),i}function vH(e,t,n,r){let i={...e._getDefaultColumnDef(),...t},a=i.accessorKey,o=i.id??(a?typeof String.prototype.replaceAll==`function`?a.replaceAll(`.`,`_`):a.replace(/\./g,`_`):void 0)??(typeof i.header==`string`?i.header:void 0),s;if(i.accessorFn?s=i.accessorFn:a&&(s=a.includes(`.`)?e=>{let t=e;for(let e of a.split(`.`))t=t?.[e];return t}:e=>e[i.accessorKey]),!o)throw Error();let c={id:`${String(o)}`,accessorFn:s,parent:r,depth:n,columnDef:i,columns:[],getFlatColumns:hH(()=>[!0],()=>[c,...c.columns?.flatMap(e=>e.getFlatColumns())],gH(e.options,`debugColumns`,`column.getFlatColumns`)),getLeafColumns:hH(()=>[e._getOrderColumnsFn()],e=>{var t;return(t=c.columns)!=null&&t.length?e(c.columns.flatMap(e=>e.getLeafColumns())):[c]},gH(e.options,`debugColumns`,`column.getLeafColumns`))};for(let t of e._features)t.createColumn==null||t.createColumn(c,e);return c}var yH=`debugHeaders`;function bH(e,t,n){let r={id:n.id??t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{let e=[],t=n=>{n.subHeaders&&n.subHeaders.length&&n.subHeaders.map(t),e.push(n)};return t(r),e},getContext:()=>({table:e,header:r,column:t})};return e._features.forEach(t=>{t.createHeader==null||t.createHeader(r,e)}),r}var xH={createTable:e=>{e.getHeaderGroups=hH(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>{let a=r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],o=i?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],s=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id)));return SH(t,[...a,...s,...o],e)},gH(e.options,yH,`getHeaderGroups`)),e.getCenterHeaderGroups=hH(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>(n=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id))),SH(t,n,e,`center`)),gH(e.options,yH,`getCenterHeaderGroups`)),e.getLeftHeaderGroups=hH(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>SH(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`left`),gH(e.options,yH,`getLeftHeaderGroups`)),e.getRightHeaderGroups=hH(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>SH(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`right`),gH(e.options,yH,`getRightHeaderGroups`)),e.getFooterGroups=hH(()=>[e.getHeaderGroups()],e=>[...e].reverse(),gH(e.options,yH,`getFooterGroups`)),e.getLeftFooterGroups=hH(()=>[e.getLeftHeaderGroups()],e=>[...e].reverse(),gH(e.options,yH,`getLeftFooterGroups`)),e.getCenterFooterGroups=hH(()=>[e.getCenterHeaderGroups()],e=>[...e].reverse(),gH(e.options,yH,`getCenterFooterGroups`)),e.getRightFooterGroups=hH(()=>[e.getRightHeaderGroups()],e=>[...e].reverse(),gH(e.options,yH,`getRightFooterGroups`)),e.getFlatHeaders=hH(()=>[e.getHeaderGroups()],e=>e.map(e=>e.headers).flat(),gH(e.options,yH,`getFlatHeaders`)),e.getLeftFlatHeaders=hH(()=>[e.getLeftHeaderGroups()],e=>e.map(e=>e.headers).flat(),gH(e.options,yH,`getLeftFlatHeaders`)),e.getCenterFlatHeaders=hH(()=>[e.getCenterHeaderGroups()],e=>e.map(e=>e.headers).flat(),gH(e.options,yH,`getCenterFlatHeaders`)),e.getRightFlatHeaders=hH(()=>[e.getRightHeaderGroups()],e=>e.map(e=>e.headers).flat(),gH(e.options,yH,`getRightFlatHeaders`)),e.getCenterLeafHeaders=hH(()=>[e.getCenterFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),gH(e.options,yH,`getCenterLeafHeaders`)),e.getLeftLeafHeaders=hH(()=>[e.getLeftFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),gH(e.options,yH,`getLeftLeafHeaders`)),e.getRightLeafHeaders=hH(()=>[e.getRightFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),gH(e.options,yH,`getRightLeafHeaders`)),e.getLeafHeaders=hH(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(e,t,n)=>[...e[0]?.headers??[],...t[0]?.headers??[],...n[0]?.headers??[]].map(e=>e.getLeafHeaders()).flat(),gH(e.options,yH,`getLeafHeaders`))}};function SH(e,t,n,r){let i=0,a=function(e,t){t===void 0&&(t=1),i=Math.max(i,t),e.filter(e=>e.getIsVisible()).forEach(e=>{var n;(n=e.columns)!=null&&n.length&&a(e.columns,t+1)},0)};a(e);let o=[],s=(e,t)=>{let i={depth:t,id:[r,`${t}`].filter(Boolean).join(`_`),headers:[]},a=[];e.forEach(e=>{let o=[...a].reverse()[0],s=e.column.depth===i.depth,c,l=!1;if(s&&e.column.parent?c=e.column.parent:(c=e.column,l=!0),o&&o?.column===c)o.subHeaders.push(e);else{let i=bH(n,c,{id:[r,t,c.id,e?.id].filter(Boolean).join(`_`),isPlaceholder:l,placeholderId:l?`${a.filter(e=>e.column===c).length}`:void 0,depth:t,index:a.length});i.subHeaders.push(e),a.push(i)}i.headers.push(e),e.headerGroup=i}),o.push(i),t>0&&s(a,t-1)};s(t.map((e,t)=>bH(n,e,{depth:i,index:t})),i-1),o.reverse();let c=e=>e.filter(e=>e.column.getIsVisible()).map(e=>{let t=0,n=0,r=[0];e.subHeaders&&e.subHeaders.length?(r=[],c(e.subHeaders).forEach(e=>{let{colSpan:n,rowSpan:i}=e;t+=n,r.push(i)})):t=1;let i=Math.min(...r);return n+=i,e.colSpan=t,e.rowSpan=n,{colSpan:t,rowSpan:n}});return c(o[0]?.headers??[]),o}var CH=(e,t,n,r,i,a,o)=>{let s={id:t,index:r,original:n,depth:i,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:t=>{if(s._valuesCache.hasOwnProperty(t))return s._valuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return s._valuesCache[t]=n.accessorFn(s.original,r),s._valuesCache[t]},getUniqueValues:t=>{if(s._uniqueValuesCache.hasOwnProperty(t))return s._uniqueValuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return n.columnDef.getUniqueValues?(s._uniqueValuesCache[t]=n.columnDef.getUniqueValues(s.original,r),s._uniqueValuesCache[t]):(s._uniqueValuesCache[t]=[s.getValue(t)],s._uniqueValuesCache[t])},renderValue:t=>s.getValue(t)??e.options.renderFallbackValue,subRows:a??[],getLeafRows:()=>mH(s.subRows,e=>e.subRows),getParentRow:()=>s.parentId?e.getRow(s.parentId,!0):void 0,getParentRows:()=>{let e=[],t=s;for(;;){let n=t.getParentRow();if(!n)break;e.push(n),t=n}return e.reverse()},getAllCells:hH(()=>[e.getAllLeafColumns()],t=>t.map(t=>_H(e,s,t,t.id)),gH(e.options,`debugRows`,`getAllCells`)),_getAllCellsByColumnId:hH(()=>[s.getAllCells()],e=>e.reduce((e,t)=>(e[t.column.id]=t,e),{}),gH(e.options,`debugRows`,`getAllCellsByColumnId`))};for(let t=0;t<e._features.length;t++){let n=e._features[t];n==null||n.createRow==null||n.createRow(s,e)}return s},wH={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},TH=(e,t,n)=>{var r,i;let a=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!(!((i=e.getValue(t))==null||(i=i.toString())==null||(i=i.toLowerCase())==null)&&i.includes(a))};TH.autoRemove=e=>FH(e);var EH=(e,t,n)=>{var r;return!!(!((r=e.getValue(t))==null||(r=r.toString())==null)&&r.includes(n))};EH.autoRemove=e=>FH(e);var DH=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};DH.autoRemove=e=>FH(e);var OH=(e,t,n)=>e.getValue(t)?.includes(n);OH.autoRemove=e=>FH(e);var kH=(e,t,n)=>!n.some(n=>{var r;return!((r=e.getValue(t))!=null&&r.includes(n))});kH.autoRemove=e=>FH(e)||!(e!=null&&e.length);var AH=(e,t,n)=>n.some(n=>e.getValue(t)?.includes(n));AH.autoRemove=e=>FH(e)||!(e!=null&&e.length);var jH=(e,t,n)=>e.getValue(t)===n;jH.autoRemove=e=>FH(e);var MH=(e,t,n)=>e.getValue(t)==n;MH.autoRemove=e=>FH(e);var NH=(e,t,n)=>{let[r,i]=n,a=e.getValue(t);return a>=r&&a<=i};NH.resolveFilterValue=e=>{let[t,n]=e,r=typeof t==`number`?t:parseFloat(t),i=typeof n==`number`?n:parseFloat(n),a=t===null||Number.isNaN(r)?-1/0:r,o=n===null||Number.isNaN(i)?1/0:i;if(a>o){let e=a;a=o,o=e}return[a,o]},NH.autoRemove=e=>FH(e)||FH(e[0])&&FH(e[1]);var PH={includesString:TH,includesStringSensitive:EH,equalsString:DH,arrIncludes:OH,arrIncludesAll:kH,arrIncludesSome:AH,equals:jH,weakEquals:MH,inNumberRange:NH};function FH(e){return e==null||e===``}var IH={getDefaultColumnDef:()=>({filterFn:`auto`}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:dH(`columnFilters`,e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);return typeof n==`string`?PH.includesString:typeof n==`number`?PH.inNumberRange:typeof n==`boolean`||typeof n==`object`&&n?PH.equals:Array.isArray(n)?PH.arrIncludes:PH.weakEquals},e.getFilterFn=()=>fH(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn===`auto`?e.getAutoFilterFn():t.options.filterFns?.[e.columnDef.filterFn]??PH[e.columnDef.filterFn],e.getCanFilter=()=>(e.columnDef.enableColumnFilter??!0)&&(t.options.enableColumnFilters??!0)&&(t.options.enableFilters??!0)&&!!e.accessorFn,e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(t=>t.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>t.getState().columnFilters?.findIndex(t=>t.id===e.id)??-1,e.setFilterValue=n=>{t.setColumnFilters(t=>{let r=e.getFilterFn(),i=t?.find(t=>t.id===e.id),a=uH(n,i?i.value:void 0);if(LH(r,a,e))return t?.filter(t=>t.id!==e.id)??[];let o={id:e.id,value:a};return i?t?.map(t=>t.id===e.id?o:t)??[]:t!=null&&t.length?[...t,o]:[o]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{let n=e.getAllLeafColumns();e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(e=>uH(t,e)?.filter(e=>{let t=n.find(t=>t.id===e.id);return!(t&&LH(t.getFilterFn(),e.value,t))}))},e.resetColumnFilters=t=>{e.setColumnFilters(t?[]:e.initialState?.columnFilters??[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function LH(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||t===void 0||typeof t==`string`&&!t}var RH={sum:(e,t,n)=>n.reduce((t,n)=>{let r=n.getValue(e);return t+(typeof r==`number`?r:0)},0),min:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r>n||r===void 0&&n>=n)&&(r=n)}),r},max:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r<n||r===void 0&&n>=n)&&(r=n)}),r},extent:(e,t,n)=>{let r,i;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r===void 0?n>=n&&(r=i=n):(r>n&&(r=n),i<n&&(i=n)))}),[r,i]},mean:(e,t)=>{let n=0,r=0;if(t.forEach(t=>{let i=t.getValue(e);i!=null&&(i=+i)>=i&&(++n,r+=i)}),n)return r/n},median:(e,t)=>{if(!t.length)return;let n=t.map(t=>t.getValue(e));if(!pH(n))return;if(n.length===1)return n[0];let r=Math.floor(n.length/2),i=n.sort((e,t)=>e-t);return n.length%2==0?(i[r-1]+i[r])/2:i[r]},unique:(e,t)=>Array.from(new Set(t.map(t=>t.getValue(e))).values()),uniqueCount:(e,t)=>new Set(t.map(t=>t.getValue(e))).size,count:(e,t)=>t.length},zH={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t;return((t=e.getValue())==null||t.toString==null?void 0:t.toString())??null},aggregationFn:`auto`}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:dH(`grouping`,e),groupedColumnMode:`reorder`}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(t=>t!=null&&t.includes(e.id)?t.filter(t=>t!==e.id):[...t??[],e.id])},e.getCanGroup=()=>(e.columnDef.enableGrouping??!0)&&(t.options.enableGrouping??!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue),e.getIsGrouped=()=>t.getState().grouping?.includes(e.id),e.getGroupedIndex=()=>t.getState().grouping?.indexOf(e.id),e.getToggleGroupingHandler=()=>{let t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);if(typeof n==`number`)return RH.sum;if(Object.prototype.toString.call(n)===`[object Date]`)return RH.extent},e.getAggregationFn=()=>{if(!e)throw Error();return fH(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn===`auto`?e.getAutoAggregationFn():t.options.aggregationFns?.[e.columnDef.aggregationFn]??RH[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{e.setGrouping(t?[]:e.initialState?.grouping??[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];let r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var t;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((t=n.subRows)!=null&&t.length)}}};function BH(e,t,n){if(!(t!=null&&t.length)||!n)return e;let r=e.filter(e=>!t.includes(e.id));return n===`remove`?r:[...t.map(t=>e.find(e=>e.id===t)).filter(Boolean),...r]}var VH={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:dH(`columnOrder`,e)}),createColumn:(e,t)=>{e.getIndex=hH(e=>[QH(t,e)],t=>t.findIndex(t=>t.id===e.id),gH(t.options,`debugColumns`,`getIndex`)),e.getIsFirstColumn=n=>QH(t,n)[0]?.id===e.id,e.getIsLastColumn=n=>{let r=QH(t,n);return r[r.length-1]?.id===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{e.setColumnOrder(t?[]:e.initialState.columnOrder??[])},e._getOrderColumnsFn=hH(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(e,t,n)=>r=>{let i=[];if(!(e!=null&&e.length))i=r;else{let t=[...e],n=[...r];for(;n.length&&t.length;){let e=t.shift(),r=n.findIndex(t=>t.id===e);r>-1&&i.push(n.splice(r,1)[0])}i=[...i,...n]}return BH(i,t,n)},gH(e.options,`debugTable`,`_getOrderColumnsFn`))}},HH=()=>({left:[],right:[]}),UH={getInitialState:e=>({columnPinning:HH(),...e}),getDefaultOptions:e=>({onColumnPinningChange:dH(`columnPinning`,e)}),createColumn:(e,t)=>{e.pin=n=>{let r=e.getLeafColumns().map(e=>e.id).filter(Boolean);t.setColumnPinning(e=>n===`right`?{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:[...(e?.right??[]).filter(e=>!(r!=null&&r.includes(e))),...r]}:n===`left`?{left:[...(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),...r],right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))}:{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))})},e.getCanPin=()=>e.getLeafColumns().some(e=>(e.columnDef.enablePinning??!0)&&(t.options.enableColumnPinning??t.options.enablePinning??!0)),e.getIsPinned=()=>{let n=e.getLeafColumns().map(e=>e.id),{left:r,right:i}=t.getState().columnPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`left`:o?`right`:!1},e.getPinnedIndex=()=>{var n;let r=e.getIsPinned();return r?((n=t.getState().columnPinning)==null||(n=n[r])==null?void 0:n.indexOf(e.id))??-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=hH(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.column.id))},gH(t.options,`debugRows`,`getCenterVisibleCells`)),e.getLeftVisibleCells=hH(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`left`})),gH(t.options,`debugRows`,`getLeftVisibleCells`)),e.getRightVisibleCells=hH(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`right`})),gH(t.options,`debugRows`,`getRightVisibleCells`))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>e.setColumnPinning(t?HH():e.initialState?.columnPinning??HH()),e.getIsSomeColumnsPinned=t=>{let n=e.getState().columnPinning;return t?!!n[t]?.length:!!(n.left?.length||n.right?.length)},e.getLeftLeafColumns=hH(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),gH(e.options,`debugColumns`,`getLeftLeafColumns`)),e.getRightLeafColumns=hH(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),gH(e.options,`debugColumns`,`getRightLeafColumns`)),e.getCenterLeafColumns=hH(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.id))},gH(e.options,`debugColumns`,`getCenterLeafColumns`))}};function WH(e){return e||(typeof document<`u`?document:null)}var GH={size:150,minSize:20,maxSize:2**53-1},KH=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),qH={getDefaultColumnDef:()=>GH,getInitialState:e=>({columnSizing:{},columnSizingInfo:KH(),...e}),getDefaultOptions:e=>({columnResizeMode:`onEnd`,columnResizeDirection:`ltr`,onColumnSizingChange:dH(`columnSizing`,e),onColumnSizingInfoChange:dH(`columnSizingInfo`,e)}),createColumn:(e,t)=>{e.getSize=()=>{let n=t.getState().columnSizing[e.id];return Math.min(Math.max(e.columnDef.minSize??GH.minSize,n??e.columnDef.size??GH.size),e.columnDef.maxSize??GH.maxSize)},e.getStart=hH(e=>[e,QH(t,e),t.getState().columnSizing],(t,n)=>n.slice(0,e.getIndex(t)).reduce((e,t)=>e+t.getSize(),0),gH(t.options,`debugColumns`,`getStart`)),e.getAfter=hH(e=>[e,QH(t,e),t.getState().columnSizing],(t,n)=>n.slice(e.getIndex(t)+1).reduce((e,t)=>e+t.getSize(),0),gH(t.options,`debugColumns`,`getAfter`)),e.resetSize=()=>{t.setColumnSizing(t=>{let{[e.id]:n,...r}=t;return r})},e.getCanResize=()=>(e.columnDef.enableResizing??!0)&&(t.options.enableColumnResizing??!0),e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let t=0,n=e=>{e.subHeaders.length?e.subHeaders.forEach(n):t+=e.column.getSize()??0};return n(e),t},e.getStart=()=>{if(e.index>0){let t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=n=>{let r=t.getColumn(e.column.id),i=r?.getCanResize();return a=>{if(!r||!i||(a.persist==null||a.persist(),XH(a)&&a.touches&&a.touches.length>1))return;let o=e.getSize(),s=e?e.getLeafHeaders().map(e=>[e.column.id,e.column.getSize()]):[[r.id,r.getSize()]],c=XH(a)?Math.round(a.touches[0].clientX):a.clientX,l={},u=(e,n)=>{typeof n==`number`&&(t.setColumnSizingInfo(e=>{let r=t.options.columnResizeDirection===`rtl`?-1:1,i=(n-(e?.startOffset??0))*r,a=Math.max(i/(e?.startSize??0),-.999999);return e.columnSizingStart.forEach(e=>{let[t,n]=e;l[t]=Math.round(Math.max(n+n*a,0)*100)/100}),{...e,deltaOffset:i,deltaPercentage:a}}),(t.options.columnResizeMode===`onChange`||e===`end`)&&t.setColumnSizing(e=>({...e,...l})))},d=e=>u(`move`,e),f=e=>{u(`end`,e),t.setColumnSizingInfo(e=>({...e,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},p=WH(n),m={moveHandler:e=>d(e.clientX),upHandler:e=>{p?.removeEventListener(`mousemove`,m.moveHandler),p?.removeEventListener(`mouseup`,m.upHandler),f(e.clientX)}},h={moveHandler:e=>(e.cancelable&&(e.preventDefault(),e.stopPropagation()),d(e.touches[0].clientX),!1),upHandler:e=>{p?.removeEventListener(`touchmove`,h.moveHandler),p?.removeEventListener(`touchend`,h.upHandler),e.cancelable&&(e.preventDefault(),e.stopPropagation()),f(e.touches[0]?.clientX)}},g=YH()?{passive:!1}:!1;XH(a)?(p?.addEventListener(`touchmove`,h.moveHandler,g),p?.addEventListener(`touchend`,h.upHandler,g)):(p?.addEventListener(`mousemove`,m.moveHandler,g),p?.addEventListener(`mouseup`,m.upHandler,g)),t.setColumnSizingInfo(e=>({...e,startOffset:c,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:s,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{e.setColumnSizing(t?{}:e.initialState.columnSizing??{})},e.resetHeaderSizeInfo=t=>{e.setColumnSizingInfo(t?KH():e.initialState.columnSizingInfo??KH())},e.getTotalSize=()=>e.getHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getLeftTotalSize=()=>e.getLeftHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getCenterTotalSize=()=>e.getCenterHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getRightTotalSize=()=>e.getRightHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0}},JH=null;function YH(){if(typeof JH==`boolean`)return JH;let e=!1;try{let t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener(`test`,n,t),window.removeEventListener(`test`,n)}catch{e=!1}return JH=e,JH}function XH(e){return e.type===`touchstart`}var ZH={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:dH(`columnVisibility`,e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(t=>({...t,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{let n=e.columns;return(n.length?n.some(e=>e.getIsVisible()):t.getState().columnVisibility?.[e.id])??!0},e.getCanHide=()=>(e.columnDef.enableHiding??!0)&&(t.options.enableHiding??!0),e.getToggleVisibilityHandler=()=>t=>{e.toggleVisibility==null||e.toggleVisibility(t.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=hH(()=>[e.getAllCells(),t.getState().columnVisibility],e=>e.filter(e=>e.column.getIsVisible()),gH(t.options,`debugRows`,`_getAllVisibleCells`)),e.getVisibleCells=hH(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(e,t,n)=>[...e,...t,...n],gH(t.options,`debugRows`,`getVisibleCells`))},createTable:e=>{let t=(t,n)=>hH(()=>[n(),n().filter(e=>e.getIsVisible()).map(e=>e.id).join(`_`)],e=>e.filter(e=>e.getIsVisible==null?void 0:e.getIsVisible()),gH(e.options,`debugColumns`,t));e.getVisibleFlatColumns=t(`getVisibleFlatColumns`,()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t(`getVisibleLeafColumns`,()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t(`getLeftVisibleLeafColumns`,()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t(`getRightVisibleLeafColumns`,()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t(`getCenterVisibleLeafColumns`,()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{e.setColumnVisibility(t?{}:e.initialState.columnVisibility??{})},e.toggleAllColumnsVisible=t=>{t??=!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((e,n)=>({...e,[n.id]:t||!(n.getCanHide!=null&&n.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(e=>!(e.getIsVisible!=null&&e.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(e=>e.getIsVisible==null?void 0:e.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{e.toggleAllColumnsVisible(t.target?.checked)}}};function QH(e,t){return t?t===`center`?e.getCenterVisibleLeafColumns():t===`left`?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}var $H={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,`__global__`),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,`__global__`),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,`__global__`),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},eU={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:dH(`globalFilter`,e),globalFilterFn:`auto`,getColumnCanGlobalFilter:t=>{var n;let r=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof r==`string`||typeof r==`number`}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>(e.columnDef.enableGlobalFilter??!0)&&(t.options.enableGlobalFilter??!0)&&(t.options.enableFilters??!0)&&((t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))??!0)&&!!e.accessorFn},createTable:e=>{e.getGlobalAutoFilterFn=()=>PH.includesString,e.getGlobalFilterFn=()=>{let{globalFilterFn:t}=e.options;return fH(t)?t:t===`auto`?e.getGlobalAutoFilterFn():e.options.filterFns?.[t]??PH[t]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},tU={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:dH(`expanded`,e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=t=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(t),e.toggleAllRowsExpanded=t=>{t??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=t=>{e.setExpanded(t?{}:e.initialState?.expanded??{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(e=>e.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>t=>{t.persist==null||t.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{let t=e.getState().expanded;return t===!0||Object.values(t).some(Boolean)},e.getIsAllRowsExpanded=()=>{let t=e.getState().expanded;return typeof t==`boolean`?t===!0:!(!Object.keys(t).length||e.getRowModel().flatRows.some(e=>!e.getIsExpanded()))},e.getExpandedDepth=()=>{let t=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(e=>{let n=e.split(`.`);t=Math.max(t,n.length)}),t},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{let i=r===!0?!0:!!(r!=null&&r[e.id]),a={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(e=>{a[e]=!0}):a=r,n??=!i,!i&&n)return{...a,[e.id]:!0};if(i&&!n){let{[e.id]:t,...n}=a;return n}return r})},e.getIsExpanded=()=>{let n=t.getState().expanded;return!!((t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))??(n===!0||n?.[e.id]))},e.getCanExpand=()=>{var n;return(t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))??((t.options.enableExpanding??!0)&&!!((n=e.subRows)!=null&&n.length))},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)r=t.getRow(r.parentId,!0),n=r.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{let t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},nU=0,rU=10,iU=()=>({pageIndex:nU,pageSize:rU}),aU={getInitialState:e=>({...e,pagination:{...iU(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:dH(`pagination`,e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=t=>e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(e=>uH(t,e)),e.resetPagination=t=>{e.setPagination(t?iU():e.initialState.pagination??iU())},e.setPageIndex=t=>{e.setPagination(n=>{let r=uH(t,n.pageIndex),i=e.options.pageCount===void 0||e.options.pageCount===-1?2**53-1:e.options.pageCount-1;return r=Math.max(0,Math.min(r,i)),{...n,pageIndex:r}})},e.resetPageIndex=t=>{var n;e.setPageIndex(t?nU:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageIndex)??nU)},e.resetPageSize=t=>{var n;e.setPageSize(t?rU:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageSize)??rU)},e.setPageSize=t=>{e.setPagination(e=>{let n=Math.max(1,uH(t,e.pageSize)),r=e.pageSize*e.pageIndex,i=Math.floor(r/n);return{...e,pageIndex:i,pageSize:n}})},e.setPageCount=t=>e.setPagination(n=>{let r=uH(t,e.options.pageCount??-1);return typeof r==`number`&&(r=Math.max(-1,r)),{...n,pageCount:r}}),e.getPageOptions=hH(()=>[e.getPageCount()],e=>{let t=[];return e&&e>0&&(t=[...Array(e)].fill(null).map((e,t)=>t)),t},gH(e.options,`debugTable`,`getPageOptions`)),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{let{pageIndex:t}=e.getState().pagination,n=e.getPageCount();return n===-1?!0:n===0?!1:t<n-1},e.previousPage=()=>e.setPageIndex(e=>e-1),e.nextPage=()=>e.setPageIndex(e=>e+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>e.options.pageCount??Math.ceil(e.getRowCount()/e.getState().pagination.pageSize),e.getRowCount=()=>e.options.rowCount??e.getPrePaginationRowModel().rows.length}},oU=()=>({top:[],bottom:[]}),sU={getInitialState:e=>({rowPinning:oU(),...e}),getDefaultOptions:e=>({onRowPinningChange:dH(`rowPinning`,e)}),createRow:(e,t)=>{e.pin=(n,r,i)=>{let a=r?e.getLeafRows().map(e=>{let{id:t}=e;return t}):[],o=i?e.getParentRows().map(e=>{let{id:t}=e;return t}):[],s=new Set([...o,e.id,...a]);t.setRowPinning(e=>n===`bottom`?{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:[...(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)]}:n===`top`?{top:[...(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)],bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))}:{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))})},e.getCanPin=()=>{let{enableRowPinning:n,enablePinning:r}=t.options;return typeof n==`function`?n(e):n??r??!0},e.getIsPinned=()=>{let n=[e.id],{top:r,bottom:i}=t.getState().rowPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`top`:o?`bottom`:!1},e.getPinnedIndex=()=>{let n=e.getIsPinned();return n?((n===`top`?t.getTopRows():t.getBottomRows())?.map(e=>{let{id:t}=e;return t}))?.indexOf(e.id)??-1:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>e.setRowPinning(t?oU():e.initialState?.rowPinning??oU()),e.getIsSomeRowsPinned=t=>{let n=e.getState().rowPinning;return t?!!n[t]?.length:!!(n.top?.length||n.bottom?.length)},e._getPinnedRows=(t,n,r)=>(e.options.keepPinnedRows??!0?(n??[]).map(t=>{let n=e.getRow(t,!0);return n.getIsAllParentsExpanded()?n:null}):(n??[]).map(e=>t.find(t=>t.id===e))).filter(Boolean).map(e=>({...e,position:r})),e.getTopRows=hH(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,`top`),gH(e.options,`debugRows`,`getTopRows`)),e.getBottomRows=hH(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,`bottom`),gH(e.options,`debugRows`,`getBottomRows`)),e.getCenterRows=hH(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(e,t,n)=>{let r=new Set([...t??[],...n??[]]);return e.filter(e=>!r.has(e.id))},gH(e.options,`debugRows`,`getCenterRows`))}},cU={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:dH(`rowSelection`,e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>e.setRowSelection(t?{}:e.initialState.rowSelection??{}),e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=t===void 0?!e.getIsAllRowsSelected():t;let r={...n},i=e.getPreGroupedRowModel().flatRows;return t?i.forEach(e=>{e.getCanSelect()&&(r[e.id]=!0)}):i.forEach(e=>{delete r[e.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{let r=t===void 0?!e.getIsAllPageRowsSelected():t,i={...n};return e.getRowModel().rows.forEach(t=>{lU(i,t.id,r,!0,e)}),i}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=hH(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?uU(e,n):{rows:[],flatRows:[],rowsById:{}},gH(e.options,`debugTable`,`getSelectedRowModel`)),e.getFilteredSelectedRowModel=hH(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?uU(e,n):{rows:[],flatRows:[],rowsById:{}},gH(e.options,`debugTable`,`getFilteredSelectedRowModel`)),e.getGroupedSelectedRowModel=hH(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?uU(e,n):{rows:[],flatRows:[],rowsById:{}},gH(e.options,`debugTable`,`getGroupedSelectedRowModel`)),e.getIsAllRowsSelected=()=>{let t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState(),r=!!(t.length&&Object.keys(n).length);return r&&t.some(e=>e.getCanSelect()&&!n[e.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows.filter(e=>e.getCanSelect()),{rowSelection:n}=e.getState(),r=!!t.length;return r&&t.some(e=>!n[e.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{let t=Object.keys(e.getState().rowSelection??{}).length;return t>0&&t<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(e=>e.getCanSelect()).some(e=>e.getIsSelected()||e.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{let i=e.getIsSelected();t.setRowSelection(a=>{if(n=n===void 0?!i:n,e.getCanSelect()&&i===n)return a;let o={...a};return lU(o,e.id,n,r?.selectChildren??!0,t),o})},e.getIsSelected=()=>{let{rowSelection:n}=t.getState();return dU(e,n)},e.getIsSomeSelected=()=>{let{rowSelection:n}=t.getState();return fU(e,n)===`some`},e.getIsAllSubRowsSelected=()=>{let{rowSelection:n}=t.getState();return fU(e,n)===`all`},e.getCanSelect=()=>typeof t.options.enableRowSelection==`function`?t.options.enableRowSelection(e):t.options.enableRowSelection??!0,e.getCanSelectSubRows=()=>typeof t.options.enableSubRowSelection==`function`?t.options.enableSubRowSelection(e):t.options.enableSubRowSelection??!0,e.getCanMultiSelect=()=>typeof t.options.enableMultiRowSelection==`function`?t.options.enableMultiRowSelection(e):t.options.enableMultiRowSelection??!0,e.getToggleSelectedHandler=()=>{let t=e.getCanSelect();return n=>{t&&e.toggleSelected(n.target?.checked)}}}},lU=(e,t,n,r,i)=>{var a;let o=i.getRow(t,!0);n?(o.getCanMultiSelect()||Object.keys(e).forEach(t=>delete e[t]),o.getCanSelect()&&(e[t]=!0)):delete e[t],r&&(a=o.subRows)!=null&&a.length&&o.getCanSelectSubRows()&&o.subRows.forEach(t=>lU(e,t.id,n,r,i))};function uU(e,t){let n=e.getState().rowSelection,r=[],i={},a=function(e,t){return e.map(e=>{var t;let o=dU(e,n);if(o&&(r.push(e),i[e.id]=e),(t=e.subRows)!=null&&t.length&&(e={...e,subRows:a(e.subRows)}),o)return e}).filter(Boolean)};return{rows:a(t.rows),flatRows:r,rowsById:i}}function dU(e,t){return t[e.id]??!1}function fU(e,t,n){var r;if(!((r=e.subRows)!=null&&r.length))return!1;let i=!0,a=!1;return e.subRows.forEach(e=>{if(!(a&&!i)&&(e.getCanSelect()&&(dU(e,t)?a=!0:i=!1),e.subRows&&e.subRows.length)){let n=fU(e,t);n===`all`?a=!0:(n===`some`&&(a=!0),i=!1)}}),i?`all`:a?`some`:!1}var pU=/([0-9]+)/gm,mU=(e,t,n)=>SU(xU(e.getValue(n)).toLowerCase(),xU(t.getValue(n)).toLowerCase()),hU=(e,t,n)=>SU(xU(e.getValue(n)),xU(t.getValue(n))),gU=(e,t,n)=>bU(xU(e.getValue(n)).toLowerCase(),xU(t.getValue(n)).toLowerCase()),_U=(e,t,n)=>bU(xU(e.getValue(n)),xU(t.getValue(n))),vU=(e,t,n)=>{let r=e.getValue(n),i=t.getValue(n);return r>i?1:r<i?-1:0},yU=(e,t,n)=>bU(e.getValue(n),t.getValue(n));function bU(e,t){return e===t?0:e>t?1:-1}function xU(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function SU(e,t){let n=e.split(pU).filter(Boolean),r=t.split(pU).filter(Boolean);for(;n.length&&r.length;){let e=n.shift(),t=r.shift(),i=parseInt(e,10),a=parseInt(t,10),o=[i,a].sort();if(isNaN(o[0])){if(e>t)return 1;if(t>e)return-1;continue}if(isNaN(o[1]))return isNaN(i)?-1:1;if(i>a)return 1;if(a>i)return-1}return n.length-r.length}var CU={alphanumeric:mU,alphanumericCaseSensitive:hU,text:gU,textCaseSensitive:_U,datetime:vU,basic:yU},wU=[xH,ZH,VH,UH,wH,IH,$H,eU,{getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:`auto`,sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:dH(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{let n=t.getFilteredRowModel().flatRows.slice(10),r=!1;for(let t of n){let n=t?.getValue(e.id);if(Object.prototype.toString.call(n)===`[object Date]`)return CU.datetime;if(typeof n==`string`&&(r=!0,n.split(pU).length>1))return CU.alphanumeric}return r?CU.text:CU.basic},e.getAutoSortDir=()=>typeof t.getFilteredRowModel().flatRows[0]?.getValue(e.id)==`string`?`asc`:`desc`,e.getSortingFn=()=>{if(!e)throw Error();return fH(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn===`auto`?e.getAutoSortingFn():t.options.sortingFns?.[e.columnDef.sortingFn]??CU[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{let i=e.getNextSortingOrder(),a=n!=null;t.setSorting(o=>{let s=o?.find(t=>t.id===e.id),c=o?.findIndex(t=>t.id===e.id),l=[],u,d=a?n:i===`desc`;return u=o!=null&&o.length&&e.getCanMultiSort()&&r?s?`toggle`:`add`:o!=null&&o.length&&c!==o.length-1?`replace`:s?`toggle`:`replace`,u===`toggle`&&(a||i||(u=`remove`)),u===`add`?(l=[...o,{id:e.id,desc:d}],l.splice(0,l.length-(t.options.maxMultiSortColCount??2**53-1))):l=u===`toggle`?o.map(t=>t.id===e.id?{...t,desc:d}:t):u===`remove`?o.filter(t=>t.id!==e.id):[{id:e.id,desc:d}],l})},e.getFirstSortDir=()=>e.columnDef.sortDescFirst??t.options.sortDescFirst??e.getAutoSortDir()===`desc`?`desc`:`asc`,e.getNextSortingOrder=n=>{let r=e.getFirstSortDir(),i=e.getIsSorted();return i?i!==r&&(t.options.enableSortingRemoval??!0)&&(!n||(t.options.enableMultiRemove??!0))?!1:i===`desc`?`asc`:`desc`:r},e.getCanSort=()=>(e.columnDef.enableSorting??!0)&&(t.options.enableSorting??!0)&&!!e.accessorFn,e.getCanMultiSort=()=>e.columnDef.enableMultiSort??t.options.enableMultiSort??!!e.accessorFn,e.getIsSorted=()=>{let n=t.getState().sorting?.find(t=>t.id===e.id);return n?n.desc?`desc`:`asc`:!1},e.getSortIndex=()=>t.getState().sorting?.findIndex(t=>t.id===e.id)??-1,e.clearSorting=()=>{t.setSorting(t=>t!=null&&t.length?t.filter(t=>t.id!==e.id):[])},e.getToggleSortingHandler=()=>{let n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{e.setSorting(t?[]:e.initialState?.sorting??[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},zH,tU,aU,sU,cU,qH];function TU(e){let t=[...wU,...e._features??[]],n={_features:t},r=n._features.reduce((e,t)=>Object.assign(e,t.getDefaultOptions==null?void 0:t.getDefaultOptions(n)),{}),i=e=>n.options.mergeOptions?n.options.mergeOptions(r,e):{...r,...e},a={...e.initialState??{}};n._features.forEach(e=>{a=(e.getInitialState==null?void 0:e.getInitialState(a))??a});let o=[],s=!1,c={_features:t,options:{...r,...e},initialState:a,_queue:e=>{o.push(e),s||(s=!0,Promise.resolve().then(()=>{for(;o.length;)o.shift()();s=!1}).catch(e=>setTimeout(()=>{throw e})))},reset:()=>{n.setState(n.initialState)},setOptions:e=>{n.options=i(uH(e,n.options))},getState:()=>n.options.state,setState:e=>{n.options.onStateChange==null||n.options.onStateChange(e)},_getRowId:(e,t,r)=>(n.options.getRowId==null?void 0:n.options.getRowId(e,t,r))??`${r?[r.id,t].join(`.`):t}`,getCoreRowModel:()=>(n._getCoreRowModel||=n.options.getCoreRowModel(n),n._getCoreRowModel()),getRowModel:()=>n.getPaginationRowModel(),getRow:(e,t)=>{let r=(t?n.getPrePaginationRowModel():n.getRowModel()).rowsById[e];if(!r&&(r=n.getCoreRowModel().rowsById[e],!r))throw Error();return r},_getDefaultColumnDef:hH(()=>[n.options.defaultColumn],e=>(e??={},{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>{var t;return((t=e.renderValue())==null||t.toString==null?void 0:t.toString())??null},...n._features.reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef==null?void 0:t.getDefaultColumnDef()),{}),...e}),gH(e,`debugColumns`,`_getDefaultColumnDef`)),_getColumnDefs:()=>n.options.columns,getAllColumns:hH(()=>[n._getColumnDefs()],e=>{let t=function(e,r,i){return i===void 0&&(i=0),e.map(e=>{let a=vH(n,e,i,r),o=e;return a.columns=o.columns?t(o.columns,a,i+1):[],a})};return t(e)},gH(e,`debugColumns`,`getAllColumns`)),getAllFlatColumns:hH(()=>[n.getAllColumns()],e=>e.flatMap(e=>e.getFlatColumns()),gH(e,`debugColumns`,`getAllFlatColumns`)),_getAllFlatColumnsById:hH(()=>[n.getAllFlatColumns()],e=>e.reduce((e,t)=>(e[t.id]=t,e),{}),gH(e,`debugColumns`,`getAllFlatColumnsById`)),getAllLeafColumns:hH(()=>[n.getAllColumns(),n._getOrderColumnsFn()],(e,t)=>t(e.flatMap(e=>e.getLeafColumns())),gH(e,`debugColumns`,`getAllLeafColumns`)),getColumn:e=>n._getAllFlatColumnsById()[e]};Object.assign(n,c);for(let e=0;e<n._features.length;e++){let t=n._features[e];t==null||t.createTable==null||t.createTable(n)}return n}function EU(){return e=>hH(()=>[e.options.data],t=>{let n={rows:[],flatRows:[],rowsById:{}},r=function(t,i,a){i===void 0&&(i=0);let o=[];for(let c=0;c<t.length;c++){let l=CH(e,e._getRowId(t[c],c,a),t[c],c,i,void 0,a?.id);if(n.flatRows.push(l),n.rowsById[l.id]=l,o.push(l),e.options.getSubRows){var s;l.originalSubRows=e.options.getSubRows(t[c],c),(s=l.originalSubRows)!=null&&s.length&&(l.subRows=r(l.originalSubRows,i+1,l))}}return o};return n.rows=r(t),n},gH(e.options,`debugTable`,`getRowModel`,()=>e._autoResetPageIndex()))}function DU(){return e=>hH(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(t!=null&&t.length))return n;let r=e.getState().sorting,i=[],a=r.filter(t=>e.getColumn(t.id)?.getCanSort()),o={};a.forEach(t=>{let n=e.getColumn(t.id);n&&(o[t.id]={sortUndefined:n.columnDef.sortUndefined,invertSorting:n.columnDef.invertSorting,sortingFn:n.getSortingFn()})});let s=e=>{let t=e.map(e=>({...e}));return t.sort((e,t)=>{for(let n=0;n<a.length;n+=1){let r=a[n],i=o[r.id],s=i.sortUndefined,c=r?.desc??!1,l=0;if(s){let n=e.getValue(r.id),i=t.getValue(r.id),a=n===void 0,o=i===void 0;if(a||o){if(s===`first`)return a?-1:1;if(s===`last`)return a?1:-1;l=a&&o?0:a?s:-s}}if(l===0&&(l=i.sortingFn(e,t,r.id)),l!==0)return c&&(l*=-1),i.invertSorting&&(l*=-1),l}return e.index-t.index}),t.forEach(e=>{var t;i.push(e),(t=e.subRows)!=null&&t.length&&(e.subRows=s(e.subRows))}),t};return{rows:s(n.rows),flatRows:i,rowsById:n.rowsById}},gH(e.options,`debugTable`,`getSortedRowModel`,()=>e._autoResetPageIndex()))}function OU(e,t){return e?kU(e)?b.createElement(e,t):e:null}function kU(e){return AU(e)||typeof e==`function`||jU(e)}function AU(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function jU(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function MU(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=b.useState(()=>({current:TU(t)})),[r,i]=b.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{i(t),e.onStateChange==null||e.onStateChange(t)}})),n.current}var NU=_();function PU(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function FU(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function IU(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var LU=(e,t)=>Math.abs(e-t)<1.01,RU=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},zU,BU=()=>{if(zU!==void 0)return zU;if(typeof navigator>`u`)return zU=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return zU=!0;let e=navigator.maxTouchPoints;return zU=navigator.platform===`MacIntel`&&e!==void 0&&e>0},VU=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},HU=e=>e,UU=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},WU=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(VU(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(VU(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},GU={passive:!0},KU=typeof window>`u`?!0:`onscrollend`in window,qU=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&KU,o=0,s=a?null:RU(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,GU),a&&r.addEventListener(`scrollend`,u,GU),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},JU=(e,t)=>qU(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),YU=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},XU=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},ZU=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:HU,rangeExtractor:UU,onChange:()=>{},measureElement:YU,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=e.start+t;n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=FU(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!BU()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,GU),e.addEventListener(`touchend`,n,GU),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(BU()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=FU(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=FU(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=PU(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=FU(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?$U({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=FU(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);if(o!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,s=a?this.getTotalSize():0,c=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(i)||this.scrollDirection!==`backward`):this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-s):c&&this.applyScrollAdjustment(o),this.notify(!1)}},this.getVirtualItems=FU(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return IU(t[QU(0,t.length-1,r?e=>n[e*2]:e=>IU(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(BU()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&LU(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},QU=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function $U({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=QU(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var eW=typeof document<`u`?b.useLayoutEffect:b.useEffect;function tW({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=b.useReducer(e=>e+1,0)[1],a=b.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}let r=!!e.options.horizontal,i=t.mode===`transform`,o=r?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let n of c){let a=n.start-s,c=e.elementsCache.get(n.key);c&&t.lastPositions.get(c)!==a&&(t.lastPositions.set(c,a),i?c.style.transform=r?`translate3d(${a}px, 0, 0)`:`translate3d(0, ${a}px, 0)`:c.style[o]=`${a}px`)}},s={...r,onChange:(t,n)=>{var s;let c=a.current,l=!0;if(c.enabled){o(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,NU.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=b.useState(()=>{let e=new ZU(s);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return c.setOptions(s),eW(()=>c._didMount(),[]),eW(()=>c._willUpdate()),eW(()=>{o(c)}),c}function nW(e){return tW({observeElementRect:WU,observeElementOffset:JU,scrollToFn:XU,...e})}function rW(e){return Nz(e)}function iW(e){return e==null?`—`:`$`+e.toFixed(2)}function aW(e){if(!e||e<=0)return`—`;let t=Math.floor(e/60),n=Math.floor(t/60);return n>0?`${n}h ${t%60}m`:`${t}m`}function oW(e){return e?new Date(e*1e3).toLocaleString(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`—`}var sW=lH(),cW={review:`tag-review`,exploration:`tag-exploration`,planning:`tag-planning`,memory:`tag-memory`,generic:`tag-generic`};function lW({data:e}){let[t,n]=(0,b.useState)(``),[r,i]=(0,b.useState)([{id:`started_at`,desc:!0}]),a=(0,b.useRef)(null),o=(0,b.useMemo)(()=>{if(!e?.data)return[];let n=t.toLowerCase();return n?e.data.filter(e=>(e.repo_label||``).toLowerCase().includes(n)||(e.model_name||``).toLowerCase().includes(n)||(e.agent_role||``).toLowerCase().includes(n)||(e.agent_nickname||``).toLowerCase().includes(n)||(e.title||``).toLowerCase().includes(n)||(e.descendant_models||[]).some(e=>(e||``).toLowerCase().includes(n))||(e.descendant_families||[]).some(e=>(e||``).toLowerCase().includes(n))||(e.descendant_roles||[]).some(e=>(e||``).toLowerCase().includes(n))||(e.descendant_nicknames||[]).some(e=>(e||``).toLowerCase().includes(n))||(e.related_titles||[]).some(e=>(e||``).toLowerCase().includes(n))):e.data},[e,t]),s=(0,b.useMemo)(()=>[sW.accessor(`started_at`,{header:`Time`,cell:e=>oW(e.getValue()),size:130}),sW.accessor(`repo_label`,{header:`Repo`,cell:e=>e.getValue()||`—`,size:140}),sW.accessor(`model_name`,{header:`Model`,cell:e=>(0,z.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,fontSize:`0.72rem`},children:e.getValue()||`?`}),size:130}),sW.accessor(`thread_count`,{header:`Threads`,cell:e=>{let t=e.getValue()||1,n=e.row.original;return t>1?`${t} (${n.subagent_count||0} sub)`:`1`},size:92}),sW.accessor(`agent_family`,{header:`Root`,cell:e=>(0,z.jsx)(`span`,{className:`tag ${cW[e.getValue()]||`tag-generic`}`,children:e.getValue()}),size:100}),sW.accessor(`agent_nickname`,{header:`Agent`,cell:e=>e.getValue()||`—`,size:85}),sW.accessor(`reasoning_effort`,{header:`Effort`,cell:e=>e.getValue()||`—`,size:70}),sW.accessor(`elapsed_seconds`,{header:`Duration`,cell:e=>aW(e.getValue()),size:85}),sW.accessor(`tokens_used`,{header:`Tokens`,cell:e=>(0,z.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`},children:rW(e.getValue())}),size:90}),sW.accessor(`cost`,{header:`Cost`,cell:e=>(0,z.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`},children:e.getValue()==null?`—`:iW(e.getValue())}),size:80}),sW.accessor(`title`,{header:`Title`,cell:e=>(0,z.jsx)(`span`,{title:e.getValue(),style:{opacity:.6},children:(e.getValue()||``).slice(0,55)}),size:240})],[]),c=MU({data:o,columns:s,state:{sorting:r},onSortingChange:i,getCoreRowModel:EU(),getSortedRowModel:DU()}),l=c.getRowModel().rows,u=(0,b.useMemo)(()=>o.reduce((e,t)=>(e.sessions+=1,e.tokens+=t.tokens_used||0,e.cost+=t.cost||0,e.elapsed+=t.elapsed_seconds||0,e),{sessions:0,tokens:0,cost:0,elapsed:0}),[o]),d=nW({count:l.length,getScrollElement:()=>a.current,estimateSize:()=>36,overscan:10,getItemKey:e=>l[e]?.id??e}),f=d.getVirtualItems(),p=f.length>0?f[0].start:0,m=f.length>0?d.getTotalSize()-f[f.length-1].end:0;return(0,z.jsx)(`div`,{className:`animate-in`,children:(0,z.jsxs)(`div`,{className:`table-wrap`,children:[(0,z.jsx)(`div`,{className:`table-search`,children:(0,z.jsx)(`input`,{placeholder:`Search sessions...`,value:t,onChange:e=>n(e.target.value)})}),(0,z.jsxs)(`div`,{style:{fontSize:`0.7rem`,color:`var(--text-muted)`,padding:`0.4rem 1rem`,borderBottom:`1px solid var(--border)`},children:[o.length.toLocaleString(),` root sessions`,e&&!e.complete&&(0,z.jsx)(`span`,{className:`incomplete-badge`,style:{marginLeft:`0.5rem`},children:`partial`})]}),(0,z.jsxs)(`div`,{style:{fontSize:`0.7rem`,color:`var(--text-muted)`,padding:`0.45rem 1rem`,borderBottom:`1px solid var(--border)`,display:`flex`,gap:`1rem`,flexWrap:`wrap`},children:[(0,z.jsxs)(`span`,{children:[`Filtered sessions: `,(0,z.jsx)(`strong`,{style:{color:`var(--text-secondary)`},children:u.sessions.toLocaleString()})]}),(0,z.jsxs)(`span`,{children:[`Tokens: `,(0,z.jsx)(`strong`,{style:{color:`var(--text-secondary)`},children:rW(u.tokens)})]}),(0,z.jsxs)(`span`,{children:[`Cost: `,(0,z.jsx)(`strong`,{style:{color:`var(--text-secondary)`},children:iW(u.cost)})]}),(0,z.jsxs)(`span`,{children:[`Time: `,(0,z.jsx)(`strong`,{style:{color:`var(--text-secondary)`},children:aW(u.elapsed)})]})]}),(0,z.jsx)(`div`,{ref:a,style:{height:`600px`,overflow:`auto`},children:(0,z.jsxs)(`table`,{style:{tableLayout:`fixed`,width:`100%`},children:[(0,z.jsx)(`thead`,{style:{position:`sticky`,top:0,background:`var(--bg-card)`,zIndex:1},children:c.getHeaderGroups().map(e=>(0,z.jsx)(`tr`,{children:e.headers.map(e=>(0,z.jsxs)(`th`,{style:{width:e.getSize()},onClick:e.column.getToggleSortingHandler(),children:[OU(e.column.columnDef.header,e.getContext()),{asc:` ↑`,desc:` ↓`}[e.column.getIsSorted()]||``]},e.id))},e.id))}),(0,z.jsxs)(`tbody`,{children:[f.length===0&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:s.length,style:{textAlign:`center`,padding:`2rem`,color:`var(--text-muted)`},children:`No sessions`})}),p>0&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:s.length,style:{height:`${p}px`,padding:0,borderBottom:`none`}})}),f.map(e=>{let t=l[e.index];return(0,z.jsx)(`tr`,{style:{height:e.size},children:t.getVisibleCells().map(e=>(0,z.jsx)(`td`,{style:{width:e.column.getSize()},children:OU(e.column.columnDef.cell,e.getContext())},e.id))},t.id)}),m>0&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:s.length,style:{height:`${m}px`,padding:0,borderBottom:`none`}})})]})]})})]})})}function uW(){return{ingest_id:null,seq:0,overview:{total:{},d7:{},d30:{},cost_assumptions:null},repos:{total:[],d7:[],d30:[]},models:{total:[],d7:[],d30:[]},families:{total:[],d7:[],d30:[]},daily:{},heatmap:{}}}function dW(e,t,n){let r=n===`bootstrap`||n===`snapshot`||n===`complete`||!e||e.ingest_id!==t.ingest_id?uW():{...e};return r.ingest_id=t.ingest_id,r.seq=t.seq,t.data?.overview?r.overview={...r.overview,...t.data.overview,total:t.data.overview.total?{...r.overview.total,...t.data.overview.total}:r.overview.total,d7:t.data.overview.d7?{...r.overview.d7,...t.data.overview.d7}:r.overview.d7,d30:t.data.overview.d30?{...r.overview.d30,...t.data.overview.d30}:r.overview.d30}:e&&(r.overview=e.overview),r.repos=fW(e?.repos,t.data?.repos,r.repos),r.models=fW(e?.models,t.data?.models,r.models),r.families=fW(e?.families,t.data?.families,r.families),r.daily=t.data?.daily?{...e?.daily||{},...t.data.daily}:e?.daily||r.daily,r.heatmap=t.data?.heatmap?{...e?.heatmap||{},...t.data.heatmap}:e?.heatmap||r.heatmap,r}function fW(e,t,n){if(!t)return e||n;let r={total:e?e.total:n.total,d7:e?e.d7:n.d7,d30:e?e.d30:n.d30};for(let e of[`total`,`d7`,`d30`])t[e]&&(r[e]=t[e]);return r}function pW(e){return e?{overview:{data:e.overview,coverage:e.overview?.total?.coverage||{total:0,enriched:0,priced:0,time_valid:0}},repos:{data:e.repos},models:{data:e.models},families:{data:e.families},daily:{data:Object.entries(e.daily).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({date:e,...t}))},heatmap:{data:e.heatmap}}:null}function mW(e,t,n=0){let r=uW();return r.ingest_id=t||null,r.seq=n,r.overview=e?.overview?.data||r.overview,r.repos=e?.repos?.data||r.repos,r.models=e?.models?.data||r.models,r.families=e?.families?.data||r.families,r.daily=Object.fromEntries((e?.daily?.data||[]).map(e=>[e.date,{...e}])),r.heatmap=e?.heatmap?.data||r.heatmap,r}function hW(e){let t=e.replay?.bootstrap?.payload||{},n=CW(t.progress||{percent:0,complete:!1}),r=dW(null,t,`bootstrap`),i=e.replay?.events||[],a=i.findIndex(EW),o=a>=0&&i[a].at_ms||0,s=wW(e,r,i),c=s[0]?.presentation||MW(),l=CW(a>=0&&i[a].payload?.progress||n),u=Math.max(e.startHoldDurationMs||0,0),d=Math.max(e.replayDurationMs||e.replay?.duration_ms||1,1),f=Math.max(e.tailDurationMs||0,0),p=Math.max(e.finalHoldDurationMs||0,0),m=Math.max(e.durationMs||u+d+f+p||1,1),h=Math.max(e.replay?.duration_ms||0,0),g=Math.min(Math.max(o,0),h),_=Math.max(1,h-g),v=NW(e.tailSourceFraction??.035),y=Math.max(1,Math.round(_*v)),b=Math.max(0,_-y),x=Math.max(g,h-y),S=e.replayEasing||`cubicInOut`,C=e.tailEasing||`cubicInOut`,w=TW(e)||s[s.length-1]?.presentation||c,T=jW(s,x),E=Math.min(3600,Math.max(1800,Math.round(d*.32))),D=Math.max(0+u,0+u+d-E),O=NW((D-(0+u))/Math.max(d,1)),k=Math.round(g+b*BW(S,O)),A=AW({keyframes:s,startSourceMs:k,endSourceMs:x,startPresentation:jW(s,k),endPresentation:T,durationMs:E,startSmoothing:.05,endSmoothing:.14}),j=kW({keyframes:s,tailSourceStartMs:x,sourceDurationMs:h,tailStartPresentation:T,finalPresentation:w,tailDurationMs:f});return{renderData:e,totalDurationMs:m,frontloadSettledDurationMs:0,startHoldDurationMs:u,replayDurationMs:d,tailDurationMs:f,finalHoldDurationMs:p,sourceDurationMs:h,sourceStartMs:g,effectiveSourceDurationMs:_,tailSourceDurationMs:y,tailSourceStartMs:x,mainReplaySourceDurationMs:b,replayStartMs:u,lateReplayStartMs:D,lateReplayDurationMs:E,lateReplaySourceStartMs:k,tailStartMs:u+d,finalHoldStartMs:u+d+f,currentSeekMs:0,started:!1,finished:!1,startWallClockMs:0,initialPresentation:c,presentation:c,keyframes:s,keyframeIndex:0,lateReplayFrames:A,tailStartPresentation:T,tailFrames:j,finalPresentation:w,progress:l||{...n,percent:0,complete:!1},bootstrapProgress:n,replayEasing:S,tailEasing:C,debugState:null,debugTrace:[]}}function gW(e){return{liveData:{ready:!0},presentation:e.presentation,rawPresentation:e.presentation,progress:e.progress,phase:e.debugState?.phase||`replay`,seekMs:e.currentSeekMs||0}}function _W(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||MW();else if(n<e.tailStartMs)if(n<e.lateReplayStartMs)i=vW(e,n),e.presentation=DW(e,i);else{let t=NW((n-e.lateReplayStartMs)/Math.max(e.lateReplayDurationMs,1));i=PW(e.lateReplaySourceStartMs,e.tailSourceStartMs,t),e.presentation=OW(e.lateReplayFrames,LW(t))}else n<e.finalHoldStartMs?(r=`tail`,a=NW((n-e.tailStartMs)/Math.max(e.tailDurationMs,1)),e.presentation=OW(e.tailFrames,BW(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:FW(e.presentation)};return e.debugState=o,e.debugTrace.push(o),gW(e)}function vW(e,t){if(t<=e.replayStartMs)return 0;let n=t-e.replayStartMs;if(n<=e.replayDurationMs){let t=NW(n/Math.max(e.replayDurationMs,1));return e.sourceStartMs+e.mainReplaySourceDurationMs*BW(e.replayEasing,t)}return e.sourceDurationMs}function yW(e,t,n,r){if(!e)return t;let i=Iz.videoExport||{};if(r<(i.displayTweenStartMs??200))return t;let a=(i.startHoldDurationMs??0)+(i.replayDurationMs??0)+(i.tailDurationMs??0)+(i.finalHoldDurationMs??0)||19e3,o=i.displayTweenLateWindowMs??2200,s=NW((r-(a-o))/Math.max(o,1)),c=Math.round(PW(i.displayTweenBaseMs??240,i.displayTweenLateMs??420,RW(s))),l=RW(1-Math.exp(-n/Math.max(c,1))),u=e.progress||{},d=t.progress||{};return{liveData:t.liveData,presentation:wB(e.presentation,t.presentation,l),rawPresentation:t.rawPresentation||t.presentation,progress:{...d,percent:PW(u.percent||0,d.percent||0,l),complete:d.complete},phase:t.phase,seekMs:t.seekMs||0}}function bW(e,t){let n=Iz.videoExport||{},r=Math.max(n.finalFlashDurationMs??280,0),i=Math.max(n.finalFlashDelayMs??0,0),a=Math.max(n.finalFlashMaxOpacity??.22,0);if(!r||!a||t==null)return{opacity:0,boxShadow:`none`};let o=e-t-i;if(o<0||o>r)return{opacity:0,boxShadow:`none`};let s=a*(1-RW(NW(o/r)));return{opacity:s,boxShadow:`0 0 120px 50px rgba(255, 255, 255, ${Math.min(1,s*.7)}) inset`}}function xW(e){let t=Iz.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 a=NW((e-r)/i);return n*(1-BW(t.introFadeEasing||`cubicOut`,a))}function SW(e){let t=Iz.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 a=NW((e-r)/i);return PW(n,1,BW(t.introFadeEasing||`cubicOut`,a))}function CW(e){return e?{...e}:null}function wW(e,t,n){let r=[],i=t;for(let e of n)EW(e)&&(i=dW(i,e.payload,e.event),r.push({at_ms:Math.max(0,e.at_ms||0),presentation:yB({overview:{data:i.overview},heatmap:{data:i.heatmap},daily:{data:Object.entries(i.daily).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({date:e,...t}))},families:{data:i.families},repos:{data:i.repos},models:{data:i.models},range:`total`})}));return r.length||r.push({at_ms:0,presentation:MW()}),r}function TW(e){let t=e.settledEnvelope;return t?.overview?.data?yB({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 EW(e){return e?.payload?.data&&(e.event===`patch`||e.event===`snapshot`||e.event===`complete`)}function DW(e,t){return jW(e.keyframes,t,e)}function OW(e,t){if(!e?.length)return MW();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=NW((t-r.u)/Math.max(i.u-r.u,1e-6));return wB(r.presentation,i.presentation,e)}}return e[e.length-1].presentation}function kW({keyframes:e,tailSourceStartMs:t,sourceDurationMs:n,tailStartPresentation:r,finalPresentation:i,tailDurationMs:a}){return AW({keyframes:e,startSourceMs:t,endSourceMs:n,startPresentation:r,endPresentation:i,durationMs:a,startSmoothing:.08,endSmoothing:.2,bidirectional:!0})}function AW({keyframes:e,startSourceMs:t,endSourceMs:n,startPresentation:r,endPresentation:i,durationMs:a,startSmoothing:o,endSmoothing:s,bidirectional:c=!1}){let l=Math.max(36,Math.min(96,Math.round(a/80))),u=[{u:0,presentation:r}];for(let r=1;r<l-1;r+=1){let i=r/(l-1),a=PW(t,n,i);u.push({u:i,presentation:jW(e,a)})}u.push({u:1,presentation:i});let d=[{u:0,presentation:r}],f=r;for(let e=1;e<u.length-1;e+=1){let t=u[e],n=PW(o,s,t.u);f=wB(f,t.presentation,n),d.push({u:t.u,presentation:f})}if(d.push({u:1,presentation:i}),!c)return d;let p=Array(u.length);p[u.length-1]={u:1,presentation:i};let m=i;for(let e=u.length-2;e>0;--e){let t=u[e],n=PW(s,o,1-t.u);m=wB(m,t.presentation,n),p[e]={u:t.u,presentation:m}}return p[0]={u:0,presentation:r},u.map((e,t)=>t===0?{u:0,presentation:r}:t===u.length-1?{u:1,presentation:i}:{u:e.u,presentation:wB(d[t].presentation,p[t].presentation,LW(e.u))})}function jW(e,t,n=null){if(!e.length)return MW();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 o=NW((t-i.at_ms)/Math.max(a.at_ms-i.at_ms,1));return wB(i.presentation,a.presentation,o)}function MW(){return yB({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 NW(e){return Math.min(Math.max(e||0,0),1)}function PW(e,t,n){return e+(t-e)*n}function FW(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 IW(e){let t=NW(e);return t*t*t}function LW(e){let t=NW(e);return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function RW(e){return 1-(1-NW(e))**3}function zW(e){let t=NW(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 PW(i,o,LW(NW((t-r)/Math.max(a-r,1e-6))))}return 1}function BW(e,t){switch(e){case`trainBrake`:return zW(t);case`cubicOut`:return RW(t);case`cubicInOut`:return LW(t);case`linear`:return NW(t);default:return IW(t)}}function VW({jobId:e}){let[t,n]=(0,b.useState)(null),[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)(!1),l=(0,b.useRef)(null),u=(0,b.useRef)(0),d=(0,b.useRef)(null),f=(0,b.useRef)(0),p=(0,b.useRef)(null);if((0,b.useEffect)(()=>{let t=!0;return(async()=>{try{let r=await fetch(E.url(`/api/export/${encodeURIComponent(e)}/render-data`));if(!r.ok)throw Error(`API error: ${r.status}`);let i=await r.json();if(!t)return;n(i),l.current=hW(i);let a=gW(l.current);d.current=a,f.current=0,o(a),c(!1),p.current=null}catch(e){if(!t)return;i(e.message||String(e))}})(),()=>{t=!1,u.current&&cancelAnimationFrame(u.current)}},[e]),(0,b.useEffect)(()=>{if(!a?.liveData||r)return;let e=!1,t=0,n=0,i=0,o=0,s=0,l=()=>{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`),a=n.length>=3&&i&&n.every(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0}),u=document.querySelectorAll(`.heatmap-cell`).length>=300;if(!(r&&a&&u)){o=requestAnimationFrame(l);return}s=window.setTimeout(()=>{e||c(!0)},180)};return t=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>{i=requestAnimationFrame(()=>{o=requestAnimationFrame(l)})})}),()=>{e=!0,t&&cancelAnimationFrame(t),n&&cancelAnimationFrame(n),i&&cancelAnimationFrame(i),o&&cancelAnimationFrame(o),s&&window.clearTimeout(s)}},[r,a]),(0,b.useEffect)(()=>{if(a){if(a.phase===`final_hold`){p.current??=a.seekMs||0;return}p.current=null}},[a?.phase,a?.seekMs]),(0,b.useEffect)(()=>{let n=()=>{let e=l.current;if(!e||e.started)return;e.started=!0,e.startWallClockMs=Date.now();let t=()=>{let e=l.current;if(!e)return;let n=Date.now(),r=Math.min(e.totalDurationMs,n-e.startWallClockMs),i=_W(e,r),a=f.current?Math.max(1,n-f.current):16;f.current=n;let s=yW(d.current,i,a,r);if(d.current=s,o(s),r>=e.totalDurationMs){e.finished=!0,u.current=0;return}u.current=requestAnimationFrame(t)};u.current=requestAnimationFrame(t)};return window.__CODEXMETER_EXPORT__={ready:!!(t&&!r&&s),jobId:e,start(){n()},get currentTimeMs(){return l.current?.currentSeekMs||0},get finished(){return!!l.current?.finished},getDebugState(){return l.current?.debugState||null},getDebugTrace(){return l.current?.debugTrace||[]}},()=>{delete window.__CODEXMETER_EXPORT__}},[s,r,e,t]),r)return(0,z.jsx)(`div`,{style:HW,children:(0,z.jsxs)(`div`,{style:WW,children:[`Export error: `,r]})});if(!a?.liveData)return(0,z.jsx)(`div`,{style:HW,children:(0,z.jsx)(`div`,{style:WW,children:`CodexMeter exporting…`})});let m=l.current,h=m?{startMs:m.startHoldDurationMs,endMs:m.finalHoldStartMs}:null;return(0,z.jsx)(`div`,{style:HW,children:(0,z.jsxs)(`div`,{style:UW,children:[(0,z.jsxs)(`div`,{style:{...YW,opacity:SW(a.seekMs)},children:[(0,z.jsx)(fV,{presentation:a.presentation,rawPresentation:a.rawPresentation,ingestProgress:Math.min(Math.max(a.progress?.percent||0,0),1),isIngestActive:!!(a.progress&&!a.progress.complete),exportMode:!1,exportPlayback:!0,exportPhase:a.phase,exportSeekMs:a.seekMs,exportDaily:m?.finalPresentation?.daily||null,exportDailyTiming:h}),(0,z.jsxs)(`div`,{style:GW,children:[`Made with `,(0,z.jsx)(`span`,{style:KW,children:`♥`}),` by JJ`]})]}),(0,z.jsx)(`div`,{style:{...JW,opacity:xW(a.seekMs)}}),(0,z.jsx)(`div`,{style:{...qW,...bW(a.seekMs,p.current)}})]})})}var HW={width:`100vw`,minHeight:`100vh`,background:`#06080f`,display:`flex`,alignItems:`center`,justifyContent:`center`,overflow:`hidden`},UW={position:`relative`,width:1080,height:864,padding:`24px 28px 20px`,background:`#06080f`,overflow:`hidden`},WW={color:`#8b949e`,fontFamily:`'JetBrains Mono', 'Fira Code', monospace`,fontSize:18},GW={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`},KW={color:`rgba(244, 63, 94, 0.52)`},qW={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`},JW={position:`absolute`,inset:0,background:`#000000`,pointerEvents:`none`,zIndex:30},YW={position:`relative`,zIndex:1},XW=[`Overview`,`Repos`,`Models`,`Daily`,`Sessions`],ZW=[{key:`d7`,label:`7d`},{key:`d30`,label:`30d`},{key:`total`,label:`All`}];function QW(e){return e?new Date(e*1e3).toLocaleDateString(`en-US`,{month:`short`,day:`2-digit`}):`—`}function $W(e){return!Number.isFinite(e)||e<=0?0:Math.floor(e/86400)*86400}function eG(e){let t=Date.parse(`${e}T12:00:00Z`);return Number.isFinite(t)?Math.floor(t/1e3):null}var tG={idle:`Starting...`,inventory:`Reading threads`,normalizing:`Normalizing`,enrichment:`Enriching rollouts`,aggregation:`Building aggregates`,finalizing:`Finalizing view`,complete:`Complete`,error:`Error`};function nG(e){return Object.values(e?.daily||{}).filter(e=>(e?.tokens||0)>0||(e?.sessions||0)>0).length>=7}function rG(){let e=typeof window<`u`?new URLSearchParams(window.location.search):null,t=e?.get(`export`),n=e?.get(`job`);if(t===`overview-video`&&n)return(0,z.jsx)(VW,{jobId:n});let[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(`Overview`),[s,c]=(0,b.useState)(`total`),[l,u]=(0,b.useState)({}),[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(!0),[h,g]=(0,b.useState)(!1),[_,v]=(0,b.useState)(!1),[y,x]=(0,b.useState)(!1),[S,C]=(0,b.useState)(!1),[w,T]=(0,b.useState)(!1),[D,O]=(0,b.useState)(!0),[k,A]=(0,b.useState)(!1),[j,ee]=(0,b.useState)(null),[M,N]=(0,b.useState)(!1),[P,F]=(0,b.useState)(!1),[I,te]=(0,b.useState)({available:!0,reason:null,portable_download:null}),[ne,re]=(0,b.useState)(null),[ie,ae]=(0,b.useState)(null),[oe,se]=(0,b.useState)(null),[ce,L]=(0,b.useState)(null),[le,ue]=(0,b.useState)(null),[de,fe]=(0,b.useState)(null),pe=(0,b.useRef)(!1),me=(0,b.useRef)(0),he=(0,b.useRef)(null),R=(0,b.useCallback)(async()=>{try{let[e,t,n,r,i,a,o]=await Promise.all([E.overview(),E.repos(),E.models(),E.daily(),E.sessions(),E.heatmap(),E.families()]),s={overview:e,repos:t,models:n,daily:r,sessions:i,heatmap:a,families:o};return u(s),s}catch(e){throw console.error(`Fetch error:`,e),e}},[]),ge=(0,b.useCallback)(async()=>{if(!w)try{T(!0),o(`Overview`),await E.rerun(),window.location.reload()}catch(e){console.error(`Rerun error:`,e),T(!1)}},[w]),_e=(0,b.useCallback)(async()=>{if(!(M||[`queued`,`running`].includes(j?.status)))try{N(!0);let e=!I?.available&&I?.portable_download?.available,t=!1;if(e){let e=I.portable_download.approx_size_mb?`about ${I.portable_download.approx_size_mb} MB`:`a fairly large download`;if(!window.confirm(`No supported browser was found for video export.\n\nCodexMeter can download a single-use portable Chromium bundle (${e}) for this export only, then delete it afterward.\n\nDo you want to continue?`))return;t=!0,F(!0)}ee(await E.startOverviewVideoExport(t?{install_portable_browser:!0}:{}))}catch(e){console.error(`Video export error:`,e)}finally{N(!1)}},[j?.status,I,M]);(0,b.useEffect)(()=>{P&&j&&j.phase!==`downloading_browser`&&(j.phase===`rendering`||j.phase===`encoding`||j.status===`complete`||j.status===`failed`)&&F(!1)},[j,P]);let ve=(0,b.useCallback)(()=>{!j?.id||j.status!==`complete`||(window.location.href=E.url(`/api/export/${encodeURIComponent(j.id)}/file`))},[j]);(0,b.useEffect)(()=>{!j?.id||j.status!==`complete`||he.current!==j.id&&(he.current=j.id,window.location.href=E.url(`/api/export/${encodeURIComponent(j.id)}/file`))},[j]),(0,b.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await E.exportSupport();e&&te(t)}catch(t){console.error(`Export support probe error:`,t),e&&te({available:!1,reason:`Video export availability could not be detected.`,portable_download:null})}})(),()=>{e=!1}},[]),(0,b.useEffect)(()=>{let e=!0,t=null,n=null,r=!1,a=!1,o=!1,s=!1,c=[],l=0,u=null,d=null,p=null,m=!1,h=()=>{p&&=(clearTimeout(p),null)},g=()=>{if(l=0,!e||c.length===0)return;let t=u,n=d;for(let e of c){let{payload:r,mode:i,progressOnly:a}=e;if(n=r.progress,!a){if(t&&r.ingest_id===t.ingest_id&&r.seq<=t.seq)continue;t=dW(t,r,i)}}zB(`apply`,{events:c.map(e=>({mode:e.mode,progressOnly:e.progressOnly,seq:e.payload?.seq})),progress:n,state:RB(t,n)}),c=[],n!==d&&(d=n,i(n)),t!==u&&(u=t,f(t),!m&&nG(t)&&(m=!0,v(!0),zB(`initial-live-ready`,RB(t,n))))},_=(e,t,n=!1)=>{zB(`receive`,{mode:t,progressOnly:n,payload:LB(e)}),c.push({payload:e,mode:t,progressOnly:n}),h(),l||=requestAnimationFrame(g)},y=(e,t=null,n=0)=>{let r=mW(e,t,Math.max((u?.seq||0)+1,n,1));u=r,f(r)},b=async(t,n=null,{hydrateLiveState:r=!1,seq:i=0}={})=>{if(!(!e||!t)){if(t.complete){if(o)return;o=!0;let t=await R();return e&&r&&y(t,n,i),t}if(t.partial_ready&&!s){s=!0;try{return await R()}catch(e){throw s=!1,e}}}},x=()=>{if(r||!e)return;r=!0;let n=async()=>{try{let n=await E.progress();if(!e)return;if(i(n),n.percent>.08&&await R(),n.complete){await R(),clearInterval(t);return}(n.error||n.phase===`error`)&&clearInterval(t)}catch(e){console.error(`Polling fallback error:`,e)}};n(),t=setInterval(n,1200)};return(()=>{if(typeof EventSource>`u`){x();return}n=E.live(),n.addEventListener(`bootstrap`,t=>{if(!e)return;let n=JSON.parse(t.data);_(n,`bootstrap`),b(n.progress,n.ingest_id).catch(e=>{console.error(`Settled fetch error:`,e),o=!1})}),n.addEventListener(`progress`,t=>{if(!e)return;let n=JSON.parse(t.data);_(n,`progress`,!0),b(n.progress,n.ingest_id).catch(e=>{console.error(`Settled fetch error:`,e),o=!1})}),n.addEventListener(`patch`,t=>{e&&_(JSON.parse(t.data),`patch`)}),n.addEventListener(`snapshot`,t=>{e&&_(JSON.parse(t.data),`snapshot`)}),n.addEventListener(`complete`,async t=>{if(!e)return;let r=JSON.parse(t.data);a=!0,_(r,r.data?`complete`:`progress`,!r.data),await b(r.progress,r.ingest_id,{hydrateLiveState:!0,seq:(r.seq||0)+1}),e&&n?.close()}),n.addEventListener(`ingest-error`,t=>{if(!e)return;let r=JSON.parse(t.data);a=!0,_(r,`progress`,!0),n?.close()}),n.addEventListener(`error`,t=>{if(e&&!a){if(n?.readyState===EventSource.CLOSED){console.warn(`SSE stream closed, falling back to polling:`,t),x();return}n?.readyState===EventSource.CONNECTING&&!r&&!p&&(p=setTimeout(()=>{p=null,!(!e||a||r)&&n?.readyState!==EventSource.OPEN&&(console.warn(`SSE stream stalled during reconnect, falling back to polling:`,t),n?.close(),x())},4e3))}})})(),()=>{e=!1,clearInterval(t),h(),l&&cancelAnimationFrame(l),n?.close()}},[R]),(0,b.useEffect)(()=>{if(r){if((_||r.partial_ready||r.percent>.08)&&p&&!h){g(!0);let e=setTimeout(()=>m(!1),600);return()=>clearTimeout(e)}if(r.complete&&p&&!h){g(!0);let e=setTimeout(()=>m(!1),600);return()=>clearTimeout(e)}}},[r,_,p,h]);let ye=!!r?.complete,be=!!l.overview?.data,xe=ye||be,Se=Math.round((r?.percent||0)*100),Ce=Math.min(Math.max(r?.percent||0,0),1),we=!ye||k,Te=!!(r&&we&&r.phase!==`error`);(0,b.useEffect)(()=>{r?.complete||O(!1)},[r?.complete]),(0,b.useEffect)(()=>{let e=ye&&!pe.current;if(pe.current=ye,!ye){A(!1);return}if(e&&!D){A(!0);return}k&&D&&A(!1)},[ye,D,k]),(0,b.useEffect)(()=>{let e=!0,t=null,n=async()=>{try{let r=!!j?.id,i=r?await E.exportStatus(j.id):await E.activeExport();if(!e)return;let a=r?i:i.job;if(!a){j?.id||ee(null);return}ee(a),[`complete`,`failed`].includes(a.status)||(t=setTimeout(n,900))}catch(t){if(!e)return;console.error(`Export status error:`,t)}};return ye&&n(),()=>{e=!1,t&&clearTimeout(t)}},[ye,j?.id]),(0,b.useEffect)(()=>{!we&&!y&&x(!0),we&&(x(!1),C(!1))},[we,y]),(0,b.useEffect)(()=>{if(!y)return;let e=setTimeout(()=>C(!0),350);return()=>clearTimeout(e)},[y]);let Ee=(0,b.useMemo)(()=>d?pW(d):null,[d]),De=!!(Ee&&!be),Oe=De?Ee.overview:l.overview||Ee?.overview,ke=De?Ee.heatmap:l.heatmap||Ee?.heatmap,Ae=De?Ee.daily:l.daily||Ee?.daily,je=De?Ee.families:l.families||Ee?.families,Me=De?Ee.repos:l.repos||Ee?.repos,Ne=De?Ee.models:l.models||Ee?.models,Pe=Oe?.data,Fe=(Pe?.[s]||Pe?.total||{})?.date_range,Ie=Te&&de?.from?eG(de.from):null,Le=Te&&de?.to?eG(de.to):null,Re=Fe&&Le?{...Fe,from:Ie||Fe.from,to:Le}:Fe;(0,b.useEffect)(()=>{if(me.current&&=(cancelAnimationFrame(me.current),0),!Re?.from||!Re?.to){re(null);return}let e={from:$W(Re.from),to:$W(Re.to)};return re(t=>{if(!t||ye||Te||t.from!==e.from||e.to<=t.to)return e;let n=t.to,r=e.to,i=Math.max(1,Math.round((r-n)/86400)),a=Math.min(1400,Math.max(320,i*110)),o=performance.now(),s=t=>{let i=Math.min(1,(t-o)/a),c=$W(n+(r-n)*i);re(t=>!t||t.from!==e.from||c<=t.to?t:{...t,to:c}),i<1?me.current=requestAnimationFrame(s):(me.current=0,re(e))};return me.current=requestAnimationFrame(s),t}),()=>{me.current&&=(cancelAnimationFrame(me.current),0)}},[ye,Re?.from,Re?.to,Te]);let ze=M||[`queued`,`running`].includes(j?.status),Be=!I?.available&&I?.portable_download?.available,Ve=P||Be&&M||Be&&j?.phase===`downloading_browser`?`Downloading single-use portable Chromium for this export.`:!I?.available&&!Be?I.reason||`Video export requires Chrome, Chromium, or Edge.`:Be?`No supported browser found. Click to download a single-use portable Chromium for this export.`:ye?ze?`Video export is already running.`:`Render Overview ingest replay video`:`Finish ingest to render the replay video.`,He=(0,b.useCallback)(e=>{e&&(c(`d7`),o(`Daily`),ae({id:Date.now(),centerDate:e}))},[]),Ue=(0,b.useCallback)(e=>{e&&(o(`Repos`),se({id:Date.now(),repoLabel:String(e)}))},[]),We=(0,b.useCallback)(e=>{e&&(o(`Models`),L({id:Date.now(),modelName:String(e)}))},[]),Ge=j?.status===`complete`?`Download MP4`:P||ze&&(M&&Be||j?.phase===`downloading_browser`)?`Downloading ${Math.max(1,Math.round((j?.progress||.03)*100))}%`:ze?`Rendering ${Math.max(1,Math.round((j?.progress||0)*100))}%`:`Render Video`;return(0,z.jsxs)(`div`,{className:`app`,children:[p&&(0,z.jsxs)(`div`,{className:`loading-overlay ${h?`fading`:``}`,children:[(0,z.jsx)(`div`,{className:`loading-logo`,children:`CodexMeter`}),(0,z.jsx)(`div`,{className:`loading-bar-wrap`,children:(0,z.jsx)(`div`,{className:`loading-bar`,style:{width:`${Se}%`}})}),(0,z.jsx)(`div`,{className:`loading-phase`,children:tG[r?.phase]||`Starting...`}),r?.phase===`enrichment`&&(0,z.jsxs)(`div`,{className:`loading-detail`,children:[r.enriched,`/`,r.needs_enrichment,` rollouts`,r.current_date_bucket&&` — ${r.current_date_bucket}`]}),r?.phase===`error`&&r?.error&&(0,z.jsx)(`div`,{className:`loading-detail`,children:r.error}),(0,z.jsxs)(`div`,{className:`loading-footer`,children:[`Made with `,(0,z.jsx)(`span`,{className:`loading-heart`,children:`♥`}),` by JJ`]})]}),(0,z.jsxs)(`div`,{className:`app-content ${h||!p?`app-content-revealed`:``}`,children:[(0,z.jsx)(`nav`,{className:`navbar`,children:(0,z.jsxs)(`div`,{className:`navbar-inner`,children:[(0,z.jsx)(`span`,{className:`navbar-brand`,children:`CodexMeter`}),(0,z.jsx)(`div`,{className:`navbar-tabs`,children:XW.map(e=>(0,z.jsx)(`button`,{className:`navbar-tab ${a===e?`active`:``} ${!xe&&e!==`Overview`?`navbar-tab-dimmed`:``}`,onClick:()=>o(e),disabled:!xe&&e!==`Overview`,children:e},e))}),(0,z.jsx)(`div`,{className:`navbar-meta`,children:Re&&(0,z.jsxs)(`div`,{className:`navbar-date-wrap ${xe?``:`navbar-date-wrap-dimmed`}`,children:[(0,z.jsxs)(`span`,{className:`navbar-date`,style:{fontSize:`0.78rem`,color:`var(--text-muted)`,fontFamily:`var(--font-mono)`},children:[QW(ne?.from||Re.from),` — `,QW(ne?.to||Re.to)]}),(0,z.jsx)(`div`,{className:`range-toggle`,children:ZW.map(e=>(0,z.jsx)(`button`,{className:`range-btn ${s===e.key?`active`:``}`,onClick:()=>c(e.key),disabled:!xe,children:e.label},e.key))}),(0,z.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":`Rerun ingest`,title:`Rerun ingest`,onClick:ge,disabled:w||!ye,children:`↻`}),(0,z.jsx)(`button`,{type:`button`,className:`navbar-tab active export-video-btn ${I?.available?``:`range-btn-unsupported`}`,onClick:j?.status===`complete`?ve:_e,disabled:!I?.available&&!Be||!ye||ze,style:{minWidth:110},title:j?.status===`complete`?`Download rendered Overview video`:Ve,children:Ge})]})})]})}),(0,z.jsxs)(`div`,{className:`main-content`,children:[a===`Overview`&&(0,z.jsx)(hV,{data:Oe,heatmap:ke,daily:Ae,families:je,repos:Me,models:Ne,range:s,onPresentationSettledChange:O,ingestProgress:Ce,isIngestActive:Te,currentDateBucket:r?.current_date_bucket||null,onDailyDebugStatsChange:ue,onPresentationDateRangeChange:fe,onNavigateToDailyDay:He,onNavigateToRepo:Ue,onNavigateToModel:We}),a===`Repos`&&(0,z.jsx)(jV,{data:l.repos,range:s,focusRequest:oe,onFocusRequestConsumed:()=>se(null)}),a===`Models`&&(0,z.jsx)(zV,{data:l.models,range:s,focusRequest:ce,onFocusRequestConsumed:()=>L(null)}),a===`Daily`&&(0,z.jsx)(cH,{data:l.daily,range:s,navigateToDayRequest:ie,onNavigateToDayConsumed:()=>ae(null)}),a===`Sessions`&&(0,z.jsx)(lW,{data:l.sessions})]}),Te&&le&&(0,z.jsxs)(`div`,{className:`app-footer-debug`,children:[`Daily Usage presentation: `,le.speedDaysPerSecond.toFixed(1),` days/s`,le.waitingForDailyData?` (waiting for daily data)`:``]}),(0,z.jsxs)(`div`,{className:`app-footer`,children:[`Made with `,(0,z.jsx)(`span`,{className:`loading-heart`,children:`♥`}),` by JJ`]})]})]})}x.createRoot(document.getElementById(`root`)).render((0,z.jsx)(rG,{}));
|
|
31
|
+
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return i}}function vH(e,t,n,r){return{debug:()=>e?.debugAll??e[t],key:!1,onChange:r}}function yH(e,t,n,r){let i={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:()=>i.getValue()??e.options.renderFallbackValue,getContext:_H(()=>[e,n,t,i],(e,t,n,r)=>({table:e,column:t,row:n,cell:r,getValue:r.getValue,renderValue:r.renderValue}),vH(e.options,`debugCells`,`cell.getContext`))};return e._features.forEach(r=>{r.createCell==null||r.createCell(i,n,t,e)},{}),i}function bH(e,t,n,r){let i={...e._getDefaultColumnDef(),...t},a=i.accessorKey,o=i.id??(a?typeof String.prototype.replaceAll==`function`?a.replaceAll(`.`,`_`):a.replace(/\./g,`_`):void 0)??(typeof i.header==`string`?i.header:void 0),s;if(i.accessorFn?s=i.accessorFn:a&&(s=a.includes(`.`)?e=>{let t=e;for(let e of a.split(`.`))t=t?.[e];return t}:e=>e[i.accessorKey]),!o)throw Error();let c={id:`${String(o)}`,accessorFn:s,parent:r,depth:n,columnDef:i,columns:[],getFlatColumns:_H(()=>[!0],()=>[c,...c.columns?.flatMap(e=>e.getFlatColumns())],vH(e.options,`debugColumns`,`column.getFlatColumns`)),getLeafColumns:_H(()=>[e._getOrderColumnsFn()],e=>{var t;return(t=c.columns)!=null&&t.length?e(c.columns.flatMap(e=>e.getLeafColumns())):[c]},vH(e.options,`debugColumns`,`column.getLeafColumns`))};for(let t of e._features)t.createColumn==null||t.createColumn(c,e);return c}var xH=`debugHeaders`;function SH(e,t,n){let r={id:n.id??t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{let e=[],t=n=>{n.subHeaders&&n.subHeaders.length&&n.subHeaders.map(t),e.push(n)};return t(r),e},getContext:()=>({table:e,header:r,column:t})};return e._features.forEach(t=>{t.createHeader==null||t.createHeader(r,e)}),r}var CH={createTable:e=>{e.getHeaderGroups=_H(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>{let a=r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],o=i?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],s=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id)));return wH(t,[...a,...s,...o],e)},vH(e.options,xH,`getHeaderGroups`)),e.getCenterHeaderGroups=_H(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>(n=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id))),wH(t,n,e,`center`)),vH(e.options,xH,`getCenterHeaderGroups`)),e.getLeftHeaderGroups=_H(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>wH(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`left`),vH(e.options,xH,`getLeftHeaderGroups`)),e.getRightHeaderGroups=_H(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>wH(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`right`),vH(e.options,xH,`getRightHeaderGroups`)),e.getFooterGroups=_H(()=>[e.getHeaderGroups()],e=>[...e].reverse(),vH(e.options,xH,`getFooterGroups`)),e.getLeftFooterGroups=_H(()=>[e.getLeftHeaderGroups()],e=>[...e].reverse(),vH(e.options,xH,`getLeftFooterGroups`)),e.getCenterFooterGroups=_H(()=>[e.getCenterHeaderGroups()],e=>[...e].reverse(),vH(e.options,xH,`getCenterFooterGroups`)),e.getRightFooterGroups=_H(()=>[e.getRightHeaderGroups()],e=>[...e].reverse(),vH(e.options,xH,`getRightFooterGroups`)),e.getFlatHeaders=_H(()=>[e.getHeaderGroups()],e=>e.map(e=>e.headers).flat(),vH(e.options,xH,`getFlatHeaders`)),e.getLeftFlatHeaders=_H(()=>[e.getLeftHeaderGroups()],e=>e.map(e=>e.headers).flat(),vH(e.options,xH,`getLeftFlatHeaders`)),e.getCenterFlatHeaders=_H(()=>[e.getCenterHeaderGroups()],e=>e.map(e=>e.headers).flat(),vH(e.options,xH,`getCenterFlatHeaders`)),e.getRightFlatHeaders=_H(()=>[e.getRightHeaderGroups()],e=>e.map(e=>e.headers).flat(),vH(e.options,xH,`getRightFlatHeaders`)),e.getCenterLeafHeaders=_H(()=>[e.getCenterFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),vH(e.options,xH,`getCenterLeafHeaders`)),e.getLeftLeafHeaders=_H(()=>[e.getLeftFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),vH(e.options,xH,`getLeftLeafHeaders`)),e.getRightLeafHeaders=_H(()=>[e.getRightFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),vH(e.options,xH,`getRightLeafHeaders`)),e.getLeafHeaders=_H(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(e,t,n)=>[...e[0]?.headers??[],...t[0]?.headers??[],...n[0]?.headers??[]].map(e=>e.getLeafHeaders()).flat(),vH(e.options,xH,`getLeafHeaders`))}};function wH(e,t,n,r){let i=0,a=function(e,t){t===void 0&&(t=1),i=Math.max(i,t),e.filter(e=>e.getIsVisible()).forEach(e=>{var n;(n=e.columns)!=null&&n.length&&a(e.columns,t+1)},0)};a(e);let o=[],s=(e,t)=>{let i={depth:t,id:[r,`${t}`].filter(Boolean).join(`_`),headers:[]},a=[];e.forEach(e=>{let o=[...a].reverse()[0],s=e.column.depth===i.depth,c,l=!1;if(s&&e.column.parent?c=e.column.parent:(c=e.column,l=!0),o&&o?.column===c)o.subHeaders.push(e);else{let i=SH(n,c,{id:[r,t,c.id,e?.id].filter(Boolean).join(`_`),isPlaceholder:l,placeholderId:l?`${a.filter(e=>e.column===c).length}`:void 0,depth:t,index:a.length});i.subHeaders.push(e),a.push(i)}i.headers.push(e),e.headerGroup=i}),o.push(i),t>0&&s(a,t-1)};s(t.map((e,t)=>SH(n,e,{depth:i,index:t})),i-1),o.reverse();let c=e=>e.filter(e=>e.column.getIsVisible()).map(e=>{let t=0,n=0,r=[0];e.subHeaders&&e.subHeaders.length?(r=[],c(e.subHeaders).forEach(e=>{let{colSpan:n,rowSpan:i}=e;t+=n,r.push(i)})):t=1;let i=Math.min(...r);return n+=i,e.colSpan=t,e.rowSpan=n,{colSpan:t,rowSpan:n}});return c(o[0]?.headers??[]),o}var TH=(e,t,n,r,i,a,o)=>{let s={id:t,index:r,original:n,depth:i,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:t=>{if(s._valuesCache.hasOwnProperty(t))return s._valuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return s._valuesCache[t]=n.accessorFn(s.original,r),s._valuesCache[t]},getUniqueValues:t=>{if(s._uniqueValuesCache.hasOwnProperty(t))return s._uniqueValuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return n.columnDef.getUniqueValues?(s._uniqueValuesCache[t]=n.columnDef.getUniqueValues(s.original,r),s._uniqueValuesCache[t]):(s._uniqueValuesCache[t]=[s.getValue(t)],s._uniqueValuesCache[t])},renderValue:t=>s.getValue(t)??e.options.renderFallbackValue,subRows:a??[],getLeafRows:()=>gH(s.subRows,e=>e.subRows),getParentRow:()=>s.parentId?e.getRow(s.parentId,!0):void 0,getParentRows:()=>{let e=[],t=s;for(;;){let n=t.getParentRow();if(!n)break;e.push(n),t=n}return e.reverse()},getAllCells:_H(()=>[e.getAllLeafColumns()],t=>t.map(t=>yH(e,s,t,t.id)),vH(e.options,`debugRows`,`getAllCells`)),_getAllCellsByColumnId:_H(()=>[s.getAllCells()],e=>e.reduce((e,t)=>(e[t.column.id]=t,e),{}),vH(e.options,`debugRows`,`getAllCellsByColumnId`))};for(let t=0;t<e._features.length;t++){let n=e._features[t];n==null||n.createRow==null||n.createRow(s,e)}return s},EH={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},DH=(e,t,n)=>{var r,i;let a=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!(!((i=e.getValue(t))==null||(i=i.toString())==null||(i=i.toLowerCase())==null)&&i.includes(a))};DH.autoRemove=e=>LH(e);var OH=(e,t,n)=>{var r;return!!(!((r=e.getValue(t))==null||(r=r.toString())==null)&&r.includes(n))};OH.autoRemove=e=>LH(e);var kH=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};kH.autoRemove=e=>LH(e);var AH=(e,t,n)=>e.getValue(t)?.includes(n);AH.autoRemove=e=>LH(e);var jH=(e,t,n)=>!n.some(n=>{var r;return!((r=e.getValue(t))!=null&&r.includes(n))});jH.autoRemove=e=>LH(e)||!(e!=null&&e.length);var MH=(e,t,n)=>n.some(n=>e.getValue(t)?.includes(n));MH.autoRemove=e=>LH(e)||!(e!=null&&e.length);var NH=(e,t,n)=>e.getValue(t)===n;NH.autoRemove=e=>LH(e);var PH=(e,t,n)=>e.getValue(t)==n;PH.autoRemove=e=>LH(e);var FH=(e,t,n)=>{let[r,i]=n,a=e.getValue(t);return a>=r&&a<=i};FH.resolveFilterValue=e=>{let[t,n]=e,r=typeof t==`number`?t:parseFloat(t),i=typeof n==`number`?n:parseFloat(n),a=t===null||Number.isNaN(r)?-1/0:r,o=n===null||Number.isNaN(i)?1/0:i;if(a>o){let e=a;a=o,o=e}return[a,o]},FH.autoRemove=e=>LH(e)||LH(e[0])&&LH(e[1]);var IH={includesString:DH,includesStringSensitive:OH,equalsString:kH,arrIncludes:AH,arrIncludesAll:jH,arrIncludesSome:MH,equals:NH,weakEquals:PH,inNumberRange:FH};function LH(e){return e==null||e===``}var RH={getDefaultColumnDef:()=>({filterFn:`auto`}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:pH(`columnFilters`,e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);return typeof n==`string`?IH.includesString:typeof n==`number`?IH.inNumberRange:typeof n==`boolean`||typeof n==`object`&&n?IH.equals:Array.isArray(n)?IH.arrIncludes:IH.weakEquals},e.getFilterFn=()=>mH(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn===`auto`?e.getAutoFilterFn():t.options.filterFns?.[e.columnDef.filterFn]??IH[e.columnDef.filterFn],e.getCanFilter=()=>(e.columnDef.enableColumnFilter??!0)&&(t.options.enableColumnFilters??!0)&&(t.options.enableFilters??!0)&&!!e.accessorFn,e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(t=>t.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>t.getState().columnFilters?.findIndex(t=>t.id===e.id)??-1,e.setFilterValue=n=>{t.setColumnFilters(t=>{let r=e.getFilterFn(),i=t?.find(t=>t.id===e.id),a=fH(n,i?i.value:void 0);if(zH(r,a,e))return t?.filter(t=>t.id!==e.id)??[];let o={id:e.id,value:a};return i?t?.map(t=>t.id===e.id?o:t)??[]:t!=null&&t.length?[...t,o]:[o]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{let n=e.getAllLeafColumns();e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(e=>fH(t,e)?.filter(e=>{let t=n.find(t=>t.id===e.id);return!(t&&zH(t.getFilterFn(),e.value,t))}))},e.resetColumnFilters=t=>{e.setColumnFilters(t?[]:e.initialState?.columnFilters??[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function zH(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||t===void 0||typeof t==`string`&&!t}var BH={sum:(e,t,n)=>n.reduce((t,n)=>{let r=n.getValue(e);return t+(typeof r==`number`?r:0)},0),min:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r>n||r===void 0&&n>=n)&&(r=n)}),r},max:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r<n||r===void 0&&n>=n)&&(r=n)}),r},extent:(e,t,n)=>{let r,i;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r===void 0?n>=n&&(r=i=n):(r>n&&(r=n),i<n&&(i=n)))}),[r,i]},mean:(e,t)=>{let n=0,r=0;if(t.forEach(t=>{let i=t.getValue(e);i!=null&&(i=+i)>=i&&(++n,r+=i)}),n)return r/n},median:(e,t)=>{if(!t.length)return;let n=t.map(t=>t.getValue(e));if(!hH(n))return;if(n.length===1)return n[0];let r=Math.floor(n.length/2),i=n.sort((e,t)=>e-t);return n.length%2==0?(i[r-1]+i[r])/2:i[r]},unique:(e,t)=>Array.from(new Set(t.map(t=>t.getValue(e))).values()),uniqueCount:(e,t)=>new Set(t.map(t=>t.getValue(e))).size,count:(e,t)=>t.length},VH={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t;return((t=e.getValue())==null||t.toString==null?void 0:t.toString())??null},aggregationFn:`auto`}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:pH(`grouping`,e),groupedColumnMode:`reorder`}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(t=>t!=null&&t.includes(e.id)?t.filter(t=>t!==e.id):[...t??[],e.id])},e.getCanGroup=()=>(e.columnDef.enableGrouping??!0)&&(t.options.enableGrouping??!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue),e.getIsGrouped=()=>t.getState().grouping?.includes(e.id),e.getGroupedIndex=()=>t.getState().grouping?.indexOf(e.id),e.getToggleGroupingHandler=()=>{let t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);if(typeof n==`number`)return BH.sum;if(Object.prototype.toString.call(n)===`[object Date]`)return BH.extent},e.getAggregationFn=()=>{if(!e)throw Error();return mH(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn===`auto`?e.getAutoAggregationFn():t.options.aggregationFns?.[e.columnDef.aggregationFn]??BH[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{e.setGrouping(t?[]:e.initialState?.grouping??[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];let r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var t;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((t=n.subRows)!=null&&t.length)}}};function HH(e,t,n){if(!(t!=null&&t.length)||!n)return e;let r=e.filter(e=>!t.includes(e.id));return n===`remove`?r:[...t.map(t=>e.find(e=>e.id===t)).filter(Boolean),...r]}var UH={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:pH(`columnOrder`,e)}),createColumn:(e,t)=>{e.getIndex=_H(e=>[eU(t,e)],t=>t.findIndex(t=>t.id===e.id),vH(t.options,`debugColumns`,`getIndex`)),e.getIsFirstColumn=n=>eU(t,n)[0]?.id===e.id,e.getIsLastColumn=n=>{let r=eU(t,n);return r[r.length-1]?.id===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{e.setColumnOrder(t?[]:e.initialState.columnOrder??[])},e._getOrderColumnsFn=_H(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(e,t,n)=>r=>{let i=[];if(!(e!=null&&e.length))i=r;else{let t=[...e],n=[...r];for(;n.length&&t.length;){let e=t.shift(),r=n.findIndex(t=>t.id===e);r>-1&&i.push(n.splice(r,1)[0])}i=[...i,...n]}return HH(i,t,n)},vH(e.options,`debugTable`,`_getOrderColumnsFn`))}},WH=()=>({left:[],right:[]}),GH={getInitialState:e=>({columnPinning:WH(),...e}),getDefaultOptions:e=>({onColumnPinningChange:pH(`columnPinning`,e)}),createColumn:(e,t)=>{e.pin=n=>{let r=e.getLeafColumns().map(e=>e.id).filter(Boolean);t.setColumnPinning(e=>n===`right`?{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:[...(e?.right??[]).filter(e=>!(r!=null&&r.includes(e))),...r]}:n===`left`?{left:[...(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),...r],right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))}:{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))})},e.getCanPin=()=>e.getLeafColumns().some(e=>(e.columnDef.enablePinning??!0)&&(t.options.enableColumnPinning??t.options.enablePinning??!0)),e.getIsPinned=()=>{let n=e.getLeafColumns().map(e=>e.id),{left:r,right:i}=t.getState().columnPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`left`:o?`right`:!1},e.getPinnedIndex=()=>{var n;let r=e.getIsPinned();return r?((n=t.getState().columnPinning)==null||(n=n[r])==null?void 0:n.indexOf(e.id))??-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=_H(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.column.id))},vH(t.options,`debugRows`,`getCenterVisibleCells`)),e.getLeftVisibleCells=_H(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`left`})),vH(t.options,`debugRows`,`getLeftVisibleCells`)),e.getRightVisibleCells=_H(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`right`})),vH(t.options,`debugRows`,`getRightVisibleCells`))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>e.setColumnPinning(t?WH():e.initialState?.columnPinning??WH()),e.getIsSomeColumnsPinned=t=>{let n=e.getState().columnPinning;return t?!!n[t]?.length:!!(n.left?.length||n.right?.length)},e.getLeftLeafColumns=_H(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),vH(e.options,`debugColumns`,`getLeftLeafColumns`)),e.getRightLeafColumns=_H(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),vH(e.options,`debugColumns`,`getRightLeafColumns`)),e.getCenterLeafColumns=_H(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.id))},vH(e.options,`debugColumns`,`getCenterLeafColumns`))}};function KH(e){return e||(typeof document<`u`?document:null)}var qH={size:150,minSize:20,maxSize:2**53-1},JH=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),YH={getDefaultColumnDef:()=>qH,getInitialState:e=>({columnSizing:{},columnSizingInfo:JH(),...e}),getDefaultOptions:e=>({columnResizeMode:`onEnd`,columnResizeDirection:`ltr`,onColumnSizingChange:pH(`columnSizing`,e),onColumnSizingInfoChange:pH(`columnSizingInfo`,e)}),createColumn:(e,t)=>{e.getSize=()=>{let n=t.getState().columnSizing[e.id];return Math.min(Math.max(e.columnDef.minSize??qH.minSize,n??e.columnDef.size??qH.size),e.columnDef.maxSize??qH.maxSize)},e.getStart=_H(e=>[e,eU(t,e),t.getState().columnSizing],(t,n)=>n.slice(0,e.getIndex(t)).reduce((e,t)=>e+t.getSize(),0),vH(t.options,`debugColumns`,`getStart`)),e.getAfter=_H(e=>[e,eU(t,e),t.getState().columnSizing],(t,n)=>n.slice(e.getIndex(t)+1).reduce((e,t)=>e+t.getSize(),0),vH(t.options,`debugColumns`,`getAfter`)),e.resetSize=()=>{t.setColumnSizing(t=>{let{[e.id]:n,...r}=t;return r})},e.getCanResize=()=>(e.columnDef.enableResizing??!0)&&(t.options.enableColumnResizing??!0),e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let t=0,n=e=>{e.subHeaders.length?e.subHeaders.forEach(n):t+=e.column.getSize()??0};return n(e),t},e.getStart=()=>{if(e.index>0){let t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=n=>{let r=t.getColumn(e.column.id),i=r?.getCanResize();return a=>{if(!r||!i||(a.persist==null||a.persist(),QH(a)&&a.touches&&a.touches.length>1))return;let o=e.getSize(),s=e?e.getLeafHeaders().map(e=>[e.column.id,e.column.getSize()]):[[r.id,r.getSize()]],c=QH(a)?Math.round(a.touches[0].clientX):a.clientX,l={},u=(e,n)=>{typeof n==`number`&&(t.setColumnSizingInfo(e=>{let r=t.options.columnResizeDirection===`rtl`?-1:1,i=(n-(e?.startOffset??0))*r,a=Math.max(i/(e?.startSize??0),-.999999);return e.columnSizingStart.forEach(e=>{let[t,n]=e;l[t]=Math.round(Math.max(n+n*a,0)*100)/100}),{...e,deltaOffset:i,deltaPercentage:a}}),(t.options.columnResizeMode===`onChange`||e===`end`)&&t.setColumnSizing(e=>({...e,...l})))},d=e=>u(`move`,e),f=e=>{u(`end`,e),t.setColumnSizingInfo(e=>({...e,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},p=KH(n),m={moveHandler:e=>d(e.clientX),upHandler:e=>{p?.removeEventListener(`mousemove`,m.moveHandler),p?.removeEventListener(`mouseup`,m.upHandler),f(e.clientX)}},h={moveHandler:e=>(e.cancelable&&(e.preventDefault(),e.stopPropagation()),d(e.touches[0].clientX),!1),upHandler:e=>{p?.removeEventListener(`touchmove`,h.moveHandler),p?.removeEventListener(`touchend`,h.upHandler),e.cancelable&&(e.preventDefault(),e.stopPropagation()),f(e.touches[0]?.clientX)}},g=ZH()?{passive:!1}:!1;QH(a)?(p?.addEventListener(`touchmove`,h.moveHandler,g),p?.addEventListener(`touchend`,h.upHandler,g)):(p?.addEventListener(`mousemove`,m.moveHandler,g),p?.addEventListener(`mouseup`,m.upHandler,g)),t.setColumnSizingInfo(e=>({...e,startOffset:c,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:s,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{e.setColumnSizing(t?{}:e.initialState.columnSizing??{})},e.resetHeaderSizeInfo=t=>{e.setColumnSizingInfo(t?JH():e.initialState.columnSizingInfo??JH())},e.getTotalSize=()=>e.getHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getLeftTotalSize=()=>e.getLeftHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getCenterTotalSize=()=>e.getCenterHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getRightTotalSize=()=>e.getRightHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0}},XH=null;function ZH(){if(typeof XH==`boolean`)return XH;let e=!1;try{let t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener(`test`,n,t),window.removeEventListener(`test`,n)}catch{e=!1}return XH=e,XH}function QH(e){return e.type===`touchstart`}var $H={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:pH(`columnVisibility`,e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(t=>({...t,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{let n=e.columns;return(n.length?n.some(e=>e.getIsVisible()):t.getState().columnVisibility?.[e.id])??!0},e.getCanHide=()=>(e.columnDef.enableHiding??!0)&&(t.options.enableHiding??!0),e.getToggleVisibilityHandler=()=>t=>{e.toggleVisibility==null||e.toggleVisibility(t.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=_H(()=>[e.getAllCells(),t.getState().columnVisibility],e=>e.filter(e=>e.column.getIsVisible()),vH(t.options,`debugRows`,`_getAllVisibleCells`)),e.getVisibleCells=_H(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(e,t,n)=>[...e,...t,...n],vH(t.options,`debugRows`,`getVisibleCells`))},createTable:e=>{let t=(t,n)=>_H(()=>[n(),n().filter(e=>e.getIsVisible()).map(e=>e.id).join(`_`)],e=>e.filter(e=>e.getIsVisible==null?void 0:e.getIsVisible()),vH(e.options,`debugColumns`,t));e.getVisibleFlatColumns=t(`getVisibleFlatColumns`,()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t(`getVisibleLeafColumns`,()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t(`getLeftVisibleLeafColumns`,()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t(`getRightVisibleLeafColumns`,()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t(`getCenterVisibleLeafColumns`,()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{e.setColumnVisibility(t?{}:e.initialState.columnVisibility??{})},e.toggleAllColumnsVisible=t=>{t??=!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((e,n)=>({...e,[n.id]:t||!(n.getCanHide!=null&&n.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(e=>!(e.getIsVisible!=null&&e.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(e=>e.getIsVisible==null?void 0:e.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{e.toggleAllColumnsVisible(t.target?.checked)}}};function eU(e,t){return t?t===`center`?e.getCenterVisibleLeafColumns():t===`left`?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}var tU={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,`__global__`),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,`__global__`),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,`__global__`),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},nU={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:pH(`globalFilter`,e),globalFilterFn:`auto`,getColumnCanGlobalFilter:t=>{var n;let r=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof r==`string`||typeof r==`number`}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>(e.columnDef.enableGlobalFilter??!0)&&(t.options.enableGlobalFilter??!0)&&(t.options.enableFilters??!0)&&((t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))??!0)&&!!e.accessorFn},createTable:e=>{e.getGlobalAutoFilterFn=()=>IH.includesString,e.getGlobalFilterFn=()=>{let{globalFilterFn:t}=e.options;return mH(t)?t:t===`auto`?e.getGlobalAutoFilterFn():e.options.filterFns?.[t]??IH[t]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},rU={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:pH(`expanded`,e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=t=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(t),e.toggleAllRowsExpanded=t=>{t??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=t=>{e.setExpanded(t?{}:e.initialState?.expanded??{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(e=>e.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>t=>{t.persist==null||t.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{let t=e.getState().expanded;return t===!0||Object.values(t).some(Boolean)},e.getIsAllRowsExpanded=()=>{let t=e.getState().expanded;return typeof t==`boolean`?t===!0:!(!Object.keys(t).length||e.getRowModel().flatRows.some(e=>!e.getIsExpanded()))},e.getExpandedDepth=()=>{let t=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(e=>{let n=e.split(`.`);t=Math.max(t,n.length)}),t},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{let i=r===!0?!0:!!(r!=null&&r[e.id]),a={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(e=>{a[e]=!0}):a=r,n??=!i,!i&&n)return{...a,[e.id]:!0};if(i&&!n){let{[e.id]:t,...n}=a;return n}return r})},e.getIsExpanded=()=>{let n=t.getState().expanded;return!!((t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))??(n===!0||n?.[e.id]))},e.getCanExpand=()=>{var n;return(t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))??((t.options.enableExpanding??!0)&&!!((n=e.subRows)!=null&&n.length))},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)r=t.getRow(r.parentId,!0),n=r.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{let t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},iU=0,aU=10,oU=()=>({pageIndex:iU,pageSize:aU}),sU={getInitialState:e=>({...e,pagination:{...oU(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:pH(`pagination`,e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=t=>e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(e=>fH(t,e)),e.resetPagination=t=>{e.setPagination(t?oU():e.initialState.pagination??oU())},e.setPageIndex=t=>{e.setPagination(n=>{let r=fH(t,n.pageIndex),i=e.options.pageCount===void 0||e.options.pageCount===-1?2**53-1:e.options.pageCount-1;return r=Math.max(0,Math.min(r,i)),{...n,pageIndex:r}})},e.resetPageIndex=t=>{var n;e.setPageIndex(t?iU:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageIndex)??iU)},e.resetPageSize=t=>{var n;e.setPageSize(t?aU:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageSize)??aU)},e.setPageSize=t=>{e.setPagination(e=>{let n=Math.max(1,fH(t,e.pageSize)),r=e.pageSize*e.pageIndex,i=Math.floor(r/n);return{...e,pageIndex:i,pageSize:n}})},e.setPageCount=t=>e.setPagination(n=>{let r=fH(t,e.options.pageCount??-1);return typeof r==`number`&&(r=Math.max(-1,r)),{...n,pageCount:r}}),e.getPageOptions=_H(()=>[e.getPageCount()],e=>{let t=[];return e&&e>0&&(t=[...Array(e)].fill(null).map((e,t)=>t)),t},vH(e.options,`debugTable`,`getPageOptions`)),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{let{pageIndex:t}=e.getState().pagination,n=e.getPageCount();return n===-1?!0:n===0?!1:t<n-1},e.previousPage=()=>e.setPageIndex(e=>e-1),e.nextPage=()=>e.setPageIndex(e=>e+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>e.options.pageCount??Math.ceil(e.getRowCount()/e.getState().pagination.pageSize),e.getRowCount=()=>e.options.rowCount??e.getPrePaginationRowModel().rows.length}},cU=()=>({top:[],bottom:[]}),lU={getInitialState:e=>({rowPinning:cU(),...e}),getDefaultOptions:e=>({onRowPinningChange:pH(`rowPinning`,e)}),createRow:(e,t)=>{e.pin=(n,r,i)=>{let a=r?e.getLeafRows().map(e=>{let{id:t}=e;return t}):[],o=i?e.getParentRows().map(e=>{let{id:t}=e;return t}):[],s=new Set([...o,e.id,...a]);t.setRowPinning(e=>n===`bottom`?{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:[...(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)]}:n===`top`?{top:[...(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)],bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))}:{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))})},e.getCanPin=()=>{let{enableRowPinning:n,enablePinning:r}=t.options;return typeof n==`function`?n(e):n??r??!0},e.getIsPinned=()=>{let n=[e.id],{top:r,bottom:i}=t.getState().rowPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`top`:o?`bottom`:!1},e.getPinnedIndex=()=>{let n=e.getIsPinned();return n?((n===`top`?t.getTopRows():t.getBottomRows())?.map(e=>{let{id:t}=e;return t}))?.indexOf(e.id)??-1:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>e.setRowPinning(t?cU():e.initialState?.rowPinning??cU()),e.getIsSomeRowsPinned=t=>{let n=e.getState().rowPinning;return t?!!n[t]?.length:!!(n.top?.length||n.bottom?.length)},e._getPinnedRows=(t,n,r)=>(e.options.keepPinnedRows??!0?(n??[]).map(t=>{let n=e.getRow(t,!0);return n.getIsAllParentsExpanded()?n:null}):(n??[]).map(e=>t.find(t=>t.id===e))).filter(Boolean).map(e=>({...e,position:r})),e.getTopRows=_H(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,`top`),vH(e.options,`debugRows`,`getTopRows`)),e.getBottomRows=_H(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,`bottom`),vH(e.options,`debugRows`,`getBottomRows`)),e.getCenterRows=_H(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(e,t,n)=>{let r=new Set([...t??[],...n??[]]);return e.filter(e=>!r.has(e.id))},vH(e.options,`debugRows`,`getCenterRows`))}},uU={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:pH(`rowSelection`,e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>e.setRowSelection(t?{}:e.initialState.rowSelection??{}),e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=t===void 0?!e.getIsAllRowsSelected():t;let r={...n},i=e.getPreGroupedRowModel().flatRows;return t?i.forEach(e=>{e.getCanSelect()&&(r[e.id]=!0)}):i.forEach(e=>{delete r[e.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{let r=t===void 0?!e.getIsAllPageRowsSelected():t,i={...n};return e.getRowModel().rows.forEach(t=>{dU(i,t.id,r,!0,e)}),i}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=_H(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?fU(e,n):{rows:[],flatRows:[],rowsById:{}},vH(e.options,`debugTable`,`getSelectedRowModel`)),e.getFilteredSelectedRowModel=_H(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?fU(e,n):{rows:[],flatRows:[],rowsById:{}},vH(e.options,`debugTable`,`getFilteredSelectedRowModel`)),e.getGroupedSelectedRowModel=_H(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?fU(e,n):{rows:[],flatRows:[],rowsById:{}},vH(e.options,`debugTable`,`getGroupedSelectedRowModel`)),e.getIsAllRowsSelected=()=>{let t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState(),r=!!(t.length&&Object.keys(n).length);return r&&t.some(e=>e.getCanSelect()&&!n[e.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows.filter(e=>e.getCanSelect()),{rowSelection:n}=e.getState(),r=!!t.length;return r&&t.some(e=>!n[e.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{let t=Object.keys(e.getState().rowSelection??{}).length;return t>0&&t<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(e=>e.getCanSelect()).some(e=>e.getIsSelected()||e.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{let i=e.getIsSelected();t.setRowSelection(a=>{if(n=n===void 0?!i:n,e.getCanSelect()&&i===n)return a;let o={...a};return dU(o,e.id,n,r?.selectChildren??!0,t),o})},e.getIsSelected=()=>{let{rowSelection:n}=t.getState();return pU(e,n)},e.getIsSomeSelected=()=>{let{rowSelection:n}=t.getState();return mU(e,n)===`some`},e.getIsAllSubRowsSelected=()=>{let{rowSelection:n}=t.getState();return mU(e,n)===`all`},e.getCanSelect=()=>typeof t.options.enableRowSelection==`function`?t.options.enableRowSelection(e):t.options.enableRowSelection??!0,e.getCanSelectSubRows=()=>typeof t.options.enableSubRowSelection==`function`?t.options.enableSubRowSelection(e):t.options.enableSubRowSelection??!0,e.getCanMultiSelect=()=>typeof t.options.enableMultiRowSelection==`function`?t.options.enableMultiRowSelection(e):t.options.enableMultiRowSelection??!0,e.getToggleSelectedHandler=()=>{let t=e.getCanSelect();return n=>{t&&e.toggleSelected(n.target?.checked)}}}},dU=(e,t,n,r,i)=>{var a;let o=i.getRow(t,!0);n?(o.getCanMultiSelect()||Object.keys(e).forEach(t=>delete e[t]),o.getCanSelect()&&(e[t]=!0)):delete e[t],r&&(a=o.subRows)!=null&&a.length&&o.getCanSelectSubRows()&&o.subRows.forEach(t=>dU(e,t.id,n,r,i))};function fU(e,t){let n=e.getState().rowSelection,r=[],i={},a=function(e,t){return e.map(e=>{var t;let o=pU(e,n);if(o&&(r.push(e),i[e.id]=e),(t=e.subRows)!=null&&t.length&&(e={...e,subRows:a(e.subRows)}),o)return e}).filter(Boolean)};return{rows:a(t.rows),flatRows:r,rowsById:i}}function pU(e,t){return t[e.id]??!1}function mU(e,t,n){var r;if(!((r=e.subRows)!=null&&r.length))return!1;let i=!0,a=!1;return e.subRows.forEach(e=>{if(!(a&&!i)&&(e.getCanSelect()&&(pU(e,t)?a=!0:i=!1),e.subRows&&e.subRows.length)){let n=mU(e,t);n===`all`?a=!0:(n===`some`&&(a=!0),i=!1)}}),i?`all`:a?`some`:!1}var hU=/([0-9]+)/gm,gU=(e,t,n)=>wU(CU(e.getValue(n)).toLowerCase(),CU(t.getValue(n)).toLowerCase()),_U=(e,t,n)=>wU(CU(e.getValue(n)),CU(t.getValue(n))),vU=(e,t,n)=>SU(CU(e.getValue(n)).toLowerCase(),CU(t.getValue(n)).toLowerCase()),yU=(e,t,n)=>SU(CU(e.getValue(n)),CU(t.getValue(n))),bU=(e,t,n)=>{let r=e.getValue(n),i=t.getValue(n);return r>i?1:r<i?-1:0},xU=(e,t,n)=>SU(e.getValue(n),t.getValue(n));function SU(e,t){return e===t?0:e>t?1:-1}function CU(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function wU(e,t){let n=e.split(hU).filter(Boolean),r=t.split(hU).filter(Boolean);for(;n.length&&r.length;){let e=n.shift(),t=r.shift(),i=parseInt(e,10),a=parseInt(t,10),o=[i,a].sort();if(isNaN(o[0])){if(e>t)return 1;if(t>e)return-1;continue}if(isNaN(o[1]))return isNaN(i)?-1:1;if(i>a)return 1;if(a>i)return-1}return n.length-r.length}var TU={alphanumeric:gU,alphanumericCaseSensitive:_U,text:vU,textCaseSensitive:yU,datetime:bU,basic:xU},EU=[CH,$H,UH,GH,EH,RH,tU,nU,{getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:`auto`,sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:pH(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{let n=t.getFilteredRowModel().flatRows.slice(10),r=!1;for(let t of n){let n=t?.getValue(e.id);if(Object.prototype.toString.call(n)===`[object Date]`)return TU.datetime;if(typeof n==`string`&&(r=!0,n.split(hU).length>1))return TU.alphanumeric}return r?TU.text:TU.basic},e.getAutoSortDir=()=>typeof t.getFilteredRowModel().flatRows[0]?.getValue(e.id)==`string`?`asc`:`desc`,e.getSortingFn=()=>{if(!e)throw Error();return mH(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn===`auto`?e.getAutoSortingFn():t.options.sortingFns?.[e.columnDef.sortingFn]??TU[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{let i=e.getNextSortingOrder(),a=n!=null;t.setSorting(o=>{let s=o?.find(t=>t.id===e.id),c=o?.findIndex(t=>t.id===e.id),l=[],u,d=a?n:i===`desc`;return u=o!=null&&o.length&&e.getCanMultiSort()&&r?s?`toggle`:`add`:o!=null&&o.length&&c!==o.length-1?`replace`:s?`toggle`:`replace`,u===`toggle`&&(a||i||(u=`remove`)),u===`add`?(l=[...o,{id:e.id,desc:d}],l.splice(0,l.length-(t.options.maxMultiSortColCount??2**53-1))):l=u===`toggle`?o.map(t=>t.id===e.id?{...t,desc:d}:t):u===`remove`?o.filter(t=>t.id!==e.id):[{id:e.id,desc:d}],l})},e.getFirstSortDir=()=>e.columnDef.sortDescFirst??t.options.sortDescFirst??e.getAutoSortDir()===`desc`?`desc`:`asc`,e.getNextSortingOrder=n=>{let r=e.getFirstSortDir(),i=e.getIsSorted();return i?i!==r&&(t.options.enableSortingRemoval??!0)&&(!n||(t.options.enableMultiRemove??!0))?!1:i===`desc`?`asc`:`desc`:r},e.getCanSort=()=>(e.columnDef.enableSorting??!0)&&(t.options.enableSorting??!0)&&!!e.accessorFn,e.getCanMultiSort=()=>e.columnDef.enableMultiSort??t.options.enableMultiSort??!!e.accessorFn,e.getIsSorted=()=>{let n=t.getState().sorting?.find(t=>t.id===e.id);return n?n.desc?`desc`:`asc`:!1},e.getSortIndex=()=>t.getState().sorting?.findIndex(t=>t.id===e.id)??-1,e.clearSorting=()=>{t.setSorting(t=>t!=null&&t.length?t.filter(t=>t.id!==e.id):[])},e.getToggleSortingHandler=()=>{let n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{e.setSorting(t?[]:e.initialState?.sorting??[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},VH,rU,sU,lU,uU,YH];function DU(e){let t=[...EU,...e._features??[]],n={_features:t},r=n._features.reduce((e,t)=>Object.assign(e,t.getDefaultOptions==null?void 0:t.getDefaultOptions(n)),{}),i=e=>n.options.mergeOptions?n.options.mergeOptions(r,e):{...r,...e},a={...e.initialState??{}};n._features.forEach(e=>{a=(e.getInitialState==null?void 0:e.getInitialState(a))??a});let o=[],s=!1,c={_features:t,options:{...r,...e},initialState:a,_queue:e=>{o.push(e),s||(s=!0,Promise.resolve().then(()=>{for(;o.length;)o.shift()();s=!1}).catch(e=>setTimeout(()=>{throw e})))},reset:()=>{n.setState(n.initialState)},setOptions:e=>{n.options=i(fH(e,n.options))},getState:()=>n.options.state,setState:e=>{n.options.onStateChange==null||n.options.onStateChange(e)},_getRowId:(e,t,r)=>(n.options.getRowId==null?void 0:n.options.getRowId(e,t,r))??`${r?[r.id,t].join(`.`):t}`,getCoreRowModel:()=>(n._getCoreRowModel||=n.options.getCoreRowModel(n),n._getCoreRowModel()),getRowModel:()=>n.getPaginationRowModel(),getRow:(e,t)=>{let r=(t?n.getPrePaginationRowModel():n.getRowModel()).rowsById[e];if(!r&&(r=n.getCoreRowModel().rowsById[e],!r))throw Error();return r},_getDefaultColumnDef:_H(()=>[n.options.defaultColumn],e=>(e??={},{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>{var t;return((t=e.renderValue())==null||t.toString==null?void 0:t.toString())??null},...n._features.reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef==null?void 0:t.getDefaultColumnDef()),{}),...e}),vH(e,`debugColumns`,`_getDefaultColumnDef`)),_getColumnDefs:()=>n.options.columns,getAllColumns:_H(()=>[n._getColumnDefs()],e=>{let t=function(e,r,i){return i===void 0&&(i=0),e.map(e=>{let a=bH(n,e,i,r),o=e;return a.columns=o.columns?t(o.columns,a,i+1):[],a})};return t(e)},vH(e,`debugColumns`,`getAllColumns`)),getAllFlatColumns:_H(()=>[n.getAllColumns()],e=>e.flatMap(e=>e.getFlatColumns()),vH(e,`debugColumns`,`getAllFlatColumns`)),_getAllFlatColumnsById:_H(()=>[n.getAllFlatColumns()],e=>e.reduce((e,t)=>(e[t.id]=t,e),{}),vH(e,`debugColumns`,`getAllFlatColumnsById`)),getAllLeafColumns:_H(()=>[n.getAllColumns(),n._getOrderColumnsFn()],(e,t)=>t(e.flatMap(e=>e.getLeafColumns())),vH(e,`debugColumns`,`getAllLeafColumns`)),getColumn:e=>n._getAllFlatColumnsById()[e]};Object.assign(n,c);for(let e=0;e<n._features.length;e++){let t=n._features[e];t==null||t.createTable==null||t.createTable(n)}return n}function OU(){return e=>_H(()=>[e.options.data],t=>{let n={rows:[],flatRows:[],rowsById:{}},r=function(t,i,a){i===void 0&&(i=0);let o=[];for(let c=0;c<t.length;c++){let l=TH(e,e._getRowId(t[c],c,a),t[c],c,i,void 0,a?.id);if(n.flatRows.push(l),n.rowsById[l.id]=l,o.push(l),e.options.getSubRows){var s;l.originalSubRows=e.options.getSubRows(t[c],c),(s=l.originalSubRows)!=null&&s.length&&(l.subRows=r(l.originalSubRows,i+1,l))}}return o};return n.rows=r(t),n},vH(e.options,`debugTable`,`getRowModel`,()=>e._autoResetPageIndex()))}function kU(){return e=>_H(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(t!=null&&t.length))return n;let r=e.getState().sorting,i=[],a=r.filter(t=>e.getColumn(t.id)?.getCanSort()),o={};a.forEach(t=>{let n=e.getColumn(t.id);n&&(o[t.id]={sortUndefined:n.columnDef.sortUndefined,invertSorting:n.columnDef.invertSorting,sortingFn:n.getSortingFn()})});let s=e=>{let t=e.map(e=>({...e}));return t.sort((e,t)=>{for(let n=0;n<a.length;n+=1){let r=a[n],i=o[r.id],s=i.sortUndefined,c=r?.desc??!1,l=0;if(s){let n=e.getValue(r.id),i=t.getValue(r.id),a=n===void 0,o=i===void 0;if(a||o){if(s===`first`)return a?-1:1;if(s===`last`)return a?1:-1;l=a&&o?0:a?s:-s}}if(l===0&&(l=i.sortingFn(e,t,r.id)),l!==0)return c&&(l*=-1),i.invertSorting&&(l*=-1),l}return e.index-t.index}),t.forEach(e=>{var t;i.push(e),(t=e.subRows)!=null&&t.length&&(e.subRows=s(e.subRows))}),t};return{rows:s(n.rows),flatRows:i,rowsById:n.rowsById}},vH(e.options,`debugTable`,`getSortedRowModel`,()=>e._autoResetPageIndex()))}function AU(e,t){return e?jU(e)?b.createElement(e,t):e:null}function jU(e){return MU(e)||typeof e==`function`||NU(e)}function MU(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function NU(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function PU(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=b.useState(()=>({current:DU(t)})),[r,i]=b.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{i(t),e.onStateChange==null||e.onStateChange(t)}})),n.current}var FU=_();function IU(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function LU(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function RU(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var zU=(e,t)=>Math.abs(e-t)<1.01,BU=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},VU,HU=()=>{if(VU!==void 0)return VU;if(typeof navigator>`u`)return VU=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return VU=!0;let e=navigator.maxTouchPoints;return VU=navigator.platform===`MacIntel`&&e!==void 0&&e>0},UU=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},WU=e=>e,GU=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},KU=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(UU(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(UU(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},qU={passive:!0},JU=typeof window>`u`?!0:`onscrollend`in window,YU=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&JU,o=0,s=a?null:BU(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,qU),a&&r.addEventListener(`scrollend`,u,qU),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},XU=(e,t)=>YU(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),ZU=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},QU=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},$U=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:WU,rangeExtractor:GU,onChange:()=>{},measureElement:ZU,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=e.start+t;n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=LU(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!HU()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,qU),e.addEventListener(`touchend`,n,qU),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(HU()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=LU(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=LU(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=IU(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=LU(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?tW({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=LU(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);if(o!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,s=a?this.getTotalSize():0,c=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(i)||this.scrollDirection!==`backward`):this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-s):c&&this.applyScrollAdjustment(o),this.notify(!1)}},this.getVirtualItems=LU(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return RU(t[eW(0,t.length-1,r?e=>n[e*2]:e=>RU(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(HU()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&zU(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},eW=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function tW({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=eW(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var nW=typeof document<`u`?b.useLayoutEffect:b.useEffect;function rW({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=b.useReducer(e=>e+1,0)[1],a=b.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}let r=!!e.options.horizontal,i=t.mode===`transform`,o=r?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let n of c){let a=n.start-s,c=e.elementsCache.get(n.key);c&&t.lastPositions.get(c)!==a&&(t.lastPositions.set(c,a),i?c.style.transform=r?`translate3d(${a}px, 0, 0)`:`translate3d(0, ${a}px, 0)`:c.style[o]=`${a}px`)}},s={...r,onChange:(t,n)=>{var s;let c=a.current,l=!0;if(c.enabled){o(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,FU.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=b.useState(()=>{let e=new $U(s);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return c.setOptions(s),nW(()=>c._didMount(),[]),nW(()=>c._willUpdate()),nW(()=>{o(c)}),c}function iW(e){return rW({observeElementRect:KU,observeElementOffset:XU,scrollToFn:QU,...e})}function aW(e){return Nz(e)}function oW(e){return e==null?`—`:`$`+e.toFixed(2)}function sW(e){if(!e||e<=0)return`—`;let t=Math.floor(e/60),n=Math.floor(t/60);return n>0?`${n}h ${t%60}m`:`${t}m`}function cW(e){return e?new Date(e*1e3).toLocaleString(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`—`}var lW=dH(),uW={review:`tag-review`,exploration:`tag-exploration`,planning:`tag-planning`,memory:`tag-memory`,generic:`tag-generic`};function dW({data:e}){let[t,n]=(0,b.useState)(``),[r,i]=(0,b.useState)([{id:`started_at`,desc:!0}]),a=(0,b.useRef)(null),o=(0,b.useMemo)(()=>{if(!e?.data)return[];let n=t.toLowerCase();return n?e.data.filter(e=>(e.repo_label||``).toLowerCase().includes(n)||(e.model_name||``).toLowerCase().includes(n)||(e.agent_role||``).toLowerCase().includes(n)||(e.agent_nickname||``).toLowerCase().includes(n)||(e.title||``).toLowerCase().includes(n)||(e.descendant_models||[]).some(e=>(e||``).toLowerCase().includes(n))||(e.descendant_families||[]).some(e=>(e||``).toLowerCase().includes(n))||(e.descendant_roles||[]).some(e=>(e||``).toLowerCase().includes(n))||(e.descendant_nicknames||[]).some(e=>(e||``).toLowerCase().includes(n))||(e.related_titles||[]).some(e=>(e||``).toLowerCase().includes(n))):e.data},[e,t]),s=(0,b.useMemo)(()=>[lW.accessor(`started_at`,{header:`Time`,cell:e=>cW(e.getValue()),size:130}),lW.accessor(`repo_label`,{header:`Repo`,cell:e=>e.getValue()||`—`,size:140}),lW.accessor(`model_name`,{header:`Model`,cell:e=>(0,z.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`,fontSize:`0.72rem`},children:e.getValue()||`?`}),size:130}),lW.accessor(`thread_count`,{header:`Threads`,cell:e=>{let t=e.getValue()||1,n=e.row.original;return t>1?`${t} (${n.subagent_count||0} sub)`:`1`},size:92}),lW.accessor(`agent_family`,{header:`Root`,cell:e=>(0,z.jsx)(`span`,{className:`tag ${uW[e.getValue()]||`tag-generic`}`,children:e.getValue()}),size:100}),lW.accessor(`agent_nickname`,{header:`Agent`,cell:e=>e.getValue()||`—`,size:85}),lW.accessor(`reasoning_effort`,{header:`Effort`,cell:e=>e.getValue()||`—`,size:70}),lW.accessor(`elapsed_seconds`,{header:`Duration`,cell:e=>sW(e.getValue()),size:85}),lW.accessor(`tokens_used`,{header:`Tokens`,cell:e=>(0,z.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`},children:aW(e.getValue())}),size:90}),lW.accessor(`cost`,{header:`Cost`,cell:e=>(0,z.jsx)(`span`,{style:{fontFamily:`var(--font-mono)`},children:e.getValue()==null?`—`:oW(e.getValue())}),size:80}),lW.accessor(`title`,{header:`Title`,cell:e=>(0,z.jsx)(`span`,{title:e.getValue(),style:{opacity:.6},children:(e.getValue()||``).slice(0,55)}),size:240})],[]),c=PU({data:o,columns:s,state:{sorting:r},onSortingChange:i,getCoreRowModel:OU(),getSortedRowModel:kU()}),l=c.getRowModel().rows,u=(0,b.useMemo)(()=>o.reduce((e,t)=>(e.sessions+=1,e.tokens+=t.tokens_used||0,e.cost+=t.cost||0,e.elapsed+=t.elapsed_seconds||0,e),{sessions:0,tokens:0,cost:0,elapsed:0}),[o]),d=iW({count:l.length,getScrollElement:()=>a.current,estimateSize:()=>36,overscan:10,getItemKey:e=>l[e]?.id??e}),f=d.getVirtualItems(),p=f.length>0?f[0].start:0,m=f.length>0?d.getTotalSize()-f[f.length-1].end:0;return(0,z.jsx)(`div`,{className:`animate-in`,children:(0,z.jsxs)(`div`,{className:`table-wrap`,children:[(0,z.jsx)(`div`,{className:`table-search`,children:(0,z.jsx)(`input`,{placeholder:`Search sessions...`,value:t,onChange:e=>n(e.target.value)})}),(0,z.jsxs)(`div`,{style:{fontSize:`0.7rem`,color:`var(--text-muted)`,padding:`0.4rem 1rem`,borderBottom:`1px solid var(--border)`},children:[o.length.toLocaleString(),` root sessions`,e&&!e.complete&&(0,z.jsx)(`span`,{className:`incomplete-badge`,style:{marginLeft:`0.5rem`},children:`partial`})]}),(0,z.jsxs)(`div`,{style:{fontSize:`0.7rem`,color:`var(--text-muted)`,padding:`0.45rem 1rem`,borderBottom:`1px solid var(--border)`,display:`flex`,gap:`1rem`,flexWrap:`wrap`},children:[(0,z.jsxs)(`span`,{children:[`Filtered sessions: `,(0,z.jsx)(`strong`,{style:{color:`var(--text-secondary)`},children:u.sessions.toLocaleString()})]}),(0,z.jsxs)(`span`,{children:[`Tokens: `,(0,z.jsx)(`strong`,{style:{color:`var(--text-secondary)`},children:aW(u.tokens)})]}),(0,z.jsxs)(`span`,{children:[`Cost: `,(0,z.jsx)(`strong`,{style:{color:`var(--text-secondary)`},children:oW(u.cost)})]}),(0,z.jsxs)(`span`,{children:[`Time: `,(0,z.jsx)(`strong`,{style:{color:`var(--text-secondary)`},children:sW(u.elapsed)})]})]}),(0,z.jsx)(`div`,{ref:a,style:{height:`600px`,overflow:`auto`},children:(0,z.jsxs)(`table`,{style:{tableLayout:`fixed`,width:`100%`},children:[(0,z.jsx)(`thead`,{style:{position:`sticky`,top:0,background:`var(--bg-card)`,zIndex:1},children:c.getHeaderGroups().map(e=>(0,z.jsx)(`tr`,{children:e.headers.map(e=>(0,z.jsxs)(`th`,{style:{width:e.getSize()},onClick:e.column.getToggleSortingHandler(),children:[AU(e.column.columnDef.header,e.getContext()),{asc:` ↑`,desc:` ↓`}[e.column.getIsSorted()]||``]},e.id))},e.id))}),(0,z.jsxs)(`tbody`,{children:[f.length===0&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:s.length,style:{textAlign:`center`,padding:`2rem`,color:`var(--text-muted)`},children:`No sessions`})}),p>0&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:s.length,style:{height:`${p}px`,padding:0,borderBottom:`none`}})}),f.map(e=>{let t=l[e.index];return(0,z.jsx)(`tr`,{style:{height:e.size},children:t.getVisibleCells().map(e=>(0,z.jsx)(`td`,{style:{width:e.column.getSize()},children:AU(e.column.columnDef.cell,e.getContext())},e.id))},t.id)}),m>0&&(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:s.length,style:{height:`${m}px`,padding:0,borderBottom:`none`}})})]})]})})]})})}function fW(){return{ingest_id:null,seq:0,overview:{total:{},d7:{},d30:{},cost_assumptions:null},repos:{total:[],d7:[],d30:[]},models:{total:[],d7:[],d30:[]},families:{total:[],d7:[],d30:[]},daily:{},heatmap:{}}}function pW(e,t,n){let r=n===`bootstrap`||n===`snapshot`||n===`complete`||!e||e.ingest_id!==t.ingest_id?fW():{...e};return r.ingest_id=t.ingest_id,r.seq=t.seq,t.data?.overview?r.overview={...r.overview,...t.data.overview,total:t.data.overview.total?{...r.overview.total,...t.data.overview.total}:r.overview.total,d7:t.data.overview.d7?{...r.overview.d7,...t.data.overview.d7}:r.overview.d7,d30:t.data.overview.d30?{...r.overview.d30,...t.data.overview.d30}:r.overview.d30}:e&&(r.overview=e.overview),r.repos=mW(e?.repos,t.data?.repos,r.repos),r.models=mW(e?.models,t.data?.models,r.models),r.families=mW(e?.families,t.data?.families,r.families),r.daily=t.data?.daily?{...e?.daily||{},...t.data.daily}:e?.daily||r.daily,r.heatmap=t.data?.heatmap?{...e?.heatmap||{},...t.data.heatmap}:e?.heatmap||r.heatmap,r}function mW(e,t,n){if(!t)return e||n;let r={total:e?e.total:n.total,d7:e?e.d7:n.d7,d30:e?e.d30:n.d30};for(let e of[`total`,`d7`,`d30`])t[e]&&(r[e]=t[e]);return r}function hW(e){return e?{overview:{data:e.overview,coverage:e.overview?.total?.coverage||{total:0,enriched:0,priced:0,time_valid:0}},repos:{data:e.repos},models:{data:e.models},families:{data:e.families},daily:{data:Object.entries(e.daily).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({date:e,...t}))},heatmap:{data:e.heatmap}}:null}function gW(e,{overviewIngestActive:t=!1,settledOverviewReady:n=!1,backendComplete:r=!1}={}){return e?n?!!(t&&!r):!0:!1}function _W(e){let t=e?.data;return Array.isArray(t)?t.length>0:!t||typeof t!=`object`?!1:[`total`,`d7`,`d30`].some(e=>Array.isArray(t[e])&&t[e].length>0)}function vW(e,t,n){return n?_W(e)?e:t||e:t}function yW(e,t,n=0){let r=fW();return r.ingest_id=t||null,r.seq=n,r.overview=e?.overview?.data||r.overview,r.repos=e?.repos?.data||r.repos,r.models=e?.models?.data||r.models,r.families=e?.families?.data||r.families,r.daily=Object.fromEntries((e?.daily?.data||[]).map(e=>[e.date,{...e}])),r.heatmap=e?.heatmap?.data||r.heatmap,r}function bW(e){let t=e.replay?.bootstrap?.payload||{},n=OW(t.progress||{percent:0,complete:!1}),r=pW(null,t,`bootstrap`),i=e.replay?.events||[],a=i.findIndex(jW),o=a>=0&&i[a].at_ms||0,s=kW(e,r,i),c=s[0]?.presentation||LW(),l=OW(a>=0&&i[a].payload?.progress||n),u=Math.max(e.startHoldDurationMs||0,0),d=Math.max(e.replayDurationMs||e.replay?.duration_ms||1,1),f=Math.max(e.tailDurationMs||0,0),p=Math.max(e.finalHoldDurationMs||0,0),m=Math.max(e.durationMs||u+d+f+p||1,1),h=Math.max(e.replay?.duration_ms||0,0),g=Math.min(Math.max(o,0),h),_=Math.max(1,h-g),v=RW(e.tailSourceFraction??.035),y=Math.max(1,Math.round(_*v)),b=Math.max(0,_-y),x=Math.max(g,h-y),S=e.replayEasing||`cubicInOut`,C=e.tailEasing||`cubicInOut`,w=AW(e)||s[s.length-1]?.presentation||c,T=IW(s,x),E=Math.min(3600,Math.max(1800,Math.round(d*.32))),D=Math.max(0+u,0+u+d-E),O=RW((D-(0+u))/Math.max(d,1)),k=Math.round(g+b*GW(S,O)),A=FW({keyframes:s,startSourceMs:k,endSourceMs:x,startPresentation:IW(s,k),endPresentation:T,durationMs:E,startSmoothing:.05,endSmoothing:.14}),j=PW({keyframes:s,tailSourceStartMs:x,sourceDurationMs:h,tailStartPresentation:T,finalPresentation:w,tailDurationMs:f});return{renderData:e,totalDurationMs:m,frontloadSettledDurationMs:0,startHoldDurationMs:u,replayDurationMs:d,tailDurationMs:f,finalHoldDurationMs:p,sourceDurationMs:h,sourceStartMs:g,effectiveSourceDurationMs:_,tailSourceDurationMs:y,tailSourceStartMs:x,mainReplaySourceDurationMs:b,replayStartMs:u,lateReplayStartMs:D,lateReplayDurationMs:E,lateReplaySourceStartMs:k,tailStartMs:u+d,finalHoldStartMs:u+d+f,currentSeekMs:0,started:!1,finished:!1,startWallClockMs:0,initialPresentation:c,presentation:c,keyframes:s,keyframeIndex:0,lateReplayFrames:A,tailStartPresentation:T,tailFrames:j,finalPresentation:w,progress:l||{...n,percent:0,complete:!1},bootstrapProgress:n,replayEasing:S,tailEasing:C,debugState:null,debugTrace:[]}}function xW(e){return{liveData:{ready:!0},presentation:e.presentation,rawPresentation:e.presentation,progress:e.progress,phase:e.debugState?.phase||`replay`,seekMs:e.currentSeekMs||0}}function SW(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||LW();else if(n<e.tailStartMs)if(n<e.lateReplayStartMs)i=CW(e,n),e.presentation=MW(e,i);else{let t=RW((n-e.lateReplayStartMs)/Math.max(e.lateReplayDurationMs,1));i=zW(e.lateReplaySourceStartMs,e.tailSourceStartMs,t),e.presentation=NW(e.lateReplayFrames,HW(t))}else n<e.finalHoldStartMs?(r=`tail`,a=RW((n-e.tailStartMs)/Math.max(e.tailDurationMs,1)),e.presentation=NW(e.tailFrames,GW(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:BW(e.presentation)};return e.debugState=o,e.debugTrace.push(o),xW(e)}function CW(e,t){if(t<=e.replayStartMs)return 0;let n=t-e.replayStartMs;if(n<=e.replayDurationMs){let t=RW(n/Math.max(e.replayDurationMs,1));return e.sourceStartMs+e.mainReplaySourceDurationMs*GW(e.replayEasing,t)}return e.sourceDurationMs}function wW(e,t,n,r){if(!e)return t;let i=Iz.videoExport||{};if(r<(i.displayTweenStartMs??200))return t;let a=(i.startHoldDurationMs??0)+(i.replayDurationMs??0)+(i.tailDurationMs??0)+(i.finalHoldDurationMs??0)||19e3,o=i.displayTweenLateWindowMs??2200,s=RW((r-(a-o))/Math.max(o,1)),c=Math.round(zW(i.displayTweenBaseMs??240,i.displayTweenLateMs??420,UW(s))),l=UW(1-Math.exp(-n/Math.max(c,1))),u=e.progress||{},d=t.progress||{};return{liveData:t.liveData,presentation:DB(e.presentation,t.presentation,l),rawPresentation:t.rawPresentation||t.presentation,progress:{...d,percent:zW(u.percent||0,d.percent||0,l),complete:d.complete},phase:t.phase,seekMs:t.seekMs||0}}function TW(e,t){let n=Iz.videoExport||{},r=Math.max(n.finalFlashDurationMs??280,0),i=Math.max(n.finalFlashDelayMs??0,0),a=Math.max(n.finalFlashMaxOpacity??.22,0);if(!r||!a||t==null)return{opacity:0,boxShadow:`none`};let o=e-t-i;if(o<0||o>r)return{opacity:0,boxShadow:`none`};let s=a*(1-UW(RW(o/r)));return{opacity:s,boxShadow:`0 0 120px 50px rgba(255, 255, 255, ${Math.min(1,s*.7)}) inset`}}function EW(e){let t=Iz.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 a=RW((e-r)/i);return n*(1-GW(t.introFadeEasing||`cubicOut`,a))}function DW(e){let t=Iz.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 a=RW((e-r)/i);return zW(n,1,GW(t.introFadeEasing||`cubicOut`,a))}function OW(e){return e?{...e}:null}function kW(e,t,n){let r=[],i=t;for(let e of n)jW(e)&&(i=pW(i,e.payload,e.event),r.push({at_ms:Math.max(0,e.at_ms||0),presentation:SB({overview:{data:i.overview},heatmap:{data:i.heatmap},daily:{data:Object.entries(i.daily).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({date:e,...t}))},families:{data:i.families},repos:{data:i.repos},models:{data:i.models},range:`total`})}));return r.length||r.push({at_ms:0,presentation:LW()}),r}function AW(e){let t=e.settledEnvelope;return t?.overview?.data?SB({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 jW(e){return e?.payload?.data&&(e.event===`patch`||e.event===`snapshot`||e.event===`complete`)}function MW(e,t){return IW(e.keyframes,t,e)}function NW(e,t){if(!e?.length)return LW();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=RW((t-r.u)/Math.max(i.u-r.u,1e-6));return DB(r.presentation,i.presentation,e)}}return e[e.length-1].presentation}function PW({keyframes:e,tailSourceStartMs:t,sourceDurationMs:n,tailStartPresentation:r,finalPresentation:i,tailDurationMs:a}){return FW({keyframes:e,startSourceMs:t,endSourceMs:n,startPresentation:r,endPresentation:i,durationMs:a,startSmoothing:.08,endSmoothing:.2,bidirectional:!0})}function FW({keyframes:e,startSourceMs:t,endSourceMs:n,startPresentation:r,endPresentation:i,durationMs:a,startSmoothing:o,endSmoothing:s,bidirectional:c=!1}){let l=Math.max(36,Math.min(96,Math.round(a/80))),u=[{u:0,presentation:r}];for(let r=1;r<l-1;r+=1){let i=r/(l-1),a=zW(t,n,i);u.push({u:i,presentation:IW(e,a)})}u.push({u:1,presentation:i});let d=[{u:0,presentation:r}],f=r;for(let e=1;e<u.length-1;e+=1){let t=u[e],n=zW(o,s,t.u);f=DB(f,t.presentation,n),d.push({u:t.u,presentation:f})}if(d.push({u:1,presentation:i}),!c)return d;let p=Array(u.length);p[u.length-1]={u:1,presentation:i};let m=i;for(let e=u.length-2;e>0;--e){let t=u[e],n=zW(s,o,1-t.u);m=DB(m,t.presentation,n),p[e]={u:t.u,presentation:m}}return p[0]={u:0,presentation:r},u.map((e,t)=>t===0?{u:0,presentation:r}:t===u.length-1?{u:1,presentation:i}:{u:e.u,presentation:DB(d[t].presentation,p[t].presentation,HW(e.u))})}function IW(e,t,n=null){if(!e.length)return LW();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 o=RW((t-i.at_ms)/Math.max(a.at_ms-i.at_ms,1));return DB(i.presentation,a.presentation,o)}function LW(){return SB({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 RW(e){return Math.min(Math.max(e||0,0),1)}function zW(e,t,n){return e+(t-e)*n}function BW(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 VW(e){let t=RW(e);return t*t*t}function HW(e){let t=RW(e);return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function UW(e){return 1-(1-RW(e))**3}function WW(e){let t=RW(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 zW(i,o,HW(RW((t-r)/Math.max(a-r,1e-6))))}return 1}function GW(e,t){switch(e){case`trainBrake`:return WW(t);case`cubicOut`:return UW(t);case`cubicInOut`:return HW(t);case`linear`:return RW(t);default:return VW(t)}}function KW({jobId:e}){let[t,n]=(0,b.useState)(null),[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)(!1),l=(0,b.useRef)(null),u=(0,b.useRef)(0),d=(0,b.useRef)(null),f=(0,b.useRef)(0),p=(0,b.useRef)(null);if((0,b.useEffect)(()=>{let t=!0;return(async()=>{try{let r=await fetch(E.url(`/api/export/${encodeURIComponent(e)}/render-data`));if(!r.ok)throw Error(`API error: ${r.status}`);let i=await r.json();if(!t)return;n(i),l.current=bW(i);let a=xW(l.current);d.current=a,f.current=0,o(a),c(!1),p.current=null}catch(e){if(!t)return;i(e.message||String(e))}})(),()=>{t=!1,u.current&&cancelAnimationFrame(u.current)}},[e]),(0,b.useEffect)(()=>{if(!a?.liveData||r)return;let e=!1,t=0,n=0,i=0,o=0,s=0,l=()=>{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`),a=n.length>=3&&i&&n.every(e=>{let t=e.getBoundingClientRect();return t.width>0&&t.height>0}),u=document.querySelectorAll(`.heatmap-cell`).length>=300;if(!(r&&a&&u)){o=requestAnimationFrame(l);return}s=window.setTimeout(()=>{e||c(!0)},180)};return t=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>{i=requestAnimationFrame(()=>{o=requestAnimationFrame(l)})})}),()=>{e=!0,t&&cancelAnimationFrame(t),n&&cancelAnimationFrame(n),i&&cancelAnimationFrame(i),o&&cancelAnimationFrame(o),s&&window.clearTimeout(s)}},[r,a]),(0,b.useEffect)(()=>{if(a){if(a.phase===`final_hold`){p.current??=a.seekMs||0;return}p.current=null}},[a?.phase,a?.seekMs]),(0,b.useEffect)(()=>{let n=()=>{let e=l.current;if(!e||e.started)return;e.started=!0,e.startWallClockMs=Date.now();let t=()=>{let e=l.current;if(!e)return;let n=Date.now(),r=Math.min(e.totalDurationMs,n-e.startWallClockMs),i=SW(e,r),a=f.current?Math.max(1,n-f.current):16;f.current=n;let s=wW(d.current,i,a,r);if(d.current=s,o(s),r>=e.totalDurationMs){e.finished=!0,u.current=0;return}u.current=requestAnimationFrame(t)};u.current=requestAnimationFrame(t)};return window.__CODEXMETER_EXPORT__={ready:!!(t&&!r&&s),jobId:e,start(){n()},get currentTimeMs(){return l.current?.currentSeekMs||0},get finished(){return!!l.current?.finished},getDebugState(){return l.current?.debugState||null},getDebugTrace(){return l.current?.debugTrace||[]}},()=>{delete window.__CODEXMETER_EXPORT__}},[s,r,e,t]),r)return(0,z.jsx)(`div`,{style:qW,children:(0,z.jsxs)(`div`,{style:YW,children:[`Export error: `,r]})});if(!a?.liveData)return(0,z.jsx)(`div`,{style:qW,children:(0,z.jsx)(`div`,{style:YW,children:`CodexMeter exporting…`})});let m=l.current,h=m?{startMs:m.startHoldDurationMs,endMs:m.finalHoldStartMs}:null;return(0,z.jsx)(`div`,{style:qW,children:(0,z.jsxs)(`div`,{style:JW,children:[(0,z.jsxs)(`div`,{style:{...eG,opacity:DW(a.seekMs)},children:[(0,z.jsx)(pV,{presentation:a.presentation,rawPresentation:a.rawPresentation,ingestProgress:Math.min(Math.max(a.progress?.percent||0,0),1),isIngestActive:!!(a.progress&&!a.progress.complete),exportMode:!1,exportPlayback:!0,exportPhase:a.phase,exportSeekMs:a.seekMs,exportDaily:m?.finalPresentation?.daily||null,exportDailyTiming:h}),(0,z.jsxs)(`div`,{style:XW,children:[`Made with `,(0,z.jsx)(`span`,{style:ZW,children:`♥`}),` by JJ`]})]}),(0,z.jsx)(`div`,{style:{...$W,opacity:EW(a.seekMs)}}),(0,z.jsx)(`div`,{style:{...QW,...TW(a.seekMs,p.current)}})]})})}var qW={width:`100vw`,minHeight:`100vh`,background:`#06080f`,display:`flex`,alignItems:`center`,justifyContent:`center`,overflow:`hidden`},JW={position:`relative`,width:1080,height:864,padding:`24px 28px 20px`,background:`#06080f`,overflow:`hidden`},YW={color:`#8b949e`,fontFamily:`'JetBrains Mono', 'Fira Code', monospace`,fontSize:18},XW={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`},ZW={color:`rgba(244, 63, 94, 0.52)`},QW={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},eG={position:`relative`,zIndex:1},tG=[`Overview`,`Repos`,`Models`,`Daily`,`Sessions`],nG=[{key:`d7`,label:`7d`},{key:`d30`,label:`30d`},{key:`total`,label:`All`}];function rG(e){return e?new Date(e*1e3).toLocaleDateString(`en-US`,{month:`short`,day:`2-digit`}):`—`}function iG(e){return!Number.isFinite(e)||e<=0?0:Math.floor(e/86400)*86400}function aG(e){let t=Date.parse(`${e}T12:00:00Z`);return Number.isFinite(t)?Math.floor(t/1e3):null}var oG={idle:`Starting...`,inventory:`Reading threads`,normalizing:`Normalizing`,enrichment:`Enriching rollouts`,aggregation:`Building aggregates`,finalizing:`Finalizing view`,complete:`Complete`,error:`Error`};function sG(e){return Object.values(e?.daily||{}).filter(e=>(e?.tokens||0)>0||(e?.sessions||0)>0).length>=7}function cG(){let e=typeof window<`u`?new URLSearchParams(window.location.search):null,t=e?.get(`export`),n=e?.get(`job`);if(t===`overview-video`&&n)return(0,z.jsx)(KW,{jobId:n});let[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(`Overview`),[s,c]=(0,b.useState)(`total`),[l,u]=(0,b.useState)({}),[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(!0),[h,g]=(0,b.useState)(!1),[_,v]=(0,b.useState)(!1),[y,x]=(0,b.useState)(!1),[S,C]=(0,b.useState)(!1),[w,T]=(0,b.useState)(!1),[D,O]=(0,b.useState)(!0),[k,A]=(0,b.useState)(!1),[j,ee]=(0,b.useState)(null),[M,N]=(0,b.useState)(!1),[P,F]=(0,b.useState)(!1),[I,te]=(0,b.useState)({available:!0,reason:null,portable_download:null}),[ne,re]=(0,b.useState)(null),[ie,ae]=(0,b.useState)(null),[oe,se]=(0,b.useState)(null),[ce,L]=(0,b.useState)(null),[le,ue]=(0,b.useState)(null),[de,fe]=(0,b.useState)(null),pe=(0,b.useRef)(!1),me=(0,b.useRef)(0),he=(0,b.useRef)(null),R=(0,b.useCallback)(async()=>{try{let[e,t,n,r,i,a,o]=await Promise.all([E.overview(),E.repos(),E.models(),E.daily(),E.sessions(),E.heatmap(),E.families()]),s={overview:e,repos:t,models:n,daily:r,sessions:i,heatmap:a,families:o};return u(s),s}catch(e){throw console.error(`Fetch error:`,e),e}},[]),ge=(0,b.useCallback)(async()=>{if(!w)try{T(!0),o(`Overview`),await E.rerun(),window.location.reload()}catch(e){console.error(`Rerun error:`,e),T(!1)}},[w]),_e=(0,b.useCallback)(async()=>{if(!(M||[`queued`,`running`].includes(j?.status)))try{N(!0);let e=!I?.available&&I?.portable_download?.available,t=!1;if(e){let e=I.portable_download.approx_size_mb?`about ${I.portable_download.approx_size_mb} MB`:`a fairly large download`;if(!window.confirm(`No supported browser was found for video export.\n\nCodexMeter can download a single-use portable Chromium bundle (${e}) for this export only, then delete it afterward.\n\nDo you want to continue?`))return;t=!0,F(!0)}ee(await E.startOverviewVideoExport(t?{install_portable_browser:!0}:{}))}catch(e){console.error(`Video export error:`,e)}finally{N(!1)}},[j?.status,I,M]);(0,b.useEffect)(()=>{P&&j&&j.phase!==`downloading_browser`&&(j.phase===`rendering`||j.phase===`encoding`||j.status===`complete`||j.status===`failed`)&&F(!1)},[j,P]);let ve=(0,b.useCallback)(()=>{!j?.id||j.status!==`complete`||(window.location.href=E.url(`/api/export/${encodeURIComponent(j.id)}/file`))},[j]);(0,b.useEffect)(()=>{!j?.id||j.status!==`complete`||he.current!==j.id&&(he.current=j.id,window.location.href=E.url(`/api/export/${encodeURIComponent(j.id)}/file`))},[j]),(0,b.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await E.exportSupport();e&&te(t)}catch(t){console.error(`Export support probe error:`,t),e&&te({available:!1,reason:`Video export availability could not be detected.`,portable_download:null})}})(),()=>{e=!1}},[]),(0,b.useEffect)(()=>{let e=!0,t=null,n=null,r=!1,a=!1,o=!1,s=!1,c=[],l=0,u=null,d=null,p=null,m=!1,h=()=>{p&&=(clearTimeout(p),null)},g=()=>{if(l=0,!e||c.length===0)return;let t=u,n=d;for(let e of c){let{payload:r,mode:i,progressOnly:a}=e;if(n=r.progress,!a){if(t&&r.ingest_id===t.ingest_id&&r.seq<=t.seq)continue;t=pW(t,r,i)}}HB(`apply`,{events:c.map(e=>({mode:e.mode,progressOnly:e.progressOnly,seq:e.payload?.seq})),progress:n,state:VB(t,n)}),c=[],n!==d&&(d=n,i(n)),t!==u&&(u=t,f(t),!m&&sG(t)&&(m=!0,v(!0),HB(`initial-live-ready`,VB(t,n))))},_=(e,t,n=!1)=>{HB(`receive`,{mode:t,progressOnly:n,payload:BB(e)}),c.push({payload:e,mode:t,progressOnly:n}),h(),l||=requestAnimationFrame(g)},y=(e,t=null,n=0)=>{let r=yW(e,t,Math.max((u?.seq||0)+1,n,1));u=r,f(r)},b=async(t,n=null,{hydrateLiveState:r=!1,seq:i=0}={})=>{if(!(!e||!t)){if(t.complete){if(o)return;o=!0;let t=await R();return e&&r&&y(t,n,i),t}if(t.partial_ready&&!s){s=!0;try{return await R()}catch(e){throw s=!1,e}}}},x=()=>{if(r||!e)return;r=!0;let n=async()=>{try{let n=await E.progress();if(!e)return;if(n.complete){await R(),i(n),clearInterval(t);return}i(n),n.percent>.08&&await R(),(n.error||n.phase===`error`)&&clearInterval(t)}catch(e){console.error(`Polling fallback error:`,e)}};n(),t=setInterval(n,1200)};return(()=>{if(typeof EventSource>`u`){x();return}n=E.live(),n.addEventListener(`bootstrap`,t=>{if(!e)return;let n=JSON.parse(t.data);_(n,`bootstrap`),b(n.progress,n.ingest_id).catch(e=>{console.error(`Settled fetch error:`,e),o=!1})}),n.addEventListener(`progress`,t=>{if(!e)return;let n=JSON.parse(t.data);_(n,`progress`,!0),b(n.progress,n.ingest_id).catch(e=>{console.error(`Settled fetch error:`,e),o=!1})}),n.addEventListener(`patch`,t=>{e&&_(JSON.parse(t.data),`patch`)}),n.addEventListener(`snapshot`,t=>{e&&_(JSON.parse(t.data),`snapshot`)}),n.addEventListener(`complete`,async t=>{if(!e)return;let r=JSON.parse(t.data);a=!0,await b(r.progress,r.ingest_id,{hydrateLiveState:!0,seq:(r.seq||0)+1}),e&&(_(r,r.data?`complete`:`progress`,!r.data),n?.close())}),n.addEventListener(`ingest-error`,t=>{if(!e)return;let r=JSON.parse(t.data);a=!0,_(r,`progress`,!0),n?.close()}),n.addEventListener(`error`,t=>{if(e&&!a){if(n?.readyState===EventSource.CLOSED){console.warn(`SSE stream closed, falling back to polling:`,t),x();return}n?.readyState===EventSource.CONNECTING&&!r&&!p&&(p=setTimeout(()=>{p=null,!(!e||a||r)&&n?.readyState!==EventSource.OPEN&&(console.warn(`SSE stream stalled during reconnect, falling back to polling:`,t),n?.close(),x())},4e3))}})})(),()=>{e=!1,clearInterval(t),h(),l&&cancelAnimationFrame(l),n?.close()}},[R]),(0,b.useEffect)(()=>{if(r){if((_||r.partial_ready||r.percent>.08)&&p&&!h){g(!0);let e=setTimeout(()=>m(!1),600);return()=>clearTimeout(e)}if(r.complete&&p&&!h){g(!0);let e=setTimeout(()=>m(!1),600);return()=>clearTimeout(e)}}},[r,_,p,h]);let ye=!!r?.complete,be=!!l.overview?.data,xe=ye||be,Se=Math.round((r?.percent||0)*100),Ce=Math.min(Math.max(r?.percent||0,0),1),we=!ye||k,Te=!!(r&&!ye&&we&&r.phase!==`error`);(0,b.useEffect)(()=>{r?.complete||O(!1)},[r?.complete]),(0,b.useEffect)(()=>{let e=ye&&!pe.current;if(pe.current=ye,!ye){A(!1);return}if(e&&!D){A(!0);return}k&&D&&A(!1)},[ye,D,k]),(0,b.useEffect)(()=>{let e=!0,t=null,n=async()=>{try{let r=!!j?.id,i=r?await E.exportStatus(j.id):await E.activeExport();if(!e)return;let a=r?i:i.job;if(!a){j?.id||ee(null);return}ee(a),[`complete`,`failed`].includes(a.status)||(t=setTimeout(n,900))}catch(t){if(!e)return;console.error(`Export status error:`,t)}};return ye&&n(),()=>{e=!1,t&&clearTimeout(t)}},[ye,j?.id]),(0,b.useEffect)(()=>{!we&&!y&&x(!0),we&&(x(!1),C(!1))},[we,y]),(0,b.useEffect)(()=>{if(!y)return;let e=setTimeout(()=>C(!0),350);return()=>clearTimeout(e)},[y]);let Ee=(0,b.useMemo)(()=>d?hW(d):null,[d]),De=gW(Ee,{overviewIngestActive:Te,settledOverviewReady:be&&(!ye||l.overview?.complete),backendComplete:ye}),Oe=De?Ee.overview:l.overview||Ee?.overview,ke=De?Ee.heatmap:l.heatmap||Ee?.heatmap,Ae=vW(Ee?.daily,l.daily||Ee?.daily,De),je=vW(Ee?.families,l.families||Ee?.families,De),Me=vW(Ee?.repos,l.repos||Ee?.repos,De),Ne=vW(Ee?.models,l.models||Ee?.models,De),Pe=vW(Ee?.repos,l.repos,De),Fe=vW(Ee?.models,l.models,De),Ie=vW(Ee?.daily,l.daily,De),Le=Oe?.data,Re=(Le?.[s]||Le?.total||{})?.date_range,ze=Te&&de?.from?aG(de.from):null,Be=Te&&de?.to?aG(de.to):null,Ve=Re&&Be?{...Re,from:ze||Re.from,to:Be}:Re;(0,b.useEffect)(()=>{if(me.current&&=(cancelAnimationFrame(me.current),0),!Ve?.from||!Ve?.to){re(null);return}let e={from:iG(Ve.from),to:iG(Ve.to)};return re(t=>{if(!t||ye||Te||t.from!==e.from||e.to<=t.to)return e;let n=t.to,r=e.to,i=Math.max(1,Math.round((r-n)/86400)),a=Math.min(1400,Math.max(320,i*110)),o=performance.now(),s=t=>{let i=Math.min(1,(t-o)/a),c=iG(n+(r-n)*i);re(t=>!t||t.from!==e.from||c<=t.to?t:{...t,to:c}),i<1?me.current=requestAnimationFrame(s):(me.current=0,re(e))};return me.current=requestAnimationFrame(s),t}),()=>{me.current&&=(cancelAnimationFrame(me.current),0)}},[ye,Ve?.from,Ve?.to,Te]);let He=M||[`queued`,`running`].includes(j?.status),Ue=!I?.available&&I?.portable_download?.available,We=P||Ue&&M||Ue&&j?.phase===`downloading_browser`?`Downloading single-use portable Chromium for this export.`:!I?.available&&!Ue?I.reason||`Video export requires Chrome, Chromium, or Edge.`:Ue?`No supported browser found. Click to download a single-use portable Chromium for this export.`:ye?He?`Video export is already running.`:`Render Overview ingest replay video`:`Finish ingest to render the replay video.`,Ge=(0,b.useCallback)(e=>{e&&(c(`d7`),o(`Daily`),ae({id:Date.now(),centerDate:e}))},[]),Ke=(0,b.useCallback)(e=>{e&&(o(`Repos`),se({id:Date.now(),repoLabel:String(e)}))},[]),qe=(0,b.useCallback)(e=>{e&&(o(`Models`),L({id:Date.now(),modelName:String(e)}))},[]),Je=j?.status===`complete`?`Download MP4`:P||He&&(M&&Ue||j?.phase===`downloading_browser`)?`Downloading ${Math.max(1,Math.round((j?.progress||.03)*100))}%`:He?`Rendering ${Math.max(1,Math.round((j?.progress||0)*100))}%`:`Render Video`;return(0,z.jsxs)(`div`,{className:`app`,children:[p&&(0,z.jsxs)(`div`,{className:`loading-overlay ${h?`fading`:``}`,children:[(0,z.jsx)(`div`,{className:`loading-logo`,children:`CodexMeter`}),(0,z.jsx)(`div`,{className:`loading-bar-wrap`,children:(0,z.jsx)(`div`,{className:`loading-bar`,style:{width:`${Se}%`}})}),(0,z.jsx)(`div`,{className:`loading-phase`,children:oG[r?.phase]||`Starting...`}),r?.phase===`enrichment`&&(0,z.jsxs)(`div`,{className:`loading-detail`,children:[r.enriched,`/`,r.needs_enrichment,` rollouts`,r.current_date_bucket&&` — ${r.current_date_bucket}`]}),r?.phase===`error`&&r?.error&&(0,z.jsx)(`div`,{className:`loading-detail`,children:r.error}),(0,z.jsxs)(`div`,{className:`loading-footer`,children:[`Made with `,(0,z.jsx)(`span`,{className:`loading-heart`,children:`♥`}),` by JJ`]})]}),(0,z.jsxs)(`div`,{className:`app-content ${h||!p?`app-content-revealed`:``}`,children:[(0,z.jsx)(`nav`,{className:`navbar`,children:(0,z.jsxs)(`div`,{className:`navbar-inner`,children:[(0,z.jsx)(`span`,{className:`navbar-brand`,children:`CodexMeter`}),(0,z.jsx)(`div`,{className:`navbar-tabs`,children:tG.map(e=>(0,z.jsx)(`button`,{className:`navbar-tab ${a===e?`active`:``} ${!xe&&e!==`Overview`?`navbar-tab-dimmed`:``}`,onClick:()=>o(e),disabled:!xe&&e!==`Overview`,children:e},e))}),(0,z.jsx)(`div`,{className:`navbar-meta`,children:Ve&&(0,z.jsxs)(`div`,{className:`navbar-date-wrap ${xe?``:`navbar-date-wrap-dimmed`}`,children:[(0,z.jsxs)(`span`,{className:`navbar-date`,style:{fontSize:`0.78rem`,color:`var(--text-muted)`,fontFamily:`var(--font-mono)`},children:[rG(ne?.from||Ve.from),` — `,rG(ne?.to||Ve.to)]}),(0,z.jsx)(`div`,{className:`range-toggle`,children:nG.map(e=>(0,z.jsx)(`button`,{className:`range-btn ${s===e.key?`active`:``}`,onClick:()=>c(e.key),disabled:!xe,children:e.label},e.key))}),(0,z.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":`Rerun ingest`,title:`Rerun ingest`,onClick:ge,disabled:w||!ye,children:`↻`}),(0,z.jsx)(`button`,{type:`button`,className:`navbar-tab active export-video-btn ${I?.available?``:`range-btn-unsupported`}`,onClick:j?.status===`complete`?ve:_e,disabled:!I?.available&&!Ue||!ye||He,style:{minWidth:110},title:j?.status===`complete`?`Download rendered Overview video`:We,children:Je})]})})]})}),(0,z.jsxs)(`div`,{className:`main-content`,children:[a===`Overview`&&(0,z.jsx)(_V,{data:Oe,heatmap:ke,daily:Ae,families:je,repos:Me,models:Ne,range:s,onPresentationSettledChange:O,ingestProgress:Ce,isIngestActive:Te,currentDateBucket:r?.current_date_bucket||null,onDailyDebugStatsChange:ue,onPresentationDateRangeChange:fe,onNavigateToDailyDay:Ge,onNavigateToRepo:Ke,onNavigateToModel:qe}),a===`Repos`&&(0,z.jsx)(NV,{data:Pe,range:s,focusRequest:oe,onFocusRequestConsumed:()=>se(null)}),a===`Models`&&(0,z.jsx)(VV,{data:Fe,range:s,focusRequest:ce,onFocusRequestConsumed:()=>L(null)}),a===`Daily`&&(0,z.jsx)(uH,{data:Ie,range:s,navigateToDayRequest:ie,onNavigateToDayConsumed:()=>ae(null)}),a===`Sessions`&&(0,z.jsx)(dW,{data:l.sessions})]}),Te&&le&&(0,z.jsxs)(`div`,{className:`app-footer-debug`,children:[`Daily Usage presentation: `,le.speedDaysPerSecond.toFixed(1),` days/s`,le.waitingForDailyData?` (waiting for daily data)`:``]}),(0,z.jsxs)(`div`,{className:`app-footer`,children:[`Made with `,(0,z.jsx)(`span`,{className:`loading-heart`,children:`♥`}),` by JJ`]})]})]})}x.createRoot(document.getElementById(`root`)).render((0,z.jsx)(cG,{}));
|