mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 22:43:43 +08:00
6b577e6f1f
Includes transpiled JS/TS, and Typescript declaration files (typings). [skip ci]
2 lines
83 KiB
JavaScript
Generated
2 lines
83 KiB
JavaScript
Generated
(()=>{var t={126:(t,e,i)=>{t.exports=i(750)},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 c(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 u(t,e){return(t+"").length*e}function h(t,e){return{x:Math.sin(t*wt)*e,y:Math.cos(t*wt)*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 p(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]=p(i);return e}function f(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=c(t,i):e=c(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=Lt(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 k(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function w(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)k(a).appendChild(i);else if("around"===n){var r=k(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 P(t,e){return w("linearGradient",{inside:t,id:e,x1:0,x2:0,y1:0,y2:1})}function A(t,e,i,n){return w("stop",{inside:t,style:"stop-color: "+i,offset:e,"stop-opacity":n})}function L(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),w("g",i)}function T(t){return w("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 O(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n="path-fill-gradient-"+e+"-"+(i?"lighter":"default"),a=P(t,n),r=[1,.6,.2];return i&&(r=[.4,.2,0]),A(a,"0%",e,r[0]),A(a,"50%",e,r[1]),A(a,"100%",e,r[2]),n}function N(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]})),w("rect",s)}function D(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},r=a.fontSize||Dt;return w("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 S(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};a.stroke||(a.stroke=St);var r=w("line",{className:"line-vertical "+a.className,x1:0,x2:0,y1:i,y2:n,styles:{stroke:a.stroke}}),s=w("text",{x:0,y:i>n?i+Ot:i-Ot-Dt,dy:Dt+"px","font-size":Dt+"px","text-anchor":"middle",innerHTML:e+""}),o=w("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=St),a.lineType||(a.lineType=""),a.shortenNumbers&&(e=g(e));var r=w("line",{className:"line-horizontal "+a.className+("dashed"===a.lineType?"dashed":""),x1:i,x2:n,y1:0,y2:0,styles:{stroke:a.stroke}}),s=w("text",{x:i<n?i-Ot:i+Ot,y:0,dy:Dt/2-2+"px","font-size":Dt+"px","text-anchor":i<n?"end":"start",innerHTML:e+""}),o=w("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 M(t,e,i,n){var a="string"==typeof e?e:e.join(", ");return[t,{transform:i.join(", ")},n,Ft,"translate",{transform:a}]}function E(t,e,i){return M(t,[0,i],[0,e],jt)}function _(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=f(i,(arguments.length>5&&void 0!==arguments[5]?arguments[5]:{}).zeroLine),s=ft(r,2),o=s[0],l=s[1];return l-=a,"rect"!==t.nodeName?[[t.childNodes[0],{width:n,height:o},_t,Ft],M(t,t.getAttribute("transform").split("(")[1].slice(0,-1),[e,l],jt)]:[[t,{width:n,height:o,x:e,y:l},_t,Ft]]}function W(t,e){return[t,{d:e},_t,Ft]}function j(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 c=void 0;c="transform"===l?document.createElementNS("http://www.w3.org/2000/svg","animateTransform"):document.createElementNS("http://www.w3.org/2000/svg","animate");var u=r[l]||t.getAttribute(l),h=e[l],d={attributeName:l,from:u,to:h,begin:"0s",dur:i/1e3+"s",values:u+";"+h,keySplines:Ht[n],keyTimes:"0;1",calcMode:"spline",fill:"freeze"};for(var p in a&&(d.type=a),d)c.setAttribute(p,d[p]);s.appendChild(c),a?o.setAttribute(l,"translate("+h+")"):o.setAttribute(l,h)}return[s,o]}function z(t,e){t.style.transform=e,t.style.webkitTransform=e,t.style.msTransform=e,t.style.mozTransform=e,t.style.oTransform=e}function F(t,e){var i=[],n=[];e.map((function(t){var e,a,r=t[0],s=r.parentNode;t[0]=r;var o=j.apply(void 0,vt(t)),l=ft(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 H(t,e,i){if(0!==i.length){var n=F(e,i);e.parentNode==t&&(t.removeChild(e),t.appendChild(n)),setTimeout((function(){n.parentNode==t&&(t.removeChild(n),t.appendChild(e))}),zt)}}function I(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:It});i.insertBefore(n,i.firstChild);var a=t.create("div");return a.appendChild(i),a.innerHTML}function R(t){var e=new Date(t);return e.setMinutes(e.getMinutes()-e.getTimezoneOffset()),e}function Y(t){var e=t.getDate(),i=t.getMonth()+1;return[t.getFullYear(),(i>9?"":"0")+i,(e>9?"":"0")+e].join("-")}function B(t){return new Date(t.getTime())}function G(t,e){var i=X(t);return Math.ceil(function(t,e){var i=Vt*Gt;return(R(e)-R(t))/i}(i,e)/Bt)}function V(t,e){return t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}function U(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=Ut[t];return e?i.slice(0,3):i}function q(t,e){return new Date(e,t+1,0)}function X(t){var e=B(t),i=e.getDay();return 0!==i&&J(e,-1*i),e}function J(t,e){t.setDate(t.getDate()+e)}function K(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 Xt(a)}function $(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 Q(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 Z(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=$(t),n=ft(i,2),a=n[0],r=n[1],s=e?e/Math.pow(10,r):0,o=Q(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=Z(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)$(n)[1],r=i?Z(n,a):Z(n);else if(n>0&&a<0){var s=Math.abs(a);n>=s?($(n)[1],r=e(n,s)):($(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);$(o)[1],r=(r=i?Z(o,l):Z(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):c(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},ct=(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")}),ut=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)},pt=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},ft=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"],kt={bar:xt,line:xt,pie:xt,percentage:xt,heatmap:["#ebedf0","#c6e48b","#7bc96f","#239a3b","#196127"],donut:xt},wt=Math.PI/180,Pt=function(){function e(t){var i=t.parent,n=void 0===i?null:i,a=t.colors,r=void 0===a?[]:a;ct(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 ut(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}(),At={"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"},Lt=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})):At[t]||t},Tt=6,Ot=4,Nt=15,Dt=10,St="#dadada",Ct="#555b51",Mt={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}},Et={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)}},_t=350,Wt=350,jt=_t,zt=250,Ft="easein",Ht={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"},It=".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}",Rt=function(){function e(t,i){if(ct(this,e),i=p(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 ut(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(kt[e])).forEach((function(t){var e=Lt(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 Pt({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 w("svg",{className:e,inside:t,width:i,height:n})}(this.container,"frappe-chart chart",this.baseWidth,this.baseHeight),this.svgDefs=function(t){return w("defs",{inside:t})}(this.svg),this.title.length&&(this.titleEL=D("title",t.margins.left,t.margins.top,this.title,{fontSize:t.titleFontSize,fill:"#666666",dy:t.titleFontSize}));var e=a(t);this.drawArea=L(this.type+"-chart chart-draw-area","translate("+r(t)+", "+e+")"),this.config.showLegend&&(e+=this.height+t.paddings.bottom,this.legendArea=L("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?(H(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=I(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}(),Yt=function(t){function e(t,i){return ct(this,e),pt(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,i))}return dt(e,t),ut(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 c=s*i+5,u=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,Nt):a;var r={className:"legend-dot",cx:0,cy:0,r:i,fill:n},s=w("text",{className:"legend-dataset-text",x:0,y:0,dx:Dt+"px",dy:Dt/3+"px","font-size":1.2*Dt+"px","text-anchor":"start",fill:Ct,innerHTML:a}),o=w("g",{transform:"translate("+t+", "+e+")"});return o.appendChild(w("circle",r)),o.appendChild(s),o}(c,n,5,t.colors[r],u+": "+h,!1);t.legendArea.appendChild(d),i++}))}}]),e}(Rt),Bt=7,Gt=1e3,Vt=86400,Ut=["January","February","March","April","May","June","July","August","September","October","November","December"],qt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Xt=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,c=e.animateElements;ct(this,t),this.layerTransform=r,this.constants=s,this.makeElements=l,this.getData=o,this.animateElements=c,this.store=[],this.labels=[],this.layerClass=n,this.layerClass="function"==typeof this.layerClass?this.layerClass():this.layerClass,this.refresh()}return ut(t,[{key:"refresh",value:function(t){this.data=t||this.getData()}},{key:"setup",value:function(t){this.layer=L(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=T(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 W(e,t.sliceStrings[i])}))}},pieSlices:{layerClass:"pie-slices",makeElements:function(t){return t.sliceStrings.map((function(e,i){var n=T(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 W(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 w("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=St),n.className||(n.className="");var a=-1*Tt,r="span"===n.mode?i+Tt:0;return"tick"===n.mode&&"right"===n.pos&&(a=i+Tt,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=ft(r,2);n=s[0],e=s[1];var o=v(a,i),l=ft(o,2);return a=l[0],i=l[1],this.render({positions:n,labels:i}),this.store.map((function(t,i){return E(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=St),n.className||(n.className="");var a=i+Tt,r="span"===n.mode?-1*Tt:i;return"tick"===n.mode&&"top"===n.pos&&(a=-1*Tt,r=0),S(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=ft(r,2);n=s[0],e=s[1];var o=v(a,i),l=ft(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 M(t,[i,0],[e,0],jt)}(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=w("text",{className:"chart-label",x:"left"===n.labelPos?Ot:i-u(e,5)-Ot,y:0,dy:Dt/-2+"px","font-size":Dt+"px","text-anchor":"start",innerHTML:e+""}),r=C(t,"",0,i,{stroke:n.stroke||St,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=ft(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 E(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=w("rect",{className:"bar mini",styles:{fill:"rgba(228, 234, 239, 0.49)",stroke:St,"stroke-dasharray":i+", "+r},x:0,y:0,width:i,height:r});a.labelPos||(a.labelPos="right");var o=w("text",{className:"chart-label",x:"left"===a.labelPos?Ot:i-u(n+"",4.5)-Ot,y:0,dy:Dt/-2+"px","font-size":Dt+"px","text-anchor":"start",innerHTML:n+""}),l=w("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=ft(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 c=[];return this.store.map((function(t,e){c=c.concat(function(t,e,i,n){var a=e-i,r=t.childNodes[0];return[[r,{height:a,"stroke-dasharray":r.getAttribute("width")+", "+a},jt,Ft],M(t,[0,n],[0,i],jt)]}(t,r[e],n[e],o[e]))})),c}},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,c=0;return this.serializedSubDomains=[],t.cols.map((function(t,i){1===i&&e.labels.push(D("domain-name",l,-12,U(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=N("day",l,c,s,o,t.fill,n);e.serializedSubDomains.push(a)}c+=r})),c=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=f(e,o.zeroLine),c=ft(l,2),u=c[0],h=c[1];h-=s,0===u&&(u=o.minHeight,h-=o.minHeight),d(t)||(t=0),d(h)||(h=0),d(u,!0)||(u=0),d(i,!0)||(i=0);var p=w("rect",{className:"bar mini",style:"fill: "+n,"data-point-index":r,x:t,y:h,width:i,height:u});if((a+="")||a.length){p.setAttribute("y",0),p.setAttribute("x",0);var v=w("text",{className:"data-point-value",x:i/2,y:0,dy:Dt/2*-1+"px","font-size":Dt+"px","text-anchor":"middle",innerHTML:a}),m=w("g",{"data-point-index":r,transform:"translate("+t+", "+h+")"});return m.appendChild(p),m.appendChild(v),m}return p}(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,c=v(r,e),u=ft(c,2);r=u[0],e=u[1];var h=v(s,i),d=ft(h,2);s=d[0],i=d[1];var p=v(o,n),f=ft(p,2);o=f[0],n=f[1];var m=v(l,a),g=ft(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(_(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=T("M"+r,"line-graph-path",i);if(n.heatline){var o=O(a.svgDefs,i);s.style.stroke="url(#"+o+")"}var l={path:s};if(n.regionFill){var c=O(a.svgDefs,i,!0),u="M"+t[0]+","+a.zeroLine+"L"+r+"L"+t.slice(-1)[0]+","+a.zeroLine;l.region=T(u,"region-fill","none","url(#"+c+")")}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=w("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=w("text",{className:"data-point-value",x:0,y:0,dy:Dt/2*-1-i+"px","font-size":Dt+"px","text-anchor":"middle",innerHTML:a}),l=w("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=ft(o,2);a=l[0],e=l[1];var c=v(r,i),u=ft(c,2);r=u[0],i=u[1];var h=v(s,n),d=ft(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 p=[];return Object.keys(this.paths).length&&(p=p.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},Wt,Ft];if(r.push(o),t.region){var l=e[0]+","+n+"L",c="L"+e.slice(-1)[0]+", "+n,u=[t.region,{d:"M"+l+s+c},Wt,Ft];r.push(u)}return r}(this.paths,e,i,t.zeroLine,this.constants.spline))),this.units.length&&this.units.map((function(t,n){p=p.concat(function(t,e,i){return"circle"!==t.nodeName?[M(t,t.getAttribute("transform").split("(")[1].slice(0,-1),[e,i],jt)]:[[t,{cx:e,cy:i},_t,Ft]]}(t,e[n],i[n]))})),p}}},Kt=function(t){function i(t,e){ct(this,i);var n=pt(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t,e));return n.type="percentage",n.setup(),n}return dt(i,t),ut(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=K.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),c=l.left-o.left+parseInt(r.getAttribute("width"))/2,u=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(c,u,{name:h,value:(100*d).toFixed(1)+"%"}),t.tip.showTip()}}))}}]),i}(Yt),$t=function(t){function i(t,e){ct(this,i);var n=pt(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),ut(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,c=i/e.grandTotal*360,u=c>180?1:0,d=a?-c:c,p=s+=d,f=h(l,n),v=h(p,n),m=t.init&&r[o],g=void 0,y=void 0;t.init?(g=m?m.startPosition:f,y=m?m.endPosition:f):(g=f,y=v);var b=360===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,c=2*i.y,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+" "+c+" z\n\t\tL"+s+" "+c+"\n\t\tA "+n+" "+n+" 0 "+r+" "+(a?1:0)+"\n\t\t"+l+" "+u+" z"}(g,y,t.center,t.radius,a,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,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+" "+c+" z"}(g,y,t.center,t.radius,a,u);e.sliceStrings.push(b),e.slicesProperties.push({startPosition:f,endPosition:v,value:i,total:e.grandTotal,startAngle:l,endAngle:p,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=K.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){z(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,c=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[i]:this.state.labels[i])+": ",u=(100*this.state.sliceTotals[i]/this.state.grandTotal).toFixed(1);this.tip.setValues(o,l,{name:c,value:u+"%"}),this.tip.showTip()}else z(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}(Yt),Qt=function(t){function e(t,i){ct(this,e);var n=pt(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),ut(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*Bt+s(e);var i=this.data,n=this.discreteDomains?12:0;this.independentWidth=12*(G(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*Gt);e[Y(n)]=t.dataPoints[i]})),t.dataPoints=e}return t}},{key:"calc",value:function(){var t=this.state;t.start=B(this.data.start),t.end=B(this.data.end),t.firstWeekStart=B(t.start),t.noOfWeeks=G(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=K.apply(void 0,vt(t));return[t[0]+"-"+e,i]})));var a=0;qt.forEach((function(e,i){if([1,3,5].includes(i)){var n=D("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=U(parseInt(s[1])-1,!0),l=t.container.getBoundingClientRect(),c=a.getBoundingClientRect(),u=parseInt(e.target.getAttribute("width")),h=c.left-l.left+u/2,d=c.top-l.top,p=r+" "+t.countLabel,f=" on "+o+" "+s[0]+", "+s[2];t.tip.setValues(h,d,{name:f,value:p,valueFirst:1},[]),t.tip.showTip()}}))}))}},{key:"renderLegend",value:function(){var t=this;this.legendArea.textContent="";var e=0,i=this.rawChartArgs.radius||0,n=D("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=N("heatmap-legend-unit",e+15*a,12,10,i,n);t.legendArea.appendChild(r)}));var a=D("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=B(t.start),l=0;l<r;l++){var c=t.end;if(!V(o,t.end)){var u=[o.getMonth(),o.getFullYear()];c=q(u[0],u[1])}s.push(this.getDomainConfig(o,c)),J(c,1),o=c}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=X(t),s={index:n,cols:[]};J(e=B(e)||q(n,a),1);for(var o=G(r,e),l=[],c=void 0,u=0;u<o;u++)c=this.getCol(r,n),l.push(c),J(r=new Date(c[Bt-1].yyyyMmDd),1);return void 0!==c[Bt-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=B(t),r=[],s=0;s<Bt;s++,J(a,1)){var o={},l=a>=n.start&&a<=n.end;i||a.getMonth()!==e||!l?o.yyyyMmDd=Y(a):o=this.getSubDomainConfig(a),r.push(o)}return r}},{key:"getSubDomainConfig",value:function(t){var e=Y(t),i=this.data.dataPoints[e];return{yyyyMmDd:e,dataValue:i||0,fill:this.colors[rt(i,this.state.distribution)]}}}]),e}(Rt),Zt=function(t){function i(t,e){ct(this,i);var n=pt(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),ut(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?"&":"<"==t?"<":">"})),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 c=new Array(t.datasetLength).fill("");this.config.valuesOverPoints&&(c=a&&e.index===t.datasets.length-1?e.cumulativeYs:e.values);var u=new Array(t.datasetLength).fill(0);return a&&(u=e.yPositions.map((function(t,i){return t-e.cumulativeYPos[i]}))),{xPositions:l,yPositions:e.yPositions,offsets:u,labels:c,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=K.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,Nt):a;var r={className:"legend-bar",x:0,y:0,width:i,height:"2px",fill:n},s=w("text",{className:"legend-dataset-text",x:0,y:0,dy:2*Dt+"px","font-size":1.2*Dt+"px","text-anchor":"start",fill:Ct,innerHTML:a}),o=w("g",{transform:"translate("+t+", "+e+")"});return o.appendChild(w("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=Mt[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];Et[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}(Rt),te=function(t){function i(t,e){ct(this,i);var n=pt(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),ut(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,c=i/e.grandTotal*360,u=c>180?1:0,d=a?-c:c,p=s+=d,f=h(l,n),v=h(p,n),m=t.init&&r[o],g=void 0,y=void 0;t.init?(g=m?m.startPosition:f,y=m?m.endPosition:f):(g=f,y=v);var b=360===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,c=2*n+o;return"M"+s+" "+o+"\n\t\tA "+n+" "+n+" 0 "+r+" "+(a?1:0)+"\n\t\t"+l+" "+c+"\n\t\tM"+s+" "+c+"\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,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;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,u);e.sliceStrings.push(b),e.slicesProperties.push({startPosition:f,endPosition:v,value:i,total:e.grandTotal,startAngle:l,endAngle:p,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=K.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){z(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,c=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[i]:this.state.labels[i])+": ",u=(100*this.state.sliceTotals[i]/this.state.grandTotal).toFixed(1);this.tip.setValues(o,l,{name:c,value:u+"%"}),this.tip.showTip()}else z(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}(Yt),ee={bar:Zt,line:Zt,percentage:Kt,heatmap:Qt,pie:$t,donut:te},ie=Object.freeze({Chart:function t(e,i){return ct(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 Zt(e,i)):ee[t]?new ee[t](e,i):void console.error("Undefined chart type: "+t)}(i.type,e,i)},PercentageChart:Kt,PieChart:$t,Heatmap:Qt,AxisChart:Zt});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 c(t,e,i,n){var a=e&&e.prototype instanceof m?e:m,r=Object.create(a.prototype),s=new N(n||[]);return r._invoke=function(t,e,i){var n=h;return function(a,r){if(n===p)throw new Error("Generator is already running");if(n===f){if("throw"===a)throw r;return S()}for(i.method=a,i.arg=r;;){var s=i.delegate;if(s){var o=L(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=f,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);n=p;var l=u(t,e,i);if("normal"===l.type){if(n=i.done?f:d,l.arg===v)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(n=f,i.method="throw",i.arg=l.arg)}}}(t,i,s),r}function u(t,e,i){try{return{type:"normal",arg:t.call(e,i)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var h="suspendedStart",d="suspendedYield",p="executing",f="completed",v={};function m(){}function g(){}function y(){}var b={};l(b,r,(function(){return this}));var x=Object.getPrototypeOf,k=x&&x(x(D([])));k&&k!==i&&n.call(k,r)&&(b=k);var w=y.prototype=m.prototype=Object.create(b);function P(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function A(t,e){function i(a,r,s,o){var l=u(t[a],t,r);if("throw"!==l.type){var c=l.arg,h=c.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){c.value=t,s(c)}),(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 L(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,L(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=u(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 T(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 O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function D(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:S}}function S(){return{value:e,done:!0}}return g.prototype=y,l(w,"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(w),t},t.awrap=function(t){return{__await:t}},P(A.prototype),l(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(e,i,n,a,r){void 0===r&&(r=Promise);var s=new A(c(e,i,n,a),r);return t.isGeneratorFunction(i)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},P(w),l(w,o,"Generator"),l(w,r,(function(){return this})),l(w,"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=D,N.prototype={constructor:N,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(O),!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"),c=n.call(s,"finallyLoc");if(l&&c){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(!c)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),O(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;O(i)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,i,n){return this.delegate={iterator:D(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 c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}function u(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,c(t,e)}var h=i(126),d=i.n(h);const p=flarum.core.compat["admin/components/DashboardWidget"];var f=i.n(p);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 k=i.n(x),w=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}u(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"}):k()(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}(f());const P=flarum.core.compat["admin/components/ExtensionPage"];var A=i.n(P);const L=flarum.core.compat["common/components/SelectDropdown"];var T=i.n(L);const O=flarum.core.compat["common/components/Button"];var N=i.n(O);const D=flarum.core.compat["common/helpers/icon"];var S=i.n(D),C=i(23),M=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.timedData=void 0,e.lifetimeData=void 0,e.loadingLifetime=!0,e.loadingTimed=!0,e.selectedEntity="users",e.selectedPeriod=void 0,e.chartEntity=void 0,e.chartPeriod=void 0,e}u(i,t);var n=i.prototype;return n.oncreate=function(e){t.prototype.oncreate.call(this,e),this.loadLifetimeData(),this.loadTimedData()},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(){var i,n,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.loadingTimed=!0,m.redraw(),t.next=4,e().request({method:"GET",url:e().forum.attribute("apiUrl")+"/statistics"});case 4:i=t.sent,this.timedData=i,this.loadingTimed=!1,(n=new Date).setTime(n.getTime()+1e3*this.timedData.timezoneOffset),n.setUTCHours(0,0,0,0),n.setTime(n.getTime()-1e3*this.timedData.timezoneOffset),a=n.getTime()/1e3,this.periods={today:{start:a,end:a+86400,step:3600},last_7_days:{start:a-604800,end:a,step:86400},previous_7_days:{start:a-1209600,end:a-604800,step:86400},last_28_days:{start:a-2419200,end:a,step:86400},previous_28_days:{start:a-4838400,end:a-2419200,step:86400},last_12_months:{start:a-31449600,end:a,step:604800}},this.selectedPeriod="last_7_days",m.redraw();case 15:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.className=function(){return"StatisticsWidget"},n.content=function(){var t=this,i=this.loadingTimed?null:this.periods[this.selectedPeriod];return 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"},this.loadingTimed?m(g(),{size:"small",display:"inline"}):m(T(),{disabled:this.loadingTimed,buttonClassName:"Button Button--text",caretIcon:"fas fa-caret-down"},Object.keys(this.periods).map((function(i){return m(N(),{key:i,active:i===t.selectedPeriod,onclick:t.changePeriod.bind(t,i),icon:i!==t.selectedPeriod||"fas fa-check"},e().translator.trans("flarum-statistics.admin.statistics."+i+"_label"))}))))),this.entities.map((function(n){var a=t.loadingLifetime?e().translator.trans("flarum-statistics.admin.statistics.loading"):t.getTotalCount(n),r=t.loadingTimed?e().translator.trans("flarum-statistics.admin.statistics.loading"):t.getPeriodCount(n,i),s=t.loadingTimed?e().translator.trans("flarum-statistics.admin.statistics.loading"):t.getPeriodCount(n,t.getLastPeriod(i)),o=t.loadingTimed||0===s?0:(r-s)/s*100;return m("button",{className:"Button--ua-reset StatisticsWidget-entity"+(t.selectedEntity===n?" active":""),onclick:t.changeEntity.bind(t,n)},m("h3",{className:"StatisticsWidget-heading"},e().translator.trans("flarum-statistics.admin.statistics."+n+"_heading")),m("div",{className:"StatisticsWidget-total",title:a},t.loadingLifetime?m(g(),{display:"inline"}):k()(a)),m("div",{className:"StatisticsWidget-period",title:r},t.loadingTimed?m(g(),{display:"inline"}):k()(r),0!==o&&m("[",null," ",m("span",{className:"StatisticsWidget-change StatisticsWidget-change--"+(o>0?"up":"down")},S()("fas fa-arrow-"+(o>0?"up":"down")),Math.abs(o).toFixed(1),"%"))))}))),this.loadingTimed?m("div",{className:"StatisticsWidget-chart"},m(g(),{size:"large"})):m("div",{className:"StatisticsWidget-chart",oncreate:this.drawChart.bind(this),onupdate:this.drawChart.bind(this)}))},n.drawChart=function(t){if(!this.chart||this.chartEntity!==this.selectedEntity||this.chartPeriod!==this.selectedPeriod){for(var i=this.timedData.timezoneOffset,n=this.periods[this.selectedPeriod],a=n.end-n.start,r=[],s=[],o=[],l=n.start;l<n.end;l+=n.step){var c=void 0;n.step<86400?c=dayjs.unix(l+i).format("h A"):(c=dayjs.unix(l+i).format("D MMM"),n.step>86400&&(c+=" - "+dayjs.unix(l+i+n.step-1).format("D MMM"))),r.push(c),s.push(this.getPeriodCount(this.selectedEntity,{start:l,end:l+n.step})),o.push(this.getPeriodCount(this.selectedEntity,{start:l-a,end:l-a+n.step}))}var u={labels:r,datasets:[{values:o},{values:s}]};this.chart?this.chart.update(u):this.chart=new C.Chart(t.dom,{data:u,type:"line",height:280,axisOptions:{xAxisMode:"tick",yAxisMode:"span",xIsSeries:!0},lineOptions:{hideDots:1},colors:["black",e().forum.attribute("themePrimaryColor")]}),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=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}(f()),E=function(t){function e(){return t.apply(this,arguments)||this}return u(e,t),e.prototype.content=function(){return m("div",{className:"StatisticsPage"},m("div",{className:"container"},m(M,null)))},e}(A());e().initializers.add("flarum-statistics",(function(){(0,a.extend)(s().prototype,"availableWidgets",(function(t){t.add("statistics",m(w,null),20)})),e().extensionData.for("flarum-statistics").registerPage(E)}))})(),module.exports=n})();
|
|
//# sourceMappingURL=admin.js.map
|