import{r as g,d as p,b,j as c,y as D,G as I,z as N,p as O,c as S,l as m,D as u,n as f,C as w,e as h}from"./index-B-YXshIJ.js";import{S as P,b as j,i as A,d as $}from"./utils-D_uDWjrW.js";const E=(e,n)=>e>n?"up":e<n?"down":"same",B=(e,n,t)=>"\n  <strong>".concat(n,"</strong> ").concat(e," ").concat(e==="WIP"?"today":"in the last month").concat(t&&t.trendDirection!=="same"?"<br />This is a <strong>".concat(t==null?void 0:t.changePercentage.replace("-","")," ").concat(t.trendDirection==="up"?"increase":"decrease","</strong> from the previous month"):""),q=({data:e,toValue:n,colorBy:t,valueToLabel:a,renderer:o,combineValues:d,tooltipLabel:T})=>{const r=g.useMemo(()=>d(e.slice(-4)),[d,e]),x=g.useMemo(()=>e.map(n),[e,n]),s=g.useMemo(()=>{if(e.length<5)return null;const V=e.slice(-5).slice(0,4),l=d(V);return{value:l,color:t==null?void 0:t([l,r]),trendDirection:E(r,l),changePercentage:p(r-l,l).map(b).getOr("0%")}},[t,d,e,r]);return c.jsxs("span",{className:"grid","data-tooltip-id":"react-tooltip","data-tooltip-html":B(T,a(r),s),children:[c.jsxs("span",{className:"inline-flex items-end gap-x-0.5",children:[a(r),c.jsx(P,{data:x,lineColor:t==null?void 0:t(x),yAxisLabel:a,renderer:o})]}),s?c.jsxs("span",{className:"text-sm text-gray-600",style:{color:s.color},children:[s.trendDirection==="up"?"▲":s.trendDirection==="same"?" ":"▼"," ",r-s.value===0?"-":a(Math.abs(r-s.value))," ",Number.parseInt(s.changePercentage,10)===0?null:c.jsxs("span",{className:"text-xs",children:["(",Number.parseInt(s.changePercentage,10)>0?"+":null,s.changePercentage,")"]})]}):null]})},k={toValue:m,combineValues:w,valueToLabel:f},i=e=>A(e.filter(h)),v=D(N,I(0)),L=e=>$(e.filter(h).filter(v)),y=e=>p(w(e),e.length),U=e=>y(e.flat().filter(h).filter(v)).getOr(0),R={colorBy:i,tooltipLabel:"new work items",...k},z={colorBy:L,tooltipLabel:"new bugs",...k},G=R,W={colorBy:L,toValue:e=>y(e).getOr(void 0),combineValues:U,valueToLabel:e=>e===0?"-":O(e),renderer:j,tooltipLabel:"cycle time"},H={...W,tooltipLabel:"change lead time"},C=(e,n)=>t=>t.reduce((a,o)=>(a.numerator+=e(o),a.denominator+=n(o),a),{numerator:0,denominator:0}),F=(e,n)=>t=>{const{numerator:a,denominator:o}=C(e,n)(t);return p(a,o)},J={colorBy:i,toValue:e=>p(e.wcTime,e.total).getOr(0),combineValues:e=>F(S("wcTime"),S("total"))(e).getOr(0),valueToLabel:b,tooltipLabel:"flow efficiency"},K={colorBy:L,toValue:m,combineValues:e=>u(e)||0,valueToLabel:f,tooltipLabel:"WIP"},Q={colorBy:i,combineValues:e=>u(e)||0,toValue:m,valueToLabel:f,tooltipLabel:"automated tests"},X={colorBy:i,combineValues:e=>u(e)||0,toValue:m,valueToLabel:e=>"".concat(e,"%"),tooltipLabel:"branch coverage"},Y=e=>({colorBy:i,combineValues:n=>u(n)||0,toValue:m,valueToLabel:n=>p(n,e).map(b).getOr("-"),tooltipLabel:"repos with sonar"}),_={colorBy:i,...k,tooltipLabel:"builds"};export{q as E,H as a,z as b,W as c,X as d,Y as e,J as f,_ as g,R as n,Q as t,G as v,K as w};
