"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;r((function(t){return null===t?NaN:+t})).center;var i=a;function l(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}var o=Math.sqrt(50),u=Math.sqrt(10),s=Math.sqrt(2);function f(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>=o?10:i>=u?5:i>=s?2:1)*Math.pow(10,a):-Math.pow(10,-a)/(i>=o?10:i>=u?5:i>=s?2:1)}function c(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>=o?a*=10:i>=u?a*=5:i>=s&&(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 d(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 g(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);g(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(p(t,r,e),i(t[a],n)>0&&p(t,r,a);l0;)--o}0===i(t[r],n)?p(t,r,o):(++o,p(t,o,a)),o<=e&&(r=o+1),e<=o&&(a=o-1)}return t}function p(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function y(t,e,n){if(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)),r=t.length){if((e=+e)<=0||r<2)return d(t);if(e>=1)return h(t);var r,a=(r-1)*e,i=Math.floor(a),l=h(g(t,i).subarray(0,i+1));return l+(d(t.subarray(i+1))-l)*(a-i)}}function m(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 k(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function M(){return!this.__axis}function T(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?A:b;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):x:a,p=Math.max(i,0)+o,y=e.range(),m=+y[0]+u,v=+y[y.length-1]+u,w=(e.bandwidth?k:D)(e.copy(),u),A=h.selection?h.selection():h,b=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");b=b.merge(b.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&&(b=b.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=w(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:w(t))+u)}))),C.remove(),b.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(w(t)+u)})),_.attr(f+"2",s*i),S.attr(f,s*p).text(g),A.filter(M).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=w}))}return h.scale=function(t){return arguments.length?(e=t,h):e},h.ticks=function(){return n=w.call(arguments),h},h.tickArguments=function(t){return arguments.length?(n=null==t?[]:w.call(t),h):n.slice()},h.tickValues=function(t){return arguments.length?(r=null==t?null:w.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 C(t){return T(3,t)}function F(t){return T(4,t)}var _={value:()=>{}};function S(){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 N(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)),I.hasOwnProperty(e)?{space:I[e],local:t}:t}function P(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===V&&e.documentElement.namespaceURI===V?e.createElement(t):e.createElementNS(n,t)}}function z(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function O(t){var e=Y(t);return(e.local?z:P)(e)}function U(){}function R(t){return null==t?U:function(){return this.querySelector(t)}}function W(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function $(){return[]}function H(t){return null==t?$:function(){return this.querySelectorAll(t)}}function j(t){return function(){return this.matches(t)}}function X(t){return function(e){return e.matches(t)}}var q=Array.prototype.find;function G(){return this.firstElementChild}var Q=Array.prototype.filter;function Z(){return this.children}function J(t){return new Array(t.length)}function K(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function tt(t){return function(){return t}}function et(t,e,n,r,a,i){for(var l,o=0,u=e.length,s=i.length;oe?1:t>=e?0:NaN}function it(t){return function(){this.removeAttribute(t)}}function lt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function ot(t,e){return function(){this.setAttribute(t,e)}}function ut(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function st(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function ft(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 ct(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function ht(t){return function(){this.style.removeProperty(t)}}function dt(t,e,n){return function(){this.style.setProperty(t,e,n)}}function gt(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function pt(t,e){return t.style.getPropertyValue(e)||ct(t).getComputedStyle(t,null).getPropertyValue(e)}function yt(t){return function(){delete this[t]}}function mt(t,e){return function(){this[t]=e}}function vt(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function wt(t){return t.trim().split(/^|\s+/)}function xt(t){return t.classList||new At(t)}function At(t){this._node=t,this._names=wt(t.getAttribute("class")||"")}function bt(t,e){for(var n=xt(t),r=-1,a=e.length;++r=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}function Ot(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 Ht=[null];function jt(t,e){this._groups=t,this._parents=e}function Xt(){return new jt([[document.documentElement]],Ht)}function qt(t){return"string"==typeof t?new jt([[document.querySelector(t)]],[document.documentElement]):new jt([[t]],Ht)}function Gt(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Qt(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Zt(){}jt.prototype=Xt.prototype={constructor:jt,select:function(t){"function"!=typeof t&&(t=R(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=at);for(var n=this._groups,r=n.length,a=new Array(r),i=0;i1?this.each((null==e?ht:"function"==typeof e?gt:dt)(t,e,null==n?"":n)):pt(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?yt:"function"==typeof e?vt:mt)(t,e)):this.node()[t]},classed:function(t,e){var n=wt(t+"");if(arguments.length<2){for(var r=xt(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?ge(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?ge(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=re.exec(t))?new me(e[1],e[2],e[3],1):(e=ae.exec(t))?new me(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=ie.exec(t))?ge(e[1],e[2],e[3],e[4]):(e=le.exec(t))?ge(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=oe.exec(t))?Ae(e[1],e[2]/100,e[3]/100,1):(e=ue.exec(t))?Ae(e[1],e[2]/100,e[3]/100,e[4]):se.hasOwnProperty(t)?de(se[t]):"transparent"===t?new me(NaN,NaN,NaN,0):null}function de(t){return new me(t>>16&255,t>>8&255,255&t,1)}function ge(t,e,n,r){return r<=0&&(t=e=n=NaN),new me(t,e,n,r)}function pe(t){return t instanceof Zt||(t=he(t)),t?new me((t=t.rgb()).r,t.g,t.b,t.opacity):new me}function ye(t,e,n,r){return 1===arguments.length?pe(t):new me(t,e,n,null==r?1:r)}function me(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function ve(){return"#"+xe(this.r)+xe(this.g)+xe(this.b)}function we(){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 xe(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Ae(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new De(t,e,n,r)}function be(t){if(t instanceof De)return new De(t.h,t.s,t.l,t.opacity);if(t instanceof Zt||(t=he(t)),!t)return new De;if(t instanceof De)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 De(l,o,u,t.opacity)}function De(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function ke(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}Gt(Zt,he,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:fe,formatHex:fe,formatHsl:function(){return be(this).formatHsl()},formatRgb:ce,toString:ce}),Gt(me,ye,Qt(Zt,{brighter:function(t){return t=null==t?Jt:Math.pow(Jt,t),new me(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new me(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:ve,formatHex:ve,formatRgb:we,toString:we})),Gt(De,(function(t,e,n,r){return 1===arguments.length?be(t):new De(t,e,n,null==r?1:r)}),Qt(Zt,{brighter:function(t){return t=null==t?Jt:Math.pow(Jt,t),new De(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new De(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 me(ke(t>=240?t-240:t+120,a,r),ke(t,a,r),ke(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 Me=Math.PI/180,Te=180/Math.PI,Ce=4/29,Fe=6/29,_e=3*Fe*Fe;function Se(t){if(t instanceof Be)return new Be(t.l,t.a,t.b,t.opacity);if(t instanceof Pe)return ze(t);t instanceof me||(t=pe(t));var e,n,r=Ie(t.r),a=Ie(t.g),i=Ie(t.b),l=Ne((.2225045*r+.7168786*a+.0606169*i)/1);return r===a&&a===i?e=n=l:(e=Ne((.4360747*r+.3850649*a+.1430804*i)/.96422),n=Ne((.0139322*r+.0971045*a+.7141733*i)/.82521)),new Be(116*l-16,500*(e-l),200*(l-n),t.opacity)}function Ee(t,e,n,r){return 1===arguments.length?Se(t):new Be(t,e,n,null==r?1:r)}function Be(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}function Ne(t){return t>.008856451679035631?Math.pow(t,1/3):t/_e+Ce}function Le(t){return t>Fe?t*t*t:_e*(t-Ce)}function Ve(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Ie(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Ye(t){if(t instanceof Pe)return new Pe(t.h,t.c,t.l,t.opacity);if(t instanceof Be||(t=Se(t)),0===t.a&&0===t.b)return new Pe(NaN,0=0&&e._call.call(null,t),e=e._next;--Re}()}finally{Re=0,function(){var t,e,n=Oe,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:Oe=e);Ue=t,nn(r)}(),je=0}}function en(){var t=qe.now(),e=t-He;e>1e3&&(Xe-=e,He=t)}function nn(t){Re||(We&&(We=clearTimeout(We)),t-je>24?(t<1/0&&(We=setTimeout(tn,t-qe.now()-Xe)),$e&&($e=clearInterval($e))):($e||(He=qe.now(),$e=setInterval(en,1e3)),Re=1,Ge(tn)))}function rn(t,e,n){var r=new Je;return e=null==e?0:+e,r.restart((n=>{r.stop(),t(n+e)}),e,n),r}Je.prototype=Ke.prototype={constructor:Je,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?Qe():+n)+(null==e?0:+e),this._next||Ue===this||(Ue?Ue._next=this:Oe=this,Ue=this),this._call=t,this._time=n,nn()},stop:function(){this._call&&(this._call=null,this._time=1/0,nn())}};var an=S("start","end","cancel","interrupt"),ln=[];function on(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 rn(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 sn(t,e){var n=fn(t,e);if(n.state>3)throw new Error("too late; already running");return n}function fn(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}var cn=t=>()=>t;function hn(t){return 1==(t=+t)?dn: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):cn(isNaN(e)?n:e)}}function dn(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):cn(isNaN(t)?e:t)}var gn=function t(e){var n=hn(e);function r(t,e){var r=n((t=ye(t)).r,(e=ye(e)).r),a=n(t.g,e.g),i=n(t.b,e.b),l=dn(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 pn(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var yn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,mn=new RegExp(yn.source,"g");function vn(t,e){var n,r,a,i=yn.lastIndex=mn.lastIndex=0,l=-1,o=[],u=[];for(t+="",e+="";(n=yn.exec(t))&&(r=mn.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:pn(n,r)})),i=mn.lastIndex;return i180?e+=360:e-t>180&&(t+=360),i.push({i:n.push(a(n)+"rotate(",null,r)-2,x:pn(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:pn(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:pn(t,n)},{i:o-2,x:pn(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)?un:sn;return function(){var l=i(this,t),o=l.on;o!==r&&(a=(r=o).copy()).on(e,n),l.on=a}}var jn=Xt.prototype.constructor;function Xn(t){return function(){this.style.removeProperty(t)}}function qn(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function Gn(t,e,n){var r,a;function i(){var i=e.apply(this,arguments);return i!==a&&(r=(a=i)&&qn(t,i,n)),r}return i._value=e,i}function Qn(t){return function(e){this.textContent=t.call(this,e)}}function Zn(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&Qn(r)),e}return r._value=t,r}var Jn=0;function Kn(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function tr(){return++Jn}var er=Xt.prototype;Kn.prototype={constructor:Kn,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=R(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 Kn?(e=t._id,t=t._name):(e=tr(),(n=nr).time=Qe(),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 fr(t){return(t=sr(Math.abs(t)))?t[1]:NaN}or.prototype=ur.prototype={constructor:or,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((ar-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%ir+ir),c>lr?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>=ar)+","+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 cr,hr=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function dr(t){if(!(e=hr.exec(t)))throw new Error("invalid format: "+t);var e;return new gr({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 gr(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 pr(t,e){var n=sr(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")}dr.prototype=gr.prototype,gr.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 yr={"%":(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)=>pr(100*t,e),r:pr,s:function(t,e){var n=sr(t,e);if(!n)return t+"";var r=n[0],a=n[1],i=a-(cr=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")+sr(t,Math.max(0,e+i-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function mr(t){return t}var vr,wr,xr,Ar=Array.prototype.map,br=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Dr(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?mr:(e=Ar.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?mr:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(Ar.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=dr(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"):yr[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=yr[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?br[8+cr/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=dr(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(fr(e)/3))),a=Math.pow(10,-r),i=br[8+r/3];return function(t){return n(a*t)+i}}}}vr=Dr({thousands:",",grouping:[3],currency:["$",""]}),wr=vr.format,xr=vr.formatPrefix;function kr(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 Mr(t,e){var n=kr((t=Ee(t)).l,(e=Ee(e)).l),r=kr(t.a,e.a),a=kr(t.b,e.b),i=kr(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 Tr(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}const Cr=Symbol("implicit");function Fr(){var t=new Map,e=[],n=[],r=Cr;function a(a){var i=a+"",l=t.get(i);if(!l){if(r!==Cr)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 Fr(e,n).unknown(r)},Tr.apply(a,arguments),a}var _r=t=>()=>t;function Sr(t){return 1==(t=+t)?Er: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):_r(isNaN(e)?n:e)}}function Er(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):_r(isNaN(t)?e:t)}var Br=function t(e){var n=Sr(e);function r(t,e){var r=n((t=ye(t)).r,(e=ye(e)).r),a=n(t.g,e.g),i=n(t.b,e.b),l=Er(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 Nr(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:Ir(n,r)})),i=zr.lastIndex;return ie&&(n=t,t=e,e=n),s=function(n){return Math.max(t,Math.min(e,n))}),r=u>2?qr: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),Ir)))(n)))},c.domain=function(t){return arguments.length?(l=Array.from(t,Wr),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=Rr,f()},c.clamp=function(t){return arguments.length?(s=!!t||Hr,f()):s!==Hr},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 Zr(){return Qr()(Hr,Hr)}function Jr(t,e,n,r){var a,i=c(t,e,n);switch((r=dr(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(fr(e)/3)))-fr(Math.abs(t)))}(i,l))||(r.precision=a),xr(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,fr(e)-fr(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,-fr(Math.abs(t)))}(i))||(r.precision=a-2*("%"===r.type))}return wr(r)}function Kr(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=f(u,s,n))===r)return i[l]=u,i[o]=s,e(i);if(a>0)u=Math.floor(u/a)*a,s=Math.ceil(s/a)*a;else{if(!(a<0))break;u=Math.ceil(u*a)/a,s=Math.floor(s*a)/a}r=a}return t},t}function ta(){var t=Zr();return t.copy=function(){return Gr(t,ta())},Tr.apply(t,arguments),Kr(t)}var ea=new Date,na=new Date;function ra(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 ea.setTime(+e),na.setTime(+r),t(ea),t(na),Math.floor(n(ea,na))},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 aa=ra((function(){}),(function(t,e){t.setTime(+t+e)}),(function(t,e){return e-t}));aa.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?ra((function(e){e.setTime(Math.floor(e/t)*t)}),(function(e,n){e.setTime(+e+n*t)}),(function(e,n){return(n-e)/t})):aa:null};var ia=ra((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()})),la=ra((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()})),oa=ra((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()})),ua=ra((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 sa(t){return ra((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 fa=sa(0),ca=sa(1);sa(2),sa(3);var ha=sa(4);sa(5),sa(6);var da=ra((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()})),ga=ra((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()}));ga.every=function(t){return isFinite(t=Math.floor(t))&&t>0?ra((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},ra((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()})),ra((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 pa=ra((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 ya(t){return ra((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 ma=ya(0),va=ya(1);ya(2),ya(3);var wa=ya(4);ya(5),ya(6),ra((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 xa=ra((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()}));xa.every=function(t){return isFinite(t=Math.floor(t))&&t>0?ra((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[Aa,ba]=function(t,e,n,a,i,l){const o=[[ia,1,1e3],[ia,5,5e3],[ia,15,15e3],[ia,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(c(e/31536e6,n/31536e6,a));if(0===l)return aa.every(Math.max(c(e,n,a),1));const[u,s]=o[i/o[l-1][2][t.toLowerCase(),e])))}function Ia(t,e,n){var r=_a.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Ya(t,e,n){var r=_a.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Pa(t,e,n){var r=_a.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function za(t,e,n){var r=_a.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Oa(t,e,n){var r=_a.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function Ua(t,e,n){var r=_a.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Ra(t,e,n){var r=_a.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Wa(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 $a(t,e,n){var r=_a.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function Ha(t,e,n){var r=_a.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function ja(t,e,n){var r=_a.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Xa(t,e,n){var r=_a.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function qa(t,e,n){var r=_a.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Ga(t,e,n){var r=_a.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Qa(t,e,n){var r=_a.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Za(t,e,n){var r=_a.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Ja(t,e,n){var r=_a.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Ka(t,e,n){var r=Sa.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function ti(t,e,n){var r=_a.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function ei(t,e,n){var r=_a.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function ni(t,e){return Ba(t.getDate(),e,2)}function ri(t,e){return Ba(t.getHours(),e,2)}function ai(t,e){return Ba(t.getHours()%12||12,e,2)}function ii(t,e){return Ba(1+ua.count(ga(t),t),e,3)}function li(t,e){return Ba(t.getMilliseconds(),e,3)}function oi(t,e){return li(t,e)+"000"}function ui(t,e){return Ba(t.getMonth()+1,e,2)}function si(t,e){return Ba(t.getMinutes(),e,2)}function fi(t,e){return Ba(t.getSeconds(),e,2)}function ci(t){var e=t.getDay();return 0===e?7:e}function hi(t,e){return Ba(fa.count(ga(t)-1,t),e,2)}function di(t){var e=t.getDay();return e>=4||0===e?ha(t):ha.ceil(t)}function gi(t,e){return t=di(t),Ba(ha.count(ga(t),t)+(4===ga(t).getDay()),e,2)}function pi(t){return t.getDay()}function yi(t,e){return Ba(ca.count(ga(t)-1,t),e,2)}function mi(t,e){return Ba(t.getFullYear()%100,e,2)}function vi(t,e){return Ba((t=di(t)).getFullYear()%100,e,2)}function wi(t,e){return Ba(t.getFullYear()%1e4,e,4)}function xi(t,e){var n=t.getDay();return Ba((t=n>=4||0===n?ha(t):ha.ceil(t)).getFullYear()%1e4,e,4)}function Ai(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Ba(e/60|0,"0",2)+Ba(e%60,"0",2)}function bi(t,e){return Ba(t.getUTCDate(),e,2)}function Di(t,e){return Ba(t.getUTCHours(),e,2)}function ki(t,e){return Ba(t.getUTCHours()%12||12,e,2)}function Mi(t,e){return Ba(1+pa.count(xa(t),t),e,3)}function Ti(t,e){return Ba(t.getUTCMilliseconds(),e,3)}function Ci(t,e){return Ti(t,e)+"000"}function Fi(t,e){return Ba(t.getUTCMonth()+1,e,2)}function _i(t,e){return Ba(t.getUTCMinutes(),e,2)}function Si(t,e){return Ba(t.getUTCSeconds(),e,2)}function Ei(t){var e=t.getUTCDay();return 0===e?7:e}function Bi(t,e){return Ba(ma.count(xa(t)-1,t),e,2)}function Ni(t){var e=t.getUTCDay();return e>=4||0===e?wa(t):wa.ceil(t)}function Li(t,e){return t=Ni(t),Ba(wa.count(xa(t),t)+(4===xa(t).getUTCDay()),e,2)}function Vi(t){return t.getUTCDay()}function Ii(t,e){return Ba(va.count(xa(t)-1,t),e,2)}function Yi(t,e){return Ba(t.getUTCFullYear()%100,e,2)}function Pi(t,e){return Ba((t=Ni(t)).getUTCFullYear()%100,e,2)}function zi(t,e){return Ba(t.getUTCFullYear()%1e4,e,4)}function Oi(t,e){var n=t.getUTCDay();return Ba((t=n>=4||0===n?wa(t):wa.ceil(t)).getUTCFullYear()%1e4,e,4)}function Ui(){return"+0000"}function Ri(){return"%"}function Wi(t){return+t}function $i(t){return Math.floor(+t/1e3)}function Hi(t){return new Date(t)}function ji(t){return t instanceof Date?+t:+new Date(+t)}function Xi(t,e,n,r,a,i,l,o,u,s){var f=Zr(),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:Wi,s:$i,S:fi,u:ci,U:hi,V:gi,w:pi,W:yi,x:null,X:null,y:mi,Y:wi,Z:Ai,"%":Ri},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:bi,e:bi,f:Ci,g:Pi,G:Oi,H:Di,I:ki,j:Mi,L:Ti,m:Fi,M:_i,p:function(t){return a[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:Wi,s:$i,S:Si,u:Ei,U:Bi,V:Li,w:Vi,W:Ii,x:null,X:null,y:Yi,Y:zi,Z:Ui,"%":Ri},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:ja,e:ja,f:Ja,g:Ra,G:Ua,H:qa,I:qa,j:Xa,L:Za,m:Ha,M:Ga,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:$a,Q:ti,s:ei,S:Qa,u:Ya,U:Pa,V:za,w:Ia,W:Oa,x:function(t,e,r){return k(t,n,e,r)},X:function(t,e,n){return k(t,r,e,n)},y:Ra,Y:Ua,Z:Wa,"%":Ka};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=ka(Ma(i.y,0,1))).getUTCDay(),r=a>4||0===a?va.ceil(r):va(r),r=pa.offset(r,7*(i.V-1)),i.y=r.getUTCFullYear(),i.m=r.getUTCMonth(),i.d=r.getUTCDate()+(i.w+6)%7):(a=(r=Da(Ma(i.y,0,1))).getDay(),r=a>4||0===a?ca.ceil(r):ca(r),r=ua.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?ka(Ma(i.y,0,1)).getUTCDay():Da(Ma(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,ka(i)):Da(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 Fa?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),Ca=Ta.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 qi,Gi=(qi=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{Gi(t[t.length-1])})(Qi);var Ji,Ki,tl,el=Math.abs,nl=Math.atan2,rl=Math.cos,al=Math.max,il=Math.min,ll=Math.sin,ol=Math.sqrt,ul=Math.PI,sl=ul/2,fl=2*ul;function cl(t){return t>1?0:t<-1?ul:Math.acos(t)}function hl(t){return t>=1?sl:t<=-1?-sl:Math.asin(t)}function dl(t){return t.innerRadius}function gl(t){return t.outerRadius}function pl(t){return t.startAngle}function yl(t){return t.endAngle}function ml(t){return t&&t.padAngle}function vl(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 wl(t,e,n,r,a,i,l){var o=t-n,u=e-r,s=(l?i:-i)/ol(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)*ol(al(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 xl(){var t=dl,e=gl,n=Zi(0),r=null,a=pl,i=yl,l=ml,o=null;function u(){var u,s,f=+t.apply(this,arguments),c=+e.apply(this,arguments),h=a.apply(this,arguments)-sl,d=i.apply(this,arguments)-sl,g=el(d-h),p=d>h;if(o||(o=u=ur()),c1e-12)if(g>fl-1e-12)o.moveTo(c*rl(h),c*ll(h)),o.arc(0,0,c,h,d,!p),f>1e-12&&(o.moveTo(f*rl(d),f*ll(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):ol(f*f+c*c)),T=il(el(c-f)/2,+n.apply(this,arguments)),C=T,F=T;if(M>1e-12){var _=hl(M/f*ll(k)),S=hl(M/c*ll(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*rl(v),B=c*ll(v),N=f*rl(A),L=f*ll(A);if(T>1e-12){var V,I=c*rl(w),Y=c*ll(w),P=f*rl(x),z=f*ll(x);if(g1e-12?F>1e-12?(y=wl(P,z,E,B,c,F,p),m=wl(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=wl(N,L,I,Y,f,-C,p),m=wl(E,B,P,z,f,-C,p),o.lineTo(y.cx+y.x01,y.cy+y.y01),Ct?1:e>=t?0:NaN}function Cl(t){return t}bl.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"}(Ji||(Ji={})),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"}(Ki||(Ki={})),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"}(tl||(tl={}));class Fl{constructor(t,e){this.date=t,this.value=e}}class _l{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=tl.Number,this.usedAsXDataset=!1,this.numTargets=0,e===Ji.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 Sl{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 Hl{constructor(t,e){this.filePath=t,this.tableIndex=e,this.xDataset=null,this.yDatasets=[]}}class jl{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 ql(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 Gl(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 Ql(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 Zl(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]=Ql(t,["year","years","Y","y"]),null!==a&&(r&&(a*=-1),e.add(a,"years"),n=!0);let i=null;[i,t]=Ql(t,["month","months","M"]),null!==i&&(r&&(i*=-1),e.add(i,"months"),n=!0);let l=null;[l,t]=Ql(t,["week","weeks","W","w"]),null!==l&&(r&&(l*=-1),e.add(l,"weeks"),n=!0);let o=null;[o,t]=Ql(t,["day","days","D","d"]),null!==o&&(r&&(o*=-1),e.add(o,"days"),n=!0);let u=null;[u,t]=Ql(t,["hour","hours","H","h"]),null!==u&&(r&&(u*=-1),e.add(u,"hours"),n=!0);let s=null;[s,t]=Ql(t,["minute","minutes","m"]),null!==s&&(r&&(s*=-1),e.add(s,"minutes"),n=!0);let f=null;return[f,t]=Ql(t,["second","seconds","S","s"]),null!==f&&(r&&(f*=-1),e.add(f,"seconds"),n=!0),n?e:null}function Jl(t,e){let n=null,r=Zl(t);return r&&window.moment.isDuration(r)&&(n=eo(e),n=n.add(r),n&&n.isValid()),n}function Kl(t,e){return null==t?null:"iso-8601"===e.toLowerCase()?t.format():t.format(e)}function to(t,e){return Gl(Kl(window.moment(t),e),e)}function eo(t){return Gl(Kl(window.moment(),t),t)}function no(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 ao(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 io(t,e=null){let n=null,r=tl.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=tl.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 lo(t,e="",n=""){var r=qt("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 oo(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 uo(t,e,n){let r=new $l(t.attr("transform"));t.attr("transform","translate("+(r.translateX+e)+","+(r.translateY+n)+")")}function so(t){return t=(t=(t=t.replace(/(^\\s\*)|(\\s\*$)/gi,"")).replace(/\[ \]{2,}/gi," ")).replace(/\\n /,"\\n")}var fo=l((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 ho(t){if("number"==typeof t){if(0===t)return!1}else if(t instanceof Sl&&t.getValues().some((function(t){return 0===t})))return!1;return!0}const go={min:function(t,e){return d(t.getValues())},minDate:function(t,e){let n=d(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 h(t.getValues())},maxDate: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: 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 v(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 ho(n)?v(t.getValues())/n:"Error: divide by zero in expression"},median:function(t,e){return y(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())}},po={"-":function(t){if("number"==typeof t)return-1*t;if(t instanceof Sl){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 Sl){return t.cloneToTmpDataset()}return"Error: unknown operation for '+'"}},yo={"+":function(t,e){if("number"==typeof t&&"number"==typeof e)return t+e;if("number"==typeof t&&e instanceof Sl){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 Sl&&"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 Sl&&e instanceof Sl){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 Sl){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 Sl&&"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 Sl&&e instanceof Sl){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 Sl){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 Sl&&"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 Sl&&e instanceof Sl){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(!ho(e))return"Error: divide by zero in expression";if("number"==typeof t&&"number"==typeof e)return t/e;if("number"==typeof t&&e instanceof Sl){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 Sl&&"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 Sl&&e instanceof Sl){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(!ho(e))return"Error: divide by zero in expression";if("number"==typeof t&&"number"==typeof e)return t%e;if("number"==typeof t&&e instanceof Sl){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 Sl&&"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 Sl&&e instanceof Sl){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 '%'"}},mo={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 vo(t,e){switch(t.type){case"Literal":return t.value;case"Identifier":let n=t.name;return n in go||n in mo?`Error: deprecated template variable '${n}', use '${n}()' instead`:`Error: unknown function name '${n}'`;case"UnaryExpression":let r=t,a=vo(r.argument,e);return"string"==typeof a?a:po[r.operator](a);case"BinaryExpression":let i=t,l=vo(i.left,e),o=vo(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 Sl?"number"==typeof e||window.moment.isMoment(e)||e instanceof Sl?"":"Error: invalide operant type":"Error: invalid operant type"}(l,o);return"string"==typeof u&&u.startsWith("Error:")?u:yo[i.operator](l,o);case"CallExpression":let s=t,f=s.callee.name,c=function(t,e){return t.map((function(t){return vo(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 go){if(0===c.length){let t=null;for(let n of e.datasets)t||n.getQuery().usedAsXDataset||(t=n);return t?go[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 Sl?go[f](t,e):`Error: function '${f}' only accepts Dataset`}return`Error: Too many arguments for function ${f}`}if(f in mo){if(1===c.length){if("string"==typeof c[0])return c[0];if(c[0]instanceof Sl){let t=c[0];return mo[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 Sl){let t=c[0];return mo[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 wo(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=fo(a)}catch(t){return"Error:"+t.message}if(!i)return"Error: failed to parse expression";const l=vo(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 xo(t,e){let n=wo(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?co.sprintf("%"+i,a):a.toFixed(1):window.moment.isMoment(a)&&(l=Kl(a,i||e.dateFormat)),l&&(t=t.split(r).join(l))}return t}function Ao(t,e){if(t=t.trim(),/^([\-]?[0-9]+[\.][0-9]+|[\-]?[0-9]+)$/.test(t))return parseFloat(t);let n=wo(t,e);if("string"==typeof n)return n;let r=n;return r.length>0?r[0].value:"Error: failed to resolve values"}function bo(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=Ao(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=xo(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 lo(t,"tracker-tick-label")})),h=[];for(let t of r.extLabel){let e=xo(t,n);if(e.startsWith("Error")){a=e;break}h.push(e)}if(""!==a)return a;let d=h.map((function(t){return lo(t,"tracker-pie-label")})),g=r.showExtLabelOnlyIfNoLabel,p=Fr().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=Cl,e=Tl,n=null,r=Zi(0),a=Zi(fl),i=Zi(0);function l(l){var o,u,s,f,c,h=(l=Al(l)).length,d=0,g=new Array(h),p=new Array(h),y=+r.apply(this,arguments),m=Math.min(fl,Math.max(-fl,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:Zi(+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:Zi(+t),l):r},l.endAngle=function(t){return arguments.length?(a="function"==typeof t?t:Zi(+t),l):a},l.padAngle=function(t){return arguments.length?(i="function"==typeof t?t:Zi(+t),l):i},l}(),v=m(u),w=y.selectAll("sector").data(v).enter().append("g").attr("class","sector"),x=xl().innerRadius(o).outerRadius(l);var A=xl().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,m=2*h,w=0,x=0;"vertical"===r.legendOrientation?(w=3*p+m+c,x=(g+1)*y):"horizontal"===r.legendOrientation&&(w=(2*p+m)*g+p+v(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,oo(a,0,x+y),uo(i,0,x+y);else if("bottom"===r.legendPosition)A=n.dataAreaSize.width/2-w/2,b=o+n.dataAreaSize.height+y,oo(a,0,x+y);else if("left"===r.legendPosition)A=0,b=o+n.dataAreaSize.height/2-x/2,oo(a,w+p,0),uo(i,w+p,0);else{if("right"!==r.legendPosition)return;A=n.dataAreaSize.width+p,b=o+n.dataAreaSize.height/2-x/2,oo(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+m,F=T;if("vertical"===r.legendOrientation)D.selectAll("markers").data(u).enter().append("circle").attr("cx",M+m/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+m/2:t+=s[n].width+p+m+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+m+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=qt(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 ko(t,e,n){if(!e||!n)return;let r="";n.template,r=n.template;let a=xo(r,e);if(a.startsWith("Error:"))return a;if(r=a,""!==r){let e=qt(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 Mo=!1;function To(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;To(t,e)}}}return!1}function Co(t,e,n,r){qt(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){Fo(e,r);let l=a.clone().add(1,"month");Eo(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){Fo(e,r);let i=eo(n.dateFormat);Eo(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=lo(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){Fo(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,uo(e.dataArea,0,g)}function So(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=lo("30","tracker-month-label"),c=2.8*Math.max(f.width,f.height),g=c/2.8*1.8/2,p=(c-2*g)/2,y=d(o.getValues());null!==r.yMin[u]&&(y=r.yMin[u]);let m=h(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=Gl(Kl(t,n.dateFormat),n.dateFormat),"2021-09-13"===t.format("YYYY-MM-DD")&&(Mo=!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);Mo&&(console.log(o),console.log(Kl(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)),Mo&&(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),Mo&&(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:Kl(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++,Mo&&(Mo=!1)}let N=(S+1)*c,L=ta().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?Mr("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?Mr("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 Mr("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=Kl(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 tl[o.valueType]})).attr("class","tracker-month-label").on("click",(function(t){Fo(e,r);let n=qt(this).attr("date");if(r.selectedDate=n,r.showSelectedRing&&e.dataArea.select("#tracker-selected-circle-"+n).style("stroke",r.selectedRingColor),r.showSelectedValue){let t=qt(this).attr("value"),n="";if("Time"===qt(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*c+parseFloat(e.header.attr("height")),R=7*c;U>P&&oo(e.svg,0,U-P),R>Y&&oo(e.svg,R-Y,0),U>O&&oo(e.graphArea,0,U-O),R>z&&oo(e.svg,R-z,0)}function Eo(t,e,n,r,a){n&&Bo&&(_o(t,e=Co(e,t,n),n,r,a),So(0,e,n,r,a))}function Bo(t,e,n){if(!e||!Bo)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(To(e,n),null===n.selectedDataset)return"No available dataset found";let a={};a=Co(a,t,e);let i=null;if(n.initMonth){if(i=Jl(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&&(_o(t,a,e,n,i),So(0,a,e,n,i),function(t,e,n){let r=qt(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 No(t,e,n){if(e&&No)return"Under construction"}function Lo(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=qt(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("%")?Jr(0,i,7)(t)+" %":Jr(0,i,7)(t)},s=lo(u(i),"tracker-tick-label");if("horizontal"===n.orientation){let n=ta();n.domain(l).range([0,e.dataAreaSize.width]),t.scale=n;let r=C(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),oo(t.svg,+s.width,6+s.height),oo(t.graphArea,+s.width,6+s.height)}else if("vertical"===n.orientation){let n=ta();n.domain(l).range([e.dataAreaSize.height,0]),t.scale=n;let r=F(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),oo(t.svg,6+s.width,0),oo(t.graphArea,6+s.width,0),uo(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=lo(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,oo(t.svg,r.width+6,0),oo(t.graphArea,r.width+6,0),uo(t.dataArea,r.width+6,0)}else if("vertical"===n.orientation){let a=e.dataAreaSize.width/2;r.width>e.dataAreaSize.width&&(oo(t.svg,r.width-e.dataAreaSize.width,0),oo(t.graphArea,r.width-e.dataAreaSize.width,0),uo(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,oo(t.svg,0,r.height+6),oo(t.graphArea,0,r.height+6),uo(t.dataArea,0,r.height+6)}}if(n.valueUnit){let r=lo(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,oo(t.svg,0,r.height+6),oo(t.graphArea,0,r.height+6),uo(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===tl.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,M=null;"left"===r?(D=n.yAxisUnit[0],k=n.yAxisTickInterval[0],M=n.yAxisTickLabelFormat[0]):"right"===r&&(D=n.yAxisUnit[1],k=n.yAxisTickInterval[1],M=n.yAxisTickLabelFormat[1]);let C,_=null;if(s?_=Zl(k):(_=parseFloat(k),Number.isNumber(_)&&!Number.isNaN(_)||(_=null)),"left"===r?C=F(v):"right"===r&&(C=T(2,v)),C){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 co.sprintf("%"+n,t)}return t}return Jr(t,e,10)}(g,p,M,s);t&&C.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)?m(t,e,Math.abs(n.asSeconds())):a>18e3?m(t=3600*Math.floor(t/3600),e=3600*Math.ceil(e/3600),3600):m(t=1800*Math.floor(t/1800),e=1800*Math.ceil(e/1800),1800):n&&"number"==typeof n&&(i=m(t,e,n));return 0===i.length?null:i}(g,p,_,s);e&&C.tickValues(e)}let S=t.dataArea.append("g").attr("id","yAxis").call(C).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=lo(t.textContent,"tracker-axis-label");e.width>L&&(L=e.width)}""!==D&&(b+=" ("+D+")");let V=lo(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),oo(t.svg,Y,0),oo(t.graphArea,Y,0),"left"===r&&(uo(t.dataArea,Y,0),t.title&&uo(t.title,Y,0))}function Yo(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=Zi(!0),r=null,a=Dl,i=null;function l(l){var o,u,s,f=(l=Al(l)).length,c=!1;for(null==r&&(i=a(s=ur())),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: "+qt(this).attr("date"),g=lo(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=qt(this).attr("valueType"),m=qt(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=lo(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 zo(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 Oo(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 lo(t,"tracker-legend-label")})),m=0,w=0;for(let t=0;tw&&(w=y[t].width,m=t);let x=w/p[m].length,A=y[m].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+v(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,oo(r,0,C+k),uo(a,0,C+k);else if("bottom"===n.legendPosition)F=c+e.dataAreaSize.width/2-T/2,_=s+e.dataAreaSize.height+f+k,oo(r,0,C+k);else if("left"===n.legendPosition)F=0,_=s+e.dataAreaSize.height/2-C/2,oo(r,T+D,0),uo(a,T+D,0);else{if("right"!==n.legendPosition)return;F=e.dataAreaSize.width+c+h+D,_=s+e.dataAreaSize.height/2-C/2,oo(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()===Ki.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=Qo(e);if(a.length>1){if(a.length>n)return l="Too many inputs for parameter '"+t+"'",l;for(let e=0;e0&&(u=jo(a[e-1].trim())),""===n)i[e]=null!==u?u:r;else{let r=jo(n);if(null===r){l="Invalid inputs for "+t;break}i[e]=r,o++}}else{let t=jo(a[a.length-1].trim());i[e]=o>0&&null!==t?t:r}}else if(""===e);else{let n=jo(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=Qo(e);if(a.length>1){if(a.length>n)return l="Too many inputs for parameter '"+t+"'",l;for(let n=0;n0&&(u=io(a[n-1].trim()).value),""===e)null!==u&&Number.isNumber(u)?i[n]=u:i[n]=r;else{let r=io(e).value;if(null===r){l="Invalid inputs for "+t;break}i[n]=r,o++}}else{let t=io(a[e.length-1].trim()).value;i[n]=o>0&&null!==t?t:r}}else if(""===e);else{let n=io(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=Qo(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 nu(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=Qo(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=tu("yAxisColor",null==t?void 0:t.yAxisColor,2,"",Go,!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=tu("yAxisLabelColor",null==t?void 0:t.yAxisLabelColor,2,"",Go,!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=tu("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=Ko(null==t?void 0:t.xAxisTickInterval,e.xAxisTickInterval);let l=tu("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=Ko(null==t?void 0:t.xAxisTickLabelFormat,e.xAxisTickLabelFormat);let o=tu("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=Jo("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=Jo("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=Zo("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 au(t){let e=[];if(null!==t){const n=Object.keys(t);for(let t of n)e.push(t.toString())}return e}function iu(t,e){return Gl(ql(t.basename,e.dateFormatPrefix,e.dateFormatSuffix),e.dateFormat)}function lu(t,e,n){let r=window.moment(""),a=t.frontmatter;if(a&&no(a,e.getTarget())){let t=no(a,e.getTarget());"string"==typeof t&&(t=ql(t,n.dateFormatPrefix,n.dateFormatSuffix),r=Gl(t,n.dateFormat))}return r}function ou(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=ql(t,n.dateFormatPrefix,n.dateFormatSuffix),a=Gl(t,n.dateFormat),a.isValid())return a}return a}function uu(t,e,n){window.moment("");let r=e.getTarget();return e.getParentTarget()&&(r=e.getParentTarget()),ou(t,"(^|\\s)#"+r+"(\\/[\\w-]+)*(:(?[\\d\\.\\/-]*)[a-zA-Z]*)?([\\.!,\\?;~-]*)?(\\s|$)",n)}function su(t,e,n){return window.moment(""),ou(t,e.getTarget(),n)}function fu(t,e,n){window.moment("");let r=e.getTarget();return e.getParentTarget()&&(r=e.getParentTarget()),r=r.replace("-","[\\s\\-]"),ou(t,"(^| |\\t)\\*{0,2}"+r+"\\*{0,2}(::[ |\\t]*(?[\\d\\.\\/\\-\\w,@; \\t:]*))(\\r\\?\\n|\\r|$)",n)}function cu(e,n,r){let a=window.moment("");if(e&&e instanceof t.TFile){let t=n.getTarget();if("cDate"===t){a=to(e.stat.ctime,r.dateFormat)}else if("mDate"===t){a=to(e.stat.mtime,r.dateFormat)}else"name"===t&&(a=iu(e,r))}return a}function hu(t,e,n){window.moment("");let r=e.getType(),a=e.getTarget();return a=r===Ji.Task?"\\[[\\sx]\\]\\s"+a:r===Ji.TaskDone?"\\[x\\]\\s"+a:r===Ji.TaskNotDone?"\\[\\s\\]\\s"+a:"\\[[\\sx]\\]\\s"+a,ou(t,a,n)}function du(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 gu(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=io(t[0].trim(),i.textValueMap);null!==e.value&&(e.type===tl.Time?(u=e.value,s=!0,n.valueType=tl.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=io(t[n.getAccessor()].trim(),i.textValueMap);null!==e.value&&(e.type===tl.Time?(u=e.value,s=!0,n.valueType=tl.Time,n.addNumTargets()):(u+=e.value,s=!0,n.addNumTargets()))}}else u+=i.constValue[n.getId()],s=!0,n.addNumTargets();if(s){return du(r,a.get(i.xDataset[n.getId()]),n,u),!0}return!1}function pu(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=tl.Date,r.addNumTargets(),du(i,o,r,t),!0}if("mDate"===t){let t=e.stat.mtime;return r.valueType=tl.Date,r.addNumTargets(),du(i,o,r,t),!0}if("size"===t){let t=e.stat.size;return r.addNumTargets(),du(i,o,r,t),!0}if("numWords"===t){return du(i,o,r,function(t){t=so(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(),du(i,o,r,t),!0}if("numSentences"===t){let t=function(t){return(((t=so(t))||"").match(/[^.。!!??\s][^.。!!??]*(?:[.!?](?!['‘’"“”「」『』]?\s|$)[^.。!!??]*)*[.。!!??]?['’"”」』]?(?=\s||$)/gm)||[]).length}(n);return r.addNumTargets(),du(i,o,r,t),!0}if("name"===t){let t=0,n=!1,l=io(e.basename,a.textValueMap);null!==l.value&&(l.type===tl.Time?(t=l.value,n=!0,r.valueType=tl.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 du(i,o,r,u),!0}}return!1}const yu={folder:"/",dateFormat:"YYYY-MM-DD"};class mu 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 'dateFormat' 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 vu extends t.Plugin{onload(){return e(this,void 0,void 0,(function*(){console.log("loading obsidian-tracker plugin"),yield this.loadSettings(),this.addSettingTab(new mu(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(Ki.Line)}),this.addCommand({id:"add-bar-chart-tracker",name:"Add Bar Chart Tracker",callback:()=>this.addCodeBlock(Ki.Bar)}),this.addCommand({id:"add-summary-tracker",name:"Add Summary Tracker",callback:()=>this.addCodeBlock(Ki.Summary)})}))}loadSettings(){return e(this,void 0,void 0,(function*(){this.settings=Object.assign({},yu,yield this.loadData())}))}saveSettings(){return e(this,void 0,void 0,(function*(){yield this.saveData(this.settings)}))}renderErrorMessage(t,e,n){!function(t,e){qt(t).select("#svg").remove(),qt(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!==Ji.Table)).length>0)return"searchType 'table' doestn't work with other types for now";let f=[],c=tu("separator",r.separator,o,"",null,!0);if("string"==typeof c)return c;f=c.map((t=>"comma"===t||"\\,"===t?",":t));let h=Jo("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.";p.folder=Ko(null==r?void 0:r.folder,n.settings.folder),""===p.folder.trim()&&(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=nu("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=nu("fileContainsLinkedFiles",r.fileContainsLinkedFiles);if("string"==typeof t)return t;p.fileContainsLinkedFiles=t}p.fileMultiplierAfterLink=Ko(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=Ko(null==r?void 0:r.dateFormatPrefix,p.dateFormatPrefix),p.dateFormatSuffix=Ko(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=ql(r.startDate,p.dateFormatPrefix,p.dateFormatSuffix),e=null,n=!1;if(e=Jl(t,p.dateFormat),e?n=!0:(e=Gl(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=ql(r.endDate,p.dateFormatPrefix,p.dateFormatSuffix),e=null,n=!1;if(e=Jl(t,p.dateFormat),e?n=!0:(e=Gl(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 Wl(Y[0],Y[1],Y[2],Y[3]);for(let t of M){let e=new Nl,n=r[t],a=au(e),l=au(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=Ko(null==n?void 0:n.name,e.name);let s=nu("xData",null==n?void 0:n.xData);if("string"==typeof s)return s;e.xData=s;let f=e.xData.length,c=nu("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 Vl,n=r[t],a=au(e),l=au(n);for(let t of l)if(!a.includes(t))return i="'"+t+"' is not an available key",i;let u=ru(n,e);if("string"==typeof u)return u;let s=tu("lineColor",null==n?void 0:n.lineColor,o,"",Go,!0);if("string"==typeof s)return s;e.lineColor=s;let f=Jo("lineWidth",null==n?void 0:n.lineWidth,o,1.5,!0);if("string"==typeof f)return f;e.lineWidth=f;let c=Zo("showLine",null==n?void 0:n.showLine,o,!0,!0);if("string"==typeof c)return c;e.showLine=c;let h=Zo("showPoint",null==n?void 0:n.showPoint,o,!0,!0);if("string"==typeof h)return h;e.showPoint=h;let d=tu("pointColor",null==n?void 0:n.pointColor,o,"#69b3a2",Go,!0);if("string"==typeof d)return d;e.pointColor=d;let g=tu("pointBorderColor",null==n?void 0:n.pointBorderColor,o,"#69b3a2",Go,!0);if("string"==typeof g)return g;e.pointBorderColor=g;let y=Jo("pointBorderWidth",null==n?void 0:n.pointBorderWidth,o,0,!0);if("string"==typeof y)return y;e.pointBorderWidth=y;let m=Jo("pointSize",null==n?void 0:n.pointSize,o,3,!0);if("string"==typeof m)return m;e.pointSize=m;let v=Zo("fillGap",null==n?void 0:n.fillGap,o,!1,!0);if("string"==typeof v)return v;e.fillGap=v;let w=tu("yAxisLocation",null==n?void 0:n.yAxisLocation,o,"left",qo,!0);if("string"==typeof w)return w;e.yAxisLocation=w,p.line.push(e)}for(let t of w){let e=new Il,n=r[t],a=au(e),l=au(n);for(let t of l)if(!a.includes(t))return i="'"+t+"' is not an available key",i;let u=ru(n,e);if("string"==typeof u)return u;let s=tu("barColor",null==n?void 0:n.barColor,o,"",Go,!0);if("string"==typeof s)return s;e.barColor=s;let f=tu("yAxisLocation",null==n?void 0:n.yAxisLocation,o,"left",qo,!0);if("string"==typeof f)return f;e.yAxisLocation=f,p.bar.push(e)}for(let t of x){let e=new Yl,n=r[t],a=au(e),l=au(n);for(let t of l)if(!a.includes(t))return i="'"+t+"' is not an available key",i;e.title=Ko(null==n?void 0:n.title,e.title);let o=nu("data",null==n?void 0:n.data);if("string"==typeof o)return o;e.data=o;let u=e.data.length,s=tu("dataColor",null==n?void 0:n.dataColor,u,null,Go,!0);if("string"==typeof s)return s;e.dataColor=s;let f=tu("dataName",null==n?void 0:n.dataName,u,"",null,!0);if("string"==typeof f)return f;e.dataName=f;let c=tu("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=tu("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=Ko(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=Ko(null==n?void 0:n.legendOrientation,d),e.legendBgColor=Ko(null==n?void 0:n.legendBgColor,e.legendBgColor),e.legendBorderColor=Ko(null==n?void 0:n.legendBorderColor,e.legendBorderColor),p.pie.push(e)}for(let t of A){let e=new Pl,n=r[t],a=au(e),l=au(n);for(let t of l)if(!a.includes(t))return i="'"+t+"' is not an available key",i;e.template=Ko(null==n?void 0:n.template,e.template),e.style=Ko(null==n?void 0:n.style,e.style),p.summary.push(e)}for(let t of b){let e=new zl,n=r[t],a=au(e),l=au(n);for(let t of l)if(!a.includes(t))return i="'"+t+"' is not an available key",i;e.mode=Ko(null==n?void 0:n.mode,e.mode);let o=eu("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=Ko(null==n?void 0:n.startWeekOn,e.startWeekOn),"boolean"==typeof(null==n?void 0:n.showCircle)&&(e.showCircle=n.showCircle);let s=eu("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;s.queries.some((t=>{let e=t.getType();return t.getTarget(),e===Ji.Frontmatter||e===Ji.Tag||e===Ji.Wiki||e===Ji.WikiLink||e===Ji.WikiDisplay}))&&(n=this.app.metadataCache.getFileCache(t));let r=null;s.queries.some((t=>{let e=t.getType(),n=t.getTarget();return e===Ji.Tag||e===Ji.Text||e===Ji.dvField||e===Ji.Task||e===Ji.TaskDone||e===Ji.TaskNotDone||e===Ji.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 s.xDataset)if(!a.has(e)){let l=window.moment("");if(-1===e)l=iu(t,s);else{let a=s.queries[e];switch(a.getType()){case Ji.Frontmatter:l=lu(n,a,s);break;case Ji.Tag:l=uu(r,a,s);break;case Ji.Text:l=su(r,a,s);break;case Ji.dvField:l=fu(r,a,s);break;case Ji.FileMeta:l=cu(t,a,s);break;case Ji.Task:case Ji.TaskDone:case Ji.TaskNotDone:l=hu(r,a,s)}}l.isValid()?(null!==s.startDate&&ls.endDate&&(i=!0,h.fileOutOfDateRange++)):(i=!0,h.fileNotInFormat++),i||(h.gotAnyValidXValue||(h.gotAnyValidXValue=!0),a.set(e,Kl(l,s.dateFormat)),h.fileAvailable++,1==h.fileAvailable?(h.minDate=l.clone(),h.maxDate=l.clone()):(lh.maxDate&&(h.maxDate=l.clone())))}if(i)return;const l=s.queries.filter((t=>t.getType()!==Ji.Table&&!t.usedAsXDataset)).map((i=>e(this,void 0,void 0,(function*(){if(n&&i.getType()===Ji.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),du(r,a.get(n.xDataset[e.getId()]),e,l),!0}}return!1}(n,i,s,c,a);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}if(n&&i.getType()===Ji.Frontmatter&&"tags"!==i.getTarget()){let t=function(t,e,n,r,a){let i=t.frontmatter;if(i){let t=no(i,e.getTarget());if(t){let i=io(t,n.textValueMap);if(null!==i.value)return i.type===tl.Time&&(e.valueType=tl.Time),e.addNumTargets(),du(r,a.get(n.xDataset[e.getId()]),e,i.value),!0}else if(e.getParentTarget()&&no(i,e.getParentTarget())){let t=no(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=io(l[e.getAccessor()].trim(),n.textValueMap);if(null!==t.value)return t.type===tl.Time&&(e.valueType=tl.Time),e.addNumTargets(),du(r,a.get(n.xDataset[e.getId()]),e,t.value),!0}}}return!1}(n,i,s,c,a);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}if(n&&(i.getType()===Ji.Wiki||i.getType()===Ji.WikiLink||i.getType()===Ji.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===Ji.Wiki?e=t.displayText?t.displayText:t.link:o===Ji.WikiLink?e=t.link:o===Ji.WikiDisplay?t.displayText&&(e=t.displayText):e=t.displayText?t.displayText:t.link,e=e.trim(),u+=e+"\n"}return gu(u,s,e,r,a,n)}(n,i,s,c,a);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}if(r&&i.getType()===Ji.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)),gu(t,"(^|\\s)#"+i+"(\\/[\\w-]+)*(:(?[\\d\\.\\/-]*)[a-zA-Z]*)?([\\.!,\\?;~-]*)?(\\s|$)",e,r,a,n)}(r,i,s,c,a);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}if(r&&i.getType()===Ji.Text){let t=function(t,e,n,r,a){return gu(t,e.getTarget(),e,r,a,n)}(r,i,s,c,a);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}if(i.getType()===Ji.FileMeta){let e=pu(t,r,i,s,c,a);h.gotAnyValidYValue||(h.gotAnyValidYValue=e)}if(r&&i.getType()===Ji.dvField){let t=function(t,e,n,r,a){let i=e.getTarget();return e.getParentTarget()&&(i=e.getParentTarget()),i=i.replace("-","[\\s\\-]"),gu(t,"(^| |\\t)\\*{0,2}"+i+"\\*{0,2}(::[ |\\t]*(?[\\d\\.\\/\\-,@; \\t:\\w$€£¥¢₹₨₱₩฿₫₪α-ωΑ-Ω©®℗™℠一-鿿㐀-䶿 、-〿]*))(\\r\\?\\n|\\r|$)",e,r,a,n)}(r,i,s,c,a);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}if(r&&(i.getType()===Ji.Task||i.getType()===Ji.TaskDone||i.getType()===Ji.TaskNotDone)){let t=function(t,e,n,r,a){let i=e.getType(),l=e.getTarget();return l=i===Ji.Task?"\\[[\\sx]\\]\\s"+l:i===Ji.TaskDone?"\\[x\\]\\s"+l:i===Ji.TaskNotDone?"\\[\\s\\]\\s"+l:"\\[[\\sx]\\]\\s"+l,gu(t,l,e,r,a,n)}(r,i,s,c,a);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}}))));yield Promise.all(l)}))));if(yield Promise.all(d),yield this.collectDataFromTable(c,s,h),h.errorMessage)return this.renderErrorMessage(h.errorMessage,a,r);let g="";if(h.minDate.isValid()&&h.maxDate.isValid()&&0!==h.fileAvailable&&h.gotAnyValidXValue||(g="No valid date as X value found in notes",h.fileOutOfDateRange>0&&(g+=`\n${h.fileOutOfDateRange} files are out of the date range.`),h.fileNotInFormat&&(g+=`\n${h.fileNotInFormat} files are not in the right format.`)),null===s.startDate&&null===s.endDate?(s.startDate=h.minDate.clone(),s.endDate=h.maxDate.clone()):null!==s.startDate&&null===s.endDate?s.startDateh.minDate?s.startDate=h.minDate.clone():g="Invalid date range":(s.startDateh.maxDate&&s.endDate>h.maxDate)&&(g="Invalid date range"),g)return this.renderErrorMessage(g,a,r);if(!h.gotAnyValidYValue)return this.renderErrorMessage("No valid Y value found in notes",a,r);let p=new El(s.startDate,s.endDate);for(let t of s.queries){let e=p.createDataset(t,s);e.addNumTargets(t.getNumTargets());for(let n=s.startDate.clone();n<=s.endDate;n.add(1,"days"))if(c.has(Kl(n,s.dateFormat))){let r=c.get(Kl(n,s.dateFormat)).filter((function(e){return e.query.equalTo(t)}));if(r.length>0){let t=null;for(let e=0;et.getType()===Ji.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 Hl(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=ro(t,"|"),h=t.split("|").length;let e=c.shift().trim();e=ro(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=ro(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=ro(l.trim(),"|").split("|");if(et.getAccessor(2)&&t.getAccessor(2)>=0){let e=null,o=io(l[t.getAccessor(2)].trim(),r.textValueMap);null!==o.value&&(o.type===tl.Time&&(t.valueType=tl.Time),e=o.value,i