framework/extensions/statistics/js/dist/admin.js
flarum-bot 31ced98e0d Bundled output for commit 9964ddd731
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-11-06 18:26:49 +00:00

2 lines
98 KiB
JavaScript
Generated

(()=>{var t={126:(t,e,i)=>{t.exports=i(750)},757:function(t){t.exports=function(){"use strict";var t=6e4,e=36e5,i="millisecond",n="second",a="minute",r="hour",s="day",o="week",l="month",u="quarter",c="year",h="date",d="Invalid Date",f=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,p=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},m=function(t,e,i){var n=String(t);return!n||n.length>=e?t:""+Array(e+1-n.length).join(i)+t},g={s:m,z:function(t){var e=-t.utcOffset(),i=Math.abs(e),n=Math.floor(i/60),a=i%60;return(e<=0?"+":"-")+m(n,2,"0")+":"+m(a,2,"0")},m:function t(e,i){if(e.date()<i.date())return-t(i,e);var n=12*(i.year()-e.year())+(i.month()-e.month()),a=e.clone().add(n,l),r=i-a<0,s=e.clone().add(n+(r?-1:1),l);return+(-(n+(i-a)/(r?a-s:s-a))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:l,y:c,w:o,d:s,D:h,h:r,m:a,s:n,ms:i,Q:u}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},y="en",b={};b[y]=v;var x=function(t){return t instanceof M},w=function(t,e,i){var n;if(!t)return y;if("string"==typeof t)b[t]&&(n=t),e&&(b[t]=e,n=t);else{var a=t.name;b[a]=t,n=a}return!i&&n&&(y=n),n||!i&&y},k=function(t,e){if(x(t))return t.clone();var i="object"==typeof e?e:{};return i.date=t,i.args=arguments,new M(i)},D=g;D.l=w,D.i=x,D.w=function(t,e){return k(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var M=function(){function v(t){this.$L=w(t.locale,null,!0),this.parse(t)}var m=v.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,i=t.utc;if(null===e)return new Date(NaN);if(D.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var n=e.match(f);if(n){var a=n[2]-1||0,r=(n[7]||"0").substring(0,3);return i?new Date(Date.UTC(n[1],a,n[3]||1,n[4]||0,n[5]||0,n[6]||0,r)):new Date(n[1],a,n[3]||1,n[4]||0,n[5]||0,n[6]||0,r)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return D},m.isValid=function(){return!(this.$d.toString()===d)},m.isSame=function(t,e){var i=k(t);return this.startOf(e)<=i&&i<=this.endOf(e)},m.isAfter=function(t,e){return k(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<k(t)},m.$g=function(t,e,i){return D.u(t)?this[e]:this.set(i,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var i=this,u=!!D.u(e)||e,d=D.p(t),f=function(t,e){var n=D.w(i.$u?Date.UTC(i.$y,e,t):new Date(i.$y,e,t),i);return u?n:n.endOf(s)},p=function(t,e){return D.w(i.toDate()[t].apply(i.toDate("s"),(u?[0,0,0,0]:[23,59,59,999]).slice(e)),i)},v=this.$W,m=this.$M,g=this.$D,y="set"+(this.$u?"UTC":"");switch(d){case c:return u?f(1,0):f(31,11);case l:return u?f(1,m):f(0,m+1);case o:var b=this.$locale().weekStart||0,x=(v<b?v+7:v)-b;return f(u?g-x:g+(6-x),m);case s:case h:return p(y+"Hours",0);case r:return p(y+"Minutes",1);case a:return p(y+"Seconds",2);case n:return p(y+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var o,u=D.p(t),d="set"+(this.$u?"UTC":""),f=(o={},o[s]=d+"Date",o[h]=d+"Date",o[l]=d+"Month",o[c]=d+"FullYear",o[r]=d+"Hours",o[a]=d+"Minutes",o[n]=d+"Seconds",o[i]=d+"Milliseconds",o)[u],p=u===s?this.$D+(e-this.$W):e;if(u===l||u===c){var v=this.clone().set(h,1);v.$d[f](p),v.init(),this.$d=v.set(h,Math.min(this.$D,v.daysInMonth())).$d}else f&&this.$d[f](p);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[D.p(t)]()},m.add=function(i,u){var h,d=this;i=Number(i);var f=D.p(u),p=function(t){var e=k(d);return D.w(e.date(e.date()+Math.round(t*i)),d)};if(f===l)return this.set(l,this.$M+i);if(f===c)return this.set(c,this.$y+i);if(f===s)return p(1);if(f===o)return p(7);var v=(h={},h[a]=t,h[r]=e,h[n]=1e3,h)[f]||1,m=this.$d.getTime()+i*v;return D.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,i=this.$locale();if(!this.isValid())return i.invalidDate||d;var n=t||"YYYY-MM-DDTHH:mm:ssZ",a=D.z(this),r=this.$H,s=this.$m,o=this.$M,l=i.weekdays,u=i.months,c=function(t,i,a,r){return t&&(t[i]||t(e,n))||a[i].substr(0,r)},h=function(t){return D.s(r%12||12,t,"0")},f=i.meridiem||function(t,e,i){var n=t<12?"AM":"PM";return i?n.toLowerCase():n},v={YY:String(this.$y).slice(-2),YYYY:this.$y,M:o+1,MM:D.s(o+1,2,"0"),MMM:c(i.monthsShort,o,u,3),MMMM:c(u,o),D:this.$D,DD:D.s(this.$D,2,"0"),d:String(this.$W),dd:c(i.weekdaysMin,this.$W,l,2),ddd:c(i.weekdaysShort,this.$W,l,3),dddd:l[this.$W],H:String(r),HH:D.s(r,2,"0"),h:h(1),hh:h(2),a:f(r,s,!0),A:f(r,s,!1),m:String(s),mm:D.s(s,2,"0"),s:String(this.$s),ss:D.s(this.$s,2,"0"),SSS:D.s(this.$ms,3,"0"),Z:a};return n.replace(p,(function(t,e){return e||v[t]||a.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(i,h,d){var f,p=D.p(h),v=k(i),m=(v.utcOffset()-this.utcOffset())*t,g=this-v,y=D.m(this,v);return y=(f={},f[c]=y/12,f[l]=y,f[u]=y/3,f[o]=(g-m)/6048e5,f[s]=(g-m)/864e5,f[r]=g/e,f[a]=g/t,f[n]=g/1e3,f)[p]||g,d?y:D.a(y)},m.daysInMonth=function(){return this.endOf(l).$D},m.$locale=function(){return b[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var i=this.clone(),n=w(t,e,!0);return n&&(i.$L=n),i},m.clone=function(){return D.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},v}(),P=M.prototype;return k.prototype=P,[["$ms",i],["$s",n],["$m",a],["$H",r],["$W",s],["$M",l],["$y",c],["$D",h]].forEach((function(t){P[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),k.extend=function(t,e){return t.$i||(t(e,M,k),t.$i=!0),k},k.locale=w,k.isDayjs=x,k.unix=function(t){return k(1e3*t)},k.en=b[y],k.Ls=b,k.p={},k}()},982:function(t){t.exports=function(){"use strict";var t={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(e,i,n){var a=i.prototype,r=a.format;n.en.formats=t,a.format=function(e){void 0===e&&(e="YYYY-MM-DDTHH:mm:ssZ");var i=this.$locale().formats,n=function(e,i){return e.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(e,n,a){var r=a&&a.toUpperCase();return n||i[a]||t[a]||i[r].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(t,e,i){return e||i.slice(1)}))}))}(e,void 0===i?{}:i);return r.call(this,n)}}}()},221:function(t){t.exports=function(){"use strict";var t="minute",e=/[+-]\d\d(?::?\d\d)?/g,i=/([+-]|\d\d)/g;return function(n,a,r){var s=a.prototype;r.utc=function(t){return new a({date:t,utc:!0,args:arguments})},s.utc=function(e){var i=r(this.toDate(),{locale:this.$L,utc:!0});return e?i.add(this.utcOffset(),t):i},s.local=function(){return r(this.toDate(),{locale:this.$L,utc:!1})};var o=s.parse;s.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),o.call(this,t)};var l=s.init;s.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else l.call(this)};var u=s.utcOffset;s.utcOffset=function(n,a){var r=this.$utils().u;if(r(n))return this.$u?0:r(this.$offset)?u.call(this):this.$offset;if("string"==typeof n&&(n=function(t){void 0===t&&(t="");var n=t.match(e);if(!n)return null;var a=(""+n[0]).match(i)||["-",0,0],r=a[0],s=60*+a[1]+ +a[2];return 0===s?0:"+"===r?s:-s}(n),null===n))return this;var s=Math.abs(n)<=16?60*n:n,o=this;if(a)return o.$offset=s,o.$u=0===n,o;if(0!==n){var l=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(s+l,t)).$offset=s,o.$x.$localOffset=l}else o=this.utc();return o};var c=s.format;s.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,e)},s.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||(new Date).getTimezoneOffset());return this.$d.valueOf()-6e4*t},s.isUTC=function(){return!!this.$u},s.toISOString=function(){return this.toDate().toISOString()},s.toString=function(){return this.toDate().toUTCString()};var h=s.toDate;s.toDate=function(t){return"s"===t&&this.$offset?r(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():h.call(this)};var d=s.diff;s.diff=function(t,e,i){if(t&&this.$u===t.$u)return d.call(this,t,e,i);var n=this.local(),a=r(t).local();return d.call(n,a,e,i)}}}()},23:function(t){t.exports=function(){"use strict";function t(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function e(t){var e=t.getBoundingClientRect();return{top:e.top+(document.documentElement.scrollTop||document.body.scrollTop),left:e.left+(document.documentElement.scrollLeft||document.body.scrollLeft)}}function i(t){return null===t.offsetParent}function n(t){var e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function a(t){return t.titleHeight+t.margins.top+t.paddings.top}function r(t){return t.margins.left+t.paddings.left}function s(t){return t.margins.top+t.margins.bottom+t.paddings.top+t.paddings.bottom+t.titleHeight+t.legendHeight}function o(t){return t.margins.left+t.margins.right+t.paddings.left+t.paddings.right}function l(t){return parseFloat(t.toFixed(2))}function u(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i||(i=n?t[0]:t[t.length-1]);var a=new Array(Math.abs(e)).fill(i);return n?a.concat(t):t.concat(a)}function c(t,e){return(t+"").length*e}function h(t,e){return{x:Math.sin(t*kt)*e,y:Math.cos(t*kt)*e}}function d(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!(Number.isNaN(t)||void 0===t||!Number.isFinite(t)||e&&t<0)}function f(t){var e=void 0,i=void 0,n=void 0;if(t instanceof Date)return new Date(t.getTime());if("object"!==(void 0===t?"undefined":lt(t))||null===t)return t;for(n in e=Array.isArray(t)?[]:{},t)i=t[n],e[n]=f(i);return e}function p(t,e){var i=void 0,n=void 0;return t<=e?(i=e-t,n=t):(i=t-e,n=e),[i,n]}function v(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length-t.length;return i>0?t=u(t,i):e=u(e,i),[t,e]}function m(t,e){if(t)return t.length>e?t.slice(0,e-3)+"...":t}function g(t){var e=void 0;if("number"==typeof t)e=t;else if("string"==typeof t&&(e=Number(t),Number.isNaN(e)))return t;var i=Math.floor(Math.log10(Math.abs(e)));if(i<=2)return e;var n=Math.floor(i/3),a=Math.pow(10,i-3*n)*+(e/Math.pow(10,i)).toFixed(1);return Math.round(100*a)/100+" "+["","K","M","B","T"][n]}function y(t,e){for(var i=[],n=0;n<t.length;n++)i.push([t[n],e[n]]);var a=function(t,e,i,n){var a=function(t,e){var i=e[0]-t[0],n=e[1]-t[1];return{length:Math.sqrt(Math.pow(i,2)+Math.pow(n,2)),angle:Math.atan2(n,i)}}(e||t,i||t),r=a.angle+(n?Math.PI:0),s=.2*a.length;return[t[0]+Math.cos(r)*s,t[1]+Math.sin(r)*s]};return function(t,e){return t.reduce((function(t,e,i,n){return 0===i?e[0]+","+e[1]:t+" "+function(t,e,i){var n=a(i[e-1],i[e-2],t),r=a(t,i[e-1],i[e+1],!0);return"C "+n[0]+","+n[1]+" "+r[0]+","+r[1]+" "+t[0]+","+t[1]}(e,i,n)}),"")}(i)}function b(t){return t>255?255:t<0?0:t}function x(t,e){var i=Pt(t),n=!1;"#"==i[0]&&(i=i.slice(1),n=!0);var a=parseInt(i,16),r=b((a>>16)+e),s=b((a>>8&255)+e);return(n?"#":"")+(b((255&a)+e)|s<<8|r<<16).toString(16)}function w(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function k(t,e){var i=document.createElementNS("http://www.w3.org/2000/svg",t);for(var n in e){var a=e[n];if("inside"===n)w(a).appendChild(i);else if("around"===n){var r=w(a);r.parentNode.insertBefore(i,r),i.appendChild(r)}else"styles"===n?"object"===(void 0===a?"undefined":lt(a))&&Object.keys(a).map((function(t){i.style[t]=a[t]})):("className"===n&&(n="class"),"innerHTML"===n?i.textContent=a:i.setAttribute(n,a))}return i}function D(t,e){return k("linearGradient",{inside:t,id:e,x1:0,x2:0,y1:0,y2:1})}function M(t,e,i,n){return k("stop",{inside:t,style:"stop-color: "+i,offset:e,"stop-opacity":n})}function P(t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,i={className:t,transform:arguments.length>1&&void 0!==arguments[1]?arguments[1]:""};return e&&(i.inside=e),k("g",i)}function L(t){return k("path",{className:arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",d:t,styles:{stroke:arguments.length>2&&void 0!==arguments[2]?arguments[2]:"none",fill:arguments.length>3&&void 0!==arguments[3]?arguments[3]:"none","stroke-width":arguments.length>4&&void 0!==arguments[4]?arguments[4]:2}})}function S(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n="path-fill-gradient-"+e+"-"+(i?"lighter":"default"),a=D(t,n),r=[1,.6,.2];return i&&(r=[.4,.2,0]),M(a,"0%",e,r[0]),M(a,"50%",e,r[1]),M(a,"100%",e,r[2]),n}function O(t,e,i,n,a){var r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},s={className:t,x:e,y:i,width:n,height:n,rx:a,fill:arguments.length>5&&void 0!==arguments[5]?arguments[5]:"none"};return Object.keys(r).map((function(t){s[t]=r[t]})),k("rect",s)}function T(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},r=a.fontSize||Tt;return k("text",{className:t,x:e,y:i,dy:(void 0!==a.dy?a.dy:r/2)+"px","font-size":r+"px",fill:a.fill||Ct,"text-anchor":a.textAnchor||"start",innerHTML:n})}function A(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};a.stroke||(a.stroke=At);var r=k("line",{className:"line-vertical "+a.className,x1:0,x2:0,y1:i,y2:n,styles:{stroke:a.stroke}}),s=k("text",{x:0,y:i>n?i+St:i-St-Tt,dy:Tt+"px","font-size":Tt+"px","text-anchor":"middle",innerHTML:e+""}),o=k("g",{transform:"translate("+t+", 0)"});return o.appendChild(r),o.appendChild(s),o}function C(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};a.stroke||(a.stroke=At),a.lineType||(a.lineType=""),a.shortenNumbers&&(e=g(e));var r=k("line",{className:"line-horizontal "+a.className+("dashed"===a.lineType?"dashed":""),x1:i,x2:n,y1:0,y2:0,styles:{stroke:a.stroke}}),s=k("text",{x:i<n?i-St:i+St,y:0,dy:Tt/2-2+"px","font-size":Tt+"px","text-anchor":i<n?"end":"start",innerHTML:e+""}),o=k("g",{transform:"translate(0, "+t+")","stroke-opacity":1});return 0!==s&&"0"!==s||(o.style.stroke="rgba(27, 31, 35, 0.6)"),o.appendChild(r),o.appendChild(s),o}function N(t,e,i,n){var a="string"==typeof e?e:e.join(", ");return[t,{transform:i.join(", ")},n,jt,"translate",{transform:a}]}function _(t,e,i){return N(t,[0,i],[0,e],Yt)}function E(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=p(i,(arguments.length>5&&void 0!==arguments[5]?arguments[5]:{}).zeroLine),s=pt(r,2),o=s[0],l=s[1];return l-=a,"rect"!==t.nodeName?[[t.childNodes[0],{width:n,height:o},Et,jt],N(t,t.getAttribute("transform").split("(")[1].slice(0,-1),[e,l],Yt)]:[[t,{width:n,height:o,x:e,y:l},Et,jt]]}function $(t,e){return[t,{d:e},Et,jt]}function Y(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"linear",a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0,r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},s=t.cloneNode(!0),o=t.cloneNode(!0);for(var l in e){var u=void 0;u="transform"===l?document.createElementNS("http://www.w3.org/2000/svg","animateTransform"):document.createElementNS("http://www.w3.org/2000/svg","animate");var c=r[l]||t.getAttribute(l),h=e[l],d={attributeName:l,from:c,to:h,begin:"0s",dur:i/1e3+"s",values:c+";"+h,keySplines:zt[n],keyTimes:"0;1",calcMode:"spline",fill:"freeze"};for(var f in a&&(d.type=a),d)u.setAttribute(f,d[f]);s.appendChild(u),a?o.setAttribute(l,"translate("+h+")"):o.setAttribute(l,h)}return[s,o]}function W(t,e){t.style.transform=e,t.style.webkitTransform=e,t.style.msTransform=e,t.style.mozTransform=e,t.style.oTransform=e}function j(t,e){var i=[],n=[];e.map((function(t){var e,a,r=t[0],s=r.parentNode;t[0]=r;var o=Y.apply(void 0,vt(t)),l=pt(o,2);e=l[0],a=l[1],i.push(a),n.push([e,s]),s&&s.replaceChild(e,r)}));var a=t.cloneNode(!0);return n.map((function(t,n){t[1]&&(t[1].replaceChild(i[n],t[0]),e[n][0]=i[n])})),a}function z(t,e,i){if(0!==i.length){var n=j(e,i);e.parentNode==t&&(t.removeChild(e),t.appendChild(n)),setTimeout((function(){n.parentNode==t&&(t.removeChild(n),t.appendChild(e))}),Wt)}}function H(e){var i=e.cloneNode(!0);i.classList.add("chart-container"),i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");var n=t.create("style",{innerHTML:Ht});i.insertBefore(n,i.firstChild);var a=t.create("div");return a.appendChild(i),a.innerHTML}function F(t){var e=new Date(t);return e.setMinutes(e.getMinutes()-e.getTimezoneOffset()),e}function I(t){var e=t.getDate(),i=t.getMonth()+1;return[t.getFullYear(),(i>9?"":"0")+i,(e>9?"":"0")+e].join("-")}function R(t){return new Date(t.getTime())}function U(t,e){var i=q(t);return Math.ceil(function(t,e){var i=Vt*Ut;return(F(e)-F(t))/i}(i,e)/Rt)}function V(t,e){return t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}function B(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=Bt[t];return e?i.slice(0,3):i}function G(t,e){return new Date(e,t+1,0)}function q(t){var e=R(t),i=e.getDay();return 0!==i&&J(e,-1*i),e}function J(t,e){t.setDate(t.getDate()+e)}function X(t,e,i){var n=Object.keys(Jt).filter((function(e){return t.includes(e)})),a=Jt[n[0]];return Object.assign(a,{constants:e,getData:i}),new qt(a)}function Z(t){if(0===t)return[0,0];if(isNaN(t))return{mantissa:-6755399441055744,exponent:972};var e=t>0?1:-1;if(!isFinite(t))return{mantissa:4503599627370496*e,exponent:972};t=Math.abs(t);var i=Math.floor(Math.log10(t));return[e*(t/Math.pow(10,i)),i]}function K(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Math.ceil(t),n=Math.floor(e),a=i-n,r=a,s=1;a>5&&(a%2!=0&&(a=++i-n),r=a/2,s=2),a<=2&&(s=a/(r=4)),0===a&&(r=5,s=1);for(var o=[],l=0;l<=r;l++)o.push(n+s*l);return o}function Q(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Z(t),n=pt(i,2),a=n[0],r=n[1],s=e?e/Math.pow(10,r):0,o=K(a=a.toFixed(6),s);return o.map((function(t){return t*Math.pow(10,r)}))}function tt(t){function e(t,e){for(var i=Q(t),n=i[1]-i[0],a=0,r=1;a<e;r++)a+=n,i.unshift(-1*a);return i}var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Math.max.apply(Math,vt(t)),a=Math.min.apply(Math,vt(t)),r=[];if(n>=0&&a>=0)Z(n)[1],r=i?Q(n,a):Q(n);else if(n>0&&a<0){var s=Math.abs(a);n>=s?(Z(n)[1],r=e(n,s)):(Z(s)[1],r=e(s,n).reverse().map((function(t){return-1*t})))}else if(n<=0&&a<=0){var o=Math.abs(a),l=Math.abs(n);Z(o)[1],r=(r=i?Q(o,l):Q(o)).reverse().map((function(t){return-1*t}))}return r}function et(t){var e=it(t);return t.indexOf(0)>=0?t.indexOf(0):t[0]>0?-1*t[0]/e:-1*t[t.length-1]/e+(t.length-1)}function it(t){return t[1]-t[0]}function nt(t){return t[t.length-1]-t[0]}function at(t,e){return l(e.zeroLine-t*e.scaleMultiplier)}function rt(t,e){return e.filter((function(e){return e<t})).length}function st(t,e){t.labels=t.labels||[];var i=t.labels.length,n=t.datasets,a=new Array(i).fill(0);return n||(n=[{values:a}]),n.map((function(t){if(t.values){var n=t.values;n=(n=n.map((function(t){return isNaN(t)?0:t}))).length>i?n.slice(0,i):u(n,i-n.length,0),t.values=n}else t.values=a;t.chartType||(gt.includes(e),t.chartType=e)})),t.yRegions&&t.yRegions.map((function(t){if(t.end<t.start){var e=[t.end,t.start];t.start=e[0],t.end=e[1]}})),t}function ot(t){var e=t.labels.length,i=new Array(e).fill(0),n={labels:t.labels.slice(0,-1),datasets:t.datasets.map((function(t){return{name:"",values:i.slice(0,-1),chartType:t.chartType}}))};return t.yMarkers&&(n.yMarkers=[{value:0,label:""}]),t.yRegions&&(n.yRegions=[{start:0,end:0,label:""}]),n}!function(t,e){void 0===e&&(e={});var i=e.insertAt;if("undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===i&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=t:a.appendChild(document.createTextNode(t))}}('.chart-container{position:relative;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.chart-container .axis,.chart-container .chart-label{fill:#555b51}.chart-container .axis line,.chart-container .chart-label line{stroke:#dadada}.chart-container .dataset-units circle{stroke:#fff;stroke-width:2}.chart-container .dataset-units path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container .dataset-path{stroke-width:2px}.chart-container .path-group path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container line.dashed{stroke-dasharray:5,3}.chart-container .axis-line .specific-value{text-anchor:start}.chart-container .axis-line .y-line{text-anchor:end}.chart-container .axis-line .x-line{text-anchor:middle}.chart-container .legend-dataset-text{fill:#6c7680;font-weight:600}.graph-svg-tip{position:absolute;z-index:99999;padding:10px;font-size:12px;color:#959da5;text-align:center;background:rgba(0,0,0,.8);border-radius:3px}.graph-svg-tip ol,.graph-svg-tip ul{padding-left:0;display:-webkit-box;display:-ms-flexbox;display:flex}.graph-svg-tip ul.data-point-list li{min-width:90px;-webkit-box-flex:1;-ms-flex:1;flex:1;font-weight:600}.graph-svg-tip strong{color:#dfe2e5;font-weight:600}.graph-svg-tip .svg-pointer{position:absolute;height:5px;margin:0 0 0 -5px;content:" ";border:5px solid transparent;border-top-color:rgba(0,0,0,.8)}.graph-svg-tip.comparison{padding:0;text-align:left;pointer-events:none}.graph-svg-tip.comparison .title{display:block;padding:10px;margin:0;font-weight:600;line-height:1;pointer-events:none}.graph-svg-tip.comparison ul{margin:0;white-space:nowrap;list-style:none}.graph-svg-tip.comparison li{display:inline-block;padding:5px 10px}');var lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ut=(function(){function t(t){this.value=t}function e(e){function i(a,r){try{var s=e[a](r),o=s.value;o instanceof t?Promise.resolve(o.value).then((function(t){i("next",t)}),(function(t){i("throw",t)})):n(s.done?"return":"normal",s.value)}catch(t){n("throw",t)}}function n(t,e){switch(t){case"return":a.resolve({value:e,done:!0});break;case"throw":a.reject(e);break;default:a.resolve({value:e,done:!1})}(a=a.next)?i(a.key,a.arg):r=null}var a,r;this._invoke=function(t,e){return new Promise((function(n,s){var o={key:t,arg:e,resolve:n,reject:s,next:null};r?r=r.next=o:(a=r=o,i(t,e))}))},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),ct=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),ht=function t(e,i,n){null===e&&(e=Function.prototype);var a=Object.getOwnPropertyDescriptor(e,i);if(void 0===a){var r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in a)return a.value;var s=a.get;return void 0!==s?s.call(n):void 0},dt=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},ft=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},pt=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var i=[],n=!0,a=!1,r=void 0;try{for(var s,o=t[Symbol.iterator]();!(n=(s=o.next()).done)&&(i.push(s.value),!e||i.length!==e);n=!0);}catch(t){a=!0,r=t}finally{try{!n&&o.return&&o.return()}finally{if(a)throw r}}return i}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},vt=function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)};t.create=function(e,i){var n=document.createElement(e);for(var a in i){var r=i[a];if("inside"===a)t(r).appendChild(n);else if("around"===a){var s=t(r);s.parentNode.insertBefore(n,s),n.appendChild(s)}else"styles"===a?"object"===(void 0===r?"undefined":lt(r))&&Object.keys(r).map((function(t){n.style[t]=r[t]})):a in n?n[a]=r:n.setAttribute(a,r)}return n};var mt={margins:{top:10,bottom:10,left:20,right:20},paddings:{top:20,bottom:40,left:30,right:10},baseHeight:240,titleHeight:20,legendHeight:30,titleFontSize:12},gt=["line","bar"],yt=2,bt=7,xt=["light-blue","blue","violet","red","orange","yellow","green","light-green","purple","magenta","light-grey","dark-grey"],wt={bar:xt,line:xt,pie:xt,percentage:xt,heatmap:["#ebedf0","#c6e48b","#7bc96f","#239a3b","#196127"],donut:xt},kt=Math.PI/180,Dt=function(){function e(t){var i=t.parent,n=void 0===i?null:i,a=t.colors,r=void 0===a?[]:a;ut(this,e),this.parent=n,this.colors=r,this.titleName="",this.titleValue="",this.listValues=[],this.titleValueFirst=0,this.x=0,this.y=0,this.top=0,this.left=0,this.setup()}return ct(e,[{key:"setup",value:function(){this.makeTooltip()}},{key:"refresh",value:function(){this.fill(),this.calcPosition()}},{key:"makeTooltip",value:function(){var e=this;this.container=t.create("div",{inside:this.parent,className:"graph-svg-tip comparison",innerHTML:'<span class="title"></span>\n\t\t\t\t<ul class="data-point-list"></ul>\n\t\t\t\t<div class="svg-pointer"></div>'}),this.hideTip(),this.title=this.container.querySelector(".title"),this.dataPointList=this.container.querySelector(".data-point-list"),this.parent.addEventListener("mouseleave",(function(){e.hideTip()}))}},{key:"fill",value:function(){var e,i=this;this.index&&this.container.setAttribute("data-point-index",this.index),e=this.titleValueFirst?"<strong>"+this.titleValue+"</strong>"+this.titleName:this.titleName+"<strong>"+this.titleValue+"</strong>",this.title.innerHTML=e,this.dataPointList.innerHTML="",this.listValues.map((function(e,n){var a=i.colors[n]||"black",r=0===e.formatted||e.formatted?e.formatted:e.value,s=t.create("li",{styles:{"border-top":"3px solid "+a},innerHTML:'<strong style="display: block;">'+(0===r||r?r:"")+"</strong>\n\t\t\t\t\t"+(e.title?e.title:"")});i.dataPointList.appendChild(s)}))}},{key:"calcPosition",value:function(){var t=this.container.offsetWidth;this.top=this.y-this.container.offsetHeight-5,this.left=this.x-t/2;var e=this.parent.offsetWidth-t,i=this.container.querySelector(".svg-pointer");if(this.left<0)i.style.left="calc(50% - "+-1*this.left+"px)",this.left=0;else if(this.left>e){var n="calc(50% + "+(this.left-e)+"px)";i.style.left=n,this.left=e}else i.style.left="50%"}},{key:"setValues",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1;this.titleName=i.name,this.titleValue=i.value,this.listValues=n,this.x=t,this.y=e,this.titleValueFirst=i.valueFirst||0,this.index=a,this.refresh()}},{key:"hideTip",value:function(){this.container.style.top="0px",this.container.style.left="0px",this.container.style.opacity="0"}},{key:"showTip",value:function(){this.container.style.top=this.top+"px",this.container.style.left=this.left+"px",this.container.style.opacity="1"}}]),e}(),Mt={"light-blue":"#7cd6fd",blue:"#5e64ff",violet:"#743ee2",red:"#ff5858",orange:"#ffa00a",yellow:"#feef72",green:"#28a745","light-green":"#98d85b",purple:"#b554ff",magenta:"#ffa3ef",black:"#36114C",grey:"#bdd3e6","light-grey":"#f0f4f7","dark-grey":"#b8c2cc"},Pt=function(t){return/rgb[a]{0,1}\([\d, ]+\)/gim.test(t)?/\D+(\d*)\D+(\d*)\D+(\d*)/gim.exec(t).map((function(t,e){return 0!==e?Number(t).toString(16):"#"})).reduce((function(t,e){return""+t+e})):Mt[t]||t},Lt=6,St=4,Ot=15,Tt=10,At="#dadada",Ct="#555b51",Nt={bar:function(t){var e=void 0;"rect"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);var i=t.cloneNode();return i.style.fill="#000000",i.style.opacity="0.4",e&&i.setAttribute("transform",e),i},dot:function(t){var e=void 0;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);var i=t.cloneNode(),n=t.getAttribute("r"),a=t.getAttribute("fill");return i.setAttribute("r",parseInt(n)+4),i.setAttribute("fill",a),i.style.opacity="0.6",e&&i.setAttribute("transform",e),i},heat_square:function(t){var e=void 0;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);var i=t.cloneNode(),n=t.getAttribute("r"),a=t.getAttribute("fill");return i.setAttribute("r",parseInt(n)+4),i.setAttribute("fill",a),i.style.opacity="0.6",e&&i.setAttribute("transform",e),i}},_t={bar:function(t,e){var i=void 0;"rect"!==t.nodeName&&(i=t.getAttribute("transform"),t=t.childNodes[0]);var n=["x","y","width","height"];Object.values(t.attributes).filter((function(t){return n.includes(t.name)&&t.specified})).map((function(t){e.setAttribute(t.name,t.nodeValue)})),i&&e.setAttribute("transform",i)},dot:function(t,e){var i=void 0;"circle"!==t.nodeName&&(i=t.getAttribute("transform"),t=t.childNodes[0]);var n=["cx","cy"];Object.values(t.attributes).filter((function(t){return n.includes(t.name)&&t.specified})).map((function(t){e.setAttribute(t.name,t.nodeValue)})),i&&e.setAttribute("transform",i)},heat_square:function(t,e){var i=void 0;"circle"!==t.nodeName&&(i=t.getAttribute("transform"),t=t.childNodes[0]);var n=["cx","cy"];Object.values(t.attributes).filter((function(t){return n.includes(t.name)&&t.specified})).map((function(t){e.setAttribute(t.name,t.nodeValue)})),i&&e.setAttribute("transform",i)}},Et=350,$t=350,Yt=Et,Wt=250,jt="easein",zt={ease:"0.25 0.1 0.25 1",linear:"0 0 1 1",easein:"0.1 0.8 0.2 1",easeout:"0 0 0.58 1",easeinout:"0.42 0 0.58 1"},Ht=".chart-container{position:relative;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Roboto','Oxygen','Ubuntu','Cantarell','Fira Sans','Droid Sans','Helvetica Neue',sans-serif}.chart-container .axis,.chart-container .chart-label{fill:#555b51}.chart-container .axis line,.chart-container .chart-label line{stroke:#dadada}.chart-container .dataset-units circle{stroke:#fff;stroke-width:2}.chart-container .dataset-units path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container .dataset-path{stroke-width:2px}.chart-container .path-group path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container line.dashed{stroke-dasharray:5,3}.chart-container .axis-line .specific-value{text-anchor:start}.chart-container .axis-line .y-line{text-anchor:end}.chart-container .axis-line .x-line{text-anchor:middle}.chart-container .legend-dataset-text{fill:#6c7680;font-weight:600}.graph-svg-tip{position:absolute;z-index:99999;padding:10px;font-size:12px;color:#959da5;text-align:center;background:rgba(0,0,0,.8);border-radius:3px}.graph-svg-tip ul{padding-left:0;display:flex}.graph-svg-tip ol{padding-left:0;display:flex}.graph-svg-tip ul.data-point-list li{min-width:90px;flex:1;font-weight:600}.graph-svg-tip strong{color:#dfe2e5;font-weight:600}.graph-svg-tip .svg-pointer{position:absolute;height:5px;margin:0 0 0 -5px;content:' ';border:5px solid transparent;border-top-color:rgba(0,0,0,.8)}.graph-svg-tip.comparison{padding:0;text-align:left;pointer-events:none}.graph-svg-tip.comparison .title{display:block;padding:10px;margin:0;font-weight:600;line-height:1;pointer-events:none}.graph-svg-tip.comparison ul{margin:0;white-space:nowrap;list-style:none}.graph-svg-tip.comparison li{display:inline-block;padding:5px 10px}",Ft=function(){function e(t,i){if(ut(this,e),i=f(i),this.parent="string"==typeof t?document.querySelector(t):t,!(this.parent instanceof HTMLElement))throw new Error("No `parent` element to render on was provided.");this.rawChartArgs=i,this.title=i.title||"",this.type=i.type||"",this.realData=this.prepareData(i.data),this.data=this.prepareFirstData(this.realData),this.colors=this.validateColors(i.colors,this.type),this.config={showTooltip:1,showLegend:1,isNavigable:i.isNavigable||0,animate:void 0!==i.animate?i.animate:1,truncateLegends:i.truncateLegends||1},this.measures=JSON.parse(JSON.stringify(mt));var n=this.measures;this.setMeasures(i),this.title.length||(n.titleHeight=0),this.config.showLegend||(n.legendHeight=0),this.argHeight=i.height||n.baseHeight,this.state={},this.options={},this.initTimeout=700,this.config.isNavigable&&(this.overlays=[]),this.configure(i)}return ct(e,[{key:"prepareData",value:function(t){return t}},{key:"prepareFirstData",value:function(t){return t}},{key:"validateColors",value:function(t,e){var i=[];return(t=(t||[]).concat(wt[e])).forEach((function(t){var e=Pt(t);!function(t){return/(^\s*)(#)((?:[A-Fa-f0-9]{3}){1,2})$/i.test(t)||/(^\s*)(rgb|hsl)(a?)[(]\s*([\d.]+\s*%?)\s*,\s*([\d.]+\s*%?)\s*,\s*([\d.]+\s*%?)\s*(?:,\s*([\d.]+)\s*)?[)]$/i.test(t)}(e)?console.warn('"'+t+'" is not a valid color.'):i.push(e)})),i}},{key:"setMeasures",value:function(){}},{key:"configure",value:function(){var t=this,e=this.argHeight;this.baseHeight=e,this.height=e-s(this.measures),this.boundDrawFn=function(){return t.draw(!0)},ResizeObserver&&(this.resizeObserver=new ResizeObserver(this.boundDrawFn),this.resizeObserver.observe(this.parent)),window.addEventListener("resize",this.boundDrawFn),window.addEventListener("orientationchange",this.boundDrawFn)}},{key:"destroy",value:function(){this.resizeObserver&&this.resizeObserver.disconnect(),window.removeEventListener("resize",this.boundDrawFn),window.removeEventListener("orientationchange",this.boundDrawFn)}},{key:"setup",value:function(){this.makeContainer(),this.updateWidth(),this.makeTooltip(),this.draw(!1,!0)}},{key:"makeContainer",value:function(){this.parent.innerHTML="";var e={inside:this.parent,className:"chart-container"};this.independentWidth&&(e.styles={width:this.independentWidth+"px"}),this.container=t.create("div",e)}},{key:"makeTooltip",value:function(){this.tip=new Dt({parent:this.container,colors:this.colors}),this.bindTooltip()}},{key:"bindTooltip",value:function(){}},{key:"draw",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e&&i(this.parent)||(this.updateWidth(),this.calc(e),this.makeChartArea(),this.setupComponents(),this.components.forEach((function(e){return e.setup(t.drawArea)})),this.render(this.components,!1),n&&(this.data=this.realData,setTimeout((function(){t.update(t.data)}),this.initTimeout)),this.renderLegend(),this.setupNavigation(n))}},{key:"calc",value:function(){}},{key:"updateWidth",value:function(){this.baseWidth=function(t){var e=window.getComputedStyle(t),i=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight);return t.clientWidth-i}(this.parent),this.width=this.baseWidth-o(this.measures)}},{key:"makeChartArea",value:function(){this.svg&&this.container.removeChild(this.svg);var t=this.measures;this.svg=function(t,e,i,n){return k("svg",{className:e,inside:t,width:i,height:n})}(this.container,"frappe-chart chart",this.baseWidth,this.baseHeight),this.svgDefs=function(t){return k("defs",{inside:t})}(this.svg),this.title.length&&(this.titleEL=T("title",t.margins.left,t.margins.top,this.title,{fontSize:t.titleFontSize,fill:"#666666",dy:t.titleFontSize}));var e=a(t);this.drawArea=P(this.type+"-chart chart-draw-area","translate("+r(t)+", "+e+")"),this.config.showLegend&&(e+=this.height+t.paddings.bottom,this.legendArea=P("chart-legend","translate("+r(t)+", "+e+")")),this.title.length&&this.svg.appendChild(this.titleEL),this.svg.appendChild(this.drawArea),this.config.showLegend&&this.svg.appendChild(this.legendArea),this.updateTipOffset(r(t),a(t))}},{key:"updateTipOffset",value:function(t,e){this.tip.offset={x:t,y:e}}},{key:"setupComponents",value:function(){this.components=new Map}},{key:"update",value:function(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.calc(),this.render(this.components,this.config.animate),this.renderLegend()}},{key:"render",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.components,i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.config.isNavigable&&this.overlays.map((function(t){return t.parentNode.removeChild(t)}));var n=[];e.forEach((function(t){n=n.concat(t.update(i))})),n.length>0?(z(this.container,this.svg,n),setTimeout((function(){e.forEach((function(t){return t.make()})),t.updateNav()}),400)):(e.forEach((function(t){return t.make()})),this.updateNav())}},{key:"updateNav",value:function(){this.config.isNavigable&&(this.makeOverlay(),this.bindUnits())}},{key:"renderLegend",value:function(){}},{key:"setupNavigation",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.config.isNavigable&&e&&(this.bindOverlay(),this.keyActions={13:this.onEnterKey.bind(this),37:this.onLeftArrow.bind(this),38:this.onUpArrow.bind(this),39:this.onRightArrow.bind(this),40:this.onDownArrow.bind(this)},document.addEventListener("keydown",(function(e){n(t.container)&&(e=e||window.event,t.keyActions[e.keyCode]&&t.keyActions[e.keyCode]())})))}},{key:"makeOverlay",value:function(){}},{key:"updateOverlay",value:function(){}},{key:"bindOverlay",value:function(){}},{key:"bindUnits",value:function(){}},{key:"onLeftArrow",value:function(){}},{key:"onRightArrow",value:function(){}},{key:"onUpArrow",value:function(){}},{key:"onDownArrow",value:function(){}},{key:"onEnterKey",value:function(){}},{key:"addDataPoint",value:function(){}},{key:"removeDataPoint",value:function(){}},{key:"getDataPoint",value:function(){}},{key:"setCurrentDataPoint",value:function(){}},{key:"updateDataset",value:function(){}},{key:"export",value:function(){var t=H(this.svg);!function(t,e){var i=document.createElement("a");i.style="display: none";var n=new Blob(e,{type:"image/svg+xml; charset=utf-8"}),a=window.URL.createObjectURL(n);i.href=a,i.download=t,document.body.appendChild(i),i.click(),setTimeout((function(){document.body.removeChild(i),window.URL.revokeObjectURL(a)}),300)}(this.title||"Chart",[t])}}]),e}(),It=function(t){function e(t,i){return ut(this,e),ft(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,i))}return dt(e,t),ct(e,[{key:"configure",value:function(t){ht(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"configure",this).call(this,t),this.config.formatTooltipY=(t.tooltipOptions||{}).formatTooltipY,this.config.maxSlices=t.maxSlices||20,this.config.maxLegendPoints=t.maxLegendPoints||20}},{key:"calc",value:function(){var t=this,e=this.state,i=this.config.maxSlices;e.sliceTotals=[];var n=this.data.labels.map((function(e,i){var n=0;return t.data.datasets.map((function(t){n+=t.values[i]})),[n,e]})).filter((function(t){return t[0]>=0})),a=n;if(n.length>i){n.sort((function(t,e){return e[0]-t[0]})),a=n.slice(0,i-1);var r=0;n.slice(i-1).map((function(t){r+=t[0]})),a.push([r,"Rest"]),this.colors[i-1]="grey"}e.labels=[],a.map((function(t){e.sliceTotals.push(function(t){return Number(Math.round(t+"e4")+"e-4")}(t[0])),e.labels.push(t[1])})),e.grandTotal=e.sliceTotals.reduce((function(t,e){return t+e}),0),this.center={x:this.width/2,y:this.height/2}}},{key:"renderLegend",value:function(){var t=this,e=this.state;this.legendArea.textContent="",this.legendTotals=e.sliceTotals.slice(0,this.config.maxLegendPoints);var i=0,n=0;this.legendTotals.map((function(a,r){var s=150,l=Math.floor((t.width-o(t.measures))/s);t.legendTotals.length<l&&(s=t.width/t.legendTotals.length),i>l&&(i=0,n+=20);var u=s*i+5,c=t.config.truncateLegends?m(e.labels[r],s/10):e.labels[r],h=t.config.formatTooltipY?t.config.formatTooltipY(a):a,d=function(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"none",a=arguments[4];a=arguments.length>5&&void 0!==arguments[5]&&arguments[5]?m(a,Ot):a;var r={className:"legend-dot",cx:0,cy:0,r:i,fill:n},s=k("text",{className:"legend-dataset-text",x:0,y:0,dx:Tt+"px",dy:Tt/3+"px","font-size":1.2*Tt+"px","text-anchor":"start",fill:Ct,innerHTML:a}),o=k("g",{transform:"translate("+t+", "+e+")"});return o.appendChild(k("circle",r)),o.appendChild(s),o}(u,n,5,t.colors[r],c+": "+h,!1);t.legendArea.appendChild(d),i++}))}}]),e}(Ft),Rt=7,Ut=1e3,Vt=86400,Bt=["January","February","March","April","May","June","July","August","September","October","November","December"],Gt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],qt=function(){function t(e){var i=e.layerClass,n=void 0===i?"":i,a=e.layerTransform,r=void 0===a?"":a,s=e.constants,o=e.getData,l=e.makeElements,u=e.animateElements;ut(this,t),this.layerTransform=r,this.constants=s,this.makeElements=l,this.getData=o,this.animateElements=u,this.store=[],this.labels=[],this.layerClass=n,this.layerClass="function"==typeof this.layerClass?this.layerClass():this.layerClass,this.refresh()}return ct(t,[{key:"refresh",value:function(t){this.data=t||this.getData()}},{key:"setup",value:function(t){this.layer=P(this.layerClass,this.layerTransform,t)}},{key:"make",value:function(){this.render(this.data),this.oldData=this.data}},{key:"render",value:function(t){var e=this;this.store=this.makeElements(t),this.layer.textContent="",this.store.forEach((function(t){e.layer.appendChild(t)})),this.labels.forEach((function(t){e.layer.appendChild(t)}))}},{key:"update",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.refresh();var e=[];return t&&(e=this.animateElements(this.data)||[]),e}}]),t}(),Jt={donutSlices:{layerClass:"donut-slices",makeElements:function(t){return t.sliceStrings.map((function(e,i){var n=L(e,"donut-path",t.colors[i],"none",t.strokeWidth);return n.style.transition="transform .3s;",n}))},animateElements:function(t){return this.store.map((function(e,i){return $(e,t.sliceStrings[i])}))}},pieSlices:{layerClass:"pie-slices",makeElements:function(t){return t.sliceStrings.map((function(e,i){var n=L(e,"pie-path","none",t.colors[i]);return n.style.transition="transform .3s;",n}))},animateElements:function(t){return this.store.map((function(e,i){return $(e,t.sliceStrings[i])}))}},percentageBars:{layerClass:"percentage-bars",makeElements:function(t){var e=this;return t.xPositions.map((function(i,n){return function(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:yt,r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"none";return k("rect",{className:"percentage-bar",x:t,y:e,width:i,height:n,fill:r,styles:{stroke:x(r,-25),"stroke-dasharray":"0, "+(n+i)+", "+i+", "+n,"stroke-width":a}})}(i,0,t.widths[n],e.constants.barHeight,e.constants.barDepth,t.colors[n])}))},animateElements:function(t){if(t)return[]}},yAxis:{layerClass:"y axis",makeElements:function(t){var e=this;return t.positions.map((function(i,n){return function(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};d(t)||(t=0),n.pos||(n.pos="left"),n.offset||(n.offset=0),n.mode||(n.mode="span"),n.stroke||(n.stroke=At),n.className||(n.className="");var a=-1*Lt,r="span"===n.mode?i+Lt:0;return"tick"===n.mode&&"right"===n.pos&&(a=i+Lt,r=i),C(t,e,a+=n.offset,r+=n.offset,{stroke:n.stroke,className:n.className,lineType:n.lineType,shortenNumbers:n.shortenNumbers})}(i,t.labels[n],e.constants.width,{mode:e.constants.mode,pos:e.constants.pos,shortenNumbers:e.constants.shortenNumbers})}))},animateElements:function(t){var e=t.positions,i=t.labels,n=this.oldData.positions,a=this.oldData.labels,r=v(n,e),s=pt(r,2);n=s[0],e=s[1];var o=v(a,i),l=pt(o,2);return a=l[0],i=l[1],this.render({positions:n,labels:i}),this.store.map((function(t,i){return _(t,e[i],n[i])}))}},xAxis:{layerClass:"x axis",makeElements:function(t){var e=this;return t.positions.map((function(i,n){return function(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};d(t)||(t=0),n.pos||(n.pos="bottom"),n.offset||(n.offset=0),n.mode||(n.mode="span"),n.stroke||(n.stroke=At),n.className||(n.className="");var a=i+Lt,r="span"===n.mode?-1*Lt:i;return"tick"===n.mode&&"top"===n.pos&&(a=-1*Lt,r=0),A(t,e,a,r,{stroke:n.stroke,className:n.className,lineType:n.lineType})}(i,t.calcLabels[n],e.constants.height,{mode:e.constants.mode,pos:e.constants.pos})}))},animateElements:function(t){var e=t.positions,i=t.calcLabels,n=this.oldData.positions,a=this.oldData.calcLabels,r=v(n,e),s=pt(r,2);n=s[0],e=s[1];var o=v(a,i),l=pt(o,2);return a=l[0],i=l[1],this.render({positions:n,calcLabels:i}),this.store.map((function(t,i){return function(t,e,i){return N(t,[i,0],[e,0],Yt)}(t,e[i],n[i])}))}},yMarkers:{layerClass:"y-markers",makeElements:function(t){var e=this;return t.map((function(t){return function(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};n.labelPos||(n.labelPos="right");var a=k("text",{className:"chart-label",x:"left"===n.labelPos?St:i-c(e,5)-St,y:0,dy:Tt/-2+"px","font-size":Tt+"px","text-anchor":"start",innerHTML:e+""}),r=C(t,"",0,i,{stroke:n.stroke||At,className:n.className||"",lineType:n.lineType});return r.appendChild(a),r}(t.position,t.label,e.constants.width,{labelPos:t.options.labelPos,mode:"span",lineType:"dashed"})}))},animateElements:function(t){var e=v(this.oldData,t),i=pt(e,2);this.oldData=i[0];var n=(t=i[1]).map((function(t){return t.position})),a=t.map((function(t){return t.label})),r=t.map((function(t){return t.options})),s=this.oldData.map((function(t){return t.position}));return this.render(s.map((function(t,e){return{position:s[e],label:a[e],options:r[e]}}))),this.store.map((function(t,e){return _(t,n[e],s[e])}))}},yRegions:{layerClass:"y-regions",makeElements:function(t){var e=this;return t.map((function(t){return function(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},r=t-e,s=k("rect",{className:"bar mini",styles:{fill:"rgba(228, 234, 239, 0.49)",stroke:At,"stroke-dasharray":i+", "+r},x:0,y:0,width:i,height:r});a.labelPos||(a.labelPos="right");var o=k("text",{className:"chart-label",x:"left"===a.labelPos?St:i-c(n+"",4.5)-St,y:0,dy:Tt/-2+"px","font-size":Tt+"px","text-anchor":"start",innerHTML:n+""}),l=k("g",{transform:"translate(0, "+e+")"});return l.appendChild(s),l.appendChild(o),l}(t.startPos,t.endPos,e.constants.width,t.label,{labelPos:t.options.labelPos})}))},animateElements:function(t){var e=v(this.oldData,t),i=pt(e,2);this.oldData=i[0];var n=(t=i[1]).map((function(t){return t.endPos})),a=t.map((function(t){return t.label})),r=t.map((function(t){return t.startPos})),s=t.map((function(t){return t.options})),o=this.oldData.map((function(t){return t.endPos})),l=this.oldData.map((function(t){return t.startPos}));this.render(o.map((function(t,e){return{startPos:l[e],endPos:o[e],label:a[e],options:s[e]}})));var u=[];return this.store.map((function(t,e){u=u.concat(function(t,e,i,n){var a=e-i,r=t.childNodes[0];return[[r,{height:a,"stroke-dasharray":r.getAttribute("width")+", "+a},Yt,jt],N(t,[0,n],[0,i],Yt)]}(t,r[e],n[e],o[e]))})),u}},heatDomain:{layerClass:function(){return"heat-domain domain-"+this.constants.index},makeElements:function(t){var e=this,i=this.constants,n=i.index,a=i.colWidth,r=i.rowHeight,s=i.squareSize,o=i.radius,l=i.xTranslate,u=0;return this.serializedSubDomains=[],t.cols.map((function(t,i){1===i&&e.labels.push(T("domain-name",l,-12,B(n,!0).toUpperCase(),{fontSize:9})),t.map((function(t,i){if(t.fill){var n={"data-date":t.yyyyMmDd,"data-value":t.dataValue,"data-day":i},a=O("day",l,u,s,o,t.fill,n);e.serializedSubDomains.push(a)}u+=r})),u=0,l+=a})),this.serializedSubDomains},animateElements:function(t){if(t)return[]}},barGraph:{layerClass:function(){return"dataset-units dataset-bars dataset-"+this.constants.index},makeElements:function(t){var e=this.constants;return this.unitType="bar",this.units=t.yPositions.map((function(i,n){return function(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,o=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},l=p(e,o.zeroLine),u=pt(l,2),c=u[0],h=u[1];h-=s,0===c&&(c=o.minHeight,h-=o.minHeight),d(t)||(t=0),d(h)||(h=0),d(c,!0)||(c=0),d(i,!0)||(i=0);var f=k("rect",{className:"bar mini",style:"fill: "+n,"data-point-index":r,x:t,y:h,width:i,height:c});if((a+="")||a.length){f.setAttribute("y",0),f.setAttribute("x",0);var v=k("text",{className:"data-point-value",x:i/2,y:0,dy:Tt/2*-1+"px","font-size":Tt+"px","text-anchor":"middle",innerHTML:a}),m=k("g",{"data-point-index":r,transform:"translate("+t+", "+h+")"});return m.appendChild(f),m.appendChild(v),m}return f}(t.xPositions[n],i,t.barWidth,e.color,t.labels[n],n,t.offsets[n],{zeroLine:t.zeroLine,barsWidth:t.barsWidth,minHeight:e.minHeight})})),this.units},animateElements:function(t){var e=t.xPositions,i=t.yPositions,n=t.offsets,a=t.labels,r=this.oldData.xPositions,s=this.oldData.yPositions,o=this.oldData.offsets,l=this.oldData.labels,u=v(r,e),c=pt(u,2);r=c[0],e=c[1];var h=v(s,i),d=pt(h,2);s=d[0],i=d[1];var f=v(o,n),p=pt(f,2);o=p[0],n=p[1];var m=v(l,a),g=pt(m,2);l=g[0],a=g[1],this.render({xPositions:r,yPositions:s,offsets:o,labels:a,zeroLine:this.oldData.zeroLine,barsWidth:this.oldData.barsWidth,barWidth:this.oldData.barWidth});var y=[];return this.store.map((function(a,r){y=y.concat(E(a,e[r],i[r],t.barWidth,n[r],{zeroLine:t.zeroLine}))})),y}},lineGraph:{layerClass:function(){return"dataset-units dataset-line dataset-"+this.constants.index},makeElements:function(t){var e=this.constants;return this.unitType="dot",this.paths={},e.hideLine||(this.paths=function(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},r=e.map((function(e,i){return t[i]+","+e})).join("L");n.spline&&(r=y(t,e));var s=L("M"+r,"line-graph-path",i);if(n.heatline){var o=S(a.svgDefs,i);s.style.stroke="url(#"+o+")"}var l={path:s};if(n.regionFill){var u=S(a.svgDefs,i,!0),c="M"+t[0]+","+a.zeroLine+"L"+r+"L"+t.slice(-1)[0]+","+a.zeroLine;l.region=L(c,"region-fill","none","url(#"+u+")")}return l}(t.xPositions,t.yPositions,e.color,{heatline:e.heatline,regionFill:e.regionFill,spline:e.spline},{svgDefs:e.svgDefs,zeroLine:t.zeroLine})),this.units=[],e.hideDots||(this.units=t.yPositions.map((function(i,n){return function(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,s=k("circle",{style:"fill: "+n,"data-point-index":r,cx:t,cy:e,r:i});if((a+="")||a.length){s.setAttribute("cy",0),s.setAttribute("cx",0);var o=k("text",{className:"data-point-value",x:0,y:0,dy:Tt/2*-1-i+"px","font-size":Tt+"px","text-anchor":"middle",innerHTML:a}),l=k("g",{"data-point-index":r,transform:"translate("+t+", "+e+")"});return l.appendChild(s),l.appendChild(o),l}return s}(t.xPositions[n],i,t.radius,e.color,e.valuesOverPoints?t.values[n]:"",n)}))),Object.values(this.paths).concat(this.units)},animateElements:function(t){var e=t.xPositions,i=t.yPositions,n=t.values,a=this.oldData.xPositions,r=this.oldData.yPositions,s=this.oldData.values,o=v(a,e),l=pt(o,2);a=l[0],e=l[1];var u=v(r,i),c=pt(u,2);r=c[0],i=c[1];var h=v(s,n),d=pt(h,2);s=d[0],n=d[1],this.render({xPositions:a,yPositions:r,values:n,zeroLine:this.oldData.zeroLine,radius:this.oldData.radius});var f=[];return Object.keys(this.paths).length&&(f=f.concat(function(t,e,i,n,a){var r=[],s=i.map((function(t,i){return e[i]+","+t})).join("L");a&&(s=y(e,i));var o=[t.path,{d:"M"+s},$t,jt];if(r.push(o),t.region){var l=e[0]+","+n+"L",u="L"+e.slice(-1)[0]+", "+n,c=[t.region,{d:"M"+l+s+u},$t,jt];r.push(c)}return r}(this.paths,e,i,t.zeroLine,this.constants.spline))),this.units.length&&this.units.map((function(t,n){f=f.concat(function(t,e,i){return"circle"!==t.nodeName?[N(t,t.getAttribute("transform").split("(")[1].slice(0,-1),[e,i],Yt)]:[[t,{cx:e,cy:i},Et,jt]]}(t,e[n],i[n]))})),f}}},Xt=function(t){function i(t,e){ut(this,i);var n=ft(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t,e));return n.type="percentage",n.setup(),n}return dt(i,t),ct(i,[{key:"setMeasures",value:function(t){var e=this.measures;this.barOptions=t.barOptions||{};var i=this.barOptions;i.height=i.height||20,i.depth=i.depth||yt,e.paddings.right=30,e.legendHeight=60,e.baseHeight=8*(i.height+.5*i.depth)}},{key:"setupComponents",value:function(){var t=this.state,e=[["percentageBars",{barHeight:this.barOptions.height,barDepth:this.barOptions.depth},function(){return{xPositions:t.xPositions,widths:t.widths,colors:this.colors}}.bind(this)]];this.components=new Map(e.map((function(t){var e=X.apply(void 0,vt(t));return[t[0],e]})))}},{key:"calc",value:function(){var t=this;ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"calc",this).call(this);var e=this.state;e.xPositions=[],e.widths=[];var n=0;e.sliceTotals.map((function(i){var a=t.width*i/e.grandTotal;e.widths.push(a),e.xPositions.push(n),n+=a}))}},{key:"makeDataByIndex",value:function(){}},{key:"bindTooltip",value:function(){var t=this,i=this.state;this.container.addEventListener("mousemove",(function(n){var a=t.components.get("percentageBars").store,r=n.target;if(a.includes(r)){var s=a.indexOf(r),o=e(t.container),l=e(r),u=l.left-o.left+parseInt(r.getAttribute("width"))/2,c=l.top-o.top,h=(t.formattedLabels&&t.formattedLabels.length>0?t.formattedLabels[s]:t.state.labels[s])+": ",d=i.sliceTotals[s]/i.grandTotal;t.tip.setValues(u,c,{name:h,value:(100*d).toFixed(1)+"%"}),t.tip.showTip()}}))}}]),i}(It),Zt=function(t){function i(t,e){ut(this,i);var n=ft(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t,e));return n.type="pie",n.initTimeout=0,n.init=1,n.setup(),n}return dt(i,t),ct(i,[{key:"configure",value:function(t){ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"configure",this).call(this,t),this.mouseMove=this.mouseMove.bind(this),this.mouseLeave=this.mouseLeave.bind(this),this.hoverRadio=t.hoverRadio||.1,this.config.startAngle=t.startAngle||0,this.clockWise=t.clockWise||!1}},{key:"calc",value:function(){var t=this;ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"calc",this).call(this);var e=this.state;this.radius=this.height>this.width?this.center.x:this.center.y;var n=this.radius,a=this.clockWise,r=e.slicesProperties||[];e.sliceStrings=[],e.slicesProperties=[];var s=180-this.config.startAngle;e.sliceTotals.map((function(i,o){var l=s,u=i/e.grandTotal*360,c=u>180?1:0,d=a?-u:u,f=s+=d,p=h(l,n),v=h(f,n),m=t.init&&r[o],g=void 0,y=void 0;t.init?(g=m?m.startPosition:p,y=m?m.endPosition:p):(g=p,y=v);var b=360===u?function(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,s=i.x+t.x,o=i.y+t.y,l=i.x+e.x,u=2*i.y,c=i.y+e.y;return"M"+i.x+" "+i.y+"\n\t\tL"+s+" "+o+"\n\t\tA "+n+" "+n+" 0 "+r+" "+(a?1:0)+"\n\t\t"+l+" "+u+" z\n\t\tL"+s+" "+u+"\n\t\tA "+n+" "+n+" 0 "+r+" "+(a?1:0)+"\n\t\t"+l+" "+c+" z"}(g,y,t.center,t.radius,a,c):function(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,s=i.x+t.x,o=i.y+t.y,l=i.x+e.x,u=i.y+e.y;return"M"+i.x+" "+i.y+"\n\t\tL"+s+" "+o+"\n\t\tA "+n+" "+n+" 0 "+r+" "+(a?1:0)+"\n\t\t"+l+" "+u+" z"}(g,y,t.center,t.radius,a,c);e.sliceStrings.push(b),e.slicesProperties.push({startPosition:p,endPosition:v,value:i,total:e.grandTotal,startAngle:l,endAngle:f,angle:d})})),this.init=0}},{key:"setupComponents",value:function(){var t=this.state,e=[["pieSlices",{},function(){return{sliceStrings:t.sliceStrings,colors:this.colors}}.bind(this)]];this.components=new Map(e.map((function(t){var e=X.apply(void 0,vt(t));return[t[0],e]})))}},{key:"calTranslateByAngle",value:function(t){var e=this.radius,i=this.hoverRadio,n=h(t.startAngle+t.angle/2,e);return"translate3d("+n.x*i+"px,"+n.y*i+"px,0)"}},{key:"hoverSlice",value:function(t,i,n,a){if(t){var r=this.colors[i];if(n){W(t,this.calTranslateByAngle(this.state.slicesProperties[i])),t.style.fill=x(r,50);var s=e(this.svg),o=a.pageX-s.left+10,l=a.pageY-s.top-10,u=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[i]:this.state.labels[i])+": ",c=(100*this.state.sliceTotals[i]/this.state.grandTotal).toFixed(1);this.tip.setValues(o,l,{name:u,value:c+"%"}),this.tip.showTip()}else W(t,"translate3d(0,0,0)"),this.tip.hideTip(),t.style.fill=r}}},{key:"bindTooltip",value:function(){this.container.addEventListener("mousemove",this.mouseMove),this.container.addEventListener("mouseleave",this.mouseLeave)}},{key:"mouseMove",value:function(t){var e=t.target,i=this.components.get("pieSlices").store,n=this.curActiveSliceIndex,a=this.curActiveSlice;if(i.includes(e)){var r=i.indexOf(e);this.hoverSlice(a,n,!1),this.curActiveSlice=e,this.curActiveSliceIndex=r,this.hoverSlice(e,r,!0,t)}else this.mouseLeave()}},{key:"mouseLeave",value:function(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)}}]),i}(It),Kt=function(t){function e(t,i){ut(this,e);var n=ft(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,i));n.type="heatmap",n.countLabel=i.countLabel||"";var a=["Sunday","Monday"],r=a.includes(i.startSubDomain)?i.startSubDomain:"Sunday";return n.startSubDomainIndex=a.indexOf(r),n.setup(),n}return dt(e,t),ct(e,[{key:"setMeasures",value:function(t){var e=this.measures;this.discreteDomains=0===t.discreteDomains?0:1,e.paddings.top=36,e.paddings.bottom=0,e.legendHeight=24,e.baseHeight=12*Rt+s(e);var i=this.data,n=this.discreteDomains?12:0;this.independentWidth=12*(U(i.start,i.end)+n)+o(e)}},{key:"updateWidth",value:function(){var t=this.discreteDomains?12:0,e=this.state.noOfWeeks?this.state.noOfWeeks:52;this.baseWidth=12*(e+t)+o(this.measures)}},{key:"prepareData",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.data;if(t.start&&t.end&&t.start>t.end)throw new Error("Start date cannot be greater than end date.");if(t.start||(t.start=new Date,t.start.setFullYear(t.start.getFullYear()-1)),t.end||(t.end=new Date),t.dataPoints=t.dataPoints||{},parseInt(Object.keys(t.dataPoints)[0])>1e5){var e={};Object.keys(t.dataPoints).forEach((function(i){var n=new Date(i*Ut);e[I(n)]=t.dataPoints[i]})),t.dataPoints=e}return t}},{key:"calc",value:function(){var t=this.state;t.start=R(this.data.start),t.end=R(this.data.end),t.firstWeekStart=R(t.start),t.noOfWeeks=U(t.start,t.end),t.distribution=function(t,e){for(var i=Math.max.apply(Math,vt(t)),n=1/(e-1),a=[],r=0;r<e;r++){var s=i*(n*r);a.push(s)}return a}(Object.values(this.data.dataPoints),5),t.domainConfigs=this.getDomains()}},{key:"setupComponents",value:function(){var t=this,e=this.state,i=this.discreteDomains?0:1,n=e.domainConfigs.map((function(n,a){return["heatDomain",{index:n.index,colWidth:12,rowHeight:12,squareSize:10,radius:t.rawChartArgs.radius||0,xTranslate:12*e.domainConfigs.filter((function(t,e){return e<a})).map((function(t){return t.cols.length-i})).reduce((function(t,e){return t+e}),0)},function(){return e.domainConfigs[a]}.bind(t)]}));this.components=new Map(n.map((function(t,e){var i=X.apply(void 0,vt(t));return[t[0]+"-"+e,i]})));var a=0;Gt.forEach((function(e,i){if([1,3,5].includes(i)){var n=T("subdomain-name",-6,a,e,{fontSize:10,dy:8,textAnchor:"end"});t.drawArea.appendChild(n)}a+=12}))}},{key:"update",value:function(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.draw(),this.bindTooltip()}},{key:"bindTooltip",value:function(){var t=this;this.container.addEventListener("mousemove",(function(e){t.components.forEach((function(i){var n=i.store,a=e.target;if(n.includes(a)){var r=a.getAttribute("data-value"),s=a.getAttribute("data-date").split("-"),o=B(parseInt(s[1])-1,!0),l=t.container.getBoundingClientRect(),u=a.getBoundingClientRect(),c=parseInt(e.target.getAttribute("width")),h=u.left-l.left+c/2,d=u.top-l.top,f=r+" "+t.countLabel,p=" on "+o+" "+s[0]+", "+s[2];t.tip.setValues(h,d,{name:p,value:f,valueFirst:1},[]),t.tip.showTip()}}))}))}},{key:"renderLegend",value:function(){var t=this;this.legendArea.textContent="";var e=0,i=this.rawChartArgs.radius||0,n=T("subdomain-name",e,12,"Less",{fontSize:11,dy:9});e=30,this.legendArea.appendChild(n),this.colors.slice(0,5).map((function(n,a){var r=O("heatmap-legend-unit",e+15*a,12,10,i,n);t.legendArea.appendChild(r)}));var a=T("subdomain-name",e+75+3,12,"More",{fontSize:11,dy:9});this.legendArea.appendChild(a)}},{key:"getDomains",value:function(){for(var t=this.state,e=[t.start.getMonth(),t.start.getFullYear()],i=e[0],n=e[1],a=[t.end.getMonth(),t.end.getFullYear()],r=a[0]-i+1+12*(a[1]-n),s=[],o=R(t.start),l=0;l<r;l++){var u=t.end;if(!V(o,t.end)){var c=[o.getMonth(),o.getFullYear()];u=G(c[0],c[1])}s.push(this.getDomainConfig(o,u)),J(u,1),o=u}return s}},{key:"getDomainConfig",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=[t.getMonth(),t.getFullYear()],n=i[0],a=i[1],r=q(t),s={index:n,cols:[]};J(e=R(e)||G(n,a),1);for(var o=U(r,e),l=[],u=void 0,c=0;c<o;c++)u=this.getCol(r,n),l.push(u),J(r=new Date(u[Rt-1].yyyyMmDd),1);return void 0!==u[Rt-1].dataValue&&(J(r,1),l.push(this.getCol(r,n,!0))),s.cols=l,s}},{key:"getCol",value:function(t,e){for(var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=this.state,a=R(t),r=[],s=0;s<Rt;s++,J(a,1)){var o={},l=a>=n.start&&a<=n.end;i||a.getMonth()!==e||!l?o.yyyyMmDd=I(a):o=this.getSubDomainConfig(a),r.push(o)}return r}},{key:"getSubDomainConfig",value:function(t){var e=I(t),i=this.data.dataPoints[e];return{yyyyMmDd:e,dataValue:i||0,fill:this.colors[rt(i,this.state.distribution)]}}}]),e}(Ft),Qt=function(t){function i(t,e){ut(this,i);var n=ft(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t,e));return n.barOptions=e.barOptions||{},n.lineOptions=e.lineOptions||{},n.type=e.type||"line",n.init=1,n.setup(),n}return dt(i,t),ct(i,[{key:"setMeasures",value:function(){this.data.datasets.length<=1&&(this.config.showLegend=0,this.measures.paddings.bottom=30)}},{key:"configure",value:function(t){ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"configure",this).call(this,t),t.axisOptions=t.axisOptions||{},t.tooltipOptions=t.tooltipOptions||{},this.config.xAxisMode=t.axisOptions.xAxisMode||"span",this.config.yAxisMode=t.axisOptions.yAxisMode||"span",this.config.xIsSeries=t.axisOptions.xIsSeries||0,this.config.shortenYAxisNumbers=t.axisOptions.shortenYAxisNumbers||0,this.config.formatTooltipX=t.tooltipOptions.formatTooltipX,this.config.formatTooltipY=t.tooltipOptions.formatTooltipY,this.config.valuesOverPoints=t.valuesOverPoints}},{key:"prepareData",value:function(){return st(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.data,this.type)}},{key:"prepareFirstData",value:function(){return ot(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.data)}},{key:"calc",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.calcXPositions(),t||this.calcYAxisParameters(this.getAllYValues(),"line"===this.type),this.makeDataByIndex()}},{key:"calcXPositions",value:function(){var t=this.state,e=this.data.labels;t.datasetLength=e.length,t.unitWidth=this.width/t.datasetLength,t.xOffset=t.unitWidth/2,t.xAxis={labels:e,positions:e.map((function(e,i){return l(t.xOffset+i*t.unitWidth)}))}}},{key:"calcYAxisParameters",value:function(t){var e=tt(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:"false"),i=this.height/nt(e),n=it(e)*i,a=this.height-et(e)*n;this.state.yAxis={labels:e,positions:e.map((function(t){return a-t*i})),scaleMultiplier:i,zeroLine:a},this.calcDatasetPoints(),this.calcYExtremes(),this.calcYRegions()}},{key:"calcDatasetPoints",value:function(){var t=this.state,e=function(e){return e.map((function(e){return at(e,t.yAxis)}))};t.datasets=this.data.datasets.map((function(t,i){var n=t.values,a=t.cumulativeYs||[];return{name:t.name&&t.name.replace(/<|>|&/g,(function(t){return"&"==t?"&amp;":"<"==t?"&lt;":"&gt;"})),index:i,chartType:t.chartType,values:n,yPositions:e(n),cumulativeYs:a,cumulativeYPos:e(a)}}))}},{key:"calcYExtremes",value:function(){var t=this.state;this.barOptions.stacked?t.yExtremes=t.datasets[t.datasets.length-1].cumulativeYPos:(t.yExtremes=new Array(t.datasetLength).fill(9999),t.datasets.map((function(e){e.yPositions.map((function(e,i){e<t.yExtremes[i]&&(t.yExtremes[i]=e)}))})))}},{key:"calcYRegions",value:function(){var t=this.state;this.data.yMarkers&&(this.state.yMarkers=this.data.yMarkers.map((function(e){return e.position=at(e.value,t.yAxis),e.options||(e.options={}),e}))),this.data.yRegions&&(this.state.yRegions=this.data.yRegions.map((function(e){return e.startPos=at(e.start,t.yAxis),e.endPos=at(e.end,t.yAxis),e.options||(e.options={}),e})))}},{key:"getAllYValues",value:function(){var t,e=this,i="values";if(this.barOptions.stacked){i="cumulativeYs";var n=new Array(this.state.datasetLength).fill(0);this.data.datasets.map((function(t,a){var r=e.data.datasets[a].values;t[i]=n=n.map((function(t,e){return t+r[e]}))}))}var a=this.data.datasets.map((function(t){return t[i]}));return this.data.yMarkers&&a.push(this.data.yMarkers.map((function(t){return t.value}))),this.data.yRegions&&this.data.yRegions.map((function(t){a.push([t.end,t.start])})),(t=[]).concat.apply(t,vt(a))}},{key:"setupComponents",value:function(){var t=this,e=[["yAxis",{mode:this.config.yAxisMode,width:this.width,shortenNumbers:this.config.shortenYAxisNumbers},function(){return this.state.yAxis}.bind(this)],["xAxis",{mode:this.config.xAxisMode,height:this.height},function(){var t=this.state;return t.xAxis.calcLabels=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=t/e.length;n<=0&&(n=1);var a=n/bt,r=void 0;if(i){var s=Math.max.apply(Math,vt(e.map((function(t){return t.length}))));r=Math.ceil(s/a)}return e.map((function(t,e){return(t+="").length>a&&(i?e%r!=0&&(t=""):t=a-3>0?t.slice(0,a-3)+" ...":t.slice(0,a)+".."),t}))}(this.width,t.xAxis.labels,this.config.xIsSeries),t.xAxis}.bind(this)],["yRegions",{width:this.width,pos:"right"},function(){return this.state.yRegions}.bind(this)]],i=this.state.datasets.filter((function(t){return"bar"===t.chartType})),n=this.state.datasets.filter((function(t){return"line"===t.chartType})),a=i.map((function(e){var n=e.index;return["barGraph-"+e.index,{index:n,color:t.colors[n],stacked:t.barOptions.stacked,valuesOverPoints:t.config.valuesOverPoints,minHeight:0*t.height},function(){var t=this.state,e=t.datasets[n],a=this.barOptions.stacked,r=this.barOptions.spaceRatio||.5,s=t.unitWidth*(1-r),o=s/(a?1:i.length),l=t.xAxis.positions.map((function(t){return t-s/2}));a||(l=l.map((function(t){return t+o*n})));var u=new Array(t.datasetLength).fill("");this.config.valuesOverPoints&&(u=a&&e.index===t.datasets.length-1?e.cumulativeYs:e.values);var c=new Array(t.datasetLength).fill(0);return a&&(c=e.yPositions.map((function(t,i){return t-e.cumulativeYPos[i]}))),{xPositions:l,yPositions:e.yPositions,offsets:c,labels:u,zeroLine:t.yAxis.zeroLine,barsWidth:s,barWidth:o}}.bind(t)]})),r=n.map((function(e){var i=e.index;return["lineGraph-"+e.index,{index:i,color:t.colors[i],svgDefs:t.svgDefs,heatline:t.lineOptions.heatline,regionFill:t.lineOptions.regionFill,spline:t.lineOptions.spline,hideDots:t.lineOptions.hideDots,hideLine:t.lineOptions.hideLine,valuesOverPoints:t.config.valuesOverPoints},function(){var t=this.state,e=t.datasets[i],n=t.yAxis.positions[0]<t.yAxis.zeroLine?t.yAxis.positions[0]:t.yAxis.zeroLine;return{xPositions:t.xAxis.positions,yPositions:e.yPositions,values:e.values,zeroLine:n,radius:this.lineOptions.dotSize||4}}.bind(t)]})),s=[["yMarkers",{width:this.width,pos:"right"},function(){return this.state.yMarkers}.bind(this)]];e=e.concat(a,r,s);var o=["yMarkers","yRegions"];this.dataUnitComponents=[],this.components=new Map(e.filter((function(e){return!o.includes(e[0])||t.state[e[0]]})).map((function(e){var i=X.apply(void 0,vt(e));return(e[0].includes("lineGraph")||e[0].includes("barGraph"))&&t.dataUnitComponents.push(i),[e[0],i]})))}},{key:"makeDataByIndex",value:function(){var t=this;this.dataByIndex={};var e=this.state,i=this.config.formatTooltipX,n=this.config.formatTooltipY;e.xAxis.labels.map((function(a,r){var s=t.state.datasets.map((function(e,i){var a=e.values[r];return{title:e.name,value:a,yPos:e.yPositions[r],color:t.colors[i],formatted:n?n(a):a}}));t.dataByIndex[r]={label:a,formattedLabel:i?i(a):a,xPos:e.xAxis.positions[r],values:s,yExtreme:e.yExtremes[r]}}))}},{key:"bindTooltip",value:function(){var t=this;this.container.addEventListener("mousemove",(function(i){var n=t.measures,s=e(t.container),o=i.pageX-s.left-r(n),l=i.pageY-s.top;l<t.height+a(n)&&l>a(n)?t.mapTooltipXPosition(o):t.tip.hideTip()}))}},{key:"mapTooltipXPosition",value:function(t){var e=this.state;if(e.yExtremes){var i=function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=e.reduce((function(e,i){return Math.abs(i-t)<Math.abs(e-t)?i:e}),[]);return i?e.indexOf(n):n}(t,e.xAxis.positions,!0);if(i>=0){var n=this.dataByIndex[i];this.tip.setValues(n.xPos+this.tip.offset.x,n.yExtreme+this.tip.offset.y,{name:n.formattedLabel,value:""},n.values,i),this.tip.showTip()}}}},{key:"renderLegend",value:function(){var t=this,e=this.data;e.datasets.length>1&&(this.legendArea.textContent="",e.datasets.map((function(e,i){var n=function(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"none",a=arguments[4];a=arguments.length>5&&void 0!==arguments[5]&&arguments[5]?m(a,Ot):a;var r={className:"legend-bar",x:0,y:0,width:i,height:"2px",fill:n},s=k("text",{className:"legend-dataset-text",x:0,y:0,dy:2*Tt+"px","font-size":1.2*Tt+"px","text-anchor":"start",fill:Ct,innerHTML:a}),o=k("g",{transform:"translate("+t+", "+e+")"});return o.appendChild(k("rect",r)),o.appendChild(s),o}(100*i,"0",100,t.colors[i],e.name,t.config.truncateLegends);t.legendArea.appendChild(n)})))}},{key:"makeOverlay",value:function(){var t=this;this.init?this.init=0:(this.overlayGuides&&this.overlayGuides.forEach((function(t){var e=t.overlay;e.parentNode.removeChild(e)})),this.overlayGuides=this.dataUnitComponents.map((function(t){return{type:t.unitType,overlay:void 0,units:t.units}})),void 0===this.state.currentIndex&&(this.state.currentIndex=this.state.datasetLength-1),this.overlayGuides.map((function(e){var i=e.units[t.state.currentIndex];e.overlay=Nt[e.type](i),t.drawArea.appendChild(e.overlay)})))}},{key:"updateOverlayGuides",value:function(){this.overlayGuides&&this.overlayGuides.forEach((function(t){var e=t.overlay;e.parentNode.removeChild(e)}))}},{key:"bindOverlay",value:function(){var t=this;this.parent.addEventListener("data-select",(function(){t.updateOverlay()}))}},{key:"bindUnits",value:function(){var t=this;this.dataUnitComponents.map((function(e){e.units.map((function(e){e.addEventListener("click",(function(){var i=e.getAttribute("data-point-index");t.setCurrentDataPoint(i)}))}))})),this.tip.container.addEventListener("click",(function(){var e=t.tip.container.getAttribute("data-point-index");t.setCurrentDataPoint(e)}))}},{key:"updateOverlay",value:function(){var t=this;this.overlayGuides.map((function(e){var i=e.units[t.state.currentIndex];_t[e.type](i,e.overlay)}))}},{key:"onLeftArrow",value:function(){this.setCurrentDataPoint(this.state.currentIndex-1)}},{key:"onRightArrow",value:function(){this.setCurrentDataPoint(this.state.currentIndex+1)}},{key:"getDataPoint",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state.currentIndex,e=this.state;return{index:t,label:e.xAxis.labels[t],values:e.datasets.map((function(e){return e.values[t]}))}}},{key:"setCurrentDataPoint",value:function(t){var e=this.state;(t=parseInt(t))<0&&(t=0),t>=e.xAxis.labels.length&&(t=e.xAxis.labels.length-1),t!==e.currentIndex&&(e.currentIndex=t,function(t,e,i){var n=document.createEvent("HTMLEvents");for(var a in n.initEvent(e,!0,!0),i)n[a]=i[a];t.dispatchEvent(n)}(this.parent,"data-select",this.getDataPoint()))}},{key:"addDataPoint",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.state.datasetLength;ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"addDataPoint",this).call(this,t,e,n),this.data.labels.splice(n,0,t),this.data.datasets.map((function(t,i){t.values.splice(n,0,e[i])})),this.update(this.data)}},{key:"removeDataPoint",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state.datasetLength-1;this.data.labels.length<=1||(ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"removeDataPoint",this).call(this,t),this.data.labels.splice(t,1),this.data.datasets.map((function(e){e.values.splice(t,1)})),this.update(this.data))}},{key:"updateDataset",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.data.datasets[e].values=t,this.update(this.data)}},{key:"updateDatasets",value:function(t){this.data.datasets.map((function(e,i){t[i]&&(e.values=t[i])})),this.update(this.data)}}]),i}(Ft),te=function(t){function i(t,e){ut(this,i);var n=ft(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t,e));return n.type="donut",n.initTimeout=0,n.init=1,n.setup(),n}return dt(i,t),ct(i,[{key:"configure",value:function(t){ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"configure",this).call(this,t),this.mouseMove=this.mouseMove.bind(this),this.mouseLeave=this.mouseLeave.bind(this),this.hoverRadio=t.hoverRadio||.1,this.config.startAngle=t.startAngle||0,this.clockWise=t.clockWise||!1,this.strokeWidth=t.strokeWidth||30}},{key:"calc",value:function(){var t=this;ht(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"calc",this).call(this);var e=this.state;this.radius=this.height>this.width?this.center.x-this.strokeWidth/2:this.center.y-this.strokeWidth/2;var n=this.radius,a=this.clockWise,r=e.slicesProperties||[];e.sliceStrings=[],e.slicesProperties=[];var s=180-this.config.startAngle;e.sliceTotals.map((function(i,o){var l=s,u=i/e.grandTotal*360,c=u>180?1:0,d=a?-u:u,f=s+=d,p=h(l,n),v=h(f,n),m=t.init&&r[o],g=void 0,y=void 0;t.init?(g=m?m.startPosition:p,y=m?m.endPosition:p):(g=p,y=v);var b=360===u?function(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,s=i.x+t.x,o=i.y+t.y,l=i.x+e.x,u=2*n+o;return"M"+s+" "+o+"\n\t\tA "+n+" "+n+" 0 "+r+" "+(a?1:0)+"\n\t\t"+l+" "+u+"\n\t\tM"+s+" "+u+"\n\t\tA "+n+" "+n+" 0 "+r+" "+(a?1:0)+"\n\t\t"+l+" "+(i.y+t.y)}(g,y,t.center,t.radius,t.clockWise,c):function(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;return"M"+(i.x+t.x)+" "+(i.y+t.y)+"\n\t\tA "+n+" "+n+" 0 "+r+" "+(a?1:0)+"\n\t\t"+(i.x+e.x)+" "+(i.y+e.y)}(g,y,t.center,t.radius,t.clockWise,c);e.sliceStrings.push(b),e.slicesProperties.push({startPosition:p,endPosition:v,value:i,total:e.grandTotal,startAngle:l,endAngle:f,angle:d})})),this.init=0}},{key:"setupComponents",value:function(){var t=this.state,e=[["donutSlices",{},function(){return{sliceStrings:t.sliceStrings,colors:this.colors,strokeWidth:this.strokeWidth}}.bind(this)]];this.components=new Map(e.map((function(t){var e=X.apply(void 0,vt(t));return[t[0],e]})))}},{key:"calTranslateByAngle",value:function(t){var e=this.radius,i=this.hoverRadio,n=h(t.startAngle+t.angle/2,e);return"translate3d("+n.x*i+"px,"+n.y*i+"px,0)"}},{key:"hoverSlice",value:function(t,i,n,a){if(t){var r=this.colors[i];if(n){W(t,this.calTranslateByAngle(this.state.slicesProperties[i])),t.style.stroke=x(r,50);var s=e(this.svg),o=a.pageX-s.left+10,l=a.pageY-s.top-10,u=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[i]:this.state.labels[i])+": ",c=(100*this.state.sliceTotals[i]/this.state.grandTotal).toFixed(1);this.tip.setValues(o,l,{name:u,value:c+"%"}),this.tip.showTip()}else W(t,"translate3d(0,0,0)"),this.tip.hideTip(),t.style.stroke=r}}},{key:"bindTooltip",value:function(){this.container.addEventListener("mousemove",this.mouseMove),this.container.addEventListener("mouseleave",this.mouseLeave)}},{key:"mouseMove",value:function(t){var e=t.target,i=this.components.get("donutSlices").store,n=this.curActiveSliceIndex,a=this.curActiveSlice;if(i.includes(e)){var r=i.indexOf(e);this.hoverSlice(a,n,!1),this.curActiveSlice=e,this.curActiveSliceIndex=r,this.hoverSlice(e,r,!0,t)}else this.mouseLeave()}},{key:"mouseLeave",value:function(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)}}]),i}(It),ee={bar:Qt,line:Qt,percentage:Xt,heatmap:Kt,pie:Zt,donut:te},ie=Object.freeze({Chart:function t(e,i){return ut(this,t),function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"line",e=arguments[1],i=arguments[2];return"axis-mixed"===t?(i.type="line",new Qt(e,i)):ee[t]?new ee[t](e,i):void console.error("Undefined chart type: "+t)}(i.type,e,i)},PercentageChart:Xt,PieChart:Zt,Heatmap:Kt,AxisChart:Qt});return Object.assign({},{NAME:"Frappe Charts",VERSION:"1.6.2"},ie)}()},750:t=>{var e=function(t){"use strict";var e,i=Object.prototype,n=i.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},r=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",o=a.toStringTag||"@@toStringTag";function l(t,e,i){return Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,i){return t[e]=i}}function u(t,e,i,n){var a=e&&e.prototype instanceof m?e:m,r=Object.create(a.prototype),s=new O(n||[]);return r._invoke=function(t,e,i){var n=h;return function(a,r){if(n===f)throw new Error("Generator is already running");if(n===p){if("throw"===a)throw r;return A()}for(i.method=a,i.arg=r;;){var s=i.delegate;if(s){var o=P(s,i);if(o){if(o===v)continue;return o}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(n===h)throw n=p,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);n=f;var l=c(t,e,i);if("normal"===l.type){if(n=i.done?p:d,l.arg===v)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(n=p,i.method="throw",i.arg=l.arg)}}}(t,i,s),r}function c(t,e,i){try{return{type:"normal",arg:t.call(e,i)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var h="suspendedStart",d="suspendedYield",f="executing",p="completed",v={};function m(){}function g(){}function y(){}var b={};l(b,r,(function(){return this}));var x=Object.getPrototypeOf,w=x&&x(x(T([])));w&&w!==i&&n.call(w,r)&&(b=w);var k=y.prototype=m.prototype=Object.create(b);function D(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function M(t,e){function i(a,r,s,o){var l=c(t[a],t,r);if("throw"!==l.type){var u=l.arg,h=u.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){i("next",t,s,o)}),(function(t){i("throw",t,s,o)})):e.resolve(h).then((function(t){u.value=t,s(u)}),(function(t){return i("throw",t,s,o)}))}o(l.arg)}var a;this._invoke=function(t,n){function r(){return new e((function(e,a){i(t,n,e,a)}))}return a=a?a.then(r,r):r()}}function P(t,i){var n=t.iterator[i.method];if(n===e){if(i.delegate=null,"throw"===i.method){if(t.iterator.return&&(i.method="return",i.arg=e,P(t,i),"throw"===i.method))return v;i.method="throw",i.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var a=c(n,t.iterator,i.arg);if("throw"===a.type)return i.method="throw",i.arg=a.arg,i.delegate=null,v;var r=a.arg;return r?r.done?(i[t.resultName]=r.value,i.next=t.nextLoc,"return"!==i.method&&(i.method="next",i.arg=e),i.delegate=null,v):r:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,v)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function T(t){if(t){var i=t[r];if(i)return i.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,s=function i(){for(;++a<t.length;)if(n.call(t,a))return i.value=t[a],i.done=!1,i;return i.value=e,i.done=!0,i};return s.next=s}}return{next:A}}function A(){return{value:e,done:!0}}return g.prototype=y,l(k,"constructor",y),l(y,"constructor",g),g.displayName=l(y,o,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,l(t,o,"GeneratorFunction")),t.prototype=Object.create(k),t},t.awrap=function(t){return{__await:t}},D(M.prototype),l(M.prototype,s,(function(){return this})),t.AsyncIterator=M,t.async=function(e,i,n,a,r){void 0===r&&(r=Promise);var s=new M(u(e,i,n,a),r);return t.isGeneratorFunction(i)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},D(k),l(k,o,"Generator"),l(k,r,(function(){return this})),l(k,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var i in t)e.push(i);return e.reverse(),function i(){for(;e.length;){var n=e.pop();if(n in t)return i.value=n,i.done=!1,i}return i.done=!0,i}},t.values=T,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(S),!t)for(var i in this)"t"===i.charAt(0)&&n.call(this,i)&&!isNaN(+i.slice(1))&&(this[i]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var i=this;function a(n,a){return o.type="throw",o.arg=t,i.next=n,a&&(i.method="next",i.arg=e),!!a}for(var r=this.tryEntries.length-1;r>=0;--r){var s=this.tryEntries[r],o=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var l=n.call(s,"catchLoc"),u=n.call(s,"finallyLoc");if(l&&u){if(this.prev<s.catchLoc)return a(s.catchLoc,!0);if(this.prev<s.finallyLoc)return a(s.finallyLoc)}else if(l){if(this.prev<s.catchLoc)return a(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return a(s.finallyLoc)}}}},abrupt:function(t,e){for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var r=a;break}}r&&("break"===t||"continue"===t)&&r.tryLoc<=e&&e<=r.finallyLoc&&(r=null);var s=r?r.completion:{};return s.type=t,s.arg=e,r?(this.method="next",this.next=r.finallyLoc,v):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var i=this.tryEntries[e];if(i.finallyLoc===t)return this.complete(i.completion,i.afterLoc),S(i),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var i=this.tryEntries[e];if(i.tryLoc===t){var n=i.completion;if("throw"===n.type){var a=n.arg;S(i)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,i,n){return this.delegate={iterator:T(t),resultName:i,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}},e={};function i(n){var a=e[n];if(void 0!==a)return a.exports;var r=e[n]={exports:{}};return t[n].call(r.exports,r,r.exports,i),r.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";i.r(n);const t=flarum.core.compat["admin/app"];var e=i.n(t);const a=flarum.core.compat["common/extend"],r=flarum.core.compat["admin/components/DashboardPage"];var s=i.n(r);function o(t,e,i,n,a,r,s){try{var o=t[r](s),l=o.value}catch(t){return void i(t)}o.done?e(l):Promise.resolve(l).then(n,a)}function l(t){return function(){var e=this,i=arguments;return new Promise((function(n,a){var r=t.apply(e,i);function s(t){o(r,n,a,s,l,"next",t)}function l(t){o(r,n,a,s,l,"throw",t)}s(void 0)}))}}function u(t,e){return u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},u(t,e)}function c(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,u(t,e)}var h=i(126),d=i.n(h);const f=flarum.core.compat["admin/components/DashboardWidget"];var p=i.n(f);const v=flarum.core.compat["common/components/LoadingIndicator"];var g=i.n(v);const y=flarum.core.compat["common/components/Link"];var b=i.n(y);const x=flarum.core.compat["common/utils/abbreviateNumber"];var w=i.n(x),k=function(t){function i(){for(var e,i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];return(e=t.call.apply(t,[this].concat(n))||this).entities=["users","discussions","posts"],e.lifetimeData=void 0,e.loadingLifetime=!0,e}c(i,t);var n=i.prototype;return n.oncreate=function(e){t.prototype.oncreate.call(this,e),this.loadLifetimeData()},n.loadLifetimeData=function(){var t=l(d().mark((function t(){var i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.loadingLifetime=!0,m.redraw(),t.next=4,e().request({method:"GET",url:e().forum.attribute("apiUrl")+"/statistics",params:{period:"lifetime"}});case 4:i=t.sent,this.lifetimeData=i,this.loadingLifetime=!1,m.redraw();case 8:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.className=function(){return"StatisticsWidget StatisticsWidget--mini"},n.content=function(){var t=this;return m("div",{className:"StatisticsWidget-table"},m("h4",{className:"StatisticsWidget-title"},e().translator.trans("flarum-statistics.admin.statistics.mini_heading")),m("div",{className:"StatisticsWidget-entities"},m("div",{className:"StatisticsWidget-labels"},m("div",{className:"StatisticsWidget-label"},e().translator.trans("flarum-statistics.admin.statistics.total_label"))),this.entities.map((function(i){var n=t.loadingLifetime?e().translator.trans("flarum-statistics.admin.statistics.loading"):t.getTotalCount(i);return m("div",{className:"StatisticsWidget-entity"},m("h3",{className:"StatisticsWidget-heading"},e().translator.trans("flarum-statistics.admin.statistics."+i+"_heading")),m("div",{className:"StatisticsWidget-total",title:n},t.loadingLifetime?m(g(),{display:"inline"}):w()(n)))}))),m("div",{className:"StatisticsWidget-viewFull"},m(b(),{href:e().route("extension",{id:"flarum-statistics"})},e().translator.trans("flarum-statistics.admin.statistics.view_full"))))},n.getTotalCount=function(t){return this.lifetimeData[t]},i}(p());const D=flarum.core.compat["admin/components/ExtensionPage"];var M=i.n(D);function P(){return P=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},P.apply(this,arguments)}const L=flarum.core.compat["common/components/SelectDropdown"];var S=i.n(L);const O=flarum.core.compat["common/components/Button"];var T=i.n(O);const A=flarum.core.compat["common/utils/extractText"];var C=i.n(A);const N=flarum.core.compat["common/components/Placeholder"];var _=i.n(N);const E=flarum.core.compat["common/helpers/icon"];var $=i.n(E);const Y=flarum.core.compat["common/utils/ItemList"];var W=i.n(Y);const j=flarum.core.compat["admin/utils/generateElementId"];var z=i.n(j);const H=flarum.core.compat["common/components/Modal"];var F=i.n(H),I=i(757),R=i.n(I),U=i(221),V=i.n(U);R().extend(V());var B=function(t){function i(){for(var e,i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];return(e=t.call.apply(t,[this].concat(n))||this).state={inputs:{startDateVal:R()().format("YYYY-MM-DD"),endDateVal:R()().format("YYYY-MM-DD")},ids:{startDate:z()(),endDate:z()()}},e}c(i,t);var n=i.prototype;return n.oninit=function(e){t.prototype.oninit.call(this,e),this.attrs.value&&(this.state.inputs={startDateVal:R().utc(1e3*this.attrs.value.start).format("YYYY-MM-DD"),endDateVal:R().utc(1e3*this.attrs.value.end).format("YYYY-MM-DD")})},n.className=function(){return"StatisticsWidgetDateSelectionModal Modal--small"},n.title=function(){return e().translator.trans("flarum-statistics.admin.date_selection_modal.title")},n.content=function(){return m("div",{class:"Modal-body"},this.items().toArray())},n.items=function(){var t=new(W());return t.add("intro",m("p",null,e().translator.trans("flarum-statistics.admin.date_selection_modal.description")),100),t.add("date_start",m("div",{class:"Form-group"},m("label",{htmlFor:this.state.ids.startDate},e().translator.trans("flarum-statistics.admin.date_selection_modal.start_date")),m("input",{type:"date",id:this.state.ids.startDate,value:this.state.inputs.startDateVal,onchange:this.updateState("startDateVal"),className:"FormControl"})),90),t.add("date_end",m("div",{class:"Form-group"},m("label",{htmlFor:this.state.ids.endDate},e().translator.trans("flarum-statistics.admin.date_selection_modal.end_date")),m("input",{type:"date",id:this.state.ids.endDate,value:this.state.inputs.endDateVal,onchange:this.updateState("endDateVal"),className:"FormControl"})),80),t.add("submit",m(T(),{class:"Button Button--primary",type:"submit"},e().translator.trans("flarum-statistics.admin.date_selection_modal.submit_button")),0),t},n.updateState=function(t){var e=this;return function(i){e.state.inputs[t]=i.currentTarget.value}},n.submitData=function(){return{start:Math.floor(+R().utc(this.state.inputs.startDateVal+"Z")/1e3),end:Math.floor(+R().utc(this.state.inputs.endDateVal+"Z").hour(23).minute(59).second(59).millisecond(999)/1e3)}},n.onsubmit=function(t){t.preventDefault();var i=this.submitData();i.end<i.start?this.alertAttrs={type:"error",controls:e().translator.trans("flarum-statistics.admin.date_selection_modal.errors.end_before_start")}:(this.attrs.onModalSubmit(i),this.hide())},i}(F()),G=i(982),q=i.n(G),J=i(23);R().extend(V()),R().extend(q());var X=function(t){function i(){for(var e,i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];return(e=t.call.apply(t,[this].concat(n))||this).entities=["users","discussions","posts"],e.periods=void 0,e.chart=void 0,e.customPeriod=null,e.timedData={},e.lifetimeData=void 0,e.customPeriodData={},e.noData=!1,e.loadingLifetime=!0,e.loadingTimed=e.entities.reduce((function(t,e){return t[e]="unloaded",t}),{}),e.loadingCustom=e.entities.reduce((function(t,e){return t[e]="unloaded",t}),{}),e.selectedEntity="users",e.selectedPeriod=void 0,e.chartEntity=void 0,e.chartPeriod=void 0,e}c(i,t);var n=i.prototype;return n.oncreate=function(e){t.prototype.oncreate.call(this,e),this.loadLifetimeData()},n.loadLifetimeData=function(){var t=l(d().mark((function t(){var i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.loadingLifetime=!0,m.redraw(),t.next=4,e().request({method:"GET",url:e().forum.attribute("apiUrl")+"/statistics",params:{period:"lifetime"}});case 4:i=t.sent,this.lifetimeData=i,this.loadingLifetime=!1,m.redraw();case 8:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.loadTimedData=function(){var t=l(d().mark((function t(i){var n,a,r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.loadingTimed[i]="loading",m.redraw(),t.prev=2,t.next=5,e().request({method:"GET",url:e().forum.attribute("apiUrl")+"/statistics",params:{period:"timed",model:i}});case 5:n=t.sent,this.timedData[i]=n,this.loadingTimed[i]="loaded",(a=new Date).setUTCHours(0,0,0,0),r=a.getTime()/1e3,this.periods={today:{start:r,end:r+86400,step:3600},last_7_days:{start:r-604800,end:r,step:86400},previous_7_days:{start:r-1209600,end:r-604800,step:86400},last_28_days:{start:r-2419200,end:r,step:86400},previous_28_days:{start:r-4838400,end:r-2419200,step:86400},last_12_months:{start:r-31449600,end:r,step:604800}},this.selectedPeriod="last_7_days",t.next=19;break;case 15:t.prev=15,t.t0=t.catch(2),console.error(t.t0),this.loadingTimed[i]="fail";case 19:m.redraw();case 20:case"end":return t.stop()}}),t,this,[[2,15]])})));return function(e){return t.apply(this,arguments)}}(),n.loadCustomRangeData=function(){var t=l(d().mark((function t(i){var n,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.loadingCustom[i]="loading",m.redraw(),n=P({},this.customPeriod),t.prev=3,t.next=6,e().request({method:"GET",url:e().forum.attribute("apiUrl")+"/statistics",params:{period:"custom",model:i,dateRange:{start:n.start,end:n.end}}});case 6:if(a=t.sent,JSON.stringify(n)===JSON.stringify(this.customPeriod)){t.next=9;break}return t.abrupt("return");case 9:this.customPeriodData[i]=a,this.loadingCustom[i]="loaded",m.redraw(),t.next=20;break;case 14:if(t.prev=14,t.t0=t.catch(3),JSON.stringify(n)===JSON.stringify(this.customPeriod)){t.next=18;break}return t.abrupt("return");case 18:console.error(t.t0),this.loadingCustom[i]="fail";case 20:case"end":return t.stop()}}),t,this,[[3,14]])})));return function(e){return t.apply(this,arguments)}}(),n.className=function(){return"StatisticsWidget"},n.content=function(){var t,i,n=this,a="loaded"!==("custom"===this.selectedPeriod?this.loadingCustom:this.loadingTimed)[this.selectedEntity],r=a?null:"custom"===this.selectedPeriod?{start:null==(t=this.customPeriod)?void 0:t.end,end:null==(i=this.customPeriod)?void 0:i.end,step:86400}:this.periods[this.selectedPeriod];return"custom"===this.selectedPeriod?this.customPeriodData[this.selectedEntity]||"unloaded"!==this.loadingCustom[this.selectedEntity]||this.loadCustomRangeData(this.selectedEntity):this.timedData[this.selectedEntity]||"unloaded"!==this.loadingTimed[this.selectedEntity]||this.loadTimedData(this.selectedEntity),m("div",{className:"StatisticsWidget-table"},m("div",{className:"StatisticsWidget-entities"},m("div",{className:"StatisticsWidget-labels"},m("div",{className:"StatisticsWidget-label"},e().translator.trans("flarum-statistics.admin.statistics.total_label")),m("div",{className:"StatisticsWidget-label"},a?m(g(),{size:"small",display:"inline"}):m(S(),{disabled:a,buttonClassName:"Button Button--text",caretIcon:"fas fa-caret-down"},Object.keys(this.periods).map((function(t){return m(T(),{key:t,active:t===n.selectedPeriod,onclick:n.changePeriod.bind(n,t),icon:t!==n.selectedPeriod||"fas fa-check"},e().translator.trans("flarum-statistics.admin.statistics."+t+"_label"))})).concat([m(T(),{key:"custom",active:"custom"===this.selectedPeriod,onclick:function(){var t={onModalSubmit:function(t){JSON.stringify(t)!==JSON.stringify(n.customPeriod)&&(n.customPeriodData={},Object.keys(n.loadingCustom).forEach((function(t){return n.loadingCustom[t]="unloaded"})),n.customPeriod=t,n.changePeriod("custom"))}};n.customPeriod&&(t.value=n.customPeriod),e().modal.show(B,t)},icon:"custom"!==this.selectedPeriod||"fas fa-check"},"custom"===this.selectedPeriod?C()(e().translator.trans("flarum-statistics.admin.statistics.custom_label_specified",{fromDate:R().utc(1e3*this.customPeriod.start).format("ll"),toDate:R().utc(1e3*this.customPeriod.end).format("ll")})):e().translator.trans("flarum-statistics.admin.statistics.custom_label"))])))),this.entities.map((function(t){var i=n.loadingLifetime?e().translator.trans("flarum-statistics.admin.statistics.loading"):n.getTotalCount(t),s=a?e().translator.trans("flarum-statistics.admin.statistics.loading"):n.getPeriodCount(t,r),o="custom"===n.selectedPeriod?null:a?e().translator.trans("flarum-statistics.admin.statistics.loading"):n.getPeriodCount(t,n.getLastPeriod(r)),l=a||0===o||null===o?0:(s-o)/o*100;return m("button",{className:"Button--ua-reset StatisticsWidget-entity"+(n.selectedEntity===t?" active":""),onclick:n.changeEntity.bind(n,t)},m("h3",{className:"StatisticsWidget-heading"},e().translator.trans("flarum-statistics.admin.statistics."+t+"_heading")),m("div",{className:"StatisticsWidget-total",title:i},n.loadingLifetime?m(g(),{display:"inline"}):w()(i)),m("div",{className:"StatisticsWidget-period",title:s},a?m(g(),{display:"inline"}):w()(s),0!==l&&m("[",null," ",m("span",{className:"StatisticsWidget-change StatisticsWidget-change--"+(l>0?"up":"down")},$()("fas fa-arrow-"+(l>0?"up":"down")),Math.abs(l).toFixed(1),"%"))))}))),m("[",null,a?m("div",{key:"loading",className:"StatisticsWidget-chart","data-loading":"true"},m(g(),{size:"large"})):m("div",{key:"loaded",className:"StatisticsWidget-chart","data-loading":"false",oncreate:this.drawChart.bind(this),onupdate:this.drawChart.bind(this)})),this.noData&&m(_(),{text:e().translator.trans("flarum-statistics.admin.statistics.no_data")}),!this.noData&&!!this.chart&&m(T(),{className:"StatisticsWidget-chartExport Button",icon:"fas fa-file-export",onclick:function(){n.chart.export()}},e().translator.trans("flarum-statistics.admin.statistics.export_chart_button")))},n.drawChart=function(t){var i,n;if(!this.chart||this.chartEntity!==this.selectedEntity||this.chartPeriod!==this.selectedPeriod){for(var a="custom"===this.selectedPeriod?{start:null==(i=this.customPeriod)?void 0:i.start,end:null==(n=this.customPeriod)?void 0:n.end,step:86400}:this.periods[this.selectedPeriod],r=a.end-a.start,s=[],o=[],l=[],u=a.start;u<a.end;u+=a.step){var c=void 0;a.step<86400?c=R().unix(u).utc().format("h A"):(c=R().unix(u).utc().format("D MMM"),a.step>86400&&(c+=" - "+R().unix(u+a.step-1).utc().format("D MMM"))),s.push(c),o.push(this.getPeriodCount(this.selectedEntity,{start:u,end:u+a.step})),l.push(this.getPeriodCount(this.selectedEntity,{start:u-r,end:u-r}))}if(0===o.length)return this.noData=!0,void m.redraw();this.noData=!1,m.redraw();var h={labels:s,datasets:[{name:C()(e().translator.trans("flarum-statistics.admin.statistics.current_period")),values:o},{name:C()(e().translator.trans("flarum-statistics.admin.statistics.previous_period")),values:l}]};this.chart&&16&document.compareDocumentPosition(this.chart.parent)?this.chart.update(h):this.chart=new J.Chart(t.dom,{data:h,type:"line",height:280,axisOptions:{xAxisMode:"tick",yAxisMode:"span",xIsSeries:!0},lineOptions:{hideDots:1,regionFill:1},colors:[e().forum.attribute("themePrimaryColor"),"black"]}),this.chartEntity=this.selectedEntity,this.chartPeriod=this.selectedPeriod}},n.changeEntity=function(t){this.selectedEntity=t},n.changePeriod=function(t){this.selectedPeriod=t},n.getTotalCount=function(t){return this.lifetimeData[t]},n.getPeriodCount=function(t,e){var i=("custom"===this.selectedPeriod?this.customPeriodData:this.timedData)[t],n=0;for(var a in i){var r=parseInt(a);r>=e.start&&r<e.end&&(n+=i[r])}return n},n.getLastPeriod=function(t){return{start:t.start-(t.end-t.start),end:t.start}},i}(p()),Z=function(t){function e(){return t.apply(this,arguments)||this}return c(e,t),e.prototype.content=function(){return m("div",{className:"StatisticsPage"},m("div",{className:"container"},m(X,null)))},e}(M());e().initializers.add("flarum-statistics",(function(){(0,a.extend)(s().prototype,"availableWidgets",(function(t){t.add("statistics",m(k,null),20)})),e().extensionData.for("flarum-statistics").registerPage(Z)}))})(),module.exports=n})();
//# sourceMappingURL=admin.js.map