(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{1135:function(a,e,t){"use strict";t.r(e),t.d(e,"default",(function(){return v}));var s=t(0),n=t(1),i=t.n(n),l=t(8),o=t(4),c=t(861),r=t(7),d=t.n(r),p=t(1360);class v extends i.a.PureComponent{constructor(){super(...arguments),this.state={loading:!0,data:null}}componentDidMount(){const{measure:a,start_at:e,end_at:t,params:s}=this.props;Object(l.a)().post("/api/v1/admin/measures",{keys:[a],start_at:e,end_at:t,[a]:s}).then((a=>{this.setState({loading:!1,data:a.data})})).catch((a=>{console.error(a)}))}render(){const{label:a,href:e,target:t}=this.props,{loading:n,data:l}=this.state;let r;if(n)r=Object(s.a)(i.a.Fragment,{},void 0,Object(s.a)("span",{className:"sparkline__value__total"},void 0,Object(s.a)(p.a,{width:43})),Object(s.a)("span",{className:"sparkline__value__change"},void 0,Object(s.a)(p.a,{width:43})));else{const a=l[0],e=a.previous_total&&((a,e)=>{let t;return t=0!==e?0!==a?(e-a)/a:1:0===e&&0===a?0:-1,t})(1*a.previous_total,1*a.total);r=Object(s.a)(i.a.Fragment,{},void 0,Object(s.a)("span",{className:"sparkline__value__total"},void 0,a.human_value||Object(s.a)(o.c,{value:a.total})),a.previous_total&&Object(s.a)("span",{className:d()("sparkline__value__change",{positive:e>0,negative:e<0})},void 0,e>0&&"+",Object(s.a)(o.c,{value:e,style:"percent"})))}const v=Object(s.a)(i.a.Fragment,{},void 0,Object(s.a)("div",{className:"sparkline__value"},void 0,r),Object(s.a)("div",{className:"sparkline__label"},void 0,a),Object(s.a)("div",{className:"sparkline__graph"},void 0,!n&&Object(s.a)(c.Sparklines,{width:259,height:55,data:l[0].data.map((a=>1*a.value))},void 0,Object(s.a)(c.SparklinesCurve,{}))));return e?Object(s.a)("a",{href:e,className:"sparkline",target:t},void 0,v):Object(s.a)("div",{className:"sparkline"},void 0,v)}}}}]);
//# sourceMappingURL=2-817202fc886add7b93a2.chunk.js.map