|
|
"use strict";var t=require("obsidian");function e(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(t){try{u(r.next(t))}catch(t){a(t)}}function l(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,l)}u((r=r.apply(t,e||[])).next())}))}function n(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function r(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function i(t){let e,i,o;function l(t,n,r=0,a=t.length){if(r<a){if(0!==e(n,n))return a;do{const e=r+a>>>1;i(t[e],n)<0?r=e+1:a=e}while(r<a)}return r}return 2!==t.length?(e=n,i=(e,r)=>n(t(e),r),o=(e,n)=>t(e)-n):(e=t===n||t===r?t:a,i=t,o=t),{left:l,center:function(t,e,n=0,r=t.length){const i=l(t,e,n,r-1);return i>n&&o(t[i-1],e)>-o(t[i],e)?i-1:i},right:function(t,n,r=0,a=t.length){if(r<a){if(0!==e(n,n))return a;do{const e=r+a>>>1;i(t[e],n)<=0?r=e+1:a=e}while(r<a)}return r}}}function a(){return 0}"function"==typeof SuppressedError&&SuppressedError;const o=i(n).right;i((function(t){return null===t?NaN:+t})).center;class l extends Map{constructor(t,e=s){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),null!=t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(u(this,t))}has(t){return super.has(u(this,t))}set(t,e){return super.set(function({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}(this,t),e)}delete(t){return super.delete(function({_intern:t,_key:e},n){const r=e(n);t.has(r)&&(n=t.get(r),t.delete(r));return n}(this,t))}}function u({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function s(t){return null!==t&&"object"==typeof t?t.valueOf():t}function f(t,e){return(null==t||!(t>=t))-(null==e||!(e>=e))||(t<e?-1:t>e?1:0)}const c=Math.sqrt(50),h=Math.sqrt(10),d=Math.sqrt(2);function g(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=c?10:a>=h?5:a>=d?2:1;let l,u,s;return i<0?(s=Math.pow(10,-i)/o,l=Math.round(t*s),u=Math.round(e*s),l/s<t&&++l,u/s>e&&--u,s=-s):(s=Math.pow(10,i)*o,l=Math.round(t/s),u=Math.round(e/s),l*s<t&&++l,u*s>e&&--u),u<l&&.5<=n&&n<2?g(t,e,2*n):[l,u,s]}function p(t,e,n){return g(t=+t,e=+e,n=+n)[2]}function y(t,e,n){n=+n;const r=(e=+e)<(t=+t),i=r?p(e,t,n):p(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function m(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 i of t)null!=(i=e(i,++r,t))&&(n<i||void 0===n&&i>=i)&&(n=i)}return n}function v(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 i of t)null!=(i=e(i,++r,t))&&(n>i||void 0===n&&i>=i)&&(n=i)}return n}function x(t,e,r=0,i=1/0,a){if(e=Math.floor(e),r=Math.floor(Math.max(0,r)),i=Math.floor(Math.min(t.length-1,i)),!(r<=e&&e<=i))return t;for(a=void 0===a?f:function(t=n){if(t===n)return f;if("function"!=typeof t)throw new TypeError("compare is not a function");return(e,n)=>{const r=t(e,n);return r||0===r?r:(0===t(n,n))-(0===t(e,e))}}(a);i>r;){if(i-r>600){const n=i-r+1,o=e-r+1,l=Math.log(n),u=.5*Math.exp(2*l/3),s=.5*Math.sqrt(l*u*(n-u)/n)*(o-n/2<0?-1:1);x(t,e,Math.max(r,Math.floor(e-o*u/n+s)),Math.min(i,Math.floor(e+(n-o)*u/n+s)),a)}const n=t[e];let o=r,l=i;for(A(t,r,e),a(t[i],n)>0&&A(t,r,i);o<l;){for(A(t,o,l),++o,--l;a(t[o],n)<0;)++o;for(;a(t[l],n)>0;)--l}0===a(t[r],n)?A(t,r,l):(++l,A(t,l,i)),l<=e&&(r=l+1),e<=l&&(i=l-1)}return t}function A(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function w(t,e){return function(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)&&!isNaN(e=+e)){if(e<=0||r<2)return v(t);if(e>=1)return m(t);var r,i=(r-1)*e,a=Math.floor(i),o=m(x(t,a).subarray(0,a+1));return o+(v(t.subarray(a+1))-o)*(i-a)}}(t,.5,e)}function b(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=0|Math.max(0,Math.ceil((e-t)/n)),a=new Array(i);++r<i;)a[r]=t+r*n;return a}function D(t,e){let n=0;if(void 0===e)for(let e of t)(e=+e)&&(n+=e);else{let r=-1;for(let i of t)(i=+e(i,++r,t))&&(n+=i)}return n}function k(t){return t}var C=1,M=2,T=3,_=4,E=1e-6;function F(t){return"translate("+t+",0)"}function S(t){return"translate(0,"+t+")"}function B(t){return e=>+t(e)}function N(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function I(){return!this.__axis}function L(t,e){var n=[],r=null,i=null,a=6,o=6,l=3,u="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,s=t===C||t===_?-1:1,f=t===_||t===M?"x":"y",c=t===C||t===T?F:S;function h(h){var d=null==r?e.ticks?e.ticks.apply(e,n):e.domain():r,g=null==i?e.tickFormat?e.tickFormat.apply(e,n):k:i,p=Math.max(a,0)+l,y=e.range(),m=+y[0]+u,v=+y[y.length-1]+u,x=(e.bandwidth?N:B)(e.copy(),u),A=h.selection?h.selection():h,w=A.selectAll(".domain").data([null]),b=A.selectAll(".tick").data(d,e).order(),D=b.exit(),F=b.enter().append("g").attr("class","tick"),S=b.select("line"),L=b.select("text");w=w.merge(w.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),b=b.merge(F),S=S.merge(F.append("line").attr("stroke","currentColor").attr(f+"2",s*a)),L=L.merge(F.append("text").attr("fill","currentColor").attr(f,s*p).attr("dy",t===C?"0em":t===T?"0.71em":"0.32em")),h!==A&&(w=w.transition(h),b=b.transition(h),S=S.transition(h),L=L.transition(h),D=D.transition(h).attr("opacity",E).attr("transform",(function(t){return isFinite(t=x(t))?c(t+u):this.getAttribute("transform")})),F.attr("opacity",E).attr("transform",(function(t){var e=this.parentNode.__axis;return c((e&&isFinite(e=e(t))?e:x(t))+u)}))),D.remove(),w.attr("d",t===_||t===M?o?"M"+s*o+","+m+"H"+u+"V"+v+"H"+s*o:"M"+u+","+m+"V"+v:o?"M"+m+","+s*o+"V"+u+"H"+v+"V"+s*o:"M"+m+","+u+"H"+v),b.attr("opacity",1).attr("transform",(function(t){return c(x(t)+u)})),S.attr(f+"2",s*a),L.attr(f,s*p).text(g),A.filter(I).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===M?"start":t===_?"end":"middle"),A.each((function(){this.__axis=x}))}return h.scale=function(t){return arguments.length?(e=t,h):e},h.ticks=function(){return n=Array.from(arguments),h},h.tickArguments=function(t){return arguments.length?(n=null==t?[]:Array.from(t),h):n.slice()},h.tickValues=function(t){return arguments.length?(r=null==t?null:Array.from(t),h):r&&r.slice()},h.tickFormat=function(t){return arguments.length?(i=t,h):i},h.tickSize=function(t){return arguments.length?(a=o=+t,h):a},h.tickSizeInner=function(t){return arguments.length?(a=+t,h):a},h.tickSizeOuter=function(t){return arguments.length?(o=+t,h):o},h.tickPadding=function(t){return arguments.length?(l=+t,h):l},h.offset=function(t){return arguments.length?(u=+t,h):u},h}function V(t){return L(T,t)}function O(t){return L(_,t)}var P={value:()=>{}};function $(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new Y(r)}function Y(t){this._=t}function z(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function R(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=P,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}Y.prototype=$.prototype={constructor:Y,on:function(t,e){var n,r,i=this._,a=(r=i,(t+"").trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),o=-1,l=a.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++o<l;)if(n=(t=a[o]).type)i[n]=R(i[n],t.name,e);else if(null==e)for(n in i)i[n]=R(i[n],t.name,null);return this}for(;++o<l;)if((n=(t=a[o]).type)&&(n=z(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Y(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),a=0;a<n;++a)i[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=0,n=(r=this._[t]).length;a<n;++a)r[a].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n)}};var U="http://www.w3.org/1999/xhtml",H={svg:"http://www.w3.org/2000/svg",xhtml:U,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function X(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),H.hasOwnProperty(e)?{space:H[e],local:t}:t}function W(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===U&&e.documentElement.namespaceURI===U?e.createElement(t):e.createElementNS(n,t)}}function j(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function q(t){var e=X(t);return(e.local?j:W)(e)}function G(){}function Q(t){return null==t?G:function(){return this.querySelector(t)}}function Z(){return[]}function K(t){return null==t?Z:function(){return this.querySelectorAll(t)}}function J(t){return function(){return function(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}(t.apply(this,arguments))}}function tt(t){return function(){return this.matches(t)}}function et(t){return function(e){return e.matches(t)}}var nt=Array.prototype.find;function rt(){return this.firstElementChild}var it=Array.prototype.filter;function at(){return Array.from(this.children)}function ot(t){return new Array(t.length)}function lt(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function ut(t,e,n,r,i,a){for(var o,l=0,u=e.length,s=a.length;l<s;++l)(o=e[l])?(o.__data__=a[l],r[l]=o):n[l]=new lt(t,a[l]);for(;l<u;++l)(o=e[l])&&(i[l]=o)}function st(t,e,n,r,i,a,o){var l,u,s,f=new Map,c=e.length,h=a.length,d=new Array(c);for(l=0;l<c;++l)(u=e[l])&&(d[l]=s=o.call(u,u.__data__,l,e)+"",f.has(s)?i[l]=u:f.set(s,u));for(l=0;l<h;++l)s=o.call(t,a[l],l,a)+"",(u=f.get(s))?(r[l]=u,u.__data__=a[l],f.delete(s)):n[l]=new lt(t,a[l]);for(l=0;l<c;++l)(u=e[l])&&f.get(d[l])===u&&(i[l]=u)}function ft(t){return t.__data__}function ct(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function ht(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function dt(t){return function(){this.removeAttribute(t)}}function gt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function pt(t,e){return function(){this.setAttribute(t,e)}}function yt(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function mt(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function vt(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 xt(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function At(t){return function(){this.style.removeProperty(t)}}function wt(t,e,n){return function(){this.style.setProperty(t,e,n)}}function bt(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function Dt(t,e){return t.style.getPropertyValue(e)||xt(t).getComputedStyle(t,null).getPropertyValue(e)}function kt(t){return function(){delete this[t]}}function Ct(t,e){return function(){this[t]=e}}function Mt(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function Tt(t){return t.trim().split(/^|\s+/)}function _t(t){return t.classList||new Et(t)}function Et(t){this._node=t,this._names=Tt(t.getAttribute("class")||"")}function Ft(t,e){for(var n=_t(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function St(t,e){for(var n=_t(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function Bt(t){return function(){Ft(this,t)}}function Nt(t){return function(){St(this,t)}}function It(t,e){return function(){(e.apply(this,arguments)?Ft:St)(this,t)}}function Lt(){this.textContent=""}function Vt(t){return function(){this.textContent=t}}function Ot(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function Pt(){this.innerHTML=""}function $t(t){return function(){this.innerHTML=t}}function Yt(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function zt(){this.nextSibling&&this.parentNode.appendChild(this)}function Rt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ut(){return null}function Ht(){var t=this.parentNode;t&&t.removeChild(this)}function Xt(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Wt(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function jt(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,a=e.length;r<a;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function qt(t,e,n){return function(){var r,i=this.__on,a=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var o=0,l=i.length;o<l;++o)if((r=i[o]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=a,r.options=n),void(r.value=e);this.addEventListener(t.type,a,n),r={type:t.type,name:t.name,value:e,listener:a,options:n},i?i.push(r):this.__on=[r]}}function Gt(t,e,n){var r=xt(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function Qt(t,e){return function(){return Gt(this,t,e)}}function Zt(t,e){return function(){return Gt(this,t,e.apply(this,arguments))}}lt.prototype={constructor:lt,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},Et.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Kt=[null];function Jt(t,e){this._groups=t,this._parents=e}function te(){return new Jt([[document.documentElement]],Kt)}function ee(t){return"string"==typeof t?new Jt([[document.querySelector(t)]],[document.documentElement]):new Jt([[t]],Kt)}function ne(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function re(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function ie(){}Jt.prototype=te.prototype={constructor:Jt,select:function(t){"function"!=typeof t&&(t=Q(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o,l=e[i],u=l.length,s=r[i]=new Array(u),f=0;f<u;++f)(a=l[f])&&(o=t.call(a,a.__data__,f,l))&&("__data__"in a&&(o.__data__=a.__data__),s[f]=o);return new Jt(r,this._parents)},selectAll:function(t){t="function"==typeof t?J(t):K(t);for(var e=this._groups,n=e.length,r=[],i=[],a=0;a<n;++a)for(var o,l=e[a],u=l.length,s=0;s<u;++s)(o=l[s])&&(r.push(t.call(o,o.__data__,s,l)),i.push(o));return new Jt(r,i)},selectChild:function(t){return this.select(null==t?rt:function(t){return function(){return nt.call(this.children,t)}}("function"==typeof t?t:et(t)))},selectChildren:function(t){return this.selectAll(null==t?at:function(t){return function(){return it.call(this.children,t)}}("function"==typeof t?t:et(t)))},filter:function(t){"function"!=typeof t&&(t=tt(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],l=o.length,u=r[i]=[],s=0;s<l;++s)(a=o[s])&&t.call(a,a.__data__,s,o)&&u.push(a);return new Jt(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,ft);var n=e?st:ut,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var a=i.length,o=new Array(a),l=new Array(a),u=new Array(a),s=0;s<a;++s){var f=r[s],c=i[s],h=c.length,d=ct(t.call(f,f&&f.__data__,s,r)),g=d.length,p=l[s]=new Array(g),y=o[s]=new Array(g);n(f,c,p,y,u[s]=new Array(h),d,e);for(var m,v,x=0,A=0;x<g;++x)if(m=p[x]){for(x>=A&&(A=x+1);!(v=y[A])&&++A<g;);m._next=v||null}}return(o=new Jt(o,r))._enter=l,o._exit=u,o},enter:function(){return new Jt(this._enter||this._groups.map(ot),this._parents)},exit:function(){return new Jt(this._exit||this._groups.map(ot),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,a=this.exit();return"function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=e&&(i=e(i))&&(i=i.selection()),null==n?a.remove():n(a),r&&i?r.merge(i).order():i},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,a=r.length,o=Math.min(i,a),l=new Array(i),u=0;u<o;++u)for(var s,f=n[u],c=r[u],h=f.length,d=l[u]=new Array(h),g=0;g<h;++g)(s=f[g]||c[g])&&(d[g]=s);for(;u<i;++u)l[u]=n[u];return new Jt(l,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],a=i.length-1,o=i[a];--a>=0;)(r=i[a])&&(o&&4^r.compareDocumentPosition(o)&&o.parentNode.insertBefore(r,o),o=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=ht);for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a){for(var o,l=n[a],u=l.length,s=i[a]=new Array(u),f=0;f<u;++f)(o=l[f])&&(s[f]=o);s.sort(e)}return new Jt(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i,a=e[n],o=0,l=a.length;o<l;++o)(i=a[o])&&t.call(i,i.__data__,o,a);return this},attr:function(t,e){var n=X(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?gt:dt:"function"==typeof e?n.local?vt:mt:n.local?yt:pt)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?At:"function"==typeof e?bt:wt)(t,e,null==n?"":n)):Dt(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?kt:"function"==typeof e?Mt:Ct)(t,e)):this.node()[t]},classed:function(t,e){var n=Tt(t+"");if(arguments.length<2){for(var r=_t(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?It:e?Bt:Nt)(n,e))},text:function(t){return arguments.length?this.each(null==t?Lt:("function"==typeof t?Ot:Vt)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?Pt:("function"==typeof t?Yt:$t)(t)):this.node().innerHTML},raise:function(){return this.each(zt)},lower:function(){return this.each(Rt)},append:function(t){var e="function"==typeof t?t:q(t);return this.select((function(){return this.appendChild(e.apply(this,arguments))}))},insert:function(t,e){var n="function"==typeof t?t:q(t),r=null==e?Ut:"function"==typeof e?e:Q(e);return this.select((function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)}))},remove:function(){return this.each(Ht)},clone:function(t){return this.select(t?Wt:Xt)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,a=function(t){return t.trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}(t+""),o=a.length;if(!(arguments.length<2)){for(l=e?qt:jt,r=0;r<o;++r)this.each(l(a[r],e,n));return this}var l=this.node().__on;if(l)for(var u,s=0,f=l.length;s<f;++s)for(r=0,u=l[s];r<o;++r)if((i=a[r]).type===u.type&&i.name===u.name)return u.value},dispatch:function(t,e){return this.each(("function"==typeof e?Zt:Qt)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],a=0,o=i.length;a<o;++a)(r=i[a])&&(yield r)}};var ae=.7,oe=1/ae,le="\\s*([+-]?\\d+)\\s*",ue="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",se="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",fe=/^#([0-9a-f]{3,8})$/,ce=new RegExp(`^rgb\\(${le},${le},${le}\\)$`),he=new RegExp(`^rgb\\(${se},${se},${se}\\)$`),de=new RegExp(`^rgba\\(${le},${le},${le},${ue}\\)$`),ge=new RegExp(`^rgba\\(${se},${se},${se},${ue}\\)$`),pe=new RegExp(`^hsl\\(${ue},${se},${se}\\)$`),ye=new RegExp(`^hsla\\(${ue},${se},${se},${ue}\\)$`),me={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function ve(){return this.rgb().formatHex()}function xe(){return this.rgb().formatRgb()}function Ae(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=fe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?we(e):3===n?new Ce(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?be(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?be(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=ce.exec(t))?new Ce(e[1],e[2],e[3],1):(e=he.exec(t))?new Ce(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=de.exec(t))?be(e[1],e[2],e[3],e[4]):(e=ge.exec(t))?be(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=pe.exec(t))?Se(e[1],e[2]/100,e[3]/100,1):(e=ye.exec(t))?Se(e[1],e[2]/100,e[3]/100,e[4]):me.hasOwnProperty(t)?we(me[t]):"transparent"===t?new Ce(NaN,NaN,NaN,0):null}function we(t){return new Ce(t>>16&255,t>>8&255,255&t,1)}function be(t,e,n,r){return r<=0&&(t=e=n=NaN),new Ce(t,e,n,r)}function De(t){return t instanceof ie||(t=Ae(t)),t?new Ce((t=t.rgb()).r,t.g,t.b,t.opacity):new Ce}function ke(t,e,n,r){return 1===arguments.length?De(t):new Ce(t,e,n,null==r?1:r)}function Ce(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function Me(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}`}function Te(){const t=_e(this.opacity);return`${1===t?"rgb(":"rgba("}${Ee(this.r)}, ${Ee(this.g)}, ${Ee(this.b)}${1===t?")":`, ${t})`}`}function _e(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Ee(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Fe(t){return((t=Ee(t))<16?"0":"")+t.toString(16)}function Se(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Ne(t,e,n,r)}function Be(t){if(t instanceof Ne)return new Ne(t.h,t.s,t.l,t.opacity);if(t instanceof ie||(t=Ae(t)),!t)return new Ne;if(t instanceof Ne)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,l=a-i,u=(a+i)/2;return l?(o=e===a?(n-r)/l+6*(n<r):n===a?(r-e)/l+2:(e-n)/l+4,l/=u<.5?a+i:2-a-i,o*=60):l=u>0&&u<1?0:o,new Ne(o,l,u,t.opacity)}function Ne(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Ie(t){return(t=(t||0)%360)<0?t+360:t}function Le(t){return Math.max(0,Math.min(1,t||0))}function Ve(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}ne(ie,Ae,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:ve,formatHex:ve,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Be(this).formatHsl()},formatRgb:xe,toString:xe}),ne(Ce,ke,re(ie,{brighter(t){return t=null==t?oe:Math.pow(oe,t),new Ce(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?ae:Math.pow(ae,t),new Ce(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ce(Ee(this.r),Ee(this.g),Ee(this.b),_e(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Me,formatHex:Me,formatHex8:function(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}${Fe(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Te,toString:Te})),ne(Ne,(function(t,e,n,r){return 1===arguments.length?Be(t):new Ne(t,e,n,null==r?1:r)}),re(ie,{brighter(t){return t=null==t?oe:Math.pow(oe,t),new Ne(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?ae:Math.pow(ae,t),new Ne(this.h,this.s,this.l*t,this.opacity)},rgb(){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,i=2*n-r;return new Ce(Ve(t>=240?t-240:t+120,i,r),Ve(t,i,r),Ve(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Ne(Ie(this.h),Le(this.s),Le(this.l),_e(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=_e(this.opacity);return`${1===t?"hsl(":"hsla("}${Ie(this.h)}, ${100*Le(this.s)}%, ${100*Le(this.l)}%${1===t?")":`, ${t})`}`}}));const Oe=Math.PI/180,Pe=180/Math.PI,$e=.96422,Ye=1,ze=.82521,Re=4/29,Ue=6/29,He=3*Ue*Ue,Xe=Ue*Ue*Ue;function We(t){if(t instanceof qe)return new qe(t.l,t.a,t.b,t.opacity);if(t instanceof Je)return tn(t);t instanceof Ce||(t=De(t));var e,n,r=Ke(t.r),i=Ke(t.g),a=Ke(t.b),o=Ge((.2225045*r+.7168786*i+.0606169*a)/Ye);return r===i&&i===a?e=n=o:(e=Ge((.4360747*r+.3850649*i+.1430804*a)/$e),n=Ge((.0139322*r+.0971045*i+.7141733*a)/ze)),new qe(116*o-16,500*(e-o),200*(o-n),t.opacity)}function je(t,e,n,r){return 1===arguments.length?We(t):new qe(t,e,n,null==r?1:r)}function qe(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r}function Ge(t){return t>Xe?Math.pow(t,1/3):t/He+Re}function Qe(t){return t>Ue?t*t*t:He*(t-Re)}function Ze(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Ke(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Je(t,e,n,r){this.h=+t,this.c=+e,this.l=+n,this.opacity=+r}function tn(t){if(isNaN(t.h))return new qe(t.l,0,0,t.opacity);var e=t.h*Oe;return new qe(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity)}ne(qe,je,re(ie,{brighter(t){return new qe(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker(t){return new qe(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,n=isNaN(this.b)?t:t-this.b/200;return new Ce(Ze(3.1338561*(e=$e*Qe(e))-1.6168667*(t=Ye*Qe(t))-.4906146*(n=ze*Qe(n))),Ze(-.9787684*e+1.9161415*t+.033454*n),Ze(.0719453*e-.2289914*t+1.4052427*n),this.opacity)}})),ne(Je,(function(t,e,n,r){return 1===arguments.length?function(t){if(t instanceof Je)return new Je(t.h,t.c,t.l,t.opacity);if(t instanceof qe||(t=We(t)),0===t.a&&0===t.b)return new Je(NaN,0<t.l&&t.l<100?0:NaN,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*Pe;return new Je(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}(t):new Je(t,e,n,null==r?1:r)}),re(ie,{brighter(t){return new Je(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker(t){return new Je(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb(){return tn(this).rgb()}}));var en=t=>()=>t;function nn(t){return 1==(t=+t)?rn: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):en(isNaN(e)?n:e)}}function rn(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):en(isNaN(t)?e:t)}var an=function t(e){var n=nn(e);function r(t,e){var r=n((t=ke(t)).r,(e=ke(e)).r),i=n(t.g,e.g),a=n(t.b,e.b),o=rn(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=a(e),t.opacity=o(e),t+""}}return r.gamma=t,r}(1);var on,ln=(on=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),i=t[r],a=t[r+1],o=r>0?t[r-1]:2*i-a,l=r<e-1?t[r+2]:2*a-i;return function(t,e,n,r,i){var a=t*t,o=a*t;return((1-3*t+3*a-o)*e+(4-6*a+3*o)*n+(1+3*t+3*a-3*o)*r+o*i)/6}((n-r/e)*e,o,i,a,l)}},function(t){var e,n,r=t.length,i=new Array(r),a=new Array(r),o=new Array(r);for(e=0;e<r;++e)n=ke(t[e]),i[e]=n.r||0,a[e]=n.g||0,o[e]=n.b||0;return i=on(i),a=on(a),o=on(o),n.opacity=1,function(t){return n.r=i(t),n.g=a(t),n.b=o(t),n+""}});function un(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,i=e.slice();return function(a){for(n=0;n<r;++n)i[n]=t[n]*(1-a)+e[n]*a;return i}}function sn(t,e){var n,r=e?e.length:0,i=t?Math.min(r,t.length):0,a=new Array(i),o=new Array(r);for(n=0;n<i;++n)a[n]=yn(t[n],e[n]);for(;n<r;++n)o[n]=e[n];return function(t){for(n=0;n<i;++n)o[n]=a[n](t);return o}}function fn(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function cn(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function hn(t,e){var n,r={},i={};for(n in null!==t&&"object"==typeof t||(t={}),null!==e&&"object"==typeof e||(e={}),e)n in t?r[n]=yn(t[n],e[n]):i[n]=e[n];return function(t){for(n in r)i[n]=r[n](t);return i}}var dn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,gn=new RegExp(dn.source,"g");function pn(t,e){var n,r,i,a=dn.lastIndex=gn.lastIndex=0,o=-1,l=[],u=[];for(t+="",e+="";(n=dn.exec(t))&&(r=gn.exec(e));)(i=r.index)>a&&(i=e.slice(a,i),l[o]?l[o]+=i:l[++o]=i),(n=n[0])===(r=r[0])?l[o]?l[o]+=r:l[++o]=r:(l[++o]=null,u.push({i:o,x:cn(n,r)})),a=gn.lastIndex;return a<e.length&&(i=e.slice(a),l[o]?l[o]+=i:l[++o]=i),l.length<2?u[0]?function(t){return function(e){return t(e)+""}}(u[0].x):function(t){return function(){return t}}(e):(e=u.length,function(t){for(var n,r=0;r<e;++r)l[(n=u[r]).i]=n.x(t);return l.join("")})}function yn(t,e){var n,r=typeof e;return null==e||"boolean"===r?en(e):("number"===r?cn:"string"===r?(n=Ae(e))?(e=n,an):pn:e instanceof Ae?an:e instanceof Date?fn:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(e)?un:Array.isArray(e)?sn:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?hn:cn)(t,e)}function mn(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var vn,xn=180/Math.PI,An={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function wn(t,e,n,r,i,a){var o,l,u;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(u=t*n+e*r)&&(n-=t*u,r-=e*u),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,u/=l),t*r<e*n&&(t=-t,e=-e,u=-u,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(e,t)*xn,skewX:Math.atan(u)*xn,scaleX:o,scaleY:l}}function bn(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(a,o){var l=[],u=[];return a=t(a),o=t(o),function(t,r,i,a,o,l){if(t!==i||r!==a){var u=o.push("translate(",null,e,null,n);l.push({i:u-4,x:cn(t,i)},{i:u-2,x:cn(r,a)})}else(i||a)&&o.push("translate("+i+e+a+n)}(a.translateX,a.translateY,o.translateX,o.translateY,l,u),function(t,e,n,a){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),a.push({i:n.push(i(n)+"rotate(",null,r)-2,x:cn(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(a.rotate,o.rotate,l,u),function(t,e,n,a){t!==e?a.push({i:n.push(i(n)+"skewX(",null,r)-2,x:cn(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(a.skewX,o.skewX,l,u),function(t,e,n,r,a,o){if(t!==n||e!==r){var l=a.push(i(a)+"scale(",null,",",null,")");o.push({i:l-4,x:cn(t,n)},{i:l-2,x:cn(e,r)})}else 1===n&&1===r||a.push(i(a)+"scale("+n+","+r+")")}(a.scaleX,a.scaleY,o.scaleX,o.scaleY,l,u),a=o=null,function(t){for(var e,n=-1,r=u.length;++n<r;)l[(e=u[n]).i]=e.x(t);return l.join("")}}}var Dn=bn((function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?An:wn(e.a,e.b,e.c,e.d,e.e,e.f)}),"px, ","px)","deg)"),kn=bn((function(t){return null==t?An:(vn||(vn=document.createElementNS("http://www.w3.org/2000/svg","g")),vn.setAttribute("transform",t),(t=vn.transform.baseVal.consolidate())?wn((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):An)}),", ",")",")");function Cn(t,e){var n=rn((t=je(t)).l,(e=je(e)).l),r=rn(t.a,e.a),i=rn(t.b,e.b),a=rn(t.opacity,e.opacity);return function(e){return t.l=n(e),t.a=r(e),t.b=i(e),t.opacity=a(e),t+""}}var Mn,Tn,_n=0,En=0,Fn=0,Sn=1e3,Bn=0,Nn=0,In=0,Ln="object"==typeof performance&&performance.now?performance:Date,Vn="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function On(){return Nn||(Vn(Pn),Nn=Ln.now()+In)}function Pn(){Nn=0}function $n(){this._call=this._time=this._next=null}function Yn(t,e,n){var r=new $n;return r.restart(t,e,n),r}function zn(){Nn=(Bn=Ln.now())+In,_n=En=0;try{!function(){On(),++_n;for(var t,e=Mn;e;)(t=Nn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--_n}()}finally{_n=0,function(){var t,e,n=Mn,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:Mn=e);Tn=t,Un(r)}(),Nn=0}}function Rn(){var t=Ln.now(),e=t-Bn;e>Sn&&(In-=e,Bn=t)}function Un(t){_n||(En&&(En=clearTimeout(En)),t-Nn>24?(t<1/0&&(En=setTimeout(zn,t-Ln.now()-In)),Fn&&(Fn=clearInterval(Fn))):(Fn||(Bn=Ln.now(),Fn=setInterval(Rn,Sn)),_n=1,Vn(zn)))}function Hn(t,e,n){var r=new $n;return e=null==e?0:+e,r.restart((n=>{r.stop(),t(n+e)}),e,n),r}$n.prototype=Yn.prototype={constructor:$n,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?On():+n)+(null==e?0:+e),this._next||Tn===this||(Tn?Tn._next=this:Mn=this,Tn=this),this._call=t,this._time=n,Un()},stop:function(){this._call&&(this._call=null,this._time=1/0,Un())}};var Xn=$("start","end","cancel","interrupt"),Wn=[],jn=0,qn=1,Gn=2,Qn=3,Zn=4,Kn=5,Jn=6;function tr(t,e,n,r,i,a){var o=t.__transition;if(o){if(n in o)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function a(t){n.state=qn,n.timer.restart(o,n.delay,n.time),n.delay<=t&&o(t-n.delay)}function o(a){var s,f,c,h;if(n.state!==qn)return u();for(s in i)if((h=i[s]).name===n.name){if(h.state===Qn)return Hn(o);h.state===Zn?(h.state=Jn,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete i[s]):+s<e&&(h.state=Jn,h.timer.stop(),h.on.call("cancel",t,t.__data__,h.index,h.group),delete i[s])}if(Hn((function(){n.state===Qn&&(n.state=Zn,n.timer.restart(l,n.delay,n.time),l(a))})),n.state=Gn,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Gn){for(n.state=Qn,r=new Array(c=n.tween.length),s=0,f=-1;s<c;++s)(h=n.tween[s].value.call(t,t.__data__,n.index,n.group))&&(r[++f]=h);r.length=f+1}}function l(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(u),n.state=Kn,1),a=-1,o=r.length;++a<o;)r[a].call(t,i);n.state===Kn&&(n.on.call("end",t,t.__data__,n.index,n.group),u())}function u(){for(var r in n.state=Jn,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=Yn(a,0,n.time)}(t,n,{name:e,index:r,group:i,on:Xn,tween:Wn,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:jn})}function er(t,e){var n=rr(t,e);if(n.state>jn)throw new Error("too late; already scheduled");return n}function nr(t,e){var n=rr(t,e);if(n.state>Qn)throw new Error("too late; already running");return n}function rr(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function ir(t,e){var n,r;return function(){var i=nr(this,t),a=i.tween;if(a!==n)for(var o=0,l=(r=n=a).length;o<l;++o)if(r[o].name===e){(r=r.slice()).splice(o,1);break}i.tween=r}}function ar(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var a=nr(this,t),o=a.tween;if(o!==r){i=(r=o).slice();for(var l={name:e,value:n},u=0,s=i.length;u<s;++u)if(i[u].name===e){i[u]=l;break}u===s&&i.push(l)}a.tween=i}}function or(t,e,n){var r=t._id;return t.each((function(){var t=nr(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)})),function(t){return rr(t,r).value[e]}}function lr(t,e){var n;return("number"==typeof e?cn:e instanceof Ae?an:(n=Ae(e))?(e=n,an):pn)(t,e)}function ur(t){return function(){this.removeAttribute(t)}}function sr(t){return function(){this.removeAttributeNS(t.space,t.local)}}function fr(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttribute(t);return o===a?null:o===r?i:i=e(r=o,n)}}function cr(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttributeNS(t.space,t.local);return o===a?null:o===r?i:i=e(r=o,n)}}function hr(t,e,n){var r,i,a;return function(){var o,l,u=n(this);if(null!=u)return(o=this.getAttribute(t))===(l=u+"")?null:o===r&&l===i?a:(i=l,a=e(r=o,u));this.removeAttribute(t)}}function dr(t,e,n){var r,i,a;return function(){var o,l,u=n(this);if(null!=u)return(o=this.getAttributeNS(t.space,t.local))===(l=u+"")?null:o===r&&l===i?a:(i=l,a=e(r=o,u));this.removeAttributeNS(t.space,t.local)}}function gr(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}(t,i)),n}return i._value=e,i}function pr(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}(t,i)),n}return i._value=e,i}function yr(t,e){return function(){er(this,t).delay=+e.apply(this,arguments)}}function mr(t,e){return e=+e,function(){er(this,t).delay=e}}function vr(t,e){return function(){nr(this,t).duration=+e.apply(this,arguments)}}function xr(t,e){return e=+e,function(){nr(this,t).duration=e}}var Ar=te.prototype.constructor;function wr(t){return function(){this.style.removeProperty(t)}}var br=0;function Dr(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function kr(){return++br}var Cr=te.prototype;Dr.prototype={constructor:Dr,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=Q(t));for(var r=this._groups,i=r.length,a=new Array(i),o=0;o<i;++o)for(var l,u,s=r[o],f=s.length,c=a[o]=new Array(f),h=0;h<f;++h)(l=s[h])&&(u=t.call(l,l.__data__,h,s))&&("__data__"in l&&(u.__data__=l.__data__),c[h]=u,tr(c[h],e,n,h,c,rr(l,n)));return new Dr(a,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=K(t));for(var r=this._groups,i=r.length,a=[],o=[],l=0;l<i;++l)for(var u,s=r[l],f=s.length,c=0;c<f;++c)if(u=s[c]){for(var h,d=t.call(u,u.__data__,c,s),g=rr(u,n),p=0,y=d.length;p<y;++p)(h=d[p])&&tr(h,e,n,p,d,g);a.push(d),o.push(u)}return new Dr(a,o,e,n)},selectChild:Cr.selectChild,selectChildren:Cr.selectChildren,filter:function(t){"function"!=typeof t&&(t=tt(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],l=o.length,u=r[i]=[],s=0;s<l;++s)(a=o[s])&&t.call(a,a.__data__,s,o)&&u.push(a);return new Dr(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,a=Math.min(r,i),o=new Array(r),l=0;l<a;++l)for(var u,s=e[l],f=n[l],c=s.length,h=o[l]=new Array(c),d=0;d<c;++d)(u=s[d]||f[d])&&(h[d]=u);for(;l<r;++l)o[l]=e[l];return new Dr(o,this._parents,this._name,this._id)},selection:function(){return new Ar(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=kr(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o,l=r[a],u=l.length,s=0;s<u;++s)if(o=l[s]){var f=rr(o,e);tr(o,t,n,s,l,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Dr(r,this._parents,t,n)},call:Cr.call,nodes:Cr.nodes,node:Cr.node,size:Cr.size,empty:Cr.empty,each:Cr.each,on:function(t,e){var n=this._id;return arguments.length<2?rr(this.node(),n).on.on(t):this.each(function(t,e,n){var r,i,a=function(t){return(t+"").trim().split(/^|\s+/).every((function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?er:nr;return function(){var o=a(this,t),l=o.on;l!==r&&(i=(r=l).copy()).on(e,n),o.on=i}}(n,t,e))},attr:function(t,e){var n=X(t),r="transform"===n?kn:lr;return this.attrTween(t,"function"==typeof e?(n.local?dr:hr)(n,r,or(this,"attr."+t,e)):null==e?(n.local?sr:ur)(n):(n.local?cr:fr)(n,r,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var r=X(t);return this.tween(n,(r.local?gr:pr)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?Dn:lr;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var a=Dt(this,t),o=(this.style.removeProperty(t),Dt(this,t));return a===o?null:a===n&&o===r?i:i=e(n=a,r=o)}}(t,r)).on("end.style."+t,wr(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,a;return function(){var o=Dt(this,t),l=n(this),u=l+"";return null==l&&(this.style.removeProperty(t),u=l=Dt(this,t)),o===u?null:o===r&&u===i?a:(i=u,a=e(r=o,l))}}(t,r,or(this,"style."+t,e))).each(function(t,e){var n,r,i,a,o="style."+e,l="end."+o;return function(){var u=nr(this,t),s=u.on,f=null==u.value[o]?a||(a=wr(e)):void 0;s===n&&i===f||(r=(n=s).copy()).on(l,i=f),u.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,a=n+"";return function(){var o=Dt(this,t);return o===a?null:o===r?i:i=e(r=o,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,function(t,e,n){var r,i;function a(){var a=e.apply(this,arguments);return a!==i&&(r=(i=a)&&function(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}(t,a,n)),r}return a._value=e,a}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(or(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&function(t){return function(e){this.textContent=t.call(this,e)}}(r)),e}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=rr(this.node(),n).tween,a=0,o=i.length;a<o;++a)if((r=i[a]).name===t)return r.value;return null}return this.each((null==e?ir:ar)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?yr:mr)(e,t)):rr(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?vr:xr)(e,t)):rr(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(function(t,e){if("function"!=typeof e)throw new Error;return function(){nr(this,t).ease=e}}(e,t)):rr(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw new Error;nr(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise((function(a,o){var l={value:o},u={value:function(){0==--i&&a()}};n.each((function(){var n=nr(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(l),e._.interrupt.push(l),e._.end.push(u)),n.on=e})),0===i&&a()}))},[Symbol.iterator]:Cr[Symbol.iterator]};var Mr={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function Tr(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}te.prototype.interrupt=function(t){return this.each((function(){!function(t,e){var n,r,i,a=t.__transition,o=!0;if(a){for(i in e=null==e?null:e+"",a)(n=a[i]).name===e?(r=n.state>Gn&&n.state<Kn,n.state=Jn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete a[i]):o=!1;o&&delete t.__transition}}(this,t)}))},te.prototype.transition=function(t){var e,n;t instanceof Dr?(e=t._id,t=t._name):(e=kr(),(n=Mr).time=On(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o,l=r[a],u=l.length,s=0;s<u;++s)(o=l[s])&&tr(o,t,e,s,l,n||Tr(o,e));return new Dr(r,this._parents,t,e)};const _r=Math.PI,Er=2*_r,Fr=1e-6,Sr=Er-Fr;function Br(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}class Nr{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=null==t?Br:function(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Br;const n=10**e;return function(t){this._+=t[0];for(let e=1,r=t.length;e<r;++e)this._+=Math.round(arguments[e]*n)/n+t[e]}}(t)}moveTo(t,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,e){this._append`L${this._x1=+t},${this._y1=+e}`}quadraticCurveTo(t,e,n,r){this._append`Q${+t},${+e},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(t,e,n,r,i,a){this._append`C${+t},${+e},${+n},${+r},${this._x1=+i},${this._y1=+a}`}arcTo(t,e,n,r,i){if(t=+t,e=+e,n=+n,r=+r,(i=+i)<0)throw new Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,l=n-t,u=r-e,s=a-t,f=o-e,c=s*s+f*f;if(null===this._x1)this._append`M${this._x1=t},${this._y1=e}`;else if(c>Fr)if(Math.abs(f*l-u*s)>Fr&&i){let h=n-a,d=r-o,g=l*l+u*u,p=h*h+d*d,y=Math.sqrt(g),m=Math.sqrt(c),v=i*Math.tan((_r-Math.acos((g+c-p)/(2*y*m)))/2),x=v/m,A=v/y;Math.abs(x-1)>Fr&&this._append`L${t+x*s},${e+x*f}`,this._append`A${i},${i},0,0,${+(f*h>s*d)},${this._x1=t+A*l},${this._y1=e+A*u}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,n,r,i,a){if(t=+t,e=+e,a=!!a,(n=+n)<0)throw new Error(`negative radius: ${n}`);let o=n*Math.cos(r),l=n*Math.sin(r),u=t+o,s=e+l,f=1^a,c=a?r-i:i-r;null===this._x1?this._append`M${u},${s}`:(Math.abs(this._x1-u)>Fr||Math.abs(this._y1-s)>Fr)&&this._append`L${u},${s}`,n&&(c<0&&(c=c%Er+Er),c>Sr?this._append`A${n},${n},0,1,${f},${t-o},${e-l}A${n},${n},0,1,${f},${this._x1=u},${this._y1=s}`:c>Fr&&this._append`A${n},${n},0,${+(c>=_r)},${f},${this._x1=t+n*Math.cos(i)},${this._y1=e+n*Math.sin(i)}`)}rect(t,e,n,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}}function Ir(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Lr(t){return(t=Ir(Math.abs(t)))?t[1]:NaN}var Vr,Or=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Pr(t){if(!(e=Or.exec(t)))throw new Error("invalid format: "+t);var e;return new $r({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 $r(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 Yr(t,e){var n=Ir(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}Pr.prototype=$r.prototype,$r.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 zr={"%":(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)=>Yr(100*t,e),r:Yr,s:function(t,e){var n=Ir(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(Vr=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+Ir(t,Math.max(0,e+a-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Rr(t){return t}var Ur,Hr,Xr,Wr=Array.prototype.map,jr=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function qr(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?Rr:(e=Wr.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,a=[],o=0,l=e[0],u=0;i>0&&l>0&&(u+l+1>r&&(l=Math.max(1,r-u)),a.push(t.substring(i-=l,i+l)),!((u+=l+1)>r));)l=e[o=(o+1)%e.length];return a.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",a=void 0===t.currency?"":t.currency[1]+"",o=void 0===t.decimal?".":t.decimal+"",l=void 0===t.numerals?Rr:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(Wr.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=Pr(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"):zr[v]||(void 0===y&&(y=12),m=!0,v="g"),(d||"0"===e&&"="===n)&&(d=!0,e="0",n="=");var x="$"===h?i:"#"===h&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",A="$"===h?a:/[%p]/.test(v)?u:"",w=zr[v],b=/[defgprs%]/.test(v);function D(t){var i,a,u,h=x,D=A;if("c"===v)D=w(t)+D,t="";else{var k=(t=+t)<0||1/t<0;if(t=isNaN(t)?f:w(Math.abs(t),y),m&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r)switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(!+t[r])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),k&&0==+t&&"+"!==c&&(k=!1),h=(k?"("===c?c:s:"-"===c||"("===c?"":c)+h,D=("s"===v?jr[8+Vr/3]:"")+D+(k&&"("===c?")":""),b)for(i=-1,a=t.length;++i<a;)if(48>(u=t.charCodeAt(i))||u>57){D=(46===u?o+t.slice(i+1):t.slice(i))+D,t=t.slice(0,i);break}}p&&!d&&(t=r(t,1/0));var C=h.length+t.length+D.length,M=C<g?new Array(g-C+1).join(e):"";switch(p&&d&&(t=r(M+t,M.length?g-D.length:1/0),M=""),n){case"<":t=h+t+D+M;break;case"=":t=h+M+t+D;break;case"^":t=M.slice(0,C=M.length>>1)+h+t+D+M.slice(C);break;default:t=M+h+t+D}return l(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=Pr(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Lr(e)/3))),i=Math.pow(10,-r),a=jr[8+r/3];return function(t){return n(i*t)+a}}}}function Gr(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}Ur=qr({thousands:",",grouping:[3],currency:["$",""]}),Hr=Ur.format,Xr=Ur.formatPrefix;const Qr=Symbol("implicit");function Zr(){var t=new l,e=[],n=[],r=Qr;function i(i){let a=t.get(i);if(void 0===a){if(r!==Qr)return r;t.set(i,a=e.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return e.slice();e=[],t=new l;for(const r of n)t.has(r)||t.set(r,e.push(r)-1);return i},i.range=function(t){return arguments.length?(n=Array.from(t),i):n.slice()},i.unknown=function(t){return arguments.length?(r=t,i):r},i.copy=function(){return Zr(e,n).unknown(r)},Gr.apply(i,arguments),i}function Kr(t){return+t}var Jr=[0,1];function ti(t){return t}function ei(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:function(t){return function(){return t}}(isNaN(e)?NaN:.5)}function ni(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=ei(i,r),a=n(o,a)):(r=ei(r,i),a=n(a,o)),function(t){return a(r(t))}}function ri(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),l=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++l<r;)i[l]=ei(t[l],t[l+1]),a[l]=n(e[l],e[l+1]);return function(e){var n=o(t,e,1,r)-1;return a[n](i[n](e))}}function ii(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function ai(){var t,e,n,r,i,a,o=Jr,l=Jr,u=yn,s=ti;function f(){var t,e,n,u=Math.min(o.length,l.length);return s!==ti&&(t=o[0],e=o[u-1],t>e&&(n=t,t=e,e=n),s=function(n){return Math.max(t,Math.min(e,n))}),r=u>2?ri:ni,i=a=null,c}function c(e){return null==e||isNaN(e=+e)?n:(i||(i=r(o.map(t),l,u)))(t(s(e)))}return c.invert=function(n){return s(e((a||(a=r(l,o.map(t),cn)))(n)))},c.domain=function(t){return arguments.length?(o=Array.from(t,Kr),f()):o.slice()},c.range=function(t){return arguments.length?(l=Array.from(t),f()):l.slice()},c.rangeRound=function(t){return l=Array.from(t),u=mn,f()},c.clamp=function(t){return arguments.length?(s=!!t||ti,f()):s!==ti},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 oi(){return ai()(ti,ti)}function li(t,e,n,r){var i,a=y(t,e,n);switch((r=Pr(null==r?",f":r)).type){case"s":var o=Math.max(Math.abs(t),Math.abs(e));return null!=r.precision||isNaN(i=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Lr(e)/3)))-Lr(Math.abs(t)))}(a,o))||(r.precision=i),Xr(r,o);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Lr(e)-Lr(t))+1}(a,Math.max(Math.abs(t),Math.abs(e))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=function(t){return Math.max(0,-Lr(Math.abs(t)))}(a))||(r.precision=i-2*("%"===r.type))}return Hr(r)}function ui(t){var e=t.domain;return t.ticks=function(t){var n=e();return function(t,e,n){if(!((n=+n)>0))return[];if((t=+t)==(e=+e))return[t];const r=e<t,[i,a,o]=r?g(e,t,n):g(t,e,n);if(!(a>=i))return[];const l=a-i+1,u=new Array(l);if(r)if(o<0)for(let t=0;t<l;++t)u[t]=(a-t)/-o;else for(let t=0;t<l;++t)u[t]=(a-t)*o;else if(o<0)for(let t=0;t<l;++t)u[t]=(i+t)/-o;else for(let t=0;t<l;++t)u[t]=(i+t)*o;return u}(n[0],n[n.length-1],null==t?10:t)},t.tickFormat=function(t,n){var r=e();return li(r[0],r[r.length-1],null==t?10:t,n)},t.nice=function(n){null==n&&(n=10);var r,i,a=e(),o=0,l=a.length-1,u=a[o],s=a[l],f=10;for(s<u&&(i=u,u=s,s=i,i=o,o=l,l=i);f-- >0;){if((i=p(u,s,n))===r)return a[o]=u,a[l]=s,e(a);if(i>0)u=Math.floor(u/i)*i,s=Math.ceil(s/i)*i;else{if(!(i<0))break;u=Math.ceil(u*i)/i,s=Math.floor(s*i)/i}r=i}return t},t}function si(){var t=oi();return t.copy=function(){return ii(t,si())},Gr.apply(t,arguments),ui(t)}const fi=new Date,ci=new Date;function hi(t,e,n,r){function i(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return i.floor=e=>(t(e=new Date(+e)),e),i.ceil=n=>(t(n=new Date(n-1)),e(n,1),t(n),n),i.round=t=>{const e=i(t),n=i.ceil(t);return t-e<n-t?e:n},i.offset=(t,n)=>(e(t=new Date(+t),null==n?1:Math.floor(n)),t),i.range=(n,r,a)=>{const o=[];if(n=i.ceil(n),a=null==a?1:Math.floor(a),!(n<r&&a>0))return o;let l;do{o.push(l=new Date(+n)),e(n,a),t(n)}while(l<n&&n<r);return o},i.filter=n=>hi((e=>{if(e>=e)for(;t(e),!n(e);)e.setTime(e-1)}),((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&&(i.count=(e,r)=>(fi.setTime(+e),ci.setTime(+r),t(fi),t(ci),Math.floor(n(fi,ci))),i.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?e=>r(e)%t==0:e=>i.count(0,e)%t==0):i:null)),i}const di=hi((()=>{}),((t,e)=>{t.setTime(+t+e)}),((t,e)=>e-t));di.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?hi((e=>{e.setTime(Math.floor(e/t)*t)}),((e,n)=>{e.setTime(+e+n*t)}),((e,n)=>(n-e)/t)):di:null),di.range;const gi=1e3,pi=6e4,yi=36e5,mi=864e5,vi=6048e5,xi=2592e6,Ai=31536e6,wi=hi((t=>{t.setTime(t-t.getMilliseconds())}),((t,e)=>{t.setTime(+t+e*gi)}),((t,e)=>(e-t)/gi),(t=>t.getUTCSeconds()));wi.range;const bi=hi((t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*gi)}),((t,e)=>{t.setTime(+t+e*pi)}),((t,e)=>(e-t)/pi),(t=>t.getMinutes()));bi.range;const Di=hi((t=>{t.setUTCSeconds(0,0)}),((t,e)=>{t.setTime(+t+e*pi)}),((t,e)=>(e-t)/pi),(t=>t.getUTCMinutes()));Di.range;const ki=hi((t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*gi-t.getMinutes()*pi)}),((t,e)=>{t.setTime(+t+e*yi)}),((t,e)=>(e-t)/yi),(t=>t.getHours()));ki.range;const Ci=hi((t=>{t.setUTCMinutes(0,0,0)}),((t,e)=>{t.setTime(+t+e*yi)}),((t,e)=>(e-t)/yi),(t=>t.getUTCHours()));Ci.range;const Mi=hi((t=>t.setHours(0,0,0,0)),((t,e)=>t.setDate(t.getDate()+e)),((t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*pi)/mi),(t=>t.getDate()-1));Mi.range;const Ti=hi((t=>{t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCDate(t.getUTCDate()+e)}),((t,e)=>(e-t)/mi),(t=>t.getUTCDate()-1));Ti.range;const _i=hi((t=>{t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCDate(t.getUTCDate()+e)}),((t,e)=>(e-t)/mi),(t=>Math.floor(t/mi)));function Ei(t){return hi((e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)}),((t,e)=>{t.setDate(t.getDate()+7*e)}),((t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*pi)/vi))}_i.range;const Fi=Ei(0),Si=Ei(1),Bi=Ei(2),Ni=Ei(3),Ii=Ei(4),Li=Ei(5),Vi=Ei(6);function Oi(t){return hi((e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCDate(t.getUTCDate()+7*e)}),((t,e)=>(e-t)/vi))}Fi.range,Si.range,Bi.range,Ni.range,Ii.range,Li.range,Vi.range;const Pi=Oi(0),$i=Oi(1),Yi=Oi(2),zi=Oi(3),Ri=Oi(4),Ui=Oi(5),Hi=Oi(6);Pi.range,$i.range,Yi.range,zi.range,Ri.range,Ui.range,Hi.range;const Xi=hi((t=>{t.setDate(1),t.setHours(0,0,0,0)}),((t,e)=>{t.setMonth(t.getMonth()+e)}),((t,e)=>e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear())),(t=>t.getMonth()));Xi.range;const Wi=hi((t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)}),((t,e)=>e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear())),(t=>t.getUTCMonth()));Wi.range;const ji=hi((t=>{t.setMonth(0,1),t.setHours(0,0,0,0)}),((t,e)=>{t.setFullYear(t.getFullYear()+e)}),((t,e)=>e.getFullYear()-t.getFullYear()),(t=>t.getFullYear()));ji.every=t=>isFinite(t=Math.floor(t))&&t>0?hi((e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)}),((e,n)=>{e.setFullYear(e.getFullYear()+n*t)})):null,ji.range;const qi=hi((t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),((t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)}),((t,e)=>e.getUTCFullYear()-t.getUTCFullYear()),(t=>t.getUTCFullYear()));qi.every=t=>isFinite(t=Math.floor(t))&&t>0?hi((e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),((e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)})):null,qi.range;const[Gi,Qi]=function(t,e,n,r,a,o){const l=[[wi,1,gi],[wi,5,5e3],[wi,15,15e3],[wi,30,3e4],[o,1,pi],[o,5,3e5],[o,15,9e5],[o,30,18e5],[a,1,yi],[a,3,108e5],[a,6,216e5],[a,12,432e5],[r,1,mi],[r,2,1728e5],[n,1,vi],[e,1,xi],[e,3,7776e6],[t,1,Ai]];function u(e,n,r){const a=Math.abs(n-e)/r,o=i((([,,t])=>t)).right(l,a);if(o===l.length)return t.every(y(e/Ai,n/Ai,r));if(0===o)return di.every(Math.max(y(e,n,r),1));const[u,s]=l[a/l[o-1][2]<l[o][2]/a?o-1:o];return u.every(s)}return[function(t,e,n){const r=e<t;r&&([t,e]=[e,t]);const i=n&&"function"==typeof n.range?n:u(t,e,n),a=i?i.range(t,+e+1):[];return r?a.reverse():a},u]}(ji,Xi,Fi,Mi,ki,bi);function Zi(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function Ki(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Ji(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}var ta,ea,na={"-":"",_:" ",0:"0"},ra=/^\s*\d+/,ia=/^%/,aa=/[\\^$*+?|[\]().{}]/g;function oa(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function la(t){return t.replace(aa,"\\$&")}function ua(t){return new RegExp("^(?:"+t.map(la).join("|")+")","i")}function sa(t){return new Map(t.map(((t,e)=>[t.toLowerCase(),e])))}function fa(t,e,n){var r=ra.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function ca(t,e,n){var r=ra.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function ha(t,e,n){var r=ra.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function da(t,e,n){var r=ra.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function ga(t,e,n){var r=ra.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function pa(t,e,n){var r=ra.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function ya(t,e,n){var r=ra.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function ma(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 va(t,e,n){var r=ra.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function xa(t,e,n){var r=ra.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Aa(t,e,n){var r=ra.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function wa(t,e,n){var r=ra.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function ba(t,e,n){var r=ra.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Da(t,e,n){var r=ra.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function ka(t,e,n){var r=ra.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Ca(t,e,n){var r=ra.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Ma(t,e,n){var r=ra.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Ta(t,e,n){var r=ia.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function _a(t,e,n){var r=ra.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Ea(t,e,n){var r=ra.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function Fa(t,e){return oa(t.getDate(),e,2)}function Sa(t,e){return oa(t.getHours(),e,2)}function Ba(t,e){return oa(t.getHours()%12||12,e,2)}function Na(t,e){return oa(1+Mi.count(ji(t),t),e,3)}function Ia(t,e){return oa(t.getMilliseconds(),e,3)}function La(t,e){return Ia(t,e)+"000"}function Va(t,e){return oa(t.getMonth()+1,e,2)}function Oa(t,e){return oa(t.getMinutes(),e,2)}function Pa(t,e){return oa(t.getSeconds(),e,2)}function $a(t){var e=t.getDay();return 0===e?7:e}function Ya(t,e){return oa(Fi.count(ji(t)-1,t),e,2)}function za(t){var e=t.getDay();return e>=4||0===e?Ii(t):Ii.ceil(t)}function Ra(t,e){return t=za(t),oa(Ii.count(ji(t),t)+(4===ji(t).getDay()),e,2)}function Ua(t){return t.getDay()}function Ha(t,e){return oa(Si.count(ji(t)-1,t),e,2)}function Xa(t,e){return oa(t.getFullYear()%100,e,2)}function Wa(t,e){return oa((t=za(t)).getFullYear()%100,e,2)}function ja(t,e){return oa(t.getFullYear()%1e4,e,4)}function qa(t,e){var n=t.getDay();return oa((t=n>=4||0===n?Ii(t):Ii.ceil(t)).getFullYear()%1e4,e,4)}function Ga(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+oa(e/60|0,"0",2)+oa(e%60,"0",2)}function Qa(t,e){return oa(t.getUTCDate(),e,2)}function Za(t,e){return oa(t.getUTCHours(),e,2)}function Ka(t,e){return oa(t.getUTCHours()%12||12,e,2)}function Ja(t,e){return oa(1+Ti.count(qi(t),t),e,3)}function to(t,e){return oa(t.getUTCMilliseconds(),e,3)}function eo(t,e){return to(t,e)+"000"}function no(t,e){return oa(t.getUTCMonth()+1,e,2)}function ro(t,e){return oa(t.getUTCMinutes(),e,2)}function io(t,e){return oa(t.getUTCSeconds(),e,2)}function ao(t){var e=t.getUTCDay();return 0===e?7:e}function oo(t,e){return oa(Pi.count(qi(t)-1,t),e,2)}function lo(t){var e=t.getUTCDay();return e>=4||0===e?Ri(t):Ri.ceil(t)}function uo(t,e){return t=lo(t),oa(Ri.count(qi(t),t)+(4===qi(t).getUTCDay()),e,2)}function so(t){return t.getUTCDay()}function fo(t,e){return oa($i.count(qi(t)-1,t),e,2)}function co(t,e){return oa(t.getUTCFullYear()%100,e,2)}function ho(t,e){return oa((t=lo(t)).getUTCFullYear()%100,e,2)}function go(t,e){return oa(t.getUTCFullYear()%1e4,e,4)}function po(t,e){var n=t.getUTCDay();return oa((t=n>=4||0===n?Ri(t):Ri.ceil(t)).getUTCFullYear()%1e4,e,4)}function yo(){return"+0000"}function mo(){return"%"}function vo(t){return+t}function xo(t){return Math.floor(+t/1e3)}function Ao(t){return new Date(t)}function wo(t){return t instanceof Date?+t:+new Date(+t)}function bo(t,e,n,r,i,a,o,l,u,s){var f=oi(),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"),x=s("%B"),A=s("%Y");function w(t){return(u(t)<t?d:l(t)<t?g:o(t)<t?p:a(t)<t?y:r(t)<t?i(t)<t?m:v:n(t)<t?x:A)(t)}return f.invert=function(t){return new Date(c(t))},f.domain=function(t){return arguments.length?h(Array.from(t,wo)):h().map(Ao)},f.ticks=function(e){var n=h();return t(n[0],n[n.length-1],null==e?10:e)},f.tickFormat=function(t,e){return null==e?w:s(e)},f.nice=function(t){var n=h();return t&&"function"==typeof t.range||(t=e(n[0],n[n.length-1],null==t?10:t)),t?h(function(t,e){var n,r=0,i=(t=t.slice()).length-1,a=t[r],o=t[i];return o<a&&(n=r,r=i,i=n,n=a,a=o,o=n),t[r]=e.floor(a),t[i]=e.ceil(o),t}(n,t)):f},f.copy=function(){return ii(f,bo(t,e,n,r,i,a,o,l,u,s))},f}function Do(){return Gr.apply(bo(Gi,Qi,ji,Xi,Fi,Mi,ki,bi,wi,ea).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}!function(t){ta=function(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,l=t.months,u=t.shortMonths,s=ua(i),f=sa(i),c=ua(a),h=sa(a),d=ua(o),g=sa(o),p=ua(l),y=sa(l),m=ua(u),v=sa(u),x={a:function(t){return o[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return u[t.getMonth()]},B:function(t){return l[t.getMonth()]},c:null,d:Fa,e:Fa,f:La,g:Wa,G:qa,H:Sa,I:Ba,j:Na,L:Ia,m:Va,M:Oa,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:vo,s:xo,S:Pa,u:$a,U:Ya,V:Ra,w:Ua,W:Ha,x:null,X:null,y:Xa,Y:ja,Z:Ga,"%":mo},A={a:function(t){return o[t.getUTCDay()]},A:function(t){return a[t.getUTCDay()]},b:function(t){return u[t.getUTCMonth()]},B:function(t){return l[t.getUTCMonth()]},c:null,d:Qa,e:Qa,f:eo,g:ho,G:po,H:Za,I:Ka,j:Ja,L:to,m:no,M:ro,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:vo,s:xo,S:io,u:ao,U:oo,V:uo,w:so,W:fo,x:null,X:null,y:co,Y:go,Z:yo,"%":mo},w={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:Aa,e:Aa,f:Ma,g:ya,G:pa,H:ba,I:ba,j:wa,L:Ca,m:xa,M:Da,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:va,Q:_a,s:Ea,S:ka,u:ca,U:ha,V:da,w:fa,W:ga,x:function(t,e,r){return k(t,n,e,r)},X:function(t,e,n){return k(t,r,e,n)},y:ya,Y:pa,Z:ma,"%":Ta};function b(t,e){return function(n){var r,i,a,o=[],l=-1,u=0,s=t.length;for(n instanceof Date||(n=new Date(+n));++l<s;)37===t.charCodeAt(l)&&(o.push(t.slice(u,l)),null!=(i=na[r=t.charAt(++l)])?r=t.charAt(++l):i="e"===r?" ":"0",(a=e[r])&&(r=a(n,i)),o.push(r),u=l+1);return o.push(t.slice(u,l)),o.join("")}}function D(t,e){return function(n){var r,i,a=Ji(1900,void 0,1);if(k(a,t,n+="",0)!=n.length)return null;if("Q"in a)return new Date(a.Q);if("s"in a)return new Date(1e3*a.s+("L"in a?a.L:0));if(e&&!("Z"in a)&&(a.Z=0),"p"in a&&(a.H=a.H%12+12*a.p),void 0===a.m&&(a.m="q"in a?a.q:0),"V"in a){if(a.V<1||a.V>53)return null;"w"in a||(a.w=1),"Z"in a?(i=(r=Ki(Ji(a.y,0,1))).getUTCDay(),r=i>4||0===i?$i.ceil(r):$i(r),r=Ti.offset(r,7*(a.V-1)),a.y=r.getUTCFullYear(),a.m=r.getUTCMonth(),a.d=r.getUTCDate()+(a.w+6)%7):(i=(r=Zi(Ji(a.y,0,1))).getDay(),r=i>4||0===i?Si.ceil(r):Si(r),r=Mi.offset(r,7*(a.V-1)),a.y=r.getFullYear(),a.m=r.getMonth(),a.d=r.getDate()+(a.w+6)%7)}else("W"in a||"U"in a)&&("w"in a||(a.w="u"in a?a.u%7:"W"in a?1:0),i="Z"in a?Ki(Ji(a.y,0,1)).getUTCDay():Zi(Ji(a.y,0,1)).getDay(),a.m=0,a.d="W"in a?(a.w+6)%7+7*a.W-(i+5)%7:a.w+7*a.U-(i+6)%7);return"Z"in a?(a.H+=a.Z/100|0,a.M+=a.Z%100,Ki(a)):Zi(a)}}function k(t,e,n,r){for(var i,a,o=0,l=e.length,u=n.length;o<l;){if(r>=u)return-1;if(37===(i=e.charCodeAt(o++))){if(i=e.charAt(o++),!(a=w[i in na?e.charAt(o++):i])||(r=a(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return x.x=b(n,x),x.X=b(r,x),x.c=b(e,x),A.x=b(n,A),A.X=b(r,A),A.c=b(e,A),{format:function(t){var e=b(t+="",x);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+="",A);return e.toString=function(){return t},e},utcParse:function(t){var e=D(t+="",!0);return e.toString=function(){return t},e}}}(t),ea=ta.format,ta.parse,ta.utcFormat,ta.utcParse}({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 ko=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map((function(t){for(var e=t.length/6|0,n=new Array(e),r=0;r<e;)n[r]="#"+t.slice(6*r,6*++r);return n}));function Co(t){return function(){return t}}(t=>{ln(t[t.length-1])})(ko);const Mo=Math.abs,To=Math.atan2,_o=Math.cos,Eo=Math.max,Fo=Math.min,So=Math.sin,Bo=Math.sqrt,No=1e-12,Io=Math.PI,Lo=Io/2,Vo=2*Io;function Oo(t){return t>=1?Lo:t<=-1?-Lo:Math.asin(t)}function Po(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(null==n)e=null;else{const t=Math.floor(n);if(!(t>=0))throw new RangeError(`invalid digits: ${n}`);e=t}return t},()=>new Nr(e)}function $o(t){return t.innerRadius}function Yo(t){return t.outerRadius}function zo(t){return t.startAngle}function Ro(t){return t.endAngle}function Uo(t){return t&&t.padAngle}function Ho(t,e,n,r,i,a,o){var l=t-n,u=e-r,s=(o?a:-a)/Bo(l*l+u*u),f=s*u,c=-s*l,h=t+f,d=e+c,g=n+f,p=r+c,y=(h+g)/2,m=(d+p)/2,v=g-h,x=p-d,A=v*v+x*x,w=i-a,b=h*p-g*d,D=(x<0?-1:1)*Bo(Eo(0,w*w*A-b*b)),k=(b*x-v*D)/A,C=(-b*v-x*D)/A,M=(b*x+v*D)/A,T=(-b*v+x*D)/A,_=k-y,E=C-m,F=M-y,S=T-m;return _*_+E*E>F*F+S*S&&(k=M,C=T),{cx:k,cy:C,x01:-f,y01:-c,x11:k*(i/w-1),y11:C*(i/w-1)}}function Xo(){var t=$o,e=Yo,n=Co(0),r=null,i=zo,a=Ro,o=Uo,l=null,u=Po(s);function s(){var s,f,c=+t.apply(this,arguments),h=+e.apply(this,arguments),d=i.apply(this,arguments)-Lo,g=a.apply(this,arguments)-Lo,p=Mo(g-d),y=g>d;if(l||(l=s=u()),h<c&&(f=h,h=c,c=f),h>No)if(p>Vo-No)l.moveTo(h*_o(d),h*So(d)),l.arc(0,0,h,d,g,!y),c>No&&(l.moveTo(c*_o(g),c*So(g)),l.arc(0,0,c,g,d,y));else{var m,v,x=d,A=g,w=d,b=g,D=p,k=p,C=o.apply(this,arguments)/2,M=C>No&&(r?+r.apply(this,arguments):Bo(c*c+h*h)),T=Fo(Mo(h-c)/2,+n.apply(this,arguments)),_=T,E=T;if(M>No){var F=Oo(M/c*So(C)),S=Oo(M/h*So(C));(D-=2*F)>No?(w+=F*=y?1:-1,b-=F):(D=0,w=b=(d+g)/2),(k-=2*S)>No?(x+=S*=y?1:-1,A-=S):(k=0,x=A=(d+g)/2)}var B=h*_o(x),N=h*So(x),I=c*_o(b),L=c*So(b);if(T>No){var V,O=h*_o(A),P=h*So(A),$=c*_o(w),Y=c*So(w);if(p<Io)if(V=function(t,e,n,r,i,a,o,l){var u=n-t,s=r-e,f=o-i,c=l-a,h=c*u-f*s;if(!(h*h<No))return[t+(h=(f*(e-a)-c*(t-i))/h)*u,e+h*s]}(B,N,$,Y,O,P,I,L)){var z=B-V[0],R=N-V[1],U=O-V[0],H=P-V[1],X=1/So(function(t){return t>1?0:t<-1?Io:Math.acos(t)}((z*U+R*H)/(Bo(z*z+R*R)*Bo(U*U+H*H)))/2),W=Bo(V[0]*V[0]+V[1]*V[1]);_=Fo(T,(c-W)/(X-1)),E=Fo(T,(h-W)/(X+1))}else _=E=0}k>No?E>No?(m=Ho($,Y,B,N,h,E,y),v=Ho(O,P,I,L,h,E,y),l.moveTo(m.cx+m.x01,m.cy+m.y01),E<T?l.arc(m.cx,m.cy,E,To(m.y01,m.x01),To(v.y01,v.x01),!y):(l.arc(m.cx,m.cy,E,To(m.y01,m.x01),To(m.y11,m.x11),!y),l.arc(0,0,h,To(m.cy+m.y11,m.cx+m.x11),To(v.cy+v.y11,v.cx+v.x11),!y),l.arc(v.cx,v.cy,E,To(v.y11,v.x11),To(v.y01,v.x01),!y))):(l.moveTo(B,N),l.arc(0,0,h,x,A,!y)):l.moveTo(B,N),c>No&&D>No?_>No?(m=Ho(I,L,O,P,c,-_,y),v=Ho(B,N,$,Y,c,-_,y),l.lineTo(m.cx+m.x01,m.cy+m.y01),_<T?l.arc(m.cx,m.cy,_,To(m.y01,m.x01),To(v.y01,v.x01),!y):(l.arc(m.cx,m.cy,_,To(m.y01,m.x01),To(m.y11,m.x11),!y),l.arc(0,0,c,To(m.cy+m.y11,m.cx+m.x11),To(v.cy+v.y11,v.cx+v.x11),y),l.arc(v.cx,v.cy,_,To(v.y11,v.x11),To(v.y01,v.x01),!y))):l.arc(0,0,c,b,w,y):l.lineTo(I,L)}else l.moveTo(0,0);if(l.closePath(),s)return l=null,s+""||null}return s.centroid=function(){var n=(+t.apply(this,arguments)+ +e.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +a.apply(this,arguments))/2-Io/2;return[_o(r)*n,So(r)*n]},s.innerRadius=function(e){return arguments.length?(t="function"==typeof e?e:Co(+e),s):t},s.outerRadius=function(t){return arguments.length?(e="function"==typeof t?t:Co(+t),s):e},s.cornerRadius=function(t){return arguments.length?(n="function"==typeof t?t:Co(+t),s):n},s.padRadius=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:Co(+t),s):r},s.startAngle=function(t){return arguments.length?(i="function"==typeof t?t:Co(+t),s):i},s.endAngle=function(t){return arguments.length?(a="function"==typeof t?t:Co(+t),s):a},s.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:Co(+t),s):o},s.context=function(t){return arguments.length?(l=null==t?null:t,s):l},s}function Wo(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function jo(t){this._context=t}function qo(t){return new jo(t)}function Go(t){return t[0]}function Qo(t){return t[1]}function Zo(t,e){return e<t?-1:e>t?1:e>=t?0:NaN}function Ko(t){return t}function Jo(t,e,n){this.k=t,this.x=e,this.y=n}var tl,el,nl;jo.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)}}},Jo.prototype={constructor:Jo,scale:function(t){return 1===t?this:new Jo(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new Jo(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}},Jo.prototype,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"}(tl||(tl={})),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"}(el||(el={})),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"}(nl||(nl={}));class rl{constructor(t,e){this.date=t,this.value=e}}class il{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=nl.Number,this.usedAsXDataset=!1,this.numTargets=0,e===tl.Table){let t,e=new RegExp("\\[(?<accessor>[0-9]+)\\]\\[(?<accessor1>[0-9]+)\\](\\[(?<accessor2>[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 i=parseFloat(t.groups.accessor1);if(Number.isNumber(i)){let a;void 0!==t.groups.accessor2&&(a=parseFloat(t.groups.accessor2)),this.accessor=r,this.accessor1=i,Number.isNumber(a)&&(this.accessor2=a),this.parentTarget=n.replace(e,"")}break}}}else{let t,e=new RegExp("\\[(?<accessor>[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 al{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<t.getDates().length;e++)this.values.push(null)}cloneToTmpDataset(){if(!this.isTmpDataset){let t=new al(this.parent,null);return t.name="tmp",t.values=[...this.values],t.yMin=this.yMin,t.yMax=this.yMax,t.startDate=this.startDate.clone(),t.endDate=this.endDate.clone(),t.numTargets=this.numTargets,t.isTmpDataset=!0,t.valueType=this.valueType,t}return this}getName(){return this.name}setName(t){this.name=t}getId(){return this.id}setId(t){this.id=t}addNumTargets(t){this.numTargets=this.numTargets+t}getNumTargets(){return this.numTargets}getValue(t,e=0){let n=this.parent.getIndexOfDate(t)+Math.floor(e);return n>=0&&n<this.values.length?this.values[n]:null}setValue(t,e){let n=this.parent.getIndexOfDate(t);n>=0&&n<this.values.length&&(this.values[n]=e,(null===this.yMin||e<this.yMin)&&(this.yMin=e),(null===this.yMax||e>this.yMax)&&(this.yMax=e),(null===this.startDate||t<this.startDate)&&(this.startDate=t.clone()),(null===this.endDate||t>this.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<this.values.length;r++)null!==this.values[r]&&(null===e||this.values[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;e<this.values.length;e++)null===this.values[e]&&(this.values[e]=t,t<this.yMin&&(this.yMin=t),t>this.yMax&&(this.yMax=t))}getQuery(){return this.query}accumulateValues(){let t=0;for(let e=0;e<this.values.length;e++)null!==this.values[e]&&(t+=this.values[e]),this.values[e]=t,t<this.yMin&&(this.yMin=t),t>this.yMax&&(this.yMax=t)}getValues(){return this.values}getLength(){return this.values.length}getLengthNotNull(){let t=0;for(let e=0;e<this.values.length;e++)null!==this.values[e]&&t++;return t}next(){if(this.currentIndex<this.values.length){let t=this.currentIndex++;return{done:!1,value:new rl(this.parent.getDates()[t],this.values[t])}}return this.currentIndex=0,{done:!0,value:null}}[Symbol.iterator](){return this}}class ol{constructor(t,e){this.currentIndex=0,this.dates=[],this.datasets=[];const n=t.creationData().format.toString();for(let r=t.clone();r<=e;r.add(1,"days")){let t=window.moment(r.format(n),n,!0);this.dates.push(t)}}createDataset(t,e){let n=new al(this,t);return n.setId(t.getId()),e&&n.setName(e.datasetName[t.getId()]),this.datasets.push(n),n}getIndexOfDate(t){const e=t.creationData().format.toString();for(let n=0;n<this.dates.length;n++)if(this.dates[n].format(e)===t.format(e))return n;return-1}getDatasetByQuery(t){for(let e of this.datasets)if(e.getQuery().equalTo(t))return e;return null}getDatasetById(t){for(let e of this.datasets)if(e.getId()===t)return e;return null}getXDatasetIds(){let t=[];for(let e of this.datasets)if(e.getQuery().usedAsXDataset){let n=e.getQuery().getId();t.includes(n)||-1===n||t.push(n)}return t}getDates(){return this.dates}getNames(){let t=[];for(let e of this.datasets)t.push(e.getName());return t}next(){return this.currentIndex<this.datasets.length?{done:!1,value:this.datasets[this.currentIndex++]}:(this.currentIndex=0,{done:!0,value:null})}[Symbol.iterator](){return this}}class ll{constructor(t){this.queries=t,this.xDataset=[],this.folder="/",this.file=[],this.specifiedFilesOnly=!1,this.fileContainsLinkedFiles=[],this.fileMultiplierAfterLink="",this.dateFormat="YYYY-MM-DD",this.dateFormatPrefix="",this.dateFormatSuffix="",this.startDate=null,this.endDate=null,this.datasetName=[],this.constValue=[1],this.ignoreAttachedValue=[],this.ignoreZeroValue=[],this.accum=[],this.penalty=[],this.valueShift=[],this.shiftOnlyValueLargerThan=[],this.valueType=[],this.textValueMap={},this.dataAreaSize=new ml(300,300),this.aspectRatio=new vl(1,1),this.margin=new xl(10,10,10,10),this.fixedScale=1,this.fitPanelWidth=!1,this.output=[],this.line=[],this.bar=[],this.pie=[],this.summary=[],this.month=[],this.heatmap=[],this.bullet=[],this.customDataset=[],this.datasets=null}getQueryById(t){for(let e of this.queries)if(e.getId()===t)return e}}class ul{constructor(){this.id=-1,this.name="",this.xData=[],this.yData=[]}}class sl{constructor(){this.title="",this.xAxisLabel="Date",this.xAxisColor="",this.xAxisLabelColor="",this.yAxisLabel=[],this.yAxisColor=[],this.yAxisLabelColor=[],this.yAxisUnit=[],this.xAxisTickInterval=null,this.yAxisTickInterval=[],this.xAxisTickLabelFormat=null,this.yAxisTickLabelFormat=[],this.yMin=[],this.yMax=[],this.reverseYAxis=[],this.allowInspectData=!0,this.showLegend=!1,this.legendPosition="",this.legendOrientation="",this.legendBgColor="",this.legendBorderColor=""}GetGraphType(){return el.Unknown}}class fl extends sl{constructor(){super(),this.lineColor=[],this.lineWidth=[],this.showLine=[],this.showPoint=[],this.pointColor=[],this.pointBorderColor=[],this.pointBorderWidth=[],this.pointSize=[],this.fillGap=[],this.yAxisLocation=[]}GetGraphType(){return el.Line}}class cl extends sl{constructor(){super(),this.barColor=[],this.yAxisLocation=[]}GetGraphType(){return el.Bar}}class hl{constructor(){this.title="",this.data=[],this.dataColor=[],this.dataName=[],this.label=[],this.hideLabelLessThan=.03,this.extLabel=[],this.showExtLabelOnlyIfNoLabel=!1,this.ratioInnerRadius=0,this.showLegend=!1,this.legendPosition="",this.legendOrientation="",this.legendBgColor="",this.legendBorderColor=""}GetGraphType(){return el.Pie}}class dl{constructor(){this.template="",this.style=""}GetGraphType(){return el.Summary}}class gl{constructor(){this.mode="circle",this.dataset=[],this.startWeekOn="Sun",this.threshold=[],this.yMin=[],this.yMax=[],this.color=null,this.dimNotInMonth=!0,this.initMonth="",this.showSelectedValue=!0,this.headerYearColor=null,this.headerMonthColor=null,this.dividingLineColor=null,this.showCircle=!0,this.showStreak=!0,this.showTodayRing=!0,this.showSelectedRing=!0,this.circleColor=null,this.circleColorByValue=!1,this.todayRingColor="",this.selectedRingColor="firebrick",this.showAnnotation=!0,this.annotation=[],this.showAnnotationOfAllTargets=!0,this.selectedDate="",this.selectedDataset=null}GetGraphType(){return el.Month}}class pl{constructor(){this.dataset="0",this.startWeekOn="Sun",this.orientation="vertical",this.yMin=null,this.yMax=null,this.color=null}GetGraphType(){return el.Heatmap}}class yl{constructor(){this.title="",this.dataset="0",this.orientation="horizontal",this.value="",this.valueUnit="",this.valueColor="#69b3a2",this.range=[],this.rangeColor=[],this.showMarker=!1,this.markerValue=0,this.markerColor=""}GetGraphType(){return el.Bullet}}class ml{constructor(t,e){this.width=t,this.height=e}}class vl{constructor(t,e){this.x=t,this.y=e}recalculateSize(t){let e=this.x/this.y,n=parseFloat((t.width*e).toFixed(2));return new ml(n,t.height)}}class xl{constructor(t,e,n,r){this.top=t,this.right=e,this.bottom=n,this.left=r}}class Al{constructor(t){if(this.translateX=0,this.translateY=0,"string"==typeof t){let e=t.match(/translate\(\s*(?<x>[\d\.\/-]+)\s*,\s*(?<y>[\d\.\/-]+)\s*\)/).groups;e&&(this.translateX=parseFloat(e.x),this.translateY=parseFloat(e.y))}}}class wl{constructor(t,e){this.filePath=t,this.tableIndex=e,this.xDataset=null,this.yDatasets=[]}}class bl{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 Dl=function(){const t=["HH","H","hh","h"],e=["mm","m"],n=["ss","s",""];let r=[];for(let i of t)for(let t of e)for(let e of n){let n=`${i}:${t}`;""!==e&&(n+=`:${e}`),i.contains("h")&&(n+=" a"),r.push(n)}return r}();function kl(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 Cl(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 Ml(t,e,n=!0){if(!t||!e||0===e.length)return[null,t];let r=null;const i="^(?<value>[0-9]+)("+e.join("|")+")$",a=new RegExp(i,"gm");let o=a.exec(t);return o&&void 0!==o.groups&&void 0!==o.groups.value&&(r=parseFloat(o.groups.value),Number.isNumber(r)&&!Number.isNaN(r))?(n&&(t=t.replace(a,"")),[r,t]):[null,t]}function Tl(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 i=null;[i,t]=Ml(t,["year","years","Y","y"]),null!==i&&(r&&(i*=-1),e.add(i,"years"),n=!0);let a=null;[a,t]=Ml(t,["month","months","M"]),null!==a&&(r&&(a*=-1),e.add(a,"months"),n=!0);let o=null;[o,t]=Ml(t,["week","weeks","W","w"]),null!==o&&(r&&(o*=-1),e.add(o,"weeks"),n=!0);let l=null;[l,t]=Ml(t,["day","days","D","d"]),null!==l&&(r&&(l*=-1),e.add(l,"days"),n=!0);let u=null;[u,t]=Ml(t,["hour","hours","H","h"]),null!==u&&(r&&(u*=-1),e.add(u,"hours"),n=!0);let s=null;[s,t]=Ml(t,["minute","minutes","m"]),null!==s&&(r&&(s*=-1),e.add(s,"minutes"),n=!0);let f=null;return[f,t]=Ml(t,["second","seconds","S","s"]),null!==f&&(r&&(f*=-1),e.add(f,"seconds"),n=!0),n?e:null}function _l(t,e){let n=null,r=Tl(t);return r&&window.moment.isDuration(r)&&(n=Sl(e),n=n.add(r),n&&n.isValid()),n}function El(t,e){return null==t?null:"iso-8601"===e.toLowerCase()?t.format():t.format(e)}function Fl(t,e){return Cl(El(window.moment(t),e),e)}function Sl(t){return Cl(El(window.moment(),t),t)}function Bl(t,e){for(var n=(e=e.replace(/^\./,"")).split("."),r=0,i=n.length;r<i;++r){var a=n[r];if(!(a in t))return null;t=t[a]}return"string"==typeof t||Array.isArray(t)?t:"number"==typeof t||"boolean"==typeof t?t.toString():null}function Nl(t,e){const n=Array.from(t),r=n.findIndex((t=>t!==e)),i=n.reverse().findIndex((t=>t!==e));return-1===r&&-1===i?t:t.substring(r,t.length-i)}function Il(t){if(null===t)return null;let e=new RegExp('<img[^>]*?alt\\s*=\\s*[""\']?(?<emoji>[^\'"" >]+?)[ \'""][^>]*?>',"g");return t.replace(e,((...t)=>{let e=t[t.length-1];return e&&e.emoji?e.emoji.trim():""}))}function Ll(t,e=null){let n=null,r=nl.Number;if("string"==typeof t)if(t.includes(":")){let e=!1;t.startsWith("-")&&(e=!0,t=t.substring(1));let i=window.moment(t,Dl,!0);i.isValid()&&(n=i.diff(window.moment("00:00","HH:mm",!0),"seconds"),e&&(n*=-1),r=nl.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 i=e[n].toString();t=t.replace(r,i);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 Vl(t,e="",n=""){var r=ee("body").append("svg");let i=r.append("text").text(t).attr("x",-99999).attr("y",-99999);e&&i.attr("class",e),n&&i.attr("transform","rotate("+n+")");var a=r.node().getBBox();return r.remove(),{width:a.width,height:a.height}}function Ol(t,e,n){let r=(0|parseFloat(t.attr("width")))+e,i=(0|parseFloat(t.attr("height")))+n;t.attr("width",r),t.attr("height",i)}function Pl(t,e,n){let r=new Al(t.attr("transform"));t.attr("transform","translate("+(r.translateX+e)+","+(r.translateY+n)+")")}function $l(t){return t=(t=(t=t.replace(/(^\\s\*)|(\\s\*$)/gi,"")).replace(/\[ \]{2,}/gi," ")).replace(/\\n /,"\\n")}class Yl{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+Yl.version}static addUnaryOp(t){return Yl.max_unop_len=Math.max(t.length,Yl.max_unop_len),Yl.unary_ops[t]=1,Yl}static addBinaryOp(t,e,n){return Yl.max_binop_len=Math.max(t.length,Yl.max_binop_len),Yl.binary_ops[t]=e,n?Yl.right_associative.add(t):Yl.right_associative.delete(t),Yl}static addIdentifierChar(t){return Yl.additional_identifier_chars.add(t),Yl}static addLiteral(t,e){return Yl.literals[t]=e,Yl}static removeUnaryOp(t){return delete Yl.unary_ops[t],t.length===Yl.max_unop_len&&(Yl.max_unop_len=Yl.getMaxKeyLen(Yl.unary_ops)),Yl}static removeAllUnaryOps(){return Yl.unary_ops={},Yl.max_unop_len=0,Yl}static removeIdentifierChar(t){return Yl.additional_identifier_chars.delete(t),Yl}static removeBinaryOp(t){return delete Yl.binary_ops[t],t.length===Yl.max_binop_len&&(Yl.max_binop_len=Yl.getMaxKeyLen(Yl.binary_ops)),Yl.right_associative.delete(t),Yl}static removeAllBinaryOps(){return Yl.binary_ops={},Yl.max_binop_len=0,Yl}static removeLiteral(t){return delete Yl.literals[t],Yl}static removeAllLiterals(){return Yl.literals={},Yl}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new Yl(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map((t=>t.length)))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return Yl.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!Yl.binary_ops[String.fromCharCode(t)]||Yl.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return Yl.isIdentifierStart(t)||Yl.isDecimalDigit(t)}throwError(t){const e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(Yl.hooks[t]){const n={context:this,node:e};return Yl.hooks.run(t,n),n.node}return e}searchHook(t){if(Yl.hooks[t]){const e={context:this};return Yl.hooks[t].find((function(t){return t.call(e.context,e),e.node})),e.node}}gobbleSpaces(){let t=this.code;for(;t===Yl.SPACE_CODE||t===Yl.TAB_CODE||t===Yl.LF_CODE||t===Yl.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const t=this.gobbleExpressions(),e=1===t.length?t[0]:{type:Yl.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e,n,r=[];for(;this.index<this.expr.length;)if(e=this.code,e===Yl.SEMCOL_CODE||e===Yl.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())r.push(n);else if(this.index<this.expr.length){if(e===t)break;this.throwError('Unexpected "'+this.char+'"')}return r}gobbleExpression(){const t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,Yl.max_binop_len),e=t.length;for(;e>0;){if(Yl.binary_ops.hasOwnProperty(t)&&(!Yl.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!Yl.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=e,t;t=t.substr(0,--e)}return!1}gobbleBinaryExpression(){let t,e,n,r,i,a,o,l,u;if(a=this.gobbleToken(),!a)return a;if(e=this.gobbleBinaryOp(),!e)return a;for(i={value:e,prec:Yl.binaryPrecedence(e),right_a:Yl.right_associative.has(e)},o=this.gobbleToken(),o||this.throwError("Expected expression after "+e),r=[a,i,o];e=this.gobbleBinaryOp();){if(n=Yl.binaryPrecedence(e),0===n){this.index-=e.length;break}i={value:e,prec:n,right_a:Yl.right_associative.has(e)},u=e;const l=t=>i.right_a&&t.right_a?n>t.prec:n<=t.prec;for(;r.length>2&&l(r[r.length-2]);)o=r.pop(),e=r.pop().value,a=r.pop(),t={type:Yl.BINARY_EXP,operator:e,left:a,right:o},r.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+u),r.push(i,t)}for(l=r.length-1,t=r[l];l>1;)t={type:Yl.BINARY_EXP,operator:r[l-1].value,left:r[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,n,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(t=this.code,Yl.isDecimalDigit(t)||t===Yl.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===Yl.SQUOTE_CODE||t===Yl.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(t===Yl.OBRACK_CODE)r=this.gobbleArray();else{for(e=this.expr.substr(this.index,Yl.max_unop_len),n=e.length;n>0;){if(Yl.unary_ops.hasOwnProperty(e)&&(!Yl.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!Yl.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=n;const t=this.gobbleToken();return t||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:Yl.UNARY_EXP,operator:e,argument:t,prefix:!0})}e=e.substr(0,--n)}Yl.isIdentifierStart(t)?(r=this.gobbleIdentifier(),Yl.literals.hasOwnProperty(r.name)?r={type:Yl.LITERAL,value:Yl.literals[r.name],raw:r.name}:r.name===Yl.this_str&&(r={type:Yl.THIS_EXP})):t===Yl.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let e=this.code;for(;e===Yl.PERIOD_CODE||e===Yl.OBRACK_CODE||e===Yl.OPAREN_CODE||e===Yl.QUMARK_CODE;){let n;if(e===Yl.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==Yl.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),e=this.code}this.index++,e===Yl.OBRACK_CODE?(t={type:Yl.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},this.gobbleSpaces(),e=this.code,e!==Yl.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):e===Yl.OPAREN_CODE?t={type:Yl.CALL_EXP,arguments:this.gobbleArguments(Yl.CPAREN_CODE),callee:t}:(e===Yl.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:Yl.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t,e,n="";for(;Yl.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(this.code===Yl.PERIOD_CODE)for(n+=this.expr.charAt(this.index++);Yl.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);if(t=this.char,"e"===t||"E"===t){for(n+=this.expr.charAt(this.index++),t=this.char,"+"!==t&&"-"!==t||(n+=this.expr.charAt(this.index++));Yl.isDecimalDigit(this.code);)n+=this.expr.charAt(this.index++);Yl.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")")}return e=this.code,Yl.isIdentifierStart(e)?this.throwError("Variable names cannot start with a number ("+n+this.char+")"):(e===Yl.PERIOD_CODE||1===n.length&&n.charCodeAt(0)===Yl.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:Yl.LITERAL,value:parseFloat(n),raw:n}}gobbleStringLiteral(){let t="";const e=this.index,n=this.expr.charAt(this.index++);let r=!1;for(;this.index<this.expr.length;){let e=this.expr.charAt(this.index++);if(e===n){r=!0;break}if("\\"===e)switch(e=this.expr.charAt(this.index++),e){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+="\t";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=e}else t+=e}return r||this.throwError('Unclosed quote after "'+t+'"'),{type:Yl.LITERAL,value:t,raw:this.expr.substring(e,this.index)}}gobbleIdentifier(){let t=this.code,e=this.index;for(Yl.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,Yl.isIdentifierPart(t));)this.index++;return{type:Yl.IDENTIFIER,name:this.expr.slice(e,this.index)}}gobbleArguments(t){const e=[];let n=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let i=this.code;if(i===t){n=!0,this.index++,t===Yl.CPAREN_CODE&&r&&r>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(i===Yl.COMMA_CODE){if(this.index++,r++,r!==e.length)if(t===Yl.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===Yl.CBRACK_CODE)for(let t=e.length;t<r;t++)e.push(null)}else if(e.length!==r&&0!==r)this.throwError("Expected comma");else{const t=this.gobbleExpression();t&&t.type!==Yl.COMPOUND||this.throwError("Expected comma"),e.push(t)}}return n||this.throwError("Expected "+String.fromCharCode(t)),e}gobbleGroup(){this.index++;let t=this.gobbleExpressions(Yl.CPAREN_CODE);if(this.code===Yl.CPAREN_CODE)return this.index++,1===t.length?t[0]:!!t.length&&{type:Yl.SEQUENCE_EXP,expressions:t};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:Yl.ARRAY_EXP,elements:this.gobbleArguments(Yl.CBRACK_CODE)}}}const zl=new class{add(t,e,n){if("string"!=typeof arguments[0])for(let t in arguments[0])this.add(t,arguments[0][t],arguments[1]);else(Array.isArray(t)?t:[t]).forEach((function(t){this[t]=this[t]||[],e&&this[t][n?"unshift":"push"](e)}),this)}run(t,e){this[t]=this[t]||[],this[t].forEach((function(t){t.call(e&&e.context?e.context:e,e)}))}};Object.assign(Yl,{hooks:zl,plugins:new class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach((t=>{if("object"!=typeof t||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");this.registered[t.name]||(t.init(this.jsep),this.registered[t.name]=t)}))}}(Yl),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),Yl.max_unop_len=Yl.getMaxKeyLen(Yl.unary_ops),Yl.max_binop_len=Yl.getMaxKeyLen(Yl.binary_ops);const Rl=t=>new Yl(t).parse();Object.getOwnPropertyNames(Yl).forEach((t=>{void 0===Rl[t]&&"prototype"!==t&&(Rl[t]=Yl[t])})),Rl.Jsep=Yl;var Ul={name:"ternary",init(t){t.hooks.add("after-expression",(function(e){if(e.node&&this.code===t.QUMARK_CODE){this.index++;const n=e.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===t.COLON_CODE){this.index++;const i=this.gobbleExpression();if(i||this.throwError("Expected expression"),e.node={type:"ConditionalExpression",test:n,consequent:r,alternate:i},n.operator&&t.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&t.binary_ops[r.right.operator]<=.9;)r=r.right;e.node.test=r.right,r.right=e.node,e.node=n}}else this.throwError("Expected :")}}))}};Rl.plugins.register(Ul);var Hl,Xl={};function Wl(t){if("number"==typeof t){if(0===t)return!1}else if(t instanceof al&&t.getValues().some((function(t){return 0===t})))return!1;return!0}Hl=Xl,function(){var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function e(n){return function(n,r){var i,a,o,l,u,s,f,c,h,d=1,g=n.length,p="";for(a=0;a<g;a++)if("string"==typeof n[a])p+=n[a];else if("object"==typeof n[a]){if((l=n[a]).keys)for(i=r[d],o=0;o<l.keys.length;o++){if(null==i)throw new Error(e('[sprintf] Cannot access property "%s" of undefined value "%s"',l.keys[o],l.keys[o-1]));i=i[l.keys[o]]}else i=l.param_no?r[l.param_no]:r[d++];if(t.not_type.test(l.type)&&t.not_primitive.test(l.type)&&i instanceof Function&&(i=i()),t.numeric_arg.test(l.type)&&"number"!=typeof i&&isNaN(i))throw new TypeError(e("[sprintf] expecting number but found %T",i));switch(t.number.test(l.type)&&(c=i>=0),l.type){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,l.width?parseInt(l.width):0);break;case"e":i=l.precision?parseFloat(i).toExponential(l.precision):parseFloat(i).toExponential();break;case"f":i=l.precision?parseFloat(i).toFixed(l.precision):parseFloat(i);break;case"g":i=l.precision?String(Number(i.toPrecision(l.precision))):parseFloat(i);break;case"o":i=(parseInt(i,10)>>>0).toString(8);break;case"s":i=String(i),i=l.precision?i.substring(0,l.precision):i;break;case"t":i=String(!!i),i=l.precision?i.substring(0,l.precision):i;break;case"T":i=Object.prototype.toString.call(i).slice(8,-1).toLowerCase(),i=l.precision?i.substring(0,l.precision):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=l.precision?i.substring(0,l.precision):i;break;case"x":i=(parseInt(i,10)>>>0).toString(16);break;case"X":i=(parseInt(i,10)>>>0).toString(16).toUpperCase()}t.json.test(l.type)?p+=i:(!t.number.test(l.type)||c&&!l.sign?h="":(h=c?"+":"-",i=i.toString().replace(t.sign,"")),s=l.pad_char?"0"===l.pad_char?"0":l.pad_char.charAt(1):" ",f=l.width-(h+i).length,u=l.width&&f>0?s.repeat(f):"",p+=l.align?h+i+u:"0"===s?h+u+i:u+h+i)}return p}(function(e){if(r[e])return r[e];for(var n,i=e,a=[],o=0;i;){if(null!==(n=t.text.exec(i)))a.push(n[0]);else if(null!==(n=t.modulo.exec(i)))a.push("%");else{if(null===(n=t.placeholder.exec(i)))throw new SyntaxError("[sprintf] unexpected placeholder");if(n[2]){o|=1;var l=[],u=n[2],s=[];if(null===(s=t.key.exec(u)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(l.push(s[1]);""!==(u=u.substring(s[0].length));)if(null!==(s=t.key_access.exec(u)))l.push(s[1]);else{if(null===(s=t.index_access.exec(u)))throw new SyntaxError("[sprintf] failed to parse named argument key");l.push(s[1])}n[2]=l}else o|=2;if(3===o)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]})}i=i.substring(n[0].length)}return r[e]=a}(n),arguments)}function n(t,n){return e.apply(null,[t].concat(n||[]))}var r=Object.create(null);Hl.sprintf=e,Hl.vsprintf=n,"undefined"!=typeof window&&(window.sprintf=e,window.vsprintf=n)}();const jl={min:function(t,e){return v(t.getValues())},minDate:function(t,e){let n=v(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 m(t.getValues())},maxDate:function(t,e){let n=m(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 D(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)e.value?n++:n=0,n>=r&&(r=n);return r},maxStreakStart:function(t,e){let n=0,r=0,i=null,a=null;if(t)for(let e of t)e.value?(0===n&&(i=e.date),n++):n=0,n>=r&&(r=n,a=i);return a},maxStreakEnd:function(t,e){let n=0,r=0,i=null,a=null;if(t){let e=Array.from(t);for(let t=0;t<e.length;t++){let o=e[t],l=null;t<e.length-1&&(l=e[t+1]),o.value?(n++,(null==l?void 0:l.value)||(i=o.date)):n=0,n>=r&&(r=n,a=i)}}return a},maxBreaks:function(t,e){let n=0,r=0;for(let e of t)e.value?n=0:n++,n>r&&(r=n);return r},maxBreaksStart:function(t,e){let n=0,r=0,i=null,a=null;if(t)for(let e of t)e.value?n=0:(0===n&&(i=e.date),n++),n>=r&&(r=n,a=i);return a},maxBreaksEnd:function(t,e){let n=0,r=0,i=null,a=null;if(t){let e=Array.from(t);for(let t=0;t<e.length;t++){let o=e[t],l=null;t<e.length-1&&(l=e[t+1]),o.value?n=0:(n++,(null==l?void 0:l.value)&&(i=o.date)),n>=r&&(r=n,a=i)}}return a},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(!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<e.length-1&&(n=e[t+1].date),!r.value)break}}return null===n?"Error: absense":n},currentStreakEnd:function(t,e){let n=0,r=null;if(t){let e=Array.from(t);for(let t=e.length-1;t>=0;t--){let i=e[t];if(!i.value)break;0===n&&(r=i.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(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<e.length-1&&(n=e[t+1].date),r.value)break}}return null===n?"Error: absense":n},currentBreaksEnd:function(t,e){let n=0,r=null;if(t){let e=Array.from(t);for(let t=e.length-1;t>=0;t--){let i=e[t];if(i.value)break;0===n&&(r=i.date),n++}}return null===r?"Error: absense":r},average:function(t,e){let n=t.getLengthNotNull();return Wl(n)?D(t.getValues())/n:"Error: divide by zero in expression"},median:function(t,e){return w(t.getValues())},variance:function(t,e){return function(t,e){let n,r=0,i=0,a=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(n=e-i,i+=n/++r,a+=n*(e-i));else{let o=-1;for(let l of t)null!=(l=e(l,++o,t))&&(l=+l)>=l&&(n=l-i,i+=n/++r,a+=n*(l-i))}if(r>1)return a/(r-1)}(t.getValues())}},ql={"-":function(t){if("number"==typeof t)return-1*t;if(t instanceof al){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 al){return t.cloneToTmpDataset()}return"Error: unknown operation for '+'"}},Gl={"+":function(t,e){if("number"==typeof t&&"number"==typeof e)return t+e;if("number"==typeof t&&e instanceof al){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 al&&"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 al&&e instanceof al){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 al){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 al&&"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 al&&e instanceof al){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 al){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 al&&"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 al&&e instanceof al){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(!Wl(e))return"Error: divide by zero in expression";if("number"==typeof t&&"number"==typeof e)return t/e;if("number"==typeof t&&e instanceof al){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 al&&"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 al&&e instanceof al){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(!Wl(e))return"Error: divide by zero in expression";if("number"==typeof t&&"number"==typeof e)return t%e;if("number"==typeof t&&e instanceof al){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 al&&"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 al&&e instanceof al){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 '%'"}},Ql={normalize:function(t,e,n){let r=t.getYMin(),i=t.getYMax();if(null!==r&&null!==i&&i>r){let e=t.cloneToTmpDataset();return e.getValues().forEach((function(t,e,n){n[e]=(t-r)/(i-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 Zl(t,e){switch(t.type){case"Literal":return t.value;case"Identifier":let n=t.name;return n in jl||n in Ql?`Error: deprecated template variable '${n}', use '${n}()' instead`:`Error: unknown function name '${n}'`;case"UnaryExpression":let r=t,i=Zl(r.argument,e);return"string"==typeof i?i:ql[r.operator](i);case"BinaryExpression":let a=t,o=Zl(a.left,e),l=Zl(a.right,e),u=function(t,e){return"string"==typeof t?t:"string"==typeof e?e:"number"==typeof t||window.moment.isMoment(t)||t instanceof al?"number"==typeof e||window.moment.isMoment(e)||e instanceof al?"":"Error: invalide operant type":"Error: invalid operant type"}(o,l);return"string"==typeof u&&u.startsWith("Error:")?u:Gl[a.operator](o,l);case"CallExpression":let s=t,f=s.callee.name,c=function(t,e){return t.map((function(t){return Zl(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 jl){if(0===c.length){let t=null;for(let n of e.datasets)t||n.getQuery().usedAsXDataset||(t=n);return t?jl[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 al?jl[f](t,e):`Error: function '${f}' only accepts Dataset`}return`Error: Too many arguments for function ${f}`}if(f in Ql){if(1===c.length){if("string"==typeof c[0])return c[0];if(c[0]instanceof al){let t=c[0];return Ql[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 al){let t=c[0];return Ql[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 Kl(t,e){let n,r=[],i=new RegExp("{{(?<expr>[\\w+\\-*\\/0-9\\s()\\[\\]%.,]+)(::(?<format>[\\w+\\-*\\/0-9\\s()\\[\\]%.:]+))?}}","gm");for(;n=i.exec(t);){let t=n[0];if(!r.some((e=>e.source===t))&&(void 0!==n.groups&&void 0!==n.groups.expr)){let i=n.groups.expr,a=null;try{a=Rl(i)}catch(t){return"Error:"+t.message}if(!a)return"Error: failed to parse expression";const o=Zl(a,e);if("string"==typeof o)return o;if("number"==typeof o||window.moment.isMoment(o)){let e=null;void 0!==n.groups.format&&(e=n.groups.format),r.push({source:t,value:o,format:e})}}}return r}function Jl(t,e){let n=Kl(t,e);if("string"==typeof n)return n;let r=n;for(let n of r){let r=n.source,i=n.value,a=n.format,o="";"number"==typeof i?o=a?Xl.sprintf("%"+a,i):i.toFixed(1):window.moment.isMoment(i)&&(o=El(i,a||e.dateFormat)),o&&(t=t.split(r).join(o))}return t}function tu(t,e){if(t=t.trim(),/^([\-]?[0-9]+[\.][0-9]+|[\-]?[0-9]+)$/.test(t))return parseFloat(t);let n=Kl(t,e);if("string"==typeof n)return n;let r=n;return r.length>0?r[0].value:"Error: failed to resolve values"}function eu(t,e,n,r){let i="",a=.5*n.dataAreaSize.width,o=.7*a,l=o*r.ratioInnerRadius,u=[];for(let t of r.data){let e=tu(t,n);if("string"==typeof e){i=e;break}"number"==typeof e&&u.push(e)}if(""!==i)return i;let s=[];for(let t of r.label){let e=Jl(t,n);if(e.startsWith("Error")){i=e;break}s.push(e)}if(""!==i)return i;let f=r.hideLabelLessThan,c=s.map((function(t){return Vl(t,"tracker-tick-label")})),h=[];for(let t of r.extLabel){let e=Jl(t,n);if(e.startsWith("Error")){i=e;break}h.push(e)}if(""!==i)return i;let d=h.map((function(t){return Vl(t,"tracker-pie-label")})),g=r.showExtLabelOnlyIfNoLabel,p=Zr().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=Ko,e=Zo,n=null,r=Co(0),i=Co(Vo),a=Co(0);function o(o){var l,u,s,f,c,h=(o=Wo(o)).length,d=0,g=new Array(h),p=new Array(h),y=+r.apply(this,arguments),m=Math.min(Vo,Math.max(-Vo,i.apply(this,arguments)-y)),v=Math.min(Math.abs(m)/h,a.apply(this,arguments)),x=v*(m<0?-1:1);for(l=0;l<h;++l)(c=p[g[l]=l]=+t(o[l],l,o))>0&&(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(o[t],o[e])})),l=0,s=d?(m-h*x)/d:0;l<h;++l,y=f)u=g[l],f=y+((c=p[u])>0?c*s:0)+x,p[u]={data:o[u],index:l,value:c,startAngle:y,endAngle:f,padAngle:v};return p}return o.value=function(e){return arguments.length?(t="function"==typeof e?e:Co(+e),o):t},o.sortValues=function(t){return arguments.length?(e=t,n=null,o):e},o.sort=function(t){return arguments.length?(n=t,e=null,o):n},o.startAngle=function(t){return arguments.length?(r="function"==typeof t?t:Co(+t),o):r},o.endAngle=function(t){return arguments.length?(i="function"==typeof t?t:Co(+t),o):i},o.padAngle=function(t){return arguments.length?(a="function"==typeof t?t:Co(+t),o):a},o}(),v=m(u),x=y.selectAll("sector").data(v).enter().append("g").attr("class","sector"),A=Xo().innerRadius(l).outerRadius(o);var w=Xo().innerRadius(.9*a).outerRadius(.9*a);function b(t){return(t.endAngle-t.startAngle)/(2*Math.PI)<f}function D(t){return t.startAngle+(t.endAngle-t.startAngle)/2}function k(t,e){let n=c[e].width,r=d[e].width;b(t);let i=D(t),o=A.centroid(t),l=w.centroid(t),u=w.centroid(t),f=Math.sqrt(Math.pow(l[0]-o[0],2)+Math.pow(l[1]-o[1],2));return""!==s[e]&&(o[0]=o[0]+(l[0]-o[0])*n/f,o[1]=o[1]+(l[1]-o[1])*n/f,u[0]=(.99*a-r-3)*(i<Math.PI?1:-1)),f=Math.sqrt(Math.pow(l[0]-o[0],2)+Math.pow(l[1]-o[1],2)),f>Math.sqrt(Math.pow(u[0]-o[0],2)+Math.pow(u[1]-o[1],2))?[o,u]:[o,l,u]}x.append("path").attr("fill",(function(t,e){return p(e.toString())})).attr("d",A),y.selectAll("label").data(m(u)).enter().append("text").text((function(t,e){return b(t)?"":s[e]})).attr("transform",(function(t){return"translate("+A.centroid(t)[0]+","+A.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=w.centroid(t),r=D(t);return n[0]=(.99*a-d[e].width)*(r<Math.PI?1:-1),"translate("+n[0]+","+n[1]+")"})).style("text-anchor",(function(t){return D(t)<Math.PI?"start":"end"})).attr("class","tracker-pie-label"),y.selectAll("line").data(v).enter().append("polyline").attr("stroke","black").style("fill","none").attr("stroke-width",1).attr("points",(function(t,e){if(g){if((""===s[e]||b(t))&&""!==h[e])return k(t,e)}else if(""!==h[e])return k(t,e)})).attr("class","tracker-axis")}function nu(t,e,n){if(!e||!n)return;let r={};r=function(t,e,n,r){ee(e).select("#svg").remove();for(var i=Object.getOwnPropertyNames(t),a=0;a<i.length;a++)delete t[i[a]];let o=ee(e).append("svg").attr("id","svg").attr("width",n.dataAreaSize.width+n.margin.left+n.margin.right).attr("height",n.dataAreaSize.height+n.margin.top+n.margin.bottom);t.svg=o;let l=o.append("g").attr("id","graphArea").attr("transform","translate("+n.margin.left+","+n.margin.top+")").attr("width",n.dataAreaSize.width+n.margin.right).attr("height",n.dataAreaSize.height+n.margin.bottom);t.graphArea=l;let u=l.append("g").attr("id","dataArea").attr("width",n.dataAreaSize.width).attr("height",n.dataAreaSize.height);return t.dataArea=u,t}(r,t,e);let i=ko[n.dataColor.length];for(let t=0;t<n.dataColor.length;t++)null===n.dataColor[t]&&(n.dataColor[t]=i[t]);!function(t,e,n,r){if(!n||!r)return;if(!r.title)return;let i=Vl(r.title,"tracker-title"),a=e.graphArea.append("text").text(r.title).attr("id","title").attr("transform","translate("+n.dataAreaSize.width/2+","+i.height/2+")").attr("height",i.height).attr("class","tracker-title");e.title=a,Ol(e.svg,0,i.height),Ol(e.graphArea,0,i.height),Pl(e.dataArea,0,i.height)}(0,r,e,n),eu(0,r,e,n),n.showLegend&&function(t,e,n,r){let i=e.svg;e.graphArea;let a=e.dataArea,o=e.title,l=0;o&&(l=parseFloat(o.attr("height")));let u=r.dataName,s=u.map((function(t){return Vl(t,"tracker-legend-label")})),f=0,c=0;for(let t=0;t<u.length;t++)s[t].width>c&&(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,v=0,x=0;"vertical"===r.legendOrientation?(v=3*p+m+c,x=(g+1)*y):"horizontal"===r.legendOrientation&&(v=(2*p+m)*g+p+D(s,(function(t,e){return t.width})),x=y+d);let A=0,w=0;if("top"===r.legendPosition)A=n.dataAreaSize.width/2-v/2,w=l,Ol(i,0,x+y),Pl(a,0,x+y);else if("bottom"===r.legendPosition)A=n.dataAreaSize.width/2-v/2,w=l+n.dataAreaSize.height+y,Ol(i,0,x+y);else if("left"===r.legendPosition)A=0,w=l+n.dataAreaSize.height/2-x/2,Ol(i,v+p,0),Pl(a,v+p,0);else{if("right"!==r.legendPosition)return;A=n.dataAreaSize.width+p,w=l+n.dataAreaSize.height/2-x/2,Ol(i,v+p,0)}let b=e.graphArea.append("g").attr("id","legend").attr("transform","translate("+A+","+w+")"),k=b.append("rect").attr("class","tracker-legend").attr("width",v).attr("height",x);r.legendBgColor&&k.style("fill",r.legendBgColor),r.legendBorderColor&&k.style("stroke",r.legendBorderColor);let C=p,M=d,T=C+p+m,_=M;if("vertical"===r.legendOrientation)b.selectAll("markers").data(u).enter().append("circle").attr("cx",C+m/2).attr("cy",(function(t,e){return M+e*y})).attr("r",(function(t,e){return 5})).style("fill",(function(t,e){return r.dataColor[e]})),b.selectAll("labels").data(u).enter().append("text").attr("x",T).attr("y",(function(t,e){return _+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,b.selectAll("markers").data(u).enter().append("circle").attr("cx",(function(e,n){return 0===n?t=C+m/2:t+=s[n].width+p+m+p,t})).attr("cy",M).attr("r",(function(t,e){return 5})).style("fill",(function(t,e){return r.dataColor[e]})),t=0,b.selectAll("labels").data(u).enter().append("text").attr("x",(function(e,n){return 0===n?t=T:t+=s[n].width+p+m+p,t})).attr("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]}))}}(0,r,e,n),function(t,e,n){let r=ee(t),i=e.svg,a=parseFloat(i.attr("width")),o=parseFloat(i.attr("height"));i.attr("width",null).attr("height",null).attr("viewBox",`0 0 ${a} ${o}`).attr("preserveAspectRatio","xMidYMid meet"),n.fitPanelWidth?r.style("width","100%"):(r.style("width",(a*n.fixedScale).toString()+"px"),r.style("height",(o*n.fixedScale).toString()+"px"))}(t,r,e)}function ru(t,e,n){if(!e||!n)return;let r="";n.template,r=n.template;let i=Jl(r,e);if(i.startsWith("Error:"))return i;if(r=i,""!==r){let e=ee(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 iu=!1,au=2.8,ou=1.8;function lu(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 i=e.selectedDataset,a=n.findIndex((t=>t===i));if(a>=0){if(a===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)}{a++;let i=n[a];if(r=t.datasets.getDatasetById(i),e.selectedDataset=i,r&&!r.getQuery().usedAsXDataset)return!0;lu(t,e)}}}return!1}function uu(t,e,n,r){ee(e).select("#svg").remove();for(var i=Object.getOwnPropertyNames(t),a=0;a<i.length;a++)delete t[i[a]];let o=ee(e).append("svg").attr("id","svg").attr("width",n.dataAreaSize.width+n.margin.left+n.margin.right).attr("height",n.dataAreaSize.height+n.margin.top+n.margin.bottom);t.svg=o;let l=o.append("g").attr("id","graphArea").attr("transform","translate("+n.margin.left+","+n.margin.top+")").attr("width",n.dataAreaSize.width+n.margin.right).attr("height",n.dataAreaSize.height+n.margin.bottom);t.graphArea=l;let u=l.append("g").attr("id","dataArea").attr("width",n.dataAreaSize.width).attr("height",n.dataAreaSize.height);return t.dataArea=u,t}function su(t,e){let n=t.svg.selectAll("circle");for(let t of n){let e=ee(t).attr("id");e&&e.startsWith("tracker-selected-circle-")&&ee(t).style("stroke","none")}e.selectedDate="",t.monitor.text("")}function fu(t,e,n,r,i){if(!n||!r)return;let a=r.selectedDataset;if(null===a)return;let o=n.datasets.getDatasetById(a);if(!o)return;let l=o.getName();i.month(),i.daysInMonth(),i.year();let u=Vl("30","tracker-month-label"),s=Math.max(u.width,u.height)*au,f=i.format("YYYY"),c=i.format("MMM"),h=Vl(f,"tracker-month-header-year"),d=Vl(c,"tracker-month-header-month"),g=0,p=e.graphArea.append("g"),y=null;r.headerMonthColor?y=r.headerMonthColor:r.color&&(y=r.color);let m=p.append("text").text(c).attr("id","titleMonth").attr("transform","translate("+s/4+","+d.height+")").attr("class","tracker-month-header-month").style("cursor","default").on("click",(function(t){su(e,r)}));y&&m.style("fill",y),g+=d.height;let v=null;r.headerYearColor?v=r.headerYearColor:r.color&&(v=r.color);let x=p.append("text").text(f).attr("id","titleYear").attr("transform","translate("+s/4+","+(g+h.height)+")").attr("class","tracker-month-header-year").style("cursor","default").attr("font-weight","bold").on("click",(function(t){su(e,r)}));v&&x.style("fill",v),g+=h.height;let A=Vl(l,"tracker-month-title-rotator");if("circle"===r.mode||"annotation"===r.mode&&!r.showAnnotationOfAllTargets){let a=p.append("text").text(l).attr("transform","translate("+3.5*s+","+A.height+")").attr("class","tracker-month-title-rotator").style("cursor","pointer").on("click",(function(a){lu(n,r)&&(su(e,r),hu(t,e,n,r,i))}));e.rotator=a}let w=Vl("0.0000","tracker-month-title-monitor"),b=p.append("text").text("").attr("id","monitor").attr("class","tracker-month-title-monitor").attr("transform","translate("+3.5*s+","+(A.height+w.height)+")").style("cursor","pointer").style("fill",r.selectedRingColor);e.monitor=b;let D=Vl("<","tracker-month-title-arrow");p.append("text").text("<").attr("id","arrowLeft").attr("transform","translate("+5.5*s+","+(g/2+D.height/2)+")").attr("class","tracker-month-title-arrow").on("click",(function(a){su(e,r),r.selectedDate="";let o=i.clone().add(-1,"month");hu(t,e,n,r,o)})).style("cursor","pointer"),p.append("text").text(">").attr("id","arrowLeft").attr("transform","translate("+6.5*s+","+(g/2+D.height/2)+")").attr("class","tracker-month-title-arrow").on("click",(function(a){su(e,r);let o=i.clone().add(1,"month");hu(t,e,n,r,o)})).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(i){su(e,r);let a=Sl(n.dateFormat);hu(t,e,n,r,a)})).style("cursor","pointer"),g+=8;let k=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];"mon"===r.startWeekOn.toLowerCase()&&k.push(k.shift());let C=Vl(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+C.height)+")"})).attr("class","tracker-month-weekday").attr("text-anchor","middle").style("cursor","default").on("click",(function(t){su(e,r)})),g+=C.height+8;let M=null;r.dividingLineColor?M=r.dividingLineColor:r.color&&(M=r.color);let T=e.graphArea.append("rect").attr("x",0).attr("y",g).attr("width",6.5*s+C.width).attr("height",1).attr("class","tracker-month-dividing-line");M&&T.style("fill",M),g+=1,p.attr("height",g),e.header=p,Pl(e.dataArea,0,g)}function cu(t,e,n,r,i){if(!n||!r)return;let a=r.mode;if("circle"!==a&&"annotation"!==a)return"Unknown month view mode";let o=r.selectedDataset;if(null===o)return;let l=n.datasets.getDatasetById(o);if(!l)return;let u=r.dataset.findIndex((t=>t===o));o<0&&(u=0);let s=r.threshold[u];i.month(),i.daysInMonth();let f=Vl("30","tracker-month-label"),c=Math.max(f.width,f.height)*au,h=c/au*ou/2,d=(c-2*h)/2,g=v(l.getValues());null!==r.yMin[u]&&(g=r.yMin[u]);let p=m(l.getValues());null!==r.yMax[u]&&(p=r.yMax[u]);let y=!0;(null===p||null===g||p<=g)&&(y=!1);const x=i.clone().startOf("month");let A=x.clone().subtract(x.day(),"days");"mon"===r.startWeekOn.toLowerCase()&&(A=A.add(1,"days"));const w=i.clone().endOf("month");let b=w.clone().add(7-w.day()-1,"days");"mon"===r.startWeekOn.toLowerCase()&&(b=b.add(1,"days"));const D=l.getStartDate(),k=l.getEndDate();let C=r.showAnnotation,M=r.annotation,T=M[u],_=r.showAnnotationOfAllTargets,E=[],F=0,S=0,B=0;for(let t=A.clone();t<=b;t.add(1,"days")){t=Cl(El(t,n.dateFormat),n.dateFormat),"2021-09-13"===t.format("YYYY-MM-DD")&&(iu=!1),"mon"===r.startWeekOn.toLowerCase()?(F=t.day()-1,F<0&&(F=6),S=Math.floor(B/7)):(F=t.day(),S=Math.floor(B/7));let e=!0;(t.diff(x)<0||t.diff(w)>0)&&(e=!1);let i=!0;D&&k&&t.diff(D)>=0&&t.diff(k)<=0&&(i=!1);const a=l.getValue(t);iu&&(console.log(l),console.log(El(t,n.dateFormat)),console.log(a));let o=!1;r.circleColorByValue?(y||null!==a&&a>s)&&(o=!0):null!==a&&a>s&&(o=!0);let u=null;r.circleColorByValue&&y&&null!==a&&(u=(a-g)/(p-g)),iu&&(console.log(g),console.log(p),console.log(u));let f=l.getValue(t,1),c=l.getValue(t,-1),h=!1;null!==a&&a>s&&null!==c&&c>s&&(h=!0);let d=!1;null!==a&&a>s&&null!==f&&f>s&&(d=!0),iu&&(console.log(`preValue: ${c}, curValue: ${a}, nextValue: ${f}`),console.log(r.threshold),console.log(`streakIn: ${h}, streakOut: ${d}`));let m="";if(C)if(_)for(let e of r.dataset){let i=r.dataset.findIndex((t=>t===e));if(i>=0){let a=n.datasets.getDatasetById(e).getValue(t),o=r.threshold[i];null!==a&&a>o&&(m+=M[i])}}else a>s&&(m=T);E.push({date:El(t,n.dateFormat),value:a,scaledValue:u,dayInMonth:t.date(),isInThisMonth:e,isOutOfDataRange:i,row:S,col:F,showCircle:o,streakIn:h,streakOut:d,annotation:m}),B++,iu&&(iu=!1)}let N=(F+1)*c,I=si().domain([-.5,6.5]).range([0,N]);if("circle"===a&&r.showCircle&&r.showStreak){let t="#69b3a2";r.circleColor?t=r.circleColor:r.color&&(t=r.color),e.dataArea.selectAll("streakIn").data(E.filter((function(t){return t.streakIn}))).enter().append("rect").attr("x",(function(t){return I(t.col)-h-d})).attr("y",(function(t){return I(t.row)-1.5})).attr("width",d).attr("height",3).style("fill",(function(e){return e.showCircle?r.circleColorByValue?null!==e.scaledValue?Cn("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(E.filter((function(t){return t.streakOut}))).enter().append("rect").attr("x",(function(t){return I(t.col)+h})).attr("y",(function(t){return I(t.row)-1.5})).attr("width",d).attr("height",3).style("fill",(function(e){return e.showCircle?r.circleColorByValue?null!==e.scaledValue?Cn("white",t)(.8*e.scaledValue+.2):"none":t:"none"})).style("opacity",(function(t){return t.isOutOfDataRange||r.dimNotInMonth&&!t.isInThisMonth?.2:1}))}let L="#69b3a2";r.circleColor?L=r.circleColor:r.color&&(L=r.color),"circle"===a&&r.showCircle&&e.dataArea.selectAll("dot").data(E).enter().append("circle").attr("r",h).attr("cx",(function(t){return I(t.col)})).attr("cy",(function(t){return I(t.row)})).style("fill",(function(t){if(t.showCircle){if(!r.circleColorByValue)return L;if(null!==t.scaledValue){return Cn("white",L)(.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 V=El(window.moment(),n.dateFormat);if("circle"===a&&r.showTodayRing){let t=e.dataArea.selectAll("todayRing").data(E.filter((function(t){return t.date===V}))).enter().append("circle").attr("r",.9*h).attr("cx",(function(t){return I(t.col)})).attr("cy",(function(t){return I(t.row)})).attr("class","tracker-month-today-circle").style("cursor","default");""!==r.todayRingColor?t.style("stroke",r.todayRingColor):t.style("stroke","white")}"circle"===a&&r.showSelectedRing&&e.dataArea.selectAll("selectedRing").data(E).enter().append("circle").attr("r",h).attr("cx",(function(t){return I(t.col)})).attr("cy",(function(t){return I(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(E).enter().append("text").text((function(t){return t.dayInMonth.toString()})).attr("transform",(function(t){return"translate("+I(t.col)+","+(I(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 nl[l.valueType]})).attr("class","tracker-month-label").on("click",(function(t){su(e,r);let n=ee(this).attr("date");if(r.selectedDate=n,r.showSelectedRing&&e.dataArea.select("#tracker-selected-circle-"+n).style("stroke",r.selectedRingColor),r.showSelectedValue){let t=ee(this).attr("value"),n="";if("Time"===ee(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"===a&&C&&e.dataArea.selectAll("dayAnnotation").data(E).enter().append("text").text((function(t){return t.annotation})).attr("transform",(function(t){let e=I(t.col),n=I(t.row)+f.height/4;return t.annotation&&(n+=h),"translate("+e+","+n+")"})).attr("class","tracker-month-annotation");let O=parseFloat(e.svg.attr("width")),P=parseFloat(e.svg.attr("height")),$=parseFloat(e.graphArea.attr("width")),Y=parseFloat(e.graphArea.attr("height")),z=7*c+parseFloat(e.header.attr("height")),R=7*c;z>P&&Ol(e.svg,0,z-P),R>O&&Ol(e.svg,R-O,0),z>Y&&Ol(e.graphArea,0,z-Y),R>$&&Ol(e.svg,R-$,0)}function hu(t,e,n,r,i){n&&du&&(fu(t,e=uu(e,t,n),n,r,i),cu(0,e,n,r,i))}function du(t,e,n){if(!e||!du)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(lu(e,n),null===n.selectedDataset)return"No available dataset found";let i={};i=uu(i,t,e);let a=null;if(n.initMonth){if(a=_l(n.initMonth,e.dateFormat),!a){let t=window.moment(n.initMonth,"YYYY-MM",!0);if(!t.isValid())return"Invalid initMonth";a=t}}else a=e.datasets.getDates().last();a&&(fu(t,i,e,n,a),cu(0,i,e,n,a),function(t,e,n){let r=ee(t),i=e.svg,a=parseFloat(i.attr("width")),o=parseFloat(i.attr("height"));i.attr("width",null).attr("height",null).attr("viewBox",`0 0 ${a} ${o}`).attr("preserveAspectRatio","xMidYMid meet"),n.fitPanelWidth?r.style("width","100%"):(r.style("width",(a*n.fixedScale).toString()+"px"),r.style("height",(o*n.fixedScale).toString()+"px"))}(t,i,e))}function gu(t,e,n){if(e&&gu)return"Under construction"}function pu(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 i=function(t,e,n){let r={};if(!e||!n)return;let i=ee(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=i;let a=i.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=a;let o=a.append("g").attr("id","dataArea").attr("width",e.dataAreaSize.width).attr("height",e.dataAreaSize.height);return r.dataArea=o,r}(t,e,n),a=function(t,e,n,r){if(!e||!n)return;let i=n.range,a=i[i.length-1],o=[0,a],l=n.valueUnit,u=function(t){return l&&l.endsWith("%")?li(0,a,7)(t)+" %":li(0,a,7)(t)},s=Vl(u(a),"tracker-tick-label");if("horizontal"===n.orientation){let n=si();n.domain(o).range([0,e.dataAreaSize.width]),t.scale=n;let r=V(n);r.tickFormat(u);let i=t.dataArea.append("g").attr("id","axis").attr("transform","translate(0,"+e.dataAreaSize.height+")").call(r).attr("class","tracker-axis");t.axis=i,i.selectAll("path").style("stroke","none"),i.selectAll("line"),i.selectAll("text").attr("class","tracker-tick-label"),i.attr("width",e.dataAreaSize.width+s.width),i.attr("height",6+s.height),Ol(t.svg,+s.width,6+s.height),Ol(t.graphArea,+s.width,6+s.height)}else if("vertical"===n.orientation){let n=si();n.domain(o).range([e.dataAreaSize.height,0]),t.scale=n;let r=O(n);r.tickFormat(u);let i=t.dataArea.append("g").attr("id","axis").attr("x",0).attr("y",0).call(r).attr("class","tracker-axis");t.axis=i,i.selectAll("path").style("stroke","none"),i.selectAll("line"),i.selectAll("text").attr("class","tracker-tick-label"),i.attr("width",6+s.width),i.attr("height",e.dataAreaSize.width),Ol(t.svg,6+s.width,0),Ol(t.graphArea,6+s.width,0),Pl(t.dataArea,6+s.width,0)}}(i,e,n);if("string"==typeof a)return a;!function(t,e,n){if(!e||!n)return;if(n.title){let r=Vl(n.title,"tracker-title-small");if("horizontal"===n.orientation){let i=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=i,Ol(t.svg,r.width+6,0),Ol(t.graphArea,r.width+6,0),Pl(t.dataArea,r.width+6,0)}else if("vertical"===n.orientation){let i=e.dataAreaSize.width/2;r.width>e.dataAreaSize.width&&(Ol(t.svg,r.width-e.dataAreaSize.width,0),Ol(t.graphArea,r.width-e.dataAreaSize.width,0),Pl(t.dataArea,r.width/2-e.dataAreaSize.width/2,0),i=r.width/2);let a=parseFloat(t.axis.attr("width")),o=t.graphArea.append("text").text(n.title).attr("id","title").attr("x",i+a).attr("y",r.height/2).attr("height",r.height).attr("class","tracker-title-small");t.title=o,Ol(t.svg,0,r.height+6),Ol(t.graphArea,0,r.height+6),Pl(t.dataArea,0,r.height+6)}}if(n.valueUnit){let r=Vl(n.valueUnit,"tracker-tick-label");if("horizontal"===n.orientation){let i=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=i}else if("vertical"===n.orientation){let i=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=i,Ol(t.svg,0,r.height+6),Ol(t.graphArea,0,r.height+6),Pl(t.dataArea,0,r.height+6)}}}(i,e,n),function(t,e,n,r){if(!e||!n)return;let i=t.scale,a=n.range,o=n.rangeColor,l=[],u=0;for(let t=0;t<a.length;t++)l.push({start:u,end:a[t],color:o[t]}),u=a[t];"horizontal"===n.orientation?t.dataArea.selectAll("backPanel").data(l).enter().append("rect").attr("x",(function(t,e){return Math.floor(i(t.start))})).attr("y",(function(t){return 0})).attr("width",(function(t,e){return Math.ceil(i(t.end-t.start))})).attr("height",e.dataAreaSize.height).style("fill",(function(t){return t.color})):"vertical"===n.orientation&&t.dataArea.selectAll("backPanel").data(l).enter().append("rect").attr("x",(function(t,e){return 0})).attr("y",(function(t){return Math.floor(i(t.end))})).attr("width",e.dataAreaSize.width).attr("height",(function(t){return e.dataAreaSize.height-Math.floor(i(t.end-t.start))})).style("fill",(function(t){return t.color}))}(i,e,n);let o=function(t,e,n,r){let i="";if(!e||!n)return;let a=tu(n.value,e);if("string"==typeof a)return a;let o=a;if(Number.isNaN(o))return i="Invalid input value: "+a,i;let l=n.valueColor,u=t.scale;if("horizontal"===n.orientation){let n=e.dataAreaSize.height/3;t.dataArea.append("rect").attr("x",u(0)).attr("y",n).attr("width",Math.floor(u(o))).attr("height",n).style("fill",l)}else if("vertical"===n.orientation){let n=e.dataAreaSize.width/3;t.dataArea.append("rect").attr("x",n).attr("y",Math.floor(u(o))).attr("width",n).attr("height",e.dataAreaSize.height-Math.floor(u(o))).style("fill",l)}}(i,e,n);if("string"==typeof o)return o;!function(t,e,n,r){if(!e||!n)return;if(!n.showMarker)return;let i=n.markerValue,a=n.markerColor,o=t.scale;if("horizontal"===n.orientation){let n=2*e.dataAreaSize.height/3;t.dataArea.append("rect").attr("x",o(i)-1.5).attr("y",n/4).attr("width",3).attr("height",n).style("fill",a)}else if("vertical"===n.orientation){let n=2*e.dataAreaSize.width/3;t.dataArea.append("rect").attr("x",n/4).attr("y",o(i)-1.5).attr("width",n).attr("height",3).style("fill",a)}}(i,e,n),function(t,e,n){let r=ee(t),i=e.svg,a=parseFloat(i.attr("width")),o=parseFloat(i.attr("height"));i.attr("width",null).attr("height",null).attr("viewBox",`0 0 ${a} ${o}`).attr("preserveAspectRatio","xMidYMid meet"),n.fitPanelWidth?r.style("width","100%"):(r.style("width",(a*n.fixedScale).toString()+"px"),r.style("height",(o*n.fixedScale).toString()+"px"))}(t,i,e)}function yu(t,e,n){if(!e||!n)return;let r=e.datasets,i=function(t,e){let n,r;if(void 0===e)for(const e of t)null!=e&&(void 0===n?e>=e&&(n=r=e):(n>e&&(n=e),r<e&&(r=e)));else{let i=-1;for(let a of t)null!=(a=e(a,++i,t))&&(void 0===n?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)))}return[n,r]}(r.getDates()),a=Do().domain(i).range([0,e.dataAreaSize.width]);t.xScale=a;let o=Tl(n.xAxisTickInterval),[l,u]=function(t,e){let n=[],r=null;if(e){let r=t[0],i=t[t.length-1];n=Mi.range(r.toDate(),i.toDate(),e.asDays())}else{let e=t.length;r=e<=15?Mi:e<=60?Mi.every(4):e<=105?Fi:e<=450?Xi:e<=900?Xi.every(2):ji}return[n,r]}(r.getDates(),o),s=function(t,e){if(e){function n(t){return El(window.moment(t),e)}return n}{let r=null,i=t.length;return r=ea(i<=15||i<=60||i<=105?"%y-%m-%d":i<=450||i<=900?"%y %b":"%Y"),r}}(r.getDates(),n.xAxisTickLabelFormat),f=V(a);l&&0!==l.length?f.tickValues(l):u&&f.ticks(u),s&&f.tickFormat(s);let c=t.dataArea.append("g").attr("id","xAxis").attr("transform","translate(0,"+e.dataAreaSize.height+")").call(f).attr("class","tracker-axis");n.xAxisColor&&c.style("stroke",n.xAxisColor),t.xAxis=c;let h=Vl("99-99-99"),d=c.selectAll("text").attr("x",-1*h.height*Math.cos(65/180*Math.PI)).attr("y",0).attr("transform","rotate(-65)").style("text-anchor","end").attr("class","tracker-tick-label");n.xAxisColor&&d.style("fill",n.xAxisColor);let g=h.width*Math.sin(65/180*Math.PI),p=c.append("text").text(n.xAxisLabel).attr("transform","translate("+e.dataAreaSize.width/2+","+(6+g)+")").attr("class","tracker-axis-label");n.xAxisLabelColor&&p.style("fill",n.xAxisLabelColor),c.attr("height",6+g),Ol(t.svg,0,6+g),Ol(t.graphArea,0,6+g)}function mu(t,e,n,r,i){if(!e||!n)return;let a=e.datasets;if(0===i.length)return;if("left"!==r&&"right"!==r)return;let o=null,l=null,u=null,s=!1;for(let t of i){let e=a.getDatasetById(t);if(!e.getQuery().usedAsXDataset)if((null===o||e.getYMin()<o)&&(o=e.getYMin()),(null===l||e.getYMax()>l)&&(l=e.getYMax()),s=e.valueType===nl.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=o: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=l:d=!0,h<f){let t=f;f=h,h=t;let e=c;c=d,d=e}let g,p,y=h-f,m=si();g=c?f:f-.2*y,p=d?h:h+.2*y,n.GetGraphType()===el.Bar&&(p<0&&(p=0),g>0&&(g=0));let v=[g,p];("left"===r&&n.reverseYAxis[0]||"right"===r&&n.reverseYAxis[1])&&(v=[p,g]),m.domain(v).range([e.dataAreaSize.height,0]),"left"===r?t.leftYScale=m:"right"===r&&(t.rightYScale=m);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 w="";"left"===r?w=n.yAxisLabel[0]:"right"===r&&(w=n.yAxisLabel[1]);let D="",k=null,C=null;"left"===r?(D=n.yAxisUnit[0],k=n.yAxisTickInterval[0],C=n.yAxisTickLabelFormat[0]):"right"===r&&(D=n.yAxisUnit[1],k=n.yAxisTickInterval[1],C=n.yAxisTickLabelFormat[1]);let T,_=null;if(s?_=Tl(k):(_=parseFloat(k),Number.isNumber(_)&&!Number.isNaN(_)||(_=null)),"left"===r?T=O(m):"right"===r&&(T=L(M,m)),T){let t=function(t,e,n,r=!1){if(r){if(n){function i(t){return window.moment("00:00","HH:mm",!0).add(t,"seconds").format(n)}return i}{function a(n){const r=Math.abs(e-t);let i=window.moment("00:00","HH:mm",!0).add(n,"seconds").format("HH:mm");return r>43200&&(n<t||n>e||(n-t)/3600%2<1)&&(i=""),i}return a}}if(n){function o(t){return Xl.sprintf("%"+n,t)}return o}return li(t,e,10)}(g,p,C,s);t&&T.tickFormat(t);let e=function(t,e,n,r=!1){const i=Math.abs(e-t);let a=[];r?a=n&&window.moment.isDuration(n)?b(t,e,Math.abs(n.asSeconds())):i>18e3?b(t=3600*Math.floor(t/3600),e=3600*Math.ceil(e/3600),3600):b(t=1800*Math.floor(t/1800),e=1800*Math.ceil(e/1800),1800):n&&"number"==typeof n&&(a=b(t,e,n));return 0===a.length?null:a}(g,p,_,s);e&&T.tickValues(e)}let E=t.dataArea.append("g").attr("id","yAxis").call(T).attr("class","tracker-axis");"right"==r&&E.attr("transform","translate("+e.dataAreaSize.width+" ,0)"),"left"===r?t.leftYAxis=E:"right"===r&&(t.rightYAxis=E);let F=E.selectAll("path");x&&F.style("stroke",x);let S=E.selectAll("line");x&&S.style("stroke",x);let B=E.selectAll("text").attr("class","tracker-tick-label");x&&B.style("fill",x);let N=0;for(let t of B)if(t.textContent){let e=Vl(t.textContent,"tracker-axis-label");e.width>N&&(N=e.width)}""!==D&&(w+=" ("+D+")");let I=Vl(w),V=E.append("text").text(w).attr("transform","rotate(-90)").attr("x",-1*e.dataAreaSize.height/2).attr("class","tracker-axis-label");"left"===r?V.attr("y",-6-N-I.height/2):V.attr("y",6+N+I.height),A&&V.style("fill",A);let P=I.height+N+6;E.attr("width",P),Ol(t.svg,P,0),Ol(t.graphArea,P,0),"left"===r&&(Pl(t.dataArea,P,0),t.title&&Pl(t.title,P,0))}function vu(t,e,n,r,i){if(!e||!n)return;let a=null;if("left"===i?a=t.leftYScale:"right"===i&&(a=t.rightYScale),n.showLine[r.getId()]){let e=function(t,e){var n=Co(!0),r=null,i=qo,a=null,o=Po(l);function l(l){var u,s,f,c=(l=Wo(l)).length,h=!1;for(null==r&&(a=i(f=o())),u=0;u<=c;++u)!(u<c&&n(s=l[u],u,l))===h&&((h=!h)?a.lineStart():a.lineEnd()),h&&a.point(+t(s,u,l),+e(s,u,l));if(f)return a=null,f+""||null}return t="function"==typeof t?t:void 0===t?Go:Co(t),e="function"==typeof e?e:void 0===e?Qo:Co(e),l.x=function(e){return arguments.length?(t="function"==typeof e?e:Co(+e),l):t},l.y=function(t){return arguments.length?(e="function"==typeof t?t:Co(+t),l):e},l.defined=function(t){return arguments.length?(n="function"==typeof t?t:Co(!!t),l):n},l.curve=function(t){return arguments.length?(i=t,null!=r&&(a=i(r)),l):i},l.context=function(t){return arguments.length?(null==t?r=a=null:a=i(r=t),l):r},l}().defined((function(t){return null!==t.value})).x((function(e){return t.xScale(e.date)})).y((function(t){return a(t.value)})),i=t.dataArea.append("path").attr("class","tracker-line").style("stroke-width",n.lineWidth[r.getId()]);n.fillGap[r.getId()]?i.datum(Array.from(r).filter((function(t){return null!==t.value}))).attr("d",e):i.datum(r).attr("d",e),n.lineColor[r.getId()]&&i.style("stroke",n.lineColor[r.getId()])}}function xu(t,e,n,r,i){if(!e||!n)return;let a=null;if("left"===i?a=t.leftYScale:"right"===i&&(a=t.rightYScale),n.showPoint[r.getId()]){let i=t.dataArea.selectAll("dot").data(Array.from(r).filter((function(t){return null!==t.value}))).enter().append("circle").attr("r",n.pointSize[r.getId()]).attr("cx",(function(e){return t.xScale(e.date)})).attr("cy",(function(t){return a(t.value)})).attr("date",(function(t){return ea("%y-%m-%d")(t.date)})).attr("value",(function(t){if(null!==t.value)return Number.isInteger(t.value)?t.value.toFixed(0):t.value.toFixed(2)})).attr("valueType",nl[r.valueType]).attr("class","tracker-dot");n.pointColor[r.getId()]&&(i.style("fill",n.pointColor[r.getId()]),n.pointBorderColor[r.getId()]&&n.pointBorderWidth[r.getId()]>0&&(i.style("stroke",n.pointBorderColor[r.getId()]),i.style("stroke-width",n.pointBorderWidth[r.getId()]))),n.allowInspectData&&function(t,e,n){let r=e.dataArea.append("svg").style("opacity",0),i=r.append("rect").attr("x",0).attr("y",0),a=r.append("text"),o=a.append("tspan").attr("class","tracker-tooltip-label"),l=a.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 i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}(t);let c=0,h=0,d="date: "+ee(this).attr("date"),g=Vl(d,"tracker-tooltip-label");o.text(d),g.width>c&&(c=g.width),h+=g.height,o.attr("x",u).attr("y",h);let p="value: ",y=ee(this).attr("valueType"),m=ee(this).attr("value");if("Time"===y){p+=window.moment("00:00","HH:mm",!0).add(parseFloat(m),"seconds").format("HH:mm"),l.text(p)}else p+=m,l.text(p);let v=Vl(p,"tracker-tooltip-label");v.width>c&&(c=v.width),h+=s+v.height,l.attr("x",u).attr("y",h),c+=2*u,h+=2*s,a.attr("width",c).attr("height",h),i.attr("width",c).attr("height",h).attr("class","tracker-tooltip");let x=e,A=f,w=12,b=12;x=e+w+c>n.dataAreaSize.width?e-c-w:e+w,A=f-b-h<0?f+b:f-b-h,r.attr("x",x).attr("y",A),r.transition().duration(200).style("opacity",1)})).on("mouseleave",(function(){r.transition().duration(500).style("opacity",0)}))}(i,t,e)}}function Au(t,e,n,r,i,a,o){if(!e||!n)return;let l=e.dataAreaSize.width/r.getLength(),u=l;l-1>0&&(u=l-1),u/=o;let s=null;"left"===i?s=t.leftYScale:"right"===i&&(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=a+1-o/2;if(n<1)return t.xScale(e.date)-l/2+a*u+n*u}return t.xScale(e.date)-l/2+a*u})).attr("y",(function(t){return s(Math.max(t.value,0))})).attr("width",(function(t,e){if(0===e){let t=a+1-o/2;return t<0?0:t<1?u*t:u}if(e===r.getLength()-1){let t=1-(a+1-o/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 wu(t,e,n){let r=t.svg;t.graphArea;let i=t.dataArea,a=t.title,o=t.xAxis,l=t.leftYAxis,u=t.rightYAxis,s=0;a&&(s=parseFloat(a.attr("height")));let f=parseFloat(o.attr("height")),c=0;l&&(c=parseFloat(l.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 Vl(t,"tracker-legend-label")})),m=0,v=0;for(let t=0;t<p.length;t++)g.includes(t)||y[t].width>v&&(v=y[t].width,m=t);let x=v/p[m].length,A=y[m].height,w=p.length-g.length,b=2*x,k=A,C=2*x,M=0,T=0;"vertical"===n.legendOrientation?(M=3*b+C+v,T=(w+1)*k):"horizontal"===n.legendOrientation&&(M=(2*b+C)*w+b+D(y,(function(t,e){return g.includes(e)?0:t.width})),T=k+A);let _=0,E=0;if("top"===n.legendPosition)_=c+e.dataAreaSize.width/2-M/2,E=s,Ol(r,0,T+k),Pl(i,0,T+k);else if("bottom"===n.legendPosition)_=c+e.dataAreaSize.width/2-M/2,E=s+e.dataAreaSize.height+f+k,Ol(r,0,T+k);else if("left"===n.legendPosition)_=0,E=s+e.dataAreaSize.height/2-T/2,Ol(r,M+b,0),Pl(i,M+b,0);else{if("right"!==n.legendPosition)return;_=e.dataAreaSize.width+c+h+b,E=s+e.dataAreaSize.height/2-T/2,Ol(r,M+b,0)}let F=t.graphArea.append("g").attr("id","legend").attr("transform","translate("+_+","+E+")"),S=F.append("rect").attr("class","tracker-legend").attr("width",M).attr("height",T);n.legendBgColor&&S.style("fill",n.legendBgColor),n.legendBorderColor&&S.style("stroke",n.legendBorderColor);let B=b,N=A,I=B+b+C,L=N;if("vertical"===n.legendOrientation){n.GetGraphType()===el.Line?(F.selectAll("markers").data(p).enter().append("line").attr("x1",B).attr("x2",B+C).attr("y1",(function(t,e){let n=g.filter((t=>t<e)).length;return N+(e-=n)*k})).attr("y2",(function(t,e){let n=g.filter((t=>t<e)).length;return N+(e-=n)*k})).style("stroke",(function(t,e){if(!g.includes(e))return n.lineColor[e]})),F.selectAll("markers").data(p).enter().append("circle").attr("cx",B+C/2).attr("cy",(function(t,e){let n=g.filter((t=>t<e)).length;return N+(e-=n)*k})).attr("r",(function(t,e){if(!g.includes(e))return n.showPoint[e]?n.pointSize[e]:0})).style("fill",(function(t,e){if(!g.includes(e))return n.pointColor[e]}))):n.GetGraphType()===el.Bar&&F.selectAll("markers").data(p).enter().append("rect").attr("x",B).attr("y",(function(t,e){let n=g.filter((t=>t<e)).length;return N+(e-=n)*k-A/2})).attr("width",C).attr("height",A).style("fill",(function(t,e){if(!g.includes(e))return n.barColor[e]}));let t=F.selectAll("labels").data(p).enter().append("text").attr("x",I).attr("y",(function(t,e){let n=g.filter((t=>t<e)).length;return L+(e-=n)*k})).text((function(t,e){return g.includes(e)?"":t})).style("alignment-baseline","middle").attr("class","tracker-legend-label");n.GetGraphType()===el.Line?t.style("fill",(function(t,e){if(!g.includes(e))return n.lineColor[e]})):n.GetGraphType()===el.Bar&&t.style("fill",(function(t,e){if(!g.includes(e))return n.barColor[e]}))}else if("horizontal"===n.legendOrientation){n.GetGraphType()===el.Line?(F.selectAll("markers").data(p).enter().append("line").attr("x1",(function(t,e){let n=b;for(let[t,r]of y.entries())if(!g.includes(t)){if(!(t<e))break;n+=C+b+r.width+b}return n})).attr("x2",(function(t,e){let n=b+C;for(let[t,r]of y.entries())if(!g.includes(t)){if(!(t<e))break;n+=b+r.width+b+C}return n})).attr("y1",N).attr("y2",N).style("stroke",(function(t,e){if(!g.includes(e))return n.lineColor[e]})),F.selectAll("markers").data(p).enter().append("circle").attr("cx",(function(t,e){let n=b+C/2;for(let[t,r]of y.entries())if(!g.includes(t)){if(!(t<e))break;n+=C/2+b+r.width+b+C/2}return n})).attr("cy",N).attr("r",(function(t,e){if(!g.includes(e))return n.showPoint[e]?n.pointSize[e]:0})).style("fill",(function(t,e){if(!g.includes(e))return n.pointColor[e]}))):n.GetGraphType()===el.Bar&&F.selectAll("markers").data(p.filter(((t,e)=>!g.includes(e)))).enter().append("rect").attr("x",(function(t,e){let n=b;for(let[t,r]of y.entries())if(!g.includes(t)){if(!(t<e))break;n+=C+b+r.width+b}return n})).attr("y",N-A/2).attr("width",C).attr("height",A).style("fill",(function(t,e){if(!g.includes(e))return n.barColor[e]}));let t=F.selectAll("labels").data(p).enter().append("text").attr("x",(function(t,e){let n=b+C+b;for(let[t,r]of y.entries())if(!g.includes(t)){if(!(t<e))break;n+=r.width+b+C+b}return n})).attr("y",L).text((function(t,e){return g.includes(e)?"":t})).style("alignment-baseline","middle").attr("class","tracker-legend-label");n.GetGraphType()===el.Line?t.style("fill",(function(t,e){if(!g.includes(e))return n.lineColor[e]})):n.GetGraphType()===el.Bar&&t.style("fill",(function(t,e){if(!g.includes(e))return n.barColor[e]}))}}function bu(t,e,n){if(!e||!n)return;if(!n.title)return;let r=Vl(n.title,"tracker-title"),i=t.graphArea.append("text").text(n.title).attr("id","title").attr("transform","translate("+e.dataAreaSize.width/2+","+r.height/2+")").attr("height",r.height).attr("class","tracker-title");t.title=i,Ol(t.svg,0,r.height),Ol(t.graphArea,0,r.height),Pl(t.dataArea,0,r.height)}function Du(t,e,n){let r=ee(t),i=e.svg,a=parseFloat(i.attr("width")),o=parseFloat(i.attr("height"));i.attr("width",null).attr("height",null).attr("viewBox",`0 0 ${a} ${o}`).attr("preserveAspectRatio","xMidYMid meet"),n.fitPanelWidth?r.style("width","100%"):(r.style("width",(a*n.fixedScale).toString()+"px"),r.style("height",(o*n.fixedScale).toString()+"px"))}function ku(t,e){let n={},r=ee(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);n.svg=r;let i=r.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);n.graphArea=i;let a=i.append("g").attr("id","dataArea").attr("width",e.dataAreaSize.width).attr("height",e.dataAreaSize.height);return n.dataArea=a,n}function Cu(t,e,n){if(!e||!n)return;let r=ku(t,e);bu(r,e,n),yu(r,e,n);let i=[],a=[],o=e.datasets.getXDatasetIds();for(let t=0;t<n.yAxisLocation.length;t++){if(o.includes(t))continue;let e=n.yAxisLocation[t];"left"===e.toLowerCase()?i.push(t):"right"===e.toLocaleLowerCase()&&a.push(t)}let l=mu(r,e,n,"left",i);if("string"==typeof l)return l;if(r.leftYAxis&&r.leftYScale)for(let t of i){let i=e.datasets.getDatasetById(t);i.getQuery().usedAsXDataset||(vu(r,e,n,i,"left"),xu(r,e,n,i,"left"))}let u=mu(r,e,n,"right",a);if("string"==typeof u)return u;if(r.rightYAxis&&r.rightYScale)for(let t of a){let i=e.datasets.getDatasetById(t);i.getQuery().usedAsXDataset||(vu(r,e,n,i,"right"),xu(r,e,n,i,"right"))}n.showLegend&&wu(r,e,n),Du(t,r,e)}function Mu(t,e,n){if(!e||!n)return;let r=ku(t,e);bu(r,e,n),yu(r,e,n);let i=[],a=[],o=e.datasets.getXDatasetIds();for(let t=0;t<n.yAxisLocation.length;t++){if(o.includes(t))continue;let e=n.yAxisLocation[t];"left"===e.toLowerCase()?i.push(t):"right"===e.toLocaleLowerCase()&&a.push(t)}let l=mu(r,e,n,"left",i);if("string"==typeof l)return l;let u=i.length+a.length,s=0;if(r.leftYAxis&&r.leftYScale)for(let t of i){let i=e.datasets.getDatasetById(t);i.getQuery().usedAsXDataset||(Au(r,e,n,i,"left",s,u),s++)}let f=mu(r,e,n,"right",a);if("string"==typeof f)return f;if(r.rightYAxis&&r.rightYScale)for(let t of a){let i=e.datasets.getDatasetById(t);i.getQuery().usedAsXDataset||(Au(r,e,n,i,"right",s,u),s++)}n.showLegend&&wu(r,e,n),Du(t,r,e)}function Tu(t){switch(t=t.trim().toLowerCase()){case"true":case"1":case"on":case"yes":return!0;case"false":case"0":case"off":case"no":return!1}return null}function _u(t){return"tag"===t.toLowerCase()||"text"===t.toLowerCase()||"frontmatter"===t.toLowerCase()||"wiki"===t.toLowerCase()||"wiki.link"===t.toLowerCase()||"wiki.display"===t.toLowerCase()||"dvfield"===t.toLowerCase()||"table"===t.toLowerCase()||"filemeta"===t.toLowerCase()||"task"===t.toLowerCase()||"task.all"===t.toLowerCase()||"task.done"===t.toLowerCase()||"task.notdone"===t.toLowerCase()}function Eu(t){return"left"===t||"right"===t||"none"===t}function Fu(t){return!0}function Su(t){const e="::::::tracker::::::";let n=t.split("\\,").join(e).split(",");for(let t=0;t<n.length;t++)n[t]=n[t].split(e).join(",");return n}function Bu(t,e,n,r,i){let a=[],o="",l=0;for(;n>a.length;)a.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;n<a.length;n++)if(n<e.length){let i=e[n],u=null;if(n>0&&(u=e[n-1].trim()),"string"==typeof i){if(i=i.trim(),""!==i){o="Invalid inputs for "+t;break}a[n]=null!==u?u:r}else{if("boolean"!=typeof i){o="Invalid inputs for "+t;break}a[n]=i,l++}}else{let t=e[e.length-1];a[n]=l>0?t:r}}}else if("string"==typeof e){let i=Su(e);if(i.length>1){if(i.length>n)return o="Too many inputs for parameter '"+t+"'",o;for(let e=0;e<a.length;e++)if(e<i.length){let n=i[e].trim(),u=null;if(e>0&&(u=Tu(i[e-1].trim())),""===n)a[e]=null!==u?u:r;else{let r=Tu(n);if(null===r){o="Invalid inputs for "+t;break}a[e]=r,l++}}else{let t=Tu(i[i.length-1].trim());a[e]=l>0&&null!==t?t:r}}else if(""===e);else{let n=Tu(e);if(null!==n){a[0]=n,l++;for(let t=1;t<a.length;t++)a[t]=n}else o="Invalid inputs for "+t}}else if("boolean"==typeof e){a[0]=e,l++;for(let t=1;t<a.length;t++)a[t]=e}else o="Invalid inputs for "+t;return i||0!==l||(o="No valid input for "+t),""!==o?o:a}function Nu(t,e,n,r,i){let a=[],o="",l=0;for(;n>a.length;)a.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;n<a.length;n++)if(n<e.length){let i=e[n],u=null;if(n>0&&(u=e[n-1].trim()),"string"==typeof i){if(i=i.trim(),""!==i){o="Invalid inputs for "+t;break}a[n]=null!==u?u:r}else{if("number"!=typeof i){o="Invalid inputs for "+t;break}a[n]=i,l++}}else{let t=e[e.length-1];a[n]=l>0?t:r}}}else if("string"==typeof e){let i=Su(e);if(i.length>1){if(i.length>n)return o="Too many inputs for parameter '"+t+"'",o;for(let n=0;n<a.length;n++)if(n<i.length){let e=i[n].trim(),u=null;if(n>0&&(u=Ll(i[n-1].trim()).value),""===e)null!==u&&Number.isNumber(u)?a[n]=u:a[n]=r;else{let r=Ll(e).value;if(null===r){o="Invalid inputs for "+t;break}a[n]=r,l++}}else{let t=Ll(i[e.length-1].trim()).value;a[n]=l>0&&null!==t?t:r}}else if(""===e);else{let n=Ll(e).value;if(null!==n){a[0]=n,l++;for(let t=1;t<a.length;t++)a[t]=n}else o="Invalid inputs for "+t}}else if("number"==typeof e)if(Number.isNumber(e)){a[0]=e,l++;for(let t=1;t<a.length;t++)a[t]=e}else o="Invalid inputs for "+t;else o="Invalid inputs for "+t;return i||0!==l||(o="No valid input for "+t),""!==o?o:a}function Iu(t,e){return"string"==typeof t?Il(t):"number"==typeof t?t.toString():e}function Lu(t,e,n,r,i,a){let o=[],l="",u=0;for(;n>o.length;)o.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;n<o.length;n++)if(n<e.length){let a=e[n],s=null;if(n>0&&(s=e[n-1].trim()),"string"!=typeof a){l="Invalid inputs for "+t;break}if(a=a.trim(),""===a)o[n]=null!==s?s:r;else if(i){if(!i(a)){l="Invalid inputs for "+t;break}o[n]=a,u++}else o[n]=a,u++}else{let t=e[e.length-1].trim();o[n]=u>0?t:r}}}else if("string"==typeof e){let a=Su(e);if(a.length>1){if(a.length>n)return l="Too many inputs for parameter '"+t+"'",l;for(let e=0;e<o.length;e++)if(e<a.length){let n=a[e].trim(),s=null;if(e>0&&(s=a[e-1].trim()),""===n)o[e]=null!==s?s:r;else if(i){if(!i(n)){l="Invalid inputs for "+t;break}o[e]=n,u++}else o[e]=n,u++}else{let t=a[a.length-1].trim();o[e]=u>0?t:r}}else if(""===e);else if(i)if(i(e)){o[0]=e,u++;for(let t=1;t<o.length;t++)o[t]=e}else l="Invalid inputs for "+t;else{o[0]=e,u++;for(let t=1;t<o.length;t++)o[t]=e}}else if("number"==typeof e){let n=e.toString();if(i)if(i(n)){o[0]=n,u++;for(let t=1;t<o.length;t++)o[t]=n}else l="Invalid inputs for "+t;else{o[0]=n,u++;for(let t=1;t<o.length;t++)o[t]=n}}else l="Invalid inputs for "+t;if(a||0!==u||(l="No valid input for "+t),""!==l)return l;for(let t=0;t<o.length;t++)o[t]=Il(o[t]);return o}function Vu(t,e){let n=[];if(null==e)return n;if("object"==typeof e){if(Array.isArray(e))for(let r of e)if("string"==typeof r){let e=parseFloat(r);if(!Number.isNumber(e)){return`Parameter '${t}' accepts only numbers`}n.push(e)}}else if("string"==typeof e){let r=Su(e);if(r.length>1)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 Ou(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=Su(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;t<n.length;t++)n[t]=Il(n[t]);return n}function Pu(t,e){t&&(e.title=Iu(null==t?void 0:t.title,e.title),e.xAxisLabel=Iu(null==t?void 0:t.xAxisLabel,e.xAxisLabel),e.xAxisColor=Iu(null==t?void 0:t.xAxisColor,e.xAxisColor),e.xAxisLabelColor=Iu(null==t?void 0:t.xAxisLabelColor,e.xAxisLabelColor),"boolean"==typeof t.allowInspectData&&(e.allowInspectData=t.allowInspectData),"boolean"==typeof t.showLegend&&(e.showLegend=t.showLegend),"string"==typeof t.legendPosition?e.legendPosition=t.legendPosition:e.legendPosition="bottom","string"==typeof t.legendOrientation?e.legendOrientation=t.legendOrientation:"top"===e.legendPosition||"bottom"===e.legendPosition?e.legendOrientation="horizontal":"left"===e.legendPosition||"right"===e.legendPosition?e.legendOrientation="vertical":e.legendOrientation="horizontal",e.legendBgColor=Iu(null==t?void 0:t.legendBgColor,e.legendBgColor),e.legendBorderColor=Iu(null==t?void 0:t.legendBorderColor,e.legendBorderColor));let n=Lu("yAxisLabel",null==t?void 0:t.yAxisLabel,2,"Value",null,!0);if("string"==typeof n)return n;if(n.length>2)return"yAxisLabel accepts not more than two values for left and right y-axes";e.yAxisLabel=n;let r=Lu("yAxisColor",null==t?void 0:t.yAxisColor,2,"",Fu,!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 i=Lu("yAxisLabelColor",null==t?void 0:t.yAxisLabelColor,2,"",Fu,!0);if("string"==typeof i)return i;if(i.length>2)return"yAxisLabelColor accepts not more than two values for left and right y-axes";e.yAxisLabelColor=i;let a=Lu("yAxisUnit",null==t?void 0:t.yAxisUnit,2,"",null,!0);if("string"==typeof a)return a;if(a.length>2)return"yAxisUnit accepts not more than two values for left and right y-axes";e.yAxisUnit=a,e.xAxisTickInterval=Iu(null==t?void 0:t.xAxisTickInterval,e.xAxisTickInterval);let o=Lu("yAxisTickInterval",null==t?void 0:t.yAxisTickInterval,2,null,null,!0);if("string"==typeof o)return o;if(o.length>2)return"yAxisTickInterval accepts not more than two values for left and right y-axes";e.yAxisTickInterval=o,e.xAxisTickLabelFormat=Iu(null==t?void 0:t.xAxisTickLabelFormat,e.xAxisTickLabelFormat);let l=Lu("yAxisTickLabelFormat",null==t?void 0:t.yAxisTickLabelFormat,2,null,null,!0);if("string"==typeof l)return l;if(l.length>2)return"yAxisTickLabelFormat accepts not more than two values for left and right y-axes";e.yAxisTickLabelFormat=l;let u=Nu("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=Nu("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=Bu("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 $u(t){let e=[];if(null!==t){const n=Object.keys(t);for(let t of n)e.push(t.toString())}return e}function Yu(t,e){return Cl(kl(t.basename,e.dateFormatPrefix,e.dateFormatSuffix),e.dateFormat)}function zu(t,e,n){let r=window.moment(""),i=t.frontmatter;if(i&&Bl(i,e.getTarget())){let t=Bl(i,e.getTarget());"string"==typeof t&&(t=kl(t,n.dateFormatPrefix,n.dateFormatSuffix),r=Cl(t,n.dateFormat))}return r}function Ru(t,e,n){let r,i=window.moment(""),a=new RegExp(e,"gm");for(;r=a.exec(t);)if(void 0!==r.groups&&void 0!==r.groups.value){let t=r.groups.value.trim();if(t=kl(t,n.dateFormatPrefix,n.dateFormatSuffix),i=Cl(t,n.dateFormat),i.isValid())return i}return i}function Uu(t,e,n){window.moment("");let r=e.getTarget();return e.getParentTarget()&&(r=e.getParentTarget()),Ru(t,"(^|\\s)#"+r+"(\\/[\\w-]+)*(:(?<value>[\\d\\.\\/-]*)[a-zA-Z]*)?([\\.!,\\?;~-]*)?(\\s|$)",n)}function Hu(t,e,n){return window.moment(""),Ru(t,e.getTarget(),n)}function Xu(t,e,n){window.moment("");let r=e.getTarget();return e.getParentTarget()&&(r=e.getParentTarget()),r=r.replace("-","[\\s\\-]"),Ru(t,"(^| |\\t)\\*{0,2}"+r+"\\*{0,2}(::[ |\\t]*(?<value>[\\d\\.\\/\\-\\w,@; \\t:]*))(\\r\\?\\n|\\r|$)",n)}function Wu(e,n,r){let i=window.moment("");if(e&&e instanceof t.TFile){let t=n.getTarget();if("cDate"===t){i=Fl(e.stat.ctime,r.dateFormat)}else if("mDate"===t){i=Fl(e.stat.mtime,r.dateFormat)}else"name"===t&&(i=Yu(e,r))}return i}function ju(t,e,n){window.moment("");let r=e.getType(),i=e.getTarget();return i=r===tl.Task?"\\[[\\sx]\\]\\s"+i:r===tl.TaskDone?"\\[x\\]\\s"+i:r===tl.TaskNotDone?"\\[\\s\\]\\s"+i:"\\[[\\sx]\\]\\s"+i,Ru(t,i,n)}function qu(t,e,n,r){if(t.has(e)){t.get(e).push({query:n,value:r})}else{let i=new Array;i.push({query:n,value:r}),t.set(e,i)}}function Gu(t,e,n,r,i,a){let o,l=new RegExp(e,"gmu"),u=0,s=!1;for(;o=l.exec(t);)if(a.ignoreAttachedValue[n.getId()])u+=a.constValue[n.getId()],s=!0,n.addNumTargets();else if(void 0!==o.groups&&void 0!==o.groups.value){let t=o.groups.value.trim().split(n.getSeparator());if(!t)continue;if(1===t.length){let e=Ll(t[0].trim(),a.textValueMap);null!==e.value&&(e.type===nl.Time?(u=e.value,s=!0,n.valueType=nl.Time,n.addNumTargets()):a.ignoreZeroValue[n.getId()]&&0===e.value||(u+=e.value,s=!0,n.addNumTargets()))}else if(t.length>n.getAccessor()&&n.getAccessor()>=0){let e=Ll(t[n.getAccessor()].trim(),a.textValueMap);null!==e.value&&(e.type===nl.Time?(u=e.value,s=!0,n.valueType=nl.Time,n.addNumTargets()):(u+=e.value,s=!0,n.addNumTargets()))}}else u+=a.constValue[n.getId()],s=!0,n.addNumTargets();if(s){return qu(r,i.get(a.xDataset[n.getId()]),n,u),!0}return!1}function Qu(e,n,r,i,a,o){if(e&&e instanceof t.TFile){let t=r.getTarget(),l=o.get(i.xDataset[r.getId()]);if("cDate"===t){let t=e.stat.ctime;return r.valueType=nl.Date,r.addNumTargets(),qu(a,l,r,t),!0}if("mDate"===t){let t=e.stat.mtime;return r.valueType=nl.Date,r.addNumTargets(),qu(a,l,r,t),!0}if("size"===t){let t=e.stat.size;return r.addNumTargets(),qu(a,l,r,t),!0}if("numWords"===t){return qu(a,l,r,function(t){t=$l(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(),qu(a,l,r,t),!0}if("numSentences"===t){let t=function(t){return(((t=$l(t))||"").match(/[^.。!!??\s][^.。!!??]*(?:[.!?](?!['‘’"“”「」『』]?\s|$)[^.。!!??]*)*[.。!!??]?['’"”」』]?(?=\s||$)/gm)||[]).length}(n);return r.addNumTargets(),qu(a,l,r,t),!0}if("name"===t){let t=0,n=!1,o=Ll(e.basename,i.textValueMap);null!==o.value&&(o.type===nl.Time?(t=o.value,n=!0,r.valueType=nl.Time,r.addNumTargets()):i.ignoreZeroValue[r.getId()]&&0===o.value||(t+=o.value,n=!0,r.addNumTargets()));let u=null;if(n&&(u=t),null!==u)return qu(a,l,r,u),!0}}return!1}const Zu={folder:"/",dateFormat:"YYYY-MM-DD"};class Ku 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 Ju extends t.Plugin{onload(){return e(this,void 0,void 0,(function*(){console.log("loading obsidian-tracker plugin"),yield this.loadSettings(),this.addSettingTab(new Ku(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(el.Line)}),this.addCommand({id:"add-bar-chart-tracker",name:"Add Bar Chart Tracker",callback:()=>this.addCodeBlock(el.Bar)}),this.addCommand({id:"add-summary-tracker",name:"Add Summary Tracker",callback:()=>this.addCodeBlock(el.Summary)})}))}loadSettings(){return e(this,void 0,void 0,(function*(){this.settings=Object.assign({},Zu,yield this.loadData())}))}saveSettings(){return e(this,void 0,void 0,(function*(){yield this.saveData(this.settings)}))}renderErrorMessage(t,e,n){!function(t,e){ee(t).select("#svg").remove(),ee(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 i of e.children)i instanceof t.TFile?"md"===i.extension&&r.push(i):i instanceof t.TFolder&&n&&(r=r.concat(this.getFilesInFolder(i)));return r}getFiles(n,r){return e(this,arguments,void 0,(function*(e,n,r=!0){if(!e)return;let i=n.folder,a=n.specifiedFilesOnly,o=n.file,l=n.fileContainsLinkedFiles,u=n.fileMultiplierAfterLink;if(!a){let n=this.app.vault.getAbstractFileByPath(t.normalizePath(i));if(n&&n instanceof t.TFolder){let t=this.getFilesInFolder(n);for(let n of t)e.push(n)}}for(let n of o){let r=n;r.endsWith(".md")||(r+=".md"),r=t.normalizePath(r);let i=this.app.vault.getAbstractFileByPath(r);i&&i instanceof t.TFile&&e.push(i)}let s=1,f=!0;""===u?f=!1:/^[0-9]+$/.test(u)?(s=parseFloat(u),f=!1):/\?<value>/.test(u)||(f=!1);for(let r of l){r.endsWith(".md")||(r+=".md");let i=this.app.vault.getAbstractFileByPath(t.normalizePath(r));if(i&&i instanceof t.TFile){let a=this.app.metadataCache.getFileCache(i),o=(yield this.app.vault.adapter.read(i.path)).split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/);if(!(null==a?void 0:a.links))continue;for(let i of a.links){if(!i)continue;let a=this.app.metadataCache.getFirstLinkpathDest(i.link,r);if(a&&a instanceof t.TFile){if(f){let t=i.position.end.line;if(t>=0&&t<o.length){let e=o[t].split(i.original);if(2===e.length){let t,r=e[1].trim(),i=new RegExp(u,"gm");for(;t=i.exec(r);)if(void 0!==t.groups&&void 0!==t.groups.value){let e=Ll(t.groups.value.trim(),n.textValueMap);if(null!==e.value){s=e.value;break}}}}}for(let t=0;t<s;t++)e.push(a)}}}}}))}postprocessor(n,r,i){return e(this,void 0,void 0,(function*(){const i=document.createElement("div");let a=n.trim(),o=this.app.vault.getConfig("tabSize"),l=Array(o).fill(" ").join("");a=a.replace(/\t/gm,l);let u=function(e,n){let r;try{r=t.parseYaml(e)}catch(t){let e="Error parsing YAML";return console.log(t),e}if(!r)return"Error parsing YAML";let i=$u(r),a="";if(!i.includes("searchTarget"))return"Parameter 'searchTarget' not found in YAML";let o=[];if("object"==typeof r.searchTarget&&null!==r.searchTarget){if(Array.isArray(r.searchTarget))for(let t of r.searchTarget)if("string"==typeof t){if(""===t){a="Empty search target is not allowed.";break}o.push(t)}}else if("string"==typeof r.searchTarget){let t=Su(r.searchTarget);if(t.length>1)for(let e of t){if(e=e.trim(),""===e){a="Empty search target is not allowed.";break}o.push(e)}else""===r.searchTarget?a="Empty search target is not allowed.":o.push(r.searchTarget)}else a="Invalid search target (searchTarget)";for(let t=0;t<o.length;t++)o[t]=Il(o[t]);if(""!==a)return a;let l=o.length;if(!i.includes("searchType"))return"Parameter 'searchType' not found in YAML";let u=[],s=Lu("searchType",r.searchType,l,"",_u,!1);if("string"==typeof s)return s;for(let t of s)switch(t.toLowerCase()){case"tag":u.push(tl.Tag);break;case"frontmatter":u.push(tl.Frontmatter);break;case"wiki":u.push(tl.Wiki);break;case"wiki.link":u.push(tl.WikiLink);break;case"wiki.display":u.push(tl.WikiDisplay);break;case"text":u.push(tl.Text);break;case"dvfield":u.push(tl.dvField);break;case"table":u.push(tl.Table);break;case"filemeta":u.push(tl.FileMeta);break;case"task":case"task.all":u.push(tl.Task);break;case"task.done":u.push(tl.TaskDone);break;case"task.notdone":u.push(tl.TaskNotDone)}if(u.includes(tl.Table)&&u.filter((t=>t!==tl.Table)).length>0)return"searchType 'table' doestn't work with other types for now";let f=[],c=Lu("separator",r.separator,l,"",null,!0);if("string"==typeof c)return c;f=c.map((t=>"comma"===t||"\\,"===t?",":t));let h=Nu("xDataset",r.xDataset,l,-1,!0);if("string"==typeof h)return h;let d=h.map((t=>t<0||t>=l?-1:t)),g=[];for(let t=0;t<o.length;t++){let e=new il(g.length,u[t],o[t]);e.setSeparator(f[t]),d.includes(t)&&(e.usedAsXDataset=!0),g.push(e)}let p=new ll(g),y=$u(p),m=["searchType","searchTarget","separator"],v=[],x=[],A=[],w=[],b=[],D=[],k=[];for(let t of i)/^line[0-9]*$/.test(t)&&(v.push(t),m.push(t)),/^bar[0-9]*$/.test(t)&&(x.push(t),m.push(t)),/^pie[0-9]*$/.test(t)&&(A.push(t),m.push(t)),/^summary[0-9]*$/.test(t)&&(w.push(t),m.push(t)),/^bullet[0-9]*$/.test(t)&&(k.push(t),m.push(t)),/^month[0-9]*$/.test(t)&&(b.push(t),m.push(t)),/^heatmap[0-9]*$/.test(t)&&(D.push(t),m.push(t));let C=[];for(let t of i)if(/^dataset[0-9]*$/.test(t)){let e=-1,n=t.replace("dataset","");if(e=""===n?0:parseFloat(n),g.some((t=>t.getId()===e)))return a="Duplicated dataset id for key '"+t+"'",a;C.push(t),m.push(t)}for(let t of i)if(!y.includes(t)&&!m.includes(t))return a="'"+t+"' is not an available key",a;if(0===v.length+x.length+A.length+w.length+k.length+b.length+D.length)return"No output parameter provided, please place line, bar, pie, month, bullet, or summary.";p.folder=Iu(null==r?void 0:r.folder,n.settings.folder),""===p.folder.trim()&&(p.folder=n.settings.folder);let M=n.app.vault.getAbstractFileByPath(t.normalizePath(p.folder));if(!(M&&M instanceof t.TFolder))return"Folder '"+p.folder+"' doesn't exist";if("string"==typeof r.file){let t=Ou("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=Ou("fileContainsLinkedFiles",r.fileContainsLinkedFiles);if("string"==typeof t)return t;p.fileContainsLinkedFiles=t}p.fileMultiplierAfterLink=Iu(null==r?void 0:r.fileMultiplierAfterLink,p.fileMultiplierAfterLink);const T=r.dateFormat;if("string"==typeof r.dateFormat?""===r.dateFormat?p.dateFormat=n.settings.dateFormat:p.dateFormat=T:p.dateFormat=n.settings.dateFormat,p.dateFormatPrefix=Iu(null==r?void 0:r.dateFormatPrefix,p.dateFormatPrefix),p.dateFormatSuffix=Iu(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=kl(r.startDate,p.dateFormatPrefix,p.dateFormatSuffix),e=null,n=!1;if(e=_l(t,p.dateFormat),e?n=!0:(e=Cl(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=kl(r.endDate,p.dateFormatPrefix,p.dateFormatSuffix),e=null,n=!1;if(e=_l(t,p.dateFormat),e?n=!0:(e=Cl(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.endDate<p.startDate)return"Invalid date range (startDate larger than endDate)";p.xDataset=d;let _=Lu("datasetName",r.datasetName,l,"untitled",null,!0);if("string"==typeof _)return _;let E=0;for(let t=0;t<_.length;t++)p.xDataset.includes(t)||"untitled"===_[t]&&(_[t]="untitled"+E.toString(),E++);if(new Set(_).size!==_.length)return"Not enough dataset names or duplicated names";p.datasetName=_;let F=Nu("constValue",r.constValue,l,1,!0);if("string"==typeof F)return F;p.constValue=F;let S=Bu("ignoreAttachedValue",r.ignoreAttachedValue,l,!1,!0);if("string"==typeof S)return S;p.ignoreAttachedValue=S;let B=Bu("ignoreZeroValue",r.ignoreZeroValue,l,!1,!0);if("string"==typeof B)return B;p.ignoreZeroValue=B;let N=Bu("accum",r.accum,l,!1,!0);if("string"==typeof N)return N;p.accum=N;let I=Nu("penalty",r.penalty,l,null,!0);if("string"==typeof I)return I;p.penalty=I;let L=Nu("valueShift",r.valueShift,l,0,!0);if("string"==typeof L)return L;p.valueShift=L;let V=Nu("shiftOnlyValueLargerThan",r.shiftOnlyValueLargerThan,l,null,!0);if("string"==typeof V)return V;if(p.shiftOnlyValueLargerThan=V,void 0!==r.textValueMap){let t=$u(r.textValueMap);for(let e of t){let t=e.trim();p.textValueMap[t]=r.textValueMap[t]}}if("number"==typeof r.fixedScale&&(p.fixedScale=r.fixedScale),"boolean"==typeof r.fitPanelWidth&&(p.fitPanelWidth=r.fitPanelWidth),"string"==typeof r.aspectRatio){let t=/([0-9]*):([0-9]*)/,e=r.aspectRatio.match(t);e.shift(),e=e.map((t=>parseInt(t,10))),2==e.length&&(p.aspectRatio=new vl(e[0],e[1]),p.dataAreaSize=p.aspectRatio.recalculateSize(p.dataAreaSize))}let O=Nu("margin",r.margin,4,10,!0);if("string"==typeof O)return O;if(O.length>4)return"margin accepts not more than four values for top, right, bottom, and left margins.";p.margin=new xl(O[0],O[1],O[2],O[3]);for(let t of C){let e=new ul,n=r[t],i=$u(e),o=$u(n);for(let t of o)if(!i.includes(t))return a="'"+t+"' is not an available key",a;let l=-1,u=t.replace("dataset","");l=""===u?0:parseFloat(u),e.id=l,e.name=Iu(null==n?void 0:n.name,e.name);let s=Ou("xData",null==n?void 0:n.xData);if("string"==typeof s)return s;e.xData=s;let f=e.xData.length,c=Ou("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 fl,n=r[t],i=$u(e),o=$u(n);for(let t of o)if(!i.includes(t))return a="'"+t+"' is not an available key",a;let u=Pu(n,e);if("string"==typeof u)return u;let s=Lu("lineColor",null==n?void 0:n.lineColor,l,"",Fu,!0);if("string"==typeof s)return s;e.lineColor=s;let f=Nu("lineWidth",null==n?void 0:n.lineWidth,l,1.5,!0);if("string"==typeof f)return f;e.lineWidth=f;let c=Bu("showLine",null==n?void 0:n.showLine,l,!0,!0);if("string"==typeof c)return c;e.showLine=c;let h=Bu("showPoint",null==n?void 0:n.showPoint,l,!0,!0);if("string"==typeof h)return h;e.showPoint=h;let d=Lu("pointColor",null==n?void 0:n.pointColor,l,"#69b3a2",Fu,!0);if("string"==typeof d)return d;e.pointColor=d;let g=Lu("pointBorderColor",null==n?void 0:n.pointBorderColor,l,"#69b3a2",Fu,!0);if("string"==typeof g)return g;e.pointBorderColor=g;let y=Nu("pointBorderWidth",null==n?void 0:n.pointBorderWidth,l,0,!0);if("string"==typeof y)return y;e.pointBorderWidth=y;let m=Nu("pointSize",null==n?void 0:n.pointSize,l,3,!0);if("string"==typeof m)return m;e.pointSize=m;let v=Bu("fillGap",null==n?void 0:n.fillGap,l,!1,!0);if("string"==typeof v)return v;e.fillGap=v;let x=Lu("yAxisLocation",null==n?void 0:n.yAxisLocation,l,"left",Eu,!0);if("string"==typeof x)return x;e.yAxisLocation=x,p.line.push(e)}for(let t of x){let e=new cl,n=r[t],i=$u(e),o=$u(n);for(let t of o)if(!i.includes(t))return a="'"+t+"' is not an available key",a;let u=Pu(n,e);if("string"==typeof u)return u;let s=Lu("barColor",null==n?void 0:n.barColor,l,"",Fu,!0);if("string"==typeof s)return s;e.barColor=s;let f=Lu("yAxisLocation",null==n?void 0:n.yAxisLocation,l,"left",Eu,!0);if("string"==typeof f)return f;e.yAxisLocation=f,p.bar.push(e)}for(let t of A){let e=new hl,n=r[t],i=$u(e),o=$u(n);for(let t of o)if(!i.includes(t))return a="'"+t+"' is not an available key",a;e.title=Iu(null==n?void 0:n.title,e.title);let l=Ou("data",null==n?void 0:n.data);if("string"==typeof l)return l;e.data=l;let u=e.data.length,s=Lu("dataColor",null==n?void 0:n.dataColor,u,null,Fu,!0);if("string"==typeof s)return s;e.dataColor=s;let f=Lu("dataName",null==n?void 0:n.dataName,u,"",null,!0);if("string"==typeof f)return f;e.dataName=f;let c=Lu("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=Lu("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=Iu(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=Iu(null==n?void 0:n.legendOrientation,d),e.legendBgColor=Iu(null==n?void 0:n.legendBgColor,e.legendBgColor),e.legendBorderColor=Iu(null==n?void 0:n.legendBorderColor,e.legendBorderColor),p.pie.push(e)}for(let t of w){let e=new dl,n=r[t],i=$u(e),o=$u(n);for(let t of o)if(!i.includes(t))return a="'"+t+"' is not an available key",a;e.template=Iu(null==n?void 0:n.template,e.template),e.style=Iu(null==n?void 0:n.style,e.style),p.summary.push(e)}for(let t of b){let e=new gl,n=r[t],i=$u(e),o=$u(n);for(let t of o)if(!i.includes(t))return a="'"+t+"' is not an available key",a;e.mode=Iu(null==n?void 0:n.mode,e.mode);let l=Vu("dataset",null==n?void 0:n.dataset);if("string"==typeof l)return l;if(0===l.length)for(let t of g)l.push(t.getId());e.dataset=l;let u=e.dataset.length;e.startWeekOn=Iu(null==n?void 0:n.startWeekOn,e.startWeekOn),"boolean"==typeof(null==n?void 0:n.showCircle)&&(e.showCircle=n.showCircle);let s=Vu("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;t<u;t++)e.threshold.push(0);if(e.threshold.length!==e.dataset.length)return"The number of inputs of threshold and dataset not matched";let f=Vu("yMin",null==n?void 0:n.yMin);if("string"==typeof f)return f;if(e.yMin=f,0===e.yMin.length)for(let t=0;t<u;t++)e.yMin.push(null);if(e.yMin.length!==e.dataset.length)return"The number of inputs of yMin and dataset not matched";let c=Vu("yMax",null==n?void 0:n.yMax);if("string"==typeof c)return c;if(e.yMax=c,0===e.yMax.length)for(let t=0;t<u;t++)e.yMax.push(null);if(e.yMax.length!==e.dataset.length)return"The number of inputs of yMin and dataset not matched";e.color=Iu(null==n?void 0:n.color,e.color),"boolean"==typeof(null==n?void 0:n.dimNotInMonth)&&(e.dimNotInMonth=n.dimNotInMonth),"boolean"==typeof(null==n?void 0:n.showStreak)&&(e.showStreak=n.showStreak),"boolean"==typeof(null==n?void 0:n.showTodayRing)&&(e.showTodayRing=n.showTodayRing),"boolean"==typeof(null==n?void 0:n.showSelectedValue)&&(e.showSelectedValue=n.showSelectedValue),"boolean"==typeof(null==n?void 0:n.showSelectedRing)&&(e.showSelectedRing=n.showSelectedRing),e.circleColor=Iu(null==n?void 0:n.circleColor,e.circleColor),"boolean"==typeof(null==n?void 0:n.circleColorByValue)&&(e.circleColorByValue=n.circleColorByValue),e.headerYearColor=Iu(null==n?void 0:n.headerYearColor,e.headerYearColor),e.headerMonthColor=Iu(null==n?void 0:n.headerMonthColor,e.headerMonthColor),e.dividingLineColor=Iu(null==n?void 0:n.dividingLineColor,e.dividingLineColor),e.todayRingColor=Iu(null==n?void 0:n.todayRingColor,e.todayRingColor),e.selectedRingColor=Iu(null==n?void 0:n.selectedRingColor,e.selectedRingColor),e.initMonth=Iu(null==n?void 0:n.initMonth,e.initMonth),"boolean"==typeof(null==n?void 0:n.showAnnotation)&&(e.showAnnotation=n.showAnnotation);let h=Ou("annotation",null==n?void 0:n.annotation);if("string"==typeof h)return h;if(e.annotation=h,0===e.annotation.length)for(let t=0;t<u;t++)e.annotation.push(null);if(e.annotation.length!==e.dataset.length)return"The number of inputs of annotation and dataset not matched";"boolean"==typeof(null==n?void 0:n.showAnnotationOfAllTargets)&&(e.showAnnotationOfAllTargets=n.showAnnotationOfAllTargets),p.month.push(e)}for(let t of D){let e=new pl,n=r[t],i=$u(e),o=$u(n);for(let t of o)if(!i.includes(t))return a="'"+t+"' is not an available key",a;p.heatmap.push(e)}for(let t of k){let e=new yl,n=r[t],i=$u(e),o=$u(n);for(let t of o)if(!i.includes(t))return a="'"+t+"' is not an available key",a;e.title=Iu(null==n?void 0:n.title,e.title),e.dataset=Iu(null==n?void 0:n.dataset,e.dataset),e.orientation=Iu(null==n?void 0:n.orientation,e.orientation);let l=Vu("range",null==n?void 0:n.range);if("string"==typeof l)return l;let u=l;if(1===u.length){if(u[0]<0)return a="Negative range value is not allowed",a}else{if(!(u.length>1))return a="Empty range is not allowed",a;{let t=u[0];if(t<0)return a="Negative range value is not allowed",a;for(let e=1;e<u.length;e++)if(u[e]<=t)return a="Values in parameter 'range' should be monotonically increasing",a}}e.range=u;let s=u.length,f=Lu("rangeColor",null==n?void 0:n.rangeColor,s,"",Fu,!0);if("string"==typeof f)return f;e.rangeColor=f,e.value=Iu(null==n?void 0:n.value,e.value),e.valueUnit=Iu(null==n?void 0:n.valueUnit,e.valueUnit),e.valueColor=Iu(null==n?void 0:n.valueColor,e.valueColor),"boolean"==typeof(null==n?void 0:n.showMarker)&&(e.showMarker=n.showMarker),"number"==typeof(null==n?void 0:n.markerValue)&&(e.markerValue=n.markerValue),e.markerColor=Iu(null==n?void 0:n.markerColor,e.markerColor),p.bullet.push(e)}return p}(a,this);if("string"==typeof u)return this.renderErrorMessage(u,i,r);let s=u,f=[];try{yield this.getFiles(f,s)}catch(t){return this.renderErrorMessage(t.message,i,r)}if(0===f.length)return this.renderErrorMessage("No markdown files found in folder",i,r);let c=new Map,h=new bl;h.fileTotal=f.length;const d=f.map((t=>e(this,void 0,void 0,(function*(){let n=null;s.queries.some((t=>{let e=t.getType();return t.getTarget(),e===tl.Frontmatter||e===tl.Tag||e===tl.Wiki||e===tl.WikiLink||e===tl.WikiDisplay}))&&(n=this.app.metadataCache.getFileCache(t));let r=null;s.queries.some((t=>{let e=t.getType(),n=t.getTarget();return e===tl.Tag||e===tl.Text||e===tl.dvField||e===tl.Task||e===tl.TaskDone||e===tl.TaskNotDone||e===tl.FileMeta&&("numWords"===n||"numChars"===n||"numSentences"===n)}))&&(r=yield this.app.vault.adapter.read(t.path));let i=new Map,a=!1;for(let e of s.xDataset)if(!i.has(e)){let o=window.moment("");if(-1===e)o=Yu(t,s);else{let i=s.queries[e];switch(i.getType()){case tl.Frontmatter:o=zu(n,i,s);break;case tl.Tag:o=Uu(r,i,s);break;case tl.Text:o=Hu(r,i,s);break;case tl.dvField:o=Xu(r,i,s);break;case tl.FileMeta:o=Wu(t,i,s);break;case tl.Task:case tl.TaskDone:case tl.TaskNotDone:o=ju(r,i,s)}}o.isValid()?(null!==s.startDate&&o<s.startDate&&(a=!0,h.fileOutOfDateRange++),null!==s.endDate&&o>s.endDate&&(a=!0,h.fileOutOfDateRange++)):(a=!0,h.fileNotInFormat++),a||(h.gotAnyValidXValue||(h.gotAnyValidXValue=!0),i.set(e,El(o,s.dateFormat)),h.fileAvailable++,1==h.fileAvailable?(h.minDate=o.clone(),h.maxDate=o.clone()):(o<h.minDate&&(h.minDate=o.clone()),o>h.maxDate&&(h.maxDate=o.clone())))}if(a)return;const o=s.queries.filter((t=>t.getType()!==tl.Table&&!t.usedAsXDataset)).map((a=>e(this,void 0,void 0,(function*(){if(n&&a.getType()===tl.Tag){let t=function(t,e,n,r,i){let a=t.frontmatter,o=[];if(a&&a.tags){let t=0,l=!1;if(Array.isArray(a.tags))o=o.concat(a.tags);else if("string"==typeof a.tags){let t=a.tags.split(e.getSeparator(!0));for(let e of t){let t=e.trim();""!==t&&o.push(t)}}for(let a of o){if(a===e.getTarget())t+=n.constValue[e.getId()],l=!0,e.addNumTargets();else{if(!a.startsWith(e.getTarget()+"/"))continue;t+=n.constValue[e.getId()],l=!0,e.addNumTargets()}let o=null;return l&&(o=t),qu(r,i.get(n.xDataset[e.getId()]),e,o),!0}}return!1}(n,a,s,c,i);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}if(n&&a.getType()===tl.Frontmatter&&"tags"!==a.getTarget()){let t=function(t,e,n,r,i){let a=t.frontmatter;if(a){let t=Bl(a,e.getTarget());if(t){let a=Ll(t,n.textValueMap);if(null===a.value&&("true"!==t&&"false"!==t||(a.type=nl.Number,a.value="true"===t?1:0)),null!==a.value)return a.type===nl.Time&&(e.valueType=nl.Time),e.addNumTargets(),qu(r,i.get(n.xDataset[e.getId()]),e,a.value),!0}else if(e.getParentTarget()&&Bl(a,e.getParentTarget())){let t=Bl(a,e.getParentTarget()),o=null;if(Array.isArray(t)?o=t.map((t=>t.toString())):"string"==typeof t&&(o=t.split(e.getSeparator())),o&&o.length>e.getAccessor()&&e.getAccessor()>=0){let t=Ll(o[e.getAccessor()].trim(),n.textValueMap);if(null!==t.value)return t.type===nl.Time&&(e.valueType=nl.Time),e.addNumTargets(),qu(r,i.get(n.xDataset[e.getId()]),e,t.value),!0}}}return!1}(n,a,s,c,i);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}if(n&&(a.getType()===tl.Wiki||a.getType()===tl.WikiLink||a.getType()===tl.WikiDisplay)){let t=function(t,e,n,r,i){let a=t.links;if(!a)return!1;let o=e.getTarget(),l=e.getType(),u="",s=o;for(let t of a){if(!t)continue;let e="";l===tl.Wiki?e=t.displayText?t.displayText:t.link:l===tl.WikiLink?e=t.link:l===tl.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,i,n)}(n,a,s,c,i);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}if(r&&a.getType()===tl.Tag){let t=function(t,e,n,r,i){let a=e.getTarget();return e.getParentTarget()&&(a=e.getParentTarget()),a.length>1&&a.startsWith("#")&&(a=a.substring(1)),Gu(t,"(^|\\s)#"+a+"(\\/[\\w-]+)*(:(?<value>[\\d\\.\\/-]*)[a-zA-Z]*)?([\\.!,\\?;~-]*)?(\\s|$)",e,r,i,n)}(r,a,s,c,i);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}if(r&&a.getType()===tl.Text){let t=function(t,e,n,r,i){return Gu(t,e.getTarget(),e,r,i,n)}(r,a,s,c,i);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}if(a.getType()===tl.FileMeta){let e=Qu(t,r,a,s,c,i);h.gotAnyValidYValue||(h.gotAnyValidYValue=e)}if(r&&a.getType()===tl.dvField){let t=function(t,e,n,r,i){let a=e.getTarget();return e.getParentTarget()&&(a=e.getParentTarget()),a=a.replace("-","[\\s\\-]"),Gu(t,String.raw`(^| |\t|\|)(\[|\()?\*{0,2}`+a+String.raw`\*{0,2}(::[ |\t]*(?<value>[\p{ExtPict}\d\.\/\-\w,@; \t:`+"\\w$€£¥¢₹₨₱₩฿₫₪α-ωΑ-Ω©®℗™℠一-鿿㐀-䶿 、-〿"+String.raw`]*)(\]|\))?)`,e,r,i,n)}(r,a,s,c,i);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}if(r&&(a.getType()===tl.Task||a.getType()===tl.TaskDone||a.getType()===tl.TaskNotDone)){let t=function(t,e,n,r,i){let a=e.getType(),o=e.getTarget();return o=a===tl.Task?"\\[[\\sx]\\]\\s"+o:a===tl.TaskDone?"\\[x\\]\\s"+o:a===tl.TaskNotDone?"\\[\\s\\]\\s"+o:"\\[[\\sx]\\]\\s"+o,Gu(t,o,e,r,i,n)}(r,a,s,c,i);h.gotAnyValidYValue||(h.gotAnyValidYValue=t)}}))));yield Promise.all(o)}))));if(yield Promise.all(d),yield this.collectDataFromTable(c,s,h),h.errorMessage)return this.renderErrorMessage(h.errorMessage,i,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.startDate<h.maxDate?s.endDate=h.maxDate.clone():g="Invalid date range":null!==s.endDate&&null===s.startDate?s.endDate>h.minDate?s.startDate=h.minDate.clone():g="Invalid date range":(s.startDate<h.minDate&&s.endDate<h.minDate||s.startDate>h.maxDate&&s.endDate>h.maxDate)&&(g="Invalid date range"),g)return this.renderErrorMessage(g,i,r);if(!h.gotAnyValidYValue)return this.renderErrorMessage("No valid Y value found in notes",i,r);let p=new ol(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(El(n,s.dateFormat))){let r=c.get(El(n,s.dateFormat)).filter((function(e){return e.query.equalTo(t)}));if(r.length>0){let t=null;for(let e=0;e<r.length;e++){let n=r[e].value;Number.isNumber(n)&&!Number.isNaN(n)&&(null===t?t=n:t+=n)}null!==t&&e.setValue(n,t)}}}s.datasets=p;let y=function(t,e){for(let t of e.datasets){if(t.getQuery().usedAsXDataset)continue;let n=e.valueShift[t.getId()];null!==n&&0!==n&&t.shift(n,e.shiftOnlyValueLargerThan[t.getId()]),null!==e.penalty[t.getId()]&&t.setPenalty(e.penalty[t.getId()]),e.accum[t.getId()]&&t.accumulateValues()}for(let n of e.line){let r=Cu(t,e,n);if("string"==typeof r)return r}for(let n of e.bar){let r=Mu(t,e,n);if("string"==typeof r)return r}for(let n of e.pie){let r=nu(t,e,n);if("string"==typeof r)return r}for(let n of e.summary){let r=ru(t,e,n);if("string"==typeof r)return r}for(let n of e.bullet){let r=pu(t,e,n);if("string"==typeof r)return r}for(let n of e.month){let r=du(t,e,n);if("string"==typeof r)return r}for(let t of e.heatmap){let t=gu(0,e);if("string"==typeof t)return t}}(i,s);if("string"==typeof y)return this.renderErrorMessage(y,i,r);r.appendChild(i)}))}collectDataFromTable(n,r,i){return e(this,void 0,void 0,(function*(){let e=r.queries.filter((t=>t.getType()===tl.Table)),a=[],o=!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)){o=!0;break}let i=n.getAccessor(),l=n.usedAsXDataset,u=a.find((t=>t.filePath===e&&t.tableIndex===i));if(u)l?u.xDataset=n:u.yDatasets.push(n);else{let t=new wl(e,i);l?t.xDataset=n:t.yDatasets.push(n),a.push(t)}}if(o)i.errorMessage="File containing tables not found";else for(let e of a){let a=e.xDataset;if(!a)continue;let o=e.yDatasets,l=a.getParentTarget(),u=a.getAccessor(),s="";l+=".md";let f=this.app.vault.getAbstractFileByPath(t.normalizePath(l));if(!(f&&f instanceof t.TFile))continue;{i.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=Nl(t,"|"),h=t.split("|").length;let e=c.shift().trim();e=Nl(e,"|");let n=e.split("|");for(let t of n)if(!t.includes("-"))break;d=c.length}if(0==d)continue;let g=a.getAccessor(1);if(g>=h)continue;let p=[];for(let t of c){let e=Nl(t.trim(),"|").split("|");if(g<e.length){let t=Cl(e[g].trim(),r.dateFormat);t.isValid()?(p.push(t),i.minDate.isValid()||i.maxDate.isValid()?(t<i.minDate&&(i.minDate=t.clone()),t>i.maxDate&&(i.maxDate=t.clone())):(i.minDate=t.clone(),i.maxDate=t.clone())):p.push(null)}else p.push(null)}if(p.every((t=>null===t)))return void(i.errorMessage="No valid date as X value found in table");i.gotAnyValidXValue||(i.gotAnyValidXValue=!0);for(let t of o){let e=t.getAccessor(1);if(e>=h)continue;let a=0;for(let o of c){let l=Nl(o.trim(),"|").split("|");if(e<l.length){let o=l[e].trim().split(t.getSeparator());if(!o)continue;if(1===o.length){let e=Ll(o[0],r.textValueMap);if(null!==e.value){e.type===nl.Time&&(t.valueType=nl.Time);let o=e.value;a<p.length&&p[a]&&(i.gotAnyValidYValue||(i.gotAnyValidYValue=!0),qu(n,El(p[a],r.dateFormat),t,o))}}else if(o.length>t.getAccessor(2)&&t.getAccessor(2)>=0){let e=null,l=Ll(o[t.getAccessor(2)].trim(),r.textValueMap);null!==l.value&&(l.type===nl.Time&&(t.valueType=nl.Time),e=l.value,a<p.length&&p[a]&&(i.gotAnyValidYValue||(i.gotAnyValidYValue=!0),qu(n,El(p[a],r.dateFormat),t,e)))}}a++}}}}))}getEditor(){return this.app.workspace.getActiveViewOfType(t.MarkdownView).editor}addCodeBlock(e){if(!(this.app.workspace.activeLeaf.view instanceof t.MarkdownView))return;let n="";switch(e){case el.Line:n='``` tracker\nsearchType: tag\nsearchTarget: tagName\nfolder: /\nstartDate:\nendDate:\nline:\n title: "Line Chart"\n xAxisLabel: Date\n yAxisLabel: Value\n```';break;case el.Bar:n='``` tracker\nsearchType: tag\nsearchTarget: tagName\nfolder: /\nstartDate:\nendDate:\nbar:\n title: "Bar Chart"\n xAxisLabel: Date\n yAxisLabel: Value\n```';break;case el.Summary:n='``` tracker\nsearchType: tag\nsearchTarget: tagName\nfolder: /\nstartDate:\nendDate:\nsummary:\n template: "Average value of tagName is {{average()}}"\n style: "color:white;"\n```'}""!==n&&this.insertToNextLine(n)}insertToNextLine(t){let e=this.getEditor();if(e){let n=e.getCursor(),r=n.line,i=e.getLine(r);return n.ch=i.length,e.setSelection(n),e.replaceSelection("\n"+t),!0}return!1}}module.exports=Ju;
|