import{a as e,d as t,i as n}from"./objectSpread2-DtFdQpqy.js";import{a as r,n as i}from"./preload-helper-EQ20WQt-.js";import{i as a}from"./prop-types-DdDwMzX7.js";import{t as o}from"./api-BtDY8vu4.js";import{t as s}from"./classnames-CFUb2mE1.js";import{t as c}from"./skeleton-BEM3iecx.js";import{t as l}from"./build-BRpvRm64.js";var u=t(r()),d=t(s()),f=l(),p=i();e();var m=(e,t)=>{let n;return n=t===0?t===0&&e===0?0:-1:e===0?1:(t-e)/e,n},h=class extends u.PureComponent{constructor(...e){super(...e),n(this,`state`,{loading:!0,data:null})}componentDidMount(){let{measure:e,start_at:t,end_at:n,params:r}=this.props;o(!1).post(`/api/v1/admin/measures`,{keys:[e],start_at:t,end_at:n,[e]:r}).then(e=>{this.setState({loading:!1,data:e.data})}).catch(e=>{console.error(e)})}render(){let{label:e,href:t,target:n}=this.props,{loading:r,data:i}=this.state,o;if(r)o=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{className:`sparkline__value__total`,children:(0,p.jsx)(c,{width:43})}),(0,p.jsx)(`span`,{className:`sparkline__value__change`,children:(0,p.jsx)(c,{width:43})})]});else{let e=i[0],t=e.previous_total&&m(e.previous_total*1,e.total*1);o=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`span`,{className:`sparkline__value__total`,children:e.human_value||(0,p.jsx)(a,{value:e.total})}),e.previous_total&&(0,p.jsxs)(`span`,{className:(0,d.default)(`sparkline__value__change`,{positive:t>0,negative:t<0}),children:[t>0&&`+`,(0,p.jsx)(a,{value:t,style:`percent`})]})]})}let s=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`sparkline__value`,children:o}),(0,p.jsx)(`div`,{className:`sparkline__label`,children:e}),(0,p.jsx)(`div`,{className:`sparkline__graph`,children:!r&&(0,p.jsx)(f.Sparklines,{width:259,height:55,data:i[0].data.map(e=>e.value*1),children:(0,p.jsx)(f.SparklinesCurve,{})})})]});return t?(0,p.jsx)(`a`,{href:t,className:`sparkline`,target:n,children:s}):(0,p.jsx)(`div`,{className:`sparkline`,children:s})}};export{h as default};
//# sourceMappingURL=Counter-EujzqLmu.js.map