"use strict";var t=require("obsidian"); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function e(t,e,n,r){return new(n||(n=Promise))((function(a,i){function l(t){try{u(r.next(t))}catch(t){i(t)}}function o(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(l,o)}u((r=r.apply(t,e||[])).next())}))}function n(t,e){return te?1:t>=e?0:NaN}function r(t){let e=t,r=t;function a(t,e,n,a){for(null==n&&(n=0),null==a&&(a=t.length);n>>1;r(t[i],e)<0?n=i+1:a=i}return n}return 1===t.length&&(e=(e,n)=>t(e)-n,r=function(t){return(e,r)=>n(t(e),r)}(t)),{left:a,center:function(t,n,r,i){null==r&&(r=0),null==i&&(i=t.length);const l=a(t,n,r,i-1);return l>r&&e(t[l-1],n)>-e(t[l],n)?l-1:l},right:function(t,e,n,a){for(null==n&&(n=0),null==a&&(a=t.length);n>>1;r(t[i],e)>0?a=i:n=i+1}return n}}}const a=r(n).right;function i(t,e,n){return t(n={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&n.path)}},n.exports),n.exports}r((function(t){return null===t?NaN:+t})).center;var l=Math.sqrt(50),o=Math.sqrt(10),u=Math.sqrt(2);function s(t,e,n){var r=(e-t)/Math.max(0,n),a=Math.floor(Math.log(r)/Math.LN10),i=r/Math.pow(10,a);return a>=0?(i>=l?10:i>=o?5:i>=u?2:1)*Math.pow(10,a):-Math.pow(10,-a)/(i>=l?10:i>=o?5:i>=u?2:1)}function f(t,e,n){var r=Math.abs(e-t)/Math.max(0,n),a=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),i=r/a;return i>=l?a*=10:i>=o?a*=5:i>=u&&(a*=2),e=e)&&(n=e);else{let r=-1;for(let a of t)null!=(a=e(a,++r,t))&&(n=a)&&(n=a)}return n}function h(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n>e||void 0===n&&e>=e)&&(n=e);else{let r=-1;for(let a of t)null!=(a=e(a,++r,t))&&(n>a||void 0===n&&a>=a)&&(n=a)}return n}function d(t,e,r=0,a=t.length-1,i=n){for(;a>r;){if(a-r>600){const n=a-r+1,l=e-r+1,o=Math.log(n),u=.5*Math.exp(2*o/3),s=.5*Math.sqrt(o*u*(n-u)/n)*(l-n/2<0?-1:1);d(t,e,Math.max(r,Math.floor(e-l*u/n+s)),Math.min(a,Math.floor(e+(n-l)*u/n+s)),i)}const n=t[e];let l=r,o=a;for(g(t,r,e),i(t[a],n)>0&&g(t,r,a);l0;)--o}0===i(t[r],n)?g(t,r,o):(++o,g(t,o,a)),o<=e&&(r=o+1),e<=o&&(a=o-1)}return t}function g(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function p(t,e,n){if(r=(t=Float64Array.from(function*(t,e){if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(yield e);else{let n=-1;for(let r of t)null!=(r=e(r,++n,t))&&(r=+r)>=r&&(yield r)}}(t,n))).length){if((e=+e)<=0||r<2)return h(t);if(e>=1)return c(t);var r,a=(r-1)*e,i=Math.floor(a),l=c(d(t,i).subarray(0,i+1));return l+(h(t.subarray(i+1))-l)*(a-i)}}function y(t,e,n){t=+t,e=+e,n=(a=arguments.length)<2?(e=t,t=0,1):a<3?1:+n;for(var r=-1,a=0|Math.max(0,Math.ceil((e-t)/n)),i=new Array(a);++r+t(e)}function D(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function k(){return!this.__axis}function M(t,e){var n=[],r=null,a=null,i=6,l=6,o=3,u="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,s=1===t||4===t?-1:1,f=4===t||2===t?"x":"y",c=1===t||3===t?x:A;function h(h){var d=null==r?e.ticks?e.ticks.apply(e,n):e.domain():r,g=null==a?e.tickFormat?e.tickFormat.apply(e,n):w:a,p=Math.max(i,0)+o,y=e.range(),m=+y[0]+u,v=+y[y.length-1]+u,x=(e.bandwidth?D:b)(e.copy(),u),A=h.selection?h.selection():h,M=A.selectAll(".domain").data([null]),T=A.selectAll(".tick").data(d,e).order(),C=T.exit(),F=T.enter().append("g").attr("class","tick"),_=T.select("line"),S=T.select("text");M=M.merge(M.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),T=T.merge(F),_=_.merge(F.append("line").attr("stroke","currentColor").attr(f+"2",s*i)),S=S.merge(F.append("text").attr("fill","currentColor").attr(f,s*p).attr("dy",1===t?"0em":3===t?"0.71em":"0.32em")),h!==A&&(M=M.transition(h),T=T.transition(h),_=_.transition(h),S=S.transition(h),C=C.transition(h).attr("opacity",1e-6).attr("transform",(function(t){return isFinite(t=x(t))?c(t+u):this.getAttribute("transform")})),F.attr("opacity",1e-6).attr("transform",(function(t){var e=this.parentNode.__axis;return c((e&&isFinite(e=e(t))?e:x(t))+u)}))),C.remove(),M.attr("d",4===t||2===t?l?"M"+s*l+","+m+"H"+u+"V"+v+"H"+s*l:"M"+u+","+m+"V"+v:l?"M"+m+","+s*l+"V"+u+"H"+v+"V"+s*l:"M"+m+","+u+"H"+v),T.attr("opacity",1).attr("transform",(function(t){return c(x(t)+u)})),_.attr(f+"2",s*i),S.attr(f,s*p).text(g),A.filter(k).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===t?"start":4===t?"end":"middle"),A.each((function(){this.__axis=x}))}return h.scale=function(t){return arguments.length?(e=t,h):e},h.ticks=function(){return n=v.call(arguments),h},h.tickArguments=function(t){return arguments.length?(n=null==t?[]:v.call(t),h):n.slice()},h.tickValues=function(t){return arguments.length?(r=null==t?null:v.call(t),h):r&&r.slice()},h.tickFormat=function(t){return arguments.length?(a=t,h):a},h.tickSize=function(t){return arguments.length?(i=l=+t,h):i},h.tickSizeInner=function(t){return arguments.length?(i=+t,h):i},h.tickSizeOuter=function(t){return arguments.length?(l=+t,h):l},h.tickPadding=function(t){return arguments.length?(o=+t,h):o},h.offset=function(t){return arguments.length?(u=+t,h):u},h}function T(t){return M(3,t)}function C(t){return M(4,t)}var F={value:()=>{}};function _(){for(var t,e=0,n=arguments.length,r={};e=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))}function B(t,e){for(var n,r=0,a=t.length;r0)for(var n,r,a=new Array(n),i=0;i=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),V.hasOwnProperty(e)?{space:V[e],local:t}:t}function Y(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===L&&e.documentElement.namespaceURI===L?e.createElement(t):e.createElementNS(n,t)}}function P(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function z(t){var e=I(t);return(e.local?P:Y)(e)}function O(){}function U(t){return null==t?O:function(){return this.querySelector(t)}}function R(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function W(){return[]}function $(t){return null==t?W:function(){return this.querySelectorAll(t)}}function H(t){return function(){return this.matches(t)}}function X(t){return function(e){return e.matches(t)}}var j=Array.prototype.find;function q(){return this.firstElementChild}var G=Array.prototype.filter;function Q(){return this.children}function Z(t){return new Array(t.length)}function J(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function K(t){return function(){return t}}function tt(t,e,n,r,a,i){for(var l,o=0,u=e.length,s=i.length;oe?1:t>=e?0:NaN}function at(t){return function(){this.removeAttribute(t)}}function it(t){return function(){this.removeAttributeNS(t.space,t.local)}}function lt(t,e){return function(){this.setAttribute(t,e)}}function ot(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function ut(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function st(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function ft(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function ct(t){return function(){this.style.removeProperty(t)}}function ht(t,e,n){return function(){this.style.setProperty(t,e,n)}}function dt(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function gt(t,e){return t.style.getPropertyValue(e)||ft(t).getComputedStyle(t,null).getPropertyValue(e)}function pt(t){return function(){delete this[t]}}function yt(t,e){return function(){this[t]=e}}function mt(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function vt(t){return t.trim().split(/^|\s+/)}function wt(t){return t.classList||new xt(t)}function xt(t){this._node=t,this._names=vt(t.getAttribute("class")||"")}function At(t,e){for(var n=wt(t),r=-1,a=e.length;++r=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function zt(t){return function(){var e=this.__on;if(e){for(var n,r=0,a=-1,i=e.length;r=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var $t=[null];function Ht(t,e){this._groups=t,this._parents=e}function Xt(){return new Ht([[document.documentElement]],$t)}function jt(t){return"string"==typeof t?new Ht([[document.querySelector(t)]],[document.documentElement]):new Ht([[t]],$t)}function qt(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Gt(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Qt(){}Ht.prototype=Xt.prototype={constructor:Ht,select:function(t){"function"!=typeof t&&(t=U(t));for(var e=this._groups,n=e.length,r=new Array(n),a=0;a=A&&(A=x+1);!(w=y[A])&&++A=0;)(r=a[i])&&(l&&4^r.compareDocumentPosition(l)&&l.parentNode.insertBefore(r,l),l=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=rt);for(var n=this._groups,r=n.length,a=new Array(r),i=0;i1?this.each((null==e?ct:"function"==typeof e?dt:ht)(t,e,null==n?"":n)):gt(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?pt:"function"==typeof e?mt:yt)(t,e)):this.node()[t]},classed:function(t,e){var n=vt(t+"");if(arguments.length<2){for(var r=wt(this.node()),a=-1,i=n.length;++a>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?de(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?de(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=ne.exec(t))?new ye(e[1],e[2],e[3],1):(e=re.exec(t))?new ye(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=ae.exec(t))?de(e[1],e[2],e[3],e[4]):(e=ie.exec(t))?de(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=le.exec(t))?xe(e[1],e[2]/100,e[3]/100,1):(e=oe.exec(t))?xe(e[1],e[2]/100,e[3]/100,e[4]):ue.hasOwnProperty(t)?he(ue[t]):"transparent"===t?new ye(NaN,NaN,NaN,0):null}function he(t){return new ye(t>>16&255,t>>8&255,255&t,1)}function de(t,e,n,r){return r<=0&&(t=e=n=NaN),new ye(t,e,n,r)}function ge(t){return t instanceof Qt||(t=ce(t)),t?new ye((t=t.rgb()).r,t.g,t.b,t.opacity):new ye}function pe(t,e,n,r){return 1===arguments.length?ge(t):new ye(t,e,n,null==r?1:r)}function ye(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function me(){return"#"+we(this.r)+we(this.g)+we(this.b)}function ve(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function we(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function xe(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new be(t,e,n,r)}function Ae(t){if(t instanceof be)return new be(t.h,t.s,t.l,t.opacity);if(t instanceof Qt||(t=ce(t)),!t)return new be;if(t instanceof be)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,a=Math.min(e,n,r),i=Math.max(e,n,r),l=NaN,o=i-a,u=(i+a)/2;return o?(l=e===i?(n-r)/o+6*(n0&&u<1?0:l,new be(l,o,u,t.opacity)}function be(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function De(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}qt(Qt,ce,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:se,formatHex:se,formatHsl:function(){return Ae(this).formatHsl()},formatRgb:fe,toString:fe}),qt(ye,pe,Gt(Qt,{brighter:function(t){return t=null==t?Zt:Math.pow(Zt,t),new ye(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new ye(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:me,formatHex:me,formatRgb:ve,toString:ve})),qt(be,(function(t,e,n,r){return 1===arguments.length?Ae(t):new be(t,e,n,null==r?1:r)}),Gt(Qt,{brighter:function(t){return t=null==t?Zt:Math.pow(Zt,t),new be(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new be(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,a=2*n-r;return new ye(De(t>=240?t-240:t+120,a,r),De(t,a,r),De(t<120?t+240:t-120,a,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));const ke=Math.PI/180,Me=180/Math.PI,Te=4/29,Ce=6/29,Fe=3*Ce*Ce;function _e(t){if(t instanceof Ee)return new Ee(t.l,t.a,t.b,t.opacity);if(t instanceof Ye)return Pe(t);t instanceof ye||(t=ge(t));var e,n,r=Ve(t.r),a=Ve(t.g),i=Ve(t.b),l=Be((.2225045*r+.7168786*a+.0606169*i)/1);return r===a&&a===i?e=n=l:(e=Be((.4360747*r+.3850649*a+.1430804*i)/.96422),n=Be((.0139322*r+.0971045*a+.7141733*i)/.82521)),new Ee(116*l-16,500*(e-l),200*(l-n),t.opacity)}function Se(t,e,n,r){return 1===arguments.length?_e(t):new Ee(t,e,n,null==r?1:r)}function Ee(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}function Be(t){return t>.008856451679035631?Math.pow(t,1/3):t/Fe+Te}function Ne(t){return t>Ce?t*t*t:Fe*(t-Te)}function Le(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Ve(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Ie(t){if(t instanceof Ye)return new Ye(t.h,t.c,t.l,t.opacity);if(t instanceof Ee||(t=_e(t)),0===t.a&&0===t.b)return new Ye(NaN,0=0&&e._call.call(null,t),e=e._next;--Ue}()}finally{Ue=0,function(){var t,e,n=ze,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:ze=e);Oe=t,en(r)}(),He=0}}function tn(){var t=je.now(),e=t-$e;e>1e3&&(Xe-=e,$e=t)}function en(t){Ue||(Re&&(Re=clearTimeout(Re)),t-He>24?(t<1/0&&(Re=setTimeout(Ke,t-je.now()-Xe)),We&&(We=clearInterval(We))):(We||($e=je.now(),We=setInterval(tn,1e3)),Ue=1,qe(Ke)))}function nn(t,e,n){var r=new Ze;return e=null==e?0:+e,r.restart((n=>{r.stop(),t(n+e)}),e,n),r}Ze.prototype=Je.prototype={constructor:Ze,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?Ge():+n)+(null==e?0:+e),this._next||Oe===this||(Oe?Oe._next=this:ze=this,Oe=this),this._call=t,this._time=n,en()},stop:function(){this._call&&(this._call=null,this._time=1/0,en())}};var rn=_("start","end","cancel","interrupt"),an=[];function ln(t,e,n,r,a,i){var l=t.__transition;if(l){if(n in l)return}else t.__transition={};!function(t,e,n){var r,a=t.__transition;function i(t){n.state=1,n.timer.restart(l,n.delay,n.time),n.delay<=t&&l(t-n.delay)}function l(i){var s,f,c,h;if(1!==n.state)return u();for(s in a)if((h=a[s]).name===n.name){if(3===h.state)return nn(l);4===h.state?(h.state=6,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete a[s]):+s0)throw new Error("too late; already scheduled");return n}function un(t,e){var n=sn(t,e);if(n.state>3)throw new Error("too late; already running");return n}function sn(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}var fn=t=>()=>t;function cn(t){return 1==(t=+t)?hn:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):fn(isNaN(e)?n:e)}}function hn(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):fn(isNaN(t)?e:t)}var dn=function t(e){var n=cn(e);function r(t,e){var r=n((t=pe(t)).r,(e=pe(e)).r),a=n(t.g,e.g),i=n(t.b,e.b),l=hn(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=a(e),t.b=i(e),t.opacity=l(e),t+""}}return r.gamma=t,r}(1);function gn(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var pn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,yn=new RegExp(pn.source,"g");function mn(t,e){var n,r,a,i=pn.lastIndex=yn.lastIndex=0,l=-1,o=[],u=[];for(t+="",e+="";(n=pn.exec(t))&&(r=yn.exec(e));)(a=r.index)>i&&(a=e.slice(i,a),o[l]?o[l]+=a:o[++l]=a),(n=n[0])===(r=r[0])?o[l]?o[l]+=r:o[++l]=r:(o[++l]=null,u.push({i:l,x:gn(n,r)})),i=yn.lastIndex;return i180?e+=360:e-t>180&&(t+=360),i.push({i:n.push(a(n)+"rotate(",null,r)-2,x:gn(t,e)})):e&&n.push(a(n)+"rotate("+e+r)}(i.rotate,l.rotate,o,u),function(t,e,n,i){t!==e?i.push({i:n.push(a(n)+"skewX(",null,r)-2,x:gn(t,e)}):e&&n.push(a(n)+"skewX("+e+r)}(i.skewX,l.skewX,o,u),function(t,e,n,r,i,l){if(t!==n||e!==r){var o=i.push(a(i)+"scale(",null,",",null,")");l.push({i:o-4,x:gn(t,n)},{i:o-2,x:gn(e,r)})}else 1===n&&1===r||i.push(a(i)+"scale("+n+","+r+")")}(i.scaleX,i.scaleY,l.scaleX,l.scaleY,o,u),i=l=null,function(t){for(var e,n=-1,r=u.length;++n=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?on:un;return function(){var l=i(this,t),o=l.on;o!==r&&(a=(r=o).copy()).on(e,n),l.on=a}}var Hn=Xt.prototype.constructor;function Xn(t){return function(){this.style.removeProperty(t)}}function jn(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function qn(t,e,n){var r,a;function i(){var i=e.apply(this,arguments);return i!==a&&(r=(a=i)&&jn(t,i,n)),r}return i._value=e,i}function Gn(t){return function(e){this.textContent=t.call(this,e)}}function Qn(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&Gn(r)),e}return r._value=t,r}var Zn=0;function Jn(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Kn(){return++Zn}var tr=Xt.prototype;Jn.prototype={constructor:Jn,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=U(t));for(var r=this._groups,a=r.length,i=new Array(a),l=0;l2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete i[a]):l=!1;l&&delete t.__transition}}(this,t)}))},Xt.prototype.transition=function(t){var e,n;t instanceof Jn?(e=t._id,t=t._name):(e=Kn(),(n=er).time=Ge(),t=null==t?null:t+"");for(var r=this._groups,a=r.length,i=0;i1?r[0]+r.slice(2):r,+t.slice(n+1)]}function sr(t){return(t=ur(Math.abs(t)))?t[1]:NaN}lr.prototype=or.prototype={constructor:lr,moveTo:function(t,e){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)},closePath:function(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(t,e){this._+="L"+(this._x1=+t)+","+(this._y1=+e)},quadraticCurveTo:function(t,e,n,r){this._+="Q"+ +t+","+ +e+","+(this._x1=+n)+","+(this._y1=+r)},bezierCurveTo:function(t,e,n,r,a,i){this._+="C"+ +t+","+ +e+","+ +n+","+ +r+","+(this._x1=+a)+","+(this._y1=+i)},arcTo:function(t,e,n,r,a){t=+t,e=+e,n=+n,r=+r,a=+a;var i=this._x1,l=this._y1,o=n-t,u=r-e,s=i-t,f=l-e,c=s*s+f*f;if(a<0)throw new Error("negative radius: "+a);if(null===this._x1)this._+="M"+(this._x1=t)+","+(this._y1=e);else if(c>1e-6)if(Math.abs(f*o-u*s)>1e-6&&a){var h=n-i,d=r-l,g=o*o+u*u,p=h*h+d*d,y=Math.sqrt(g),m=Math.sqrt(c),v=a*Math.tan((rr-Math.acos((g+c-p)/(2*y*m)))/2),w=v/m,x=v/y;Math.abs(w-1)>1e-6&&(this._+="L"+(t+w*s)+","+(e+w*f)),this._+="A"+a+","+a+",0,0,"+ +(f*h>s*d)+","+(this._x1=t+x*o)+","+(this._y1=e+x*u)}else this._+="L"+(this._x1=t)+","+(this._y1=e);else;},arc:function(t,e,n,r,a,i){t=+t,e=+e,i=!!i;var l=(n=+n)*Math.cos(r),o=n*Math.sin(r),u=t+l,s=e+o,f=1^i,c=i?r-a:a-r;if(n<0)throw new Error("negative radius: "+n);null===this._x1?this._+="M"+u+","+s:(Math.abs(this._x1-u)>1e-6||Math.abs(this._y1-s)>1e-6)&&(this._+="L"+u+","+s),n&&(c<0&&(c=c%ar+ar),c>ir?this._+="A"+n+","+n+",0,1,"+f+","+(t-l)+","+(e-o)+"A"+n+","+n+",0,1,"+f+","+(this._x1=u)+","+(this._y1=s):c>1e-6&&(this._+="A"+n+","+n+",0,"+ +(c>=rr)+","+f+","+(this._x1=t+n*Math.cos(a))+","+(this._y1=e+n*Math.sin(a))))},rect:function(t,e,n,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},toString:function(){return this._}};var fr,cr=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function hr(t){if(!(e=cr.exec(t)))throw new Error("invalid format: "+t);var e;return new dr({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function dr(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function gr(t,e){var n=ur(t,e);if(!n)return t+"";var r=n[0],a=n[1];return a<0?"0."+new Array(-a).join("0")+r:r.length>a+1?r.slice(0,a+1)+"."+r.slice(a+1):r+new Array(a-r.length+2).join("0")}hr.prototype=dr.prototype,dr.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var pr={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>gr(100*t,e),r:gr,s:function(t,e){var n=ur(t,e);if(!n)return t+"";var r=n[0],a=n[1],i=a-(fr=3*Math.max(-8,Math.min(8,Math.floor(a/3))))+1,l=r.length;return i===l?r:i>l?r+new Array(i-l+1).join("0"):i>0?r.slice(0,i)+"."+r.slice(i):"0."+new Array(1-i).join("0")+ur(t,Math.max(0,e+i-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function yr(t){return t}var mr,vr,wr,xr=Array.prototype.map,Ar=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function br(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?yr:(e=xr.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var a=t.length,i=[],l=0,o=e[0],u=0;a>0&&o>0&&(u+o+1>r&&(o=Math.max(1,r-u)),i.push(t.substring(a-=o,a+o)),!((u+=o+1)>r));)o=e[l=(l+1)%e.length];return i.reverse().join(n)}),a=void 0===t.currency?"":t.currency[0]+"",i=void 0===t.currency?"":t.currency[1]+"",l=void 0===t.decimal?".":t.decimal+"",o=void 0===t.numerals?yr:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(xr.call(t.numerals,String)),u=void 0===t.percent?"%":t.percent+"",s=void 0===t.minus?"−":t.minus+"",f=void 0===t.nan?"NaN":t.nan+"";function c(t){var e=(t=hr(t)).fill,n=t.align,c=t.sign,h=t.symbol,d=t.zero,g=t.width,p=t.comma,y=t.precision,m=t.trim,v=t.type;"n"===v?(p=!0,v="g"):pr[v]||(void 0===y&&(y=12),m=!0,v="g"),(d||"0"===e&&"="===n)&&(d=!0,e="0",n="=");var w="$"===h?a:"#"===h&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",x="$"===h?i:/[%p]/.test(v)?u:"",A=pr[v],b=/[defgprs%]/.test(v);function D(t){var a,i,u,h=w,D=x;if("c"===v)D=A(t)+D,t="";else{var k=(t=+t)<0||1/t<0;if(t=isNaN(t)?f:A(Math.abs(t),y),m&&(t=function(t){t:for(var e,n=t.length,r=1,a=-1;r0&&(a=0)}return a>0?t.slice(0,a)+t.slice(e+1):t}(t)),k&&0==+t&&"+"!==c&&(k=!1),h=(k?"("===c?c:s:"-"===c||"("===c?"":c)+h,D=("s"===v?Ar[8+fr/3]:"")+D+(k&&"("===c?")":""),b)for(a=-1,i=t.length;++a(u=t.charCodeAt(a))||u>57){D=(46===u?l+t.slice(a+1):t.slice(a))+D,t=t.slice(0,a);break}}p&&!d&&(t=r(t,1/0));var M=h.length+t.length+D.length,T=M>1)+h+t+D+T.slice(M);break;default:t=T+h+t+D}return o(t)}return y=void 0===y?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y)),D.toString=function(){return t+""},D}return{format:c,formatPrefix:function(t,e){var n=c(((t=hr(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(sr(e)/3))),a=Math.pow(10,-r),i=Ar[8+r/3];return function(t){return n(a*t)+i}}}}mr=br({thousands:",",grouping:[3],currency:["$",""]}),vr=mr.format,wr=mr.formatPrefix;function Dr(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):(t=>()=>t)(isNaN(t)?e:t)}function kr(t,e){var n=Dr((t=Se(t)).l,(e=Se(e)).l),r=Dr(t.a,e.a),a=Dr(t.b,e.b),i=Dr(t.opacity,e.opacity);return function(e){return t.l=n(e),t.a=r(e),t.b=a(e),t.opacity=i(e),t+""}}function Mr(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}const Tr=Symbol("implicit");function Cr(){var t=new Map,e=[],n=[],r=Tr;function a(a){var i=a+"",l=t.get(i);if(!l){if(r!==Tr)return r;t.set(i,l=e.push(a))}return n[(l-1)%n.length]}return a.domain=function(n){if(!arguments.length)return e.slice();e=[],t=new Map;for(const r of n){const n=r+"";t.has(n)||t.set(n,e.push(r))}return a},a.range=function(t){return arguments.length?(n=Array.from(t),a):n.slice()},a.unknown=function(t){return arguments.length?(r=t,a):r},a.copy=function(){return Cr(e,n).unknown(r)},Mr.apply(a,arguments),a}var Fr=t=>()=>t;function _r(t){return 1==(t=+t)?Sr:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):Fr(isNaN(e)?n:e)}}function Sr(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):Fr(isNaN(t)?e:t)}var Er=function t(e){var n=_r(e);function r(t,e){var r=n((t=pe(t)).r,(e=pe(e)).r),a=n(t.g,e.g),i=n(t.b,e.b),l=Sr(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=a(e),t.b=i(e),t.opacity=l(e),t+""}}return r.gamma=t,r}(1);function Br(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,a=e.slice();return function(i){for(n=0;ni&&(a=e.slice(i,a),o[l]?o[l]+=a:o[++l]=a),(n=n[0])===(r=r[0])?o[l]?o[l]+=r:o[++l]=r:(o[++l]=null,u.push({i:l,x:Vr(n,r)})),i=Pr.lastIndex;return ie&&(n=t,t=e,e=n),s=function(n){return Math.max(t,Math.min(e,n))}),r=u>2?jr:Xr,a=i=null,c}function c(e){return null==e||isNaN(e=+e)?n:(a||(a=r(l.map(t),o,u)))(t(s(e)))}return c.invert=function(n){return s(e((i||(i=r(o,l.map(t),Vr)))(n)))},c.domain=function(t){return arguments.length?(l=Array.from(t,Rr),f()):l.slice()},c.range=function(t){return arguments.length?(o=Array.from(t),f()):o.slice()},c.rangeRound=function(t){return o=Array.from(t),u=Ur,f()},c.clamp=function(t){return arguments.length?(s=!!t||$r,f()):s!==$r},c.interpolate=function(t){return arguments.length?(u=t,f()):u},c.unknown=function(t){return arguments.length?(n=t,c):n},function(n,r){return t=n,e=r,f()}}function Qr(){return Gr()($r,$r)}function Zr(t,e,n,r){var a,i=f(t,e,n);switch((r=hr(null==r?",f":r)).type){case"s":var l=Math.max(Math.abs(t),Math.abs(e));return null!=r.precision||isNaN(a=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(sr(e)/3)))-sr(Math.abs(t)))}(i,l))||(r.precision=a),wr(r,l);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(a=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,sr(e)-sr(t))+1}(i,Math.max(Math.abs(t),Math.abs(e))))||(r.precision=a-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(a=function(t){return Math.max(0,-sr(Math.abs(t)))}(i))||(r.precision=a-2*("%"===r.type))}return vr(r)}function Jr(t){var e=t.domain;return t.ticks=function(t){var n=e();return function(t,e,n){var r,a,i,l,o=-1;if(n=+n,(t=+t)==(e=+e)&&n>0)return[t];if((r=e0){let n=Math.round(t/l),r=Math.round(e/l);for(n*le&&--r,i=new Array(a=r-n+1);++oe&&--r,i=new Array(a=r-n+1);++o0;){if((a=s(u,f,n))===r)return i[l]=u,i[o]=f,e(i);if(a>0)u=Math.floor(u/a)*a,f=Math.ceil(f/a)*a;else{if(!(a<0))break;u=Math.ceil(u*a)/a,f=Math.floor(f*a)/a}r=a}return t},t}function Kr(){var t=Qr();return t.copy=function(){return qr(t,Kr())},Mr.apply(t,arguments),Jr(t)}var ta=new Date,ea=new Date;function na(t,e,n,r){function a(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return a.floor=function(e){return t(e=new Date(+e)),e},a.ceil=function(n){return t(n=new Date(n-1)),e(n,1),t(n),n},a.round=function(t){var e=a(t),n=a.ceil(t);return t-e0))return o;do{o.push(l=new Date(+n)),e(n,i),t(n)}while(l=e)for(;t(e),!n(e);)e.setTime(e-1)}),(function(t,r){if(t>=t)if(r<0)for(;++r<=0;)for(;e(t,-1),!n(t););else for(;--r>=0;)for(;e(t,1),!n(t););}))},n&&(a.count=function(e,r){return ta.setTime(+e),ea.setTime(+r),t(ta),t(ea),Math.floor(n(ta,ea))},a.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?a.filter(r?function(e){return r(e)%t==0}:function(e){return a.count(0,e)%t==0}):a:null}),a}var ra=na((function(){}),(function(t,e){t.setTime(+t+e)}),(function(t,e){return e-t}));ra.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?na((function(e){e.setTime(Math.floor(e/t)*t)}),(function(e,n){e.setTime(+e+n*t)}),(function(e,n){return(n-e)/t})):ra:null};var aa=na((function(t){t.setTime(t-t.getMilliseconds())}),(function(t,e){t.setTime(+t+1e3*e)}),(function(t,e){return(e-t)/1e3}),(function(t){return t.getUTCSeconds()})),ia=na((function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds())}),(function(t,e){t.setTime(+t+6e4*e)}),(function(t,e){return(e-t)/6e4}),(function(t){return t.getMinutes()})),la=na((function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds()-6e4*t.getMinutes())}),(function(t,e){t.setTime(+t+36e5*e)}),(function(t,e){return(e-t)/36e5}),(function(t){return t.getHours()})),oa=na((t=>t.setHours(0,0,0,0)),((t,e)=>t.setDate(t.getDate()+e)),((t,e)=>(e-t-6e4*(e.getTimezoneOffset()-t.getTimezoneOffset()))/864e5),(t=>t.getDate()-1));function ua(t){return na((function(e){e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)}),(function(t,e){t.setDate(t.getDate()+7*e)}),(function(t,e){return(e-t-6e4*(e.getTimezoneOffset()-t.getTimezoneOffset()))/6048e5}))}var sa=ua(0),fa=ua(1);ua(2),ua(3);var ca=ua(4);ua(5),ua(6);var ha=na((function(t){t.setDate(1),t.setHours(0,0,0,0)}),(function(t,e){t.setMonth(t.getMonth()+e)}),(function(t,e){return e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear())}),(function(t){return t.getMonth()})),da=na((function(t){t.setMonth(0,1),t.setHours(0,0,0,0)}),(function(t,e){t.setFullYear(t.getFullYear()+e)}),(function(t,e){return e.getFullYear()-t.getFullYear()}),(function(t){return t.getFullYear()}));da.every=function(t){return isFinite(t=Math.floor(t))&&t>0?na((function(e){e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)}),(function(e,n){e.setFullYear(e.getFullYear()+n*t)})):null},na((function(t){t.setUTCSeconds(0,0)}),(function(t,e){t.setTime(+t+6e4*e)}),(function(t,e){return(e-t)/6e4}),(function(t){return t.getUTCMinutes()})),na((function(t){t.setUTCMinutes(0,0,0)}),(function(t,e){t.setTime(+t+36e5*e)}),(function(t,e){return(e-t)/36e5}),(function(t){return t.getUTCHours()}));var ga=na((function(t){t.setUTCHours(0,0,0,0)}),(function(t,e){t.setUTCDate(t.getUTCDate()+e)}),(function(t,e){return(e-t)/864e5}),(function(t){return t.getUTCDate()-1}));function pa(t){return na((function(e){e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)}),(function(t,e){t.setUTCDate(t.getUTCDate()+7*e)}),(function(t,e){return(e-t)/6048e5}))}var ya=pa(0),ma=pa(1);pa(2),pa(3);var va=pa(4);pa(5),pa(6),na((function(t){t.setUTCDate(1),t.setUTCHours(0,0,0,0)}),(function(t,e){t.setUTCMonth(t.getUTCMonth()+e)}),(function(t,e){return e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear())}),(function(t){return t.getUTCMonth()}));var wa=na((function(t){t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),(function(t,e){t.setUTCFullYear(t.getUTCFullYear()+e)}),(function(t,e){return e.getUTCFullYear()-t.getUTCFullYear()}),(function(t){return t.getUTCFullYear()}));wa.every=function(t){return isFinite(t=Math.floor(t))&&t>0?na((function(e){e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),(function(e,n){e.setUTCFullYear(e.getUTCFullYear()+n*t)})):null};const[xa,Aa]=function(t,e,n,a,i,l){const o=[[aa,1,1e3],[aa,5,5e3],[aa,15,15e3],[aa,30,3e4],[l,1,6e4],[l,5,3e5],[l,15,9e5],[l,30,18e5],[i,1,36e5],[i,3,108e5],[i,6,216e5],[i,12,432e5],[a,1,864e5],[a,2,1728e5],[n,1,6048e5],[e,1,2592e6],[e,3,7776e6],[t,1,31536e6]];function u(e,n,a){const i=Math.abs(n-e)/a,l=r((([,,t])=>t)).right(o,i);if(l===o.length)return t.every(f(e/31536e6,n/31536e6,a));if(0===l)return ra.every(Math.max(f(e,n,a),1));const[u,s]=o[i/o[l-1][2][t.toLowerCase(),e])))}function Va(t,e,n){var r=Fa.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Ia(t,e,n){var r=Fa.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Ya(t,e,n){var r=Fa.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Pa(t,e,n){var r=Fa.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function za(t,e,n){var r=Fa.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function Oa(t,e,n){var r=Fa.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Ua(t,e,n){var r=Fa.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Ra(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function Wa(t,e,n){var r=Fa.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function $a(t,e,n){var r=Fa.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Ha(t,e,n){var r=Fa.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Xa(t,e,n){var r=Fa.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function ja(t,e,n){var r=Fa.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function qa(t,e,n){var r=Fa.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Ga(t,e,n){var r=Fa.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Qa(t,e,n){var r=Fa.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Za(t,e,n){var r=Fa.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Ja(t,e,n){var r=_a.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Ka(t,e,n){var r=Fa.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function ti(t,e,n){var r=Fa.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function ei(t,e){return Ea(t.getDate(),e,2)}function ni(t,e){return Ea(t.getHours(),e,2)}function ri(t,e){return Ea(t.getHours()%12||12,e,2)}function ai(t,e){return Ea(1+oa.count(da(t),t),e,3)}function ii(t,e){return Ea(t.getMilliseconds(),e,3)}function li(t,e){return ii(t,e)+"000"}function oi(t,e){return Ea(t.getMonth()+1,e,2)}function ui(t,e){return Ea(t.getMinutes(),e,2)}function si(t,e){return Ea(t.getSeconds(),e,2)}function fi(t){var e=t.getDay();return 0===e?7:e}function ci(t,e){return Ea(sa.count(da(t)-1,t),e,2)}function hi(t){var e=t.getDay();return e>=4||0===e?ca(t):ca.ceil(t)}function di(t,e){return t=hi(t),Ea(ca.count(da(t),t)+(4===da(t).getDay()),e,2)}function gi(t){return t.getDay()}function pi(t,e){return Ea(fa.count(da(t)-1,t),e,2)}function yi(t,e){return Ea(t.getFullYear()%100,e,2)}function mi(t,e){return Ea((t=hi(t)).getFullYear()%100,e,2)}function vi(t,e){return Ea(t.getFullYear()%1e4,e,4)}function wi(t,e){var n=t.getDay();return Ea((t=n>=4||0===n?ca(t):ca.ceil(t)).getFullYear()%1e4,e,4)}function xi(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Ea(e/60|0,"0",2)+Ea(e%60,"0",2)}function Ai(t,e){return Ea(t.getUTCDate(),e,2)}function bi(t,e){return Ea(t.getUTCHours(),e,2)}function Di(t,e){return Ea(t.getUTCHours()%12||12,e,2)}function ki(t,e){return Ea(1+ga.count(wa(t),t),e,3)}function Mi(t,e){return Ea(t.getUTCMilliseconds(),e,3)}function Ti(t,e){return Mi(t,e)+"000"}function Ci(t,e){return Ea(t.getUTCMonth()+1,e,2)}function Fi(t,e){return Ea(t.getUTCMinutes(),e,2)}function _i(t,e){return Ea(t.getUTCSeconds(),e,2)}function Si(t){var e=t.getUTCDay();return 0===e?7:e}function Ei(t,e){return Ea(ya.count(wa(t)-1,t),e,2)}function Bi(t){var e=t.getUTCDay();return e>=4||0===e?va(t):va.ceil(t)}function Ni(t,e){return t=Bi(t),Ea(va.count(wa(t),t)+(4===wa(t).getUTCDay()),e,2)}function Li(t){return t.getUTCDay()}function Vi(t,e){return Ea(ma.count(wa(t)-1,t),e,2)}function Ii(t,e){return Ea(t.getUTCFullYear()%100,e,2)}function Yi(t,e){return Ea((t=Bi(t)).getUTCFullYear()%100,e,2)}function Pi(t,e){return Ea(t.getUTCFullYear()%1e4,e,4)}function zi(t,e){var n=t.getUTCDay();return Ea((t=n>=4||0===n?va(t):va.ceil(t)).getUTCFullYear()%1e4,e,4)}function Oi(){return"+0000"}function Ui(){return"%"}function Ri(t){return+t}function Wi(t){return Math.floor(+t/1e3)}function $i(t){return new Date(t)}function Hi(t){return t instanceof Date?+t:+new Date(+t)}function Xi(t,e,n,r,a,i,l,o,u,s){var f=Qr(),c=f.invert,h=f.domain,d=s(".%L"),g=s(":%S"),p=s("%I:%M"),y=s("%I %p"),m=s("%a %d"),v=s("%b %d"),w=s("%B"),x=s("%Y");function A(t){return(u(t)=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:Ri,s:Wi,S:si,u:fi,U:ci,V:di,w:gi,W:pi,x:null,X:null,y:yi,Y:vi,Z:xi,"%":Ui},x={a:function(t){return l[t.getUTCDay()]},A:function(t){return i[t.getUTCDay()]},b:function(t){return u[t.getUTCMonth()]},B:function(t){return o[t.getUTCMonth()]},c:null,d:Ai,e:Ai,f:Ti,g:Yi,G:zi,H:bi,I:Di,j:ki,L:Mi,m:Ci,M:Fi,p:function(t){return a[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:Ri,s:Wi,S:_i,u:Si,U:Ei,V:Ni,w:Li,W:Vi,x:null,X:null,y:Ii,Y:Pi,Z:Oi,"%":Ui},A={a:function(t,e,n){var r=d.exec(e.slice(n));return r?(t.w=g.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(t,e,n){var r=c.exec(e.slice(n));return r?(t.w=h.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){var r=m.exec(e.slice(n));return r?(t.m=v.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){var r=p.exec(e.slice(n));return r?(t.m=y.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,n,r){return k(t,e,n,r)},d:Ha,e:Ha,f:Za,g:Ua,G:Oa,H:ja,I:ja,j:Xa,L:Qa,m:$a,M:qa,p:function(t,e,n){var r=s.exec(e.slice(n));return r?(t.p=f.get(r[0].toLowerCase()),n+r[0].length):-1},q:Wa,Q:Ka,s:ti,S:Ga,u:Ia,U:Ya,V:Pa,w:Va,W:za,x:function(t,e,r){return k(t,n,e,r)},X:function(t,e,n){return k(t,r,e,n)},y:Ua,Y:Oa,Z:Ra,"%":Ja};function b(t,e){return function(n){var r,a,i,l=[],o=-1,u=0,s=t.length;for(n instanceof Date||(n=new Date(+n));++o53)return null;"w"in i||(i.w=1),"Z"in i?(a=(r=Da(ka(i.y,0,1))).getUTCDay(),r=a>4||0===a?ma.ceil(r):ma(r),r=ga.offset(r,7*(i.V-1)),i.y=r.getUTCFullYear(),i.m=r.getUTCMonth(),i.d=r.getUTCDate()+(i.w+6)%7):(a=(r=ba(ka(i.y,0,1))).getDay(),r=a>4||0===a?fa.ceil(r):fa(r),r=oa.offset(r,7*(i.V-1)),i.y=r.getFullYear(),i.m=r.getMonth(),i.d=r.getDate()+(i.w+6)%7)}else("W"in i||"U"in i)&&("w"in i||(i.w="u"in i?i.u%7:"W"in i?1:0),a="Z"in i?Da(ka(i.y,0,1)).getUTCDay():ba(ka(i.y,0,1)).getDay(),i.m=0,i.d="W"in i?(i.w+6)%7+7*i.W-(a+5)%7:i.w+7*i.U-(a+6)%7);return"Z"in i?(i.H+=i.Z/100|0,i.M+=i.Z%100,Da(i)):ba(i)}}function k(t,e,n,r){for(var a,i,l=0,o=e.length,u=n.length;l=u)return-1;if(37===(a=e.charCodeAt(l++))){if(a=e.charAt(l++),!(i=A[a in Ca?e.charAt(l++):a])||(r=i(t,n,r))<0)return-1}else if(a!=n.charCodeAt(r++))return-1}return r}return w.x=b(n,w),w.X=b(r,w),w.c=b(e,w),x.x=b(n,x),x.X=b(r,x),x.c=b(e,x),{format:function(t){var e=b(t+="",w);return e.toString=function(){return t},e},parse:function(t){var e=D(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=b(t+="",x);return e.toString=function(){return t},e},utcParse:function(t){var e=D(t+="",!0);return e.toString=function(){return t},e}}}(t),Ta=Ma.format}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});var ji,qi=(ji=function(t){var e=t.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),a=t[r],i=t[r+1],l=r>0?t[r-1]:2*a-i,o=r{qi(t[t.length-1])})(Gi);var Zi,Ji,Ki,tl=Math.abs,el=Math.atan2,nl=Math.cos,rl=Math.max,al=Math.min,il=Math.sin,ll=Math.sqrt,ol=Math.PI,ul=ol/2,sl=2*ol;function fl(t){return t>1?0:t<-1?ol:Math.acos(t)}function cl(t){return t>=1?ul:t<=-1?-ul:Math.asin(t)}function hl(t){return t.innerRadius}function dl(t){return t.outerRadius}function gl(t){return t.startAngle}function pl(t){return t.endAngle}function yl(t){return t&&t.padAngle}function ml(t,e,n,r,a,i,l,o){var u=n-t,s=r-e,f=l-a,c=o-i,h=c*u-f*s;if(!(h*h<1e-12))return[t+(h=(f*(e-i)-c*(t-a))/h)*u,e+h*s]}function vl(t,e,n,r,a,i,l){var o=t-n,u=e-r,s=(l?i:-i)/ll(o*o+u*u),f=s*u,c=-s*o,h=t+f,d=e+c,g=n+f,p=r+c,y=(h+g)/2,m=(d+p)/2,v=g-h,w=p-d,x=v*v+w*w,A=a-i,b=h*p-g*d,D=(w<0?-1:1)*ll(rl(0,A*A*x-b*b)),k=(b*w-v*D)/x,M=(-b*v-w*D)/x,T=(b*w+v*D)/x,C=(-b*v+w*D)/x,F=k-y,_=M-m,S=T-y,E=C-m;return F*F+_*_>S*S+E*E&&(k=T,M=C),{cx:k,cy:M,x01:-f,y01:-c,x11:k*(a/A-1),y11:M*(a/A-1)}}function wl(){var t=hl,e=dl,n=Qi(0),r=null,a=gl,i=pl,l=yl,o=null;function u(){var u,s,f=+t.apply(this,arguments),c=+e.apply(this,arguments),h=a.apply(this,arguments)-ul,d=i.apply(this,arguments)-ul,g=tl(d-h),p=d>h;if(o||(o=u=or()),c1e-12)if(g>sl-1e-12)o.moveTo(c*nl(h),c*il(h)),o.arc(0,0,c,h,d,!p),f>1e-12&&(o.moveTo(f*nl(d),f*il(d)),o.arc(0,0,f,d,h,p));else{var y,m,v=h,w=d,x=h,A=d,b=g,D=g,k=l.apply(this,arguments)/2,M=k>1e-12&&(r?+r.apply(this,arguments):ll(f*f+c*c)),T=al(tl(c-f)/2,+n.apply(this,arguments)),C=T,F=T;if(M>1e-12){var _=cl(M/f*il(k)),S=cl(M/c*il(k));(b-=2*_)>1e-12?(x+=_*=p?1:-1,A-=_):(b=0,x=A=(h+d)/2),(D-=2*S)>1e-12?(v+=S*=p?1:-1,w-=S):(D=0,v=w=(h+d)/2)}var E=c*nl(v),B=c*il(v),N=f*nl(A),L=f*il(A);if(T>1e-12){var V,I=c*nl(w),Y=c*il(w),P=f*nl(x),z=f*il(x);if(g1e-12?F>1e-12?(y=vl(P,z,E,B,c,F,p),m=vl(I,Y,N,L,c,F,p),o.moveTo(y.cx+y.x01,y.cy+y.y01),F1e-12&&b>1e-12?C>1e-12?(y=vl(N,L,I,Y,f,-C,p),m=vl(E,B,P,z,f,-C,p),o.lineTo(y.cx+y.x01,y.cy+y.y01),Ct?1:e>=t?0:NaN}function Tl(t){return t}Al.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e)}}},function(t){t[t.Tag=0]="Tag",t[t.Frontmatter=1]="Frontmatter",t[t.Wiki=2]="Wiki",t[t.WikiLink=3]="WikiLink",t[t.WikiDisplay=4]="WikiDisplay",t[t.Text=5]="Text",t[t.dvField=6]="dvField",t[t.Table=7]="Table",t[t.FileMeta=8]="FileMeta",t[t.Task=9]="Task",t[t.TaskDone=10]="TaskDone",t[t.TaskNotDone=11]="TaskNotDone"}(Zi||(Zi={})),function(t){t[t.Line=0]="Line",t[t.Bar=1]="Bar",t[t.Pie=2]="Pie",t[t.Radar=3]="Radar",t[t.Summary=4]="Summary",t[t.Table=5]="Table",t[t.Month=6]="Month",t[t.Heatmap=7]="Heatmap",t[t.Bullet=8]="Bullet",t[t.Unknown=9]="Unknown"}(Ji||(Ji={})),function(t){t[t.Number=0]="Number",t[t.Int=1]="Int",t[t.Date=2]="Date",t[t.Time=3]="Time",t[t.DateTime=4]="DateTime",t[t.String=5]="String"}(Ki||(Ki={}));class Cl{constructor(t,e){this.date=t,this.value=e}}class Fl{constructor(t,e,n){if(this.type=e,this.target=n,this.separator="",this.id=t,this.accessor=-1,this.accessor1=-1,this.accessor2=-1,this.valueType=Ki.Number,this.usedAsXDataset=!1,this.numTargets=0,e===Zi.Table){let t,e=new RegExp("\\[(?[0-9]+)\\]\\[(?[0-9]+)\\](\\[(?[0-9]+)\\])?","gm");for(;t=e.exec(n);)if(void 0!==t.groups.accessor){let r=parseFloat(t.groups.accessor);if(Number.isNumber(r)&&void 0!==t.groups.accessor1){let a=parseFloat(t.groups.accessor1);if(Number.isNumber(a)){let i;void 0!==t.groups.accessor2&&(i=parseFloat(t.groups.accessor2)),this.accessor=r,this.accessor1=a,Number.isNumber(i)&&(this.accessor2=i),this.parentTarget=n.replace(e,"")}break}}}else{let t,e=new RegExp("\\[(?[0-9]+)\\]","gm");for(;t=e.exec(n);)if(void 0!==t.groups.accessor){let r=parseFloat(t.groups.accessor);Number.isNumber(r)&&(this.accessor=r,this.parentTarget=n.replace(e,""));break}}}equalTo(t){return this.type===t.type&&this.target===t.target}getType(){return this.type}getTarget(){return this.target}getParentTarget(){return this.parentTarget}getId(){return this.id}getAccessor(t=0){switch(t){case 0:return this.accessor;case 1:return this.accessor1;case 2:return this.accessor2}return null}setSeparator(t){this.separator=t}getSeparator(t=!1){return""===this.separator?t?",":"/":this.separator}addNumTargets(t=1){this.numTargets=this.numTargets+t}getNumTargets(){return this.numTargets}}class _l{constructor(t,e){this.currentIndex=0,this.name="untitled",this.query=e,this.values=[],this.parent=t,this.id=-1,this.yMin=null,this.yMax=null,this.startDate=null,this.endDate=null,this.numTargets=0,this.lineInfo=null,this.barInfo=null,this.isTmpDataset=!1,this.valueType=null==e?void 0:e.valueType;for(let e=0;e=0&&n=0&&nthis.yMax)&&(this.yMax=e),(null===this.startDate||tthis.endDate)&&(this.endDate=t.clone()))}recalculateMinMax(){this.yMin=Math.min(...this.values),this.yMax=Math.max(...this.values)}getYMin(){return this.yMin}getYMax(){return this.yMax}getStartDate(){return this.startDate}getEndDate(){return this.endDate}shift(t,e){let n=!1;for(let r=0;r=e)&&(this.values[r]=this.values[r]+t,n=!0);n&&(this.yMin=this.yMin+t,this.yMax=this.yMax+t)}setPenalty(t){for(let e=0;ethis.yMax&&(this.yMax=t))}getQuery(){return this.query}accumulateValues(){let t=0;for(let e=0;ethis.yMax&&(this.yMax=t)}getValues(){return this.values}getLength(){return this.values.length}getLengthNotNull(){let t=0;for(let e=0;e[\d\.\/-]+)\s*,\s*(?[\d\.\/-]+)\s*\)/).groups;e&&(this.translateX=parseFloat(e.x),this.translateY=parseFloat(e.y))}}}class $l{constructor(t,e){this.filePath=t,this.tableIndex=e,this.xDataset=null,this.yDatasets=[]}}class Hl{constructor(){this.fileTotal=0,this.fileAvailable=0,this.fileOutOfDateRange=0,this.fileNotInFormat=0,this.errorMessage="",this.minDate=window.moment(""),this.maxDate=window.moment(""),this.gotAnyValidXValue=!1,this.gotAnyValidYValue=!1}}const Xl=function(){const t=["HH","H","hh","h"],e=["mm","m"],n=["ss","s",""];let r=[];for(let a of t)for(let t of e)for(let e of n){let n=`${a}:${t}`;""!==e&&(n+=`:${e}`),a.contains("h")&&(n+=" a"),r.push(n)}return r}();function jl(t,e,n){if(!e&&!n)return t;let r=t;if(r.startsWith("^")&&(r=r.slice(1)),e){let t=new RegExp("^("+e+")","gm");t.test(r)&&(r=r.replace(t,""))}if(n){let t=new RegExp("("+n+")$","gm");t.test(r)&&(r=r.replace(t,""))}return r}function ql(t,e){let n=e;t.length>4&&t.startsWith("[[")&&t.endsWith("]]")&&(t=t.substring(2,t.length-2)),"iso-8601"===e.toLowerCase()&&(n=window.moment.ISO_8601);let r=window.moment(t,n,!0);return r=r.startOf("day"),r}function Gl(t,e,n=!0){if(!t||!e||0===e.length)return[null,t];let r=null;const a="^(?[0-9]+)("+e.join("|")+")$",i=new RegExp(a,"gm");let l=i.exec(t);return l&&void 0!==l.groups&&void 0!==l.groups.value&&(r=parseFloat(l.groups.value),Number.isNumber(r)&&!Number.isNaN(r))?(n&&(t=t.replace(i,"")),[r,t]):[null,t]}function Ql(t){if(!t)return null;let e=window.moment.duration(0),n=!1,r=!1;t.startsWith("+")&&(r=!1,t=t.substring(1)),t.startsWith("-")&&(r=!0,t=t.substring(1));let a=null;[a,t]=Gl(t,["year","years","Y","y"]),null!==a&&(r&&(a*=-1),e.add(a,"years"),n=!0);let i=null;[i,t]=Gl(t,["month","months","M"]),null!==i&&(r&&(i*=-1),e.add(i,"months"),n=!0);let l=null;[l,t]=Gl(t,["week","weeks","W","w"]),null!==l&&(r&&(l*=-1),e.add(l,"weeks"),n=!0);let o=null;[o,t]=Gl(t,["day","days","D","d"]),null!==o&&(r&&(o*=-1),e.add(o,"days"),n=!0);let u=null;[u,t]=Gl(t,["hour","hours","H","h"]),null!==u&&(r&&(u*=-1),e.add(u,"hours"),n=!0);let s=null;[s,t]=Gl(t,["minute","minutes","m"]),null!==s&&(r&&(s*=-1),e.add(s,"minutes"),n=!0);let f=null;return[f,t]=Gl(t,["second","seconds","S","s"]),null!==f&&(r&&(f*=-1),e.add(f,"seconds"),n=!0),n?e:null}function Zl(t,e){let n=null,r=Ql(t);return r&&window.moment.isDuration(r)&&(n=to(e),n=n.add(r),n&&n.isValid()),n}function Jl(t,e){return null==t?null:"iso-8601"===e.toLowerCase()?t.format():t.format(e)}function Kl(t,e){return ql(Jl(window.moment(t),e),e)}function to(t){return ql(Jl(window.moment(),t),t)}function eo(t,e){for(var n=(e=e.replace(/^\./,"")).split("."),r=0,a=n.length;rt!==e)),a=n.reverse().findIndex((t=>t!==e));return-1===r&&-1===a?t:t.substring(r,t.length-a)}function ro(t){if(null===t)return null;let e=new RegExp(']*?alt\\s*=\\s*[""\']?(?[^\'"" >]+?)[ \'""][^>]*?>',"g");return t.replace(e,((...t)=>{let e=t[t.length-1];return e&&e.emoji?e.emoji.trim():""}))}function ao(t,e=null){let n=null,r=Ki.Number;if("string"==typeof t)if(t.includes(":")){let e=!1;t.startsWith("-")&&(e=!0,t=t.substring(1));let a=window.moment(t,Xl,!0);a.isValid()&&(n=a.diff(window.moment("00:00","HH:mm",!0),"seconds"),e&&(n*=-1),r=Ki.Time)}else if(e){const r=Object.keys(e);for(let n of r)if("string"==typeof n){let r=new RegExp(n,"gm");if(r.test(t)&&Number.isNumber(e[n])){let a=e[n].toString();t=t.replace(r,a);break}}n=parseFloat(t),Number.isNaN(n)&&(n=null)}else n=parseFloat(t),Number.isNaN(n)&&(n=null);else"number"==typeof t&&(n=t);return{type:r,value:n}}function io(t,e="",n=""){var r=jt("body").append("svg");let a=r.append("text").text(t).attr("x",-99999).attr("y",-99999);e&&a.attr("class",e),n&&a.attr("transform","rotate("+n+")");var i=r.node().getBBox();return r.remove(),{width:i.width,height:i.height}}function lo(t,e,n){let r=(0|parseFloat(t.attr("width")))+e,a=(0|parseFloat(t.attr("height")))+n;t.attr("width",r),t.attr("height",a)}function oo(t,e,n){let r=new Wl(t.attr("transform"));t.attr("transform","translate("+(r.translateX+e)+","+(r.translateY+n)+")")}function uo(t){return t=(t=(t=t.replace(/(^\\s\*)|(\\s\*$)/gi,"")).replace(/\[ \]{2,}/gi," ")).replace(/\\n /,"\\n")}var so=i((function(t,e){!function(n){var r="Compound",a="MemberExpression",i="Literal",l=function(t,e){var n=new Error(t+" at character "+e);throw n.index=e,n.description=t,n},o=!0,u={"-":o,"!":o,"~":o,"+":o},s={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},f={$:o,_:o},c=function(t){var e,n=0;for(var r in t)(e=r.length)>n&&t.hasOwnProperty(r)&&(n=e);return n},h=c(u),d=c(s),g={true:!0,false:!1,null:null},p=function(t){return s[t]||0},y=function(t,e,n){return{type:"||"===t||"&&"===t?"LogicalExpression":"BinaryExpression",operator:t,left:e,right:n}},m=function(t){return t>=48&&t<=57},v=function(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!s[String.fromCharCode(t)]||f.hasOwnProperty(String.fromCharCode(t))},w=function(t){return t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||t>=128&&!s[String.fromCharCode(t)]||f.hasOwnProperty(String.fromCharCode(t))},x=function(t){for(var e,n,o=0,f=t.charAt,c=t.charCodeAt,x=function(e){return f.call(t,e)},A=function(e){return c.call(t,e)},b=t.length,D=function(){for(var t=A(o);32===t||9===t||10===t||13===t;)t=A(++o)},k=function(){var t,e,n=T();return D(),63!==A(o)?n:(o++,(t=k())||l("Expected expression",o),D(),58===A(o)?(o++,(e=k())||l("Expected expression",o),{type:"ConditionalExpression",test:n,consequent:t,alternate:e}):void l("Expected :",o))},M=function(){D();for(var e=t.substr(o,d),n=e.length;n>0;){if(s.hasOwnProperty(e)&&(!v(A(o))||o+e.length2&&n<=r[r.length-2].prec;)u=r.pop(),e=r.pop().value,i=r.pop(),t=y(e,i,u),r.push(t);(t=C())||l("Expected expression after "+f,o),r.push(a,t)}for(t=r[s=r.length-1];s>1;)t=y(r[s-1].value,r[s-2],t),s-=2;return t},C=function(){var e,n,r,i;if(D(),e=A(o),m(e)||46===e)return F();if(39===e||34===e)i=_();else if(91===e)i=N();else{for(r=(n=t.substr(o,h)).length;r>0;){if(u.hasOwnProperty(n)&&(!v(A(o))||o+n.length=a.length&&l("Unexpected token "+String.fromCharCode(t),o);break}if(44===e){if(o++,++u!==a.length)if(41===t)l("Unexpected token ,",o);else if(93===t)for(var s=a.length;s=0),o.type){case"b":a=parseInt(a,10).toString(2);break;case"c":a=String.fromCharCode(parseInt(a,10));break;case"d":case"i":a=parseInt(a,10);break;case"j":a=JSON.stringify(a,null,o.width?parseInt(o.width):0);break;case"e":a=o.precision?parseFloat(a).toExponential(o.precision):parseFloat(a).toExponential();break;case"f":a=o.precision?parseFloat(a).toFixed(o.precision):parseFloat(a);break;case"g":a=o.precision?String(Number(a.toPrecision(o.precision))):parseFloat(a);break;case"o":a=(parseInt(a,10)>>>0).toString(8);break;case"s":a=String(a),a=o.precision?a.substring(0,o.precision):a;break;case"t":a=String(!!a),a=o.precision?a.substring(0,o.precision):a;break;case"T":a=Object.prototype.toString.call(a).slice(8,-1).toLowerCase(),a=o.precision?a.substring(0,o.precision):a;break;case"u":a=parseInt(a,10)>>>0;break;case"v":a=a.valueOf(),a=o.precision?a.substring(0,o.precision):a;break;case"x":a=(parseInt(a,10)>>>0).toString(16);break;case"X":a=(parseInt(a,10)>>>0).toString(16).toUpperCase()}t.json.test(o.type)?p+=a:(!t.number.test(o.type)||c&&!o.sign?h="":(h=c?"+":"-",a=a.toString().replace(t.sign,"")),s=o.pad_char?"0"===o.pad_char?"0":o.pad_char.charAt(1):" ",f=o.width-(h+a).length,u=o.width&&f>0?s.repeat(f):"",p+=o.align?h+a+u:"0"===s?h+u+a:u+h+a)}return p}var i=Object.create(null);function l(e){if(i[e])return i[e];for(var n,r=e,a=[],l=0;r;){if(null!==(n=t.text.exec(r)))a.push(n[0]);else if(null!==(n=t.modulo.exec(r)))a.push("%");else{if(null===(n=t.placeholder.exec(r)))throw new SyntaxError("[sprintf] unexpected placeholder");if(n[2]){l|=1;var o=[],u=n[2],s=[];if(null===(s=t.key.exec(u)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o.push(s[1]);""!==(u=u.substring(s[0].length));)if(null!==(s=t.key_access.exec(u)))o.push(s[1]);else{if(null===(s=t.index_access.exec(u)))throw new SyntaxError("[sprintf] failed to parse named argument key");o.push(s[1])}n[2]=o}else l|=2;if(3===l)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");a.push({placeholder:n[0],param_no:n[1],keys:n[2],sign:n[3],pad_char:n[4],align:n[5],width:n[6],precision:n[7],type:n[8]})}r=r.substring(n[0].length)}return i[e]=a}e.sprintf=n,e.vsprintf=r,"undefined"!=typeof window&&(window.sprintf=n,window.vsprintf=r)}()}));function co(t){if("number"==typeof t){if(0===t)return!1}else if(t instanceof _l&&t.getValues().some((function(t){return 0===t})))return!1;return!0}const ho={min:function(t,e){return h(t.getValues())},minDate:function(t,e){let n=h(t.getValues());if(Number.isNumber(n)){let e=Array.from(t);for(let t of e.reverse())if(null!==t.value&&t.value===n)return t.date}return"Error: min not found"},max:function(t,e){return c(t.getValues())},maxDate:function(t,e){let n=c(t.getValues());if(Number.isNumber(n)){let e=Array.from(t);for(let t of e.reverse())if(null!==t.value&&t.value===n)return t.date}return"Error: max not found"},startDate:function(t,e){if(t){let e=t.getStartDate();if(e&&e.isValid())return e}return e.startDate},endDate:function(t,e){if(t){let e=t.getEndDate();if(e&&e.isValid())return e}return e.endDate},sum:function(t,e){return m(t.getValues())},count:function(t,e){return"Error: deprecated function 'count'"},numTargets:function(t,e){return t.getNumTargets()},days:function(t,e){return"Error: deprecated function 'days'"},numDays:function(t,e){return t.getLength()},numDaysHavingData:function(t,e){return t.getLengthNotNull()},maxStreak:function(t,e){let n=0,r=0;for(let e of t)null!==e.value?n++:n=0,n>=r&&(r=n);return r},maxStreakStart:function(t,e){let n=0,r=0,a=null,i=null;if(t)for(let e of t)null!==e.value?(0===n&&(a=e.date),n++):n=0,n>=r&&(r=n,i=a);return i},maxStreakEnd:function(t,e){let n=0,r=0,a=null,i=null;if(t){let e=Array.from(t);for(let t=0;t=r&&(r=n,i=a)}}return i},maxBreaks:function(t,e){let n=0,r=0;for(let e of t)null===e.value?n++:n=0,n>r&&(r=n);return r},maxBreaksStart:function(t,e){let n=0,r=0,a=null,i=null;if(t)for(let e of t)null===e.value?(0===n&&(a=e.date),n++):n=0,n>=r&&(r=n,i=a);return i},maxBreaksEnd:function(t,e){let n=0,r=0,a=null,i=null;if(t){let e=Array.from(t);for(let t=0;t=r&&(r=n,i=a)}}return i},lastStreak:function(t,e){return"Error: deprecated function 'lastStreak'"},currentStreak:function(t,e){let n=0;if(t){let e=Array.from(t);for(let t=e.length-1;t>=0;t--){if(null===e[t].value)break;n++}}return n},currentStreakStart:function(t,e){let n=null;if(t){let e=Array.from(t);for(let t=e.length-1;t>=0;t--){let r=e[t];if(t=0;t--){let a=e[t];if(null===a.value)break;0===n&&(r=a.date),n++}}return null===r?"Error: absense":r},currentBreaks:function(t,e){let n=0;if(t){let e=Array.from(t);for(let t=e.length-1;t>=0;t--){if(null!==e[t].value)break;n++}}return n},currentBreaksStart:function(t,e){let n=null;if(t){let e=Array.from(t);for(let t=e.length-1;t>=0;t--){let r=e[t];if(t=0;t--){let a=e[t];if(null!==a.value)break;0===n&&(r=a.date),n++}}return null===r?"Error: absense":r},average:function(t,e){let n=t.getLengthNotNull();return co(n)?m(t.getValues())/n:"Error: divide by zero in expression"},median:function(t,e){return p(t.getValues(),.5,n);var n},variance:function(t,e){return function(t,e){let n,r=0,a=0,i=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(n=e-a,a+=n/++r,i+=n*(e-a));else{let l=-1;for(let o of t)null!=(o=e(o,++l,t))&&(o=+o)>=o&&(n=o-a,a+=n/++r,i+=n*(o-a))}if(r>1)return i/(r-1)}(t.getValues())}},go={"-":function(t){if("number"==typeof t)return-1*t;if(t instanceof _l){let e=t.cloneToTmpDataset();return e.getValues().forEach((function(t,e,n){null!==n[e]&&(n[e]=-1*t)})),e.recalculateMinMax(),e}return"Error: unknown operation for '-'"},"+":function(t){if("number"==typeof t)return t;if(t instanceof _l){return t.cloneToTmpDataset()}return"Error: unknown operation for '+'"}},po={"+":function(t,e){if("number"==typeof t&&"number"==typeof e)return t+e;if("number"==typeof t&&e instanceof _l){let n=e.cloneToTmpDataset();return n.getValues().forEach((function(e,n,r){null!==r[n]?r[n]=t+e:r[n]=null})),n.recalculateMinMax(),n}if(t instanceof _l&&"number"==typeof e){let n=t.cloneToTmpDataset();return n.getValues().forEach((function(t,n,r){null!==r[n]?r[n]=t+e:r[n]=null})),n.recalculateMinMax(),n}if(t instanceof _l&&e instanceof _l){let n=t.cloneToTmpDataset();return n.getValues().forEach((function(t,n,r){null!==r[n]?r[n]=t+e.getValues()[n]:r[n]=null})),n.recalculateMinMax(),n}return"Error: unknown operation for '+'"},"-":function(t,e){if("number"==typeof t&&"number"==typeof e)return t-e;if("number"==typeof t&&e instanceof _l){let n=e.cloneToTmpDataset();return n.getValues().forEach((function(e,n,r){null!==r[n]?r[n]=t-e:r[n]=null})),n.recalculateMinMax(),n}if(t instanceof _l&&"number"==typeof e){let n=t.cloneToTmpDataset();return n.getValues().forEach((function(t,n,r){null!==r[n]?r[n]=t-e:r[n]=null})),n}if(t instanceof _l&&e instanceof _l){let n=t.cloneToTmpDataset();return n.getValues().forEach((function(t,n,r){null!==r[n]?r[n]=t-e.getValues()[n]:r[n]=null})),n.recalculateMinMax(),n}return"Error: unknown operation for '-'"},"*":function(t,e){if("number"==typeof t&&"number"==typeof e)return t*e;if("number"==typeof t&&e instanceof _l){let n=e.cloneToTmpDataset();return n.getValues().forEach((function(e,n,r){null!==r[n]?r[n]=t*e:r[n]=null})),n.recalculateMinMax(),n}if(t instanceof _l&&"number"==typeof e){let n=t.cloneToTmpDataset();return n.getValues().forEach((function(t,n,r){null!==r[n]?r[n]=t*e:r[n]=null})),n.recalculateMinMax(),n}if(t instanceof _l&&e instanceof _l){let n=t.cloneToTmpDataset();return n.getValues().forEach((function(t,n,r){null!==r[n]?r[n]=t*e.getValues()[n]:r[n]=null})),n.recalculateMinMax(),n}return"Error: unknown operation for '*'"},"/":function(t,e){if(!co(e))return"Error: divide by zero in expression";if("number"==typeof t&&"number"==typeof e)return t/e;if("number"==typeof t&&e instanceof _l){let n=e.cloneToTmpDataset();return n.getValues().forEach((function(e,n,r){null!==r[n]?r[n]=t/e:r[n]=null})),n.recalculateMinMax(),n}if(t instanceof _l&&"number"==typeof e){let n=t.cloneToTmpDataset();return n.getValues().forEach((function(t,n,r){null!==r[n]?r[n]=t/e:r[n]=null})),n.recalculateMinMax(),n}if(t instanceof _l&&e instanceof _l){let n=t.cloneToTmpDataset();return n.getValues().forEach((function(t,n,r){null!==r[n]?r[n]=t/e.getValues()[n]:r[n]=null})),n.recalculateMinMax(),n}return"Error: unknown operation for '/'"},"%":function(t,e){if(!co(e))return"Error: divide by zero in expression";if("number"==typeof t&&"number"==typeof e)return t%e;if("number"==typeof t&&e instanceof _l){let n=e.cloneToTmpDataset();return n.getValues().forEach((function(e,n,r){null!==r[n]?r[n]=t%e:r[n]=null})),n.recalculateMinMax(),n}if(t instanceof _l&&"number"==typeof e){let n=t.cloneToTmpDataset();return n.getValues().forEach((function(t,n,r){null!==r[n]?r[n]=t%e:r[n]=null})),n.recalculateMinMax(),n}if(t instanceof _l&&e instanceof _l){let n=t.cloneToTmpDataset();return n.getValues().forEach((function(t,n,r){null!==r[n]?r[n]=t%e.getValues()[n]:r[n]=null})),n.recalculateMinMax(),n}return"Error: unknown operation for '%'"}},yo={normalize:function(t,e,n){let r=t.getYMin(),a=t.getYMax();if(null!==r&&null!==a&&a>r){let e=t.cloneToTmpDataset();return e.getValues().forEach((function(t,e,n){n[e]=(t-r)/(a-r)})),e.recalculateMinMax(),e}return"Error: invalid data range for function 'normalize'"},setMissingValues:function(t,e,n){if(e&&e.length>0){let n=e[0],r=t.cloneToTmpDataset();return Number.isNumber(n)&&!Number.isNaN(n)?(r.getValues().forEach((function(t,e,r){null===t&&(r[e]=n)})),r.recalculateMinMax(),r):"Error: invalid arguments for function 'setMissingValues'"}return"Error: invalid arguments for function 'setMissingValues"}};function mo(t,e){switch(t.type){case"Literal":return t.value;case"Identifier":let n=t.name;return n in ho||n in yo?`Error: deprecated template variable '${n}', use '${n}()' instead`:`Error: unknown function name '${n}'`;case"UnaryExpression":let r=t,a=mo(r.argument,e);return"string"==typeof a?a:go[r.operator](a);case"BinaryExpression":let i=t,l=mo(i.left,e),o=mo(i.right,e),u=function(t,e){return"string"==typeof t?t:"string"==typeof e?e:"number"==typeof t||window.moment.isMoment(t)||t instanceof _l?"number"==typeof e||window.moment.isMoment(e)||e instanceof _l?"":"Error: invalide operant type":"Error: invalid operant type"}(l,o);return"string"==typeof u&&u.startsWith("Error:")?u:po[i.operator](l,o);case"CallExpression":let s=t,f=s.callee.name,c=function(t,e){return t.map((function(t){return mo(t,e)}))}(s.arguments,e);if("string"==typeof c)return c;if("dataset"===f){if(1===c.length){let t=c[0];if("string"==typeof t)return t;if("number"!=typeof t)return"Error: function 'dataset' only accepts id in number";let n=function(t,e){return e.datasets.getDatasetById(t)}(t,e);return n||`Error: no dataset found for id '${t}'`}}else{if(f in ho){if(0===c.length){let t=null;for(let n of e.datasets)t||n.getQuery().usedAsXDataset||(t=n);return t?ho[f](t,e):`No available dataset found for function ${f}`}if(1===c.length){let t=c[0];return"string"==typeof t?t:t instanceof _l?ho[f](t,e):`Error: function '${f}' only accepts Dataset`}return`Error: Too many arguments for function ${f}`}if(f in yo){if(1===c.length){if("string"==typeof c[0])return c[0];if(c[0]instanceof _l){let t=c[0];return yo[f](t,null,e)}return`Error: function ${f} only accept Dataset`}if(c.length>1){if("string"==typeof c[0])return c[0];if(c[0]instanceof _l){let t=c[0];return yo[f](t,c.filter((function(t,e,n){return e>0})),e)}return`Error: function ${f} only accept Dataset`}return`Error: Too many arguments for function ${f}`}}return`Error: unknown function name '${f}'`}return"Error: unknown expression"}function vo(t,e){let n,r=[],a=new RegExp("{{(?[\\w+\\-*\\/0-9\\s()\\[\\]%.,]+)(::(?[\\w+\\-*\\/0-9\\s()\\[\\]%.:]+))?}}","gm");for(;n=a.exec(t);){let t=n[0];if(!r.some((e=>e.source===t))&&(void 0!==n.groups&&void 0!==n.groups.expr)){let a=n.groups.expr,i=null;try{i=so(a)}catch(t){return"Error:"+t.message}if(!i)return"Error: failed to parse expression";const l=mo(i,e);if("string"==typeof l)return l;if("number"==typeof l||window.moment.isMoment(l)){let e=null;void 0!==n.groups.format&&(e=n.groups.format),r.push({source:t,value:l,format:e})}}}return r}function wo(t,e){let n=vo(t,e);if("string"==typeof n)return n;let r=n;for(let n of r){let r=n.source,a=n.value,i=n.format,l="";"number"==typeof a?l=i?fo.sprintf("%"+i,a):a.toFixed(1):window.moment.isMoment(a)&&(l=Jl(a,i||e.dateFormat)),l&&(t=t.split(r).join(l))}return t}function xo(t,e){if(t=t.trim(),/^([\-]?[0-9]+[\.][0-9]+|[\-]?[0-9]+)$/.test(t))return parseFloat(t);let n=vo(t,e);if("string"==typeof n)return n;let r=n;return r.length>0?r[0].value:"Error: failed to resolve values"}function Ao(t,e,n,r){let a="",i=.5*n.dataAreaSize.width,l=.7*i,o=l*r.ratioInnerRadius,u=[];for(let t of r.data){let e=xo(t,n);if("string"==typeof e){a=e;break}"number"==typeof e&&u.push(e)}if(""!==a)return a;let s=[];for(let t of r.label){let e=wo(t,n);if(e.startsWith("Error")){a=e;break}s.push(e)}if(""!==a)return a;let f=r.hideLabelLessThan,c=s.map((function(t){return io(t,"tracker-tick-label")})),h=[];for(let t of r.extLabel){let e=wo(t,n);if(e.startsWith("Error")){a=e;break}h.push(e)}if(""!==a)return a;let d=h.map((function(t){return io(t,"tracker-pie-label")})),g=r.showExtLabelOnlyIfNoLabel,p=Cr().range(r.dataColor),y=e.dataArea.append("g");y.attr("transform",(function(){return"translate("+.5*n.dataAreaSize.width+","+.5*n.dataAreaSize.height+")"}));let m=function(){var t=Tl,e=Ml,n=null,r=Qi(0),a=Qi(sl),i=Qi(0);function l(l){var o,u,s,f,c,h=(l=xl(l)).length,d=0,g=new Array(h),p=new Array(h),y=+r.apply(this,arguments),m=Math.min(sl,Math.max(-sl,a.apply(this,arguments)-y)),v=Math.min(Math.abs(m)/h,i.apply(this,arguments)),w=v*(m<0?-1:1);for(o=0;o0&&(d+=c);for(null!=e?g.sort((function(t,n){return e(p[t],p[n])})):null!=n&&g.sort((function(t,e){return n(l[t],l[e])})),o=0,s=d?(m-h*w)/d:0;o0?c*s:0)+w,p[u]={data:l[u],index:o,value:c,startAngle:y,endAngle:f,padAngle:v};return p}return l.value=function(e){return arguments.length?(t="function"==typeof e?e:Qi(+e),l):t},l.sortValues=function(t){return arguments.length?(e=t,n=null,l):e},l.sort=function(t){return arguments.length?(n=t,e=null,l):n},l.startAngle=function(t){return arguments.length?(r="function"==typeof t?t:Qi(+t),l):r},l.endAngle=function(t){return arguments.length?(a="function"==typeof t?t:Qi(+t),l):a},l.padAngle=function(t){return arguments.length?(i="function"==typeof t?t:Qi(+t),l):i},l}(),v=m(u),w=y.selectAll("sector").data(v).enter().append("g").attr("class","sector"),x=wl().innerRadius(o).outerRadius(l);var A=wl().innerRadius(.9*i).outerRadius(.9*i);function b(t){return(t.endAngle-t.startAngle)/(2*Math.PI)Math.sqrt(Math.pow(u[0]-l[0],2)+Math.pow(u[1]-l[1],2))?[l,u]:[l,o,u]}w.append("path").attr("fill",(function(t,e){return p(e.toString())})).attr("d",x),y.selectAll("label").data(m(u)).enter().append("text").text((function(t,e){return b(t)?"":s[e]})).attr("transform",(function(t){return"translate("+x.centroid(t)[0]+","+x.centroid(t)[1]+")"})).style("text-anchor","middle").attr("class","tracker-pie-label"),y.selectAll("extLabel").data(v).enter().append("text").text((function(t,e){return g?""===s[e]||b(t)?h[e]:"":h[e]})).attr("transform",(function(t,e){let n=A.centroid(t),r=D(t);return n[0]=(.99*i-d[e].width)*(rc&&(c=s[t].width,f=t);let h=c/u[f].length,d=s[f].height,g=u.length,p=2*h,y=d,v=2*h,w=0,x=0;"vertical"===r.legendOrientation?(w=3*p+v+c,x=(g+1)*y):"horizontal"===r.legendOrientation&&(w=(2*p+v)*g+p+m(s,(function(t,e){return t.width})),x=y+d);let A=0,b=0;if("top"===r.legendPosition)A=n.dataAreaSize.width/2-w/2,b=o,lo(a,0,x+y),oo(i,0,x+y);else if("bottom"===r.legendPosition)A=n.dataAreaSize.width/2-w/2,b=o+n.dataAreaSize.height+y,lo(a,0,x+y);else if("left"===r.legendPosition)A=0,b=o+n.dataAreaSize.height/2-x/2,lo(a,w+p,0),oo(i,w+p,0);else{if("right"!==r.legendPosition)return;A=n.dataAreaSize.width+p,b=o+n.dataAreaSize.height/2-x/2,lo(a,w+p,0)}let D=e.graphArea.append("g").attr("id","legend").attr("transform","translate("+A+","+b+")"),k=D.append("rect").attr("class","tracker-legend").attr("width",w).attr("height",x);r.legendBgColor&&k.style("fill",r.legendBgColor),r.legendBorderColor&&k.style("stroke",r.legendBorderColor);let M=p,T=d,C=M+p+v,F=T;if("vertical"===r.legendOrientation)D.selectAll("markers").data(u).enter().append("circle").attr("cx",M+v/2).attr("cy",(function(t,e){return T+e*y})).attr("r",(function(t,e){return 5})).style("fill",(function(t,e){return r.dataColor[e]})),D.selectAll("labels").data(u).enter().append("text").attr("x",C).attr("y",(function(t,e){return F+e*y})).text((function(t,e){return t})).style("alignment-baseline","middle").attr("class","tracker-legend-label").style("fill",(function(t,e){return r.dataColor[e]}));else if("horizontal"===r.legendOrientation){let t=0;t=0,D.selectAll("markers").data(u).enter().append("circle").attr("cx",(function(e,n){return 0===n?t=M+v/2:t+=s[n].width+p+v+p,t})).attr("cy",T).attr("r",(function(t,e){return 5})).style("fill",(function(t,e){return r.dataColor[e]})),t=0,D.selectAll("labels").data(u).enter().append("text").attr("x",(function(e,n){return 0===n?t=C:t+=s[n].width+p+v+p,t})).attr("y",F).text((function(t,e){return t})).style("alignment-baseline","middle").attr("class","tracker-legend-label").style("fill",(function(t,e){return r.dataColor[e]}))}}(0,r,e,n),function(t,e,n){let r=jt(t),a=e.svg,i=parseFloat(a.attr("width")),l=parseFloat(a.attr("height"));a.attr("width",null).attr("height",null).attr("viewBox",`0 0 ${i} ${l}`).attr("preserveAspectRatio","xMidYMid meet"),n.fitPanelWidth?r.style("width","100%"):(r.style("width",(i*n.fixedScale).toString()+"px"),r.style("height",(l*n.fixedScale).toString()+"px"))}(t,r,e)}function Do(t,e,n){if(!e||!n)return;let r="";n.template,r=n.template;let a=wo(r,e);if(a.startsWith("Error:"))return a;if(r=a,""!==r){let e=jt(t).append("div");if(r.includes("\n")||r.includes("\\n")){let t=r.split(/(\n|\\n)/);for(let n of t)"\n"!==n&&"\\n"!==n&&e.append("div").text(n)}else e.text(r);""!==n.style&&e.attr("style",n.style)}}let ko=!1;function Mo(t,e){let n=e.dataset;if(0===n.length)return!1;let r=null;if(null===e.selectedDataset){for(let e of n)if(r=t.datasets.getDatasetById(e),r&&!r.getQuery().usedAsXDataset)break;if(r)return e.selectedDataset=r.getId(),!0}else{let a=e.selectedDataset,i=n.findIndex((t=>t===a));if(i>=0){if(i===e.dataset.length-1){for(let e of n)if(r=t.datasets.getDatasetById(e),r&&!r.getQuery().usedAsXDataset)break;return!!r&&(e.selectedDataset=r.getId(),!0)}{i++;let a=n[i];if(r=t.datasets.getDatasetById(a),e.selectedDataset=a,r&&!r.getQuery().usedAsXDataset)return!0;Mo(t,e)}}}return!1}function To(t,e,n,r){jt(e).select("#svg").remove();for(var a=Object.getOwnPropertyNames(t),i=0;i").attr("id","arrowLeft").attr("transform","translate("+6.5*s+","+(g/2+D.height/2)+")").attr("class","tracker-month-title-arrow").on("click",(function(i){Co(e,r);let l=a.clone().add(1,"month");So(t,e,n,r,l)})).style("cursor","pointer"),p.append("text").text("◦").attr("id","arrowToday").attr("transform","translate("+6*s+","+(g/2+D.height/2)+")").attr("class","tracker-month-title-arrow").on("click",(function(a){Co(e,r);let i=to(n.dateFormat);So(t,e,n,r,i)})).style("cursor","pointer"),g+=8;let k=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];"mon"===r.startWeekOn.toLowerCase()&&k.push(k.shift());let M=io(k[0],"tracker-month-weekday");e.graphArea.selectAll("weekDays").data(k).enter().append("text").text((function(t){return t})).attr("transform",(function(t,e){return"translate("+(e+.5)*s+","+(g+M.height)+")"})).attr("class","tracker-month-weekday").attr("text-anchor","middle").style("cursor","default").on("click",(function(t){Co(e,r)})),g+=M.height+8;let T=null;r.dividingLineColor?T=r.dividingLineColor:r.color&&(T=r.color);let C=e.graphArea.append("rect").attr("x",0).attr("y",g).attr("width",6.5*s+M.width).attr("height",1).attr("class","tracker-month-dividing-line");T&&C.style("fill",T),g+=1,p.attr("height",g),e.header=p,oo(e.dataArea,0,g)}function _o(t,e,n,r,a){if(!n||!r)return;let i=r.mode;if("circle"!==i&&"annotation"!==i)return"Unknown month view mode";let l=r.selectedDataset;if(null===l)return;let o=n.datasets.getDatasetById(l);if(!o)return;let u=r.dataset.findIndex((t=>t===l));l<0&&(u=0);let s=r.threshold[u];a.month(),a.daysInMonth();let f=io("30","tracker-month-label"),d=2.8*Math.max(f.width,f.height),g=d/2.8*1.8/2,p=(d-2*g)/2,y=h(o.getValues());null!==r.yMin[u]&&(y=r.yMin[u]);let m=c(o.getValues());null!==r.yMax[u]&&(m=r.yMax[u]);let v=!0;(null===m||null===y||m<=y)&&(v=!1);const w=a.clone().startOf("month");let x=w.clone().subtract(w.day(),"days");"mon"===r.startWeekOn.toLowerCase()&&(x=x.add(1,"days"));const A=a.clone().endOf("month");let b=A.clone().add(7-A.day()-1,"days");"mon"===r.startWeekOn.toLowerCase()&&(b=b.add(1,"days"));const D=o.getStartDate(),k=o.getEndDate();let M=r.showAnnotation,T=r.annotation,C=T[u],F=r.showAnnotationOfAllTargets,_=[],S=0,E=0,B=0;for(let t=x.clone();t<=b;t.add(1,"days")){t=ql(Jl(t,n.dateFormat),n.dateFormat),"2021-09-13"===t.format("YYYY-MM-DD")&&(ko=!1),"mon"===r.startWeekOn.toLowerCase()?(S=t.day()-1,S<0&&(S=6),E=Math.floor(B/7)):(S=t.day(),E=Math.floor(B/7));let e=!0;(t.diff(w)<0||t.diff(A)>0)&&(e=!1);let a=!0;D&&k&&t.diff(D)>=0&&t.diff(k)<=0&&(a=!1);const i=o.getValue(t);ko&&(console.log(o),console.log(Jl(t,n.dateFormat)),console.log(i));let l=!1;r.circleColorByValue?(v||null!==i&&i>s)&&(l=!0):null!==i&&i>s&&(l=!0);let u=null;r.circleColorByValue&&v&&null!==i&&(u=(i-y)/(m-y)),ko&&(console.log(y),console.log(m),console.log(u));let f=o.getValue(t,1),c=o.getValue(t,-1),h=!1;null!==i&&i>s&&null!==c&&c>s&&(h=!0);let d=!1;null!==i&&i>s&&null!==f&&f>s&&(d=!0),ko&&(console.log(`preValue: ${c}, curValue: ${i}, nextValue: ${f}`),console.log(r.threshold),console.log(`streakIn: ${h}, streakOut: ${d}`));let g="";if(M)if(F)for(let e of r.dataset){let a=r.dataset.findIndex((t=>t===e));if(a>=0){let i=n.datasets.getDatasetById(e).getValue(t),l=r.threshold[a];null!==i&&i>l&&(g+=T[a])}}else i>s&&(g=C);_.push({date:Jl(t,n.dateFormat),value:i,scaledValue:u,dayInMonth:t.date(),isInThisMonth:e,isOutOfDataRange:a,row:E,col:S,showCircle:l,streakIn:h,streakOut:d,annotation:g}),B++,ko&&(ko=!1)}let N=(S+1)*d,L=Kr().domain([-.5,6.5]).range([0,N]);if("circle"===i&&r.showCircle&&r.showStreak){let t="#69b3a2";r.circleColor?t=r.circleColor:r.color&&(t=r.color),e.dataArea.selectAll("streakIn").data(_.filter((function(t){return t.streakIn}))).enter().append("rect").attr("x",(function(t){return L(t.col)-g-p})).attr("y",(function(t){return L(t.row)-1.5})).attr("width",p).attr("height",3).style("fill",(function(e){return e.showCircle?r.circleColorByValue?null!==e.scaledValue?kr("white",t)(.8*e.scaledValue+.2):"none":t:"none"})).style("opacity",(function(t){return t.isOutOfDataRange||r.dimNotInMonth&&!t.isInThisMonth?.2:1})),e.dataArea.selectAll("streakOut").data(_.filter((function(t){return t.streakOut}))).enter().append("rect").attr("x",(function(t){return L(t.col)+g})).attr("y",(function(t){return L(t.row)-1.5})).attr("width",p).attr("height",3).style("fill",(function(e){return e.showCircle?r.circleColorByValue?null!==e.scaledValue?kr("white",t)(.8*e.scaledValue+.2):"none":t:"none"})).style("opacity",(function(t){return t.isOutOfDataRange||r.dimNotInMonth&&!t.isInThisMonth?.2:1}))}let V="#69b3a2";r.circleColor?V=r.circleColor:r.color&&(V=r.color),"circle"===i&&r.showCircle&&e.dataArea.selectAll("dot").data(_).enter().append("circle").attr("r",g).attr("cx",(function(t){return L(t.col)})).attr("cy",(function(t){return L(t.row)})).style("fill",(function(t){if(t.showCircle){if(!r.circleColorByValue)return V;if(null!==t.scaledValue){return kr("white",V)(.8*t.scaledValue+.2)}return"none"}return"none"})).style("opacity",(function(t){return t.isOutOfDataRange||r.dimNotInMonth&&!t.isInThisMonth?.2:1})).style("cursor","default");let I=Jl(window.moment(),n.dateFormat);if("circle"===i&&r.showTodayRing){let t=e.dataArea.selectAll("todayRing").data(_.filter((function(t){return t.date===I}))).enter().append("circle").attr("r",.9*g).attr("cx",(function(t){return L(t.col)})).attr("cy",(function(t){return L(t.row)})).attr("class","tracker-month-today-circle").style("cursor","default");""!==r.todayRingColor?t.style("stroke",r.todayRingColor):t.style("stroke","white")}"circle"===i&&r.showSelectedRing&&e.dataArea.selectAll("selectedRing").data(_).enter().append("circle").attr("r",g).attr("cx",(function(t){return L(t.col)})).attr("cy",(function(t){return L(t.row)})).attr("id",(function(t){return"tracker-selected-circle-"+t.date})).attr("class","tracker-month-selected-circle").style("cursor","default").style("stroke","none"),e.dataArea.selectAll("dayLabel").data(_).enter().append("text").text((function(t){return t.dayInMonth.toString()})).attr("transform",(function(t){return"translate("+L(t.col)+","+(L(t.row)+f.height/4)+")"})).style("fill-opacity",(function(t){return t.isOutOfDataRange||r.dimNotInMonth&&!t.isInThisMonth?.2:1})).attr("date",(function(t){return t.date})).attr("value",(function(t){return t.value})).attr("valueType",(function(t){return Ki[o.valueType]})).attr("class","tracker-month-label").on("click",(function(t){Co(e,r);let n=jt(this).attr("date");if(r.selectedDate=n,r.showSelectedRing&&e.dataArea.select("#tracker-selected-circle-"+n).style("stroke",r.selectedRingColor),r.showSelectedValue){let t=jt(this).attr("value"),n="";if("Time"===jt(this).attr("valueType")){n=window.moment("00:00","HH:mm",!0).add(parseFloat(t),"seconds").format("HH:mm")}else n=t;e.monitor.text(n)}})).style("cursor","pointer"),"annotation"===i&&M&&e.dataArea.selectAll("dayAnnotation").data(_).enter().append("text").text((function(t){return t.annotation})).attr("transform",(function(t){let e=L(t.col),n=L(t.row)+f.height/4;return t.annotation&&(n+=g),"translate("+e+","+n+")"})).attr("class","tracker-month-annotation");let Y=parseFloat(e.svg.attr("width")),P=parseFloat(e.svg.attr("height")),z=parseFloat(e.graphArea.attr("width")),O=parseFloat(e.graphArea.attr("height")),U=7*d+parseFloat(e.header.attr("height")),R=7*d;U>P&&lo(e.svg,0,U-P),R>Y&&lo(e.svg,R-Y,0),U>O&&lo(e.graphArea,0,U-O),R>z&&lo(e.svg,R-z,0)}function So(t,e,n,r,a){n&&Eo&&(Fo(t,e=To(e,t,n),n,r,a),_o(0,e,n,r,a))}function Eo(t,e,n){if(!e||!Eo)return;n.dataset;let r=0;for(let t of e.datasets)t.getQuery().usedAsXDataset||r++;if(0===r)return"No available dataset found";if(Mo(e,n),null===n.selectedDataset)return"No available dataset found";let a={};a=To(a,t,e);let i=null;if(n.initMonth){if(i=Zl(n.initMonth,e.dateFormat),!i){let t=window.moment(n.initMonth,"YYYY-MM",!0);if(!t.isValid())return"Invalid initMonth";i=t}}else i=e.datasets.getDates().last();i&&(Fo(t,a,e,n,i),_o(0,a,e,n,i),function(t,e,n){let r=jt(t),a=e.svg,i=parseFloat(a.attr("width")),l=parseFloat(a.attr("height"));a.attr("width",null).attr("height",null).attr("viewBox",`0 0 ${i} ${l}`).attr("preserveAspectRatio","xMidYMid meet"),n.fitPanelWidth?r.style("width","100%"):(r.style("width",(i*n.fixedScale).toString()+"px"),r.style("height",(l*n.fixedScale).toString()+"px"))}(t,a,e))}function Bo(t,e,n){if(e&&Bo)return"Under construction"}function No(t,e,n){if(!e||!n)return;let r=parseFloat(n.dataset);e.datasets.getDatasetById(r),"horizontal"===n.orientation?e.dataAreaSize={width:250,height:24}:"vertical"===n.orientation&&(e.dataAreaSize={width:24,height:250});let a=function(t,e,n){let r={};if(!e||!n)return;let a=jt(t).append("svg").attr("id","svg").attr("width",e.dataAreaSize.width+e.margin.left+e.margin.right).attr("height",e.dataAreaSize.height+e.margin.top+e.margin.bottom);r.svg=a;let i=a.append("g").attr("id","graphArea").attr("transform","translate("+e.margin.left+","+e.margin.top+")").attr("width",e.dataAreaSize.width+e.margin.right).attr("height",e.dataAreaSize.height+e.margin.bottom);r.graphArea=i;let l=i.append("g").attr("id","dataArea").attr("width",e.dataAreaSize.width).attr("height",e.dataAreaSize.height);return r.dataArea=l,r}(t,e,n),i=function(t,e,n,r){if(!e||!n)return;let a=n.range,i=a[a.length-1],l=[0,i],o=n.valueUnit,u=function(t){return o&&o.endsWith("%")?Zr(0,i,7)(t)+" %":Zr(0,i,7)(t)},s=io(u(i),"tracker-tick-label");if("horizontal"===n.orientation){let n=Kr();n.domain(l).range([0,e.dataAreaSize.width]),t.scale=n;let r=T(n);r.tickFormat(u);let a=t.dataArea.append("g").attr("id","axis").attr("transform","translate(0,"+e.dataAreaSize.height+")").call(r).attr("class","tracker-axis");t.axis=a,a.selectAll("path").style("stroke","none"),a.selectAll("line"),a.selectAll("text").attr("class","tracker-tick-label"),a.attr("width",e.dataAreaSize.width+s.width),a.attr("height",6+s.height),lo(t.svg,+s.width,6+s.height),lo(t.graphArea,+s.width,6+s.height)}else if("vertical"===n.orientation){let n=Kr();n.domain(l).range([e.dataAreaSize.height,0]),t.scale=n;let r=C(n);r.tickFormat(u);let a=t.dataArea.append("g").attr("id","axis").attr("x",0).attr("y",0).call(r).attr("class","tracker-axis");t.axis=a,a.selectAll("path").style("stroke","none"),a.selectAll("line"),a.selectAll("text").attr("class","tracker-tick-label"),a.attr("width",6+s.width),a.attr("height",e.dataAreaSize.width),lo(t.svg,6+s.width,0),lo(t.graphArea,6+s.width,0),oo(t.dataArea,6+s.width,0)}}(a,e,n);if("string"==typeof i)return i;!function(t,e,n){if(!e||!n)return;if(n.title){let r=io(n.title,"tracker-title-small");if("horizontal"===n.orientation){let a=t.graphArea.append("text").text(n.title).attr("id","title").attr("x",r.width/2).attr("y",e.dataAreaSize.height/2).attr("height",r.height).attr("class","tracker-title-small");t.title=a,lo(t.svg,r.width+6,0),lo(t.graphArea,r.width+6,0),oo(t.dataArea,r.width+6,0)}else if("vertical"===n.orientation){let a=e.dataAreaSize.width/2;r.width>e.dataAreaSize.width&&(lo(t.svg,r.width-e.dataAreaSize.width,0),lo(t.graphArea,r.width-e.dataAreaSize.width,0),oo(t.dataArea,r.width/2-e.dataAreaSize.width/2,0),a=r.width/2);let i=parseFloat(t.axis.attr("width")),l=t.graphArea.append("text").text(n.title).attr("id","title").attr("x",a+i).attr("y",r.height/2).attr("height",r.height).attr("class","tracker-title-small");t.title=l,lo(t.svg,0,r.height+6),lo(t.graphArea,0,r.height+6),oo(t.dataArea,0,r.height+6)}}if(n.valueUnit){let r=io(n.valueUnit,"tracker-tick-label");if("horizontal"===n.orientation){let a=t.dataArea.append("text").text(n.valueUnit).attr("id","unit").attr("x",-1*(r.width+6)).attr("y",e.dataAreaSize.height+6).attr("height",r.height).attr("class","tracker-tick-label");t.unit=a}else if("vertical"===n.orientation){let a=t.dataArea.append("text").text(n.valueUnit).attr("id","unit").attr("x",e.dataAreaSize.width/2-r.width/2).attr("y",-(r.height/2+6)).attr("height",r.height).attr("class","tracker-tick-label");t.unit=a,lo(t.svg,0,r.height+6),lo(t.graphArea,0,r.height+6),oo(t.dataArea,0,r.height+6)}}}(a,e,n),function(t,e,n,r){if(!e||!n)return;let a=t.scale,i=n.range,l=n.rangeColor,o=[],u=0;for(let t=0;t=e&&(n=r=e):(n>e&&(n=e),r=i&&(n=r=i):(n>i&&(n=i),ro)&&(o=e.getYMax()),s=e.valueType===Ki.Time,null===u)u=s;else if(s!==u)return"Not all values in time format"}let f=null;"left"===r?f=n.yMin[0]:"right"===r&&(f=n.yMin[1]);let c=!1;"number"!=typeof f?f=l:c=!0;let h=null;"left"===r?h=n.yMax[0]:"right"===r&&(h=n.yMax[1]);let d=!1;if("number"!=typeof h?h=o:d=!0,h0&&(g=0));let w=[g,p];("left"===r&&n.reverseYAxis[0]||"right"===r&&n.reverseYAxis[1])&&(w=[p,g]),v.domain(w).range([e.dataAreaSize.height,0]),"left"===r?t.leftYScale=v:"right"===r&&(t.rightYScale=v);let x="";"left"===r?x=n.yAxisColor[0]:"right"===r&&(x=n.yAxisColor[1]);let A="";"left"===r?A=n.yAxisLabelColor[0]:"right"===r&&(A=n.yAxisLabelColor[1]);let b="";"left"===r?b=n.yAxisLabel[0]:"right"===r&&(b=n.yAxisLabel[1]);let D="",k=null,T=null;"left"===r?(D=n.yAxisUnit[0],k=n.yAxisTickInterval[0],T=n.yAxisTickLabelFormat[0]):"right"===r&&(D=n.yAxisUnit[1],k=n.yAxisTickInterval[1],T=n.yAxisTickLabelFormat[1]);let F,_=null;if(s?_=Ql(k):(_=parseFloat(k),Number.isNumber(_)&&!Number.isNaN(_)||(_=null)),"left"===r?F=C(v):"right"===r&&(F=M(2,v)),F){let t=function(t,e,n,r=!1){if(r){if(n){function t(t){return window.moment("00:00","HH:mm",!0).add(t,"seconds").format(n)}return t}{function n(n){const r=Math.abs(e-t);let a=window.moment("00:00","HH:mm",!0).add(n,"seconds").format("HH:mm");if(r>43200){let r=(n-t)/3600%2;(ne||r<1)&&(a="")}return a}return n}}if(n){function t(t){return fo.sprintf("%"+n,t)}return t}return Zr(t,e,10)}(g,p,T,s);t&&F.tickFormat(t);let e=function(t,e,n,r=!1){const a=Math.abs(e-t);let i=[];r?i=n&&window.moment.isDuration(n)?y(t,e,Math.abs(n.asSeconds())):a>18e3?y(t=3600*Math.floor(t/3600),e=3600*Math.ceil(e/3600),3600):y(t=1800*Math.floor(t/1800),e=1800*Math.ceil(e/1800),1800):n&&"number"==typeof n&&(i=y(t,e,n));return 0===i.length?null:i}(g,p,_,s);e&&F.tickValues(e)}let S=t.dataArea.append("g").attr("id","yAxis").call(F).attr("class","tracker-axis");"right"==r&&S.attr("transform","translate("+e.dataAreaSize.width+" ,0)"),"left"===r?t.leftYAxis=S:"right"===r&&(t.rightYAxis=S);let E=S.selectAll("path");x&&E.style("stroke",x);let B=S.selectAll("line");x&&B.style("stroke",x);let N=S.selectAll("text").attr("class","tracker-tick-label");x&&N.style("fill",x);let L=0;for(let t of N)if(t.textContent){let e=io(t.textContent,"tracker-axis-label");e.width>L&&(L=e.width)}""!==D&&(b+=" ("+D+")");let V=io(b),I=S.append("text").text(b).attr("transform","rotate(-90)").attr("x",-1*e.dataAreaSize.height/2).attr("class","tracker-axis-label");"left"===r?I.attr("y",-6-L-V.height/2):I.attr("y",6+L+V.height),A&&I.style("fill",A);let Y=V.height+L+6;S.attr("width",Y),lo(t.svg,Y,0),lo(t.graphArea,Y,0),"left"===r&&(oo(t.dataArea,Y,0),t.title&&oo(t.title,Y,0))}function Io(t,e,n,r,a){if(!e||!n)return;let i=null;if("left"===a?i=t.leftYScale:"right"===a&&(i=t.rightYScale),n.showLine[r.getId()]){let e=function(t,e){var n=Qi(!0),r=null,a=bl,i=null;function l(l){var o,u,s,f=(l=xl(l)).length,c=!1;for(null==r&&(i=a(s=or())),o=0;o<=f;++o)!(o0&&(a.style("stroke",n.pointBorderColor[r.getId()]),a.style("stroke-width",n.pointBorderWidth[r.getId()]))),n.allowInspectData&&function(t,e,n){let r=e.dataArea.append("svg").style("opacity",0),a=r.append("rect").attr("x",0).attr("y",0),i=r.append("text"),l=i.append("tspan").attr("class","tracker-tooltip-label"),o=i.append("tspan").attr("class","tracker-tooltip-label"),u=3,s=3;t.on("mouseenter",(function(t){const[e,f]=function(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(e.getScreenCTM().inverse())).x,r.y]}if(e.getBoundingClientRect){var a=e.getBoundingClientRect();return[t.clientX-a.left-e.clientLeft,t.clientY-a.top-e.clientTop]}}return[t.pageX,t.pageY]}(t);let c=0,h=0,d="date: "+jt(this).attr("date"),g=io(d,"tracker-tooltip-label");l.text(d),g.width>c&&(c=g.width),h+=g.height,l.attr("x",u).attr("y",h);let p="value: ",y=jt(this).attr("valueType"),m=jt(this).attr("value");if("Time"===y){p+=window.moment("00:00","HH:mm",!0).add(parseFloat(m),"seconds").format("HH:mm"),o.text(p)}else p+=m,o.text(p);let v=io(p,"tracker-tooltip-label");v.width>c&&(c=v.width),h+=s+v.height,o.attr("x",u).attr("y",h),c+=2*u,h+=2*s,i.attr("width",c).attr("height",h),a.attr("width",c).attr("height",h).attr("class","tracker-tooltip");let w=e,x=f,A=12,b=12;w=e+A+c>n.dataAreaSize.width?e-c-A:e+A,x=f-b-h<0?f+b:f-b-h,r.attr("x",w).attr("y",x),r.transition().duration(200).style("opacity",1)})).on("mouseleave",(function(){r.transition().duration(500).style("opacity",0)}))}(a,t,e)}}function Po(t,e,n,r,a,i,l){if(!e||!n)return;let o=e.dataAreaSize.width/r.getLength(),u=o;o-1>0&&(u=o-1),u/=l;let s=null;"left"===a?s=t.leftYScale:"right"===a&&(s=t.rightYScale);let f=t.dataArea.selectAll("bar").data(Array.from(r).filter((function(t){return null!==t.value}))).enter().append("rect").attr("x",(function(e,n){if(0===n){let n=i+1-l/2;if(n<1)return t.xScale(e.date)-o/2+i*u+n*u}return t.xScale(e.date)-o/2+i*u})).attr("y",(function(t){return s(Math.max(t.value,0))})).attr("width",(function(t,e){if(0===e){let t=i+1-l/2;return t<0?0:t<1?u*t:u}if(e===r.getLength()-1){let t=1-(i+1-l/2);return t<0?0:t<1?u*t:u}return u})).attr("height",(function(t){if(null!==t.value)return Math.abs(s(t.value)-s(0))})).attr("class","tracker-bar");n.barColor[r.getId()]&&f.style("fill",n.barColor[r.getId()])}function zo(t,e,n){let r=t.svg;t.graphArea;let a=t.dataArea,i=t.title,l=t.xAxis,o=t.leftYAxis,u=t.rightYAxis,s=0;i&&(s=parseFloat(i.attr("height")));let f=parseFloat(l.attr("height")),c=0;o&&(c=parseFloat(o.attr("width")));let h=0;u&&(h=parseFloat(u.attr("width")));let d=e.datasets,g=d.getXDatasetIds(),p=d.getNames(),y=p.map((function(t){return io(t,"tracker-legend-label")})),v=0,w=0;for(let t=0;tw&&(w=y[t].width,v=t);let x=w/p[v].length,A=y[v].height,b=p.length-g.length,D=2*x,k=A,M=2*x,T=0,C=0;"vertical"===n.legendOrientation?(T=3*D+M+w,C=(b+1)*k):"horizontal"===n.legendOrientation&&(T=(2*D+M)*b+D+m(y,(function(t,e){return g.includes(e)?0:t.width})),C=k+A);let F=0,_=0;if("top"===n.legendPosition)F=c+e.dataAreaSize.width/2-T/2,_=s,lo(r,0,C+k),oo(a,0,C+k);else if("bottom"===n.legendPosition)F=c+e.dataAreaSize.width/2-T/2,_=s+e.dataAreaSize.height+f+k,lo(r,0,C+k);else if("left"===n.legendPosition)F=0,_=s+e.dataAreaSize.height/2-C/2,lo(r,T+D,0),oo(a,T+D,0);else{if("right"!==n.legendPosition)return;F=e.dataAreaSize.width+c+h+D,_=s+e.dataAreaSize.height/2-C/2,lo(r,T+D,0)}let S=t.graphArea.append("g").attr("id","legend").attr("transform","translate("+F+","+_+")"),E=S.append("rect").attr("class","tracker-legend").attr("width",T).attr("height",C);n.legendBgColor&&E.style("fill",n.legendBgColor),n.legendBorderColor&&E.style("stroke",n.legendBorderColor);let B=D,N=A,L=B+D+M,V=N;if("vertical"===n.legendOrientation){n.GetGraphType()===Ji.Line?(S.selectAll("markers").data(p).enter().append("line").attr("x1",B).attr("x2",B+M).attr("y1",(function(t,e){let n=g.filter((t=>ttttt!g.includes(e)))).enter().append("rect").attr("x",(function(t,e){let n=D;for(let[t,r]of y.entries())if(!g.includes(t)){if(!(ti.length;)i.push(r);if(null==e);else if("object"==typeof e&&null!==e){if(Array.isArray(e)){if(e.length>n)return l="Too many inputs for parameter '"+t+"'",l;if(0===e.length)return l="Empty array not allowd for "+t,l;for(let n=0;n0&&(u=e[n-1].trim()),"string"==typeof a){if(a=a.trim(),""!==a){l="Invalid inputs for "+t;break}i[n]=null!==u?u:r}else{if("boolean"!=typeof a){l="Invalid inputs for "+t;break}i[n]=a,o++}}else{let t=e[e.length-1];i[n]=o>0?t:r}}}else if("string"==typeof e){let a=Go(e);if(a.length>1){if(a.length>n)return l="Too many inputs for parameter '"+t+"'",l;for(let e=0;e0&&(u=Ho(a[e-1].trim())),""===n)i[e]=null!==u?u:r;else{let r=Ho(n);if(null===r){l="Invalid inputs for "+t;break}i[e]=r,o++}}else{let t=Ho(a[a.length-1].trim());i[e]=o>0&&null!==t?t:r}}else if(""===e);else{let n=Ho(e);if(null!==n){i[0]=n,o++;for(let t=1;ti.length;)i.push(r);if(null==e);else if("object"==typeof e&&null!==e){if(Array.isArray(e)){if(e.length>n)return l="Too many inputs for parameter '"+t+"'",l;if(0===e.length)return l="Empty array not allowd for "+t,l;for(let n=0;n0&&(u=e[n-1].trim()),"string"==typeof a){if(a=a.trim(),""!==a){l="Invalid inputs for "+t;break}i[n]=null!==u?u:r}else{if("number"!=typeof a){l="Invalid inputs for "+t;break}i[n]=a,o++}}else{let t=e[e.length-1];i[n]=o>0?t:r}}}else if("string"==typeof e){let a=Go(e);if(a.length>1){if(a.length>n)return l="Too many inputs for parameter '"+t+"'",l;for(let n=0;n0&&(u=ao(a[n-1].trim()).value),""===e)null!==u&&Number.isNumber(u)?i[n]=u:i[n]=r;else{let r=ao(e).value;if(null===r){l="Invalid inputs for "+t;break}i[n]=r,o++}}else{let t=ao(a[e.length-1].trim()).value;i[n]=o>0&&null!==t?t:r}}else if(""===e);else{let n=ao(e).value;if(null!==n){i[0]=n,o++;for(let t=1;tl.length;)l.push(r);if(null==e);else if("object"==typeof e&&null!==e){if(Array.isArray(e)){if(e.length>n)return o="Too many inputs for parameter '"+t+"'",o;if(0===e.length)return o="Empty array not allowd for "+t,o;for(let n=0;n0&&(s=e[n-1].trim()),"string"!=typeof i){o="Invalid inputs for "+t;break}if(i=i.trim(),""===i)l[n]=null!==s?s:r;else if(a){if(!a(i)){o="Invalid inputs for "+t;break}l[n]=i,u++}else l[n]=i,u++}else{let t=e[e.length-1].trim();l[n]=u>0?t:r}}}else if("string"==typeof e){let i=Go(e);if(i.length>1){if(i.length>n)return o="Too many inputs for parameter '"+t+"'",o;for(let e=0;e0&&(s=i[e-1].trim()),""===n)l[e]=null!==s?s:r;else if(a){if(!a(n)){o="Invalid inputs for "+t;break}l[e]=n,u++}else l[e]=n,u++}else{let t=i[i.length-1].trim();l[e]=u>0?t:r}}else if(""===e);else if(a)if(a(e)){l[0]=e,u++;for(let t=1;t1)for(let e of r){let r=parseFloat(e.trim());if(Number.isNaN(r)){return`Parameter '${t}' accepts only numbers`}n.push(r)}else{if(""===e){return`Empty ${t} is not allowed.`}{let r=parseFloat(e);if(!Number.isNumber(r)){return`Parameter '${t}' accepts only numbers`}n.push(r)}}}else{if("number"!=typeof e){return`Invalid ${t}`}n.push(e)}return n}function eu(t,e){let n=[];if(null==e)return n;if("object"==typeof e){if(Array.isArray(e))for(let t of e)"string"==typeof t&&n.push(t.trim())}else{if("string"!=typeof e){return`Invalid ${t}`}{let r=Go(e);if(r.length>1)for(let t of r)n.push(t.trim());else{if(""===e){return`Empty ${t} is not allowed.`}n.push(e)}}}for(let t=0;t2)return"yAxisLabel accepts not more than two values for left and right y-axes";e.yAxisLabel=n;let r=Ko("yAxisColor",null==t?void 0:t.yAxisColor,2,"",qo,!0);if("string"==typeof r)return r;if(r.length>2)return"yAxisColor accepts not more than two values for left and right y-axes";e.yAxisColor=r;let a=Ko("yAxisLabelColor",null==t?void 0:t.yAxisLabelColor,2,"",qo,!0);if("string"==typeof a)return a;if(a.length>2)return"yAxisLabelColor accepts not more than two values for left and right y-axes";e.yAxisLabelColor=a;let i=Ko("yAxisUnit",null==t?void 0:t.yAxisUnit,2,"",null,!0);if("string"==typeof i)return i;if(i.length>2)return"yAxisUnit accepts not more than two values for left and right y-axes";e.yAxisUnit=i,e.xAxisTickInterval=Jo(null==t?void 0:t.xAxisTickInterval,e.xAxisTickInterval);let l=Ko("yAxisTickInterval",null==t?void 0:t.yAxisTickInterval,2,null,null,!0);if("string"==typeof l)return l;if(l.length>2)return"yAxisTickInterval accepts not more than two values for left and right y-axes";e.yAxisTickInterval=l,e.xAxisTickLabelFormat=Jo(null==t?void 0:t.xAxisTickLabelFormat,e.xAxisTickLabelFormat);let o=Ko("yAxisTickLabelFormat",null==t?void 0:t.yAxisTickLabelFormat,2,null,null,!0);if("string"==typeof o)return o;if(o.length>2)return"yAxisTickLabelFormat accepts not more than two values for left and right y-axes";e.yAxisTickLabelFormat=o;let u=Zo("yMin",null==t?void 0:t.yMin,2,null,!0);if("string"==typeof u)return u;if(u.length>2)return"yMin accepts not more than two values for left and right y-axes";e.yMin=u;let s=Zo("yMax",null==t?void 0:t.yMax,2,null,!0);if("string"==typeof s)return s;if(s.length>2)return"yMax accepts not more than two values for left and right y-axes";e.yMax=s;let f=Qo("reverseYAxis",null==t?void 0:t.reverseYAxis,2,!1,!0);return"string"==typeof f?f:f.length>2?"reverseYAxis accepts not more than two values for left and right y-axes":void(e.reverseYAxis=f)}function ru(t){let e=[];if(null!==t){const n=Object.keys(t);for(let t of n)e.push(t.toString())}return e}function au(t,e){return ql(jl(t.basename,e.dateFormatPrefix,e.dateFormatSuffix),e.dateFormat)}function iu(t,e,n){let r=window.moment(""),a=t.frontmatter;if(a&&eo(a,e.getTarget())){let t=eo(a,e.getTarget());"string"==typeof t&&(t=jl(t,n.dateFormatPrefix,n.dateFormatSuffix),r=ql(t,n.dateFormat))}return r}function lu(t,e,n){let r,a=window.moment(""),i=new RegExp(e,"gm");for(;r=i.exec(t);)if(void 0!==r.groups&&void 0!==r.groups.value){let t=r.groups.value.trim();if(t=jl(t,n.dateFormatPrefix,n.dateFormatSuffix),a=ql(t,n.dateFormat),a.isValid())return a}return a}function ou(t,e,n){window.moment("");let r=e.getTarget();return e.getParentTarget()&&(r=e.getParentTarget()),lu(t,"(^|\\s)#"+r+"(\\/[\\w-]+)*(:(?[\\d\\.\\/-]*)[a-zA-Z]*)?([\\.!,\\?;~-]*)?(\\s|$)",n)}function uu(t,e,n){return window.moment(""),lu(t,e.getTarget(),n)}function su(t,e,n){window.moment("");let r=e.getTarget();return e.getParentTarget()&&(r=e.getParentTarget()),r=r.replace("-","[\\s\\-]"),lu(t,"(^| |\\t)\\*{0,2}"+r+"\\*{0,2}(::[ |\\t]*(?[\\d\\.\\/\\-\\w,@; \\t:]*))(\\r\\?\\n|\\r|$)",n)}function fu(e,n,r){let a=window.moment("");if(e&&e instanceof t.TFile){let t=n.getTarget();if("cDate"===t){a=Kl(e.stat.ctime,r.dateFormat)}else if("mDate"===t){a=Kl(e.stat.mtime,r.dateFormat)}else"name"===t&&(a=au(e,r))}return a}function cu(t,e,n){window.moment("");let r=e.getType(),a=e.getTarget();return a=r===Zi.Task?"\\[[\\sx]\\]\\s"+a:r===Zi.TaskDone?"\\[x\\]\\s"+a:r===Zi.TaskNotDone?"\\[\\s\\]\\s"+a:"\\[[\\sx]\\]\\s"+a,lu(t,a,n)}function hu(t,e,n,r){if(t.has(e)){t.get(e).push({query:n,value:r})}else{let a=new Array;a.push({query:n,value:r}),t.set(e,a)}}function du(t,e,n,r,a,i){let l,o=new RegExp(e,"gm"),u=0,s=!1;for(;l=o.exec(t);)if(i.ignoreAttachedValue[n.getId()])u+=i.constValue[n.getId()],s=!0,n.addNumTargets();else if(void 0!==l.groups&&void 0!==l.groups.value){let t=l.groups.value.trim().split(n.getSeparator());if(!t)continue;if(1===t.length){let e=ao(t[0].trim(),i.textValueMap);null!==e.value&&(e.type===Ki.Time?(u=e.value,s=!0,n.valueType=Ki.Time,n.addNumTargets()):i.ignoreZeroValue[n.getId()]&&0===e.value||(u+=e.value,s=!0,n.addNumTargets()))}else if(t.length>n.getAccessor()&&n.getAccessor()>=0){let e=ao(t[n.getAccessor()].trim(),i.textValueMap);null!==e.value&&(e.type===Ki.Time?(u=e.value,s=!0,n.valueType=Ki.Time,n.addNumTargets()):(u+=e.value,s=!0,n.addNumTargets()))}}else u+=i.constValue[n.getId()],s=!0,n.addNumTargets();if(s){return hu(r,a.get(i.xDataset[n.getId()]),n,u),!0}return!1}function gu(e,n,r,a,i,l){if(e&&e instanceof t.TFile){let t=r.getTarget(),o=l.get(a.xDataset[r.getId()]);if("cDate"===t){let t=e.stat.ctime;return r.valueType=Ki.Date,r.addNumTargets(),hu(i,o,r,t),!0}if("mDate"===t){let t=e.stat.mtime;return r.valueType=Ki.Date,r.addNumTargets(),hu(i,o,r,t),!0}if("size"===t){let t=e.stat.size;return r.addNumTargets(),hu(i,o,r,t),!0}if("numWords"===t){return hu(i,o,r,function(t){t=uo(t);var e=new RegExp(["(?:[0-9]+(?:(?:,|\\.)[0-9]+)*|[\\-"+/A-Za-z\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC/.source+"])+",/[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u4E00-\u9FD5]{1}/.source].join("|"),"g");return(t.match(e)||[]).length}(n)),!0}if("numChars"===t){let t=n.length;return r.addNumTargets(),hu(i,o,r,t),!0}if("numSentences"===t){let t=function(t){return(((t=uo(t))||"").match(/[^.。!!??\s][^.。!!??]*(?:[.!?](?!['‘’"“”「」『』]?\s|$)[^.。!!??]*)*[.。!!??]?['’"”」』]?(?=\s||$)/gm)||[]).length}(n);return r.addNumTargets(),hu(i,o,r,t),!0}if("name"===t){let t=0,n=!1,l=ao(e.basename,a.textValueMap);null!==l.value&&(l.type===Ki.Time?(t=l.value,n=!0,r.valueType=Ki.Time,r.addNumTargets()):a.ignoreZeroValue[r.getId()]&&0===l.value||(t+=l.value,n=!0,r.addNumTargets()));let u=null;if(n&&(u=t),null!==u)return hu(i,o,r,u),!0}}return!1}const pu={folder:"/",dateFormat:"YYYY-MM-DD"};class yu extends t.PluginSettingTab{constructor(t,e){super(t,e),this.plugin=e}display(){let{containerEl:n}=this;n.empty(),new t.Setting(n).setName("Default folder location").setDesc("Files in this folder will be parsed and used as input data of the tracker plugin.\nYou can also override it using 'folder' argument in the tracker codeblock.").addText((t=>t.setPlaceholder("Folder Path").setValue(this.plugin.settings.folder).onChange((t=>e(this,void 0,void 0,(function*(){this.plugin.settings.folder=t,yield this.plugin.saveSettings()})))))),new t.Setting(n).setName("Default date format").setDesc("This format is used to parse the date in your diary title.\nYou can also override it using 'date-format' argument in the tracker codeblock.").addText((t=>t.setPlaceholder("YYYY-MM-DD").setValue(this.plugin.settings.dateFormat).onChange((t=>e(this,void 0,void 0,(function*(){this.plugin.settings.dateFormat=t,yield this.plugin.saveSettings()}))))))}}class mu extends t.Plugin{onload(){return e(this,void 0,void 0,(function*(){console.log("loading obsidian-tracker plugin"),yield this.loadSettings(),this.addSettingTab(new yu(this.app,this)),this.registerMarkdownCodeBlockProcessor("tracker",this.postprocessor.bind(this)),this.addCommand({id:"add-line-chart-tracker",name:"Add Line Chart Tracker",callback:()=>this.addCodeBlock(Ji.Line)}),this.addCommand({id:"add-bar-chart-tracker",name:"Add Bar Chart Tracker",callback:()=>this.addCodeBlock(Ji.Bar)}),this.addCommand({id:"add-summary-tracker",name:"Add Summary Tracker",callback:()=>this.addCodeBlock(Ji.Summary)})}))}loadSettings(){return e(this,void 0,void 0,(function*(){this.settings=Object.assign({},pu,yield this.loadData())}))}saveSettings(){return e(this,void 0,void 0,(function*(){yield this.saveData(this.settings)}))}renderErrorMessage(t,e,n){!function(t,e){jt(t).select("#svg").remove(),jt(t).append("div").text(e).style("background-color","white").style("margin-bottom","20px").style("padding","10px").style("color","red")}(e,t),n.appendChild(e)}onunload(){console.log("unloading obsidian-tracker plugin")}getFilesInFolder(e,n=!0){let r=[];for(let a of e.children)a instanceof t.TFile?"md"===a.extension&&r.push(a):a instanceof t.TFolder&&n&&(r=r.concat(this.getFilesInFolder(a)));return r}getFiles(n,r,a=!0){return e(this,void 0,void 0,(function*(){if(!n)return;let e=r.folder,a=r.specifiedFilesOnly,i=r.file,l=r.fileContainsLinkedFiles,o=r.fileMultiplierAfterLink;if(!a){let r=this.app.vault.getAbstractFileByPath(t.normalizePath(e));if(r&&r instanceof t.TFolder){let t=this.getFilesInFolder(r);for(let e of t)n.push(e)}}for(let e of i){let r=e;r.endsWith(".md")||(r+=".md"),r=t.normalizePath(r);let a=this.app.vault.getAbstractFileByPath(r);a&&a instanceof t.TFile&&n.push(a)}let u=1,s=!0;""===o?s=!1:/^[0-9]+$/.test(o)?(u=parseFloat(o),s=!1):/\?/.test(o)||(s=!1);for(let e of l){e.endsWith(".md")||(e+=".md");let a=this.app.vault.getAbstractFileByPath(t.normalizePath(e));if(a&&a instanceof t.TFile){let i=this.app.metadataCache.getFileCache(a),l=(yield this.app.vault.adapter.read(a.path)).split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/);if(!(null==i?void 0:i.links))continue;for(let a of i.links){if(!a)continue;let i=this.app.metadataCache.getFirstLinkpathDest(a.link,e);if(i&&i instanceof t.TFile){if(s){let t=a.position.end.line;if(t>=0&&t1)for(let e of t){if(e=e.trim(),""===e){i="Empty search target is not allowed.";break}l.push(e)}else""===r.searchTarget?i="Empty search target is not allowed.":l.push(r.searchTarget)}else i="Invalid search target (searchTarget)";for(let t=0;tt!==Zi.Table)).length>0)return"searchType 'table' doestn't work with other types for now";let f=[],c=Ko("separator",r.separator,o,"",null,!0);if("string"==typeof c)return c;f=c.map((t=>"comma"===t||"\\,"===t?",":t));let h=Zo("xDataset",r.xDataset,o,-1,!0);if("string"==typeof h)return h;let d=h.map((t=>t<0||t>=o?-1:t)),g=[];for(let t=0;tt.getId()===e)))return i="Duplicated dataset id for key '"+t+"'",i;M.push(t),m.push(t)}for(let t of a)if(!y.includes(t)&&!m.includes(t))return i="'"+t+"' is not an available key",i;if(0===v.length+w.length+x.length+A.length+k.length+b.length+D.length)return"No output parameter provided, please place line, bar, pie, month, bullet, or summary.";"string"==typeof r.folder?""===r.folder?p.folder=n.settings.folder:p.folder=r.folder:p.folder=n.settings.folder;let T=n.app.vault.getAbstractFileByPath(t.normalizePath(p.folder));if(!(T&&T instanceof t.TFolder))return"Folder '"+p.folder+"' doesn't exist";if("string"==typeof r.file){let t=eu("file",r.file);if("string"==typeof t)return t;p.file=t}if("boolean"==typeof r.specifiedFilesOnly&&(p.specifiedFilesOnly=r.specifiedFilesOnly),"string"==typeof r.fileContainsLinkedFiles){let t=eu("fileContainsLinkedFiles",r.fileContainsLinkedFiles);if("string"==typeof t)return t;p.fileContainsLinkedFiles=t}p.fileMultiplierAfterLink=Jo(null==r?void 0:r.fileMultiplierAfterLink,p.fileMultiplierAfterLink);const C=r.dateFormat;if("string"==typeof r.dateFormat?""===r.dateFormat?p.dateFormat=n.settings.dateFormat:p.dateFormat=C:p.dateFormat=n.settings.dateFormat,p.dateFormatPrefix=Jo(null==r?void 0:r.dateFormatPrefix,p.dateFormatPrefix),p.dateFormatSuffix=Jo(null==r?void 0:r.dateFormatSuffix,p.dateFormatSuffix),"string"==typeof r.startDate){if(/^([\-]?[0-9]+[\.][0-9]+|[\-]?[0-9]+)m$/.test(r.startDate))return"'m' for 'minute' is too small for parameter startDate, please use 'd' for 'day' or 'M' for month";let t=jl(r.startDate,p.dateFormatPrefix,p.dateFormatSuffix),e=null,n=!1;if(e=Zl(t,p.dateFormat),e?n=!0:(e=ql(t,p.dateFormat),e.isValid()&&(n=!0)),!n||null===e)return"Invalid startDate, the format of startDate may not match your dateFormat "+p.dateFormat;p.startDate=e}if("string"==typeof r.endDate){if(/^([\-]?[0-9]+[\.][0-9]+|[\-]?[0-9]+)m$/.test(r.endDate))return"'m' for 'minute' is too small for parameter endDate, please use 'd' for 'day' or 'M' for month";let t=jl(r.endDate,p.dateFormatPrefix,p.dateFormatSuffix),e=null,n=!1;if(e=Zl(t,p.dateFormat),e?n=!0:(e=ql(t,p.dateFormat),e.isValid()&&(n=!0)),!n||null===e)return"Invalid endDate, the format of endDate may not match your dateFormat "+p.dateFormat;p.endDate=e}if(null!==p.startDate&&p.startDate.isValid()&&null!==p.endDate&&p.endDate.isValid()&&p.endDate4)return"margin accepts not more than four values for top, right, bottom, and left margins.";p.margin=new Rl(Y[0],Y[1],Y[2],Y[3]);for(let t of M){let e=new Bl,n=r[t],a=ru(e),l=ru(n);for(let t of l)if(!a.includes(t))return i="'"+t+"' is not an available key",i;let o=-1,u=t.replace("dataset","");o=""===u?0:parseFloat(u),e.id=o,e.name=Jo(null==n?void 0:n.name,e.name);let s=eu("xData",null==n?void 0:n.xData);if("string"==typeof s)return s;e.xData=s;let f=e.xData.length,c=eu("yData",null==n?void 0:n.yData);if("string"==typeof c)return c;if(e.yData=c,e.yData.length!==f)return"Number of elements in xData and yData not matched";p.customDataset.push(e)}for(let t of v){let e=new Ll,n=r[t],a=ru(e),l=ru(n);for(let t of l)if(!a.includes(t))return i="'"+t+"' is not an available key",i;let u=nu(n,e);if("string"==typeof u)return u;let s=Ko("lineColor",null==n?void 0:n.lineColor,o,"",qo,!0);if("string"==typeof s)return s;e.lineColor=s;let f=Zo("lineWidth",null==n?void 0:n.lineWidth,o,1.5,!0);if("string"==typeof f)return f;e.lineWidth=f;let c=Qo("showLine",null==n?void 0:n.showLine,o,!0,!0);if("string"==typeof c)return c;e.showLine=c;let h=Qo("showPoint",null==n?void 0:n.showPoint,o,!0,!0);if("string"==typeof h)return h;e.showPoint=h;let d=Ko("pointColor",null==n?void 0:n.pointColor,o,"#69b3a2",qo,!0);if("string"==typeof d)return d;e.pointColor=d;let g=Ko("pointBorderColor",null==n?void 0:n.pointBorderColor,o,"#69b3a2",qo,!0);if("string"==typeof g)return g;e.pointBorderColor=g;let y=Zo("pointBorderWidth",null==n?void 0:n.pointBorderWidth,o,0,!0);if("string"==typeof y)return y;e.pointBorderWidth=y;let m=Zo("pointSize",null==n?void 0:n.pointSize,o,3,!0);if("string"==typeof m)return m;e.pointSize=m;let v=Qo("fillGap",null==n?void 0:n.fillGap,o,!1,!0);if("string"==typeof v)return v;e.fillGap=v;let w=Ko("yAxisLocation",null==n?void 0:n.yAxisLocation,o,"left",jo,!0);if("string"==typeof w)return w;e.yAxisLocation=w,p.line.push(e)}for(let t of w){let e=new Vl,n=r[t],a=ru(e),l=ru(n);for(let t of l)if(!a.includes(t))return i="'"+t+"' is not an available key",i;let u=nu(n,e);if("string"==typeof u)return u;let s=Ko("barColor",null==n?void 0:n.barColor,o,"",qo,!0);if("string"==typeof s)return s;e.barColor=s;let f=Ko("yAxisLocation",null==n?void 0:n.yAxisLocation,o,"left",jo,!0);if("string"==typeof f)return f;e.yAxisLocation=f,p.bar.push(e)}for(let t of x){let e=new Il,n=r[t],a=ru(e),l=ru(n);for(let t of l)if(!a.includes(t))return i="'"+t+"' is not an available key",i;e.title=Jo(null==n?void 0:n.title,e.title);let o=eu("data",null==n?void 0:n.data);if("string"==typeof o)return o;e.data=o;let u=e.data.length,s=Ko("dataColor",null==n?void 0:n.dataColor,u,null,qo,!0);if("string"==typeof s)return s;e.dataColor=s;let f=Ko("dataName",null==n?void 0:n.dataName,u,"",null,!0);if("string"==typeof f)return f;e.dataName=f;let c=Ko("label",null==n?void 0:n.label,u,"",null,!0);if("string"==typeof c)return c;e.label=c,"number"==typeof(null==n?void 0:n.hideLabelLessThan)&&(e.hideLabelLessThan=n.hideLabelLessThan);let h=Ko("extLabel",null==n?void 0:n.extLabel,u,"",null,!0);if("string"==typeof h)return h;e.extLabel=h,"boolean"==typeof(null==n?void 0:n.showExtLabelOnlyIfNoLabel)&&(e.showExtLabelOnlyIfNoLabel=n.showExtLabelOnlyIfNoLabel),"number"==typeof(null==n?void 0:n.ratioInnerRadius)&&(e.ratioInnerRadius=n.ratioInnerRadius),"boolean"==typeof(null==n?void 0:n.showLegend)&&(e.showLegend=n.showLegend),e.legendPosition=Jo(null==n?void 0:n.legendPosition,"right");let d="horizontal";d="top"===e.legendPosition||"bottom"===e.legendPosition?"horizontal":"left"===e.legendPosition||"right"===e.legendPosition?"vertical":"horizontal",e.legendOrientation=Jo(null==n?void 0:n.legendOrientation,d),e.legendBgColor=Jo(null==n?void 0:n.legendBgColor,e.legendBgColor),e.legendBorderColor=Jo(null==n?void 0:n.legendBorderColor,e.legendBorderColor),p.pie.push(e)}for(let t of A){let e=new Yl,n=r[t],a=ru(e),l=ru(n);for(let t of l)if(!a.includes(t))return i="'"+t+"' is not an available key",i;e.template=Jo(null==n?void 0:n.template,e.template),e.style=Jo(null==n?void 0:n.style,e.style),p.summary.push(e)}for(let t of b){let e=new Pl,n=r[t],a=ru(e),l=ru(n);for(let t of l)if(!a.includes(t))return i="'"+t+"' is not an available key",i;e.mode=Jo(null==n?void 0:n.mode,e.mode);let o=tu("dataset",null==n?void 0:n.dataset);if("string"==typeof o)return o;if(0===o.length)for(let t of g)o.push(t.getId());e.dataset=o;let u=e.dataset.length;e.startWeekOn=Jo(null==n?void 0:n.startWeekOn,e.startWeekOn),"boolean"==typeof(null==n?void 0:n.showCircle)&&(e.showCircle=n.showCircle);let s=tu("threshold",null==n?void 0:n.threshold);if("string"==typeof s)return s;if(e.threshold=s,0===e.threshold.length)for(let t=0;t1))return i="Empty range is not allowed",i;{let t=u[0];if(t<0)return i="Negative range value is not allowed",i;for(let e=1;ee(this,void 0,void 0,(function*(){let n=null;l.queries.some((t=>{let e=t.getType();return t.getTarget(),e===Zi.Frontmatter||e===Zi.Tag||e===Zi.Wiki||e===Zi.WikiLink||e===Zi.WikiDisplay}))&&(n=this.app.metadataCache.getFileCache(t));let r=null;l.queries.some((t=>{let e=t.getType(),n=t.getTarget();return e===Zi.Tag||e===Zi.Text||e===Zi.dvField||e===Zi.Task||e===Zi.TaskDone||e===Zi.TaskNotDone||e===Zi.FileMeta&&("numWords"===n||"numChars"===n||"numSentences"===n)}))&&(r=yield this.app.vault.adapter.read(t.path));let a=new Map,i=!1;for(let e of l.xDataset)if(!a.has(e)){let o=window.moment("");if(-1===e)o=au(t,l);else{let a=l.queries[e];switch(a.getType()){case Zi.Frontmatter:o=iu(n,a,l);break;case Zi.Tag:o=ou(r,a,l);break;case Zi.Text:o=uu(r,a,l);break;case Zi.dvField:o=su(r,a,l);break;case Zi.FileMeta:o=fu(t,a,l);break;case Zi.Task:case Zi.TaskDone:case Zi.TaskNotDone:o=cu(r,a,l)}}o.isValid()?(null!==l.startDate&&ol.endDate&&(i=!0,s.fileOutOfDateRange++)):(i=!0,s.fileNotInFormat++),i||(s.gotAnyValidXValue||(s.gotAnyValidXValue=!0),a.set(e,Jl(o,l.dateFormat)),s.fileAvailable++,1==s.fileAvailable?(s.minDate=o.clone(),s.maxDate=o.clone()):(os.maxDate&&(s.maxDate=o.clone())))}if(i)return;const o=l.queries.filter((t=>t.getType()!==Zi.Table&&!t.usedAsXDataset)).map((i=>e(this,void 0,void 0,(function*(){if(n&&i.getType()===Zi.Tag){let t=function(t,e,n,r,a){let i=t.frontmatter,l=[];if(i&&i.tags){let t=0,o=!1;if(Array.isArray(i.tags))l=l.concat(i.tags);else if("string"==typeof i.tags){let t=i.tags.split(e.getSeparator(!0));for(let e of t){let t=e.trim();""!==t&&l.push(t)}}for(let i of l){if(i===e.getTarget())t+=n.constValue[e.getId()],o=!0,e.addNumTargets();else{if(!i.startsWith(e.getTarget()+"/"))continue;t+=n.constValue[e.getId()],o=!0,e.addNumTargets()}let l=null;return o&&(l=t),hu(r,a.get(n.xDataset[e.getId()]),e,l),!0}}return!1}(n,i,l,u,a);s.gotAnyValidYValue||(s.gotAnyValidYValue=t)}if(n&&i.getType()===Zi.Frontmatter&&"tags"!==i.getTarget()){let t=function(t,e,n,r,a){let i=t.frontmatter;if(i){let t=eo(i,e.getTarget());if(t){let i=ao(t,n.textValueMap);if(null!==i.value)return i.type===Ki.Time&&(e.valueType=Ki.Time),e.addNumTargets(),hu(r,a.get(n.xDataset[e.getId()]),e,i.value),!0}else if(e.getParentTarget()&&eo(i,e.getParentTarget())){let t=eo(i,e.getParentTarget()),l=null;if(Array.isArray(t)?l=t.map((t=>t.toString())):"string"==typeof t&&(l=t.split(e.getSeparator())),l&&l.length>e.getAccessor()&&e.getAccessor()>=0){let t=ao(l[e.getAccessor()].trim(),n.textValueMap);if(null!==t.value)return t.type===Ki.Time&&(e.valueType=Ki.Time),e.addNumTargets(),hu(r,a.get(n.xDataset[e.getId()]),e,t.value),!0}}}return!1}(n,i,l,u,a);s.gotAnyValidYValue||(s.gotAnyValidYValue=t)}if(n&&(i.getType()===Zi.Wiki||i.getType()===Zi.WikiLink||i.getType()===Zi.WikiDisplay)){let t=function(t,e,n,r,a){let i=t.links;if(!i)return!1;let l=e.getTarget(),o=e.getType(),u="",s=l;for(let t of i){if(!t)continue;let e="";o===Zi.Wiki?e=t.displayText?t.displayText:t.link:o===Zi.WikiLink?e=t.link:o===Zi.WikiDisplay?t.displayText&&(e=t.displayText):e=t.displayText?t.displayText:t.link,e=e.trim(),u+=e+"\n"}return du(u,s,e,r,a,n)}(n,i,l,u,a);s.gotAnyValidYValue||(s.gotAnyValidYValue=t)}if(r&&i.getType()===Zi.Tag){let t=function(t,e,n,r,a){let i=e.getTarget();return e.getParentTarget()&&(i=e.getParentTarget()),i.length>1&&i.startsWith("#")&&(i=i.substring(1)),du(t,"(^|\\s)#"+i+"(\\/[\\w-]+)*(:(?[\\d\\.\\/-]*)[a-zA-Z]*)?([\\.!,\\?;~-]*)?(\\s|$)",e,r,a,n)}(r,i,l,u,a);s.gotAnyValidYValue||(s.gotAnyValidYValue=t)}if(r&&i.getType()===Zi.Text){let t=function(t,e,n,r,a){return du(t,e.getTarget(),e,r,a,n)}(r,i,l,u,a);s.gotAnyValidYValue||(s.gotAnyValidYValue=t)}if(i.getType()===Zi.FileMeta){let e=gu(t,r,i,l,u,a);s.gotAnyValidYValue||(s.gotAnyValidYValue=e)}if(r&&i.getType()===Zi.dvField){let t=function(t,e,n,r,a){let i=e.getTarget();return e.getParentTarget()&&(i=e.getParentTarget()),i=i.replace("-","[\\s\\-]"),du(t,"(^| |\\t)\\*{0,2}"+i+"\\*{0,2}(::[ |\\t]*(?[\\d\\.\\/\\-\\w,@; \\t:]*))(\\r\\?\\n|\\r|$)",e,r,a,n)}(r,i,l,u,a);s.gotAnyValidYValue||(s.gotAnyValidYValue=t)}if(r&&(i.getType()===Zi.Task||i.getType()===Zi.TaskDone||i.getType()===Zi.TaskNotDone)){let t=function(t,e,n,r,a){let i=e.getType(),l=e.getTarget();return l=i===Zi.Task?"\\[[\\sx]\\]\\s"+l:i===Zi.TaskDone?"\\[x\\]\\s"+l:i===Zi.TaskNotDone?"\\[\\s\\]\\s"+l:"\\[[\\sx]\\]\\s"+l,du(t,l,e,r,a,n)}(r,i,l,u,a);s.gotAnyValidYValue||(s.gotAnyValidYValue=t)}}))));yield Promise.all(o)}))));if(yield Promise.all(f),yield this.collectDataFromTable(u,l,s),s.errorMessage)return this.renderErrorMessage(s.errorMessage,a,r);let c="";if(s.minDate.isValid()&&s.maxDate.isValid()&&0!==s.fileAvailable&&s.gotAnyValidXValue||(c="No valid date as X value found in notes",s.fileOutOfDateRange>0&&(c+=`\n${s.fileOutOfDateRange} files are out of the date range.`),s.fileNotInFormat&&(c+=`\n${s.fileNotInFormat} files are not in the right format.`)),null===l.startDate&&null===l.endDate?(l.startDate=s.minDate.clone(),l.endDate=s.maxDate.clone()):null!==l.startDate&&null===l.endDate?l.startDates.minDate?l.startDate=s.minDate.clone():c="Invalid date range":(l.startDates.maxDate&&l.endDate>s.maxDate)&&(c="Invalid date range"),c)return this.renderErrorMessage(c,a,r);if(!s.gotAnyValidYValue)return this.renderErrorMessage("No valid Y value found in notes",a,r);let h=new Sl(l.startDate,l.endDate);for(let t of l.queries){let e=h.createDataset(t,l);e.addNumTargets(t.getNumTargets());for(let n=l.startDate.clone();n<=l.endDate;n.add(1,"days"))if(u.has(Jl(n,l.dateFormat))){let r=u.get(Jl(n,l.dateFormat)).filter((function(e){return e.query.equalTo(t)}));if(r.length>0){let t=null;for(let e=0;et.getType()===Zi.Table)),i=[],l=!1;for(let n of e){let e=n.getParentTarget(),r=this.app.vault.getAbstractFileByPath(t.normalizePath(e+".md"));if(!(r&&r instanceof t.TFile)){l=!0;break}let a=n.getAccessor(),o=n.usedAsXDataset,u=i.find((t=>t.filePath===e&&t.tableIndex===a));if(u)o?u.xDataset=n:u.yDatasets.push(n);else{let t=new $l(e,a);o?t.xDataset=n:t.yDatasets.push(n),i.push(t)}}if(l)a.errorMessage="File containing tables not found";else for(let e of i){let i=e.xDataset;if(!i)continue;let l=e.yDatasets,o=i.getParentTarget(),u=i.getAccessor(),s="";o+=".md";let f=this.app.vault.getAbstractFileByPath(t.normalizePath(o));if(!(f&&f instanceof t.TFile))continue;{a.fileAvailable++;let t,e=yield this.app.vault.adapter.read(f.path),n=new RegExp("((\\r?\\n){2}|^)([^\\r\\n]*\\|[^\\r\\n]*(\\r?\\n)?)+(?=(\\r?\\n){2}|$)","gm"),r=0;for(;t=n.exec(e);){if(r===u){s=t[0];break}r++}}let c=s.split(/\r?\n/);c=c.filter((t=>""!==t));let h=0,d=0;if(c.length>=2){let t=c.shift().trim();t=no(t,"|"),h=t.split("|").length;let e=c.shift().trim();e=no(e,"|");let n=e.split("|");for(let t of n)if(!t.includes("-"))break;d=c.length}if(0==d)continue;let g=i.getAccessor(1);if(g>=h)continue;let p=[];for(let t of c){let e=no(t.trim(),"|").split("|");if(ga.maxDate&&(a.maxDate=t.clone())):(a.minDate=t.clone(),a.maxDate=t.clone())):p.push(null)}else p.push(null)}if(p.every((t=>null===t)))return void(a.errorMessage="No valid date as X value found in table");a.gotAnyValidXValue||(a.gotAnyValidXValue=!0);for(let t of l){let e=t.getAccessor(1);if(e>=h)continue;let i=0;for(let l of c){let o=no(l.trim(),"|").split("|");if(et.getAccessor(2)&&t.getAccessor(2)>=0){let e=null,o=ao(l[t.getAccessor(2)].trim(),r.textValueMap);null!==o.value&&(o.type===Ki.Time&&(t.valueType=Ki.Time),e=o.value,i