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