diff --git a/dist/chart-card/chart-bundle-min.js b/dist/chart-card/chart-bundle-min.js index 82dee99..a8ceefe 100644 --- a/dist/chart-card/chart-bundle-min.js +++ b/dist/chart-card/chart-bundle-min.js @@ -1 +1 @@ -function LineFitter(){this.count=0,this.sumX=0,this.sumX2=0,this.sumXY=0,this.sumY=0}function addFitter(t,e,i,s,n){if(i&&i.data&&i.data.length){const o="time"===s.options.type,a=i.data.length-1,r=t.data[0].x,l=t.data[a].x,h=new LineFitter;i.data.forEach(function(t,e){h.add(e,o?t.y:t)}),e.lineWidth=i.trendlineLinear.lineStyle||"solid","dotted"===(i.trendlineLinear.lineStyle||"solid")&&e.setLineDash([2,3]),e.beginPath(),e.lineWidth=2,e.moveTo(r,n.getPixelForValue(h.project(0))),e.lineTo(l,n.getPixelForValue(h.project(a))),e.strokeStyle=i.trendlineLinear.color||i.borderColor||"rgba(255, 0, 0, 0.85)",e.stroke()}}!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Chart=e()}(this,function(){"use strict";const t="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function e(e,i,s){const n=s||(t=>Array.prototype.slice.call(t));let o=!1,a=[];return function(...s){a=n(s),o||(o=!0,t.call(window,()=>{o=!1,e.apply(i,a)}))}}function i(t,e){let i;return function(...s){return e?(clearTimeout(i),i=setTimeout(t,e,s)):t.apply(this,s),e}}const s=t=>"start"===t?"left":"end"===t?"right":"center",n=(t,e,i)=>"start"===t?e:"end"===t?i:(e+i)/2,o=(t,e,i,s)=>{return t===(s?"left":"right")?i:"center"===t?(e+i)/2:e};var a=new class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,s){const n=e.listeners[s],o=e.duration;n.forEach(s=>s({chart:t,initial:e.initial,numSteps:o,currentStep:Math.min(i-e.start,o)}))}_refresh(){this._request||(this._running=!0,this._request=t.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((i,s)=>{if(!i.running||!i.items.length)return;const n=i.items;let o,a=n.length-1,r=!1;for(;a>=0;--a)(o=n[a])._active?(o._total>i.duration&&(i.duration=o._total),o.tick(t),r=!0):(n[a]=n[n.length-1],n.pop());r&&(s.draw(),this._notify(s,i,t,"progress")),n.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),e+=n.length}),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((t,e)=>Math.max(t,e._duration),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}};const r={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},l="0123456789ABCDEF",h=t=>l[15&t],c=t=>l[(240&t)>>4]+l[15&t],d=t=>(240&t)>>4==(15&t);function u(t){var e=function(t){return d(t.r)&&d(t.g)&&d(t.b)&&d(t.a)}(t)?h:c;return t?"#"+e(t.r)+e(t.g)+e(t.b)+(t.a<255?e(t.a):""):t}function f(t){return t+.5|0}const g=(t,e,i)=>Math.max(Math.min(t,i),e);function p(t){return g(f(2.55*t),0,255)}function m(t){return g(f(255*t),0,255)}function x(t){return g(f(t/2.55)/100,0,1)}function b(t){return g(f(100*t),0,100)}const _=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const y=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function v(t,e,i){const s=e*Math.min(i,1-i),n=(e,n=(e+t/30)%12)=>i-s*Math.max(Math.min(n-3,9-n,1),-1);return[n(0),n(8),n(4)]}function w(t,e,i){const s=(s,n=(s+t/60)%6)=>i-i*e*Math.max(Math.min(n,4-n,1),0);return[s(5),s(3),s(1)]}function M(t,e,i){const s=v(t,1,.5);let n;for(e+i>1&&(e*=n=1/(e+i),i*=n),n=0;n<3;n++)s[n]*=1-e-i,s[n]+=e;return s}function k(t){const e=t.r/255,i=t.g/255,s=t.b/255,n=Math.max(e,i,s),o=Math.min(e,i,s),a=(n+o)/2;let r,l,h;return n!==o&&(h=n-o,l=a>.5?h/(2-n-o):h/(n+o),r=60*(r=n===e?(i-s)/h+(i>16&255,o>>8&255,255&o]}return t}()).transparent=[0,0,0,0]);const e=T[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}function R(t,e,i){if(t){let s=k(t);s[e]=Math.max(0,Math.min(s[e]+s[e]*i,0===e?360:1)),s=P(s),t.r=s[0],t.g=s[1],t.b=s[2]}}function E(t,e){return t?Object.assign(e||{},t):t}function I(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=m(t[3]))):(e=E(t,{r:0,g:0,b:0,a:1})).a=m(e.a),e}function z(t){return"r"===t.charAt(0)?function(t){const e=_.exec(t);let i,s,n,o=255;if(e){if(e[7]!==i){const t=+e[7];o=255&(e[8]?p(t):255*t)}return i=+e[1],s=+e[3],n=+e[5],{r:i=255&(e[2]?p(i):i),g:s=255&(e[4]?p(s):s),b:n=255&(e[6]?p(n):n),a:o}}}(t):C(t)}class F{constructor(t){if(t instanceof F)return t;const e=typeof t;let i;var s,n,o;"object"===e?i=I(t):"string"===e&&(o=(s=t).length,"#"===s[0]&&(4===o||5===o?n={r:255&17*r[s[1]],g:255&17*r[s[2]],b:255&17*r[s[3]],a:5===o?17*r[s[4]]:255}:7!==o&&9!==o||(n={r:r[s[1]]<<4|r[s[2]],g:r[s[3]]<<4|r[s[4]],b:r[s[5]]<<4|r[s[6]],a:9===o?r[s[7]]<<4|r[s[8]]:255})),i=n||L(t)||z(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=E(this._rgb);return t&&(t.a=x(t.a)),t}set rgb(t){this._rgb=I(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${x(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):this._rgb;var t}hexString(){return this._valid?u(this._rgb):this._rgb}hslString(){return this._valid?function(t){if(!t)return;const e=k(t),i=e[0],s=b(e[1]),n=b(e[2]);return t.a<255?`hsla(${i}, ${s}%, ${n}%, ${x(t.a)})`:`hsl(${i}, ${s}%, ${n}%)`}(this._rgb):this._rgb}mix(t,e){const i=this;if(t){const s=i.rgb,n=t.rgb;let o;const a=e===o?.5:e,r=2*a-1,l=s.a-n.a,h=((r*l==-1?r:(r+l)/(1+r*l))+1)/2;o=1-h,s.r=255&h*s.r+o*n.r+.5,s.g=255&h*s.g+o*n.g+.5,s.b=255&h*s.b+o*n.b+.5,s.a=a*s.a+(1-a)*n.a,i.rgb=s}return i}clone(){return new F(this.rgb)}alpha(t){return this._rgb.a=m(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,e=f(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return R(this._rgb,2,t),this}darken(t){return R(this._rgb,2,-t),this}saturate(t){return R(this._rgb,1,t),this}desaturate(t){return R(this._rgb,1,-t),this}rotate(t){return function(t,e){var i=k(t);i[0]=D(i[0]+e),i=P(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this}}function V(t){return new F(t)}const B=t=>t instanceof CanvasGradient||t instanceof CanvasPattern;function W(t){return B(t)?t:V(t)}function N(t){return B(t)?t:V(t).saturate(.5).darken(.1).hexString()}function H(){}const j=function(){let t=0;return function(){return t++}}();function $(t){return null==t}function Y(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.substr(0,7)&&"Array]"===e.substr(-6)}function U(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}const X=t=>("number"==typeof t||t instanceof Number)&&isFinite(+t);function q(t,e){return X(t)?t:e}function K(t,e){return void 0===t?e:t}const G=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:t/e,Z=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function Q(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function J(t,e,i,s){let n,o,a;if(Y(t))if(o=t.length,s)for(n=o-1;n>=0;n--)e.call(i,t[n],n);else for(n=0;ni;)t=t[e.substr(i,s-i)],s=ht(e,i=s+1);return t}function dt(t){return t.charAt(0).toUpperCase()+t.slice(1)}const ut=t=>void 0!==t,ft=t=>"function"==typeof t,gt=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0},pt=Object.create(null),mt=Object.create(null);function xt(t,e){if(!e)return t;const i=e.split(".");for(let e=0,s=i.length;et.chart.platform.getDevicePixelRatio()),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=((t,e)=>N(e.backgroundColor)),this.hoverBorderColor=((t,e)=>N(e.borderColor)),this.hoverColor=((t,e)=>N(e.color)),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.describe(t)}set(t,e){return bt(this,t,e)}get(t){return xt(this,t)}describe(t,e){return bt(mt,t,e)}override(t,e){return bt(pt,t,e)}route(t,e,i,s){const n=xt(this,t),o=xt(this,i),a="_"+e;Object.defineProperties(n,{[a]:{value:n[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[a],e=o[s];return U(t)?Object.assign({},e,t):K(t,e)},set(t){this[a]=t}}})}}({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}});const yt=Math.PI,vt=2*yt,wt=vt+yt,Mt=Number.POSITIVE_INFINITY,kt=yt/180,St=yt/2,Pt=yt/4,Dt=2*yt/3,Ct=Math.log10,Ot=Math.sign;function At(t){const e=Math.round(t);t=Rt(t,e,t/1e3)?e:t;const i=Math.pow(10,Math.floor(Ct(t))),s=t/i;return(s<=1?1:s<=2?2:s<=5?5:10)*i}function Tt(t){const e=[],i=Math.sqrt(t);let s;for(s=1;st-e).pop(),e}function Lt(t){return!isNaN(parseFloat(t))&&isFinite(t)}function Rt(t,e,i){return Math.abs(t-e)=t}function It(t,e,i){let s,n,o;for(s=0,n=t.length;sl&&hs&&(s=o),s}function qt(t,e,i,s){let n=(s=s||{}).data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==e&&(n=s.data={},o=s.garbageCollect=[],s.font=e),t.save(),t.font=e;let a=0;const r=i.length;let l,h,c,d,u;for(l=0;li.length){for(l=0;l0&&t.stroke()}}function Qt(t,e,i){return i=i||.5,!e||t&&t.x>e.left-i&&t.xe.top-i&&t.y0&&""!==o.strokeColor;let l,h;for(t.save(),t.font=n.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]);$(e.rotation)||t.rotate(e.rotation);e.color&&(t.fillStyle=e.color);e.textAlign&&(t.textAlign=e.textAlign);e.textBaseline&&(t.textBaseline=e.textBaseline)}(t,o),l=0;lt[i]1;)i(s=o+n>>1)?o=s:n=s;return{lo:o,hi:n}}const re=(t,e,i)=>ae(t,i,s=>t[s][e]ae(t,i,s=>t[s][e]>=i);function he(t,e,i){let s=0,n=t.length;for(;ss&&t[n-1]>i;)n--;return s>0||n{const i="_onData"+dt(e),s=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...e){const n=s.apply(this,e);return t._chartjs.listeners.forEach(t=>{"function"==typeof t[i]&&t[i](...e)}),n}})}))}function ue(t,e){const i=t._chartjs;if(!i)return;const s=i.listeners,n=s.indexOf(e);-1!==n&&s.splice(n,1),s.length>0||(ce.forEach(e=>{delete t[e]}),delete t._chartjs)}function fe(t){const e=new Set;let i,s;for(i=0,s=t.length;iwindow.getComputedStyle(t,null);function be(t,e){return xe(t).getPropertyValue(e)}const _e=["top","right","bottom","left"];function ye(t,e,i){const s={};i=i?"-"+i:"";for(let n=0;n<4;n++){const o=_e[n];s[o]=parseFloat(t[e+"-"+o+i])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}const ve=(t,e,i)=>(t>0||e>0)&&(!i||!i.shadowRoot);function we(t,e){const{canvas:i,currentDevicePixelRatio:s}=e,n=xe(i),o="border-box"===n.boxSizing,a=ye(n,"padding"),r=ye(n,"border","width"),{x:l,y:h,box:c}=function(t,e){const i=t.native||t,s=i.touches,n=s&&s.length?s[0]:i,{offsetX:o,offsetY:a}=n;let r,l,h=!1;if(ve(o,a,i.target))r=o,l=a;else{const t=e.getBoundingClientRect();r=n.clientX-t.left,l=n.clientY-t.top,h=!0}return{x:r,y:l,box:h}}(t,i),d=a.left+(c&&r.left),u=a.top+(c&&r.top);let{width:f,height:g}=e;return o&&(f-=a.width+r.width,g-=a.height+r.height),{x:Math.round((l-d)/f*i.width/s),y:Math.round((h-u)/g*i.height/s)}}const Me=t=>Math.round(10*t)/10;function ke(t,e,i,s){const n=xe(t),o=ye(n,"margin"),a=me(n.maxWidth,t,"clientWidth")||Mt,r=me(n.maxHeight,t,"clientHeight")||Mt,l=function(t,e,i){let s,n;if(void 0===e||void 0===i){const o=pe(t);if(o){const t=o.getBoundingClientRect(),a=xe(o),r=ye(a,"border","width"),l=ye(a,"padding");e=t.width-l.width-r.width,i=t.height-l.height-r.height,s=me(a.maxWidth,o,"clientWidth"),n=me(a.maxHeight,o,"clientHeight")}else e=t.clientWidth,i=t.clientHeight}return{width:e,height:i,maxWidth:s||Mt,maxHeight:n||Mt}}(t,e,i);let{width:h,height:c}=l;if("content-box"===n.boxSizing){const t=ye(n,"border","width"),e=ye(n,"padding");h-=e.width+t.width,c-=e.height+t.height}return h=Math.max(0,h-o.width),c=Math.max(0,s?Math.floor(h/s):c-o.height),h=Me(Math.min(h,a,l.maxWidth)),c=Me(Math.min(c,r,l.maxHeight)),h&&!c&&(c=Me(h/2)),{width:h,height:c}}function Se(t,e,i){const s=e||1,n=Math.floor(t.height*s),o=Math.floor(t.width*s);t.height=n/s,t.width=o/s;const a=t.canvas;return a.style&&(i||!a.style.height&&!a.style.width)&&(a.style.height=`${t.height}px`,a.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(t.currentDevicePixelRatio=s,a.height=n,a.width=o,t.ctx.setTransform(s,0,0,s,0,0),!0)}const Pe=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}();function De(t,e){const i=be(t,e),s=i&&i.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function Ce(t,e){return"native"in t?{x:t.x,y:t.y}:we(t,e)}function Oe(t,e,i,s){const{controller:n,data:o,_sorted:a}=t,r=n._cachedMeta.iScale;if(r&&e===r.axis&&a&&o.length){const t=r._reversePixels?le:re;if(!s)return t(o,e,i);if(n._sharedOptions){const s=o[0],n="function"==typeof s.getRange&&s.getRange(e);if(n){const s=t(o,e,i-n),a=t(o,e,i+n);return{lo:s.lo,hi:a.hi}}}}return{lo:0,hi:o.length-1}}function Ae(t,e,i,s,n){const o=t.getSortedVisibleDatasetMetas(),a=i[e];for(let t=0,i=o.length;t{t[r](n[a],s)&&o.push({element:t,datasetIndex:e,index:i}),t.inRange(n.x,n.y,s)&&(l=!0)}),i.intersect&&!l?[]:o}var Ee={modes:{index(t,e,i,s){const n=Ce(e,t),o=i.axis||"x",a=i.intersect?Te(t,n,o,s):Le(t,n,o,!1,s),r=[];return a.length?(t.getSortedVisibleDatasetMetas().forEach(t=>{const e=a[0].index,i=t.data[e];i&&!i.skip&&r.push({element:i,datasetIndex:t.index,index:e})}),r):[]},dataset(t,e,i,s){const n=Ce(e,t),o=i.axis||"xy";let a=i.intersect?Te(t,n,o,s):Le(t,n,o,!1,s);if(a.length>0){const e=a[0].datasetIndex,i=t.getDatasetMeta(e).data;a=[];for(let t=0;tTe(t,Ce(e,t),i.axis||"xy",s),nearest:(t,e,i,s)=>Le(t,Ce(e,t),i.axis||"xy",i.intersect,s),x:(t,e,i,s)=>(i.axis="x",Re(t,e,i,s)),y:(t,e,i,s)=>(i.axis="y",Re(t,e,i,s))}};const Ie=new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/),ze=new RegExp(/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/);function Fe(t,e){const i=(""+t).match(Ie);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}const Ve=t=>+t||0;function Be(t,e){const i={},s=U(e),n=s?Object.keys(e):e,o=U(t)?s?i=>K(t[i],t[e[i]]):e=>t[e]:()=>t;for(const t of n)i[t]=Ve(o(t));return i}function We(t){return Be(t,{top:"y",right:"x",bottom:"y",left:"x"})}function Ne(t){return Be(t,["topLeft","topRight","bottomLeft","bottomRight"])}function He(t){const e=We(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function je(t,e){t=t||{},e=e||_t.font;let i=K(t.size,e.size);"string"==typeof i&&(i=parseInt(i,10));let s=K(t.style,e.style);s&&!(""+s).match(ze)&&(console.warn('Invalid font style specified: "'+s+'"'),s="");const n={family:K(t.family,e.family),lineHeight:Fe(K(t.lineHeight,e.lineHeight),i),size:i,style:s,weight:K(t.weight,e.weight),string:""};return n.string=Ut(n),n}function $e(t,e,i,s){let n,o,a,r=!0;for(n=0,o=t.length;ni&&0===t?0:t+e;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function Ue(t,e){return Object.assign(Object.create(t),e)}const Xe=["left","top","right","bottom"];function qe(t,e){return t.filter(t=>t.pos===e)}function Ke(t,e){return t.filter(t=>-1===Xe.indexOf(t.pos)&&t.box.axis===e)}function Ge(t,e){return t.sort((t,i)=>{const s=e?i:t,n=e?t:i;return s.weight===n.weight?s.index-n.index:s.weight-n.weight})}function Ze(t,e){const i=function(t){const e={};for(const i of t){const{stack:t,pos:s,stackWeight:n}=i;if(!t||!Xe.includes(s))continue;const o=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=n}return e}(t),{vBoxMaxWidth:s,hBoxMaxHeight:n}=e;let o,a,r;for(o=0,a=t.length;o{s[t]=Math.max(e[t],i[t])}),s}return s(t?["left","right"]:["top","bottom"])}function ii(t,e,i,s){const n=[];let o,a,r,l,h,c;for(o=0,a=t.length,h=0;ot.box.fullSize),!0),s=Ge(qe(e,"left"),!0),n=Ge(qe(e,"right")),o=Ge(qe(e,"top"),!0),a=Ge(qe(e,"bottom")),r=Ke(e,"x"),l=Ke(e,"y");return{fullSize:i,leftAndTop:s.concat(o),rightAndBottom:n.concat(l).concat(a).concat(r),chartArea:qe(e,"chartArea"),vertical:s.concat(n).concat(l),horizontal:o.concat(a).concat(r)}}(t.boxes),l=r.vertical,h=r.horizontal;J(t.boxes,t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()});const c=l.reduce((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1,0)||1,d=Object.freeze({outerWidth:e,outerHeight:i,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/c,hBoxMaxHeight:a/2}),u=Object.assign({},n);Je(u,He(s));const f=Object.assign({maxPadding:u,w:o,h:a,x:n.left,y:n.top},n),g=Ze(l.concat(h),d);ii(r.fullSize,f,d,g),ii(l,f,d,g),ii(h,f,d,g)&&ii(l,f,d,g),function(t){const e=t.maxPadding;function i(i){const s=Math.max(e[i]-t[i],0);return t[i]+=s,s}t.y+=i("top"),t.x+=i("left"),i("right"),i("bottom")}(f),ni(r.leftAndTop,f,d,g),f.x+=f.w,f.y+=f.h,ni(r.rightAndBottom,f,d,g),t.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},J(r.chartArea,e=>{const i=e.box;Object.assign(i,t.chartArea),i.update(f.w,f.h)})}};function ai(t,e=[""],i=t,s,n=(()=>t[0])){return ut(s)||(s=xi("_fallback",t)),new Proxy({[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:i,_fallback:s,_getTarget:n,override:n=>ai([n,...t],e,i,s)},{deleteProperty:(e,i)=>(delete e[i],delete e._keys,delete t[0][i],!0),get:(i,s)=>di(i,s,()=>(function(t,e,i,s){let n;for(const o of e)if(n=xi(hi(o,t),i),ut(n))return ci(t,n)?pi(i,s,t,n):n})(s,e,t,i)),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>bi(t).includes(e),ownKeys:t=>bi(t),set:(t,e,i)=>((t._storage||(t._storage=n()))[e]=i,delete t[e],delete t._keys,!0)})}function ri(t,e,i,s){const n={_cacheable:!1,_proxy:t,_context:e,_subProxy:i,_stack:new Set,_descriptors:li(t,s),setContext:e=>ri(t,e,i,s),override:n=>ri(t.override(n),e,i,s)};return new Proxy(n,{deleteProperty:(e,i)=>(delete e[i],delete t[i],!0),get:(t,e,i)=>di(t,e,()=>(function(t,e,i){const{_proxy:s,_context:n,_subProxy:o,_descriptors:a}=t;let r=s[e];ft(r)&&a.isScriptable(e)&&(r=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_stack:r}=i;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);r.add(t),e=e(o,a||s),r.delete(t),U(e)&&(e=pi(n._scopes,n,t,e));return e}(e,r,t,i));Y(r)&&r.length&&(r=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_descriptors:r}=i;if(ut(o.index)&&s(t))e=e[o.index%e.length];else if(U(e[0])){const i=e,s=n._scopes.filter(t=>t!==i);e=[];for(const l of i){const i=pi(s,n,t,l);e.push(ri(i,o,a&&a[t],r))}}return e}(e,r,t,a.isIndexable));ci(e,r)&&(r=ri(r,n,o&&o[e],a));return r})(t,e,i)),getOwnPropertyDescriptor:(e,i)=>e._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,i)=>Reflect.has(t,i),ownKeys:()=>Reflect.ownKeys(t),set:(e,i,s)=>(t[i]=s,delete e[i],!0)})}function li(t,e={scriptable:!0,indexable:!0}){const{_scriptable:i=e.scriptable,_indexable:s=e.indexable,_allKeys:n=e.allKeys}=t;return{allKeys:n,scriptable:i,indexable:s,isScriptable:ft(i)?i:()=>i,isIndexable:ft(s)?s:()=>s}}const hi=(t,e)=>t?t+dt(e):e,ci=(t,e)=>U(e)&&"adapters"!==t;function di(t,e,i){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];const s=i();return t[e]=s,s}function ui(t,e,i){return ft(t)?t(e,i):t}const fi=(t,e)=>!0===t?e:"string"==typeof t?ct(e,t):void 0;function gi(t,e,i,s){for(const n of e){const e=fi(i,n);if(e){t.add(e);const n=ui(e._fallback,i,e);if(ut(n)&&n!==i&&n!==s)return n}else if(!1===e&&ut(s)&&i!==s)return null}return!1}function pi(t,e,i,s){const n=e._rootScopes,o=ui(e._fallback,i,s),a=[...t,...n],r=new Set;r.add(s);let l=mi(r,a,i,o||i);return null!==l&&((!ut(o)||o===i||null!==(l=mi(r,a,o,l)))&&ai(Array.from(r),[""],n,o,()=>(function(t,e,i){const s=t._getTarget();e in s||(s[e]={});const n=s[e];if(Y(n)&&U(i))return i;return n})(e,i,s)))}function mi(t,e,i,s){for(;i;)i=gi(t,e,i,s);return i}function xi(t,e){for(const i of e){if(!i)continue;const e=i[t];if(ut(e))return e}}function bi(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const i of t)for(const t of Object.keys(i).filter(t=>!t.startsWith("_")))e.add(t);return Array.from(e)}(t._scopes)),e}const _i=Number.EPSILON||1e-14,yi=(t,e)=>e"x"===t?"y":"x";function wi(t,e,i,s){const n=t.skip?e:t,o=e,a=i.skip?e:i,r=Wt(o,n),l=Wt(a,o);let h=r/(r+l),c=l/(r+l);const d=s*(h=isNaN(h)?0:h),u=s*(c=isNaN(c)?0:c);return{previous:{x:o.x-d*(a.x-n.x),y:o.y-d*(a.y-n.y)},next:{x:o.x+u*(a.x-n.x),y:o.y+u*(a.y-n.y)}}}function Mi(t,e="x"){const i=vi(e),s=t.length,n=Array(s).fill(0),o=Array(s);let a,r,l,h=yi(t,0);for(a=0;a!t.skip)),"monotone"===e.cubicInterpolationMode)Mi(t,n);else{let i=s?t[t.length-1]:t[0];for(o=0,a=t.length;o0===t||1===t,Di=(t,e,i)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*vt/i),Ci=(t,e,i)=>Math.pow(2,-10*t)*Math.sin((t-e)*vt/i)+1,Oi={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*St),easeOutSine:t=>Math.sin(t*St),easeInOutSine:t=>-.5*(Math.cos(yt*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>Pi(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>Pi(t)?t:Di(t,.075,.3),easeOutElastic:t=>Pi(t)?t:Ci(t,.075,.3),easeInOutElastic:t=>Pi(t)?t:t<.5?.5*Di(2*t,.1125,.45):.5+.5*Ci(2*t-1,.1125,.45),easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-Oi.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},easeInOutBounce:t=>t<.5?.5*Oi.easeInBounce(2*t):.5*Oi.easeOutBounce(2*t-1)+.5};function Ai(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:t.y+i*(e.y-t.y)}}function Ti(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:"middle"===s?i<.5?t.y:e.y:"after"===s?i<1?t.y:e.y:i>0?e.y:t.y}}function Li(t,e,i,s){const n={x:t.cp2x,y:t.cp2y},o={x:e.cp1x,y:e.cp1y},a=Ai(t,n,i),r=Ai(n,o,i),l=Ai(o,e,i),h=Ai(a,r,i),c=Ai(r,l,i);return Ai(h,c,i)}const Ri=new Map;function Ei(t,e,i){return function(t,e){e=e||{};const i=t+JSON.stringify(e);let s=Ri.get(i);return s||(s=new Intl.NumberFormat(t,e),Ri.set(i,s)),s}(e,i).format(t)}const Ii=function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}},zi=function(){return{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}};function Fi(t,e,i){return t?Ii(e,i):zi()}function Vi(t,e){let i,s;"ltr"!==e&&"rtl"!==e||(s=[(i=t.canvas.style).getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=s)}function Bi(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Wi(t){return"angle"===t?{between:jt,compare:Nt,normalize:Ht}:{between:(t,e,i)=>t>=Math.min(e,i)&&t<=Math.max(i,e),compare:(t,e)=>t-e,normalize:t=>t}}function Ni({start:t,end:e,count:i,loop:s,style:n}){return{start:t%i,end:e%i,loop:s&&(e-t+1)%i==0,style:n}}function Hi(t,e,i){if(!i)return[t];const{property:s,start:n,end:o}=i,a=e.length,{compare:r,between:l,normalize:h}=Wi(s),{start:c,end:d,loop:u,style:f}=function(t,e,i){const{property:s,start:n,end:o}=i,{between:a,normalize:r}=Wi(s),l=e.length;let h,c,{start:d,end:u,loop:f}=t;if(f){for(d+=l,u+=l,h=0,c=l;hb||(()=>l(n,x,p)&&0!==r(n,x))(),v=()=>!b||(()=>0===r(o,p)||l(o,x,p))();for(let t=c,i=c;t<=d;++t)(m=e[t%a]).skip||(p=h(m[s]))!==x&&(b=l(p,n,o),null===_&&y()&&(_=0===r(p,n)?t:i),null!==_&&v()&&(g.push(Ni({start:_,end:t,loop:u,count:a,style:f})),_=null),i=t,x=p);return null!==_&&g.push(Ni({start:_,end:d,loop:u,count:a,style:f})),g}function ji(t,e){const i=[],s=t.segments;for(let n=0;nn&&t[o%e].skip;)o--;return{start:n,end:o%=e}}(i,n,o,s);return Yi(t,!0===s?[{start:a,end:r,loop:o}]:function(t,e,i,s){const n=t.length,o=[];let a,r=e,l=t[e];for(a=e+1;a<=i;++a){const i=t[a%n];i.skip||i.stop?l.skip||(s=!1,o.push({start:e%n,end:(a-1)%n,loop:s}),e=r=i.stop?a:null):(r=a,l.skip&&(e=a)),l=i}return null!==r&&o.push({start:e%n,end:r%n,loop:s}),o}(i,a,rnull===t||""===t;const ts=!!Pe&&{passive:!0};function es(t,e,i){t.canvas.removeEventListener(e,i,ts)}function is(t,e,i){const s=t.canvas,n=new MutationObserver(t=>{for(const e of t)for(const t of e.addedNodes)if(t===s||t.contains(s))return i()});return n.observe(document,{childList:!0,subtree:!0}),n}function ss(t,e,i){const s=t.canvas,n=new MutationObserver(t=>{for(const e of t)for(const t of e.removedNodes)if(t===s||t.contains(s))return i()});return n.observe(document,{childList:!0,subtree:!0}),n}const ns=new Map;let os=0;function as(){const t=window.devicePixelRatio;t!==os&&(os=t,ns.forEach((e,i)=>{i.currentDevicePixelRatio!==t&&e()}))}function rs(t,i,s){const n=t.canvas,o=n&&pe(n);if(!o)return;const a=e((t,e)=>{const i=o.clientWidth;s(t,e),i{const e=t[0],i=e.contentRect.width,s=e.contentRect.height;0===i&&0===s||a(i,s)});return r.observe(o),function(t,e){ns.size||window.addEventListener("resize",as),ns.set(t,e)}(t,a),r}function ls(t,e,i){i&&i.disconnect(),"resize"===e&&function(t){ns.delete(t),ns.size||window.removeEventListener("resize",as)}(t)}function hs(t,i,s){const n=t.canvas,o=e(e=>{null!==t.ctx&&s(function(t,e){const i=Qi[t.type]||t.type,{x:s,y:n}=we(t,e);return{type:i,chart:e,native:t,x:void 0!==s?s:null,y:void 0!==n?n:null}}(e,t))},t,t=>{const e=t[0];return[e,e.offsetX,e.offsetY]});return function(t,e,i){t.addEventListener(e,i,ts)}(n,i,o),o}class cs extends Ki{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(function(t,e){const i=t.style,s=t.getAttribute("height"),n=t.getAttribute("width");if(t[Zi]={initial:{height:s,width:n,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",Ji(n)){const e=De(t,"width");void 0!==e&&(t.width=e)}if(Ji(s))if(""===t.style.height)t.height=t.width/(e||2);else{const e=De(t,"height");void 0!==e&&(t.height=e)}}(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e[Zi])return!1;const i=e[Zi].initial;["height","width"].forEach(t=>{const s=i[t];$(s)?e.removeAttribute(t):e.setAttribute(t,s)});const s=i.style||{};return Object.keys(s).forEach(t=>{e.style[t]=s[t]}),e.width=e.width,delete e[Zi],!0}addEventListener(t,e,i){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),n={attach:is,detach:ss,resize:rs}[e]||hs;s[e]=n(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];s&&(({attach:ls,detach:ls,resize:ls}[e]||es)(t,e,s),i[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return ke(t,e,i,s)}isAttached(t){const e=pe(t);return!(!e||!e.isConnected)}}function ds(t){return!ge()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?Gi:cs}var us=Object.freeze({__proto__:null,_detectPlatform:ds,BasePlatform:Ki,BasicPlatform:Gi,DomPlatform:cs});const fs={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const s=W(t||"transparent"),n=s.valid&&W(e||"transparent");return n&&n.valid?n.mix(s,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class gs{constructor(t,e,i,s){const n=e[i];s=$e([t.to,s,n,t.from]);const o=$e([t.from,n,s]);this._active=!0,this._fn=t.fn||fs[t.type||typeof o],this._easing=Oi[t.easing]||Oi.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=o,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const s=this._target[this._prop],n=i-this._start,o=this._duration-n;this._start=i,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=n,this._loop=!!t.loop,this._to=$e([t.to,e,s,t.from]),this._from=$e([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,s=this._prop,n=this._from,o=this._loop,a=this._to;let r;if(this._active=n!==a&&(o||e1?2-r:r,r=this._easing(Math.min(1,Math.max(0,r))),this._target[s]=this._fn(n,a,r))}wait(){const t=this._promises||(this._promises=[]);return new Promise((e,i)=>{t.push({res:e,rej:i})})}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let t=0;t"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),_t.set("animations",{colors:{type:"color",properties:["color","borderColor","backgroundColor"]},numbers:{type:"number",properties:["x","y","borderWidth","radius","tension"]}}),_t.describe("animations",{_fallback:"animation"}),_t.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}});class ms{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!U(t))return;const e=this._properties;Object.getOwnPropertyNames(t).forEach(i=>{const s=t[i];if(!U(s))return;const n={};for(const t of ps)n[t]=s[t];(Y(s.properties)&&s.properties||[i]).forEach(t=>{t!==i&&e.has(t)||e.set(t,n)})})}_animateOptions(t,e){const i=e.options,s=function(t,e){if(!e)return;let i=t.options;if(!i)return void(t.options=e);i.$shared&&(t.options=i=Object.assign({},i,{$shared:!1,$animations:{}}));return i}(t,i);if(!s)return[];const n=this._createAnimations(s,i);return i.$shared&&function(t,e){const i=[],s=Object.keys(e);for(let e=0;e{t.options=i},()=>{}),n}_createAnimations(t,e){const i=this._properties,s=[],n=t.$animations||(t.$animations={}),o=Object.keys(e),a=Date.now();let r;for(r=o.length-1;r>=0;--r){const l=o[r];if("$"===l.charAt(0))continue;if("options"===l){s.push(...this._animateOptions(t,e));continue}const h=e[l];let c=n[l];const d=i.get(l);if(c){if(d&&c.active()){c.update(d,h,a);continue}c.cancel()}d&&d.duration?(n[l]=c=new gs(d,t,l,h),s.push(c)):t[l]=h}return s}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(a.add(this._chart,i),!0):void 0}}function xs(t,e){const i=t&&t.options||{},s=i.reverse,n=void 0===i.min?e:0,o=void 0===i.max?e:0;return{start:s?o:n,end:s?n:o}}function bs(t,e){const i=[],s=t._getSortedDatasetMetas(e);let n,o;for(n=0,o=s.length;n0||!i&&e<0)return n.index}return null}function Ms(t,e){const{chart:i,_cachedMeta:s}=t,n=i._stacks||(i._stacks={}),{iScale:o,vScale:a,index:r}=s,l=o.axis,h=a.axis,c=function(t,e,i){return`${t.id}.${e.id}.${i.stack||i.type}`}(o,a,s),d=e.length;let u;for(let t=0;ti[t].axis===e).shift()}function Ss(t,e){const i=t.controller.index,s=t.vScale&&t.vScale.axis;if(s){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[s]||void 0===e[s][i])return;delete e[s][i]}}}const Ps=t=>"reset"===t||"none"===t,Ds=(t,e)=>e?t:Object.assign({},t),Cs=(t,e,i)=>t&&!e.hidden&&e._stacked&&{keys:bs(i,!0),values:null};class Os{constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.$context=void 0,this._syncList=[],this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=ys(t.vScale,t),this.addElements()}updateIndex(t){this.index!==t&&Ss(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(t,e,i,s)=>"x"===t?e:"r"===t?s:i,n=e.xAxisID=K(i.xAxisID,ks(t,"x")),o=e.yAxisID=K(i.yAxisID,ks(t,"y")),a=e.rAxisID=K(i.rAxisID,ks(t,"r")),r=e.indexAxis,l=e.iAxisID=s(r,n,o,a),h=e.vAxisID=s(r,o,n,a);e.xScale=this.getScaleForId(n),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(l),e.vScale=this.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&ue(this._data,this),t._stacked&&Ss(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(U(e))this._data=function(t){const e=Object.keys(t),i=new Array(e.length);let s,n,o;for(s=0,n=e.length;s0&&i._parsed[t-1];if(!1===this._parsing)i._parsed=s,i._sorted=!0,h=s;else{h=Y(s[t])?this.parseArrayData(i,s,t,e):U(s[t])?this.parseObjectData(i,s,t,e):this.parsePrimitiveData(i,s,t,e);const n=()=>null===l[a]||d&&l[a]e||c=0;--d)if(!f()){this.updateRangeFromParsed(l,t,u,r);break}return l}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,n,o;for(s=0,n=e.length;s=0&&tthis.getContext(i,s),c);return f.$shared&&(f.$shared=r,n[o]=Object.freeze(Ds(f,r))),f}_resolveAnimations(t,e,i){const s=this.chart,n=this._cachedDataOpts,o=`animation-${e}`,a=n[o];if(a)return a;let r;if(!1!==s.options.animation){const s=this.chart.config,n=s.datasetAnimationScopeKeys(this._type,e),o=s.getOptionScopes(this.getDataset(),n);r=s.createResolver(o,this.getContext(t,i,e))}const l=new ms(s,r&&r.animations);return r&&r._cacheable&&(n[o]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Ps(t)||this.chart._animationsDisabled}updateElement(t,e,i,s){Ps(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!Ps(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,s){t.active=s;const n=this.getStyle(e,s);this._resolveAnimations(e,i,s).update(t,{options:!s&&this.getSharedOptions(n)||n})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,i=this._cachedMeta.data;for(const[t,e,i]of this._syncList)this[t](e,i);this._syncList=[];const s=i.length,n=e.length,o=Math.min(n,s);o&&this.parse(0,o),n>s?this._insertElements(s,n-s,t):n{for(t.length+=e,a=t.length-1;a>=o;a--)t[a]=t[a-e]};for(r(n),a=t;a{s[t]=i[t]&&i[t].active()?i[t]._to:this[t]}),s}}As.defaults={},As.defaultRoutes=void 0;const Ts={values:t=>Y(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const s=this.chart.options.locale;let n,o=t;if(i.length>1){const e=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));(e<1e-4||e>1e15)&&(n="scientific"),o=function(t,e){let i=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;Math.abs(i)>=1&&t!==Math.floor(t)&&(i=t-Math.floor(t));return i}(t,i)}const a=Ct(Math.abs(o)),r=Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:n,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),Ei(t,s,l)},logarithmic(t,e,i){if(0===t)return"0";const s=t/Math.pow(10,Math.floor(Ct(t)));return 1===s||2===s||5===s?Ts.numeric.call(this,t,e,i):""}};var Ls={formatters:Ts};function Rs(t,e){const i=t.options.ticks,s=i.maxTicksLimit||function(t){const e=t.options.offset,i=t._tickSize(),s=t._length/i+(e?0:1),n=t._maxLength/i;return Math.floor(Math.min(s,n))}(t),n=i.major.enabled?function(t){const e=[];let i,s;for(i=0,s=t.length;is)return function(t,e,i,s){let n,o=0,a=i[0];for(s=Math.ceil(s),n=0;nn)return e}return Math.max(n,1)}(n,e,s);if(o>0){let t,i;const s=o>1?Math.round((r-a)/(o-1)):null;for(Es(e,l,h,$(s)?0:a-s,a),t=0,i=o-1;te.lineWidth,tickColor:(t,e)=>e.color,offset:!1,borderDash:[],borderDashOffset:0,borderWidth:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Ls.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),_t.route("scale.ticks","color","","color"),_t.route("scale.grid","color","","borderColor"),_t.route("scale.grid","borderColor","","borderColor"),_t.route("scale.title","color","","color"),_t.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t}),_t.describe("scales",{_fallback:"scale"}),_t.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t});const Is=t=>"left"===t?"right":"right"===t?"left":t,zs=(t,e,i)=>"top"===e||"left"===e?t[e]+i:t[e]-i;function Fs(t,e){const i=[],s=t.length/e,n=t.length;let o=0;for(;oa+1e-6)))return l}function Bs(t){return t.drawTicks?t.tickLength:0}function Ws(t,e){if(!t.display)return 0;const i=je(t.font,e),s=He(t.padding);return(Y(t.text)?t.text.length:1)*i.lineHeight+s.height}function Ns(t,e,i){let n=s(t);return(i&&"right"!==e||!i&&"right"===e)&&(n=Is(n)),n}class Hs extends As{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:i,_suggestedMax:s}=this;return t=q(t,Number.POSITIVE_INFINITY),e=q(e,Number.NEGATIVE_INFINITY),i=q(i,Number.POSITIVE_INFINITY),s=q(s,Number.NEGATIVE_INFINITY),{min:q(t,i),max:q(e,s),minDefined:X(t),maxDefined:X(e)}}getMinMax(t){let e,{min:i,max:s,minDefined:n,maxDefined:o}=this.getUserBounds();if(n&&o)return{min:i,max:s};const a=this.getMatchingVisibleMetas();for(let r=0,l=a.length;rs?s:i,q(s=n&&i>s?i:s,i)),max:q(s,q(i,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){Q(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:n,ticks:o}=this.options,a=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Ye(this,n,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const r=a=n||i<=1||!this.isHorizontal())return void(this.labelRotation=s);const h=this._getLabelSizes(),c=h.widest.width,d=h.highest.height,u=$t(this.chart.width-c,0,this.maxWidth);c+6>(o=t.offset?this.maxWidth/i:u/(i-1))&&(o=u/(i-(t.offset?.5:1)),a=this.maxHeight-Bs(t.grid)-e.padding-Ws(t.title,this.chart.options.font),r=Math.sqrt(c*c+d*d),l=Ft(Math.min(Math.asin($t((h.highest.height+6)/o,-1,1)),Math.asin($t(a/r,-1,1))-Math.asin($t(d/r,-1,1)))),l=Math.max(s,Math.min(n,l))),this.labelRotation=l}afterCalculateLabelRotation(){Q(this.options.afterCalculateLabelRotation,[this])}beforeFit(){Q(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:n}}=this,o=this._isVisible(),a=this.isHorizontal();if(o){const o=Ws(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=Bs(n)+o):(t.height=this.maxHeight,t.width=Bs(n)+o),i.display&&this.ticks.length){const{first:e,last:s,widest:n,highest:o}=this._getLabelSizes(),r=2*i.padding,l=zt(this.labelRotation),h=Math.cos(l),c=Math.sin(l);if(a){const e=i.mirror?0:c*n.width+h*o.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=i.mirror?0:h*n.width+c*o.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,s,c,h)}}this._handleMargins(),a?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,s){const{ticks:{align:n,padding:o},position:a}=this.options,r=0!==this.labelRotation,l="top"!==a&&"x"===this.axis;if(this.isHorizontal()){const a=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1);let c=0,d=0;r?l?(c=s*t.width,d=i*e.height):(c=i*t.height,d=s*e.width):"start"===n?d=e.width:"end"===n?c=t.width:(c=t.width/2,d=e.width/2),this.paddingLeft=Math.max((c-a+o)*this.width/(this.width-a),0),this.paddingRight=Math.max((d-h+o)*this.width/(this.width-h),0)}else{let i=e.height/2,s=t.height/2;"start"===n?(i=0,s=t.height):"end"===n&&(i=e.height,s=0),this.paddingTop=i+o,this.paddingBottom=s+o}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){Q(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,i;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,i=t.length;e{const i=t.gc,s=i.length/2;let n;if(s>e){for(n=0;n({width:n[t]||0,height:o[t]||0});return{first:v(0),last:v(e-1),widest:v(_),highest:v(y),widths:n,heights:o}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return Yt(this._alignToPixels?Kt(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&ta*s?a/i:r/s:r*s0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:n,position:o}=s,a=n.offset,r=this.isHorizontal(),l=this.ticks.length+(a?1:0),h=Bs(n),c=[],d=n.setContext(this.getContext()),u=d.drawBorder?d.borderWidth:0,f=u/2,g=function(t){return Kt(i,t,u)};let p,m,x,b,_,y,v,w,M,k,S,P;if("top"===o)p=g(this.bottom),y=this.bottom-h,w=p-f,k=g(t.top)+f,P=t.bottom;else if("bottom"===o)p=g(this.top),k=t.top,P=g(t.bottom)-f,y=p+f,w=this.top+h;else if("left"===o)p=g(this.right),_=this.right-h,v=p-f,M=g(t.left)+f,S=t.right;else if("right"===o)p=g(this.left),M=t.left,S=g(t.right)-f,_=p+f,v=this.left+h;else if("x"===e){if("center"===o)p=g((t.top+t.bottom)/2+.5);else if(U(o)){const t=Object.keys(o)[0],e=o[t];p=g(this.chart.scales[t].getPixelForValue(e))}k=t.top,P=t.bottom,w=(y=p+f)+h}else if("y"===e){if("center"===o)p=g((t.left+t.right)/2);else if(U(o)){const t=Object.keys(o)[0],e=o[t];p=g(this.chart.scales[t].getPixelForValue(e))}v=(_=p-f)-h,M=t.left,S=t.right}const D=K(s.ticks.maxTicksLimit,l),C=Math.max(1,Math.ceil(l/D));for(m=0;me.value===t);if(i>=0){return e.setContext(this.getContext(i)).lineWidth}return 0}drawGrid(t){const e=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let n,o;const a=(t,e,s)=>{s.width&&s.color&&(i.save(),i.lineWidth=s.width,i.strokeStyle=s.color,i.setLineDash(s.borderDash||[]),i.lineDashOffset=s.borderDashOffset,i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke(),i.restore())};if(e.display)for(n=0,o=s.length;n{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:i+1,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let n,o;for(n=0,o=e.length;n{const s=i.split("."),n=s.pop(),o=[t].concat(s).join("."),a=e[i].split("."),r=a.pop(),l=a.join(".");_t.route(o,n,l,r)})}(e,t.defaultRoutes);t.descriptors&&_t.describe(e,t.descriptors)}(t,o,i),this.override&&_t.override(t.id,t.overrides),o)}get(t){return this.items[t]}unregister(t){const e=this.items,i=t.id,s=this.scope;i in e&&delete e[i],s&&i in _t[s]&&(delete _t[s][i],this.override&&delete pt[i])}}var $s=new class{constructor(){this.controllers=new js(Os,"datasets",!0),this.elements=new js(As,"elements"),this.plugins=new js(Object,"plugins"),this.scales=new js(Hs,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){[...e].forEach(e=>{const s=i||this._getRegistryForType(e);i||s.isForType(e)||s===this.plugins&&e.id?this._exec(t,s,e):J(e,e=>{const s=i||this._getRegistryForType(e);this._exec(t,s,e)})})}_exec(t,e,i){const s=dt(t);Q(i["before"+s],[],i),e[t](i),Q(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;et.filter(t=>!e.some(e=>t.plugin.id===e.plugin.id));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function Us(t,e){return e||!1!==t?!0===t?{}:t:null}function Xs(t,e,i,s){const n=t.pluginScopeKeys(e),o=t.getOptionScopes(i,n);return t.createResolver(o,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function qs(t,e){const i=_t.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function Ks(t,e){return"x"===t||"y"===t?t:e.axis||("top"===(i=e.position)||"bottom"===i?"x":"left"===i||"right"===i?"y":void 0)||t.charAt(0).toLowerCase();var i}function Gs(t){const e=t.options||(t.options={});e.plugins=K(e.plugins,{}),e.scales=function(t,e){const i=pt[t.type]||{scales:{}},s=e.scales||{},n=qs(t.type,e),o=Object.create(null),a=Object.create(null);return Object.keys(s).forEach(t=>{const e=s[t];if(!U(e))return console.error(`Invalid scale configuration for scale: ${t}`);if(e._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);const r=Ks(t,e),l=function(t,e){return t===e?"_index_":"_value_"}(r,n),h=i.scales||{};o[r]=o[r]||t,a[t]=ot(Object.create(null),[{axis:r},e,h[r],h[l]])}),t.data.datasets.forEach(i=>{const n=i.type||t.type,r=i.indexAxis||qs(n,e),l=(pt[n]||{}).scales||{};Object.keys(l).forEach(t=>{const e=function(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}(t,r),n=i[e+"AxisID"]||o[e]||e;a[n]=a[n]||Object.create(null),ot(a[n],[{axis:e},s[n],l[t]])})}),Object.keys(a).forEach(t=>{const e=a[t];ot(e,[_t.scales[e.type],_t.scale])}),a}(t,e)}function Zs(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const Qs=new Map,Js=new Set;function tn(t,e){let i=Qs.get(t);return i||(i=e(),Qs.set(t,i),Js.add(i)),i}const en=(t,e,i)=>{const s=ct(e,i);void 0!==s&&t.add(s)};class sn{constructor(t){this._config=function(t){return(t=t||{}).data=Zs(t.data),Gs(t),t}(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Zs(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Gs(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return tn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return tn(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return tn(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id;return tn(`${this.type}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){const i=this._scopeCache;let s=i.get(t);return s&&!e||(s=new Map,i.set(t,s)),s}getOptionScopes(t,e,i){const{options:s,type:n}=this,o=this._cachedScopes(t,i),a=o.get(e);if(a)return a;const r=new Set;e.forEach(e=>{t&&(r.add(t),e.forEach(e=>en(r,t,e))),e.forEach(t=>en(r,s,t)),e.forEach(t=>en(r,pt[n]||{},t)),e.forEach(t=>en(r,_t,t)),e.forEach(t=>en(r,mt,t))});const l=Array.from(r);return 0===l.length&&l.push(Object.create(null)),Js.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,pt[e]||{},_t.datasets[e]||{},{type:e},_t,mt]}resolveNamedOptions(t,e,i,s=[""]){const n={$shared:!0},{resolver:o,subPrefixes:a}=nn(this._resolverCache,t,s);let r=o;if(function(t,e){const{isScriptable:i,isIndexable:s}=li(t);for(const n of e){const e=i(n),o=s(n),a=(o||e)&&t[n];if(e&&(ft(a)||on(a))||o&&Y(a))return!0}return!1}(o,e)){n.$shared=!1,r=ri(o,i=ft(i)?i():i,this.createResolver(t,i,a))}for(const t of e)n[t]=r[t];return n}createResolver(t,e,i=[""],s){const{resolver:n}=nn(this._resolverCache,t,i);return U(e)?ri(n,e,void 0,s):n}}function nn(t,e,i){let s=t.get(e);s||(s=new Map,t.set(e,s));const n=i.join();let o=s.get(n);if(!o){o={resolver:ai(e,i),subPrefixes:i.filter(t=>!t.toLowerCase().includes("hover"))},s.set(n,o)}return o}const on=t=>U(t)&&Object.getOwnPropertyNames(t).reduce((e,i)=>e||ft(t[i]),!1);const an=["top","bottom","left","right","chartArea"];function rn(t,e){return"top"===t||"bottom"===t||-1===an.indexOf(t)&&"x"===e}function ln(t,e){return function(i,s){return i[t]===s[t]?i[e]-s[e]:i[t]-s[t]}}function hn(t){const e=t.chart,i=e.options.animation;e.notifyPlugins("afterRender"),Q(i&&i.onComplete,[t],e)}function cn(t){const e=t.chart,i=e.options.animation;Q(i&&i.onProgress,[t],e)}function dn(t){return ge()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const un={},fn=t=>{const e=dn(t);return Object.values(un).filter(t=>t.canvas===e).pop()};class gn{constructor(t,e){const s=this.config=new sn(e),n=dn(t),o=fn(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas can be reused.");const r=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||ds(n)),this.platform.updateConfig(s);const l=this.platform.acquireContext(n,r.aspectRatio),h=l&&l.canvas,c=h&&h.height,d=h&&h.width;this.id=j(),this.ctx=l,this.canvas=h,this.width=d,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Ys,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=i(t=>this.update(t),r.resizeDelay||0),un[this.id]=this,l&&h?(a.listen(this,"complete",hn),a.listen(this,"progress",cn),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:s,_aspectRatio:n}=this;return $(t)?e&&n?n:s?i/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Se(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Gt(this.canvas,this.ctx),this}stop(){return a.stop(this),this}resize(t,e){a.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,s=this.canvas,n=i.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(s,t,e,n),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,Se(this,a,!0)&&(this.notifyPlugins("resize",{size:o}),Q(i.onResize,[this,o],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){J(this.options.scales||{},(t,e)=>{t.id=e})}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce((t,e)=>(t[e]=!1,t),{});let n=[];e&&(n=n.concat(Object.keys(e).map(t=>{const i=e[t],s=Ks(t,i),n="r"===s,o="x"===s;return{options:i,dposition:n?"chartArea":o?"bottom":"left",dtype:n?"radialLinear":o?"category":"linear"}}))),J(n,e=>{const n=e.options,o=n.id,a=Ks(o,n),r=K(n.type,e.dtype);void 0!==n.position&&rn(n.position,a)===rn(e.dposition)||(n.position=e.dposition),s[o]=!0;let l=null;if(o in i&&i[o].type===r)l=i[o];else{l=new($s.getScale(r))({id:o,type:r,ctx:this.ctx,chart:this}),i[l.id]=l}l.init(n,t)}),J(s,(t,e)=>{t||delete i[e]}),J(i,t=>{oi.configure(this,t,t.options),oi.addBox(this,t)})}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort((t,e)=>t.index-e.index),i>e){for(let t=e;te.length&&delete this._stacks,t.forEach((t,i)=>{0===e.filter(e=>e===t._dataset).length&&this._destroyDatasetMeta(i)})}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=e.length;i{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext());J(this.scales,t=>{oi.removeBox(this,t)});const s=this._animationsDisabled=!i.animation;this.ensureScalesHaveIDs(),this.buildOrUpdateScales();const n=new Set(Object.keys(this._listeners)),o=new Set(i.events);if(gt(n,o)&&!!this._responsiveListeners===i.responsive||(this.unbindEvents(),this.bindEvents()),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const a=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let t=0,e=this.data.datasets.length;t{t.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(ln("z","_idx")),this._lastEvent&&this._eventHandler(this._lastEvent,!0),this.render()}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;oi.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],J(this.boxes,t=>{i&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))},this),this._layers.forEach((t,e)=>{t._idx=e}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let e=0,i=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,s=!i.disabled,n=this.chartArea,o={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",o)&&(s&&Jt(e,{left:!1===i.left?0:n.left-i.left,right:!1===i.right?this.width:n.right+i.right,top:!1===i.top?0:n.top-i.top,bottom:!1===i.bottom?this.height:n.bottom+i.bottom}),t.controller.draw(),s&&te(e),o.cancelable=!1,this.notifyPlugins("afterDatasetDraw",o))}getElementsAtEventForMode(t,e,i,s){const n=Ee.modes[e];return"function"==typeof n?n(this,t,i,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let s=i.filter(t=>t&&t._dataset===e).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=Ue(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",n=this.getDatasetMeta(t),o=n.controller._resolveAnimations(void 0,s);ut(e)?(n.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),o.update(n,{visible:i}),this.update(e=>e.datasetIndex===t?s:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),a.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,i,s),t[i]=s},s=(t,e,i)=>{t.offsetX=e,t.offsetY=i,this._eventHandler(t)};J(this.options.events,t=>i(t,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(i,s)=>{e.addEventListener(this,i,s),t[i]=s},s=(i,s)=>{t[i]&&(e.removeEventListener(this,i,s),delete t[i])},n=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",n),i("detach",o)};o=(()=>{this.attached=!1,s("resize",n),this._stop(),this._resize(0,0),i("attach",a)}),e.isAttached(this.canvas)?a():o()}unbindEvents(){J(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},J(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const s=i?"set":"remove";let n,o,a,r;for("dataset"===e&&(n=this.getDatasetMeta(t[0].datasetIndex)).controller["_"+s+"DatasetHoverStyle"](),a=0,r=t.length;a{const i=this.getDatasetMeta(t);if(!i)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:i.data[e],index:e}});!tt(i,e)&&(this._active=i,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}_updateHoverStyles(t,e,i){const s=this.options.hover,n=(t,e)=>t.filter(t=>!e.some(e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)),o=n(e,t),a=i?t:n(t,e);o.length&&this.updateHoverStyle(o,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0},s=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",i,s))return;const n=this._handleEvent(t,e);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(n||i.changed)&&this.render(),this}_handleEvent(t,e){const{_active:i=[],options:s}=this,n=s.hover,o=e;let a=[],r=!1,l=null;return"mouseout"!==t.type&&(a=this.getElementsAtEventForMode(t,n.mode,n,o),l="click"===t.type?this._lastEvent:t),this._lastEvent=null,Qt(t,this.chartArea,this._minPadding)&&(Q(s.onHover,[t,a,this],this),"mouseup"!==t.type&&"click"!==t.type&&"contextmenu"!==t.type||Q(s.onClick,[t,a,this],this)),((r=!tt(a,i))||e)&&(this._active=a,this._updateHoverStyles(a,i,e)),this._lastEvent=l,r}}const pn=()=>J(gn.instances,t=>t._plugins.invalidate());function mn(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}Object.defineProperties(gn,{defaults:{enumerable:!0,value:_t},instances:{enumerable:!0,value:un},overrides:{enumerable:!0,value:pt},registry:{enumerable:!0,value:$s},version:{enumerable:!0,value:"3.6.0"},getChart:{enumerable:!0,value:fn},register:{enumerable:!0,value:(...t)=>{$s.add(...t),pn()}},unregister:{enumerable:!0,value:(...t)=>{$s.remove(...t),pn()}}});class xn{constructor(t){this.options=t||{}}formats(){return mn()}parse(t,e){return mn()}format(t,e){return mn()}add(t,e,i){return mn()}diff(t,e,i){return mn()}startOf(t,e,i){return mn()}endOf(t,e){return mn()}}xn.override=function(t){Object.assign(xn.prototype,t)};var bn={_date:xn};function _n(t){const e=t.iScale,i=function(t,e){if(!t._cache.$bar){const i=t.getMatchingVisibleMetas(e);let s=[];for(let e=0,n=i.length;et-e))}return t._cache.$bar}(e,t.type);let s,n,o,a,r=e._length;const l=()=>{32767!==o&&-32768!==o&&(ut(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(s=0,n=i.length;sMath.abs(r)&&(l=r,h=a),e[i.axis]=h,e._custom={barStart:l,barEnd:h,start:n,end:o,min:a,max:r}}(t,e,i,s):e[i.axis]=i.parse(t,s),e}function vn(t,e,i,s){const n=t.iScale,o=t.vScale,a=n.getLabels(),r=n===o,l=[];let h,c,d,u;for(h=i,c=i+s;ht.x,i="left",s="right"):(e=t.base=i?1:-1)}(c,e,o)*n,d===o&&(p-=c/2),h=p+c),p===e.getPixelForValue(o)){const t=Ot(c)*e.getLineWidthForValue(o)/2;p+=t,c-=t}return{size:c,base:p,head:h,center:h+c/2}}_calculateBarIndexPixels(t,e){const i=e.scale,s=this.options,n=s.skipNull,o=K(s.maxBarThickness,1/0);let a,r;if(e.grouped){const i=n?this._getStackCount(t):e.stackCount,l="flex"===s.barThickness?function(t,e,i,s){const n=e.pixels,o=n[t];let a=t>0?n[t-1]:null,r=t=0;--i)e=Math.max(e,t[i].size(this.resolveDataElementOptions(i))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,{xScale:i,yScale:s}=e,n=this.getParsed(t),o=i.getLabelForValue(n.x),a=s.getLabelForValue(n.y),r=n._custom;return{label:e.label,value:"("+o+", "+a+(r?", "+r:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a}=this._cachedMeta,r=this.resolveDataElementOptions(e,s),l=this.getSharedOptions(r),h=this.includeOptions(s,l),c=o.axis,d=a.axis;for(let r=e;r""}}}};class On extends Os{constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,s=this._cachedMeta;if(!1===this._parsing)s._parsed=i;else{let n,o,a=t=>+i[t];if(U(i[t])){const{key:t="value"}=this._parsing;a=(e=>+ct(i[e],t))}for(n=t,o=t+e;njt(t,r,l,!0)?1:Math.max(e,e*i,s,s*i),g=(t,e,s)=>jt(t,r,l,!0)?-1:Math.min(e,e*i,s,s*i),p=f(0,h,d),m=f(St,c,u),x=g(yt,h,d),b=g(yt+St,c,u);s=(p-x)/2,n=(m-b)/2,o=-(p+x)/2,a=-(m+b)/2}return{ratioX:s,ratioY:n,offsetX:o,offsetY:a}}(c,h,r),p=(i.width-o)/d,m=(i.height-o)/u,x=Math.max(Math.min(p,m)/2,0),b=Z(this.options.radius,x),_=(b-Math.max(b*r,0))/this._getVisibleDatasetWeightTotal();this.offsetX=f*b,this.offsetY=g*b,s.total=this.calculateTotal(),this.outerRadius=b-_*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-_*l,0),this.updateElements(n,0,n.length,t)}_circumference(t,e){const i=this.options,s=this._cachedMeta,n=this._getCircumference();return e&&i.animation.animateRotate||!this.chart.getDataVisibility(t)||null===s._parsed[t]||s.data[t].hidden?0:this.calculateCircumference(s._parsed[t]*n/vt)}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.chartArea,r=o.options.animation,l=(a.left+a.right)/2,h=(a.top+a.bottom)/2,c=n&&r.animateScale,d=c?0:this.innerRadius,u=c?0:this.outerRadius,f=this.resolveDataElementOptions(e,s),g=this.getSharedOptions(f),p=this.includeOptions(s,g);let m,x=this._getRotation();for(m=0;m0&&!isNaN(t)?vt*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=Ei(e._parsed[t],i.options.locale);return{label:s[t]||"",value:n}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,n,o,a,r;if(!t)for(s=0,n=i.data.datasets.length;s"spacing"!==t,_indexable:t=>"spacing"!==t},On.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label(t){let e=t.label;const i=": "+t.formattedValue;return Y(e)?(e=e.slice())[0]+=i:e+=i,e}}}}};class An extends Os{initialize(){this.enableOptionSharing=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:i,data:s=[],_dataset:n}=e,o=this.chart._animationsDisabled;let{start:a,count:r}=function(t,e,i){const s=e.length;let n=0,o=s;if(t._sorted){const{iScale:a,_parsed:r}=t,l=a.axis,{min:h,max:c,minDefined:d,maxDefined:u}=a.getUserBounds();d&&(n=$t(Math.min(re(r,a.axis,h).lo,i?s:re(e,l,a.getPixelForValue(h)).lo),0,s-1)),o=u?$t(Math.max(re(r,a.axis,c).hi+1,i?0:re(e,l,a.getPixelForValue(c)).hi+1),n,s)-n:s-n}return{start:n,count:o}}(e,s,o);this._drawStart=a,this._drawCount=r,function(t){const{xScale:e,yScale:i,_scaleRanges:s}=t,n={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!s)return t._scaleRanges=n,!0;const o=s.xmin!==e.min||s.xmax!==e.max||s.ymin!==i.min||s.ymax!==i.max;return Object.assign(s,n),o}(e)&&(a=0,r=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!n._decimated,i.points=s;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(i,void 0,{animated:!o,options:l},t),this.updateElements(s,a,r,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,h=this.resolveDataElementOptions(e,s),c=this.getSharedOptions(h),d=this.includeOptions(s,c),u=o.axis,f=a.axis,{spanGaps:g,segment:p}=this.options,m=Lt(g)?g:Number.POSITIVE_INFINITY,x=this.chart._animationsDisabled||n||"none"===s;let b=e>0&&this.getParsed(e-1);for(let h=e;h0&&i[u]-b[u]>m,p&&(g.parsed=i,g.raw=l.data[h]),d&&(g.options=c||this.resolveDataElementOptions(h,e.active?"active":s)),x||this.updateElement(e,h,g,s),b=i}this.updateSharedOptions(c,s,h)}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,n,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}An.id="line",An.defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1},An.overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};class Tn extends Os{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=Ei(e._parsed[t].r,i.options.locale);return{label:s[t]||"",value:n}}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),n=Math.max(s/2,0),o=(n-Math.max(i.cutoutPercentage?n/100*i.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=n-o*this.index,this.innerRadius=this.outerRadius-o}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=this.getDataset(),r=o.options.animation,l=this._cachedMeta.rScale,h=l.xCenter,c=l.yCenter,d=l.getIndexAngle(0)-.5*yt;let u,f=d;const g=360/this.countVisibleElements();for(u=0;u{!isNaN(t.data[s])&&this.chart.getDataVisibility(s)&&i++}),i}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?zt(this.resolveDataElementOptions(t,e).angle||i):0}}Tn.id="polarArea",Tn.defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0},Tn.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label:t=>t.chart.data.labels[t.dataIndex]+": "+t.formattedValue}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};class Ln extends On{}Ln.id="pie",Ln.defaults={cutout:0,rotation:0,circumference:360,radius:"100%"};class Rn extends Os{getLabelAndValue(t){const e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}update(t){const e=this._cachedMeta,i=e.dataset,s=e.data||[],n=e.iScale.getLabels();if(i.points=s,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:!0,_fullLoop:n.length===s.length,options:e};this.updateElement(i,void 0,o,t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,i,s){const n=this.getDataset(),o=this._cachedMeta.rScale,a="reset"===s;for(let r=e;r"",label:t=>"("+t.label+", "+t.formattedValue+")"}}},scales:{x:{type:"linear"},y:{type:"linear"}}};var In=Object.freeze({__proto__:null,BarController:Dn,BubbleController:Cn,DoughnutController:On,LineController:An,PolarAreaController:Tn,PieController:Ln,RadarController:Rn,ScatterController:En});function zn(t,e,i){const{startAngle:s,pixelMargin:n,x:o,y:a,outerRadius:r,innerRadius:l}=e;let h=n/r;t.beginPath(),t.arc(o,a,r,s-h,i+h),l>n?(h=n/l,t.arc(o,a,l,i+h,s-h,!0)):t.arc(o,a,n,i+St,s-St),t.closePath(),t.clip()}function Fn(t,e,i,s){const n=Be(t.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]);const o=(i-e)/2,a=Math.min(o,s*e/2),r=t=>{const e=(i-Math.min(o,t))*s/2;return $t(t,0,Math.min(o,e))};return{outerStart:r(n.outerStart),outerEnd:r(n.outerEnd),innerStart:$t(n.innerStart,0,a),innerEnd:$t(n.innerEnd,0,a)}}function Vn(t,e,i,s){return{x:i+t*Math.cos(e),y:s+t*Math.sin(e)}}function Bn(t,e,i,s,n){const{x:o,y:a,startAngle:r,pixelMargin:l,innerRadius:h}=e,c=Math.max(e.outerRadius+s+i-l,0),d=h>0?h+s+i+l:0;let u=0;const f=n-r;if(s){const t=((h>0?h-s:0)+(c>0?c-s:0))/2;u=(f-(0!==t?f*t/(t+s):f))/2}const g=(f-Math.max(.001,f*c-i/yt)/c)/2,p=r+g+u,m=n-g-u,{outerStart:x,outerEnd:b,innerStart:_,innerEnd:y}=Fn(e,d,c,m-p),v=c-x,w=c-b,M=p+x/v,k=m-b/w,S=d+_,P=d+y,D=p+_/S,C=m-y/P;if(t.beginPath(),t.arc(o,a,c,M,k),b>0){const e=Vn(w,k,o,a);t.arc(e.x,e.y,b,k,m+St)}const O=Vn(P,m,o,a);if(t.lineTo(O.x,O.y),y>0){const e=Vn(P,C,o,a);t.arc(e.x,e.y,y,m+St,C+Math.PI)}if(t.arc(o,a,d,m-y/d,p+_/d,!0),_>0){const e=Vn(S,D,o,a);t.arc(e.x,e.y,_,D+Math.PI,p-St)}const A=Vn(v,p,o,a);if(t.lineTo(A.x,A.y),x>0){const e=Vn(v,M,o,a);t.arc(e.x,e.y,x,p-St,M)}t.closePath()}function Wn(t,e,i,s,n){const{options:o}=e,a="inner"===o.borderAlign;o.borderWidth&&(a?(t.lineWidth=2*o.borderWidth,t.lineJoin="round"):(t.lineWidth=o.borderWidth,t.lineJoin="bevel"),e.fullCircles&&function(t,e,i){const{x:s,y:n,startAngle:o,pixelMargin:a,fullCircles:r}=e,l=Math.max(e.outerRadius-a,0),h=e.innerRadius+a;let c;for(i&&zn(t,e,o+vt),t.beginPath(),t.arc(s,n,h,o+vt,o,!0),c=0;c=vt||jt(n,a,r))&&(o>=l+d&&o<=h+d)}getCenterPoint(t){const{x:e,y:i,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius","circumference"],t),{offset:r,spacing:l}=this.options,h=(s+n)/2,c=(o+a+l+r)/2;return{x:e+Math.cos(h)*c,y:i+Math.sin(h)*c}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:i}=this,s=(e.offset||0)/2,n=(e.spacing||0)/2;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=i>vt?Math.floor(i/vt):0,0===i||this.innerRadius<0||this.outerRadius<0)return;t.save();let o=0;if(s){o=s/2;const e=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(e)*o,Math.sin(e)*o),this.circumference>=yt&&(o=s)}t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor;const a=function(t,e,i,s){const{fullCircles:n,startAngle:o,circumference:a}=e;let r=e.endAngle;if(n){Bn(t,e,i,s,o+vt);for(let e=0;er&&o>r;return{count:s,start:l,loop:e.loop,ilen:h(a+(h?r-t:t))%o,_=()=>{f!==g&&(t.lineTo(m,g),t.lineTo(m,f),t.lineTo(m,p))};for(l&&(d=n[b(0)],t.moveTo(d.x,d.y)),c=0;c<=r;++c){if((d=n[b(c)]).skip)continue;const e=d.x,i=d.y,s=0|e;s===u?(ig&&(g=i),m=(x*m+e)/++x):(_(),t.lineTo(e,i),u=s,x=0,f=g=i),p=i}_()}function Xn(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||i)?Un:Yn}Nn.id="arc",Nn.defaults={borderAlign:"center",borderColor:"#fff",borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0},Nn.defaultRoutes={backgroundColor:"backgroundColor"};const qn="function"==typeof Path2D;function Kn(t,e,i,s){qn&&!e.options.segment?function(t,e,i,s){let n=e._path;n||(n=e._path=new Path2D,e.path(n,i,s)&&n.closePath()),Hn(t,e.options),t.stroke(n)}(t,e,i,s):function(t,e,i,s){const{segments:n,options:o}=e,a=Xn(e);for(const r of n)Hn(t,o,r.style),t.beginPath(),a(t,e,r,{start:i,end:i+s-1})&&t.closePath(),t.stroke()}(t,e,i,s)}class Gn extends As{constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const i=this.options;if((i.tension||"monotone"===i.cubicInterpolationMode)&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;Si(this._points,i,t,s,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=$i(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],n=this.points,o=ji(this,{property:e,start:s,end:s});if(!o.length)return;const a=[],r=function(t){return t.stepped?Ti:t.tension||"monotone"===t.cubicInterpolationMode?Li:Ai}(i);let l,h;for(l=0,h=o.length;l"borderDash"!==t&&"fill"!==t};class Qn extends As{constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,e,i){const s=this.options,{x:n,y:o}=this.getProps(["x","y"],i);return Math.pow(t-n,2)+Math.pow(e-o,2)=a.left&&e<=a.right)&&(o||i>=a.top&&i<=a.bottom)}function so(t,e){t.rect(e.x,e.y,e.w,e.h)}function no(t,e,i={}){const s=t.x!==i.x?-e:0,n=t.y!==i.y?-e:0,o=(t.x+t.w!==i.x+i.w?e:0)-s,a=(t.y+t.h!==i.y+i.h?e:0)-n;return{x:t.x+s,y:t.y+n,w:t.w+o,h:t.h+a,radius:t.radius}}Qn.id="point",Qn.defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0},Qn.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};class oo extends As{constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:e,options:{borderColor:i,backgroundColor:s}}=this,{inner:n,outer:o}=eo(this),a=(r=o.radius).topLeft||r.topRight||r.bottomLeft||r.bottomRight?oe:so;var r;t.save(),o.w===n.w&&o.h===n.h||(t.beginPath(),a(t,no(o,e,n)),t.clip(),a(t,no(n,-e,o)),t.fillStyle=i,t.fill("evenodd")),t.beginPath(),a(t,no(n,e)),t.fillStyle=s,t.fill(),t.restore()}inRange(t,e,i){return io(this,t,e,i)}inXRange(t,e){return io(this,t,null,e)}inYRange(t,e){return io(this,null,t,e)}getCenterPoint(t){const{x:e,y:i,base:s,horizontal:n}=this.getProps(["x","y","base","horizontal"],t);return{x:n?(e+s)/2:e,y:n?i:(i+s)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}}oo.id="bar",oo.defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0},oo.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};var ao=Object.freeze({__proto__:null,ArcElement:Nn,LineElement:Gn,PointElement:Qn,BarElement:oo});function ro(t){if(t._decimated){const e=t._data;delete t._decimated,delete t._data,Object.defineProperty(t,"data",{value:e})}}function lo(t){t.data.datasets.forEach(t=>{ro(t)})}var ho={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,i)=>{if(!i.enabled)return void lo(t);const s=t.width;t.data.datasets.forEach((e,n)=>{const{_data:o,indexAxis:a}=e,r=t.getDatasetMeta(n),l=o||e.data;if("y"===$e([a,t.options.indexAxis]))return;if("line"!==r.type)return;const h=t.scales[r.xAxisID];if("linear"!==h.type&&"time"!==h.type)return;if(t.options.parsing)return;let{start:c,count:d}=function(t,e){const i=e.length;let s,n=0;const{iScale:o}=t,{min:a,max:r,minDefined:l,maxDefined:h}=o.getUserBounds();return l&&(n=$t(re(e,o.axis,a).lo,0,i-1)),{start:n,count:s=h?$t(re(e,o.axis,r).hi+1,n,i)-n:i-n}}(r,l);if(d<=(i.threshold||4*s))return void ro(e);let u;switch($(o)&&(e._data=l,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),i.algorithm){case"lttb":u=function(t,e,i,s,n){const o=n.samples||s;if(o>=i)return t.slice(e,e+i);const a=[],r=(i-2)/(o-2);let l=0;const h=e+i-1;let c,d,u,f,g,p=e;for(a[l++]=t[p],c=0;cu&&(u=f,d=t[s],g=s);a[l++]=d,p=g}return a[l++]=t[h],a}(l,c,d,s,i);break;case"min-max":u=function(t,e,i,s){let n,o,a,r,l,h,c,d,u,f,g=0,p=0;const m=[],x=e+i-1,b=t[e].x,_=t[x].x-b;for(n=e;nf&&(f=r,c=n),g=(p*g+o.x)/++p;else{const i=n-1;if(!$(h)&&!$(c)){const e=Math.min(h,c),s=Math.max(h,c);e!==d&&e!==i&&m.push({...t[e],x:g}),s!==d&&s!==i&&m.push({...t[s],x:g})}n>0&&i!==d&&m.push(t[i]),m.push(o),l=e,p=0,u=f=r,h=c=d=n}}return m}(l,c,d,s);break;default:throw new Error(`Unsupported decimation algorithm '${i.algorithm}'`)}e._decimated=u})},destroy(t){lo(t)}};function co(t,e,i){const s=function(t){const e=t.options,i=e.fill;let s=K(i&&i.target,i);return void 0===s&&(s=!!e.backgroundColor),!1!==s&&null!==s&&(!0===s?"origin":s)}(t);if(U(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return X(n)&&Math.floor(n)===n?("-"!==s[0]&&"+"!==s[0]||(n=e+n),!(n===e||n<0||n>=i)&&n):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}class uo{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){const{x:s,y:n,radius:o}=this;return e=e||{start:0,end:vt},t.arc(s,n,o,e.end,e.start,!0),!i.bounds}interpolate(t){const{x:e,y:i,radius:s}=this,n=t.angle;return{x:e+Math.cos(n)*s,y:i+Math.sin(n)*s,angle:n}}}function fo(t){return(t.scale||{}).getPointPositionForValue?function(t){const{scale:e,fill:i}=t,s=e.options,n=e.getLabels().length,o=[],a=s.reverse?e.max:e.min,r=s.reverse?e.min:e.max;let l,h,c;if(c="start"===i?a:"end"===i?r:U(i)?i.value:e.getBaseValue(),s.grid.circular)return h=e.getPointPositionForValue(0,a),new uo({x:h.x,y:h.y,radius:e.getDistanceFromCenterForValue(c)});for(l=0;lt;e--){const t=i[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function po(t,e,i){const s=[];for(let n=0;n=s&&n<=h){r=n===s,l=n===h;break}}return{first:r,last:l,point:s}}function xo(t){const{chart:e,fill:i,line:s}=t;if(X(i))return function(t,e){const i=t.getDatasetMeta(e);return i&&t.isDatasetVisible(e)?i.dataset:null}(e,i);if("stack"===i)return function(t){const{scale:e,index:i,line:s}=t,n=[],o=s.segments,a=s.points,r=function(t,e){const i=[],s=t.getMatchingVisibleMetas("line");for(let t=0;t{e=go(t,e,n);const a=n[t],r=n[e];null!==s?(o.push({x:a.x,y:s}),o.push({x:r.x,y:s})):null!==i&&(o.push({x:i,y:a.y}),o.push({x:i,y:r.y}))}),o}(t,e),i.length?new Gn({points:i,options:{tension:0},_loop:s,_fullLoop:s}):null}function _o(t,e,i){let s=t[e].fill;const n=[e];let o;if(!i)return s;for(;!1!==s&&-1===n.indexOf(s);){if(!X(s))return s;if(!(o=t[s]))return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function yo(t,e,i){t.beginPath(),e.path(t),t.lineTo(e.last().x,i),t.lineTo(e.first().x,i),t.closePath(),t.clip()}function vo(t,e,i,s){if(s)return;let n=e[t],o=i[t];return"angle"===t&&(n=Ht(n),o=Ht(o)),{property:t,start:n,end:o}}function wo(t,e,i,s){return t&&e?s(t[i],e[i]):t?t[i]:e?e[i]:0}function Mo(t,e,i){const{top:s,bottom:n}=e.chart.chartArea,{property:o,start:a,end:r}=i||{};"x"===o&&(t.beginPath(),t.rect(a,s,r-a,n-s),t.clip())}function ko(t,e,i,s){const n=e.interpolate(i,s);n&&t.lineTo(n.x,n.y)}function So(t,e){const{line:i,target:s,property:n,color:o,scale:a}=e,r=function(t,e,i){const s=t.segments,n=t.points,o=e.points,a=[];for(const t of s){let{start:s,end:r}=t;r=go(s,r,n);const l=vo(i,n[s],n[r],t.loop);if(!e.segments){a.push({source:t,target:l,start:n[s],end:n[r]});continue}const h=ji(e,l);for(const e of h){const s=vo(i,o[e.start],o[e.end],e.loop),r=Hi(t,n,s);for(const t of r)a.push({source:t,target:e,start:{[i]:wo(l,s,"start",Math.max)},end:{[i]:wo(l,s,"end",Math.min)}})}}return a}(i,s,n);for(const{source:e,target:l,start:h,end:c}of r){const{style:{backgroundColor:r=o}={}}=e,d=!0!==s;t.save(),t.fillStyle=r,Mo(t,a,d&&vo(n,h,c)),t.beginPath();const u=!!i.pathSegment(t,e);let f;if(d){u?t.closePath():ko(t,s,c,n);const e=!!s.pathSegment(t,l,{move:u,reverse:!0});(f=u&&e)||ko(t,s,h,n)}t.closePath(),t.fill(f?"evenodd":"nonzero"),t.restore()}}function Po(t,e,i){const s=xo(e),{line:n,scale:o,axis:a}=e,r=n.options,l=r.fill,h=r.backgroundColor,{above:c=h,below:d=h}=l||{};s&&n.points.length&&(Jt(t,i),function(t,e){const{line:i,target:s,above:n,below:o,area:a,scale:r}=e,l=i._loop?"angle":e.axis;t.save(),"x"===l&&o!==n&&(yo(t,s,a.top),So(t,{line:i,target:s,color:n,scale:r,property:l}),t.restore(),t.save(),yo(t,s,a.bottom)),So(t,{line:i,target:s,color:o,scale:r,property:l}),t.restore()}(t,{line:n,target:s,above:c,below:d,area:i,scale:o,axis:a}),te(t))}var Do={id:"filler",afterDatasetsUpdate(t,e,i){const s=(t.data.datasets||[]).length,n=[];let o,a,r,l;for(a=0;a=0;--e){const i=n[e].$filler;i&&(i.line.updateControlPoints(o,i.axis),s&&Po(t.ctx,i,o))}},beforeDatasetsDraw(t,e,i){if("beforeDatasetsDraw"!==i.drawTime)return;const s=t.getSortedVisibleDatasetMetas();for(let e=s.length-1;e>=0;--e){const i=s[e].$filler;i&&Po(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,i){const s=e.meta.$filler;s&&!1!==s.fill&&"beforeDatasetDraw"===i.drawTime&&Po(t.ctx,s,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const Co=(t,e)=>{let{boxHeight:i=e,boxWidth:s=e}=t;return t.usePointStyle&&(i=Math.min(i,e),s=Math.min(s,e)),{boxWidth:s,boxHeight:i,itemHeight:Math.max(e,i)}},Oo=(t,e)=>null!==t&&null!==e&&t.datasetIndex===e.datasetIndex&&t.index===e.index;class Ao extends As{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=Q(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(e=>t.filter(e,this.chart.data))),t.sort&&(e=e.sort((e,i)=>t.sort(e,i,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const i=t.labels,s=je(i.font),n=s.size,o=this._computeTitleHeight(),{boxWidth:a,itemHeight:r}=Co(i,n);let l,h;e.font=s.string,this.isHorizontal()?(l=this.maxWidth,h=this._fitRows(o,n,a,r)+10):(h=this.maxHeight,l=this._fitCols(o,n,a,r)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:n,maxWidth:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.lineWidths=[0],h=s+a;let c=t;n.textAlign="left",n.textBaseline="middle";let d=-1,u=-h;return this.legendItems.forEach((t,f)=>{const g=i+e/2+n.measureText(t.text).width;(0===f||l[l.length-1]+g+2*a>o)&&(c+=h,l[l.length-(f>0?0:1)]=0,u+=h,d++),r[f]={left:0,top:u,row:d,width:g,height:s},l[l.length-1]+=g+a}),c}_fitCols(t,e,i,s){const{ctx:n,maxHeight:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.columnSizes=[],h=o-t;let c=a,d=0,u=0,f=0,g=0;return this.legendItems.forEach((t,o)=>{const p=i+e/2+n.measureText(t.text).width;o>0&&u+s+2*a>h&&(c+=d+a,l.push({width:d,height:u}),f+=d+a,g++,d=u=0),r[o]={left:f,top:u,col:g,width:p,height:s},d=Math.max(d,p),u+=s+a}),c+=d,l.push({width:d,height:u}),c}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:o}}=this,a=Fi(o,this.left,this.width);if(this.isHorizontal()){let o=0,r=n(i,this.left+s,this.right-this.lineWidths[o]);for(const l of e)o!==l.row&&(o=l.row,r=n(i,this.left+s,this.right-this.lineWidths[o])),l.top+=this.top+t+s,l.left=a.leftForLtr(a.x(r),l.width),r+=l.width+s}else{let o=0,r=n(i,this.top+t+s,this.bottom-this.columnSizes[o].height);for(const l of e)l.col!==o&&(o=l.col,r=n(i,this.top+t+s,this.bottom-this.columnSizes[o].height)),l.top=r,l.left+=this.left+s,l.left=a.leftForLtr(a.x(l.left),l.width),r+=l.height+s}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;Jt(t,this),this._draw(),te(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:a,labels:r}=t,l=_t.color,h=Fi(t.rtl,this.left,this.width),c=je(r.font),{color:d,padding:u}=r,f=c.size,g=f/2;let p;this.drawTitle(),s.textAlign=h.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:m,boxHeight:x,itemHeight:b}=Co(r,f),_=this.isHorizontal(),y=this._computeTitleHeight();p=_?{x:n(a,this.left+u,this.right-i[0]),y:this.top+u+y,line:0}:{x:this.left+u,y:n(a,this.top+y+u,this.bottom-e[0].height),line:0},Vi(this.ctx,t.textDirection);const v=b+u;this.legendItems.forEach((w,M)=>{s.strokeStyle=w.fontColor||d,s.fillStyle=w.fontColor||d;const k=s.measureText(w.text).width,S=h.textAlign(w.textAlign||(w.textAlign=r.textAlign)),P=m+g+k;let D=p.x,C=p.y;h.setWidth(this.width),_?M>0&&D+P+u>this.right&&(C=p.y+=v,p.line++,D=p.x=n(a,this.left+u,this.right-i[p.line])):M>0&&C+v>this.bottom&&(D=p.x=D+e[p.line].width+u,p.line++,C=p.y=n(a,this.top+y+u,this.bottom-e[p.line].height)),function(t,e,i){if(isNaN(m)||m<=0||isNaN(x)||x<0)return;s.save();const n=K(i.lineWidth,1);if(s.fillStyle=K(i.fillStyle,l),s.lineCap=K(i.lineCap,"butt"),s.lineDashOffset=K(i.lineDashOffset,0),s.lineJoin=K(i.lineJoin,"miter"),s.lineWidth=n,s.strokeStyle=K(i.strokeStyle,l),s.setLineDash(K(i.lineDash,[])),r.usePointStyle){const o={radius:m*Math.SQRT2/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:n},a=h.xPlus(t,m/2);Zt(s,o,a,e+g)}else{const o=e+Math.max((f-x)/2,0),a=h.leftForLtr(t,m),r=Ne(i.borderRadius);s.beginPath(),Object.values(r).some(t=>0!==t)?oe(s,{x:a,y:o,w:m,h:x,radius:r}):s.rect(a,o,m,x),s.fill(),0!==n&&s.stroke()}s.restore()}(h.x(D),C,w),D=o(S,D+m+g,_?D+P:this.right,t.rtl),function(t,e,i){se(s,i.text,t,e+b/2,c,{strikethrough:i.hidden,textAlign:h.textAlign(i.textAlign)})}(h.x(D),C,w),_?p.x+=P+u:p.y+=v}),Bi(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=je(e.font),o=He(e.padding);if(!e.display)return;const a=Fi(t.rtl,this.left,this.width),r=this.ctx,l=e.position,h=i.size/2,c=o.top+h;let d,u=this.left,f=this.width;if(this.isHorizontal())f=Math.max(...this.lineWidths),d=this.top+c,u=n(t.align,u,this.right-f);else{const e=this.columnSizes.reduce((t,e)=>Math.max(t,e.height),0);d=c+n(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const g=n(l,u,u+f);r.textAlign=a.textAlign(s(l)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=i.string,se(r,e.text,g,d,i)}_computeTitleHeight(){const t=this.options.title,e=je(t.font),i=He(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,n;if(t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom)for(n=this.legendHitBoxes,i=0;i=(s=n[i]).left&&t<=s.left+s.width&&e>=s.top&&e<=s.top+s.height)return this.legendItems[i];return null}handleEvent(t){const e=this.options;if(!function(t,e){if("mousemove"===t&&(e.onHover||e.onLeave))return!0;if(e.onClick&&("click"===t||"mouseup"===t))return!0;return!1}(t.type,e))return;const i=this._getLegendItemAt(t.x,t.y);if("mousemove"===t.type){const s=this._hoveredItem,n=Oo(s,i);s&&!n&&Q(e.onLeave,[t,s,this],this),this._hoveredItem=i,i&&!n&&Q(e.onHover,[t,i,this],this)}else i&&Q(e.onClick,[t,i,this],this)}}var To={id:"legend",_element:Ao,start(t,e,i){const s=t.legend=new Ao({ctx:t.ctx,options:i,chart:t});oi.configure(t,s,i),oi.addBox(t,s)},stop(t){oi.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,i){const s=t.legend;oi.configure(t,s,i),s.options=i},afterUpdate(t){const e=t.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(t,e){e.replay||t.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,e,i){const s=e.datasetIndex,n=i.chart;n.isDatasetVisible(s)?(n.hide(s),e.hidden=!0):(n.show(s),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:i,pointStyle:s,textAlign:n,color:o}}=t.legend.options;return t._getSortedDatasetMetas().map(t=>{const a=t.controller.getStyle(i?0:void 0),r=He(a.borderWidth);return{text:e[t.index].label,fillStyle:a.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:a.borderCapStyle,lineDash:a.borderDash,lineDashOffset:a.borderDashOffset,lineJoin:a.borderJoinStyle,lineWidth:(r.width+r.height)/4,strokeStyle:a.borderColor,pointStyle:s||a.pointStyle,rotation:a.rotation,textAlign:n||a.textAlign,borderRadius:0,datasetIndex:t.index}},this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class Lo extends As{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this.options;if(this.left=0,this.top=0,!i.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const s=Y(i.text)?i.text.length:1;this._padding=He(i.padding);const n=s*je(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=n:this.width=n}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:s,right:o,options:a}=this,r=a.align;let l,h,c,d=0;return this.isHorizontal()?(h=n(r,i,o),c=e+t,l=o-i):("left"===a.position?(h=i+t,c=n(r,s,e),d=-.5*yt):(h=o-t,c=n(r,e,s),d=.5*yt),l=s-e),{titleX:h,titleY:c,maxWidth:l,rotation:d}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=je(e.font),n=i.lineHeight/2+this._padding.top,{titleX:o,titleY:a,maxWidth:r,rotation:l}=this._drawArgs(n);se(t,e.text,0,0,i,{color:e.color,maxWidth:r,rotation:l,textAlign:s(e.align),textBaseline:"middle",translation:[o,a]})}}var Ro={id:"title",_element:Lo,start(t,e,i){!function(t,e){const i=new Lo({ctx:t.ctx,options:e,chart:t});oi.configure(t,i,e),oi.addBox(t,i),t.titleBlock=i}(t,i)},stop(t){const e=t.titleBlock;oi.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){const s=t.titleBlock;oi.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Eo=new WeakMap;var Io={id:"subtitle",start(t,e,i){const s=new Lo({ctx:t.ctx,options:i,chart:t});oi.configure(t,s,i),oi.addBox(t,s),Eo.set(t,s)},stop(t){oi.removeBox(t,Eo.get(t)),Eo.delete(t)},beforeUpdate(t,e,i){const s=Eo.get(t);oi.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const zo={average(t){if(!t.length)return!1;let e,i,s=0,n=0,o=0;for(e=0,i=t.length;e-1?t.split("\n"):t}function Bo(t,e){const{element:i,datasetIndex:s,index:n}=e,o=t.getDatasetMeta(s).controller,{label:a,value:r}=o.getLabelAndValue(n);return{chart:t,label:a,parsed:o.getParsed(n),raw:t.data.datasets[s].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:i}}function Wo(t,e){const i=t._chart.ctx,{body:s,footer:n,title:o}=t,{boxWidth:a,boxHeight:r}=e,l=je(e.bodyFont),h=je(e.titleFont),c=je(e.footerFont),d=o.length,u=n.length,f=s.length,g=He(e.padding);let p=g.height,m=0,x=s.reduce((t,e)=>t+e.before.length+e.lines.length+e.after.length,0);if(x+=t.beforeBody.length+t.afterBody.length,d&&(p+=d*h.lineHeight+(d-1)*e.titleSpacing+e.titleMarginBottom),x){p+=f*(e.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(x-f)*l.lineHeight+(x-1)*e.bodySpacing}u&&(p+=e.footerMarginTop+u*c.lineHeight+(u-1)*e.footerSpacing);let b=0;const _=function(t){m=Math.max(m,i.measureText(t).width+b)};return i.save(),i.font=h.string,J(t.title,_),i.font=l.string,J(t.beforeBody.concat(t.afterBody),_),b=e.displayColors?a+2+e.boxPadding:0,J(s,t=>{J(t.before,_),J(t.lines,_),J(t.after,_)}),b=0,i.font=c.string,J(t.footer,_),i.restore(),{width:m+=g.width,height:p}}function No(t,e,i,s){const{x:n,width:o}=i,{width:a,chartArea:{left:r,right:l}}=t;let h="center";return"center"===s?h=n<=(r+l)/2?"left":"right":n<=o/2?h="left":n>=a-o/2&&(h="right"),function(t,e,i,s){const{x:n,width:o}=s,a=i.caretSize+i.caretPadding;return"left"===t&&n+o+a>e.width||"right"===t&&n-o-a<0||void 0}(h,t,e,i)&&(h="center"),h}function Ho(t,e,i){const s=e.yAlign||function(t,e){const{y:i,height:s}=e;return it.height-s/2?"bottom":"center"}(t,i);return{xAlign:e.xAlign||No(t,e,i,s),yAlign:s}}function jo(t,e,i,s){const{caretSize:n,caretPadding:o,cornerRadius:a}=t,{xAlign:r,yAlign:l}=i,h=n+o,{topLeft:c,topRight:d,bottomLeft:u,bottomRight:f}=Ne(a);let g=function(t,e){let{x:i,width:s}=t;return"right"===e?i-=s:"center"===e&&(i-=s/2),i}(e,r);const p=function(t,e,i){let{y:s,height:n}=t;return"top"===e?s+=i:s-="bottom"===e?n+i:n/2,s}(e,l,h);return"center"===l?"left"===r?g+=h:"right"===r&&(g-=h):"left"===r?g-=Math.max(c,u)+o:"right"===r&&(g+=Math.max(d,f)+o),{x:$t(g,0,s.width-e.width),y:$t(p,0,s.height-e.height)}}function $o(t,e,i){const s=He(i.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-s.right:t.x+s.left}function Yo(t){return Fo([],Vo(t))}function Uo(t,e){const i=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return i?t.override(i):t}class Xo extends As{constructor(t){super(),this.opacity=0,this._active=[],this._chart=t._chart,this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this._chart,i=this.options.setContext(this.getContext()),s=i.enabled&&e.options.animation&&i.animations,n=new ms(this._chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(n)),n}getContext(){return this.$context||(this.$context=(t=this._chart.getContext(),e=this,i=this._tooltipItems,Ue(t,{tooltip:e,tooltipItems:i,type:"tooltip"})));var t,e,i}getTitle(t,e){const{callbacks:i}=e,s=i.beforeTitle.apply(this,[t]),n=i.title.apply(this,[t]),o=i.afterTitle.apply(this,[t]);let a=[];return a=Fo(a,Vo(s)),a=Fo(a,Vo(n)),a=Fo(a,Vo(o))}getBeforeBody(t,e){return Yo(e.callbacks.beforeBody.apply(this,[t]))}getBody(t,e){const{callbacks:i}=e,s=[];return J(t,t=>{const e={before:[],lines:[],after:[]},n=Uo(i,t);Fo(e.before,Vo(n.beforeLabel.call(this,t))),Fo(e.lines,n.label.call(this,t)),Fo(e.after,Vo(n.afterLabel.call(this,t))),s.push(e)}),s}getAfterBody(t,e){return Yo(e.callbacks.afterBody.apply(this,[t]))}getFooter(t,e){const{callbacks:i}=e,s=i.beforeFooter.apply(this,[t]),n=i.footer.apply(this,[t]),o=i.afterFooter.apply(this,[t]);let a=[];return a=Fo(a,Vo(s)),a=Fo(a,Vo(n)),a=Fo(a,Vo(o))}_createItems(t){const e=this._active,i=this._chart.data,s=[],n=[],o=[];let a,r,l=[];for(a=0,r=e.length;at.filter(e,s,n,i))),t.itemSort&&(l=l.sort((e,s)=>t.itemSort(e,s,i))),J(l,e=>{const i=Uo(t.callbacks,e);s.push(i.labelColor.call(this,e)),n.push(i.labelPointStyle.call(this,e)),o.push(i.labelTextColor.call(this,e))}),this.labelColors=s,this.labelPointStyles=n,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let n,o=[];if(s.length){const t=zo[i.position].call(this,s,this._eventPosition);o=this._createItems(i),this.title=this.getTitle(o,i),this.beforeBody=this.getBeforeBody(o,i),this.body=this.getBody(o,i),this.afterBody=this.getAfterBody(o,i),this.footer=this.getFooter(o,i);const e=this._size=Wo(this,i),a=Object.assign({},t,e),r=Ho(this._chart,i,a),l=jo(i,a,r,this._chart);this.xAlign=r.xAlign,this.yAlign=r.yAlign,n={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(n={opacity:0});this._tooltipItems=o,this.$context=void 0,n&&this._resolveAnimations().update(this,n),t&&i.external&&i.external.call(this,{chart:this._chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const n=this.getCaretPosition(t,i,s);e.lineTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:n}=this,{caretSize:o,cornerRadius:a}=i,{topLeft:r,topRight:l,bottomLeft:h,bottomRight:c}=Ne(a),{x:d,y:u}=t,{width:f,height:g}=e;let p,m,x,b,_,y;return"center"===n?(_=u+g/2,"left"===s?(m=(p=d)-o,b=_+o,y=_-o):(m=(p=d+f)+o,b=_-o,y=_+o),x=p):(m="left"===s?d+Math.max(r,h)+o:"right"===s?d+f-Math.max(l,c)-o:this.caretX,"top"===n?(_=(b=u)-o,p=m-o,x=m+o):(_=(b=u+g)+o,p=m+o,x=m-o),y=b),{x1:p,x2:m,x3:x,y1:b,y2:_,y3:y}}drawTitle(t,e,i){const s=this.title,n=s.length;let o,a,r;if(n){const l=Fi(i.rtl,this.x,this.width);for(t.x=$o(this,i.titleAlign,i),e.textAlign=l.textAlign(i.titleAlign),e.textBaseline="middle",o=je(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=o.string,r=0;r0!==t)?(t.beginPath(),t.fillStyle=n.multiKeyBackground,oe(t,{x:e,y:g,w:l,h:r,radius:a}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),oe(t,{x:i,y:g+1,w:l-2,h:r-2,radius:a}),t.fill()):(t.fillStyle=n.multiKeyBackground,t.fillRect(e,g,l,r),t.strokeRect(e,g,l,r),t.fillStyle=o.backgroundColor,t.fillRect(i,g+1,l-2,r-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:n,bodyAlign:o,displayColors:a,boxHeight:r,boxWidth:l,boxPadding:h}=i,c=je(i.bodyFont);let d=c.lineHeight,u=0;const f=Fi(i.rtl,this.x,this.width),g=function(i){e.fillText(i,f.x(t.x+u),t.y+d/2),t.y+=d+n},p=f.textAlign(o);let m,x,b,_,y,v,w;for(e.textAlign=o,e.textBaseline="middle",e.font=c.string,t.x=$o(this,p,i),e.fillStyle=i.bodyColor,J(this.beforeBody,g),u=a&&"right"!==p?"center"===o?l/2+h:l+2+h:0,_=0,v=s.length;_0&&e.stroke()}_updateAnimationTarget(t){const e=this._chart,i=this.$animations,s=i&&i.x,n=i&&i.y;if(s||n){const i=zo[t.position].call(this,this._active,this._eventPosition);if(!i)return;const o=this._size=Wo(this,t),a=Object.assign({},i,this._size),r=Ho(e,t,a),l=jo(t,a,r,e);s._to===l.x&&n._to===l.y||(this.xAlign=r.xAlign,this.yAlign=r.yAlign,this.width=o.width,this.height=o.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,l))}}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},n={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const o=He(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(n,t,s,e),Vi(t,e.textDirection),n.y+=o.top,this.drawTitle(n,t,e),this.drawBody(n,t,e),this.drawFooter(n,t,e),Bi(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map(({datasetIndex:t,index:e})=>{const i=this._chart.getDatasetMeta(t);if(!i)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:i.data[e],index:e}}),n=!tt(i,s),o=this._positionChanged(s,e);(n||o)&&(this._active=s,this._eventPosition=e,this.update(!0))}handleEvent(t,e){const i=this.options,s=this._active||[];let n=!1,o=[];"mouseout"!==t.type&&(o=this._chart.getElementsAtEventForMode(t,i.mode,i,e),i.reverse&&o.reverse());const a=this._positionChanged(o,t);return(n=e||!tt(o,s)||a)&&(this._active=o,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),n}_positionChanged(t,e){const{caretX:i,caretY:s,options:n}=this,o=zo[n.position].call(this,t,e);return!1!==o&&(i!==o.x||s!==o.y)}}Xo.positioners=zo;var qo={id:"tooltip",_element:Xo,positioners:zo,afterInit(t,e,i){i&&(t.tooltip=new Xo({_chart:t,options:i}))},beforeUpdate(t,e,i){t.tooltip&&t.tooltip.initialize(i)},reset(t,e,i){t.tooltip&&t.tooltip.initialize(i)},afterDraw(t){const e=t.tooltip,i={tooltip:e};!1!==t.notifyPlugins("beforeTooltipDraw",i)&&(e&&e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i))},afterEvent(t,e){if(t.tooltip){const i=e.replay;t.tooltip.handleEvent(e.event,i)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:{beforeTitle:H,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,s=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(s>0&&e.dataIndex"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},Ko=Object.freeze({__proto__:null,Decimation:ho,Filler:Do,Legend:To,SubTitle:Io,Title:Ro,Tooltip:qo});const Go=(t,e,i)=>"string"==typeof e?t.push(e)-1:isNaN(e)?null:i;const Zo=(t,e)=>null===t?null:$t(Math.round(t),0,e);class Qo extends Hs{constructor(t){super(t),this._startValue=void 0,this._valueRange=0}parse(t,e){if($(t))return null;const i=this.getLabels();return e=isFinite(e)&&i[e]===t?e:function(t,e,i){const s=t.indexOf(e);return-1===s?Go(t,e,i):s!==t.lastIndexOf(e)?i:s}(i,t,K(e,t)),Zo(e,i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(i=0),e||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,e=this.max,i=this.options.offset,s=[];let n=this.getLabels();n=0===t&&e===n.length-1?n:n.slice(t,e+1),this._valueRange=Math.max(n.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let i=t;i<=e;i++)s.push({value:i});return s}getLabelForValue(t){const e=this.getLabels();return t>=0&&te.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function Jo(t,e,{horizontal:i,minRotation:s}){const n=zt(s),o=(i?Math.sin(n):Math.cos(n))||.001,a=.75*e*(""+t).length;return Math.min(e/o,a)}Qo.id="category",Qo.defaults={ticks:{callback:Qo.prototype.getLabelForValue}};class ta extends Hs{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return $(t)?null:("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:s,max:n}=this;const o=t=>s=e?s:t,a=t=>n=i?n:t;if(t){const t=Ot(s),e=Ot(n);t<0&&e<0?a(0):t>0&&e>0&&o(0)}if(s===n){let e=1;(n>=Number.MAX_SAFE_INTEGER||s<=Number.MIN_SAFE_INTEGER)&&(e=Math.abs(.05*n)),a(n+e),t||o(s-e)}this.min=s,this.max=n}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:i,stepSize:s}=t;return s?(e=Math.ceil(this.max/s)-Math.floor(this.min/s)+1)>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3):(e=this.computeTickLimit(),i=i||11),i&&(e=Math.min(i,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();const s=function(t,e){const i=[],{bounds:s,step:n,min:o,max:a,precision:r,count:l,maxTicks:h,maxDigits:c,includeBounds:d}=t,u=n||1,f=h-1,{min:g,max:p}=e,m=!$(o),x=!$(a),b=!$(l),_=(p-g)/(c+1);let y,v,w,M,k=At((p-g)/f/u)*u;if(k<1e-14&&!m&&!x)return[{value:g},{value:p}];(M=Math.ceil(p/k)-Math.floor(g/k))>f&&(k=At(M*k/f/u)*u),$(r)||(y=Math.pow(10,r),k=Math.ceil(k*y)/y),"ticks"===s?(v=Math.floor(g/k)*k,w=Math.ceil(p/k)*k):(v=g,w=p),m&&x&&n&&Et((a-o)/n,k/1e3)?(k=(a-o)/(M=Math.round(Math.min((a-o)/k,h))),v=o,w=a):b?k=((w=x?a:w)-(v=m?o:v))/(M=l-1):M=Rt(M=(w-v)/k,Math.round(M),k/1e3)?Math.round(M):Math.ceil(M);const S=Math.max(Vt(k),Vt(v));y=Math.pow(10,$(r)?S:r),v=Math.round(v*y)/y,w=Math.round(w*y)/y;let P=0;for(m&&(d&&v!==o?(i.push({value:o}),v0?i:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=X(t)?Math.max(0,t):null,this.max=X(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const n=e=>i=t?i:e,o=t=>s=e?s:t,a=(t,e)=>Math.pow(10,Math.floor(Ct(t))+e);i===s&&(i<=0?(n(1),o(10)):(n(a(i,-1)),o(a(s,1)))),i<=0&&n(a(s,-1)),s<=0&&o(a(i,1)),this._zero&&this.min!==this._suggestedMin&&i===a(this.min,0)&&n(a(i,-1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e=function(t,e){const i=Math.floor(Ct(e.max)),s=Math.ceil(e.max/Math.pow(10,i)),n=[];let o=q(t.min,Math.pow(10,Math.floor(Ct(e.min)))),a=Math.floor(Ct(o)),r=Math.floor(o/Math.pow(10,a)),l=a<0?Math.pow(10,Math.abs(a)):1;do{n.push({value:o,major:ia(o)}),10==++r&&(r=1,l=++a>=0?1:l),o=Math.round(r*Math.pow(10,a)*l)/l}while(an?{start:e-i,end:e}:{start:e,end:e+i}}function aa(t){const e={l:0,r:t.width,t:0,b:t.height-t.paddingTop},i={},s=[],n=[],o=t.getLabels().length;for(let h=0;he.r&&(e.r=p.end,i.r=f),m.starte.b&&(e.b=m.end,i.b=f)}var a,r,l;t._setReductions(t.drawingArea,e,i),t._pointLabelItems=function(t,e,i){const s=[],n=t.getLabels().length,o=t.options,a=na(o),r=t.getDistanceFromCenterForValue(o.ticks.reverse?t.min:t.max);for(let o=0;o270||i<90)&&(t-=e),t}function ca(t,e,i,s){const{ctx:n}=t;if(i)n.arc(t.xCenter,t.yCenter,e,0,vt);else{let i=t.getPointPosition(0,e);n.moveTo(i.x,i.y);for(let o=1;o{const i=Q(this.options.pointLabels.callback,[t,e],this);return i||0===i?i:""})}fit(){const t=this.options;t.display&&t.pointLabels.display?aa(this):this.setCenterPoint(0,0,0,0)}_setReductions(t,e,i){let s=e.l/Math.sin(i.l),n=Math.max(e.r-this.width,0)/Math.sin(i.r),o=-e.t/Math.cos(i.t),a=-Math.max(e.b-(this.height-this.paddingTop),0)/Math.cos(i.b);s=da(s),n=da(n),o=da(o),a=da(a),this.drawingArea=Math.max(t/2,Math.min(Math.floor(t-(s+n)/2),Math.floor(t-(o+a)/2))),this.setCenterPoint(s,n,o,a)}setCenterPoint(t,e,i,s){const n=this.width-e-this.drawingArea,o=t+this.drawingArea,a=i+this.drawingArea,r=this.height-this.paddingTop-s-this.drawingArea;this.xCenter=Math.floor((o+n)/2+this.left),this.yCenter=Math.floor((a+r)/2+this.top+this.paddingTop)}getIndexAngle(t){return Ht(t*(vt/this.getLabels().length)+zt(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if($(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if($(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t=0;n--){const e=s.setContext(t.getPointLabelContext(n)),o=je(e.font),{x:a,y:r,textAlign:l,left:h,top:c,right:d,bottom:u}=t._pointLabelItems[n],{backdropColor:f}=e;if(!$(f)){const t=He(e.backdropPadding);i.fillStyle=f,i.fillRect(h-t.left,c-t.top,d-h+t.width,u-c+t.height)}se(i,t._pointLabels[n],a,r+o.lineHeight/2,o,{color:e.color,textAlign:l,textBaseline:"middle"})}}(this,n),s.display&&this.ticks.forEach((t,e)=>{if(0!==e){a=this.getDistanceFromCenterForValue(t.value),function(t,e,i,s){const n=t.ctx,o=e.circular,{color:a,lineWidth:r}=e;!o&&!s||!a||!r||i<0||(n.save(),n.strokeStyle=a,n.lineWidth=r,n.setLineDash(e.borderDash),n.lineDashOffset=e.borderDashOffset,n.beginPath(),ca(t,i,o,s),n.closePath(),n.stroke(),n.restore())}(this,s.setContext(this.getContext(e-1)),a,n)}}),i.display){for(t.save(),o=this.getLabels().length-1;o>=0;o--){const s=i.setContext(this.getPointLabelContext(o)),{color:n,lineWidth:l}=s;l&&n&&(t.lineWidth=l,t.strokeStyle=n,t.setLineDash(s.borderDash),t.lineDashOffset=s.borderDashOffset,a=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),r=this.getPointPosition(o,a),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(r.x,r.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let n,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((s,a)=>{if(0===a&&!e.reverse)return;const r=i.setContext(this.getContext(a)),l=je(r.font);if(n=this.getDistanceFromCenterForValue(this.ticks[a].value),r.showLabelBackdrop){t.font=l.string,o=t.measureText(s.label).width,t.fillStyle=r.backdropColor;const e=He(r.backdropPadding);t.fillRect(-o/2-e.left,-n-l.size/2-e.top,o+e.width,l.size+e.height)}se(t,s.label,0,-n,l,{color:r.color})}),t.restore()}drawTitle(){}}ua.id="radialLinear",ua.defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Ls.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback:t=>t,padding:5}},ua.defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"},ua.descriptors={angleLines:{_fallback:"grid"}};const fa={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},ga=Object.keys(fa);function pa(t,e){return t-e}function ma(t,e){if($(e))return null;const i=t._adapter,{parser:s,round:n,isoWeekday:o}=t._parseOpts;let a=e;return"function"==typeof s&&(a=s(a)),X(a)||(a="string"==typeof s?i.parse(a,s):i.parse(a)),null===a?null:(n&&(a="week"!==n||!Lt(o)&&!0!==o?i.startOf(a,n):i.startOf(a,"isoWeek",o)),+a)}function xa(t,e,i,s){const n=ga.length;for(let o=ga.indexOf(t);o=e?i[s]:i[n]]=!0}}else t[e]=!0}function _a(t,e,i){const s=[],n={},o=e.length;let a,r;for(a=0;a=0&&(e[l].major=!0);return e}(t,s,n,i):s}class ya extends Hs{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e){const i=t.time||(t.time={}),s=this._adapter=new bn._date(t.adapters.date);ot(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:ma(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,i=t.time.unit||"day";let{min:s,max:n,minDefined:o,maxDefined:a}=this.getUserBounds();function r(t){o||isNaN(t.min)||(s=Math.min(s,t.min)),a||isNaN(t.max)||(n=Math.max(n,t.max))}o&&a||(r(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||r(this.getMinMax(!1))),s=X(s)&&!isNaN(s)?s:+e.startOf(Date.now(),i),n=X(n)&&!isNaN(n)?n:+e.endOf(Date.now(),i)+1,this.min=Math.min(s,n-1),this.max=Math.max(s+1,n)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this.options,e=t.time,i=t.ticks,s="labels"===i.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const n=this.min,o=he(s,n,this.max);return this._unit=e.unit||(i.autoSkip?xa(e.minUnit,this.min,this.max,this._getLabelCapacity(n)):function(t,e,i,s,n){for(let o=ga.length-1;o>=ga.indexOf(i);o--){const i=ga[o];if(fa[i].common&&t._adapter.diff(n,s,i)>=e-1)return i}return ga[i?ga.indexOf(i):0]}(this,o.length,e.minUnit,this.min,this.max)),this._majorUnit=i.major.enabled&&"year"!==this._unit?function(t){for(let e=ga.indexOf(t)+1,i=ga.length;e1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+o);const f="data"===s.ticks.source&&this.getDataTimestamps();for(c=u,d=0;ct-e).map(t=>+t)}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}_tickFormatFunction(t,e,i,s){const n=this.options,o=n.time.displayFormats,a=this._unit,r=this._majorUnit,l=a&&o[a],h=r&&o[r],c=i[e],d=r&&h&&c&&c.major,u=this._adapter.format(t,s||(d?h:l)),f=n.ticks.callback;return f?Q(f,[u,e,i],this):u}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t,e,i=this._cache.data||[];if(i.length)return i;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(t=0,e=s.length;t=t[r].pos&&e<=t[l].pos&&({lo:r,hi:l}=re(t,"pos",e)),({pos:s,time:o}=t[r]),({pos:n,time:a}=t[l])):(e>=t[r].time&&e<=t[l].time&&({lo:r,hi:l}=re(t,"time",e)),({time:s,pos:o}=t[r]),({time:n,pos:a}=t[l]));const h=n-s;return h?o+(a-o)*(e-s)/h:o}ya.id="time",ya.defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",major:{enabled:!1}}};class wa extends ya{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=va(e,this.min),this._tableRange=va(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],n=[];let o,a,r,l,h;for(o=0,a=t.length;o=e&&l<=i&&s.push(l);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(o=0,a=s.length;o"string"==typeof t,e=Chart.helpers;let i=null;new Map;return window.plugin_gradient={id:"gradient",beforeDatasetsUpdate(s){const n=s.ctx,o=s.chartArea;if(!o)return null;if(s.options.gradientcolor&&void 0!==s.options.gradientcolor.type){const a=s.data.datasets[0].type||s.config.type;if(null===i){const r=s.data.datasets[0].backgroundColor;i=function(i,s,n,o){let a=[];switch(s.toLowerCase()){case"pie":case"doughnut":if(o&&o.length&&t(o[0])){const t=(n.left+n.right)/2,s=(n.top+n.bottom)/2,r=1;return Object.entries(o).forEach(([,n],o)=>{let l=i.createRadialGradient(t,s,0,t,s,r);l.addColorStop(0,e.color(n).alpha(.4).rgbString()),l.addColorStop(1,e.color(n).alpha(1).rgbString()),a.push(l)}),a}case"bar":return Object.entries(o).forEach(([,s],o)=>{if(t(s)){let t=i.createLinearGradient(0,n.bottom,0,n.top);t.addColorStop(0,e.color(s).alpha(1).rgbString()),t.addColorStop(.5,e.color(s).alpha(.5).rgbString()),t.addColorStop(1,e.color(s).alpha(1).rgbString()),a.push(t)}else a.push(s)}),a}return o}(n,a,o,r),s.data.datasets[0].backgroundColor=i}}else s.data.datasets.forEach((t,s)=>{const a=t.gradient;a&&o&&Object.keys(a).forEach(s=>{const{axis:r,colors:l}=a[s];l&&l.length&&(i=function(t,i,s,n){if(s.bottom&&s.top&&s.left&&s.right){const o="y"===i?t.createLinearGradient(0,s.bottom,0,s.top):t.createLinearGradient(s.left,0,s.right,0);if(n&&1==n.length)o.addColorStop(0,e.color(color).alpha(.2).rgbString()),o.addColorStop(.3,e.color(color).alpha(.4).rgbString()),o.addColorStop(.5,e.color(color).alpha(.6).rgbString()),o.addColorStop(1,e.color(color).alpha(1).rgbString());else{const t=1/(n.length-1);Object.entries(n).forEach(([,e],i)=>{o.addColorStop(t*i,e)})}return o}}(n,r,o,l),t.backgroundColor=i)})})}},plugin_gradient}),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self)["chartjs-background"]=e()}(this,function(){"use strict";return{id:"chardbackground",beforeDraw:function(t){if(t.config.options.chartArea&&t.config.options.chartArea.backgroundColor){const e=t.chartArea,i=t.ctx;i.save(),i.fillStyle=t.config.options.chartArea.backgroundColor,i.fillRect(e.left,e.top,e.right-e.left,e.bottom-e.top),i.restore()}}}}),LineFitter.prototype={add:function(t,e){this.count++,this.sumX+=t,this.sumX2+=t*t,this.sumXY+=t*e,this.sumY+=e},project:function(t){const e=this.count*this.sumX2-this.sumX*this.sumX;return(this.sumX2*this.sumY-this.sumX*this.sumXY)/e+t*((this.count*this.sumXY-this.sumX*this.sumY)/e)}},window.plugin_trendline={id:"trendline",afterDatasetsDraw:function(t){const e=t.ctx;e&&(t.data.datasets.forEach(function(i,s){if(i.trendlineLinear){const n=t.scales.x||t.scales[i.xAxisID],o=t.scales.y||t.scales[i.yAxisID];addFitter(t.getDatasetMeta(s),e,i,n,o)}}),e.setLineDash([]))}}; \ No newline at end of file +function LineFitter(){this.count=0,this.sumX=0,this.sumX2=0,this.sumXY=0,this.sumY=0}function addFitter(t,e,i,s,n){if(i&&i.data&&i.data.length){const o="time"===s.options.type,a=i.data.length-1,r=t.data[0].x,l=t.data[a].x,h=new LineFitter;i.data.forEach(function(t,e){h.add(e,o?t.y:t)}),e.lineWidth=i.trendlineLinear.lineStyle||"solid","dotted"===(i.trendlineLinear.lineStyle||"solid")&&e.setLineDash([2,3]),e.beginPath(),e.lineWidth=2,e.moveTo(r,n.getPixelForValue(h.project(0))),e.lineTo(l,n.getPixelForValue(h.project(a))),e.strokeStyle=i.trendlineLinear.color||i.borderColor||"rgba(255, 0, 0, 0.85)",e.stroke()}}!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Chart=e()}(this,function(){"use strict";const t="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function e(e,i,s){const n=s||(t=>Array.prototype.slice.call(t));let o=!1,a=[];return function(...s){a=n(s),o||(o=!0,t.call(window,()=>{o=!1,e.apply(i,a)}))}}function i(t,e){let i;return function(...s){return e?(clearTimeout(i),i=setTimeout(t,e,s)):t.apply(this,s),e}}const s=t=>"start"===t?"left":"end"===t?"right":"center",n=(t,e,i)=>"start"===t?e:"end"===t?i:(e+i)/2,o=(t,e,i,s)=>{return t===(s?"left":"right")?i:"center"===t?(e+i)/2:e};var a=new class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,s){const n=e.listeners[s],o=e.duration;n.forEach(s=>s({chart:t,initial:e.initial,numSteps:o,currentStep:Math.min(i-e.start,o)}))}_refresh(){this._request||(this._running=!0,this._request=t.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((i,s)=>{if(!i.running||!i.items.length)return;const n=i.items;let o,a=n.length-1,r=!1;for(;a>=0;--a)(o=n[a])._active?(o._total>i.duration&&(i.duration=o._total),o.tick(t),r=!0):(n[a]=n[n.length-1],n.pop());r&&(s.draw(),this._notify(s,i,t,"progress")),n.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),e+=n.length}),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((t,e)=>Math.max(t,e._duration),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}};const r={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},l="0123456789ABCDEF",h=t=>l[15&t],c=t=>l[(240&t)>>4]+l[15&t],d=t=>(240&t)>>4==(15&t);function u(t){var e=function(t){return d(t.r)&&d(t.g)&&d(t.b)&&d(t.a)}(t)?h:c;return t?"#"+e(t.r)+e(t.g)+e(t.b)+(t.a<255?e(t.a):""):t}function f(t){return t+.5|0}const g=(t,e,i)=>Math.max(Math.min(t,i),e);function p(t){return g(f(2.55*t),0,255)}function m(t){return g(f(255*t),0,255)}function b(t){return g(f(t/2.55)/100,0,1)}function x(t){return g(f(100*t),0,100)}const _=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const y=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function v(t,e,i){const s=e*Math.min(i,1-i),n=(e,n=(e+t/30)%12)=>i-s*Math.max(Math.min(n-3,9-n,1),-1);return[n(0),n(8),n(4)]}function w(t,e,i){const s=(s,n=(s+t/60)%6)=>i-i*e*Math.max(Math.min(n,4-n,1),0);return[s(5),s(3),s(1)]}function M(t,e,i){const s=v(t,1,.5);let n;for(e+i>1&&(e*=n=1/(e+i),i*=n),n=0;n<3;n++)s[n]*=1-e-i,s[n]+=e;return s}function k(t){const e=t.r/255,i=t.g/255,s=t.b/255,n=Math.max(e,i,s),o=Math.min(e,i,s),a=(n+o)/2;let r,l,h;return n!==o&&(h=n-o,l=a>.5?h/(2-n-o):h/(n+o),r=60*(r=n===e?(i-s)/h+(i>16&255,o>>8&255,255&o]}return t}()).transparent=[0,0,0,0]);const e=T[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}function R(t,e,i){if(t){let s=k(t);s[e]=Math.max(0,Math.min(s[e]+s[e]*i,0===e?360:1)),s=P(s),t.r=s[0],t.g=s[1],t.b=s[2]}}function E(t,e){return t?Object.assign(e||{},t):t}function I(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=m(t[3]))):(e=E(t,{r:0,g:0,b:0,a:1})).a=m(e.a),e}function z(t){return"r"===t.charAt(0)?function(t){const e=_.exec(t);let i,s,n,o=255;if(e){if(e[7]!==i){const t=+e[7];o=255&(e[8]?p(t):255*t)}return i=+e[1],s=+e[3],n=+e[5],{r:i=255&(e[2]?p(i):i),g:s=255&(e[4]?p(s):s),b:n=255&(e[6]?p(n):n),a:o}}}(t):C(t)}class F{constructor(t){if(t instanceof F)return t;const e=typeof t;let i;var s,n,o;"object"===e?i=I(t):"string"===e&&(o=(s=t).length,"#"===s[0]&&(4===o||5===o?n={r:255&17*r[s[1]],g:255&17*r[s[2]],b:255&17*r[s[3]],a:5===o?17*r[s[4]]:255}:7!==o&&9!==o||(n={r:r[s[1]]<<4|r[s[2]],g:r[s[3]]<<4|r[s[4]],b:r[s[5]]<<4|r[s[6]],a:9===o?r[s[7]]<<4|r[s[8]]:255})),i=n||L(t)||z(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=E(this._rgb);return t&&(t.a=b(t.a)),t}set rgb(t){this._rgb=I(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${b(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):this._rgb;var t}hexString(){return this._valid?u(this._rgb):this._rgb}hslString(){return this._valid?function(t){if(!t)return;const e=k(t),i=e[0],s=x(e[1]),n=x(e[2]);return t.a<255?`hsla(${i}, ${s}%, ${n}%, ${b(t.a)})`:`hsl(${i}, ${s}%, ${n}%)`}(this._rgb):this._rgb}mix(t,e){const i=this;if(t){const s=i.rgb,n=t.rgb;let o;const a=e===o?.5:e,r=2*a-1,l=s.a-n.a,h=((r*l==-1?r:(r+l)/(1+r*l))+1)/2;o=1-h,s.r=255&h*s.r+o*n.r+.5,s.g=255&h*s.g+o*n.g+.5,s.b=255&h*s.b+o*n.b+.5,s.a=a*s.a+(1-a)*n.a,i.rgb=s}return i}clone(){return new F(this.rgb)}alpha(t){return this._rgb.a=m(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,e=f(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return R(this._rgb,2,t),this}darken(t){return R(this._rgb,2,-t),this}saturate(t){return R(this._rgb,1,t),this}desaturate(t){return R(this._rgb,1,-t),this}rotate(t){return function(t,e){var i=k(t);i[0]=D(i[0]+e),i=P(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this}}function B(t){return new F(t)}const V=t=>t instanceof CanvasGradient||t instanceof CanvasPattern;function W(t){return V(t)?t:B(t)}function N(t){return V(t)?t:B(t).saturate(.5).darken(.1).hexString()}function j(){}const H=function(){let t=0;return function(){return t++}}();function $(t){return null==t}function Y(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.substr(0,7)&&"Array]"===e.substr(-6)}function U(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}const X=t=>("number"==typeof t||t instanceof Number)&&isFinite(+t);function q(t,e){return X(t)?t:e}function K(t,e){return void 0===t?e:t}const G=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:t/e,Z=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function Q(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function J(t,e,i,s){let n,o,a;if(Y(t))if(o=t.length,s)for(n=o-1;n>=0;n--)e.call(i,t[n],n);else for(n=0;ni;)t=t[e.substr(i,s-i)],s=ht(e,i=s+1);return t}function dt(t){return t.charAt(0).toUpperCase()+t.slice(1)}const ut=t=>void 0!==t,ft=t=>"function"==typeof t,gt=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0},pt=Object.create(null),mt=Object.create(null);function bt(t,e){if(!e)return t;const i=e.split(".");for(let e=0,s=i.length;et.chart.platform.getDevicePixelRatio()),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=((t,e)=>N(e.backgroundColor)),this.hoverBorderColor=((t,e)=>N(e.borderColor)),this.hoverColor=((t,e)=>N(e.color)),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.describe(t)}set(t,e){return xt(this,t,e)}get(t){return bt(this,t)}describe(t,e){return xt(mt,t,e)}override(t,e){return xt(pt,t,e)}route(t,e,i,s){const n=bt(this,t),o=bt(this,i),a="_"+e;Object.defineProperties(n,{[a]:{value:n[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[a],e=o[s];return U(t)?Object.assign({},e,t):K(t,e)},set(t){this[a]=t}}})}}({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}});const yt=Math.PI,vt=2*yt,wt=vt+yt,Mt=Number.POSITIVE_INFINITY,kt=yt/180,St=yt/2,Pt=yt/4,Dt=2*yt/3,Ct=Math.log10,Ot=Math.sign;function At(t){const e=Math.round(t);t=Rt(t,e,t/1e3)?e:t;const i=Math.pow(10,Math.floor(Ct(t))),s=t/i;return(s<=1?1:s<=2?2:s<=5?5:10)*i}function Tt(t){const e=[],i=Math.sqrt(t);let s;for(s=1;st-e).pop(),e}function Lt(t){return!isNaN(parseFloat(t))&&isFinite(t)}function Rt(t,e,i){return Math.abs(t-e)=t}function It(t,e,i){let s,n,o;for(s=0,n=t.length;sl&&h=Math.min(e,i)-s&&t<=Math.max(e,i)+s}function Xt(t){return!t||$(t.size)||$(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}function qt(t,e,i,s,n){let o=e[n];return o||(o=e[n]=t.measureText(n).width,i.push(n)),o>s&&(s=o),s}function Kt(t,e,i,s){let n=(s=s||{}).data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==e&&(n=s.data={},o=s.garbageCollect=[],s.font=e),t.save(),t.font=e;let a=0;const r=i.length;let l,h,c,d,u;for(l=0;li.length){for(l=0;l0&&t.stroke()}}function Jt(t,e,i){return i=i||.5,!e||t&&t.x>e.left-i&&t.xe.top-i&&t.y0&&""!==o.strokeColor;let l,h;for(t.save(),t.font=n.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]);$(e.rotation)||t.rotate(e.rotation);e.color&&(t.fillStyle=e.color);e.textAlign&&(t.textAlign=e.textAlign);e.textBaseline&&(t.textBaseline=e.textBaseline)}(t,o),l=0;lt[i]1;)i(s=o+n>>1)?o=s:n=s;return{lo:o,hi:n}}const le=(t,e,i)=>re(t,i,s=>t[s][e]re(t,i,s=>t[s][e]>=i);function ce(t,e,i){let s=0,n=t.length;for(;ss&&t[n-1]>i;)n--;return s>0||n{const i="_onData"+dt(e),s=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...e){const n=s.apply(this,e);return t._chartjs.listeners.forEach(t=>{"function"==typeof t[i]&&t[i](...e)}),n}})}))}function fe(t,e){const i=t._chartjs;if(!i)return;const s=i.listeners,n=s.indexOf(e);-1!==n&&s.splice(n,1),s.length>0||(de.forEach(e=>{delete t[e]}),delete t._chartjs)}function ge(t){const e=new Set;let i,s;for(i=0,s=t.length;iwindow.getComputedStyle(t,null);function _e(t,e){return xe(t).getPropertyValue(e)}const ye=["top","right","bottom","left"];function ve(t,e,i){const s={};i=i?"-"+i:"";for(let n=0;n<4;n++){const o=ye[n];s[o]=parseFloat(t[e+"-"+o+i])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}const we=(t,e,i)=>(t>0||e>0)&&(!i||!i.shadowRoot);function Me(t,e){const{canvas:i,currentDevicePixelRatio:s}=e,n=xe(i),o="border-box"===n.boxSizing,a=ve(n,"padding"),r=ve(n,"border","width"),{x:l,y:h,box:c}=function(t,e){const i=t.native||t,s=i.touches,n=s&&s.length?s[0]:i,{offsetX:o,offsetY:a}=n;let r,l,h=!1;if(we(o,a,i.target))r=o,l=a;else{const t=e.getBoundingClientRect();r=n.clientX-t.left,l=n.clientY-t.top,h=!0}return{x:r,y:l,box:h}}(t,i),d=a.left+(c&&r.left),u=a.top+(c&&r.top);let{width:f,height:g}=e;return o&&(f-=a.width+r.width,g-=a.height+r.height),{x:Math.round((l-d)/f*i.width/s),y:Math.round((h-u)/g*i.height/s)}}const ke=t=>Math.round(10*t)/10;function Se(t,e,i,s){const n=xe(t),o=ve(n,"margin"),a=be(n.maxWidth,t,"clientWidth")||Mt,r=be(n.maxHeight,t,"clientHeight")||Mt,l=function(t,e,i){let s,n;if(void 0===e||void 0===i){const o=me(t);if(o){const t=o.getBoundingClientRect(),a=xe(o),r=ve(a,"border","width"),l=ve(a,"padding");e=t.width-l.width-r.width,i=t.height-l.height-r.height,s=be(a.maxWidth,o,"clientWidth"),n=be(a.maxHeight,o,"clientHeight")}else e=t.clientWidth,i=t.clientHeight}return{width:e,height:i,maxWidth:s||Mt,maxHeight:n||Mt}}(t,e,i);let{width:h,height:c}=l;if("content-box"===n.boxSizing){const t=ve(n,"border","width"),e=ve(n,"padding");h-=e.width+t.width,c-=e.height+t.height}return h=Math.max(0,h-o.width),c=Math.max(0,s?Math.floor(h/s):c-o.height),h=ke(Math.min(h,a,l.maxWidth)),c=ke(Math.min(c,r,l.maxHeight)),h&&!c&&(c=ke(h/2)),{width:h,height:c}}function Pe(t,e,i){const s=e||1,n=Math.floor(t.height*s),o=Math.floor(t.width*s);t.height=n/s,t.width=o/s;const a=t.canvas;return a.style&&(i||!a.style.height&&!a.style.width)&&(a.style.height=`${t.height}px`,a.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(t.currentDevicePixelRatio=s,a.height=n,a.width=o,t.ctx.setTransform(s,0,0,s,0,0),!0)}const De=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}();function Ce(t,e){const i=_e(t,e),s=i&&i.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function Oe(t,e){return"native"in t?{x:t.x,y:t.y}:Me(t,e)}function Ae(t,e,i,s){const{controller:n,data:o,_sorted:a}=t,r=n._cachedMeta.iScale;if(r&&e===r.axis&&a&&o.length){const t=r._reversePixels?he:le;if(!s)return t(o,e,i);if(n._sharedOptions){const s=o[0],n="function"==typeof s.getRange&&s.getRange(e);if(n){const s=t(o,e,i-n),a=t(o,e,i+n);return{lo:s.lo,hi:a.hi}}}}return{lo:0,hi:o.length-1}}function Te(t,e,i,s,n){const o=t.getSortedVisibleDatasetMetas(),a=i[e];for(let t=0,i=o.length;t{t[r](n[a],s)&&o.push({element:t,datasetIndex:e,index:i}),t.inRange(n.x,n.y,s)&&(l=!0)}),i.intersect&&!l?[]:o}var Ie={modes:{index(t,e,i,s){const n=Oe(e,t),o=i.axis||"x",a=i.intersect?Le(t,n,o,s):Re(t,n,o,!1,s),r=[];return a.length?(t.getSortedVisibleDatasetMetas().forEach(t=>{const e=a[0].index,i=t.data[e];i&&!i.skip&&r.push({element:i,datasetIndex:t.index,index:e})}),r):[]},dataset(t,e,i,s){const n=Oe(e,t),o=i.axis||"xy";let a=i.intersect?Le(t,n,o,s):Re(t,n,o,!1,s);if(a.length>0){const e=a[0].datasetIndex,i=t.getDatasetMeta(e).data;a=[];for(let t=0;tLe(t,Oe(e,t),i.axis||"xy",s),nearest:(t,e,i,s)=>Re(t,Oe(e,t),i.axis||"xy",i.intersect,s),x:(t,e,i,s)=>(i.axis="x",Ee(t,e,i,s)),y:(t,e,i,s)=>(i.axis="y",Ee(t,e,i,s))}};const ze=new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/),Fe=new RegExp(/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/);function Be(t,e){const i=(""+t).match(ze);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}const Ve=t=>+t||0;function We(t,e){const i={},s=U(e),n=s?Object.keys(e):e,o=U(t)?s?i=>K(t[i],t[e[i]]):e=>t[e]:()=>t;for(const t of n)i[t]=Ve(o(t));return i}function Ne(t){return We(t,{top:"y",right:"x",bottom:"y",left:"x"})}function je(t){return We(t,["topLeft","topRight","bottomLeft","bottomRight"])}function He(t){const e=Ne(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function $e(t,e){t=t||{},e=e||_t.font;let i=K(t.size,e.size);"string"==typeof i&&(i=parseInt(i,10));let s=K(t.style,e.style);s&&!(""+s).match(Fe)&&(console.warn('Invalid font style specified: "'+s+'"'),s="");const n={family:K(t.family,e.family),lineHeight:Be(K(t.lineHeight,e.lineHeight),i),size:i,style:s,weight:K(t.weight,e.weight),string:""};return n.string=Xt(n),n}function Ye(t,e,i,s){let n,o,a,r=!0;for(n=0,o=t.length;ni&&0===t?0:t+e;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function Xe(t,e){return Object.assign(Object.create(t),e)}const qe=["left","top","right","bottom"];function Ke(t,e){return t.filter(t=>t.pos===e)}function Ge(t,e){return t.filter(t=>-1===qe.indexOf(t.pos)&&t.box.axis===e)}function Ze(t,e){return t.sort((t,i)=>{const s=e?i:t,n=e?t:i;return s.weight===n.weight?s.index-n.index:s.weight-n.weight})}function Qe(t,e){const i=function(t){const e={};for(const i of t){const{stack:t,pos:s,stackWeight:n}=i;if(!t||!qe.includes(s))continue;const o=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=n}return e}(t),{vBoxMaxWidth:s,hBoxMaxHeight:n}=e;let o,a,r;for(o=0,a=t.length;o{s[t]=Math.max(e[t],i[t])}),s}return s(t?["left","right"]:["top","bottom"])}function si(t,e,i,s){const n=[];let o,a,r,l,h,c;for(o=0,a=t.length,h=0;ot.box.fullSize),!0),s=Ze(Ke(e,"left"),!0),n=Ze(Ke(e,"right")),o=Ze(Ke(e,"top"),!0),a=Ze(Ke(e,"bottom")),r=Ge(e,"x"),l=Ge(e,"y");return{fullSize:i,leftAndTop:s.concat(o),rightAndBottom:n.concat(l).concat(a).concat(r),chartArea:Ke(e,"chartArea"),vertical:s.concat(n).concat(l),horizontal:o.concat(a).concat(r)}}(t.boxes),l=r.vertical,h=r.horizontal;J(t.boxes,t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()});const c=l.reduce((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1,0)||1,d=Object.freeze({outerWidth:e,outerHeight:i,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/c,hBoxMaxHeight:a/2}),u=Object.assign({},n);ti(u,He(s));const f=Object.assign({maxPadding:u,w:o,h:a,x:n.left,y:n.top},n),g=Qe(l.concat(h),d);si(r.fullSize,f,d,g),si(l,f,d,g),si(h,f,d,g)&&si(l,f,d,g),function(t){const e=t.maxPadding;function i(i){const s=Math.max(e[i]-t[i],0);return t[i]+=s,s}t.y+=i("top"),t.x+=i("left"),i("right"),i("bottom")}(f),oi(r.leftAndTop,f,d,g),f.x+=f.w,f.y+=f.h,oi(r.rightAndBottom,f,d,g),t.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},J(r.chartArea,e=>{const i=e.box;Object.assign(i,t.chartArea),i.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}};function ri(t,e=[""],i=t,s,n=(()=>t[0])){return ut(s)||(s=xi("_fallback",t)),new Proxy({[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:i,_fallback:s,_getTarget:n,override:n=>ri([n,...t],e,i,s)},{deleteProperty:(e,i)=>(delete e[i],delete e._keys,delete t[0][i],!0),get:(i,s)=>ui(i,s,()=>(function(t,e,i,s){let n;for(const o of e)if(n=xi(ci(o,t),i),ut(n))return di(t,n)?mi(i,s,t,n):n})(s,e,t,i)),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>_i(t).includes(e),ownKeys:t=>_i(t),set:(t,e,i)=>((t._storage||(t._storage=n()))[e]=i,delete t[e],delete t._keys,!0)})}function li(t,e,i,s){const n={_cacheable:!1,_proxy:t,_context:e,_subProxy:i,_stack:new Set,_descriptors:hi(t,s),setContext:e=>li(t,e,i,s),override:n=>li(t.override(n),e,i,s)};return new Proxy(n,{deleteProperty:(e,i)=>(delete e[i],delete t[i],!0),get:(t,e,i)=>ui(t,e,()=>(function(t,e,i){const{_proxy:s,_context:n,_subProxy:o,_descriptors:a}=t;let r=s[e];ft(r)&&a.isScriptable(e)&&(r=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_stack:r}=i;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);r.add(t),e=e(o,a||s),r.delete(t),di(t,e)&&(e=mi(n._scopes,n,t,e));return e}(e,r,t,i));Y(r)&&r.length&&(r=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_descriptors:r}=i;if(ut(o.index)&&s(t))e=e[o.index%e.length];else if(U(e[0])){const i=e,s=n._scopes.filter(t=>t!==i);e=[];for(const l of i){const i=mi(s,n,t,l);e.push(li(i,o,a&&a[t],r))}}return e}(e,r,t,a.isIndexable));di(e,r)&&(r=li(r,n,o&&o[e],a));return r})(t,e,i)),getOwnPropertyDescriptor:(e,i)=>e._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,i)=>Reflect.has(t,i),ownKeys:()=>Reflect.ownKeys(t),set:(e,i,s)=>(t[i]=s,delete e[i],!0)})}function hi(t,e={scriptable:!0,indexable:!0}){const{_scriptable:i=e.scriptable,_indexable:s=e.indexable,_allKeys:n=e.allKeys}=t;return{allKeys:n,scriptable:i,indexable:s,isScriptable:ft(i)?i:()=>i,isIndexable:ft(s)?s:()=>s}}const ci=(t,e)=>t?t+dt(e):e,di=(t,e)=>U(e)&&"adapters"!==t&&(null===Object.getPrototypeOf(e)||e.constructor===Object);function ui(t,e,i){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];const s=i();return t[e]=s,s}function fi(t,e,i){return ft(t)?t(e,i):t}const gi=(t,e)=>!0===t?e:"string"==typeof t?ct(e,t):void 0;function pi(t,e,i,s){for(const n of e){const e=gi(i,n);if(e){t.add(e);const n=fi(e._fallback,i,e);if(ut(n)&&n!==i&&n!==s)return n}else if(!1===e&&ut(s)&&i!==s)return null}return!1}function mi(t,e,i,s){const n=e._rootScopes,o=fi(e._fallback,i,s),a=[...t,...n],r=new Set;r.add(s);let l=bi(r,a,i,o||i);return null!==l&&((!ut(o)||o===i||null!==(l=bi(r,a,o,l)))&&ri(Array.from(r),[""],n,o,()=>(function(t,e,i){const s=t._getTarget();e in s||(s[e]={});const n=s[e];if(Y(n)&&U(i))return i;return n})(e,i,s)))}function bi(t,e,i,s){for(;i;)i=pi(t,e,i,s);return i}function xi(t,e){for(const i of e){if(!i)continue;const e=i[t];if(ut(e))return e}}function _i(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const i of t)for(const t of Object.keys(i).filter(t=>!t.startsWith("_")))e.add(t);return Array.from(e)}(t._scopes)),e}const yi=Number.EPSILON||1e-14,vi=(t,e)=>e"x"===t?"y":"x";function Mi(t,e,i,s){const n=t.skip?e:t,o=e,a=i.skip?e:i,r=Wt(o,n),l=Wt(a,o);let h=r/(r+l),c=l/(r+l);const d=s*(h=isNaN(h)?0:h),u=s*(c=isNaN(c)?0:c);return{previous:{x:o.x-d*(a.x-n.x),y:o.y-d*(a.y-n.y)},next:{x:o.x+u*(a.x-n.x),y:o.y+u*(a.y-n.y)}}}function ki(t,e="x"){const i=wi(e),s=t.length,n=Array(s).fill(0),o=Array(s);let a,r,l,h=vi(t,0);for(a=0;a!t.skip)),"monotone"===e.cubicInterpolationMode)ki(t,n);else{let i=s?t[t.length-1]:t[0];for(o=0,a=t.length;o0===t||1===t,Ci=(t,e,i)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*vt/i),Oi=(t,e,i)=>Math.pow(2,-10*t)*Math.sin((t-e)*vt/i)+1,Ai={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*St),easeOutSine:t=>Math.sin(t*St),easeInOutSine:t=>-.5*(Math.cos(yt*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>Di(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>Di(t)?t:Ci(t,.075,.3),easeOutElastic:t=>Di(t)?t:Oi(t,.075,.3),easeInOutElastic:t=>Di(t)?t:t<.5?.5*Ci(2*t,.1125,.45):.5+.5*Oi(2*t-1,.1125,.45),easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-Ai.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},easeInOutBounce:t=>t<.5?.5*Ai.easeInBounce(2*t):.5*Ai.easeOutBounce(2*t-1)+.5};function Ti(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:t.y+i*(e.y-t.y)}}function Li(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:"middle"===s?i<.5?t.y:e.y:"after"===s?i<1?t.y:e.y:i>0?e.y:t.y}}function Ri(t,e,i,s){const n={x:t.cp2x,y:t.cp2y},o={x:e.cp1x,y:e.cp1y},a=Ti(t,n,i),r=Ti(n,o,i),l=Ti(o,e,i),h=Ti(a,r,i),c=Ti(r,l,i);return Ti(h,c,i)}const Ei=new Map;function Ii(t,e,i){return function(t,e){e=e||{};const i=t+JSON.stringify(e);let s=Ei.get(i);return s||(s=new Intl.NumberFormat(t,e),Ei.set(i,s)),s}(e,i).format(t)}const zi=function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}},Fi=function(){return{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}};function Bi(t,e,i){return t?zi(e,i):Fi()}function Vi(t,e){let i,s;"ltr"!==e&&"rtl"!==e||(s=[(i=t.canvas.style).getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=s)}function Wi(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Ni(t){return"angle"===t?{between:Ht,compare:Nt,normalize:jt}:{between:Ut,compare:(t,e)=>t-e,normalize:t=>t}}function ji({start:t,end:e,count:i,loop:s,style:n}){return{start:t%i,end:e%i,loop:s&&(e-t+1)%i==0,style:n}}function Hi(t,e,i){if(!i)return[t];const{property:s,start:n,end:o}=i,a=e.length,{compare:r,between:l,normalize:h}=Ni(s),{start:c,end:d,loop:u,style:f}=function(t,e,i){const{property:s,start:n,end:o}=i,{between:a,normalize:r}=Ni(s),l=e.length;let h,c,{start:d,end:u,loop:f}=t;if(f){for(d+=l,u+=l,h=0,c=l;hx||(()=>l(n,b,p)&&0!==r(n,b))(),v=()=>!x||(()=>0===r(o,p)||l(o,b,p))();for(let t=c,i=c;t<=d;++t)(m=e[t%a]).skip||(p=h(m[s]))!==b&&(x=l(p,n,o),null===_&&y()&&(_=0===r(p,n)?t:i),null!==_&&v()&&(g.push(ji({start:_,end:t,loop:u,count:a,style:f})),_=null),i=t,b=p);return null!==_&&g.push(ji({start:_,end:d,loop:u,count:a,style:f})),g}function $i(t,e){const i=[],s=t.segments;for(let n=0;nn&&t[o%e].skip;)o--;return{start:n,end:o%=e}}(i,n,o,s);return Ui(t,!0===s?[{start:a,end:r,loop:o}]:function(t,e,i,s){const n=t.length,o=[];let a,r=e,l=t[e];for(a=e+1;a<=i;++a){const i=t[a%n];i.skip||i.stop?l.skip||(s=!1,o.push({start:e%n,end:(a-1)%n,loop:s}),e=r=i.stop?a:null):(r=a,l.skip&&(e=a)),l=i}return null!==r&&o.push({start:e%n,end:r%n,loop:s}),o}(i,a,rnull===t||""===t;const es=!!De&&{passive:!0};function is(t,e,i){t.canvas.removeEventListener(e,i,es)}function ss(t,e){for(const i of t)if(i===e||i.contains(e))return!0}function ns(t,e,i){const s=t.canvas,n=new MutationObserver(t=>{let e=!1;for(const i of t)e=(e=e||ss(i.addedNodes,s))&&!ss(i.removedNodes,s);e&&i()});return n.observe(document,{childList:!0,subtree:!0}),n}function os(t,e,i){const s=t.canvas,n=new MutationObserver(t=>{let e=!1;for(const i of t)e=(e=e||ss(i.removedNodes,s))&&!ss(i.addedNodes,s);e&&i()});return n.observe(document,{childList:!0,subtree:!0}),n}const as=new Map;let rs=0;function ls(){const t=window.devicePixelRatio;t!==rs&&(rs=t,as.forEach((e,i)=>{i.currentDevicePixelRatio!==t&&e()}))}function hs(t,i,s){const n=t.canvas,o=n&&me(n);if(!o)return;const a=e((t,e)=>{const i=o.clientWidth;s(t,e),i{const e=t[0],i=e.contentRect.width,s=e.contentRect.height;0===i&&0===s||a(i,s)});return r.observe(o),function(t,e){as.size||window.addEventListener("resize",ls),as.set(t,e)}(t,a),r}function cs(t,e,i){i&&i.disconnect(),"resize"===e&&function(t){as.delete(t),as.size||window.removeEventListener("resize",ls)}(t)}function ds(t,i,s){const n=t.canvas,o=e(e=>{null!==t.ctx&&s(function(t,e){const i=Ji[t.type]||t.type,{x:s,y:n}=Me(t,e);return{type:i,chart:e,native:t,x:void 0!==s?s:null,y:void 0!==n?n:null}}(e,t))},t,t=>{const e=t[0];return[e,e.offsetX,e.offsetY]});return function(t,e,i){t.addEventListener(e,i,es)}(n,i,o),o}class us extends Gi{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(function(t,e){const i=t.style,s=t.getAttribute("height"),n=t.getAttribute("width");if(t[Qi]={initial:{height:s,width:n,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",ts(n)){const e=Ce(t,"width");void 0!==e&&(t.width=e)}if(ts(s))if(""===t.style.height)t.height=t.width/(e||2);else{const e=Ce(t,"height");void 0!==e&&(t.height=e)}}(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e[Qi])return!1;const i=e[Qi].initial;["height","width"].forEach(t=>{const s=i[t];$(s)?e.removeAttribute(t):e.setAttribute(t,s)});const s=i.style||{};return Object.keys(s).forEach(t=>{e.style[t]=s[t]}),e.width=e.width,delete e[Qi],!0}addEventListener(t,e,i){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),n={attach:ns,detach:os,resize:hs}[e]||ds;s[e]=n(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];s&&(({attach:cs,detach:cs,resize:cs}[e]||is)(t,e,s),i[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return Se(t,e,i,s)}isAttached(t){const e=me(t);return!(!e||!e.isConnected)}}function fs(t){return!pe()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?Zi:us}var gs=Object.freeze({__proto__:null,_detectPlatform:fs,BasePlatform:Gi,BasicPlatform:Zi,DomPlatform:us});const ps={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const s=W(t||"transparent"),n=s.valid&&W(e||"transparent");return n&&n.valid?n.mix(s,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class ms{constructor(t,e,i,s){const n=e[i];s=Ye([t.to,s,n,t.from]);const o=Ye([t.from,n,s]);this._active=!0,this._fn=t.fn||ps[t.type||typeof o],this._easing=Ai[t.easing]||Ai.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=o,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const s=this._target[this._prop],n=i-this._start,o=this._duration-n;this._start=i,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=n,this._loop=!!t.loop,this._to=Ye([t.to,e,s,t.from]),this._from=Ye([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,s=this._prop,n=this._from,o=this._loop,a=this._to;let r;if(this._active=n!==a&&(o||e1?2-r:r,r=this._easing(Math.min(1,Math.max(0,r))),this._target[s]=this._fn(n,a,r))}wait(){const t=this._promises||(this._promises=[]);return new Promise((e,i)=>{t.push({res:e,rej:i})})}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let t=0;t"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),_t.set("animations",{colors:{type:"color",properties:["color","borderColor","backgroundColor"]},numbers:{type:"number",properties:["x","y","borderWidth","radius","tension"]}}),_t.describe("animations",{_fallback:"animation"}),_t.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}});class xs{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!U(t))return;const e=this._properties;Object.getOwnPropertyNames(t).forEach(i=>{const s=t[i];if(!U(s))return;const n={};for(const t of bs)n[t]=s[t];(Y(s.properties)&&s.properties||[i]).forEach(t=>{t!==i&&e.has(t)||e.set(t,n)})})}_animateOptions(t,e){const i=e.options,s=function(t,e){if(!e)return;let i=t.options;if(!i)return void(t.options=e);i.$shared&&(t.options=i=Object.assign({},i,{$shared:!1,$animations:{}}));return i}(t,i);if(!s)return[];const n=this._createAnimations(s,i);return i.$shared&&function(t,e){const i=[],s=Object.keys(e);for(let e=0;e{t.options=i},()=>{}),n}_createAnimations(t,e){const i=this._properties,s=[],n=t.$animations||(t.$animations={}),o=Object.keys(e),a=Date.now();let r;for(r=o.length-1;r>=0;--r){const l=o[r];if("$"===l.charAt(0))continue;if("options"===l){s.push(...this._animateOptions(t,e));continue}const h=e[l];let c=n[l];const d=i.get(l);if(c){if(d&&c.active()){c.update(d,h,a);continue}c.cancel()}d&&d.duration?(n[l]=c=new ms(d,t,l,h),s.push(c)):t[l]=h}return s}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(a.add(this._chart,i),!0):void 0}}function _s(t,e){const i=t&&t.options||{},s=i.reverse,n=void 0===i.min?e:0,o=void 0===i.max?e:0;return{start:s?o:n,end:s?n:o}}function ys(t,e){const i=[],s=t._getSortedDatasetMetas(e);let n,o;for(n=0,o=s.length;n0||!i&&e<0)return n.index}return null}function Ss(t,e){const{chart:i,_cachedMeta:s}=t,n=i._stacks||(i._stacks={}),{iScale:o,vScale:a,index:r}=s,l=o.axis,h=a.axis,c=function(t,e,i){return`${t.id}.${e.id}.${i.stack||i.type}`}(o,a,s),d=e.length;let u;for(let t=0;ti[t].axis===e).shift()}function Ds(t,e){const i=t.controller.index,s=t.vScale&&t.vScale.axis;if(s){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[s]||void 0===e[s][i])return;delete e[s][i]}}}const Cs=t=>"reset"===t||"none"===t,Os=(t,e)=>e?t:Object.assign({},t),As=(t,e,i)=>t&&!e.hidden&&e._stacked&&{keys:ys(i,!0),values:null};class Ts{constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.$context=void 0,this._syncList=[],this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=ws(t.vScale,t),this.addElements()}updateIndex(t){this.index!==t&&Ds(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(t,e,i,s)=>"x"===t?e:"r"===t?s:i,n=e.xAxisID=K(i.xAxisID,Ps(t,"x")),o=e.yAxisID=K(i.yAxisID,Ps(t,"y")),a=e.rAxisID=K(i.rAxisID,Ps(t,"r")),r=e.indexAxis,l=e.iAxisID=s(r,n,o,a),h=e.vAxisID=s(r,o,n,a);e.xScale=this.getScaleForId(n),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(l),e.vScale=this.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&fe(this._data,this),t._stacked&&Ds(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(U(e))this._data=function(t){const e=Object.keys(t),i=new Array(e.length);let s,n,o;for(s=0,n=e.length;s0&&i._parsed[t-1];if(!1===this._parsing)i._parsed=s,i._sorted=!0,h=s;else{h=Y(s[t])?this.parseArrayData(i,s,t,e):U(s[t])?this.parseObjectData(i,s,t,e):this.parsePrimitiveData(i,s,t,e);const n=()=>null===l[a]||d&&l[a]e||c=0;--d)if(!f()){this.updateRangeFromParsed(l,t,u,r);break}return l}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,n,o;for(s=0,n=e.length;s=0&&tthis.getContext(i,s),c);return f.$shared&&(f.$shared=r,n[o]=Object.freeze(Os(f,r))),f}_resolveAnimations(t,e,i){const s=this.chart,n=this._cachedDataOpts,o=`animation-${e}`,a=n[o];if(a)return a;let r;if(!1!==s.options.animation){const s=this.chart.config,n=s.datasetAnimationScopeKeys(this._type,e),o=s.getOptionScopes(this.getDataset(),n);r=s.createResolver(o,this.getContext(t,i,e))}const l=new xs(s,r&&r.animations);return r&&r._cacheable&&(n[o]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Cs(t)||this.chart._animationsDisabled}updateElement(t,e,i,s){Cs(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!Cs(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,s){t.active=s;const n=this.getStyle(e,s);this._resolveAnimations(e,i,s).update(t,{options:!s&&this.getSharedOptions(n)||n})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,i=this._cachedMeta.data;for(const[t,e,i]of this._syncList)this[t](e,i);this._syncList=[];const s=i.length,n=e.length,o=Math.min(n,s);o&&this.parse(0,o),n>s?this._insertElements(s,n-s,t):n{for(t.length+=e,a=t.length-1;a>=o;a--)t[a]=t[a-e]};for(r(n),a=t;a{s[t]=i[t]&&i[t].active()?i[t]._to:this[t]}),s}}Ls.defaults={},Ls.defaultRoutes=void 0;const Rs={values:t=>Y(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const s=this.chart.options.locale;let n,o=t;if(i.length>1){const e=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));(e<1e-4||e>1e15)&&(n="scientific"),o=function(t,e){let i=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;Math.abs(i)>=1&&t!==Math.floor(t)&&(i=t-Math.floor(t));return i}(t,i)}const a=Ct(Math.abs(o)),r=Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:n,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),Ii(t,s,l)},logarithmic(t,e,i){if(0===t)return"0";const s=t/Math.pow(10,Math.floor(Ct(t)));return 1===s||2===s||5===s?Rs.numeric.call(this,t,e,i):""}};var Es={formatters:Rs};function Is(t,e){const i=t.options.ticks,s=i.maxTicksLimit||function(t){const e=t.options.offset,i=t._tickSize(),s=t._length/i+(e?0:1),n=t._maxLength/i;return Math.floor(Math.min(s,n))}(t),n=i.major.enabled?function(t){const e=[];let i,s;for(i=0,s=t.length;is)return function(t,e,i,s){let n,o=0,a=i[0];for(s=Math.ceil(s),n=0;nn)return e}return Math.max(n,1)}(n,e,s);if(o>0){let t,i;const s=o>1?Math.round((r-a)/(o-1)):null;for(zs(e,l,h,$(s)?0:a-s,a),t=0,i=o-1;te.lineWidth,tickColor:(t,e)=>e.color,offset:!1,borderDash:[],borderDashOffset:0,borderWidth:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Es.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),_t.route("scale.ticks","color","","color"),_t.route("scale.grid","color","","borderColor"),_t.route("scale.grid","borderColor","","borderColor"),_t.route("scale.title","color","","color"),_t.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t}),_t.describe("scales",{_fallback:"scale"}),_t.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t});const Fs=t=>"left"===t?"right":"right"===t?"left":t,Bs=(t,e,i)=>"top"===e||"left"===e?t[e]+i:t[e]-i;function Vs(t,e){const i=[],s=t.length/e,n=t.length;let o=0;for(;oa+1e-6)))return l}function Ns(t){return t.drawTicks?t.tickLength:0}function js(t,e){if(!t.display)return 0;const i=$e(t.font,e),s=He(t.padding);return(Y(t.text)?t.text.length:1)*i.lineHeight+s.height}function Hs(t,e,i){let n=s(t);return(i&&"right"!==e||!i&&"right"===e)&&(n=Fs(n)),n}class $s extends Ls{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:i,_suggestedMax:s}=this;return t=q(t,Number.POSITIVE_INFINITY),e=q(e,Number.NEGATIVE_INFINITY),i=q(i,Number.POSITIVE_INFINITY),s=q(s,Number.NEGATIVE_INFINITY),{min:q(t,i),max:q(e,s),minDefined:X(t),maxDefined:X(e)}}getMinMax(t){let e,{min:i,max:s,minDefined:n,maxDefined:o}=this.getUserBounds();if(n&&o)return{min:i,max:s};const a=this.getMatchingVisibleMetas();for(let r=0,l=a.length;rs?s:i,q(s=n&&i>s?i:s,i)),max:q(s,q(i,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){Q(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:n,ticks:o}=this.options,a=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Ue(this,n,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const r=a=n||i<=1||!this.isHorizontal())return void(this.labelRotation=s);const h=this._getLabelSizes(),c=h.widest.width,d=h.highest.height,u=$t(this.chart.width-c,0,this.maxWidth);c+6>(o=t.offset?this.maxWidth/i:u/(i-1))&&(o=u/(i-(t.offset?.5:1)),a=this.maxHeight-Ns(t.grid)-e.padding-js(t.title,this.chart.options.font),r=Math.sqrt(c*c+d*d),l=Ft(Math.min(Math.asin($t((h.highest.height+6)/o,-1,1)),Math.asin($t(a/r,-1,1))-Math.asin($t(d/r,-1,1)))),l=Math.max(s,Math.min(n,l))),this.labelRotation=l}afterCalculateLabelRotation(){Q(this.options.afterCalculateLabelRotation,[this])}beforeFit(){Q(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:n}}=this,o=this._isVisible(),a=this.isHorizontal();if(o){const o=js(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=Ns(n)+o):(t.height=this.maxHeight,t.width=Ns(n)+o),i.display&&this.ticks.length){const{first:e,last:s,widest:n,highest:o}=this._getLabelSizes(),r=2*i.padding,l=zt(this.labelRotation),h=Math.cos(l),c=Math.sin(l);if(a){const e=i.mirror?0:c*n.width+h*o.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=i.mirror?0:h*n.width+c*o.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,s,c,h)}}this._handleMargins(),a?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,s){const{ticks:{align:n,padding:o},position:a}=this.options,r=0!==this.labelRotation,l="top"!==a&&"x"===this.axis;if(this.isHorizontal()){const a=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1);let c=0,d=0;r?l?(c=s*t.width,d=i*e.height):(c=i*t.height,d=s*e.width):"start"===n?d=e.width:"end"===n?c=t.width:(c=t.width/2,d=e.width/2),this.paddingLeft=Math.max((c-a+o)*this.width/(this.width-a),0),this.paddingRight=Math.max((d-h+o)*this.width/(this.width-h),0)}else{let i=e.height/2,s=t.height/2;"start"===n?(i=0,s=t.height):"end"===n&&(i=e.height,s=0),this.paddingTop=i+o,this.paddingBottom=s+o}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){Q(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,i;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,i=t.length;e{const i=t.gc,s=i.length/2;let n;if(s>e){for(n=0;n({width:n[t]||0,height:o[t]||0});return{first:v(0),last:v(e-1),widest:v(_),highest:v(y),widths:n,heights:o}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return Yt(this._alignToPixels?Gt(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&ta*s?a/i:r/s:r*s0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:n,position:o}=s,a=n.offset,r=this.isHorizontal(),l=this.ticks.length+(a?1:0),h=Ns(n),c=[],d=n.setContext(this.getContext()),u=d.drawBorder?d.borderWidth:0,f=u/2,g=function(t){return Gt(i,t,u)};let p,m,b,x,_,y,v,w,M,k,S,P;if("top"===o)p=g(this.bottom),y=this.bottom-h,w=p-f,k=g(t.top)+f,P=t.bottom;else if("bottom"===o)p=g(this.top),k=t.top,P=g(t.bottom)-f,y=p+f,w=this.top+h;else if("left"===o)p=g(this.right),_=this.right-h,v=p-f,M=g(t.left)+f,S=t.right;else if("right"===o)p=g(this.left),M=t.left,S=g(t.right)-f,_=p+f,v=this.left+h;else if("x"===e){if("center"===o)p=g((t.top+t.bottom)/2+.5);else if(U(o)){const t=Object.keys(o)[0],e=o[t];p=g(this.chart.scales[t].getPixelForValue(e))}k=t.top,P=t.bottom,w=(y=p+f)+h}else if("y"===e){if("center"===o)p=g((t.left+t.right)/2);else if(U(o)){const t=Object.keys(o)[0],e=o[t];p=g(this.chart.scales[t].getPixelForValue(e))}v=(_=p-f)-h,M=t.left,S=t.right}const D=K(s.ticks.maxTicksLimit,l),C=Math.max(1,Math.ceil(l/D));for(m=0;me.value===t);if(i>=0){return e.setContext(this.getContext(i)).lineWidth}return 0}drawGrid(t){const e=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let n,o;const a=(t,e,s)=>{s.width&&s.color&&(i.save(),i.lineWidth=s.width,i.strokeStyle=s.color,i.setLineDash(s.borderDash||[]),i.lineDashOffset=s.borderDashOffset,i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke(),i.restore())};if(e.display)for(n=0,o=s.length;n{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:i+1,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let n,o;for(n=0,o=e.length;n{const s=i.split("."),n=s.pop(),o=[t].concat(s).join("."),a=e[i].split("."),r=a.pop(),l=a.join(".");_t.route(o,n,l,r)})}(e,t.defaultRoutes);t.descriptors&&_t.describe(e,t.descriptors)}(t,o,i),this.override&&_t.override(t.id,t.overrides),o)}get(t){return this.items[t]}unregister(t){const e=this.items,i=t.id,s=this.scope;i in e&&delete e[i],s&&i in _t[s]&&(delete _t[s][i],this.override&&delete pt[i])}}var Us=new class{constructor(){this.controllers=new Ys(Ts,"datasets",!0),this.elements=new Ys(Ls,"elements"),this.plugins=new Ys(Object,"plugins"),this.scales=new Ys($s,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){[...e].forEach(e=>{const s=i||this._getRegistryForType(e);i||s.isForType(e)||s===this.plugins&&e.id?this._exec(t,s,e):J(e,e=>{const s=i||this._getRegistryForType(e);this._exec(t,s,e)})})}_exec(t,e,i){const s=dt(t);Q(i["before"+s],[],i),e[t](i),Q(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;et.filter(t=>!e.some(e=>t.plugin.id===e.plugin.id));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function qs(t,e){return e||!1!==t?!0===t?{}:t:null}function Ks(t,e,i,s){const n=t.pluginScopeKeys(e),o=t.getOptionScopes(i,n);return t.createResolver(o,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Gs(t,e){const i=_t.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function Zs(t,e){return"x"===t||"y"===t?t:e.axis||("top"===(i=e.position)||"bottom"===i?"x":"left"===i||"right"===i?"y":void 0)||t.charAt(0).toLowerCase();var i}function Qs(t){const e=t.options||(t.options={});e.plugins=K(e.plugins,{}),e.scales=function(t,e){const i=pt[t.type]||{scales:{}},s=e.scales||{},n=Gs(t.type,e),o=Object.create(null),a=Object.create(null);return Object.keys(s).forEach(t=>{const e=s[t];if(!U(e))return console.error(`Invalid scale configuration for scale: ${t}`);if(e._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);const r=Zs(t,e),l=function(t,e){return t===e?"_index_":"_value_"}(r,n),h=i.scales||{};o[r]=o[r]||t,a[t]=ot(Object.create(null),[{axis:r},e,h[r],h[l]])}),t.data.datasets.forEach(i=>{const n=i.type||t.type,r=i.indexAxis||Gs(n,e),l=(pt[n]||{}).scales||{};Object.keys(l).forEach(t=>{const e=function(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}(t,r),n=i[e+"AxisID"]||o[e]||e;a[n]=a[n]||Object.create(null),ot(a[n],[{axis:e},s[n],l[t]])})}),Object.keys(a).forEach(t=>{const e=a[t];ot(e,[_t.scales[e.type],_t.scale])}),a}(t,e)}function Js(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const tn=new Map,en=new Set;function sn(t,e){let i=tn.get(t);return i||(i=e(),tn.set(t,i),en.add(i)),i}const nn=(t,e,i)=>{const s=ct(e,i);void 0!==s&&t.add(s)};class on{constructor(t){this._config=function(t){return(t=t||{}).data=Js(t.data),Qs(t),t}(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Js(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Qs(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return sn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return sn(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return sn(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id;return sn(`${this.type}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){const i=this._scopeCache;let s=i.get(t);return s&&!e||(s=new Map,i.set(t,s)),s}getOptionScopes(t,e,i){const{options:s,type:n}=this,o=this._cachedScopes(t,i),a=o.get(e);if(a)return a;const r=new Set;e.forEach(e=>{t&&(r.add(t),e.forEach(e=>nn(r,t,e))),e.forEach(t=>nn(r,s,t)),e.forEach(t=>nn(r,pt[n]||{},t)),e.forEach(t=>nn(r,_t,t)),e.forEach(t=>nn(r,mt,t))});const l=Array.from(r);return 0===l.length&&l.push(Object.create(null)),en.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,pt[e]||{},_t.datasets[e]||{},{type:e},_t,mt]}resolveNamedOptions(t,e,i,s=[""]){const n={$shared:!0},{resolver:o,subPrefixes:a}=an(this._resolverCache,t,s);let r=o;if(function(t,e){const{isScriptable:i,isIndexable:s}=hi(t);for(const n of e){const e=i(n),o=s(n),a=(o||e)&&t[n];if(e&&(ft(a)||rn(a))||o&&Y(a))return!0}return!1}(o,e)){n.$shared=!1,r=li(o,i=ft(i)?i():i,this.createResolver(t,i,a))}for(const t of e)n[t]=r[t];return n}createResolver(t,e,i=[""],s){const{resolver:n}=an(this._resolverCache,t,i);return U(e)?li(n,e,void 0,s):n}}function an(t,e,i){let s=t.get(e);s||(s=new Map,t.set(e,s));const n=i.join();let o=s.get(n);if(!o){o={resolver:ri(e,i),subPrefixes:i.filter(t=>!t.toLowerCase().includes("hover"))},s.set(n,o)}return o}const rn=t=>U(t)&&Object.getOwnPropertyNames(t).reduce((e,i)=>e||ft(t[i]),!1);const ln=["top","bottom","left","right","chartArea"];function hn(t,e){return"top"===t||"bottom"===t||-1===ln.indexOf(t)&&"x"===e}function cn(t,e){return function(i,s){return i[t]===s[t]?i[e]-s[e]:i[t]-s[t]}}function dn(t){const e=t.chart,i=e.options.animation;e.notifyPlugins("afterRender"),Q(i&&i.onComplete,[t],e)}function un(t){const e=t.chart,i=e.options.animation;Q(i&&i.onProgress,[t],e)}function fn(t){return pe()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const gn={},pn=t=>{const e=fn(t);return Object.values(gn).filter(t=>t.canvas===e).pop()};function mn(t,e,i){const s=Object.keys(t);for(const n of s){const s=+n;if(s>=e){const o=t[n];delete t[n],(i>0||s>e)&&(t[s+i]=o)}}}class bn{constructor(t,e){const s=this.config=new on(e),n=fn(t),o=pn(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas can be reused.");const r=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||fs(n)),this.platform.updateConfig(s);const l=this.platform.acquireContext(n,r.aspectRatio),h=l&&l.canvas,c=h&&h.height,d=h&&h.width;this.id=H(),this.ctx=l,this.canvas=h,this.width=d,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Xs,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=i(t=>this.update(t),r.resizeDelay||0),this._dataChanges=[],gn[this.id]=this,l&&h?(a.listen(this,"complete",dn),a.listen(this,"progress",un),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:s,_aspectRatio:n}=this;return $(t)?e&&n?n:s?i/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Pe(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Zt(this.canvas,this.ctx),this}stop(){return a.stop(this),this}resize(t,e){a.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,s=this.canvas,n=i.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(s,t,e,n),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,Pe(this,a,!0)&&(this.notifyPlugins("resize",{size:o}),Q(i.onResize,[this,o],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){J(this.options.scales||{},(t,e)=>{t.id=e})}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce((t,e)=>(t[e]=!1,t),{});let n=[];e&&(n=n.concat(Object.keys(e).map(t=>{const i=e[t],s=Zs(t,i),n="r"===s,o="x"===s;return{options:i,dposition:n?"chartArea":o?"bottom":"left",dtype:n?"radialLinear":o?"category":"linear"}}))),J(n,e=>{const n=e.options,o=n.id,a=Zs(o,n),r=K(n.type,e.dtype);void 0!==n.position&&hn(n.position,a)===hn(e.dposition)||(n.position=e.dposition),s[o]=!0;let l=null;if(o in i&&i[o].type===r)l=i[o];else{l=new(Us.getScale(r))({id:o,type:r,ctx:this.ctx,chart:this}),i[l.id]=l}l.init(n,t)}),J(s,(t,e)=>{t||delete i[e]}),J(i,t=>{ai.configure(this,t,t.options),ai.addBox(this,t)})}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort((t,e)=>t.index-e.index),i>e){for(let t=e;te.length&&delete this._stacks,t.forEach((t,i)=>{0===e.filter(e=>e===t._dataset).length&&this._destroyDatasetMeta(i)})}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=e.length;i{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const n=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let t=0,e=this.data.datasets.length;t{t.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(cn("z","_idx")),this._lastEvent&&this._eventHandler(this._lastEvent,!0),this.render()}_updateScales(){J(this.scales,t=>{ai.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);gt(e,i)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:n}of e){mn(t,s,"_removeElements"===i?-n:n)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,i=e=>new Set(t.filter(t=>t[0]===e).map((t,e)=>e+","+t.splice(1).join(","))),s=i(0);for(let t=1;tt.split(",")).map(t=>({method:t[1],start:+t[2],count:+t[3]}))}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;ai.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],J(this.boxes,t=>{i&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))},this),this._layers.forEach((t,e)=>{t._idx=e}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let t=0,e=this.data.datasets.length;t=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,s=!i.disabled,n=this.chartArea,o={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",o)&&(s&&te(e,{left:!1===i.left?0:n.left-i.left,right:!1===i.right?this.width:n.right+i.right,top:!1===i.top?0:n.top-i.top,bottom:!1===i.bottom?this.height:n.bottom+i.bottom}),t.controller.draw(),s&&ee(e),o.cancelable=!1,this.notifyPlugins("afterDatasetDraw",o))}getElementsAtEventForMode(t,e,i,s){const n=Ie.modes[e];return"function"==typeof n?n(this,t,i,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let s=i.filter(t=>t&&t._dataset===e).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=Xe(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",n=this.getDatasetMeta(t),o=n.controller._resolveAnimations(void 0,s);ut(e)?(n.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),o.update(n,{visible:i}),this.update(e=>e.datasetIndex===t?s:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),a.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,i,s),t[i]=s},s=(t,e,i)=>{t.offsetX=e,t.offsetY=i,this._eventHandler(t)};J(this.options.events,t=>i(t,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(i,s)=>{e.addEventListener(this,i,s),t[i]=s},s=(i,s)=>{t[i]&&(e.removeEventListener(this,i,s),delete t[i])},n=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",n),i("detach",o)};o=(()=>{this.attached=!1,s("resize",n),this._stop(),this._resize(0,0),i("attach",a)}),e.isAttached(this.canvas)?a():o()}unbindEvents(){J(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},J(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const s=i?"set":"remove";let n,o,a,r;for("dataset"===e&&(n=this.getDatasetMeta(t[0].datasetIndex)).controller["_"+s+"DatasetHoverStyle"](),a=0,r=t.length;a{const i=this.getDatasetMeta(t);if(!i)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:i.data[e],index:e}});!tt(i,e)&&(this._active=i,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}_updateHoverStyles(t,e,i){const s=this.options.hover,n=(t,e)=>t.filter(t=>!e.some(e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)),o=n(e,t),a=i?t:n(t,e);o.length&&this.updateHoverStyle(o,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0},s=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",i,s))return;const n=this._handleEvent(t,e);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(n||i.changed)&&this.render(),this}_handleEvent(t,e){const{_active:i=[],options:s}=this,n=s.hover,o=e;let a=[],r=!1,l=null;return"mouseout"!==t.type&&(a=this.getElementsAtEventForMode(t,n.mode,n,o),l="click"===t.type?this._lastEvent:t),this._lastEvent=null,Jt(t,this.chartArea,this._minPadding)&&(Q(s.onHover,[t,a,this],this),"mouseup"!==t.type&&"click"!==t.type&&"contextmenu"!==t.type||Q(s.onClick,[t,a,this],this)),((r=!tt(a,i))||e)&&(this._active=a,this._updateHoverStyles(a,i,e)),this._lastEvent=l,r}}const xn=()=>J(bn.instances,t=>t._plugins.invalidate());function _n(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}Object.defineProperties(bn,{defaults:{enumerable:!0,value:_t},instances:{enumerable:!0,value:gn},overrides:{enumerable:!0,value:pt},registry:{enumerable:!0,value:Us},version:{enumerable:!0,value:"3.6.1"},getChart:{enumerable:!0,value:pn},register:{enumerable:!0,value:(...t)=>{Us.add(...t),xn()}},unregister:{enumerable:!0,value:(...t)=>{Us.remove(...t),xn()}}});class yn{constructor(t){this.options=t||{}}formats(){return _n()}parse(t,e){return _n()}format(t,e){return _n()}add(t,e,i){return _n()}diff(t,e,i){return _n()}startOf(t,e,i){return _n()}endOf(t,e){return _n()}}yn.override=function(t){Object.assign(yn.prototype,t)};var vn={_date:yn};function wn(t){const e=t.iScale,i=function(t,e){if(!t._cache.$bar){const i=t.getMatchingVisibleMetas(e);let s=[];for(let e=0,n=i.length;et-e))}return t._cache.$bar}(e,t.type);let s,n,o,a,r=e._length;const l=()=>{32767!==o&&-32768!==o&&(ut(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(s=0,n=i.length;sMath.abs(r)&&(l=r,h=a),e[i.axis]=h,e._custom={barStart:l,barEnd:h,start:n,end:o,min:a,max:r}}(t,e,i,s):e[i.axis]=i.parse(t,s),e}function kn(t,e,i,s){const n=t.iScale,o=t.vScale,a=n.getLabels(),r=n===o,l=[];let h,c,d,u;for(h=i,c=i+s;ht.x,i="left",s="right"):(e=t.base=i?1:-1)}(c,e,o)*n,d===o&&(p-=c/2),h=p+c),p===e.getPixelForValue(o)){const t=Ot(c)*e.getLineWidthForValue(o)/2;p+=t,c-=t}return{size:c,base:p,head:h,center:h+c/2}}_calculateBarIndexPixels(t,e){const i=e.scale,s=this.options,n=s.skipNull,o=K(s.maxBarThickness,1/0);let a,r;if(e.grouped){const i=n?this._getStackCount(t):e.stackCount,l="flex"===s.barThickness?function(t,e,i,s){const n=e.pixels,o=n[t];let a=t>0?n[t-1]:null,r=t=0;--i)e=Math.max(e,t[i].size(this.resolveDataElementOptions(i))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,{xScale:i,yScale:s}=e,n=this.getParsed(t),o=i.getLabelForValue(n.x),a=s.getLabelForValue(n.y),r=n._custom;return{label:e.label,value:"("+o+", "+a+(r?", "+r:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a}=this._cachedMeta,r=this.resolveDataElementOptions(e,s),l=this.getSharedOptions(r),h=this.includeOptions(s,l),c=o.axis,d=a.axis;for(let r=e;r""}}}};class Ln extends Ts{constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,s=this._cachedMeta;if(!1===this._parsing)s._parsed=i;else{let n,o,a=t=>+i[t];if(U(i[t])){const{key:t="value"}=this._parsing;a=(e=>+ct(i[e],t))}for(n=t,o=t+e;nHt(t,r,l,!0)?1:Math.max(e,e*i,s,s*i),g=(t,e,s)=>Ht(t,r,l,!0)?-1:Math.min(e,e*i,s,s*i),p=f(0,h,d),m=f(St,c,u),b=g(yt,h,d),x=g(yt+St,c,u);s=(p-b)/2,n=(m-x)/2,o=-(p+b)/2,a=-(m+x)/2}return{ratioX:s,ratioY:n,offsetX:o,offsetY:a}}(c,h,r),p=(i.width-o)/d,m=(i.height-o)/u,b=Math.max(Math.min(p,m)/2,0),x=Z(this.options.radius,b),_=(x-Math.max(x*r,0))/this._getVisibleDatasetWeightTotal();this.offsetX=f*x,this.offsetY=g*x,s.total=this.calculateTotal(),this.outerRadius=x-_*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-_*l,0),this.updateElements(n,0,n.length,t)}_circumference(t,e){const i=this.options,s=this._cachedMeta,n=this._getCircumference();return e&&i.animation.animateRotate||!this.chart.getDataVisibility(t)||null===s._parsed[t]||s.data[t].hidden?0:this.calculateCircumference(s._parsed[t]*n/vt)}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.chartArea,r=o.options.animation,l=(a.left+a.right)/2,h=(a.top+a.bottom)/2,c=n&&r.animateScale,d=c?0:this.innerRadius,u=c?0:this.outerRadius,f=this.resolveDataElementOptions(e,s),g=this.getSharedOptions(f),p=this.includeOptions(s,g);let m,b=this._getRotation();for(m=0;m0&&!isNaN(t)?vt*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=Ii(e._parsed[t],i.options.locale);return{label:s[t]||"",value:n}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,n,o,a,r;if(!t)for(s=0,n=i.data.datasets.length;s"spacing"!==t,_indexable:t=>"spacing"!==t},Ln.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label(t){let e=t.label;const i=": "+t.formattedValue;return Y(e)?(e=e.slice())[0]+=i:e+=i,e}}}}};class Rn extends Ts{initialize(){this.enableOptionSharing=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:i,data:s=[],_dataset:n}=e,o=this.chart._animationsDisabled;let{start:a,count:r}=function(t,e,i){const s=e.length;let n=0,o=s;if(t._sorted){const{iScale:a,_parsed:r}=t,l=a.axis,{min:h,max:c,minDefined:d,maxDefined:u}=a.getUserBounds();d&&(n=$t(Math.min(le(r,a.axis,h).lo,i?s:le(e,l,a.getPixelForValue(h)).lo),0,s-1)),o=u?$t(Math.max(le(r,a.axis,c).hi+1,i?0:le(e,l,a.getPixelForValue(c)).hi+1),n,s)-n:s-n}return{start:n,count:o}}(e,s,o);this._drawStart=a,this._drawCount=r,function(t){const{xScale:e,yScale:i,_scaleRanges:s}=t,n={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!s)return t._scaleRanges=n,!0;const o=s.xmin!==e.min||s.xmax!==e.max||s.ymin!==i.min||s.ymax!==i.max;return Object.assign(s,n),o}(e)&&(a=0,r=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!n._decimated,i.points=s;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(i,void 0,{animated:!o,options:l},t),this.updateElements(s,a,r,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,h=this.resolveDataElementOptions(e,s),c=this.getSharedOptions(h),d=this.includeOptions(s,c),u=o.axis,f=a.axis,{spanGaps:g,segment:p}=this.options,m=Lt(g)?g:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||n||"none"===s;let x=e>0&&this.getParsed(e-1);for(let h=e;h0&&i[u]-x[u]>m,p&&(g.parsed=i,g.raw=l.data[h]),d&&(g.options=c||this.resolveDataElementOptions(h,e.active?"active":s)),b||this.updateElement(e,h,g,s),x=i}this.updateSharedOptions(c,s,h)}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,n,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}Rn.id="line",Rn.defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1},Rn.overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};class En extends Ts{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=Ii(e._parsed[t].r,i.options.locale);return{label:s[t]||"",value:n}}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),n=Math.max(s/2,0),o=(n-Math.max(i.cutoutPercentage?n/100*i.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=n-o*this.index,this.innerRadius=this.outerRadius-o}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=this.getDataset(),r=o.options.animation,l=this._cachedMeta.rScale,h=l.xCenter,c=l.yCenter,d=l.getIndexAngle(0)-.5*yt;let u,f=d;const g=360/this.countVisibleElements();for(u=0;u{!isNaN(t.data[s])&&this.chart.getDataVisibility(s)&&i++}),i}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?zt(this.resolveDataElementOptions(t,e).angle||i):0}}En.id="polarArea",En.defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0},En.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label:t=>t.chart.data.labels[t.dataIndex]+": "+t.formattedValue}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};class In extends Ln{}In.id="pie",In.defaults={cutout:0,rotation:0,circumference:360,radius:"100%"};class zn extends Ts{getLabelAndValue(t){const e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}update(t){const e=this._cachedMeta,i=e.dataset,s=e.data||[],n=e.iScale.getLabels();if(i.points=s,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:!0,_fullLoop:n.length===s.length,options:e};this.updateElement(i,void 0,o,t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,i,s){const n=this.getDataset(),o=this._cachedMeta.rScale,a="reset"===s;for(let r=e;r"",label:t=>"("+t.label+", "+t.formattedValue+")"}}},scales:{x:{type:"linear"},y:{type:"linear"}}};var Bn=Object.freeze({__proto__:null,BarController:An,BubbleController:Tn,DoughnutController:Ln,LineController:Rn,PolarAreaController:En,PieController:In,RadarController:zn,ScatterController:Fn});function Vn(t,e,i){const{startAngle:s,pixelMargin:n,x:o,y:a,outerRadius:r,innerRadius:l}=e;let h=n/r;t.beginPath(),t.arc(o,a,r,s-h,i+h),l>n?(h=n/l,t.arc(o,a,l,i+h,s-h,!0)):t.arc(o,a,n,i+St,s-St),t.closePath(),t.clip()}function Wn(t,e,i,s){const n=We(t.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]);const o=(i-e)/2,a=Math.min(o,s*e/2),r=t=>{const e=(i-Math.min(o,t))*s/2;return $t(t,0,Math.min(o,e))};return{outerStart:r(n.outerStart),outerEnd:r(n.outerEnd),innerStart:$t(n.innerStart,0,a),innerEnd:$t(n.innerEnd,0,a)}}function Nn(t,e,i,s){return{x:i+t*Math.cos(e),y:s+t*Math.sin(e)}}function jn(t,e,i,s,n){const{x:o,y:a,startAngle:r,pixelMargin:l,innerRadius:h}=e,c=Math.max(e.outerRadius+s+i-l,0),d=h>0?h+s+i+l:0;let u=0;const f=n-r;if(s){const t=((h>0?h-s:0)+(c>0?c-s:0))/2;u=(f-(0!==t?f*t/(t+s):f))/2}const g=(f-Math.max(.001,f*c-i/yt)/c)/2,p=r+g+u,m=n-g-u,{outerStart:b,outerEnd:x,innerStart:_,innerEnd:y}=Wn(e,d,c,m-p),v=c-b,w=c-x,M=p+b/v,k=m-x/w,S=d+_,P=d+y,D=p+_/S,C=m-y/P;if(t.beginPath(),t.arc(o,a,c,M,k),x>0){const e=Nn(w,k,o,a);t.arc(e.x,e.y,x,k,m+St)}const O=Nn(P,m,o,a);if(t.lineTo(O.x,O.y),y>0){const e=Nn(P,C,o,a);t.arc(e.x,e.y,y,m+St,C+Math.PI)}if(t.arc(o,a,d,m-y/d,p+_/d,!0),_>0){const e=Nn(S,D,o,a);t.arc(e.x,e.y,_,D+Math.PI,p-St)}const A=Nn(v,p,o,a);if(t.lineTo(A.x,A.y),b>0){const e=Nn(v,M,o,a);t.arc(e.x,e.y,b,p-St,M)}t.closePath()}function Hn(t,e,i,s,n){const{options:o}=e,a="inner"===o.borderAlign;o.borderWidth&&(a?(t.lineWidth=2*o.borderWidth,t.lineJoin="round"):(t.lineWidth=o.borderWidth,t.lineJoin="bevel"),e.fullCircles&&function(t,e,i){const{x:s,y:n,startAngle:o,pixelMargin:a,fullCircles:r}=e,l=Math.max(e.outerRadius-a,0),h=e.innerRadius+a;let c;for(i&&Vn(t,e,o+vt),t.beginPath(),t.arc(s,n,h,o+vt,o,!0),c=0;c=vt||Ht(n,a,r),f=Ut(o,l+d,h+d);return u&&f}getCenterPoint(t){const{x:e,y:i,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius","circumference"],t),{offset:r,spacing:l}=this.options,h=(s+n)/2,c=(o+a+l+r)/2;return{x:e+Math.cos(h)*c,y:i+Math.sin(h)*c}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:i}=this,s=(e.offset||0)/2,n=(e.spacing||0)/2;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=i>vt?Math.floor(i/vt):0,0===i||this.innerRadius<0||this.outerRadius<0)return;t.save();let o=0;if(s){o=s/2;const e=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(e)*o,Math.sin(e)*o),this.circumference>=yt&&(o=s)}t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor;const a=function(t,e,i,s){const{fullCircles:n,startAngle:o,circumference:a}=e;let r=e.endAngle;if(n){jn(t,e,i,s,o+vt);for(let e=0;er&&o>r;return{count:s,start:l,loop:e.loop,ilen:h(a+(h?r-t:t))%o,_=()=>{f!==g&&(t.lineTo(m,g),t.lineTo(m,f),t.lineTo(m,p))};for(l&&(d=n[x(0)],t.moveTo(d.x,d.y)),c=0;c<=r;++c){if((d=n[x(c)]).skip)continue;const e=d.x,i=d.y,s=0|e;s===u?(ig&&(g=i),m=(b*m+e)/++b):(_(),t.lineTo(e,i),u=s,b=0,f=g=i),p=i}_()}function Gn(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||i)?Kn:qn}$n.id="arc",$n.defaults={borderAlign:"center",borderColor:"#fff",borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0},$n.defaultRoutes={backgroundColor:"backgroundColor"};const Zn="function"==typeof Path2D;function Qn(t,e,i,s){Zn&&!e.options.segment?function(t,e,i,s){let n=e._path;n||(n=e._path=new Path2D,e.path(n,i,s)&&n.closePath()),Yn(t,e.options),t.stroke(n)}(t,e,i,s):function(t,e,i,s){const{segments:n,options:o}=e,a=Gn(e);for(const r of n)Yn(t,o,r.style),t.beginPath(),a(t,e,r,{start:i,end:i+s-1})&&t.closePath(),t.stroke()}(t,e,i,s)}class Jn extends Ls{constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const i=this.options;if((i.tension||"monotone"===i.cubicInterpolationMode)&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;Pi(this._points,i,t,s,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Yi(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],n=this.points,o=$i(this,{property:e,start:s,end:s});if(!o.length)return;const a=[],r=function(t){return t.stepped?Li:t.tension||"monotone"===t.cubicInterpolationMode?Ri:Ti}(i);let l,h;for(l=0,h=o.length;l"borderDash"!==t&&"fill"!==t};class eo extends Ls{constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,e,i){const s=this.options,{x:n,y:o}=this.getProps(["x","y"],i);return Math.pow(t-n,2)+Math.pow(e-o,2){co(t)})}var fo={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,i)=>{if(!i.enabled)return void uo(t);const s=t.width;t.data.datasets.forEach((e,n)=>{const{_data:o,indexAxis:a}=e,r=t.getDatasetMeta(n),l=o||e.data;if("y"===Ye([a,t.options.indexAxis]))return;if("line"!==r.type)return;const h=t.scales[r.xAxisID];if("linear"!==h.type&&"time"!==h.type)return;if(t.options.parsing)return;let{start:c,count:d}=function(t,e){const i=e.length;let s,n=0;const{iScale:o}=t,{min:a,max:r,minDefined:l,maxDefined:h}=o.getUserBounds();return l&&(n=$t(le(e,o.axis,a).lo,0,i-1)),{start:n,count:s=h?$t(le(e,o.axis,r).hi+1,n,i)-n:i-n}}(r,l);if(d<=(i.threshold||4*s))return void co(e);let u;switch($(o)&&(e._data=l,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),i.algorithm){case"lttb":u=function(t,e,i,s,n){const o=n.samples||s;if(o>=i)return t.slice(e,e+i);const a=[],r=(i-2)/(o-2);let l=0;const h=e+i-1;let c,d,u,f,g,p=e;for(a[l++]=t[p],c=0;cu&&(u=f,d=t[s],g=s);a[l++]=d,p=g}return a[l++]=t[h],a}(l,c,d,s,i);break;case"min-max":u=function(t,e,i,s){let n,o,a,r,l,h,c,d,u,f,g=0,p=0;const m=[],b=e+i-1,x=t[e].x,_=t[b].x-x;for(n=e;nf&&(f=r,c=n),g=(p*g+o.x)/++p;else{const i=n-1;if(!$(h)&&!$(c)){const e=Math.min(h,c),s=Math.max(h,c);e!==d&&e!==i&&m.push({...t[e],x:g}),s!==d&&s!==i&&m.push({...t[s],x:g})}n>0&&i!==d&&m.push(t[i]),m.push(o),l=e,p=0,u=f=r,h=c=d=n}}return m}(l,c,d,s);break;default:throw new Error(`Unsupported decimation algorithm '${i.algorithm}'`)}e._decimated=u})},destroy(t){uo(t)}};function go(t,e,i){const s=function(t){const e=t.options,i=e.fill;let s=K(i&&i.target,i);return void 0===s&&(s=!!e.backgroundColor),!1!==s&&null!==s&&(!0===s?"origin":s)}(t);if(U(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return X(n)&&Math.floor(n)===n?("-"!==s[0]&&"+"!==s[0]||(n=e+n),!(n===e||n<0||n>=i)&&n):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}class po{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){const{x:s,y:n,radius:o}=this;return e=e||{start:0,end:vt},t.arc(s,n,o,e.end,e.start,!0),!i.bounds}interpolate(t){const{x:e,y:i,radius:s}=this,n=t.angle;return{x:e+Math.cos(n)*s,y:i+Math.sin(n)*s,angle:n}}}function mo(t){return(t.scale||{}).getPointPositionForValue?function(t){const{scale:e,fill:i}=t,s=e.options,n=e.getLabels().length,o=[],a=s.reverse?e.max:e.min,r=s.reverse?e.min:e.max;let l,h,c;if(c="start"===i?a:"end"===i?r:U(i)?i.value:e.getBaseValue(),s.grid.circular)return h=e.getPointPositionForValue(0,a),new po({x:h.x,y:h.y,radius:e.getDistanceFromCenterForValue(c)});for(l=0;lt;e--){const t=i[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function xo(t,e,i){const s=[];for(let n=0;n{e=bo(t,e,n);const a=n[t],r=n[e];null!==s?(o.push({x:a.x,y:s}),o.push({x:r.x,y:s})):null!==i&&(o.push({x:i,y:a.y}),o.push({x:i,y:r.y}))}),o}(t,e),i.length?new Jn({points:i,options:{tension:0},_loop:s,_fullLoop:s}):null}function wo(t,e,i){let s=t[e].fill;const n=[e];let o;if(!i)return s;for(;!1!==s&&-1===n.indexOf(s);){if(!X(s))return s;if(!(o=t[s]))return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function Mo(t,e,i){t.beginPath(),e.path(t),t.lineTo(e.last().x,i),t.lineTo(e.first().x,i),t.closePath(),t.clip()}function ko(t,e,i,s){if(s)return;let n=e[t],o=i[t];return"angle"===t&&(n=jt(n),o=jt(o)),{property:t,start:n,end:o}}function So(t,e,i,s){return t&&e?s(t[i],e[i]):t?t[i]:e?e[i]:0}function Po(t,e,i){const{top:s,bottom:n}=e.chart.chartArea,{property:o,start:a,end:r}=i||{};"x"===o&&(t.beginPath(),t.rect(a,s,r-a,n-s),t.clip())}function Do(t,e,i,s){const n=e.interpolate(i,s);n&&t.lineTo(n.x,n.y)}function Co(t,e){const{line:i,target:s,property:n,color:o,scale:a}=e,r=function(t,e,i){const s=t.segments,n=t.points,o=e.points,a=[];for(const t of s){let{start:s,end:r}=t;r=bo(s,r,n);const l=ko(i,n[s],n[r],t.loop);if(!e.segments){a.push({source:t,target:l,start:n[s],end:n[r]});continue}const h=$i(e,l);for(const e of h){const s=ko(i,o[e.start],o[e.end],e.loop),r=Hi(t,n,s);for(const t of r)a.push({source:t,target:e,start:{[i]:So(l,s,"start",Math.max)},end:{[i]:So(l,s,"end",Math.min)}})}}return a}(i,s,n);for(const{source:e,target:l,start:h,end:c}of r){const{style:{backgroundColor:r=o}={}}=e,d=!0!==s;t.save(),t.fillStyle=r,Po(t,a,d&&ko(n,h,c)),t.beginPath();const u=!!i.pathSegment(t,e);let f;if(d){u?t.closePath():Do(t,s,c,n);const e=!!s.pathSegment(t,l,{move:u,reverse:!0});(f=u&&e)||Do(t,s,h,n)}t.closePath(),t.fill(f?"evenodd":"nonzero"),t.restore()}}function Oo(t,e,i){const s=yo(e),{line:n,scale:o,axis:a}=e,r=n.options,l=r.fill,h=r.backgroundColor,{above:c=h,below:d=h}=l||{};s&&n.points.length&&(te(t,i),function(t,e){const{line:i,target:s,above:n,below:o,area:a,scale:r}=e,l=i._loop?"angle":e.axis;t.save(),"x"===l&&o!==n&&(Mo(t,s,a.top),Co(t,{line:i,target:s,color:n,scale:r,property:l}),t.restore(),t.save(),Mo(t,s,a.bottom)),Co(t,{line:i,target:s,color:o,scale:r,property:l}),t.restore()}(t,{line:n,target:s,above:c,below:d,area:i,scale:o,axis:a}),ee(t))}var Ao={id:"filler",afterDatasetsUpdate(t,e,i){const s=(t.data.datasets||[]).length,n=[];let o,a,r,l;for(a=0;a=0;--e){const i=n[e].$filler;i&&(i.line.updateControlPoints(o,i.axis),s&&Oo(t.ctx,i,o))}},beforeDatasetsDraw(t,e,i){if("beforeDatasetsDraw"!==i.drawTime)return;const s=t.getSortedVisibleDatasetMetas();for(let e=s.length-1;e>=0;--e){const i=s[e].$filler;i&&Oo(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,i){const s=e.meta.$filler;s&&!1!==s.fill&&"beforeDatasetDraw"===i.drawTime&&Oo(t.ctx,s,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const To=(t,e)=>{let{boxHeight:i=e,boxWidth:s=e}=t;return t.usePointStyle&&(i=Math.min(i,e),s=Math.min(s,e)),{boxWidth:s,boxHeight:i,itemHeight:Math.max(e,i)}},Lo=(t,e)=>null!==t&&null!==e&&t.datasetIndex===e.datasetIndex&&t.index===e.index;class Ro extends Ls{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=Q(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(e=>t.filter(e,this.chart.data))),t.sort&&(e=e.sort((e,i)=>t.sort(e,i,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const i=t.labels,s=$e(i.font),n=s.size,o=this._computeTitleHeight(),{boxWidth:a,itemHeight:r}=To(i,n);let l,h;e.font=s.string,this.isHorizontal()?(l=this.maxWidth,h=this._fitRows(o,n,a,r)+10):(h=this.maxHeight,l=this._fitCols(o,n,a,r)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:n,maxWidth:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.lineWidths=[0],h=s+a;let c=t;n.textAlign="left",n.textBaseline="middle";let d=-1,u=-h;return this.legendItems.forEach((t,f)=>{const g=i+e/2+n.measureText(t.text).width;(0===f||l[l.length-1]+g+2*a>o)&&(c+=h,l[l.length-(f>0?0:1)]=0,u+=h,d++),r[f]={left:0,top:u,row:d,width:g,height:s},l[l.length-1]+=g+a}),c}_fitCols(t,e,i,s){const{ctx:n,maxHeight:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.columnSizes=[],h=o-t;let c=a,d=0,u=0,f=0,g=0;return this.legendItems.forEach((t,o)=>{const p=i+e/2+n.measureText(t.text).width;o>0&&u+s+2*a>h&&(c+=d+a,l.push({width:d,height:u}),f+=d+a,g++,d=u=0),r[o]={left:f,top:u,col:g,width:p,height:s},d=Math.max(d,p),u+=s+a}),c+=d,l.push({width:d,height:u}),c}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:o}}=this,a=Bi(o,this.left,this.width);if(this.isHorizontal()){let o=0,r=n(i,this.left+s,this.right-this.lineWidths[o]);for(const l of e)o!==l.row&&(o=l.row,r=n(i,this.left+s,this.right-this.lineWidths[o])),l.top+=this.top+t+s,l.left=a.leftForLtr(a.x(r),l.width),r+=l.width+s}else{let o=0,r=n(i,this.top+t+s,this.bottom-this.columnSizes[o].height);for(const l of e)l.col!==o&&(o=l.col,r=n(i,this.top+t+s,this.bottom-this.columnSizes[o].height)),l.top=r,l.left+=this.left+s,l.left=a.leftForLtr(a.x(l.left),l.width),r+=l.height+s}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;te(t,this),this._draw(),ee(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:a,labels:r}=t,l=_t.color,h=Bi(t.rtl,this.left,this.width),c=$e(r.font),{color:d,padding:u}=r,f=c.size,g=f/2;let p;this.drawTitle(),s.textAlign=h.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:m,boxHeight:b,itemHeight:x}=To(r,f),_=this.isHorizontal(),y=this._computeTitleHeight();p=_?{x:n(a,this.left+u,this.right-i[0]),y:this.top+u+y,line:0}:{x:this.left+u,y:n(a,this.top+y+u,this.bottom-e[0].height),line:0},Vi(this.ctx,t.textDirection);const v=x+u;this.legendItems.forEach((w,M)=>{s.strokeStyle=w.fontColor||d,s.fillStyle=w.fontColor||d;const k=s.measureText(w.text).width,S=h.textAlign(w.textAlign||(w.textAlign=r.textAlign)),P=m+g+k;let D=p.x,C=p.y;h.setWidth(this.width),_?M>0&&D+P+u>this.right&&(C=p.y+=v,p.line++,D=p.x=n(a,this.left+u,this.right-i[p.line])):M>0&&C+v>this.bottom&&(D=p.x=D+e[p.line].width+u,p.line++,C=p.y=n(a,this.top+y+u,this.bottom-e[p.line].height)),function(t,e,i){if(isNaN(m)||m<=0||isNaN(b)||b<0)return;s.save();const n=K(i.lineWidth,1);if(s.fillStyle=K(i.fillStyle,l),s.lineCap=K(i.lineCap,"butt"),s.lineDashOffset=K(i.lineDashOffset,0),s.lineJoin=K(i.lineJoin,"miter"),s.lineWidth=n,s.strokeStyle=K(i.strokeStyle,l),s.setLineDash(K(i.lineDash,[])),r.usePointStyle){const o={radius:m*Math.SQRT2/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:n},a=h.xPlus(t,m/2);Qt(s,o,a,e+g)}else{const o=e+Math.max((f-b)/2,0),a=h.leftForLtr(t,m),r=je(i.borderRadius);s.beginPath(),Object.values(r).some(t=>0!==t)?ae(s,{x:a,y:o,w:m,h:b,radius:r}):s.rect(a,o,m,b),s.fill(),0!==n&&s.stroke()}s.restore()}(h.x(D),C,w),D=o(S,D+m+g,_?D+P:this.right,t.rtl),function(t,e,i){ne(s,i.text,t,e+x/2,c,{strikethrough:i.hidden,textAlign:h.textAlign(i.textAlign)})}(h.x(D),C,w),_?p.x+=P+u:p.y+=v}),Wi(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=$e(e.font),o=He(e.padding);if(!e.display)return;const a=Bi(t.rtl,this.left,this.width),r=this.ctx,l=e.position,h=i.size/2,c=o.top+h;let d,u=this.left,f=this.width;if(this.isHorizontal())f=Math.max(...this.lineWidths),d=this.top+c,u=n(t.align,u,this.right-f);else{const e=this.columnSizes.reduce((t,e)=>Math.max(t,e.height),0);d=c+n(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const g=n(l,u,u+f);r.textAlign=a.textAlign(s(l)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=i.string,ne(r,e.text,g,d,i)}_computeTitleHeight(){const t=this.options.title,e=$e(t.font),i=He(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,n;if(Ut(t,this.left,this.right)&&Ut(e,this.top,this.bottom))for(n=this.legendHitBoxes,i=0;it.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:i,pointStyle:s,textAlign:n,color:o}}=t.legend.options;return t._getSortedDatasetMetas().map(t=>{const a=t.controller.getStyle(i?0:void 0),r=He(a.borderWidth);return{text:e[t.index].label,fillStyle:a.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:a.borderCapStyle,lineDash:a.borderDash,lineDashOffset:a.borderDashOffset,lineJoin:a.borderJoinStyle,lineWidth:(r.width+r.height)/4,strokeStyle:a.borderColor,pointStyle:s||a.pointStyle,rotation:a.rotation,textAlign:n||a.textAlign,borderRadius:0,datasetIndex:t.index}},this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class Io extends Ls{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this.options;if(this.left=0,this.top=0,!i.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const s=Y(i.text)?i.text.length:1;this._padding=He(i.padding);const n=s*$e(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=n:this.width=n}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:s,right:o,options:a}=this,r=a.align;let l,h,c,d=0;return this.isHorizontal()?(h=n(r,i,o),c=e+t,l=o-i):("left"===a.position?(h=i+t,c=n(r,s,e),d=-.5*yt):(h=o-t,c=n(r,e,s),d=.5*yt),l=s-e),{titleX:h,titleY:c,maxWidth:l,rotation:d}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=$e(e.font),n=i.lineHeight/2+this._padding.top,{titleX:o,titleY:a,maxWidth:r,rotation:l}=this._drawArgs(n);ne(t,e.text,0,0,i,{color:e.color,maxWidth:r,rotation:l,textAlign:s(e.align),textBaseline:"middle",translation:[o,a]})}}var zo={id:"title",_element:Io,start(t,e,i){!function(t,e){const i=new Io({ctx:t.ctx,options:e,chart:t});ai.configure(t,i,e),ai.addBox(t,i),t.titleBlock=i}(t,i)},stop(t){const e=t.titleBlock;ai.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){const s=t.titleBlock;ai.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Fo=new WeakMap;var Bo={id:"subtitle",start(t,e,i){const s=new Io({ctx:t.ctx,options:i,chart:t});ai.configure(t,s,i),ai.addBox(t,s),Fo.set(t,s)},stop(t){ai.removeBox(t,Fo.get(t)),Fo.delete(t)},beforeUpdate(t,e,i){const s=Fo.get(t);ai.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Vo={average(t){if(!t.length)return!1;let e,i,s=0,n=0,o=0;for(e=0,i=t.length;e-1?t.split("\n"):t}function jo(t,e){const{element:i,datasetIndex:s,index:n}=e,o=t.getDatasetMeta(s).controller,{label:a,value:r}=o.getLabelAndValue(n);return{chart:t,label:a,parsed:o.getParsed(n),raw:t.data.datasets[s].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:i}}function Ho(t,e){const i=t._chart.ctx,{body:s,footer:n,title:o}=t,{boxWidth:a,boxHeight:r}=e,l=$e(e.bodyFont),h=$e(e.titleFont),c=$e(e.footerFont),d=o.length,u=n.length,f=s.length,g=He(e.padding);let p=g.height,m=0,b=s.reduce((t,e)=>t+e.before.length+e.lines.length+e.after.length,0);if(b+=t.beforeBody.length+t.afterBody.length,d&&(p+=d*h.lineHeight+(d-1)*e.titleSpacing+e.titleMarginBottom),b){p+=f*(e.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(b-f)*l.lineHeight+(b-1)*e.bodySpacing}u&&(p+=e.footerMarginTop+u*c.lineHeight+(u-1)*e.footerSpacing);let x=0;const _=function(t){m=Math.max(m,i.measureText(t).width+x)};return i.save(),i.font=h.string,J(t.title,_),i.font=l.string,J(t.beforeBody.concat(t.afterBody),_),x=e.displayColors?a+2+e.boxPadding:0,J(s,t=>{J(t.before,_),J(t.lines,_),J(t.after,_)}),x=0,i.font=c.string,J(t.footer,_),i.restore(),{width:m+=g.width,height:p}}function $o(t,e,i,s){const{x:n,width:o}=i,{width:a,chartArea:{left:r,right:l}}=t;let h="center";return"center"===s?h=n<=(r+l)/2?"left":"right":n<=o/2?h="left":n>=a-o/2&&(h="right"),function(t,e,i,s){const{x:n,width:o}=s,a=i.caretSize+i.caretPadding;return"left"===t&&n+o+a>e.width||"right"===t&&n-o-a<0||void 0}(h,t,e,i)&&(h="center"),h}function Yo(t,e,i){const s=e.yAlign||function(t,e){const{y:i,height:s}=e;return it.height-s/2?"bottom":"center"}(t,i);return{xAlign:e.xAlign||$o(t,e,i,s),yAlign:s}}function Uo(t,e,i,s){const{caretSize:n,caretPadding:o,cornerRadius:a}=t,{xAlign:r,yAlign:l}=i,h=n+o,{topLeft:c,topRight:d,bottomLeft:u,bottomRight:f}=je(a);let g=function(t,e){let{x:i,width:s}=t;return"right"===e?i-=s:"center"===e&&(i-=s/2),i}(e,r);const p=function(t,e,i){let{y:s,height:n}=t;return"top"===e?s+=i:s-="bottom"===e?n+i:n/2,s}(e,l,h);return"center"===l?"left"===r?g+=h:"right"===r&&(g-=h):"left"===r?g-=Math.max(c,u)+n:"right"===r&&(g+=Math.max(d,f)+n),{x:$t(g,0,s.width-e.width),y:$t(p,0,s.height-e.height)}}function Xo(t,e,i){const s=He(i.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-s.right:t.x+s.left}function qo(t){return Wo([],No(t))}function Ko(t,e){const i=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return i?t.override(i):t}class Go extends Ls{constructor(t){super(),this.opacity=0,this._active=[],this._chart=t._chart,this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this._chart,i=this.options.setContext(this.getContext()),s=i.enabled&&e.options.animation&&i.animations,n=new xs(this._chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(n)),n}getContext(){return this.$context||(this.$context=(t=this._chart.getContext(),e=this,i=this._tooltipItems,Xe(t,{tooltip:e,tooltipItems:i,type:"tooltip"})));var t,e,i}getTitle(t,e){const{callbacks:i}=e,s=i.beforeTitle.apply(this,[t]),n=i.title.apply(this,[t]),o=i.afterTitle.apply(this,[t]);let a=[];return a=Wo(a,No(s)),a=Wo(a,No(n)),a=Wo(a,No(o))}getBeforeBody(t,e){return qo(e.callbacks.beforeBody.apply(this,[t]))}getBody(t,e){const{callbacks:i}=e,s=[];return J(t,t=>{const e={before:[],lines:[],after:[]},n=Ko(i,t);Wo(e.before,No(n.beforeLabel.call(this,t))),Wo(e.lines,n.label.call(this,t)),Wo(e.after,No(n.afterLabel.call(this,t))),s.push(e)}),s}getAfterBody(t,e){return qo(e.callbacks.afterBody.apply(this,[t]))}getFooter(t,e){const{callbacks:i}=e,s=i.beforeFooter.apply(this,[t]),n=i.footer.apply(this,[t]),o=i.afterFooter.apply(this,[t]);let a=[];return a=Wo(a,No(s)),a=Wo(a,No(n)),a=Wo(a,No(o))}_createItems(t){const e=this._active,i=this._chart.data,s=[],n=[],o=[];let a,r,l=[];for(a=0,r=e.length;at.filter(e,s,n,i))),t.itemSort&&(l=l.sort((e,s)=>t.itemSort(e,s,i))),J(l,e=>{const i=Ko(t.callbacks,e);s.push(i.labelColor.call(this,e)),n.push(i.labelPointStyle.call(this,e)),o.push(i.labelTextColor.call(this,e))}),this.labelColors=s,this.labelPointStyles=n,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let n,o=[];if(s.length){const t=Vo[i.position].call(this,s,this._eventPosition);o=this._createItems(i),this.title=this.getTitle(o,i),this.beforeBody=this.getBeforeBody(o,i),this.body=this.getBody(o,i),this.afterBody=this.getAfterBody(o,i),this.footer=this.getFooter(o,i);const e=this._size=Ho(this,i),a=Object.assign({},t,e),r=Yo(this._chart,i,a),l=Uo(i,a,r,this._chart);this.xAlign=r.xAlign,this.yAlign=r.yAlign,n={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(n={opacity:0});this._tooltipItems=o,this.$context=void 0,n&&this._resolveAnimations().update(this,n),t&&i.external&&i.external.call(this,{chart:this._chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const n=this.getCaretPosition(t,i,s);e.lineTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:n}=this,{caretSize:o,cornerRadius:a}=i,{topLeft:r,topRight:l,bottomLeft:h,bottomRight:c}=je(a),{x:d,y:u}=t,{width:f,height:g}=e;let p,m,b,x,_,y;return"center"===n?(_=u+g/2,"left"===s?(m=(p=d)-o,x=_+o,y=_-o):(m=(p=d+f)+o,x=_-o,y=_+o),b=p):(m="left"===s?d+Math.max(r,h)+o:"right"===s?d+f-Math.max(l,c)-o:this.caretX,"top"===n?(_=(x=u)-o,p=m-o,b=m+o):(_=(x=u+g)+o,p=m+o,b=m-o),y=x),{x1:p,x2:m,x3:b,y1:x,y2:_,y3:y}}drawTitle(t,e,i){const s=this.title,n=s.length;let o,a,r;if(n){const l=Bi(i.rtl,this.x,this.width);for(t.x=Xo(this,i.titleAlign,i),e.textAlign=l.textAlign(i.titleAlign),e.textBaseline="middle",o=$e(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=o.string,r=0;r0!==t)?(t.beginPath(),t.fillStyle=n.multiKeyBackground,ae(t,{x:e,y:g,w:l,h:r,radius:a}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),ae(t,{x:i,y:g+1,w:l-2,h:r-2,radius:a}),t.fill()):(t.fillStyle=n.multiKeyBackground,t.fillRect(e,g,l,r),t.strokeRect(e,g,l,r),t.fillStyle=o.backgroundColor,t.fillRect(i,g+1,l-2,r-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:n,bodyAlign:o,displayColors:a,boxHeight:r,boxWidth:l,boxPadding:h}=i,c=$e(i.bodyFont);let d=c.lineHeight,u=0;const f=Bi(i.rtl,this.x,this.width),g=function(i){e.fillText(i,f.x(t.x+u),t.y+d/2),t.y+=d+n},p=f.textAlign(o);let m,b,x,_,y,v,w;for(e.textAlign=o,e.textBaseline="middle",e.font=c.string,t.x=Xo(this,p,i),e.fillStyle=i.bodyColor,J(this.beforeBody,g),u=a&&"right"!==p?"center"===o?l/2+h:l+2+h:0,_=0,v=s.length;_0&&e.stroke()}_updateAnimationTarget(t){const e=this._chart,i=this.$animations,s=i&&i.x,n=i&&i.y;if(s||n){const i=Vo[t.position].call(this,this._active,this._eventPosition);if(!i)return;const o=this._size=Ho(this,t),a=Object.assign({},i,this._size),r=Yo(e,t,a),l=Uo(t,a,r,e);s._to===l.x&&n._to===l.y||(this.xAlign=r.xAlign,this.yAlign=r.yAlign,this.width=o.width,this.height=o.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,l))}}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},n={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const o=He(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(n,t,s,e),Vi(t,e.textDirection),n.y+=o.top,this.drawTitle(n,t,e),this.drawBody(n,t,e),this.drawFooter(n,t,e),Wi(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map(({datasetIndex:t,index:e})=>{const i=this._chart.getDatasetMeta(t);if(!i)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:i.data[e],index:e}}),n=!tt(i,s),o=this._positionChanged(s,e);(n||o)&&(this._active=s,this._eventPosition=e,this.update(!0))}handleEvent(t,e){const i=this.options,s=this._active||[];let n=!1,o=[];"mouseout"!==t.type&&(o=this._chart.getElementsAtEventForMode(t,i.mode,i,e),i.reverse&&o.reverse());const a=this._positionChanged(o,t);return(n=e||!tt(o,s)||a)&&(this._active=o,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),n}_positionChanged(t,e){const{caretX:i,caretY:s,options:n}=this,o=Vo[n.position].call(this,t,e);return!1!==o&&(i!==o.x||s!==o.y)}}Go.positioners=Vo;var Zo={id:"tooltip",_element:Go,positioners:Vo,afterInit(t,e,i){i&&(t.tooltip=new Go({_chart:t,options:i}))},beforeUpdate(t,e,i){t.tooltip&&t.tooltip.initialize(i)},reset(t,e,i){t.tooltip&&t.tooltip.initialize(i)},afterDraw(t){const e=t.tooltip,i={tooltip:e};!1!==t.notifyPlugins("beforeTooltipDraw",i)&&(e&&e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i))},afterEvent(t,e){if(t.tooltip){const i=e.replay;t.tooltip.handleEvent(e.event,i)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:{beforeTitle:j,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,s=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(s>0&&e.dataIndex"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},Qo=Object.freeze({__proto__:null,Decimation:fo,Filler:Ao,Legend:Eo,SubTitle:Bo,Title:zo,Tooltip:Zo});const Jo=(t,e,i,s)=>("string"==typeof e?(i=t.push(e)-1,s.unshift({index:i,label:e})):isNaN(e)&&(i=null),i);const ta=(t,e)=>null===t?null:$t(Math.round(t),0,e);class ea extends $s{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const e=this._addedLabels;if(e.length){const t=this.getLabels();for(const{index:i,label:s}of e)t[i]===s&&t.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,e){if($(t))return null;const i=this.getLabels();return e=isFinite(e)&&i[e]===t?e:function(t,e,i,s){const n=t.indexOf(e);return-1===n?Jo(t,e,i,s):n!==t.lastIndexOf(e)?i:n}(i,t,K(e,t),this._addedLabels),ta(e,i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(i=0),e||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,e=this.max,i=this.options.offset,s=[];let n=this.getLabels();n=0===t&&e===n.length-1?n:n.slice(t,e+1),this._valueRange=Math.max(n.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let i=t;i<=e;i++)s.push({value:i});return s}getLabelForValue(t){const e=this.getLabels();return t>=0&&te.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function ia(t,e,{horizontal:i,minRotation:s}){const n=zt(s),o=(i?Math.sin(n):Math.cos(n))||.001,a=.75*e*(""+t).length;return Math.min(e/o,a)}ea.id="category",ea.defaults={ticks:{callback:ea.prototype.getLabelForValue}};class sa extends $s{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return $(t)?null:("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:s,max:n}=this;const o=t=>s=e?s:t,a=t=>n=i?n:t;if(t){const t=Ot(s),e=Ot(n);t<0&&e<0?a(0):t>0&&e>0&&o(0)}if(s===n){let e=1;(n>=Number.MAX_SAFE_INTEGER||s<=Number.MIN_SAFE_INTEGER)&&(e=Math.abs(.05*n)),a(n+e),t||o(s-e)}this.min=s,this.max=n}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:i,stepSize:s}=t;return s?(e=Math.ceil(this.max/s)-Math.floor(this.min/s)+1)>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3):(e=this.computeTickLimit(),i=i||11),i&&(e=Math.min(i,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();const s=function(t,e){const i=[],{bounds:s,step:n,min:o,max:a,precision:r,count:l,maxTicks:h,maxDigits:c,includeBounds:d}=t,u=n||1,f=h-1,{min:g,max:p}=e,m=!$(o),b=!$(a),x=!$(l),_=(p-g)/(c+1);let y,v,w,M,k=At((p-g)/f/u)*u;if(k<1e-14&&!m&&!b)return[{value:g},{value:p}];(M=Math.ceil(p/k)-Math.floor(g/k))>f&&(k=At(M*k/f/u)*u),$(r)||(y=Math.pow(10,r),k=Math.ceil(k*y)/y),"ticks"===s?(v=Math.floor(g/k)*k,w=Math.ceil(p/k)*k):(v=g,w=p),m&&b&&n&&Et((a-o)/n,k/1e3)?(k=(a-o)/(M=Math.round(Math.min((a-o)/k,h))),v=o,w=a):x?k=((w=b?a:w)-(v=m?o:v))/(M=l-1):M=Rt(M=(w-v)/k,Math.round(M),k/1e3)?Math.round(M):Math.ceil(M);const S=Math.max(Bt(k),Bt(v));y=Math.pow(10,$(r)?S:r),v=Math.round(v*y)/y,w=Math.round(w*y)/y;let P=0;for(m&&(d&&v!==o?(i.push({value:o}),v0?i:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=X(t)?Math.max(0,t):null,this.max=X(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const n=e=>i=t?i:e,o=t=>s=e?s:t,a=(t,e)=>Math.pow(10,Math.floor(Ct(t))+e);i===s&&(i<=0?(n(1),o(10)):(n(a(i,-1)),o(a(s,1)))),i<=0&&n(a(s,-1)),s<=0&&o(a(i,1)),this._zero&&this.min!==this._suggestedMin&&i===a(this.min,0)&&n(a(i,-1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e=function(t,e){const i=Math.floor(Ct(e.max)),s=Math.ceil(e.max/Math.pow(10,i)),n=[];let o=q(t.min,Math.pow(10,Math.floor(Ct(e.min)))),a=Math.floor(Ct(o)),r=Math.floor(o/Math.pow(10,a)),l=a<0?Math.pow(10,Math.abs(a)):1;do{n.push({value:o,major:oa(o)}),10==++r&&(r=1,l=++a>=0?1:l),o=Math.round(r*Math.pow(10,a)*l)/l}while(an?{start:e-i,end:e}:{start:e,end:e+i}}function ha(t){const e={l:0,r:t.width,t:0,b:t.height-t.paddingTop},i={},s=[],n=[],o=t.getLabels().length;for(let h=0;he.r&&(e.r=p.end,i.r=f),m.starte.b&&(e.b=m.end,i.b=f)}var a,r,l;t._setReductions(t.drawingArea,e,i),t._pointLabelItems=function(t,e,i){const s=[],n=t.getLabels().length,o=t.options,a=ra(o),r=t.getDistanceFromCenterForValue(o.ticks.reverse?t.min:t.max);for(let o=0;o270||i<90)&&(t-=e),t}function fa(t,e,i,s){const{ctx:n}=t;if(i)n.arc(t.xCenter,t.yCenter,e,0,vt);else{let i=t.getPointPosition(0,e);n.moveTo(i.x,i.y);for(let o=1;o{const i=Q(this.options.pointLabels.callback,[t,e],this);return i||0===i?i:""})}fit(){const t=this.options;t.display&&t.pointLabels.display?ha(this):this.setCenterPoint(0,0,0,0)}_setReductions(t,e,i){let s=e.l/Math.sin(i.l),n=Math.max(e.r-this.width,0)/Math.sin(i.r),o=-e.t/Math.cos(i.t),a=-Math.max(e.b-(this.height-this.paddingTop),0)/Math.cos(i.b);s=ga(s),n=ga(n),o=ga(o),a=ga(a),this.drawingArea=Math.max(t/2,Math.min(Math.floor(t-(s+n)/2),Math.floor(t-(o+a)/2))),this.setCenterPoint(s,n,o,a)}setCenterPoint(t,e,i,s){const n=this.width-e-this.drawingArea,o=t+this.drawingArea,a=i+this.drawingArea,r=this.height-this.paddingTop-s-this.drawingArea;this.xCenter=Math.floor((o+n)/2+this.left),this.yCenter=Math.floor((a+r)/2+this.top+this.paddingTop)}getIndexAngle(t){return jt(t*(vt/this.getLabels().length)+zt(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if($(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if($(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t=0;n--){const e=s.setContext(t.getPointLabelContext(n)),o=$e(e.font),{x:a,y:r,textAlign:l,left:h,top:c,right:d,bottom:u}=t._pointLabelItems[n],{backdropColor:f}=e;if(!$(f)){const t=He(e.backdropPadding);i.fillStyle=f,i.fillRect(h-t.left,c-t.top,d-h+t.width,u-c+t.height)}ne(i,t._pointLabels[n],a,r+o.lineHeight/2,o,{color:e.color,textAlign:l,textBaseline:"middle"})}}(this,n),s.display&&this.ticks.forEach((t,e)=>{if(0!==e){a=this.getDistanceFromCenterForValue(t.value),function(t,e,i,s){const n=t.ctx,o=e.circular,{color:a,lineWidth:r}=e;!o&&!s||!a||!r||i<0||(n.save(),n.strokeStyle=a,n.lineWidth=r,n.setLineDash(e.borderDash),n.lineDashOffset=e.borderDashOffset,n.beginPath(),fa(t,i,o,s),n.closePath(),n.stroke(),n.restore())}(this,s.setContext(this.getContext(e-1)),a,n)}}),i.display){for(t.save(),o=this.getLabels().length-1;o>=0;o--){const s=i.setContext(this.getPointLabelContext(o)),{color:n,lineWidth:l}=s;l&&n&&(t.lineWidth=l,t.strokeStyle=n,t.setLineDash(s.borderDash),t.lineDashOffset=s.borderDashOffset,a=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),r=this.getPointPosition(o,a),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(r.x,r.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let n,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((s,a)=>{if(0===a&&!e.reverse)return;const r=i.setContext(this.getContext(a)),l=$e(r.font);if(n=this.getDistanceFromCenterForValue(this.ticks[a].value),r.showLabelBackdrop){t.font=l.string,o=t.measureText(s.label).width,t.fillStyle=r.backdropColor;const e=He(r.backdropPadding);t.fillRect(-o/2-e.left,-n-l.size/2-e.top,o+e.width,l.size+e.height)}ne(t,s.label,0,-n,l,{color:r.color})}),t.restore()}drawTitle(){}}pa.id="radialLinear",pa.defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Es.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback:t=>t,padding:5}},pa.defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"},pa.descriptors={angleLines:{_fallback:"grid"}};const ma={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},ba=Object.keys(ma);function xa(t,e){return t-e}function _a(t,e){if($(e))return null;const i=t._adapter,{parser:s,round:n,isoWeekday:o}=t._parseOpts;let a=e;return"function"==typeof s&&(a=s(a)),X(a)||(a="string"==typeof s?i.parse(a,s):i.parse(a)),null===a?null:(n&&(a="week"!==n||!Lt(o)&&!0!==o?i.startOf(a,n):i.startOf(a,"isoWeek",o)),+a)}function ya(t,e,i,s){const n=ba.length;for(let o=ba.indexOf(t);o=e?i[s]:i[n]]=!0}}else t[e]=!0}function wa(t,e,i){const s=[],n={},o=e.length;let a,r;for(a=0;a=0&&(e[l].major=!0);return e}(t,s,n,i):s}class Ma extends $s{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e){const i=t.time||(t.time={}),s=this._adapter=new vn._date(t.adapters.date);ot(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:_a(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,i=t.time.unit||"day";let{min:s,max:n,minDefined:o,maxDefined:a}=this.getUserBounds();function r(t){o||isNaN(t.min)||(s=Math.min(s,t.min)),a||isNaN(t.max)||(n=Math.max(n,t.max))}o&&a||(r(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||r(this.getMinMax(!1))),s=X(s)&&!isNaN(s)?s:+e.startOf(Date.now(),i),n=X(n)&&!isNaN(n)?n:+e.endOf(Date.now(),i)+1,this.min=Math.min(s,n-1),this.max=Math.max(s+1,n)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this.options,e=t.time,i=t.ticks,s="labels"===i.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const n=this.min,o=ce(s,n,this.max);return this._unit=e.unit||(i.autoSkip?ya(e.minUnit,this.min,this.max,this._getLabelCapacity(n)):function(t,e,i,s,n){for(let o=ba.length-1;o>=ba.indexOf(i);o--){const i=ba[o];if(ma[i].common&&t._adapter.diff(n,s,i)>=e-1)return i}return ba[i?ba.indexOf(i):0]}(this,o.length,e.minUnit,this.min,this.max)),this._majorUnit=i.major.enabled&&"year"!==this._unit?function(t){for(let e=ba.indexOf(t)+1,i=ba.length;e1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+o);const f="data"===s.ticks.source&&this.getDataTimestamps();for(c=u,d=0;ct-e).map(t=>+t)}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}_tickFormatFunction(t,e,i,s){const n=this.options,o=n.time.displayFormats,a=this._unit,r=this._majorUnit,l=a&&o[a],h=r&&o[r],c=i[e],d=r&&h&&c&&c.major,u=this._adapter.format(t,s||(d?h:l)),f=n.ticks.callback;return f?Q(f,[u,e,i],this):u}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t,e,i=this._cache.data||[];if(i.length)return i;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(t=0,e=s.length;t=t[r].pos&&e<=t[l].pos&&({lo:r,hi:l}=le(t,"pos",e)),({pos:s,time:o}=t[r]),({pos:n,time:a}=t[l])):(e>=t[r].time&&e<=t[l].time&&({lo:r,hi:l}=le(t,"time",e)),({time:s,pos:o}=t[r]),({time:n,pos:a}=t[l]));const h=n-s;return h?o+(a-o)*(e-s)/h:o}Ma.id="time",Ma.defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",major:{enabled:!1}}};class Sa extends Ma{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=ka(e,this.min),this._tableRange=ka(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],n=[];let o,a,r,l,h;for(o=0,a=t.length;o=e&&l<=i&&s.push(l);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(o=0,a=s.length;o"string"==typeof t,e=Chart.helpers;let i=null;new Map;return window.plugin_gradient={id:"gradient",beforeDatasetsUpdate(s){const n=s.ctx,o=s.chartArea;if(!o)return null;if(s.options.gradientcolor&&void 0!==s.options.gradientcolor.type){const a=s.data.datasets[0].type||s.config.type;if(null===i){const r=s.data.datasets[0].backgroundColor;i=function(i,s,n,o){let a=[];switch(s.toLowerCase()){case"pie":case"doughnut":if(o&&o.length&&t(o[0])){const t=(n.left+n.right)/2,s=(n.top+n.bottom)/2,r=1;return Object.entries(o).forEach(([,n],o)=>{let l=i.createRadialGradient(t,s,0,t,s,r);l.addColorStop(0,e.color(n).alpha(.4).rgbString()),l.addColorStop(1,e.color(n).alpha(1).rgbString()),a.push(l)}),a}case"bar":return Object.entries(o).forEach(([,s],o)=>{if(t(s)){let t=i.createLinearGradient(0,n.bottom,0,n.top);t.addColorStop(0,e.color(s).alpha(1).rgbString()),t.addColorStop(.5,e.color(s).alpha(.5).rgbString()),t.addColorStop(1,e.color(s).alpha(1).rgbString()),a.push(t)}else a.push(s)}),a}return o}(n,a,o,r),s.data.datasets[0].backgroundColor=i}}else s.data.datasets.forEach((t,s)=>{const a=t.gradient;a&&o&&Object.keys(a).forEach(s=>{const{axis:r,colors:l}=a[s];l&&l.length&&(i=function(t,i,s,n){if(s.bottom&&s.top&&s.left&&s.right){const o="y"===i?t.createLinearGradient(0,s.bottom,0,s.top):t.createLinearGradient(s.left,0,s.right,0);if(n&&1==n.length)o.addColorStop(0,e.color(color).alpha(.2).rgbString()),o.addColorStop(.3,e.color(color).alpha(.4).rgbString()),o.addColorStop(.5,e.color(color).alpha(.6).rgbString()),o.addColorStop(1,e.color(color).alpha(1).rgbString());else{const t=1/(n.length-1);Object.entries(n).forEach(([,e],i)=>{o.addColorStop(t*i,e)})}return o}}(n,r,o,l),t.backgroundColor=i)})})}},plugin_gradient}),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self)["chartjs-background"]=e()}(this,function(){"use strict";return{id:"chardbackground",beforeDraw:function(t){if(t.config.options.chartArea&&t.config.options.chartArea.backgroundColor){const e=t.chartArea,i=t.ctx;i.save(),i.fillStyle=t.config.options.chartArea.backgroundColor,i.fillRect(e.left,e.top,e.right-e.left,e.bottom-e.top),i.restore()}}}}),LineFitter.prototype={add:function(t,e){this.count++,this.sumX+=t,this.sumX2+=t*t,this.sumXY+=t*e,this.sumY+=e},project:function(t){const e=this.count*this.sumX2-this.sumX*this.sumX;return(this.sumX2*this.sumY-this.sumX*this.sumXY)/e+t*((this.count*this.sumXY-this.sumX*this.sumY)/e)}},window.plugin_trendline={id:"trendline",afterDatasetsDraw:function(t){const e=t.ctx;e&&(t.data.datasets.forEach(function(i,s){if(i.trendlineLinear){const n=t.scales.x||t.scales[i.xAxisID],o=t.scales.y||t.scales[i.yAxisID];addFitter(t.getDatasetMeta(s),e,i,n,o)}}),e.setLineDash([]))}}; \ No newline at end of file diff --git a/dist/chart-card/chart-bundle.js b/dist/chart-card/chart-bundle.js index 089051a..4a504f4 100644 --- a/dist/chart-card/chart-bundle.js +++ b/dist/chart-card/chart-bundle.js @@ -1,5 +1,5 @@ /*! - * Chart.js v3.6.0 + * Chart.js v3.6.1 * https://www.chartjs.org * (c) 2021 Chart.js Contributors * Released under the MIT License @@ -1166,6 +1166,9 @@ function _limitValue(value, min, max) { function _int16Range(value) { return _limitValue(value, -32768, 32767); } +function _isBetween(value, start, end, epsilon = 1e-6) { + return value >= Math.min(start, end) - epsilon && value <= Math.max(start, end) + epsilon; +} function toFontString(font) { if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) { @@ -2301,7 +2304,7 @@ var layouts = { each(boxes.chartArea, (layout) => { const box = layout.box; Object.assign(box, chart.chartArea); - box.update(chartArea.w, chartArea.h); + box.update(chartArea.w, chartArea.h, {left: 0, top: 0, right: 0, bottom: 0}); }); } }; @@ -2404,7 +2407,8 @@ function _descriptors(proxy, defaults = {scriptable: true, indexable: true}) { }; } const readKey = (prefix, name) => prefix ? prefix + _capitalize(name) : name; -const needsSubResolver = (prop, value) => isObject(value) && prop !== 'adapters'; +const needsSubResolver = (prop, value) => isObject(value) && prop !== 'adapters' && + (Object.getPrototypeOf(value) === null || value.constructor === Object); function _cached(target, prop, resolve) { if (Object.prototype.hasOwnProperty.call(target, prop)) { return target[prop]; @@ -2435,7 +2439,7 @@ function _resolveScriptable(prop, value, target, receiver) { _stack.add(prop); value = value(_context, _subProxy || receiver); _stack.delete(prop); - if (isObject(value)) { + if (needsSubResolver(prop, value)) { value = createSubResolver(_proxy._scopes, _proxy, prop, value); } return value; @@ -2900,7 +2904,7 @@ function propertyFn(property) { }; } return { - between: (n, s, e) => n >= Math.min(s, e) && n <= Math.max(e, s), + between: _isBetween, compare: (a, b) => a - b, normalize: x => x }; @@ -3236,6 +3240,7 @@ _normalizeAngle: _normalizeAngle, _angleBetween: _angleBetween, _limitValue: _limitValue, _int16Range: _int16Range, +_isBetween: _isBetween, getRtlAdapter: getRtlAdapter, overrideTextDirection: overrideTextDirection, restoreTextDirection: restoreTextDirection, @@ -3344,15 +3349,23 @@ function fromNativeEvent(event, chart) { y: y !== undefined ? y : null, }; } +function nodeListContains(nodeList, canvas) { + for (const node of nodeList) { + if (node === canvas || node.contains(canvas)) { + return true; + } + } +} function createAttachObserver(chart, type, listener) { const canvas = chart.canvas; const observer = new MutationObserver(entries => { + let trigger = false; for (const entry of entries) { - for (const node of entry.addedNodes) { - if (node === canvas || node.contains(canvas)) { - return listener(); - } - } + trigger = trigger || nodeListContains(entry.addedNodes, canvas); + trigger = trigger && !nodeListContains(entry.removedNodes, canvas); + } + if (trigger) { + listener(); } }); observer.observe(document, {childList: true, subtree: true}); @@ -3361,12 +3374,13 @@ function createAttachObserver(chart, type, listener) { function createDetachObserver(chart, type, listener) { const canvas = chart.canvas; const observer = new MutationObserver(entries => { + let trigger = false; for (const entry of entries) { - for (const node of entry.removedNodes) { - if (node === canvas || node.contains(canvas)) { - return listener(); - } - } + trigger = trigger || nodeListContains(entry.removedNodes, canvas); + trigger = trigger && !nodeListContains(entry.addedNodes, canvas); + } + if (trigger) { + listener(); } }); observer.observe(document, {childList: true, subtree: true}); @@ -4111,6 +4125,7 @@ class DatasetController { const scopes = config.getOptionScopes(this.getDataset(), scopeKeys, true); this.options = config.createResolver(scopes, this.getContext()); this._parsing = this.options.parsing; + this._cachedDataOpts = {}; } parse(start, count) { const {_cachedMeta: meta, _data: data} = this; @@ -4282,8 +4297,6 @@ class DatasetController { } _update(mode) { const meta = this._cachedMeta; - this.configure(); - this._cachedDataOpts = {}; this.update(mode || 'default'); meta._clip = toClip(valueOrDefault(this.options.clip, defaultClip(meta.xScale, meta.yScale, this.getMaxOverflow()))); } @@ -4497,6 +4510,7 @@ class DatasetController { const [method, arg1, arg2] = args; this[method](arg1, arg2); } + this.chart._dataChanges.push([this.index, ...args]); } _onDataPush() { const count = arguments.length; @@ -4509,8 +4523,13 @@ class DatasetController { this._sync(['_removeElements', 0, 1]); } _onDataSplice(start, count) { - this._sync(['_removeElements', start, count]); - this._sync(['_insertElements', start, arguments.length - 2]); + if (count) { + this._sync(['_removeElements', start, count]); + } + const newCount = arguments.length - 2; + if (newCount) { + this._sync(['_insertElements', start, newCount]); + } } _onDataUnshift() { this._sync(['_insertElements', 0, arguments.length]); @@ -6507,7 +6526,7 @@ function needContext(proxy, names) { return false; } -var version = "3.6.0"; +var version = "3.6.1"; const KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea']; function positionIsHorizontal(position, axis) { @@ -6547,6 +6566,19 @@ const getChart = (key) => { const canvas = getCanvas(key); return Object.values(instances).filter((c) => c.canvas === canvas).pop(); }; +function moveNumericKeys(obj, start, move) { + const keys = Object.keys(obj); + for (const key of keys) { + const intKey = +key; + if (intKey >= start) { + const value = obj[key]; + delete obj[key]; + if (move > 0 || intKey > start) { + obj[intKey + move] = value; + } + } + } +} class Chart { constructor(item, userConfig) { const config = this.config = new Config(userConfig); @@ -6591,6 +6623,7 @@ class Chart { this._animationsDisabled = undefined; this.$context = undefined; this._doResize = debounce(mode => this.update(mode), options.resizeDelay || 0); + this._dataChanges = []; instances[this.id] = this; if (!context || !canvas) { console.error("Failed to create chart: can't acquire context from the given item"); @@ -6810,18 +6843,10 @@ class Chart { const config = this.config; config.update(); const options = this._options = config.createResolver(config.chartOptionScopes(), this.getContext()); - each(this.scales, (scale) => { - layouts.removeBox(this, scale); - }); const animsDisabled = this._animationsDisabled = !options.animation; - this.ensureScalesHaveIDs(); - this.buildOrUpdateScales(); - const existingEvents = new Set(Object.keys(this._listeners)); - const newEvents = new Set(options.events); - if (!setsEqual(existingEvents, newEvents) || !!this._responsiveListeners !== options.responsive) { - this.unbindEvents(); - this.bindEvents(); - } + this._updateScales(); + this._checkEventBindings(); + this._updateHiddenIndices(); this._plugins.invalidate(); if (this.notifyPlugins('beforeUpdate', {mode, cancelable: true}) === false) { return; @@ -6850,6 +6875,52 @@ class Chart { } this.render(); } + _updateScales() { + each(this.scales, (scale) => { + layouts.removeBox(this, scale); + }); + this.ensureScalesHaveIDs(); + this.buildOrUpdateScales(); + } + _checkEventBindings() { + const options = this.options; + const existingEvents = new Set(Object.keys(this._listeners)); + const newEvents = new Set(options.events); + if (!setsEqual(existingEvents, newEvents) || !!this._responsiveListeners !== options.responsive) { + this.unbindEvents(); + this.bindEvents(); + } + } + _updateHiddenIndices() { + const {_hiddenIndices} = this; + const changes = this._getUniformDataChanges() || []; + for (const {method, start, count} of changes) { + const move = method === '_removeElements' ? -count : count; + moveNumericKeys(_hiddenIndices, start, move); + } + } + _getUniformDataChanges() { + const _dataChanges = this._dataChanges; + if (!_dataChanges || !_dataChanges.length) { + return; + } + this._dataChanges = []; + const datasetCount = this.data.datasets.length; + const makeSet = (idx) => new Set( + _dataChanges + .filter(c => c[0] === idx) + .map((c, i) => i + ',' + c.splice(1).join(',')) + ); + const changeSet = makeSet(0); + for (let i = 1; i < datasetCount; i++) { + if (!setsEqual(changeSet, makeSet(i))) { + return; + } + } + return Array.from(changeSet) + .map(c => c.split(',')) + .map(a => ({method: a[1], start: +a[2], count: +a[3]})); + } _updateLayout(minPadding) { if (this.notifyPlugins('beforeLayout', {cancelable: true}) === false) { return; @@ -6876,6 +6947,9 @@ class Chart { if (this.notifyPlugins('beforeDatasetsUpdate', {mode, cancelable: true}) === false) { return; } + for (let i = 0, ilen = this.data.datasets.length; i < ilen; ++i) { + this.getDatasetMeta(i).controller.configure(); + } for (let i = 0, ilen = this.data.datasets.length; i < ilen; ++i) { this._updateDataset(i, isFunction(mode) ? mode({datasetIndex: i}) : mode); } @@ -8102,9 +8176,6 @@ class DoughnutController extends DatasetController { meta = chart.getDatasetMeta(i); arcs = meta.data; controller = meta.controller; - if (controller !== this) { - controller.configure(); - } break; } } @@ -8835,8 +8906,9 @@ class ArcElement extends Element { 'circumference' ], useFinalPosition); const rAdjust = this.options.spacing / 2; - const betweenAngles = circumference >= TAU || _angleBetween(angle, startAngle, endAngle); - const withinRadius = (distance >= innerRadius + rAdjust && distance <= outerRadius + rAdjust); + const _circumference = valueOrDefault(circumference, endAngle - startAngle); + const betweenAngles = _circumference >= TAU || _angleBetween(angle, startAngle, endAngle); + const withinRadius = _isBetween(distance, innerRadius + rAdjust, outerRadius + rAdjust); return (betweenAngles && withinRadius); } getCenterPoint(useFinalPosition) { @@ -9324,8 +9396,8 @@ function inRange(bar, x, y, useFinalPosition) { const skipBoth = skipX && skipY; const bounds = bar && !skipBoth && getBarBounds(bar, useFinalPosition); return bounds - && (skipX || x >= bounds.left && x <= bounds.right) - && (skipY || y >= bounds.top && y <= bounds.bottom); + && (skipX || _isBetween(x, bounds.left, bounds.right)) + && (skipY || _isBetween(y, bounds.top, bounds.bottom)); } function hasRadius(radius) { return radius.topLeft || radius.topRight || radius.bottomLeft || radius.bottomRight; @@ -9822,7 +9894,7 @@ function findPoint(line, sourcePoint, property) { const segment = segments[i]; const firstValue = linePoints[segment.start][property]; const lastValue = linePoints[segment.end][property]; - if (pointValue >= firstValue && pointValue <= lastValue) { + if (_isBetween(pointValue, firstValue, lastValue)) { first = pointValue === firstValue; last = pointValue === lastValue; break; @@ -10441,11 +10513,13 @@ class Legend extends Element { } _getLegendItemAt(x, y) { let i, hitBox, lh; - if (x >= this.left && x <= this.right && y >= this.top && y <= this.bottom) { + if (_isBetween(x, this.left, this.right) + && _isBetween(y, this.top, this.bottom)) { lh = this.legendHitBoxes; for (i = 0; i < lh.length; ++i) { hitBox = lh[i]; - if (x >= hitBox.left && x <= hitBox.left + hitBox.width && y >= hitBox.top && y <= hitBox.top + hitBox.height) { + if (_isBetween(x, hitBox.left, hitBox.left + hitBox.width) + && _isBetween(y, hitBox.top, hitBox.top + hitBox.height)) { return this.legendItems[i]; } } @@ -10961,9 +11035,9 @@ function getBackgroundPoint(options, size, alignment, chart) { x -= paddingAndSize; } } else if (xAlign === 'left') { - x -= Math.max(topLeft, bottomLeft) + caretPadding; + x -= Math.max(topLeft, bottomLeft) + caretSize; } else if (xAlign === 'right') { - x += Math.max(topRight, bottomRight) + caretPadding; + x += Math.max(topRight, bottomRight) + caretSize; } return { x: _limitValue(x, 0, chart.width - size.width), @@ -11695,13 +11769,19 @@ Title: plugin_title, Tooltip: plugin_tooltip }); -const addIfString = (labels, raw, index) => typeof raw === 'string' - ? labels.push(raw) - 1 - : isNaN(raw) ? null : index; -function findOrAddLabel(labels, raw, index) { +const addIfString = (labels, raw, index, addedLabels) => { + if (typeof raw === 'string') { + index = labels.push(raw) - 1; + addedLabels.unshift({index, label: raw}); + } else if (isNaN(raw)) { + index = null; + } + return index; +}; +function findOrAddLabel(labels, raw, index, addedLabels) { const first = labels.indexOf(raw); if (first === -1) { - return addIfString(labels, raw, index); + return addIfString(labels, raw, index, addedLabels); } const last = labels.lastIndexOf(raw); return first !== last ? index : first; @@ -11712,6 +11792,20 @@ class CategoryScale extends Scale { super(cfg); this._startValue = undefined; this._valueRange = 0; + this._addedLabels = []; + } + init(scaleOptions) { + const added = this._addedLabels; + if (added.length) { + const labels = this.getLabels(); + for (const {index, label} of added) { + if (labels[index] === label) { + labels.splice(index, 1); + } + } + this._addedLabels = []; + } + super.init(scaleOptions); } parse(raw, index) { if (isNullOrUndef(raw)) { @@ -11719,7 +11813,7 @@ class CategoryScale extends Scale { } const labels = this.getLabels(); index = isFinite(index) && labels[index] === raw ? index - : findOrAddLabel(labels, raw, valueOrDefault(index, raw)); + : findOrAddLabel(labels, raw, valueOrDefault(index, raw), this._addedLabels); return validIndex(index, labels.length - 1); } determineDataLimits() { @@ -11996,7 +12090,7 @@ class LinearScaleBase extends Scale { this._valueRange = end - start; } getLabelForValue(value) { - return formatNumber(value, this.chart.options.locale); + return formatNumber(value, this.chart.options.locale, this.options.ticks.format); } } @@ -12129,7 +12223,9 @@ class LogarithmicScale extends Scale { return ticks; } getLabelForValue(value) { - return value === undefined ? '0' : formatNumber(value, this.chart.options.locale); + return value === undefined + ? '0' + : formatNumber(value, this.chart.options.locale, this.options.ticks.format); } configure() { const start = this.min; diff --git a/dist/chart-card/chart-card-min.js b/dist/chart-card/chart-card-min.js index 70315bc..93b139f 100644 --- a/dist/chart-card/chart-card-min.js +++ b/dist/chart-card/chart-card-min.js @@ -7,4 +7,4 @@ * Author: Peter siebler */ -"use strict";import"/hacsfiles/chart-card/chart.js?module";const appinfo={name:"✓ custom:chart-card ",app:"chart-card",version:"v2.1.6/v3.6.0",chartjs:Chart.version||"v3.6.0",assets:"/hacsfiles/chart-card/assets/",github:"https://github.com/zibous/lovelace-graph-chart-card"};console.info(`%c ${appinfo.name} %c ▪︎▪︎▪︎▪︎ ${appinfo.version} ▪︎▪︎▪︎▪︎`,"color:#FFFFFF; background:#3498db;display:inline-block;font-size:12px;font-weight:300;padding: 6px 0 6px 0","color:#2c3e50; background:#ecf0f1;display:inline-block;font-size:12px;font-weight:300;padding: 6px 0 6px 0");const CT_DATAPOINTSTYLE=["circle","triangle","rectRounded","rect","rectRot","cross","star","line","dash"],CT_CHARTGRIDLINES=["bar","line","bubble","scatter"],CT_NOSHOWSTATES=["bubble","scatter"],CT_BARCHARTS=["bar","horizontalbar"],CT_SHOWLEGEND=["pie","doughnut","polararea","line"],CT_AVIABLETYPES=["line","radar","bar","horizontalbar","pie","doughnut","polararea","bubble","scatter"],CT_DATASCALEMODES={disabled:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1},category:{history:!0,timescale:!0,timeaxis:!1,multiseries:!1},time:{history:!0,timescale:!0,timeaxis:!0,multiseries:!1},bar:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1},horizontalbar:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1},line:{history:!0,timescale:!0,timeaxis:!0,multiseries:!1},pie:{history:!1,timescale:!1,timeaxis:!1,multiseries:!0},doughnut:{history:!1,timescale:!1,timeaxis:!1,multiseries:!0},polararea:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1},scatter:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1},radar:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1},bubble:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1}},LOADERFILES=["audio","ball-triangle","bars","circles","grid","hearts","oval","pfuff","rings","spinning-circles","tail-spin","three-dots"],DSC_UNITS=["day","second","minute","hour","month","year"],DSC_RANGES=["last","max","min","range","midrange","mean","sum","first"],API_DATAMODE={history:1,statemode:2,database:3},SERIESDEFAULT_VALUE=0,TRANSFORM_MODE={statebased:1,datalabel:2,seriesdata:3},DATEFILTERS={year:{digits:4,format:"yyyy"},month:{digits:7,format:"yyyy-mm"},day:{digits:10,format:"yyyy-mm-dd"},hour:{digits:13,format:"yyyy-mm-dd H"},minute:{digits:16,format:"yyyy-mm-dd H:M"},second:{digits:19,format:"yyyy-mm-dd H:M:s"},millisecond:{digits:23,format:"yyyy-mm-dd H:M:s.l"}};function setChartDefaults(t){if(window.Chart3&&window.Chart3.defaults){if(window.Chart3.defaults.theme&&t.theme==window.Chart3.defaults.theme)return;window.Chart3.defaults.theme=t.theme,window.Chart3.defaults.responsive=!0,window.Chart3.defaults.maintainAspectRatio=!1,window.Chart3.defaults.hoverOffset=8,t.useAnimations||(window.Chart3.defaults.animation=0),window.Chart3.defaults.locale=t.locale,window.localeNames=getLocaleText(window.Chart3.defaults.locale),window.Chart3.defaults.font.family=t.font,window.Chart3.defaults.color=convertColor(t.fontColor),window.Chart3.defaults.layout.padding.top=t.padding.top||0,window.Chart3.defaults.layout.padding.bottom=t.padding.bottom||0,window.Chart3.defaults.layout.padding.left=t.padding.left||0,window.Chart3.defaults.layout.padding.right=t.padding.right||0,window.Chart3.defaults.plugins.legend.labels.color=convertColor(t.fontColor),window.Chart3.defaults.plugins.legend.position="top",window.Chart3.defaults.plugins.legend.labels.usePointStyle=!0,window.Chart3.defaults.plugins.legend.labels.boxWidth=8,window.Chart3.defaults.plugins.legend.show=!1,window.Chart3.defaults.plugins.tooltip.backgroundColor=convertColor(t.tooltipsBackground),window.Chart3.defaults.plugins.tooltip.titleColor=convertColor(t.tooltipsFontColor),window.Chart3.defaults.plugins.tooltip.bodyColor=convertColor(t.tooltipsFontColor),window.Chart3.defaults.plugins.tooltip.footerColor=convertColor(t.tooltipsFontColor),window.Chart3.defaults.plugins.tooltip.enabled=!0,window.Chart3.defaults.elements.arc.borderWidth=0,window.Chart3.defaults.elements.line.fill=!1,window.Chart3.defaults.elements.line.tension=.225,window.Chart3.defaults.elements.point.borderWidth=0,window.Chart3.defaults.elements.point.hoverRadius=8,window.Chart3.defaults.elements.point.hitRadius=8,window.Chart3.defaults.scale.grid.drawBorder=!0,window.Chart3.defaults.scale.grid.borderWidth=parseFloat((1.1*t.gridLineWidth).toFixed(3))||1,window.Chart3.defaults.scale.grid.color=convertColor(t.gridlineColor,.8),window.Chart3.defaults.scale.grid.lineWidth=t.gridLineWidth,window.Chart3.defaults.scale.grid.borderDash=t.borderDash,window.Chart3.defaults.scale.grid.lineWidth=(e=>0===e.index?0:t.gridLineWidth||1),window.Chart3.defaults.scale.grid.borderColor=convertColor(t.zeroLineColor),window.Chart3.defaults.scale.alignToPixels=!0,window.Chart3.defaults.scales.radialLinear.ticks.backdropColor="transparent",window.gradient&&window.Chart3.register(window.gradient)}}window.Chart3=Chart;const plugin_gradient=window["chartjs-gradient"],fireEvent=(t,e,a,i)=>{i=i||{},a=null==a?{}:a;const s=new Event(e,{bubbles:void 0===i.bubbles||i.bubbles,cancelable:Boolean(i.cancelable),composed:void 0===i.composed||i.composed});return s.detail=a,t.dispatchEvent(s),s},style=document.createElement("style");style.innerHTML="\n html {\n scrollbar-width: none; \n -ms-overflow-style: none;\n }\n\n html::-webkit-scrollbar {\n width: 0px;\n }\n .card-header{\n padding-bottom:0 !important;\n white-space:nowrap;\n }\n .card-header-icon{\n position:relative;\n top:-2px;\n padding:0 6px 0 4px;\n }\n .card-header-title{\n overflow:hidden;\n text-overflow:ellipsis;\n white-space:nowrap;\n display:inline-block;\n vertical-align:top;\n width:70%;\n }\n .card-content{\n overflow: auto;\n }\n .card-canvas{\n -moz-user-select: none; \n -webkit-user-select: none; \n -ms-user-select: none;\n width:100%;\n height:auto;\n }\n .card-loader{\n width: 60px;\n position:absolute;\n top:42%;\n left:38%;\n width:60px;\n z-index:500;\n margin: 0 auto\n }\n .card-state-view{\n position:absolute;\n top:12px;\n right:20px;\n background-color:transparent;\n max-width: 15%;\n z-index:100;\n }\n .card-state-view::-webkit-scrollbar,\n .state-view-data::-webkit-scrollbar {\n display: none;\n }\n .state-view-data{\n font-weight:400;\n margin:0;\n cursor:pointer;\n height:3.85em;\n overflow:auto;\n scrollbar-width: none; \n -ms-overflow-style: none;\n }\n .state-view-value{\n font-size:1.85em;\n line-height:1.2em;\n text-align:right;\n margin:0;\n color:#fff;\n border-bottom: 1px dotted\n }\n .state-view-value span{\n padding-left: 4px;\n font-size:0.4em;\n vertical-align:top\n } \n .state-view-name{\n border: none;\n font-size: 0.65em;\n text-align: center;\n margin: 0;\n line-height: 2em;\n width: 95%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n } \n .card-detail-view{\n margin-top: 1.925em;\n }\n .card-detail-view hr{\n border-bottom-width: 0px;\n opacity:0.5;\n } \n .card-detail-view h2{\n margin-left: 0.5em;\n font-size: 1.25em;\n }\n .card-detail-table{\n margin: 0 auto;\n font-size:0.925em;\n font-weight:300;\n width: 95%;\n border-collapse: collapse !important;\n table-layout: fixed;\n text-align:left;\n line-height: 1.8rem\n }\n table-row-background-color\n\n .card-detail-table tr:nth-child(even) {background: var(--table-row-background-color)}\n .card-detail-table tr:nth-child(odd) {background:var(--table-row-alternative-background-color)}\n\n .card-detail-table th{\n padding: 0 6px;\n font-weight:400;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .card-detail-table td{\n padding: 0 6px;\n overflow:hidden;\n text-overflow:ellipsis;\n white-space:nowrap;\n font-weight:300;\n }\n .card-timestamp{\n position:absolute;\n right:0.8em;\n bottom:0;\n font-weight:300;\n font-size:0.7em;\n text-align:right;\n z-index:800\n color: #000000;\n }\n @media (min-width: 320px) and (max-width: 480px){\n \n }\n";class ChartCard extends HTMLElement{constructor(){super(),this._hass=null,this._config=null,this.attachShadow({mode:"open"}),this.card_icon=null,this.card_title=null,this.card_height=240,this.theme="",this.themeSettings=null,this.graphChart=null,this.chart_type="bar",this.chart_locale="de-DE",this.chart_update=!1,this.ctx=null,this.chartconfig=null,this.graphData={},this.hassEntities=[],this.entity_items=new Entities(null,!1),this.entity_options=null,this.updateTimer=-1,this.update_interval=6e4,this.skipRender=!1,this.lastUpdate=null,this.ready=!1,this.updating=!1,this._initialized=!1,this.initial=!0,this.dataInfo={time_start:new Date,ISO_time_start:(new Date).toISOString(),time_end:new Date,ISO_time_end:(new Date).toISOString(),entity_items:null,entities:"",useAlias:!1,time:(new Date).getTime(),loading:!1,url:"",prev_url:"not_set",param:"",options:""},this.DEBUGMODE=0,this.DEBUGDATA={API:{}},this.APISTART=performance.now(),this.DEBUGDATA.API.elapsed_total=0,this.DEBUGDATA.PROFILER={}}_evaluateCssVariable(t){try{return getComputedStyle(document.documentElement).getPropertyValue(t).trim()}catch(e){console.error("ERROR evaluateCssVariable:",t,"ERROR",e.message,e)}return t}_setDefaultThemeSettings(){this.themeSettings={theme:{theme:"system",dark:!1},fontColor:"#1E1E1E",fontFamily:"Quicksand, Roboto,'Open Sans','Rubik','Helvetica Neue', 'Helvetica', 'Arial', sans-serif",gridlineColor:"1E1E1E",zeroLineColor:"#333333",tooltipsBackground:"#ecf0f1",tooltipsFontColor:"#647687",showGridLines:CT_CHARTGRIDLINES.includes(this.chart_type.toLowerCase())||!1,secondaryAxis:!1,gridLineWidth:1,borderDash:[1,1],padding:{top:20,right:24,bottom:12,left:24},useAnimations:!0,locale:this.chart_locale}}_getThemeSettings(){this._setDefaultThemeSettings();try{return this.themeSettings.fontColor=this.chart_themesettings&&this.chart_themesettings.fontcolor||this._evaluateCssVariable("--chartjs-text-fontColor")||this._evaluateCssVariable("--primary-text-color")||this.themeSettings.fontFamily,this.themeSettings.fontFamily=this._evaluateCssVariable("--chartjs-fontFamily")||this._evaluateCssVariable("--paper-font-common-base_-_font-family")||"Quicksand, Roboto,'Open Sans','Rubik','Helvetica Neue', 'Helvetica', 'Arial', sans-serif",this.themeSettings.gridlineColor=this.chart_themesettings&&this.chart_themesettings.gridlinecolor||this._evaluateCssVariable("--chartjs-gridline-color")||this._evaluateCssVariable("--light-primary-color")||this.themeSettings.gridlineColor,this.themeSettings.zeroLineColor=this.chart_themesettings&&this.chart_themesettings.zerolinecolor||this._evaluateCssVariable("--chartjs-zero-gridline-color")||this._evaluateCssVariable("--dark-primary-color")||this.themeSettings.zeroLineColor,this.themeSettings.tooltipsBackground=this.chart_themesettings&&this.chart_themesettings.tooltipsbackground||this._evaluateCssVariable("--chartjs-tooltip-background")||this.themeSettings.tooltipsBackground,this.themeSettings.tooltipsFontColor=this.chart_themesettings&&this.chart_themesettings.tooltipsfontcolor||this._evaluateCssVariable("--chartjs-text-fontcolor")||this.themeSettings.tooltipsFontColor,this.themeSettings.showGridLines=CT_CHARTGRIDLINES.includes(this.chart_type.toLowerCase())||!1,this.themeSettings.secondaryAxis=!1,this.themeSettings.themecolorused=this._evaluateCssVariable("--chartjs-theme")||!1,this.themeSettings.useAnimations=this._evaluateCssVariable("--chart-animantions")||this.themeSettings.useAnimations,void 0!==this.theme&&void 0!==this.theme.dark||(this.theme={theme:"system",dark:"dark"===this.themeSettings.themecolorused||!1},this.themeSettings.theme=this.theme),this.theme&&null!=this.theme.dark&&(this.themeSettings.theme=this.theme),this.themeSettings.gridLineWidth=this.themeSettings.theme.dark?.8:1,this.themeSettings.borderDash=[1,1],this.chartconfig.options&&this.chartconfig.options.scale&&this.chartconfig.options.scale.gridLines&&(this.themeSettings.showGridLines=!0),this.chartconfig.options&&this.chartconfig.options.legend&&(this.themeSettings.showLegend=!0),this.DEBUGMODE&&(this.DEBUGDATA.THEMESETTINGS=this.themeSettings),setChartDefaults(this.themeSettings),!0}catch(t){console.error("Fatal Error theme settings",t.message,t)}return!1}_setChartConfig(){if(this._getThemeSettings(),this.ctx){let t={ctx:this.ctx,canvasId:this.canvasId,entity_items:this.entity_items,chart_type:this.chart_type,chartconfig:this.chartconfig,loader:this.loader,debugmode:this.DEBUGMODE,debugdata:this.DEBUGDATA};this.graphChart=new graphChart(t)}else console.error("No chart.js container found !")}_creatHACard(){if(this.id)return;this.id="TC"+Math.floor(1e3*Math.random());const t=document.createElement("ha-card");t.setAttribute("class","graph-card"),t.id=this.id+"-card",t.setAttribute("data-graphtype",this.chart_type),this.chart_themesettings&&this.chart_themesettings.cardbackground&&(t.style.cssText+=`background: ${this.chart_themesettings.cardbackground} !important;`);const e=document.createElement("div");if(e.setAttribute("class","card-content"),e.id=this.id+"-view",this.chart_showdetails&&1==this.chart_showdetails.visible||(e.style.height=cssAttr(this.card_height)),this.card_title||this.card_icon){const e=document.createElement("div");if(e.setAttribute("class","card-header header flex"),e.id=this.id+"-header",this.card_icon){const t=document.createElement("ha-icon");t.setAttribute("class","card-header-icon"),t.setAttribute("icon",this.card_icon),e.appendChild(t)}if(this.card_title){const t=document.createElement("span");t.setAttribute("class","card-header-title"),t.innerHTML=this.card_title,e.appendChild(t)}t.append(e)}this.canvasId=this.id+"-chart";const a=document.createElement("canvas");a.setAttribute("class","card-canvas"),this.ctx=a.getContext("2d"),a.id=this.canvasId;a.height=this.card_height-10,a.style.height=cssAttr(this.card_height-10),a.style.maxHeight=cssAttr(this.card_height-10),a.style.display="block",this.loaderart&&(this.loader=document.createElement("img"),this.loader.setAttribute("class","card-loader"),this.loader.id=this.id+"-loader",this.loader.alt="loading...",this.loader.style.width="60",this.loader.src=appinfo.assets+this.loaderart+".svg"),this.chart_showstate&&(this.currentData=document.createElement("div"),this.currentData.setAttribute("class","card-state-view"),this.currentData.id=this.id+"state-view"),this.showdetails&&this.chart_showdetails?(this.detailData=document.createElement("div"),this.detailData.setAttribute("class","card-detail-view"),this.detailData.id=this.id+"detail-info",this.detailData.id&&(this.detailData.setAttribute("data-view",this.detailData.id),1==this.chart_showdetails.visible&&this.detailData.setAttribute("style","margin:0 !important;"))):e.style.maxHeight=cssAttr(this.card_height),e.appendChild(a),this.loader&&e.append(this.loader),this.showdetails&&this.detailData&&e.append(this.detailData),t.appendChild(e),this.chart_showstate&&this.currentData&&t.appendChild(this.currentData),this.card_timestamp&&(this.timestampLayer=document.createElement("div"),this.timestampLayer.setAttribute("class","card-timestamp"),this.timestampLayer.id=this.id+"detail-footertext",this._renderCardTimestamp(),t.appendChild(this.timestampLayer)),this.card=t,this.root.appendChild(t)}_checkLocale(t){try{Intl.getCanonicalLocales(t)}catch(t){return console.error(" RangeError: invalid language tag:",this.config),navigator.language||navigator.userLanguage}return t}getEntities(){let t=JSON.parse(JSON.stringify(this._config.entities));if(t&&0!==t.length)return t.forEach(t=>{if(t.entity){const e=t.entity.split(".");t.id=`${e[0]}.${e[1]}`}else t.id="OD-"+Math.floor(1e3*Math.random())}),t}_checkDatascales(){this.datascales=Object.assign({},this._config.datascales),this.datascales.chart=this.chart_type.toLowerCase(),this.datascales.cardtitle=this.card_title,this.datascales.range=this.datascales.range||0,this.datascales.unit&&(this.datascales.unit=this.datascales.unit.toLowerCase()),void 0===this.datascales.mode?this.datascales.mode=CT_DATASCALEMODES[this.datascales.chart]:this.datascales.mode=CT_DATASCALEMODES[this.datascales.mode]||CT_DATASCALEMODES[this.datascales.chart],0===this.datascales.range||this.datascales.mode.history||(this.datascales.mode.history=!0),this.chart_type.isChartType("line")&&0===this.datascales.range&&(this.datascales.range=48,this.datascales.unit=DSC_UNITS[0],this.datascales.format=this.datascales.format||this.datascales.unit),this.datascales.range&&(this.datascales.unit=this.datascales.unit||DSC_UNITS[0],this.datascales.format=this.datascales.format||this.datascales.unit,this.datascales.ignoreZero=this.datascales.ignoreZero||!0,this.datascales.aggregate=this.datascales.aggregate||DSC_RANGES[0]),this.datascales.unit&&0==DSC_UNITS.includes(this.datascales.unit)&&(this.datascales.range=24,this.datascales.unit=DSC_UNITS[0],this.datascales.format=this.datascales.format||this.datascales.unit),this.datascales.aggregate&&0==DSC_RANGES.includes(this.datascales.aggregate.toLowerCase())&&(this.datascales.aggregate=DSC_RANGES[0]),this.datascales.factor=this.datascales.factor||1,this.datascales.isoWeekday=this.datascales.isoWeekday||1}setConfig(t){if(!t.entities)throw new Error("You need to define an entity");try{if(this._config)return void console.error("CHART-CART Config",t.title," allready loaded...");for(this.root=this.shadowRoot;this.root.hasChildNodes();)this.root.removeChild(root.lastChild);const e=style.cloneNode(!0);if(this.root.appendChild(e),this._config=Object.assign({},t),this._config.chart=this._config.chart||"bar",this.DEBUGMODE=this._config.debug||this.DEBUGMODE,this.card_title=this._config.title||"",this.card_icon=this._config.icon||null,this.card_height=this._config.height||240,this.card_timestamp=this._config.cardtimestamp||!0,this.chart_type=this._config.chart||"bar",this._config.id=this.chart_type+Math.floor(1e3*Math.random()),this.chart_showstate=this._config.showstate||!1,this.showdetails=!1,this.chart_showdetails=Object.assign({},this._config.showdetails),this._config.showdetails&&(this.showdetails=""!==[this.chart_showdetails.title_mean||"",this.chart_showdetails.title_min||"",this.chart_showdetails.title_max||""].join("")),this.chart_themesettings=this._config.theme||null,this.loaderart=this._config.loader||"three-dots",LOADERFILES.includes(this.loaderart)||(this.loaderart="spinning-circles"),!this.chart_type)throw new Error("You need to define type of chart");if(!CT_AVIABLETYPES.includes(this.chart_type.toLowerCase()))throw new Error("Invalid config for 'chart:'"+this.chart_type+". Available options are: "+availableTypes.join(", "));"horizontalbar"===this.chart_type.toLowerCase()&&(this.chart_type="bar"),this.chartconfig={},this.chartconfig.type=this.chart_type,(this._config.options||this._config.chartOptions)&&(this.chartconfig.options=this._config.options||this._config.chartOptions),this.chart_locale=navigator.language||navigator.userLanguage||"DE",this._checkLocale(),this._checkDatascales(),this.update_interval=1e3*this._config.update_interval||this.update_interval,this.chart_showstate&&(0===this.datascales.range||CT_NOSHOWSTATES.includes(this.chart_type.toLocaleLowerCase()))&&(this.chart_showstate=!1,this.showdetails=!1),!1===this._initialized&&this._creatHACard()}catch(e){console.error(e.message,t,e)}}setEntity_itemsData(t){if(!1===this.ready&&this.entity_items.getSize()!==this.hassEntities.length){this.entity_options=null,this.entity_items=new Entities(null);for(const e of t){if(e.options)this.entity_options=Object.assign({},e.options);else{const t=this.hassEntities.find(t=>t.entity_id===e.id);if(t){let a=this.entity_items.getEntity(e.entity)||Object.assign({},e);t.attributes&&(void 0===a.name&&(a.name=t.attributes.friendly_name||a.name),a.unit=a.unit||t.attributes.unit_of_measurement||""),void 0!==a.name&&(a.last_changed=t.last_changed,a.state=t.state||0,a.value=t.state||0,a.dataid&&a.datasource&&a.datasource.influxdb&&(this.datascales.range=this.datascales.range||24,this.datascales.unit=this.datascales.unit||DSC_UNITS[0],a.datascales=this.datascales||{}),a.datascales=this.datascales,a.datascales.ignoreZero=this.datascales.ignoreZero||a.ignoreZero||!1,a.datascales.aggregate=a.aggregate||this.datascales.aggregate||"last",a.datascales.factor=a.factor||this.datascales.factor,a.datascales.useStatistics=this.chart_showdetails||!1,a.state=a.state*a.datascales.factor,a.factor=a.datascales.factor,a.ignoreZero=a.ignoreZero||this.datascales.ignoreZero,a.stateOnly=a.stateOnly||!1,a.useAttribute=!1,a.entity!=a.id&&(a.field=a.entity.slice(a.id.length+1),a.state=(getAttributeValue(t,a.field)||0)*a.factor,a.useAttribute=!0),a.attribute&&(a.field=`attributes.${a.attribute}`,a.state=(getAttributeValue(t,a.field)||0)*a.factor,a.useAttribute=!0),a.target_value&&isNumeric(a.target_value)?(a.current=a.state,a.uom=a.unit,a.state=this.entity_items.calcItemValue({value:a.state,factor:a.factor||1,target_value:a.target_value})):a.state=_safeParseFloat(a.state),a.chart=this.chart_type,a.dataready=!1,this.entity_items.addEntity(a))}}null===this.entity_options?this.entity_options={settings:!1,mode:this.datascales.mode||CT_DATASCALEMODES.disabled}:this.entity_options.mode=this.entity_options.mode||this.datascales.mode||CT_DATASCALEMODES.disabled}return this.entity_items.isValid()||!1}return!1}set hass(t){if(void 0===t)return;this.timeOut&&clearTimeout(this.timeOut),this._hass=t;const e=this._hass.language||navigator.language||navigator.userLanguage||"en-GB";this.chart_locale!==e&&(this.chart_locale=e,window.localeNames=getLocaleText(e),window.Chart3.defaults.locale=e,this._getThemeSettings(),this.graphChart&&(this.themeSettings.theme=this.theme,this.updateGraph(!0))),this.selectedTheme=t.selectedTheme||{theme:"system",dark:!1},this.theme&&this.theme.dark!==this.selectedTheme.dark&&(this.theme=this.selectedTheme,this._getThemeSettings(),this.graphChart&&(this.themeSettings.theme=this.theme,this.updateGraph(!0))),this.theme=this.selectedTheme;const a=this.getEntities();a?(this.hassEntities=a.map(e=>t.states[e.id]).filter(t=>void 0!==t),this.hassEntities&&0!==this.hassEntities.length?this.skipRender&&!1===this.updating&&0===this.update_interval?this.checkUpdate():(this.ready=this.setEntity_itemsData(a),this.timeOut=setTimeout(()=>{this.updateGraph(!1)},this.initial?200:this.update_interval),this.skipRender=!0):console.error(this.chart_type,"No valid entities found, check your settings...")):console.error(this.chart_type,"No valid entities found, check your settings...")}updateGraph(t){t="undefined"===t?!this.initial:t,!0!==this.updating&&(this.graphChart||(this._getThemeSettings(),this.themeSettings.theme=this.theme,this._setChartConfig(),t=!1),this.graphChart&&(this.updating=!0,this._getThemeSettings(),this.themeSettings.theme=this.theme,this.entity_items.getSize&&(this.graphChart.entityData=this.entity_items.getData(),this.chart_update=t,this._getHistory(),this._renderCardTimestamp()),this.updating=!1,this.initial=!1))}checkUpdate(){if(!0===this.updating)return!1;this.hasChanged=!1;const t=this.entity_items.getEntitieslist();return this.hassEntities&&this.hassEntities.length&&this._hass&&(this.hassEntities=t.map(t=>this._hass.states[t.entity]).filter(t=>void 0!==t),this.hasChanged=this.entity_items.hasChanged(this.hassEntities),this.hasChanged&&this.updateGraph(!0)),this.hasChanged}_getHistory(){if(1!=this.dataInfo.loading&&(!this.card||0!=this.card.getClientRects().length)&&(this.ready=this.entity_items.isValid(),this.ready))if(this.DEBUGMODE&&(this.APISTART=performance.now(),this.DEBUGDATA.PROFILER.GETHASSDATA={start:performance.now()},this.DEBUGDATA.PROFILER.GETBUCKETDATA={start:performance.now()},this.DEBUGDATA.PROFILER.GETSTATEDATA={start:performance.now()}),this.datascales.range>0)if(this.dataInfo.entities=this.entity_items.getEntityIdsAsString(),this.dataInfo.entity_items=this.entity_items.items,this.dataInfo.useAlias=this.entity_items.useAliasFields(),""!=this.dataInfo.entities){if(this.dataInfo.time=(new Date).getTime(),this.dataInfo.time_start=new Date,this.datascales.range<1?(this.dataInfo.time_start.setMinutes(this.dataInfo.time_start.getMinutes()-60*this.datascales.range),this.dataInfo.range=`${60*this.datascales.range} min`):(1==["day","month","year"].includes(this.datascales.unit)?this.dataInfo.time_start.setHours(-this.datascales.range,0,0,0):this.dataInfo.time_start.setHours(this.dataInfo.time_start.getHours()-this.datascales.range),this.dataInfo.range=`unit: ${this.datascales.unit}, range: ${this.datascales.range} h`),this.dataInfo.time_end=new Date,this.dataInfo.ISO_time_start=this.dataInfo.time_start.toISOString(),this.dataInfo.ISO_time_end=this.dataInfo.time_end.toISOString(),this.dataInfo.options="&skip_initial_state",this.dataInfo.useAlias||(this.dataInfo.options+="&minimal_response"),this.dataInfo.param==`${this.dataInfo.time_end}:${this.dataInfo.entities}`)return void console.warn("Data allready loaded...");if(this.dataInfo.param=`${this.dataInfo.time_end}:${this.dataInfo.entities}`,this.dataInfo.url=`history/period/${this.dataInfo.ISO_time_start}?end_time=${this.dataInfo.ISO_time_end}&filter_entity_id=${this.dataInfo.entities}${this.dataInfo.options}`,this.dataInfo.url!==this.dataInfo.prev_url){this.dataInfo.loading=!0;this._hass.callApi("GET",this.dataInfo.url).then(t=>this._buildGraphData(t,API_DATAMODE.history),()=>null);this.dataInfo.prev_url=this.dataInfo.url}}else{this.DEBUGMODE&&(this.DEBUGDATA.INFLUXDB,this.DEBUGDATA.PROFILER.INFLUXDB={start:performance.now()},this.DEBUGDATA.INFLUXDB={url:"",authorization:!1,count:0,status:"init"}),this.entity_items.getEntitieslist().forEach(t=>{this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.INFLUXDB.start=performance.now()),t.datasource&&this._buildGraphDataInfluxDB(t)})}else this._buildGraphData(null,API_DATAMODE.statemode)}renderStateData(t){let e=[];if(this.currentData&&this.chart_showstate&&t){let a="margin:0;line-height:1.2em";e.push('
');for(const i of t){let t=' style="'+a+";color:"+i.color+'"';e.push('
'),e.push(`

${_formatNumber(this.chart_locale,i.current||0)}${i.unit||""}

`),e.push('

'+i.name+"

"),e.push("
")}e.push("
"),this.currentData.innerHTML=e.join("")}if(this.chart_showdetails&&this.detailData&&t){const t=this.entity_items.getStatisticData();t&&((e=[]).push(`
`),this.chart_showdetails.title&&e.push(`

${this.chart_showdetails.title}

`),e.push('
'),e.push(""),e.push(``),this.chart_showdetails.title_mean&&""!=this.chart_showdetails.title_mean&&e.push(``),this.chart_showdetails.title_min&&""!=this.chart_showdetails.title_min&&e.push(``),this.chart_showdetails.title_max&&""!=this.chart_showdetails.title_max&&e.push(``),this.chart_showdetails.title_current&&""!=this.chart_showdetails.title_current&&e.push(``),this.chart_showdetails.title_timestamp&&""!=this.chart_showdetails.title_timestamp&&e.push(``),e.push(""),t.forEach(t=>{e.push(""),e.push('"),this.chart_showdetails.title_mean&&""!=this.chart_showdetails.title_mean&&e.push(""),this.chart_showdetails.title_min&&""!=this.chart_showdetails.title_min&&e.push(""),this.chart_showdetails.title_max&&""!=this.chart_showdetails.title_max&&e.push(""),this.chart_showdetails.title_current&&""!=this.chart_showdetails.title_current&&e.push(""),this.chart_showdetails.title_timestamp&&""!=this.chart_showdetails.title_timestamp&&e.push("")}),e.push("
${this.chart_showdetails.title_sensor||"Statitics"}${this.chart_showdetails.title_mean}${this.chart_showdetails.title_min}${this.chart_showdetails.title_max}${this.chart_showdetails.title_current||"current"}${this.chart_showdetails.title_timestamp||"Timestamp"}
'+t.name+""+_formatNumber(this.chart_locale,t.mean||0)+" "+t.unit+""+_formatNumber(this.chart_locale,t.min||0)+" "+t.unit+""+_formatNumber(this.chart_locale,t.max||0)+" "+t.unit+""+_formatNumber(this.chart_locale,t.current||0)+" "+t.unit+""+localDatetime(t.timestamp,this.chart_locale)+""),e.push("

"),e.length&&(this.detailData.innerHTML=e.join("")))}}_renderCardTimestamp(){this.card_timestamp&&this.timestampLayer&&(this.timestampLayer.innerHTML=localDatetime((new Date).toISOString()))}_renderDebugInfo(){this.DEBUGMODE&&(this.DEBUGDATA.CARD=this.card_title,this.DEBUGDATA.API.updateIntervall=msToTime(this.update_interval),this.DEBUGDATA.API.elapsed_total=msToTime(performance.now()-this.APISTART),this.DEBUGDATA.API.datainfo=this.dataInfo,this.DEBUGDATA.DATA_ENTITIES=this.entity_items.items,this.DEBUGDATA.LOVELACE_CONFIG=this._config,this.DEBUGDATA.LOCALEINFO=window.localeNames,this.DEBUGDATA.PROFILER&&(this.DEBUGDATA.PROFILER.GETHASSDATA&&delete this.DEBUGDATA.PROFILER.GETHASSDATA.start,this.DEBUGDATA.PROFILER.GETBUCKETDATA&&delete this.DEBUGDATA.PROFILER.GETBUCKETDATA.start,this.DEBUGDATA.PROFILER.GETSTATEDATA&&delete this.DEBUGDATA.PROFILER.GETSTATEDATA.start,this.DEBUGDATA.PROFILER.CHART&&this.DEBUGDATA.PROFILER.CHART.start&&delete this.DEBUGDATA.PROFILER.CHART.start,this.DEBUGDATA.PROFILER.DATAPROVIDER&&delete this.DEBUGDATA.PROFILER.DATAPROVIDER.start),console.info(`%cDEBUGDATA ${this.chart_type.toUpperCase()} ${appinfo.name} ${appinfo.version}:`,"color:white;background:#cc283a;padding:4px",this.DEBUGDATA))}_buildGraphDataInfluxDB(t){if(!t.datasource.influxdb||!t.datasource.query)return;const e={host:t.datasource.influxdb||null,query:t.datasource.query||null,token:t.datasource.token||""};e.url=encodeURI(e.host+"&q="+e.query),e.authorization=""!=e.token,this.DEBUGMODE&&(this.DEBUGDATA.INFLUXDB.url=e.url,this.DEBUGDATA.INFLUXDB.authorization=""!=e.token,this.DEBUGDATA.INFLUXDB.count=0),function(t){return new Promise((e,a)=>{const i=new XMLHttpRequest;i.open("GET",t.url),t.authorization&&i.setRequestHeader("Authorization","Basic "+t.token),i.withCredentials=!1,i.responseType="json",i.onreadystatechange=(()=>{i.readyState<4||(200!==i.status&&a(i.response),4===i.readyState&&e(i.response))}),i.send()})}(e).then(e=>{if(e&&e.results[0]){if(e.results[0].series){if(t.dbfields=e.results[0].series[0].columns,t.seriesdata=t.seriesdata||[],t.seriesdata.data=t.seriesdata.data||[],t.seriesdata.data=e.results[0].series[0].values.map(e=>({x:e[0],y:e[1],localedate:formatdate(e[0],t.datascales.format)})),t.datascales.data_count=t.seriesdata.data.length,t.datascales.data_count){if(t.datascales.useStatistics){const e=t.seriesdata.data.filter(t=>null!==t.y);t.statistics={current:e[e.length-1].y,first:e[0].y,last:e[e.length-1].y,min:e.reduce((t,e)=>e.ye.y>t?e.y:t,e[0].y),sum:e.reduce((t,{y:e})=>t+e,0),avg:e.reduce((t,{y:e})=>t+e,0)/e.length},t.statistics.range=t.statistics.max-t.statistics.min,t.statistics.midrange=.5*(t.statistics.max-t.statistics.min),t.state=t.statistics.current}this._buildGraphData(null,API_DATAMODE.database)}this.DEBUGMODE&&(this.DEBUGDATA.INFLUXDB.count=t.datascales.data_count)}this.DEBUGMODE&&(this.DEBUGDATA.INFLUXDB.status="No Error, all well done..."),this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.INFLUXDB.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.INFLUXDB.start))}else this.DEBUGMODE&&(this.DEBUGDATA.INFLUXDB.status="No Error, but no data found!"),this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.INFLUXDB.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.INFLUXDB.start))}).catch(e=>{throw this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.INFLUXDB.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.INFLUXDB.start),this.DEBUGDATA.INFLUXDB.status="Fatal Error: "+e,this._renderDebugInfo()),console.error("Dataprovider.getInfluxDbData",{card:this.card_title,entitiy:t.name,errormessage:e,connection:t.datasource.influxdb,query:t.datasource.query,token:t.datasource.token}),e})}_buildGraphData(t,e){if(this.DEBUGMODE&&(this.DEBUGDATA.API.datamode=e==API_DATAMODE.history?"History":"Current",e==API_DATAMODE.history&&(this.DEBUGDATA.PROFILER.GETHASSDATA.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.GETHASSDATA.start),this.DEBUGDATA.PROFILER.HISTORYDATA=t,this.DEBUGDATA.PROFILER.GETBUCKETDATA={start:performance.now()})),e===API_DATAMODE.history&&!t||t&&!t.length)return this.DEBUGMODE&&(this.DEBUGDATA.API.ERROR="No Historydata found!",this._renderDebugInfo()),this.dataInfo.loading=!1,null;if(!this.entity_items.isValid())return this.DEBUGMODE&&(this.DEBUGDATA.API.ERROR="No valid Entities found!",this.DEBUGDATA.API.DATA=t,this._renderDebugInfo()),this.dataInfo.loading=!1,null;if(e==API_DATAMODE.history){const e=new DataProvider({datainfo:this.dataInfo,datascales:this.datascales,debugmode:this.DEBUGMODE,debugdata:this.DEBUGDATA});if(1==CT_DATASCALEMODES[this.chart_type.toLowerCase()].multiseries?e.datamode=this.chartconfig.options.multiseries?TRANSFORM_MODE.seriesdata:TRANSFORM_MODE.statebased:e.datamode=TRANSFORM_MODE.seriesdata,0==e.getSeriesdata(t))return this.DEBUGMODE&&(this.DEBUGDATA.API.DATA=t,this.DEBUGDATA.API.ERROR="Transform Historydata failed!",this._renderDebugInfo()),this.dataInfo.loading=!1,null}const a=new chartData({card_config:{title:this.card_title,chart:this._config.chart,chartOptions:this.chartconfig.options},entity_items:this.entity_items,entityOptions:this.entity_options,debugmode:this.DEBUGMODE,debugdata:this.DEBUGDATA});if(e===API_DATAMODE.statemode?(this.graphData=a.getCurrentGraphData(),this.lastUpdate=(new Date).toISOString()):(this.graphData=a.getHistoryGraphData(),this.lastUpdate=(new Date).toISOString()),null===this.graphData)return this.DEBUGMODE&&(this.DEBUGDATA.API.ERROR="No GraphData found!",this.DEBUGDATA.API.DATA=t,this._renderDebugInfo()),this.dataInfo.loading=!1,null;if(this.graphData&&this.graphData.config&&(this.themeSettings.secondaryAxis=this.graphData.config.secondaryAxis||!1),this.DEBUGMODE&&(e===API_DATAMODE.statemode&&(this.DEBUGDATA.PROFILER.GETSTATEDATA.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.GETSTATEDATA.start)),this.DEBUGDATA.PROFILER.CHART={start:performance.now()}),this.chart_update?this.graphChart&&this.graphData&&(this.graphChart.graphData=this.graphData,this.graphChart.renderGraph(!0)):this.graphChart&&this.graphData&&(this.graphChart.graphData=this.graphData,this.graphChart.renderGraph(!1)),this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.CHART.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.CHART.start)),this._renderCardTimestamp(),e!=API_DATAMODE.statemode){if(this.chart_showstate||this.showdetails){let t=this.graphData.data.datasets.map(function(t){return{name:t.label||"",current:t.current,unit:t.unit||"",color:t.labelcolor||t.backgroundColor,timestamp:t.last_changed||""}});t&&this.renderStateData(t)}return this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.GETBUCKETDATA.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.GETBUCKETDATA.start),this._renderDebugInfo()),this.dataInfo.loading=!1,!0}this.DEBUGMODE&&this._renderDebugInfo(),this.dataInfo.loading=!1}connectedCallback(){this._initialized=!0,0!==this.update_interval&&(this.updateTimer=setInterval(()=>{!1===this.updating&&this.checkUpdate()},this.update_interval))}disconnectedCallback(){this._initialized=!1,this.updateTimer&&clearInterval(this.updateTimer)}getCardSize(){return 1}}customElements.define("chart-card",ChartCard);class Entities{constructor(t){this.items=t||{}}addEntity(t){t.dataid?this.items[t.dataid]=t:this.items[t.id]=t}_getDataFromInfluxDb(){}setData(t,e){this.items[t]=e}setDataField(t,e,a){this.items[t][e]=a}getSize(){return this.getEntityIds().length}isValid(){return 0!=this.getSize()}useAliasFields(){let t=0;return this.getEntityIds().forEach(e=>{this.items[e];t+=this.items[e].attribute?1:0}),0!=t}calcItemValue(t){let e=+t.value||0;return e*=t.factor,t.target_value&&isNumeric(t.target_value)&&(e=t.value/t.target_value*100),_safeParseFloat(e)||0}hasChanged(t){let e=!1;if(t&&t.length){const a=this.getEntitieslist();for(let i of a){const a=t.find(t=>t.entity_id===i.entity);i.laststate=i.state||0,i.update=!1,a&&i.last_changed!==a.last_changed&&i.state!==a.state&&(i.last_changed=a.last_changed,i.state=this.calcItemValue({value:i.useAttribute?getAttributeValue(a,i.field):a.state,factor:i.factor||1,target_value:i.target_value}),i.target_value&&isNumeric(i.target_value)&&(i.unit="%",i.current=a.state),i.update=!0,e=!0)}}return e}getEntity(t){return Number.isInteger(t)?this.getEntitieslist()[t]:this.items[t]}getNames(){return this.getAttribute("name")}getAttribute(t){let e=this.items;return Object.keys(e).map(function(a){return e[a][t]}).filter(t=>void 0!==t)}getOptions(t,e){const a=this.getEntity(t);return a&&a.style&&!e?a.style:a&&a.style&&void 0!==a.style[e]?a.style[e]:{}}getDataScales(t){const e=this.getEntity(t);return e?e.datascales:{range:24,unit:"day",format:"MMM d",factor:1,ignoreZero:!0,aggregate:"last"}}getStyle(t){return this.getEntity(t).style}getColors(){const t=this.items;return Object.keys(t).map(function(e){if(t[e].style&&void 0!==t[e].style.color||t[e].style&&void 0!==t[e].style.backgroundColor)return t[e].style.color||t[e].style.backgroundColor}).filter(t=>void 0!==t)}getData(t=null){return t?this.items[t].state:this.getAttribute("state")}getChartLabelAndData(){let t=[],e=[],a=[];return this.getEntitieslist().forEach(i=>{i.ignoreZero&&0===i.state||(t.push(i.name),e.push(i.state),i.style&&a.push(i.style.color||i.style.backgroundColor))}),{labels:t,colors:a,data:e}}getEntityIds(){return Object.keys(this.items)}checkDataSouresItems(){return Object.keys(this.items).filter(t=>null!=this.items[t].datasource)}getEntityIdsAsString(){const t=Object.keys(this.items).filter(t=>null==this.items[t].datasource&&0==this.items[t].stateOnly).map(t=>this.items[t].id);return[...new Set(t)].join(",")}getEntities(){return Object.entries(this.items)}getEntitieslist(){const t=this.items;return Object.keys(t).map(function(e){return t[e]})}getItemLabels(t){return this.getEntity(t).labels}getItemData(t){return this.getEntity(t).seriesdata.data}getDataset(t){if(this.items[t].seriesdata&&this.items[t].seriesdata.data){const e=this.items[t].seriesdata.data;let a=[],i=[];return e.forEach(t=>{a.push(t.localedate),i.push(t.y)}),{labels:a,data:i}}return{labels:[],data:[]}}getStatisticData(){let t=[];return this.getEntitieslist().forEach(e=>{let a={};if(e.seriesdata&&e.seriesdata.data){const t=e.seriesdata.data.map(t=>t.y);t.length&&(a.max=arrStatistics.max(t),a.min=arrStatistics.min(t),a.sum=arrStatistics.sum(t),a.mean=arrStatistics.mean(t),a.last=t[t.length-1],a.first=t[0])}a.name=e.name,a.entity=e.entity,a.color=e.style.backgroundColor||e.style.color,e.style.gradient&&e.style.gradient.colors&&(a.color=a.color||e.style.gradient.colors[0]),a.current=e.state,a.unit=e.unit||"",a.timestamp=e.last_changed,t.push(a)}),t}getSeriesData(){let t=[];const e=this.getEntityIds();for(const a of e){const e=this.items[a];e.seriesdata&&t.push(e.seriesdata)}return t}}function convertColor(t,e=1){return window.Chart3&&window.Chart3.helpers&&window.Chart3.helpers.color&&window.Chart3.helpers.color(t).alpha(e).rgbString()||t}function logInfo(t,...e){t&&console.info(`%cLOGINFO ${(new Date).toISOString()}:`,"color:white;background:#0275d8;padding:4px",...e)}function getAttributeValue(t,e){try{return e.split(".").reduce(function(t,e){return t[e]},t)}catch(t){return null}}String.prototype.isChartType=function(t){return this.toString().toLowerCase()===t.toLowerCase()};const cssAttr=function(t){return"number"==typeof t?t+"px":t},_parseNumber=t=>t===parseInt(t)?Number(parseInt(t)):Number(parseFloat(t).toFixed(3)),roundToBase=(t=0,e=3)=>Math.pow(e,Math.floor(Math.log(t)/Math.log(e))),_formatNumber=(t,e)=>new Intl.NumberFormat(t).format(_parseNumber(e)),_safeParseFloat=function(t){return t=parseFloat(t),isFinite(t)?+t.toFixed(3):0};function isNumeric(t){return!isNaN(parseFloat(t))&&isFinite(t)}function validItem(t,e=!1){return e?0!=t&&isNumeric(t):isNumeric(t)}function msToTime(t){return t>1e3?Number(parseFloat(t/1e3).toFixed(2))+" s":Number(parseFloat(t).toFixed(4))+" ms"}function strToDate(t){if(!t)return null;const e=new Date(t.replace(/-|\ |\./gi,"/"));return isNaN(e)?(console.error("Not a valid date string",t),null):e}function localDatetime(t,e="at-DE"){if(!t)return"";e||(e=navigator.language||navigator.userLanguage||"en-GB");const a=new Date(t);return isNaN(a)?t:new Intl.DateTimeFormat(e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}).format(a)}function checkDate(t){return t=t||new Date,isNaN(t)||"object"==typeof t?"string"==typeof t&&(t=new Date(t)):t=new Date(1e3*t),t}function getLocaleText(t="DE"){return{days_narrow:[...Array(7).keys()].map(e=>new Intl.DateTimeFormat(t,{weekday:"narrow"}).format(new Date(Date.UTC(2021,5,e)))),days_short:[...Array(7).keys()].map(e=>new Intl.DateTimeFormat(t,{weekday:"short"}).format(new Date(Date.UTC(2021,5,e)))),days_long:[...Array(7).keys()].map(e=>new Intl.DateTimeFormat(t,{weekday:"long"}).format(new Date(Date.UTC(2021,5,e)))),month_narrow:[...Array(12).keys()].map(e=>new Intl.DateTimeFormat(t,{month:"narrow"}).format(new Date(Date.UTC(2021,e,1)))),month_short:[...Array(12).keys()].map(e=>new Intl.DateTimeFormat(t,{month:"short"}).format(new Date(Date.UTC(2021,e,1)))),month_long:[...Array(12).keys()].map(e=>new Intl.DateTimeFormat(t,{month:"long"}).format(new Date(Date.UTC(2021,e,1))))}}Date.prototype.getWeek=function(t=0){var e=new Date(this.getFullYear(),0,1);return t=t||0,Math.floor(((this-e)/864e5+e.getDay()-t)/7)};var formatdate=function(){const t=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZWQw]|"[^"]*"|'[^']*'/g,e=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,a=/[^-+\dA-Z]/g,i=function(t,e){for(t=String(t),e=e||2;t.length99?Math.round(f/10):f),t:u<12?"a":"p",tt:u<12?"am":"pm",T:u<12?"A":"P",TT:u<12?"AM":"PM",Z:n?"UTC":(String(s).match(e)||[""]).pop().replace(a,""),o:(D>0?"-":"+")+i(100*Math.floor(Math.abs(D)/60)+Math.abs(D)%60,4)};return r.replace(t,function(t){return t in _?_[t]:t.slice(1,t.length-1)})}}();formatdate.masks={default:"ddd, dd mmm yyyy HH:MM:ss",shortDate:"m.d.yy",mediumDate:"d mmm yyyy",longDate:"d mmmm yyyy",fullDate:"dddd, d mmmm yyyy",shortTime:"H:MM",mediumTime:"HH:MM:ss",longTime:"HH:MM:ss.l",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",week:"W",quater:"Q",datetime:"ddd, d mmmm yyyy HH:MM:ss",millisecond:"HH:MM:ss l",second:"HH:MM:ss",minute:"HH:MM:ss",hour:"ddd, HH:MM",day:"ddd, d.mmm.yy",month:"mmm yyyy",year:"yyyy"};const arrStatistics={max:function(t){return _safeParseFloat(Math.max.apply(null,t))},min:function(t){return _safeParseFloat(Math.min.apply(null,t))},range:function(t){return _safeParseFloat(arrStatistics.max(t)-arrStatistics.min(t))},midrange:function(t){return _safeParseFloat(arrStatistics.range(t)/2)},mean:function(t){return _safeParseFloat(arrStatistics.sum(t)/t.length)},sum:function(t){for(var e=0,a=0,i=t.length;ar?n=1:s"string"!=typeof t?"":t.charAt(0).toUpperCase()+t.slice(1);function filter(t,e){let a=[];return e.forEach(e=>{const i=[];i.push(t=>(function(t,e){let a,i;"object"==typeof e?(a=e.key.split("."),i=e.key):(a=e.split("."),i=e);const s=new RegExp(`^${i.replace(/\*/g,".*")}$`,"i");return 0===t.search(s)})(t,e.entity_filter)),i&&i.length&&Object.keys(t).sort().forEach(s=>{if(Object.keys(t[s]).sort(),i.every(t=>t(`${s}`))){let i;if(e.attribute){if(t[s].attributes[e.attribute]){let a=t[s].attributes.friendly_name?t[s].attributes.friendly_name:s;a+=e.name?" "+e.name:" "+capitalize(e.attribute),(i={entity:s,name:a,unit:e.unit||"",state:t[s].attributes[e.attribute.toLowerCase()],attributes:t[s].attributes,last_changed:t[s].last_changed,field:e.attribute.toLowerCase()}).attributes.friendly_name=i.name}}else i={entity:s,name:t[s].attributes.friendly_name?t[s].attributes.friendly_name:s,state:t[s].state,attributes:t[s].attributes,last_changed:t[s].last_changed};if(i)if(e.options&&(i.options=e.options),i.state&&(e.state_min_value||e.state_max_value)){const t=e.state_min_value||Number.MIN_VALUE,s=e.state_max||Number.MAX_VALUE;i.state=parseFloat(i.state),(i.state-t)*(i.state-s)<=0&&a.push(i)}else a.push(i)}})}),a}class DataProvider{constructor(t){this.dataInfo=t.datainfo,this.datascales=t.datascales,this.datamode=TRANSFORM_MODE.seriesdata,this.DEBUGMODE=t.debugmode,this.DEBUGDATA=t.debugdata,this.locale="DE"|window.Chart3.defaults.locale,this.ready=this._checkParam(),this.version="1.0.1",this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.DATAPROVIDER={start:performance.now()})}_checkParam(){return!!(this.datascales&&this.dataInfo.entity_items&&Object.keys(this.dataInfo.entity_items))&&(this.datascales.range=this.datascales.range||24,this.datascales.aggregate=this.datascales.aggregate||"last",!0)}_setEntityServiceDataInformation(t){t&&(t.datascales.data_count=0,t.datascales.servicemode=TRANSFORM_MODE.seriesdata)}_createTimeSeriesData(t,e){return t.seriesdata=t.seriesdata||[],t.seriesdata.data=t.seriesdata.data||[],t.seriesdata.data=Object.entries(e).map(function(e){const a=e[1].data;if(a&&a.length){let i={x:new Date(e[0]).getTime(),localedate:e[1].localedate,y:arrStatistics[t.aggregate||t.datascales.aggregate](a)};return t.datascales.useStatistics&&(i.statistics={current:t.state,first:a[0],last:a[a.length-1],max:arrStatistics.max(a),min:arrStatistics.min(a),sum:arrStatistics.sum(a),avg:arrStatistics.mean(a)}),i}}),t.datascales.data_count=t.seriesdata.data.length,t.datascales.data_count}getSimpleData(t){return t&&t.length&&t.forEach(t=>{const e=t[0].entity_id,a=this.dataInfo.entity_items[e];if(this._setEntityServiceDataInformation(a),e&&a){const e=a.factor||1,i=t.map(t=>a.field?(getAttributeValue(t,a.field)||0)*e:t.state*e);if(a.datascales.useStatistics){({}).statistics={current:a.state,first:i[0],last:i[i.length-1],max:arrStatistics.max(i),min:arrStatistics.min(i),sum:arrStatistics.sum(i),avg:arrStatistics.mean(i)}}a.datascales.data_count=i.length,a.state=arrStatistics[a.datascales.aggregate](i)}else console.error(`Sensordata ${a} not found !`)}),this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.DATAPROVIDER.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.DATAPROVIDER.start)),!0}getSeriesdata(t){if(this.datamode===TRANSFORM_MODE.statebased)return this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.DATAPROVIDER.mode="simpledata"),this.getSimpleData(t);function e(t,e="label",a="day"){const i={millisecond:"yyyy/m/d H:M:ss.l",datetime:"yyyy/md/ H:M:s",second:"yyyy/m/d H:M:s",minute:"yyyy/m/d H:M:00",hour:"yyyy/m/d H:00:00",day:"yyyy/m/d",month:"yyyy/m/1",year:"yyyy/12/31"};return formatdate(t,"group"==e?i[a]||i.day:a)}return this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.DATAPROVIDER.mode="seriesdata"),t&&t.length?(t.forEach(t=>{const a=t[0].entity_id,i=this.dataInfo.entity_items[a];if(i&&a){const a=i.factor||1;this._setEntityServiceDataInformation(i),i.hasOwnProperty("ignoreZero")||(i.ignoreZero=!1),i.datascales.states_count=t.length;let s=[];t.forEach(function(t){const r=e(t.last_changed,"group",i.datascales.unit);let n=i.field?+getAttributeValue(t,i.field):+t.state;validItem(n,i.ignoreZero)&&(n*=a,s[r]=s[r]||[],s[r].data=s[r].data||[],s[r].localedate=e(t.last_changed,"label",i.datascales.format||i.datascales.unit),s[r].data.push(_safeParseFloat(n)))}),i.datascales.data_count=this._createTimeSeriesData(i,s)}}),this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.DATAPROVIDER.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.DATAPROVIDER.start)),!0):void 0}}const DEFAULT_COLORS=["rgba(237,212,0,0.85)","rgba(115,210,22,0.85)","rgba(245,121,0,0.85)","rgba(52,101,164,0.85)","rgba(89,161,79,0.85)","rgba(182,153,45,0.85)","rgba(73,152,148,0.85)","rgba(225,87,89,0.85)","rgba(121,112,110,0.85)","rgba(211,114,149,0.85)","rgba(176,122,161,0.85)","rgba(157,118,96,0.85)","rgba(52,152,219,0.85)","rgba(46,204,113,0.85)","rgba(241,196,15,0.85)","rgba(155,89,182,0.85)","rgba(26,188,156,0.85)","rgba(39,174,96,0.85)","rgba(41,128,185,0.85)","rgba(142,68,173,0.85)","rgba(44,62,80,0.85)","rgba(230,126,34,0.85)","rgba(231,76,60,0.85)","rgba(236,240,241,0.85)","rgba(149,165,166,0.85)","rgba(243,156,18,0.85)","rgba(211,84,0,0.85)","rgba(192,57,43,0.85)","rgba(229,28,35,0.85)","rgba(205,220,57,0.85)","rgba(52,152,219,0.85)","rgba(231,76,60,0.85)","rgba(155,89,182,0.85)","rgba(241,196,15,0.85)","rgba(46,204,113,0.85)","rgba(26,188,156,0.85)","rgba(52,73,94,0.85)","rgba(230,126,34,0.85)","rgba(127,140,141,0.85)","rgba(39,174,96,0.85)","rgba(41,128,185,0.85)","rgba(142,68,173,0.85)"],COLOR_RADARCHART="rgba(41, 182, 246, 0.45)",COLOR_BUBBLECHAT="rgba(255, 152, 0, 0.685)",randomColor="#"+Math.floor(16777215*Math.random()).toString(16),randomColor2=DEFAULT_COLORS[Math.floor(Math.random()*DEFAULT_COLORS.length)];class chartData{constructor(t){this.card_config=t.card_config,this.entity_options=t.entityOptions,this.entity_items=t.entity_items,this.DEBUGMODE=t.debugmode,this.data_pointStyles=CT_DATAPOINTSTYLE,this.indicators={up:"▲",down:"▼",equal:"≃"},this.graphData={},this.version="1.0.1"}getDefaultGraphData(){return{data:{datasets:[]},config:{mode:"init",secondaryAxis:!1,series:0,gradient:!1,options:{},segmentbar:!1,timescale:!1,trendline:!1,thresholds:!1}}}createScatterChartData(){if(!this.entity_items.isValid())return null;let t=null,e=this.entity_items.getSize(),a=this.entity_items.getEntitieslist();if(e%2==0){(t=this.getDefaultGraphData()).config.mode="simple";for(let i=0;iNumber(t));const e=Math.max(...t.data),a=(Math.min(...t.data),Chart.helpers);return{data:t.data.map(t=>e-t),backgroundColors:t.backgroundColor.map(t=>a.color(t).alpha(.25).rgbString())}}return null}createChartData(){if(!this.entity_items.isValid())return null;const t=this.entity_items.getChartLabelAndData();if(0===t.length)return console.error("Create Chart Data, no Data present !"),null;let e={mode:"current",unit:""},a=this.getDefaultGraphData();a.config.mode="simple",this.entity_options&&(e={...e,...this.entity_options}),a.data.labels=t.labels,a.data.datasets[0]=e,a.data.datasets[0].label=this.card_config.title||"",this.entity_options&&this.entity_options.unit?a.data.datasets[0].unit=this.entity_options.unit||"":a.data.datasets[0].units=this.entity_items.getEntitieslist().map(t=>t.unit),this.card_config.chart.isChartType("horizontalbar")&&(a.data.datasets[0].indexAxis="y");let i=t.colors;if(this.entity_options&&null!=this.entity_options.gradient&&(a.config.gradient=!0),i.length===a.data.labels.length?(a.data.datasets[0].backgroundColor=i,a.data.datasets[0].showLine=!1):this.card_config.chart.isChartType("radar")?(a.data.datasets[0].backgroundColor=COLOR_RADARCHART,a.data.datasets[0].borderColor=COLOR_RADARCHART,a.data.datasets[0].borderWidth=1,a.data.datasets[0].pointBorderColor=COLOR_RADARCHART,a.data.datasets[0].pointBackgroundColor=COLOR_RADARCHART,a.data.datasets[0].tooltip=!0,a.config.gradient=!1):(i=DEFAULT_COLORS.slice(1,t.data.length+1),a.data.datasets[0].backgroundColor=i,a.data.datasets[0].borderWidth=0,a.data.datasets[0].showLine=!1),a.data.datasets[0].data=t.data,a.config.segmentbar=!1,this.card_config.chart.isChartType("bar")&&this.card_config.chartOptions&&this.card_config.chartOptions.segmented){const t=this.createSimpleBarSegmentedData(a.data.datasets[0]);t&&(a.data.datasets[1]={},a.data.datasets[1].data=t.data,a.data.datasets[1].tooltip=!1,a.data.datasets[1].backgroundColor=t.backgroundColors,a.data.datasets[1].borderWidth=0,a.data.datasets[1].showLine=!1,a.config.segmentbar=0!==t.data.length)}return a}getCurrentGraphData(){try{switch(this.card_config.chart){case"bubble":this.graphData=this.createBubbleChartData();break;case"scatter":this.graphData=this.createScatterChartData();break;default:this.graphData=this.createChartData()}return this.graphData}catch(t){console.error("Current entities GraphData",t.message,t)}return null}createHistoryBubbleData(){if(!this.entity_items.isValid())return null;let t=this.entity_items.getSeriesData();if(t&&t.length%3==0){let e=this.getDefaultGraphData();for(let a=0;a{const a=this.entity_items.items[e];let i={...this.entity_items.getOptions(e)},s={label:a.name||"unkonwn",unit:a.unit||"",pointRadius:0,current:a.state||0,last_changed:a.last_changed||new Date,mode:"history"};if(this.card_config.chart.isChartType("horizontalbar")&&(s.indexAxis="y"),this.card_config.chart.isChartType("radar")&&(s.pointRadius=12,s.hoverRadius=18,s.hitRadius=22),this.entity_options&&(s={...s,...this.entity_options},t.config.options={...t.config.options,...this.entity_options}),s={...s,...i},t.config.options.fill=i.fill||CT_BARCHARTS.includes(this.card_config.chart),i.fill&&i.gradient&&i.gradient.colors){const e="y"===s.indexAxis?"x":"y";s.gradient={backgroundColor:{axis:e,colors:i.gradient.colors}},s.labelcolor=i.gradient.colors[0],s.borderColor=i.gradient.colors[0]||DEFAULT_COLORS[t.config.series],t.config.gradient=!0}else void 0===i.backgroundColor?(s.backgroundColor=DEFAULT_COLORS[t.config.series],s.borderColor=DEFAULT_COLORS[t.config.series]):(s.backgroundColor=s.backgroundColor||s.backgroundColor||s.color,s.borderColor=s.borderColor||s.backgroundColor||s.color);if(i.trendlineLinear&&(t.config.trendline=!0),this.card_config.chartOptions.thresholds&&(t.config.thresholds=!0),t.config.secondaryAxis||(t.config.secondaryAxis=null!=i.yAxisID||null!=i.xAxisID),0==t.config.options.mode.timeaxis){const a=this.entity_items.getDataset(e);t.config.multiseries=!1,a&&a.data&&(t.data.labels=a.labels,(this.card_config.chart.isChartType("pie")||this.card_config.chart.isChartType("doughnut"))&&(t.data.labels=this.entity_items.getNames(),t.config.multiseries=!0),s.data=a.data,t.config.useTimeSeries=t.config.options.mode.timescale)}else a.seriesdata&&a.seriesdata.data&&(s.data=a.seriesdata.data,t.config.datascales=a.datascales,t.config.timescale=t.config.options.mode.timescale);t.data.datasets.push(s),t.config.series++}),t}getHistoryGraphData(){try{switch(this.card_config.chart){case"bubble":this.entity_options.mode=CT_DATASCALEMODES[this.card_config.chart],this.graphData=this.createHistoryBubbleData();break;case"scatter":this.entity_options.mode=CT_DATASCALEMODES[this.card_config.chart],this.graphData=this.createHistoryScatterData();break;case"bar":case"horizontalbar":this.entity_options&&this.entity_options.mode&&this.entity_options.mode.history?this.graphData=this.createHistoryChartData():this.graphData=this.createChartData();break;case"pie":case"doughnut":this.card_config&&this.card_config.chartOptions&&!0===this.card_config.chartOptions.multiseries&&this.entity_options&&this.entity_options.mode&&this.entity_options.mode.history?this.graphData=this.createHistoryChartData():(this.entity_options.mode=CT_DATASCALEMODES[this.card_config.chart],this.graphData=this.createChartData());break;default:this.graphData=this.createHistoryChartData()}if(this.graphData)return this.graphData;console.error("Error getHistoryGraphData, no data present!")}catch(t){console.error("Build History GraphData",t.message,t)}return null}}function xAxisFormat(t,e,a){if(this&&this.options.time&&this.options.time.unit){const e=this.options.time.format||this.options.time.unit;if(e&&Number.isInteger(t))return formatdate(+t,e)}return t}function yAxisFormat(t,e,a){return t}function formatToolTipTitle(t){const e=t[0].chart.config._config.type;return"polarArea"==e?t[0].chart.config._config.data.labels[t[0].dataIndex]||"":"scatter"==e?"":t[0].label&&t[0].raw&&t[0].raw.localedate?t[0].raw.localedate||t[0].label:t[0].label||""}function formatToolTipLabel(t){if(!1===t.dataset.tooltip)return null;let e=t.dataset.label||t.label||t.chart.data.labels[t.dataIndex]||"";const a="bubble"===t.chart.config._config.type?t.parsed._custom:t.formattedValue;return t.dataset.units&&t.dataset.units.length>t.dataIndex?e+=`: ${a} ${t.dataset.units[t.dataIndex]||""}`:e+=`: ${a} ${t.dataset.unit||""}`,e}class graphChart{constructor(t){this.ctx=t.ctx||null,this.canvasId=t.canvasId,this.entity_items=t.entity_items,this.chart_type=t.chart_type||"bar",this.chartconfig=t.chartconfig||{},this.loader=t.loader,this.DEBUGMODE=t.debugmode||0,this.DEBUGDATA=t.debugdata,this.chart=null,this.graphData={},this.graphDataSets=[],this.chart_ready=!1,this.lastUpdate=null,this.ChartControl=window.Chart3||Chart,this.version="1.0.1"}_setChartOptions(){const t=this.loader;let e={hoverOffset:8,layout:{},chartArea:{backgroundColor:"transparent"},elements:{},spanGaps:!0,plugins:{title:{},tooltip:{},legend:{display:CT_SHOWLEGEND.includes(this.chart_type)||!1}},animation:{onComplete:function(){t&&(t.style.display="none")}}};if(!0===this.graphData.config.gradient&&"simple"===this.graphData.config.mode&&(e.gradientcolor={color:!0,type:this.chart_type}),plugin_gradient&&this.graphData.config.gradient&&(e.plugins={plugin_gradient:plugin_gradient}),this.graphData.config.secondaryAxis&&this.graphData&&this.graphData.data&&this.graphData.data.datasets){let t={};this.graphData.data.datasets.forEach(e=>{e.yAxisID&&(t[e.yAxisID]={},t[e.yAxisID].id=e.yAxisID,t[e.yAxisID].type="linear",t[e.yAxisID].position=e.yAxisID,t[e.yAxisID].display=!0,"right"==e.yAxisID.toLowerCase()&&(t[e.yAxisID].grid={drawOnChartArea:!1})),e.xAxisID&&(t[e.xAxisID]={},t[e.xAxisID].id=e.xAxisID,t[e.xAxisID].type="linear",t[e.xAxisID].position=e.xAxisID,t[e.xAxisID].display=!0,"top"==e.xAxisID.toLowerCase()&&(t[e.xAxisID].grid={drawOnChartArea:!1}))}),t&&(e.scales=t)}if(this.chart_type.isChartType("bubble")){const t=this.entity_items.getEntitieslist();let a=t[0].name;a+=t[0].unit?" ("+t[0].unit+")":"";let i=t[1].name;i+=t[1].unit?" ("+t[1].unit+")":"",e.scales={x:{id:"x",title:{display:!0,text:a}},y:{id:"y",title:{display:!0,text:i}}},this.graphData.config.bubbleScale&&(e.elements={point:{radius:t=>{return t.dataset.data[t.dataIndex]._r*this.graphData.config.bubbleScale}}})}this.graphData.config.timescale&&this.graphData.config.datascales&&(e.scales=e.scales||{},e.scales.x=e.scales.x||{},e.scales.x.maxRotation=0,e.scales.x.autoSkip=!0,e.scales.x.major=!0,e.scales.x.type="time",e.scales.x.time={unit:this.graphData.config.datascales.unit,format:this.graphData.config.datascales.format,isoWeekday:this.graphData.config.datascales.isoWeekday},e.scales.x.ticks={callback:xAxisFormat}),!0===this.graphData.config.segmentbar?(e.scales={x:{id:"x",stacked:!0},y:{id:"y",stacked:!0}},e.plugins.legend={labels:{filter:(t,e)=>!1!==e.datasets[t.datasetIndex].tooltip},display:!1},e.plugins.tooltip.callbacks={label:t=>!1!==t.dataset.tooltip&&t.dataset.label?`${t.formattedValue} ${t.dataset.unit||""}`:null},e.interaction={intersect:!1,mode:"index"}):(e.plugins.tooltip={callbacks:{label:formatToolTipLabel,title:formatToolTipTitle}},e.interaction={intersect:!0,mode:"point"}),this.chart_type.isChartType("bubble")&&(e.plugins.legend={display:!1}),!0===this.graphData.config.multiseries&&(e.plugins.legend={labels:{generateLabels:function(t){const e=Chart.overrides.pie.plugins.legend.labels.generateLabels.call(this,t);let a=t.data.datasets.map(function(t){return t.backgroundColor});return a=a.flat(),e.forEach(e=>{e.datasetIndex=e.index,e.hidden=!t.isDatasetVisible(e.datasetIndex),e.fillStyle=a[e.index]}),e}},onClick:function(t,e,a){a.chart.getDatasetMeta(e.datasetIndex).hidden=a.chart.isDatasetVisible(e.datasetIndex),a.chart.update()}},e.plugins.tooltip={callbacks:{label:function(t){const e=t.datasetIndex;return`${t.chart.data.labels[e]}: ${t.formattedValue} ${t.dataset.unit||""}`}}});let a={type:this.chart_type,data:{datasets:[]},options:e};return this.chartconfig.options?a.options=deepMerge(e,this.chartconfig.options):a.options=e,a}sendJSON(t,e){let a=new XMLHttpRequest;a.open("POST",t,!0),a.withCredentials=!1,a.setRequestHeader("Content-Type","application/json"),a.onreadystatechange=function(){4===a.readyState&&200===a.status&&console.info("sendJson",this.responseText)},a.send(JSON.stringify(e))}renderGraph(t){try{if(this.graphData&&this.graphData.data&&this.graphData.config){if(this.graphDataSets&&this.graphDataSets.length&&JSON.stringify(this.graphDataSets)===JSON.stringify(this.graphData.data.datasets))return;let e=this._setChartOptions();e.data={datasets:this.graphData.data.datasets},this.graphData.data.labels&&(e.data.labels=this.graphData.data.labels),this.ctx&&e.data&&e.options&&(t&&this.chart&&this.chart.data?(this.chart.data=e.data,this.chart.update({duration:0,easing:"linear"}),this.DEBUGMODE&&(this.DEBUGDATA.CHARD={chartOptions:e,chartMode:"update data ready",chartjs:window.Chart3.version,chartGraphdata:this.graphData.config})):(!1===this.chart_ready&&this.ChartControl.register&&(this.graphData.config.gradient&&this.ChartControl.register(plugin_gradient),this.graphData.config.trendline&&window.plugin_trendline&&this.ChartControl.register(window.plugin_trendline),this.ChartControl&&this.chartconfig&&this.chartconfig.options&&this.chartconfig.options.chartArea&&""!==this.chartconfig.options.chartArea.backgroundColor&&this.ChartControl.register({id:"chardbackground",beforeDraw:function(t){if(t.config.options.chartArea&&t.config.options.chartArea.backgroundColor){const e=t.chartArea,a=t.ctx;a.save(),a.fillStyle=t.config.options.chartArea.backgroundColor,a.fillRect(e.left,e.top,e.right-e.left,e.bottom-e.top),a.restore()}}}),this.graphData.config.thresholds&&this.ChartControl.register({id:"thresholds",beforeDraw:function(t){const e=t.config.options.thresholds,a=function(t,e){if(e){const a=t.scales[e.yScaleID||e.xScaleID],i=e.xScaleID?"x":"y";return{x:t.chartArea.left,x2:t.chartArea.right,y:"y"===i?a.getPixelForValue(e.value):t.chartArea.top,y2:t.chartArea.bottom,w:"x"===i?t.chartArea.right-a.getPixelForValue(e.value):t.chartArea.width,h:"y"===i?t.chartArea.bottom-a.getPixelForValue(e.value):t.chartArea.height,width:t.chartArea.width,height:t.chartArea.height,axis:i}}return null}(t,e),i=t.ctx;if(e&&e&&a){i.save();const t="y"===a.axis?i.createLinearGradient(0,0,0,a.h):i.createLinearGradient(0,0,a.w,0),s=e.backgroundColor||"rgb(249, 70, 12)";t.addColorStop(0,window.Chart3.helpers.color(s).alpha(.85).rgbString()),t.addColorStop(1,window.Chart3.helpers.color(s).alpha(.15).rgbString()),i.fillStyle=t,i.fillRect(a.x,a.y,a.width,a.h),i.beginPath(),i.lineWidth=1.25,i.strokeStyle=s,"y"===a.axis?(i.moveTo(a.x-5,a.y),i.lineTo(a.x2,a.y)):(i.moveTo(a.x,a.y-5),i.lineTo(a.x,a.y2)),i.stroke(),i.restore()}}})),this.chart&&(this.chart.destroy(),this.chart=null),this.DEBUGMODE&&(this.DEBUGDATA.CHARD={},this.DEBUGDATA.CHARD.cart3Options=e),this.chart=new window.Chart3(this.ctx,e),this.graphDataSets=this.graphData.data.datasets,this.DEBUGMODE&&(this.DEBUGDATA.CHARD={chartOptions:e,chartMode:"new data ready",chartjs:window.Chart3.version,chartmodul:"v "+this.version,chartGraphdata:this.graphData.config}),this.chart&&(this.chart_ready=!0)))}else console.error("Fatal Error, missing graphdata",graphOptions)}catch(t){console.error("Error Render Graph Error on ",this.chart_type,": ",t,t.message)}}} \ No newline at end of file +"use strict";import"/hacsfiles/chart-card/chart.js?module";const appinfo={name:"✓ custom:chart-card ",app:"chart-card",version:"v2.1.6/v3.6.1",chartjs:Chart.version||"v3.6.1",assets:"/hacsfiles/chart-card/assets/",github:"https://github.com/zibous/lovelace-graph-chart-card"};console.info(`%c ${appinfo.name} %c ▪︎▪︎▪︎▪︎ ${appinfo.version} ▪︎▪︎▪︎▪︎`,"color:#FFFFFF; background:#3498db;display:inline-block;font-size:12px;font-weight:300;padding: 6px 0 6px 0","color:#2c3e50; background:#ecf0f1;display:inline-block;font-size:12px;font-weight:300;padding: 6px 0 6px 0");const CT_DATAPOINTSTYLE=["circle","triangle","rectRounded","rect","rectRot","cross","star","line","dash"],CT_CHARTGRIDLINES=["bar","line","bubble","scatter"],CT_NOSHOWSTATES=["bubble","scatter"],CT_BARCHARTS=["bar","horizontalbar"],CT_SHOWLEGEND=["pie","doughnut","polararea","line"],CT_AVIABLETYPES=["line","radar","bar","horizontalbar","pie","doughnut","polararea","bubble","scatter"],CT_DATASCALEMODES={disabled:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1},category:{history:!0,timescale:!0,timeaxis:!1,multiseries:!1},time:{history:!0,timescale:!0,timeaxis:!0,multiseries:!1},bar:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1},horizontalbar:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1},line:{history:!0,timescale:!0,timeaxis:!0,multiseries:!1},pie:{history:!1,timescale:!1,timeaxis:!1,multiseries:!0},doughnut:{history:!1,timescale:!1,timeaxis:!1,multiseries:!0},polararea:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1},scatter:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1},radar:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1},bubble:{history:!1,timescale:!1,timeaxis:!1,multiseries:!1}},LOADERFILES=["audio","ball-triangle","bars","circles","grid","hearts","oval","pfuff","rings","spinning-circles","tail-spin","three-dots"],DSC_UNITS=["day","second","minute","hour","month","year"],DSC_RANGES=["last","max","min","range","midrange","mean","sum","first"],API_DATAMODE={history:1,statemode:2,database:3},SERIESDEFAULT_VALUE=0,TRANSFORM_MODE={statebased:1,datalabel:2,seriesdata:3},DATEFILTERS={year:{digits:4,format:"yyyy"},month:{digits:7,format:"yyyy-mm"},day:{digits:10,format:"yyyy-mm-dd"},hour:{digits:13,format:"yyyy-mm-dd H"},minute:{digits:16,format:"yyyy-mm-dd H:M"},second:{digits:19,format:"yyyy-mm-dd H:M:s"},millisecond:{digits:23,format:"yyyy-mm-dd H:M:s.l"}};function setChartDefaults(t){if(window.Chart3&&window.Chart3.defaults){if(window.Chart3.defaults.theme&&t.theme==window.Chart3.defaults.theme)return;window.Chart3.defaults.theme=t.theme,window.Chart3.defaults.responsive=!0,window.Chart3.defaults.maintainAspectRatio=!1,window.Chart3.defaults.hoverOffset=8,t.useAnimations||(window.Chart3.defaults.animation=0),window.Chart3.defaults.locale=t.locale,window.localeNames=getLocaleText(window.Chart3.defaults.locale),window.Chart3.defaults.font.family=t.font,window.Chart3.defaults.color=convertColor(t.fontColor),window.Chart3.defaults.layout.padding.top=t.padding.top||0,window.Chart3.defaults.layout.padding.bottom=t.padding.bottom||0,window.Chart3.defaults.layout.padding.left=t.padding.left||0,window.Chart3.defaults.layout.padding.right=t.padding.right||0,window.Chart3.defaults.plugins.legend.labels.color=convertColor(t.fontColor),window.Chart3.defaults.plugins.legend.position="top",window.Chart3.defaults.plugins.legend.labels.usePointStyle=!0,window.Chart3.defaults.plugins.legend.labels.boxWidth=8,window.Chart3.defaults.plugins.legend.show=!1,window.Chart3.defaults.plugins.tooltip.backgroundColor=convertColor(t.tooltipsBackground),window.Chart3.defaults.plugins.tooltip.titleColor=convertColor(t.tooltipsFontColor),window.Chart3.defaults.plugins.tooltip.bodyColor=convertColor(t.tooltipsFontColor),window.Chart3.defaults.plugins.tooltip.footerColor=convertColor(t.tooltipsFontColor),window.Chart3.defaults.plugins.tooltip.enabled=!0,window.Chart3.defaults.elements.arc.borderWidth=0,window.Chart3.defaults.elements.line.fill=!1,window.Chart3.defaults.elements.line.tension=.225,window.Chart3.defaults.elements.point.borderWidth=0,window.Chart3.defaults.elements.point.hoverRadius=8,window.Chart3.defaults.elements.point.hitRadius=8,window.Chart3.defaults.scale.grid.drawBorder=!0,window.Chart3.defaults.scale.grid.borderWidth=parseFloat((1.1*t.gridLineWidth).toFixed(3))||1,window.Chart3.defaults.scale.grid.color=convertColor(t.gridlineColor,.8),window.Chart3.defaults.scale.grid.lineWidth=t.gridLineWidth,window.Chart3.defaults.scale.grid.borderDash=t.borderDash,window.Chart3.defaults.scale.grid.lineWidth=(e=>0===e.index?0:t.gridLineWidth||1),window.Chart3.defaults.scale.grid.borderColor=convertColor(t.zeroLineColor),window.Chart3.defaults.scale.alignToPixels=!0,window.Chart3.defaults.scales.radialLinear.ticks.backdropColor="transparent",window.gradient&&window.Chart3.register(window.gradient)}}window.Chart3=Chart;const plugin_gradient=window["chartjs-gradient"],fireEvent=(t,e,a,i)=>{i=i||{},a=null==a?{}:a;const s=new Event(e,{bubbles:void 0===i.bubbles||i.bubbles,cancelable:Boolean(i.cancelable),composed:void 0===i.composed||i.composed});return s.detail=a,t.dispatchEvent(s),s},style=document.createElement("style");style.innerHTML="\n html {\n scrollbar-width: none; \n -ms-overflow-style: none;\n }\n\n html::-webkit-scrollbar {\n width: 0px;\n }\n .card-header{\n padding-bottom:0 !important;\n white-space:nowrap;\n }\n .card-header-icon{\n position:relative;\n top:-2px;\n padding:0 6px 0 4px;\n }\n .card-header-title{\n overflow:hidden;\n text-overflow:ellipsis;\n white-space:nowrap;\n display:inline-block;\n vertical-align:top;\n width:70%;\n }\n .card-content{\n overflow: auto;\n }\n .card-canvas{\n -moz-user-select: none; \n -webkit-user-select: none; \n -ms-user-select: none;\n width:100%;\n height:auto;\n }\n .card-loader{\n width: 60px;\n position:absolute;\n top:42%;\n left:38%;\n width:60px;\n z-index:500;\n margin: 0 auto\n }\n .card-state-view{\n position:absolute;\n top:12px;\n right:20px;\n background-color:transparent;\n max-width: 15%;\n z-index:100;\n }\n .card-state-view::-webkit-scrollbar,\n .state-view-data::-webkit-scrollbar {\n display: none;\n }\n .state-view-data{\n font-weight:400;\n margin:0;\n cursor:pointer;\n height:3.85em;\n overflow:auto;\n scrollbar-width: none; \n -ms-overflow-style: none;\n }\n .state-view-value{\n font-size:1.85em;\n line-height:1.2em;\n text-align:right;\n margin:0;\n color:#fff;\n border-bottom: 1px dotted\n }\n .state-view-value span{\n padding-left: 4px;\n font-size:0.4em;\n vertical-align:top\n } \n .state-view-name{\n border: none;\n font-size: 0.65em;\n text-align: center;\n margin: 0;\n line-height: 2em;\n width: 95%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n } \n .card-detail-view{\n margin-top: 1.925em;\n }\n .card-detail-view hr{\n border-bottom-width: 0px;\n opacity:0.5;\n } \n .card-detail-view h2{\n margin-left: 0.5em;\n font-size: 1.25em;\n }\n .card-detail-table{\n margin: 0 auto;\n font-size:0.925em;\n font-weight:300;\n width: 95%;\n border-collapse: collapse !important;\n table-layout: fixed;\n text-align:left;\n line-height: 1.8rem\n }\n table-row-background-color\n\n .card-detail-table tr:nth-child(even) {background: var(--table-row-background-color)}\n .card-detail-table tr:nth-child(odd) {background:var(--table-row-alternative-background-color)}\n\n .card-detail-table th{\n padding: 0 6px;\n font-weight:400;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .card-detail-table td{\n padding: 0 6px;\n overflow:hidden;\n text-overflow:ellipsis;\n white-space:nowrap;\n font-weight:300;\n }\n .card-timestamp{\n position:absolute;\n right:0.8em;\n bottom:0;\n font-weight:300;\n font-size:0.7em;\n text-align:right;\n z-index:800\n color: #000000;\n }\n @media (min-width: 320px) and (max-width: 480px){\n \n }\n";class ChartCard extends HTMLElement{constructor(){super(),this._hass=null,this._config=null,this.attachShadow({mode:"open"}),this.card_icon=null,this.card_title=null,this.card_height=240,this.theme="",this.themeSettings=null,this.graphChart=null,this.chart_type="bar",this.chart_locale="de-DE",this.chart_update=!1,this.ctx=null,this.chartconfig=null,this.graphData={},this.hassEntities=[],this.entity_items=new Entities(null,!1),this.entity_options=null,this.updateTimer=-1,this.update_interval=6e4,this.skipRender=!1,this.lastUpdate=null,this.ready=!1,this.updating=!1,this._initialized=!1,this.initial=!0,this.dataInfo={time_start:new Date,ISO_time_start:(new Date).toISOString(),time_end:new Date,ISO_time_end:(new Date).toISOString(),entity_items:null,entities:"",useAlias:!1,time:(new Date).getTime(),loading:!1,url:"",prev_url:"not_set",param:"",options:""},this.DEBUGMODE=0,this.DEBUGDATA={API:{}},this.APISTART=performance.now(),this.DEBUGDATA.API.elapsed_total=0,this.DEBUGDATA.PROFILER={}}_evaluateCssVariable(t){try{return getComputedStyle(document.documentElement).getPropertyValue(t).trim()}catch(e){console.error("ERROR evaluateCssVariable:",t,"ERROR",e.message,e)}return t}_setDefaultThemeSettings(){this.themeSettings={theme:{theme:"system",dark:!1},fontColor:"#1E1E1E",fontFamily:"Quicksand, Roboto,'Open Sans','Rubik','Helvetica Neue', 'Helvetica', 'Arial', sans-serif",gridlineColor:"1E1E1E",zeroLineColor:"#333333",tooltipsBackground:"#ecf0f1",tooltipsFontColor:"#647687",showGridLines:CT_CHARTGRIDLINES.includes(this.chart_type.toLowerCase())||!1,secondaryAxis:!1,gridLineWidth:1,borderDash:[1,1],padding:{top:20,right:24,bottom:12,left:24},useAnimations:!0,locale:this.chart_locale}}_getThemeSettings(){this._setDefaultThemeSettings();try{return this.themeSettings.fontColor=this.chart_themesettings&&this.chart_themesettings.fontcolor||this._evaluateCssVariable("--chartjs-text-fontColor")||this._evaluateCssVariable("--primary-text-color")||this.themeSettings.fontFamily,this.themeSettings.fontFamily=this._evaluateCssVariable("--chartjs-fontFamily")||this._evaluateCssVariable("--paper-font-common-base_-_font-family")||"Quicksand, Roboto,'Open Sans','Rubik','Helvetica Neue', 'Helvetica', 'Arial', sans-serif",this.themeSettings.gridlineColor=this.chart_themesettings&&this.chart_themesettings.gridlinecolor||this._evaluateCssVariable("--chartjs-gridline-color")||this._evaluateCssVariable("--light-primary-color")||this.themeSettings.gridlineColor,this.themeSettings.zeroLineColor=this.chart_themesettings&&this.chart_themesettings.zerolinecolor||this._evaluateCssVariable("--chartjs-zero-gridline-color")||this._evaluateCssVariable("--dark-primary-color")||this.themeSettings.zeroLineColor,this.themeSettings.tooltipsBackground=this.chart_themesettings&&this.chart_themesettings.tooltipsbackground||this._evaluateCssVariable("--chartjs-tooltip-background")||this.themeSettings.tooltipsBackground,this.themeSettings.tooltipsFontColor=this.chart_themesettings&&this.chart_themesettings.tooltipsfontcolor||this._evaluateCssVariable("--chartjs-text-fontcolor")||this.themeSettings.tooltipsFontColor,this.themeSettings.showGridLines=CT_CHARTGRIDLINES.includes(this.chart_type.toLowerCase())||!1,this.themeSettings.secondaryAxis=!1,this.themeSettings.themecolorused=this._evaluateCssVariable("--chartjs-theme")||!1,this.themeSettings.useAnimations=this._evaluateCssVariable("--chart-animantions")||this.themeSettings.useAnimations,void 0!==this.theme&&void 0!==this.theme.dark||(this.theme={theme:"system",dark:"dark"===this.themeSettings.themecolorused||!1},this.themeSettings.theme=this.theme),this.theme&&null!=this.theme.dark&&(this.themeSettings.theme=this.theme),this.themeSettings.gridLineWidth=this.themeSettings.theme.dark?.8:1,this.themeSettings.borderDash=[1,1],this.chartconfig.options&&this.chartconfig.options.scale&&this.chartconfig.options.scale.gridLines&&(this.themeSettings.showGridLines=!0),this.chartconfig.options&&this.chartconfig.options.legend&&(this.themeSettings.showLegend=!0),this.DEBUGMODE&&(this.DEBUGDATA.THEMESETTINGS=this.themeSettings),setChartDefaults(this.themeSettings),!0}catch(t){console.error("Fatal Error theme settings",t.message,t)}return!1}_setChartConfig(){if(this._getThemeSettings(),this.ctx){let t={ctx:this.ctx,canvasId:this.canvasId,entity_items:this.entity_items,chart_type:this.chart_type,chartconfig:this.chartconfig,loader:this.loader,debugmode:this.DEBUGMODE,debugdata:this.DEBUGDATA};this.graphChart=new graphChart(t)}else console.error("No chart.js container found !")}_creatHACard(){if(this.id)return;this.id="TC"+Math.floor(1e3*Math.random());const t=document.createElement("ha-card");t.setAttribute("class","graph-card"),t.id=this.id+"-card",t.setAttribute("data-graphtype",this.chart_type),this.chart_themesettings&&this.chart_themesettings.cardbackground&&(t.style.cssText+=`background: ${this.chart_themesettings.cardbackground} !important;`);const e=document.createElement("div");if(e.setAttribute("class","card-content"),e.id=this.id+"-view",this.chart_showdetails&&1==this.chart_showdetails.visible||(e.style.height=cssAttr(this.card_height)),this.card_title||this.card_icon){const e=document.createElement("div");if(e.setAttribute("class","card-header header flex"),e.id=this.id+"-header",this.card_icon){const t=document.createElement("ha-icon");t.setAttribute("class","card-header-icon"),t.setAttribute("icon",this.card_icon),e.appendChild(t)}if(this.card_title){const t=document.createElement("span");t.setAttribute("class","card-header-title"),t.innerHTML=this.card_title,e.appendChild(t)}t.append(e)}this.canvasId=this.id+"-chart";const a=document.createElement("canvas");a.setAttribute("class","card-canvas"),this.ctx=a.getContext("2d"),a.id=this.canvasId;a.height=this.card_height-10,a.style.height=cssAttr(this.card_height-10),a.style.maxHeight=cssAttr(this.card_height-10),a.style.display="block",this.loaderart&&(this.loader=document.createElement("img"),this.loader.setAttribute("class","card-loader"),this.loader.id=this.id+"-loader",this.loader.alt="loading...",this.loader.style.width="60",this.loader.src=appinfo.assets+this.loaderart+".svg"),this.chart_showstate&&(this.currentData=document.createElement("div"),this.currentData.setAttribute("class","card-state-view"),this.currentData.id=this.id+"state-view"),this.showdetails&&this.chart_showdetails?(this.detailData=document.createElement("div"),this.detailData.setAttribute("class","card-detail-view"),this.detailData.id=this.id+"detail-info",this.detailData.id&&(this.detailData.setAttribute("data-view",this.detailData.id),1==this.chart_showdetails.visible&&this.detailData.setAttribute("style","margin:0 !important;"))):e.style.maxHeight=cssAttr(this.card_height),e.appendChild(a),this.loader&&e.append(this.loader),this.showdetails&&this.detailData&&e.append(this.detailData),t.appendChild(e),this.chart_showstate&&this.currentData&&t.appendChild(this.currentData),this.card_timestamp&&(this.timestampLayer=document.createElement("div"),this.timestampLayer.setAttribute("class","card-timestamp"),this.timestampLayer.id=this.id+"detail-footertext",this._renderCardTimestamp(),t.appendChild(this.timestampLayer)),this.card=t,this.root.appendChild(t)}_checkLocale(t){try{Intl.getCanonicalLocales(t)}catch(t){return console.error(" RangeError: invalid language tag:",this.config),navigator.language||navigator.userLanguage}return t}getEntities(){let t=JSON.parse(JSON.stringify(this._config.entities));if(t&&0!==t.length)return t.forEach(t=>{if(t.entity){const e=t.entity.split(".");t.id=`${e[0]}.${e[1]}`}else t.id="OD-"+Math.floor(1e3*Math.random())}),t}_checkDatascales(){this.datascales=Object.assign({},this._config.datascales),this.datascales.chart=this.chart_type.toLowerCase(),this.datascales.cardtitle=this.card_title,this.datascales.range=this.datascales.range||0,this.datascales.unit&&(this.datascales.unit=this.datascales.unit.toLowerCase()),void 0===this.datascales.mode?this.datascales.mode=CT_DATASCALEMODES[this.datascales.chart]:this.datascales.mode=CT_DATASCALEMODES[this.datascales.mode]||CT_DATASCALEMODES[this.datascales.chart],0===this.datascales.range||this.datascales.mode.history||(this.datascales.mode.history=!0),this.chart_type.isChartType("line")&&0===this.datascales.range&&(this.datascales.range=48,this.datascales.unit=DSC_UNITS[0],this.datascales.format=this.datascales.format||this.datascales.unit),this.datascales.range&&(this.datascales.unit=this.datascales.unit||DSC_UNITS[0],this.datascales.format=this.datascales.format||this.datascales.unit,this.datascales.ignoreZero=this.datascales.ignoreZero||!0,this.datascales.aggregate=this.datascales.aggregate||DSC_RANGES[0]),this.datascales.unit&&0==DSC_UNITS.includes(this.datascales.unit)&&(this.datascales.range=24,this.datascales.unit=DSC_UNITS[0],this.datascales.format=this.datascales.format||this.datascales.unit),this.datascales.aggregate&&0==DSC_RANGES.includes(this.datascales.aggregate.toLowerCase())&&(this.datascales.aggregate=DSC_RANGES[0]),this.datascales.factor=this.datascales.factor||1,this.datascales.isoWeekday=this.datascales.isoWeekday||1}setConfig(t){if(!t.entities)throw new Error("You need to define an entity");try{if(this._config)return void console.error("CHART-CART Config",t.title," allready loaded...");for(this.root=this.shadowRoot;this.root.hasChildNodes();)this.root.removeChild(root.lastChild);const e=style.cloneNode(!0);if(this.root.appendChild(e),this._config=Object.assign({},t),this._config.chart=this._config.chart||"bar",this.DEBUGMODE=this._config.debug||this.DEBUGMODE,this.card_title=this._config.title||"",this.card_icon=this._config.icon||null,this.card_height=this._config.height||240,this.card_timestamp=this._config.cardtimestamp||!0,this.chart_type=this._config.chart||"bar",this._config.id=this.chart_type+Math.floor(1e3*Math.random()),this.chart_showstate=this._config.showstate||!1,this.showdetails=!1,this.chart_showdetails=Object.assign({},this._config.showdetails),this._config.showdetails&&(this.showdetails=""!==[this.chart_showdetails.title_mean||"",this.chart_showdetails.title_min||"",this.chart_showdetails.title_max||""].join("")),this.chart_themesettings=this._config.theme||null,this.loaderart=this._config.loader||"three-dots",LOADERFILES.includes(this.loaderart)||(this.loaderart="spinning-circles"),!this.chart_type)throw new Error("You need to define type of chart");if(!CT_AVIABLETYPES.includes(this.chart_type.toLowerCase()))throw new Error("Invalid config for 'chart:'"+this.chart_type+". Available options are: "+availableTypes.join(", "));"horizontalbar"===this.chart_type.toLowerCase()&&(this.chart_type="bar"),this.chartconfig={},this.chartconfig.type=this.chart_type,(this._config.options||this._config.chartOptions)&&(this.chartconfig.options=this._config.options||this._config.chartOptions),this.chart_locale=navigator.language||navigator.userLanguage||"DE",this._checkLocale(),this._checkDatascales(),this.update_interval=1e3*this._config.update_interval||this.update_interval,this.chart_showstate&&(0===this.datascales.range||CT_NOSHOWSTATES.includes(this.chart_type.toLocaleLowerCase()))&&(this.chart_showstate=!1,this.showdetails=!1),!1===this._initialized&&this._creatHACard()}catch(e){console.error(e.message,t,e)}}setEntity_itemsData(t){if(!1===this.ready&&this.entity_items.getSize()!==this.hassEntities.length){this.entity_options=null,this.entity_items=new Entities(null);for(const e of t){if(e.options)this.entity_options=Object.assign({},e.options);else{const t=this.hassEntities.find(t=>t.entity_id===e.id);if(t){let a=this.entity_items.getEntity(e.entity)||Object.assign({},e);t.attributes&&(void 0===a.name&&(a.name=t.attributes.friendly_name||a.name),a.unit=a.unit||t.attributes.unit_of_measurement||""),void 0!==a.name&&(a.last_changed=t.last_changed,a.state=t.state||0,a.value=t.state||0,a.dataid&&a.datasource&&a.datasource.influxdb&&(this.datascales.range=this.datascales.range||24,this.datascales.unit=this.datascales.unit||DSC_UNITS[0],a.datascales=this.datascales||{}),a.datascales=this.datascales,a.datascales.ignoreZero=this.datascales.ignoreZero||a.ignoreZero||!1,a.datascales.aggregate=a.aggregate||this.datascales.aggregate||"last",a.datascales.factor=a.factor||this.datascales.factor,a.datascales.useStatistics=this.chart_showdetails||!1,a.state=a.state*a.datascales.factor,a.factor=a.datascales.factor,a.ignoreZero=a.ignoreZero||this.datascales.ignoreZero,a.stateOnly=a.stateOnly||!1,a.useAttribute=!1,a.entity!=a.id&&(a.field=a.entity.slice(a.id.length+1),a.state=(getAttributeValue(t,a.field)||0)*a.factor,a.useAttribute=!0),a.attribute&&(a.field=`attributes.${a.attribute}`,a.state=(getAttributeValue(t,a.field)||0)*a.factor,a.useAttribute=!0),a.target_value&&isNumeric(a.target_value)?(a.current=a.state,a.uom=a.unit,a.state=this.entity_items.calcItemValue({value:a.state,factor:a.factor||1,target_value:a.target_value})):a.state=_safeParseFloat(a.state),a.chart=this.chart_type,a.dataready=!1,this.entity_items.addEntity(a))}}null===this.entity_options?this.entity_options={settings:!1,mode:this.datascales.mode||CT_DATASCALEMODES.disabled}:this.entity_options.mode=this.entity_options.mode||this.datascales.mode||CT_DATASCALEMODES.disabled}return this.entity_items.isValid()||!1}return!1}set hass(t){if(void 0===t)return;this.timeOut&&clearTimeout(this.timeOut),this._hass=t;const e=this._hass.language||navigator.language||navigator.userLanguage||"en-GB";this.chart_locale!==e&&(this.chart_locale=e,window.localeNames=getLocaleText(e),window.Chart3.defaults.locale=e,this._getThemeSettings(),this.graphChart&&(this.themeSettings.theme=this.theme,this.updateGraph(!0))),this.selectedTheme=t.selectedTheme||{theme:"system",dark:!1},this.theme&&this.theme.dark!==this.selectedTheme.dark&&(this.theme=this.selectedTheme,this._getThemeSettings(),this.graphChart&&(this.themeSettings.theme=this.theme,this.updateGraph(!0))),this.theme=this.selectedTheme;const a=this.getEntities();a?(this.hassEntities=a.map(e=>t.states[e.id]).filter(t=>void 0!==t),this.hassEntities&&0!==this.hassEntities.length?this.skipRender&&!1===this.updating&&0===this.update_interval?this.checkUpdate():(this.ready=this.setEntity_itemsData(a),this.timeOut=setTimeout(()=>{this.updateGraph(!1)},this.initial?200:this.update_interval),this.skipRender=!0):console.error(this.chart_type,"No valid entities found, check your settings...")):console.error(this.chart_type,"No valid entities found, check your settings...")}updateGraph(t){t="undefined"===t?!this.initial:t,!0!==this.updating&&(this.graphChart||(this._getThemeSettings(),this.themeSettings.theme=this.theme,this._setChartConfig(),t=!1),this.graphChart&&(this.updating=!0,this._getThemeSettings(),this.themeSettings.theme=this.theme,this.entity_items.getSize&&(this.graphChart.entityData=this.entity_items.getData(),this.chart_update=t,this._getHistory(),this._renderCardTimestamp()),this.updating=!1,this.initial=!1))}checkUpdate(){if(!0===this.updating)return!1;this.hasChanged=!1;const t=this.entity_items.getEntitieslist();return this.hassEntities&&this.hassEntities.length&&this._hass&&(this.hassEntities=t.map(t=>this._hass.states[t.entity]).filter(t=>void 0!==t),this.hasChanged=this.entity_items.hasChanged(this.hassEntities),this.hasChanged&&this.updateGraph(!0)),this.hasChanged}_getHistory(){if(1!=this.dataInfo.loading&&(!this.card||0!=this.card.getClientRects().length)&&(this.ready=this.entity_items.isValid(),this.ready))if(this.DEBUGMODE&&(this.APISTART=performance.now(),this.DEBUGDATA.PROFILER.GETHASSDATA={start:performance.now()},this.DEBUGDATA.PROFILER.GETBUCKETDATA={start:performance.now()},this.DEBUGDATA.PROFILER.GETSTATEDATA={start:performance.now()}),this.datascales.range>0)if(this.dataInfo.entities=this.entity_items.getEntityIdsAsString(),this.dataInfo.entity_items=this.entity_items.items,this.dataInfo.useAlias=this.entity_items.useAliasFields(),""!=this.dataInfo.entities){if(this.dataInfo.time=(new Date).getTime(),this.dataInfo.time_start=new Date,this.datascales.range<1?(this.dataInfo.time_start.setMinutes(this.dataInfo.time_start.getMinutes()-60*this.datascales.range),this.dataInfo.range=`${60*this.datascales.range} min`):(1==["day","month","year"].includes(this.datascales.unit)?this.dataInfo.time_start.setHours(-this.datascales.range,0,0,0):this.dataInfo.time_start.setHours(this.dataInfo.time_start.getHours()-this.datascales.range),this.dataInfo.range=`unit: ${this.datascales.unit}, range: ${this.datascales.range} h`),this.dataInfo.time_end=new Date,this.dataInfo.ISO_time_start=this.dataInfo.time_start.toISOString(),this.dataInfo.ISO_time_end=this.dataInfo.time_end.toISOString(),this.dataInfo.options="&skip_initial_state",this.dataInfo.useAlias||(this.dataInfo.options+="&minimal_response"),this.dataInfo.param==`${this.dataInfo.time_end}:${this.dataInfo.entities}`)return void console.warn("Data allready loaded...");if(this.dataInfo.param=`${this.dataInfo.time_end}:${this.dataInfo.entities}`,this.dataInfo.url=`history/period/${this.dataInfo.ISO_time_start}?end_time=${this.dataInfo.ISO_time_end}&filter_entity_id=${this.dataInfo.entities}${this.dataInfo.options}`,this.dataInfo.url!==this.dataInfo.prev_url){this.dataInfo.loading=!0;this._hass.callApi("GET",this.dataInfo.url).then(t=>this._buildGraphData(t,API_DATAMODE.history),()=>null);this.dataInfo.prev_url=this.dataInfo.url}}else{this.DEBUGMODE&&(this.DEBUGDATA.INFLUXDB,this.DEBUGDATA.PROFILER.INFLUXDB={start:performance.now()},this.DEBUGDATA.INFLUXDB={url:"",authorization:!1,count:0,status:"init"}),this.entity_items.getEntitieslist().forEach(t=>{this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.INFLUXDB.start=performance.now()),t.datasource&&this._buildGraphDataInfluxDB(t)})}else this._buildGraphData(null,API_DATAMODE.statemode)}renderStateData(t){let e=[];if(this.currentData&&this.chart_showstate&&t){let a="margin:0;line-height:1.2em";e.push('
');for(const i of t){let t=' style="'+a+";color:"+i.color+'"';e.push('
'),e.push(`

${_formatNumber(this.chart_locale,i.current||0)}${i.unit||""}

`),e.push('

'+i.name+"

"),e.push("
")}e.push("
"),this.currentData.innerHTML=e.join("")}if(this.chart_showdetails&&this.detailData&&t){const t=this.entity_items.getStatisticData();t&&((e=[]).push(`
`),this.chart_showdetails.title&&e.push(`

${this.chart_showdetails.title}

`),e.push('
'),e.push(""),e.push(``),this.chart_showdetails.title_mean&&""!=this.chart_showdetails.title_mean&&e.push(``),this.chart_showdetails.title_min&&""!=this.chart_showdetails.title_min&&e.push(``),this.chart_showdetails.title_max&&""!=this.chart_showdetails.title_max&&e.push(``),this.chart_showdetails.title_current&&""!=this.chart_showdetails.title_current&&e.push(``),this.chart_showdetails.title_timestamp&&""!=this.chart_showdetails.title_timestamp&&e.push(``),e.push(""),t.forEach(t=>{e.push(""),e.push('"),this.chart_showdetails.title_mean&&""!=this.chart_showdetails.title_mean&&e.push(""),this.chart_showdetails.title_min&&""!=this.chart_showdetails.title_min&&e.push(""),this.chart_showdetails.title_max&&""!=this.chart_showdetails.title_max&&e.push(""),this.chart_showdetails.title_current&&""!=this.chart_showdetails.title_current&&e.push(""),this.chart_showdetails.title_timestamp&&""!=this.chart_showdetails.title_timestamp&&e.push("")}),e.push("
${this.chart_showdetails.title_sensor||"Statitics"}${this.chart_showdetails.title_mean}${this.chart_showdetails.title_min}${this.chart_showdetails.title_max}${this.chart_showdetails.title_current||"current"}${this.chart_showdetails.title_timestamp||"Timestamp"}
'+t.name+""+_formatNumber(this.chart_locale,t.mean||0)+" "+t.unit+""+_formatNumber(this.chart_locale,t.min||0)+" "+t.unit+""+_formatNumber(this.chart_locale,t.max||0)+" "+t.unit+""+_formatNumber(this.chart_locale,t.current||0)+" "+t.unit+""+localDatetime(t.timestamp,this.chart_locale)+""),e.push("

"),e.length&&(this.detailData.innerHTML=e.join("")))}}_renderCardTimestamp(){this.card_timestamp&&this.timestampLayer&&(this.timestampLayer.innerHTML=localDatetime((new Date).toISOString()))}_renderDebugInfo(){this.DEBUGMODE&&(this.DEBUGDATA.CARD=this.card_title,this.DEBUGDATA.API.updateIntervall=msToTime(this.update_interval),this.DEBUGDATA.API.elapsed_total=msToTime(performance.now()-this.APISTART),this.DEBUGDATA.API.datainfo=this.dataInfo,this.DEBUGDATA.DATA_ENTITIES=this.entity_items.items,this.DEBUGDATA.LOVELACE_CONFIG=this._config,this.DEBUGDATA.LOCALEINFO=window.localeNames,this.DEBUGDATA.PROFILER&&(this.DEBUGDATA.PROFILER.GETHASSDATA&&delete this.DEBUGDATA.PROFILER.GETHASSDATA.start,this.DEBUGDATA.PROFILER.GETBUCKETDATA&&delete this.DEBUGDATA.PROFILER.GETBUCKETDATA.start,this.DEBUGDATA.PROFILER.GETSTATEDATA&&delete this.DEBUGDATA.PROFILER.GETSTATEDATA.start,this.DEBUGDATA.PROFILER.CHART&&this.DEBUGDATA.PROFILER.CHART.start&&delete this.DEBUGDATA.PROFILER.CHART.start,this.DEBUGDATA.PROFILER.DATAPROVIDER&&delete this.DEBUGDATA.PROFILER.DATAPROVIDER.start),console.info(`%cDEBUGDATA ${this.chart_type.toUpperCase()} ${appinfo.name} ${appinfo.version}:`,"color:white;background:#cc283a;padding:4px",this.DEBUGDATA))}_buildGraphDataInfluxDB(t){if(!t.datasource.influxdb||!t.datasource.query)return;const e={host:t.datasource.influxdb||null,query:t.datasource.query||null,token:t.datasource.token||""};e.url=encodeURI(e.host+"&q="+e.query),e.authorization=""!=e.token,this.DEBUGMODE&&(this.DEBUGDATA.INFLUXDB.url=e.url,this.DEBUGDATA.INFLUXDB.authorization=""!=e.token,this.DEBUGDATA.INFLUXDB.count=0),function(t){return new Promise((e,a)=>{const i=new XMLHttpRequest;i.open("GET",t.url),t.authorization&&i.setRequestHeader("Authorization","Basic "+t.token),i.withCredentials=!1,i.responseType="json",i.onreadystatechange=(()=>{i.readyState<4||(200!==i.status&&a(i.response),4===i.readyState&&e(i.response))}),i.send()})}(e).then(e=>{if(e&&e.results[0]){if(e.results[0].series){if(t.dbfields=e.results[0].series[0].columns,t.seriesdata=t.seriesdata||[],t.seriesdata.data=t.seriesdata.data||[],t.seriesdata.data=e.results[0].series[0].values.map(e=>({x:e[0],y:e[1],localedate:formatdate(e[0],t.datascales.format)})),t.datascales.data_count=t.seriesdata.data.length,t.datascales.data_count){if(t.datascales.useStatistics){const e=t.seriesdata.data.filter(t=>null!==t.y);t.statistics={current:e[e.length-1].y,first:e[0].y,last:e[e.length-1].y,min:e.reduce((t,e)=>e.ye.y>t?e.y:t,e[0].y),sum:e.reduce((t,{y:e})=>t+e,0),avg:e.reduce((t,{y:e})=>t+e,0)/e.length},t.statistics.range=t.statistics.max-t.statistics.min,t.statistics.midrange=.5*(t.statistics.max-t.statistics.min),t.state=t.statistics.current}this._buildGraphData(null,API_DATAMODE.database)}this.DEBUGMODE&&(this.DEBUGDATA.INFLUXDB.count=t.datascales.data_count)}this.DEBUGMODE&&(this.DEBUGDATA.INFLUXDB.status="No Error, all well done..."),this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.INFLUXDB.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.INFLUXDB.start))}else this.DEBUGMODE&&(this.DEBUGDATA.INFLUXDB.status="No Error, but no data found!"),this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.INFLUXDB.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.INFLUXDB.start))}).catch(e=>{throw this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.INFLUXDB.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.INFLUXDB.start),this.DEBUGDATA.INFLUXDB.status="Fatal Error: "+e,this._renderDebugInfo()),console.error("Dataprovider.getInfluxDbData",{card:this.card_title,entitiy:t.name,errormessage:e,connection:t.datasource.influxdb,query:t.datasource.query,token:t.datasource.token}),e})}_buildGraphData(t,e){if(this.DEBUGMODE&&(this.DEBUGDATA.API.datamode=e==API_DATAMODE.history?"History":"Current",e==API_DATAMODE.history&&(this.DEBUGDATA.PROFILER.GETHASSDATA.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.GETHASSDATA.start),this.DEBUGDATA.PROFILER.HISTORYDATA=t,this.DEBUGDATA.PROFILER.GETBUCKETDATA={start:performance.now()})),e===API_DATAMODE.history&&!t||t&&!t.length)return this.DEBUGMODE&&(this.DEBUGDATA.API.ERROR="No Historydata found!",this._renderDebugInfo()),this.dataInfo.loading=!1,null;if(!this.entity_items.isValid())return this.DEBUGMODE&&(this.DEBUGDATA.API.ERROR="No valid Entities found!",this.DEBUGDATA.API.DATA=t,this._renderDebugInfo()),this.dataInfo.loading=!1,null;if(e==API_DATAMODE.history){const e=new DataProvider({datainfo:this.dataInfo,datascales:this.datascales,debugmode:this.DEBUGMODE,debugdata:this.DEBUGDATA});if(1==CT_DATASCALEMODES[this.chart_type.toLowerCase()].multiseries?e.datamode=this.chartconfig.options.multiseries?TRANSFORM_MODE.seriesdata:TRANSFORM_MODE.statebased:e.datamode=TRANSFORM_MODE.seriesdata,0==e.getSeriesdata(t))return this.DEBUGMODE&&(this.DEBUGDATA.API.DATA=t,this.DEBUGDATA.API.ERROR="Transform Historydata failed!",this._renderDebugInfo()),this.dataInfo.loading=!1,null}const a=new chartData({card_config:{title:this.card_title,chart:this._config.chart,chartOptions:this.chartconfig.options},entity_items:this.entity_items,entityOptions:this.entity_options,debugmode:this.DEBUGMODE,debugdata:this.DEBUGDATA});if(e===API_DATAMODE.statemode?(this.graphData=a.getCurrentGraphData(),this.lastUpdate=(new Date).toISOString()):(this.graphData=a.getHistoryGraphData(),this.lastUpdate=(new Date).toISOString()),null===this.graphData)return this.DEBUGMODE&&(this.DEBUGDATA.API.ERROR="No GraphData found!",this.DEBUGDATA.API.DATA=t,this._renderDebugInfo()),this.dataInfo.loading=!1,null;if(this.graphData&&this.graphData.config&&(this.themeSettings.secondaryAxis=this.graphData.config.secondaryAxis||!1),this.DEBUGMODE&&(e===API_DATAMODE.statemode&&(this.DEBUGDATA.PROFILER.GETSTATEDATA.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.GETSTATEDATA.start)),this.DEBUGDATA.PROFILER.CHART={start:performance.now()}),this.chart_update?this.graphChart&&this.graphData&&(this.graphChart.graphData=this.graphData,this.graphChart.renderGraph(!0)):this.graphChart&&this.graphData&&(this.graphChart.graphData=this.graphData,this.graphChart.renderGraph(!1)),this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.CHART.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.CHART.start)),this._renderCardTimestamp(),e!=API_DATAMODE.statemode){if(this.chart_showstate||this.showdetails){let t=this.graphData.data.datasets.map(function(t){return{name:t.label||"",current:t.current,unit:t.unit||"",color:t.labelcolor||t.backgroundColor,timestamp:t.last_changed||""}});t&&this.renderStateData(t)}return this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.GETBUCKETDATA.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.GETBUCKETDATA.start),this._renderDebugInfo()),this.dataInfo.loading=!1,!0}this.DEBUGMODE&&this._renderDebugInfo(),this.dataInfo.loading=!1}connectedCallback(){this._initialized=!0,0!==this.update_interval&&(this.updateTimer=setInterval(()=>{!1===this.updating&&this.checkUpdate()},this.update_interval))}disconnectedCallback(){this._initialized=!1,this.updateTimer&&clearInterval(this.updateTimer)}getCardSize(){return 1}}customElements.define("chart-card",ChartCard);class Entities{constructor(t){this.items=t||{}}addEntity(t){t.dataid?this.items[t.dataid]=t:this.items[t.id]=t}_getDataFromInfluxDb(){}setData(t,e){this.items[t]=e}setDataField(t,e,a){this.items[t][e]=a}getSize(){return this.getEntityIds().length}isValid(){return 0!=this.getSize()}useAliasFields(){let t=0;return this.getEntityIds().forEach(e=>{this.items[e];t+=this.items[e].attribute?1:0}),0!=t}calcItemValue(t){let e=+t.value||0;return e*=t.factor,t.target_value&&isNumeric(t.target_value)&&(e=t.value/t.target_value*100),_safeParseFloat(e)||0}hasChanged(t){let e=!1;if(t&&t.length){const a=this.getEntitieslist();for(let i of a){const a=t.find(t=>t.entity_id===i.entity);i.laststate=i.state||0,i.update=!1,a&&i.last_changed!==a.last_changed&&i.state!==a.state&&(i.last_changed=a.last_changed,i.state=this.calcItemValue({value:i.useAttribute?getAttributeValue(a,i.field):a.state,factor:i.factor||1,target_value:i.target_value}),i.target_value&&isNumeric(i.target_value)&&(i.unit="%",i.current=a.state),i.update=!0,e=!0)}}return e}getEntity(t){return Number.isInteger(t)?this.getEntitieslist()[t]:this.items[t]}getNames(){return this.getAttribute("name")}getAttribute(t){let e=this.items;return Object.keys(e).map(function(a){return e[a][t]}).filter(t=>void 0!==t)}getOptions(t,e){const a=this.getEntity(t);return a&&a.style&&!e?a.style:a&&a.style&&void 0!==a.style[e]?a.style[e]:{}}getDataScales(t){const e=this.getEntity(t);return e?e.datascales:{range:24,unit:"day",format:"MMM d",factor:1,ignoreZero:!0,aggregate:"last"}}getStyle(t){return this.getEntity(t).style}getColors(){const t=this.items;return Object.keys(t).map(function(e){if(t[e].style&&void 0!==t[e].style.color||t[e].style&&void 0!==t[e].style.backgroundColor)return t[e].style.color||t[e].style.backgroundColor}).filter(t=>void 0!==t)}getData(t=null){return t?this.items[t].state:this.getAttribute("state")}getChartLabelAndData(){let t=[],e=[],a=[];return this.getEntitieslist().forEach(i=>{i.ignoreZero&&0===i.state||(t.push(i.name),e.push(i.state),i.style&&a.push(i.style.color||i.style.backgroundColor))}),{labels:t,colors:a,data:e}}getEntityIds(){return Object.keys(this.items)}checkDataSouresItems(){return Object.keys(this.items).filter(t=>null!=this.items[t].datasource)}getEntityIdsAsString(){const t=Object.keys(this.items).filter(t=>null==this.items[t].datasource&&0==this.items[t].stateOnly).map(t=>this.items[t].id);return[...new Set(t)].join(",")}getEntities(){return Object.entries(this.items)}getEntitieslist(){const t=this.items;return Object.keys(t).map(function(e){return t[e]})}getItemLabels(t){return this.getEntity(t).labels}getItemData(t){return this.getEntity(t).seriesdata.data}getDataset(t){if(this.items[t].seriesdata&&this.items[t].seriesdata.data){const e=this.items[t].seriesdata.data;let a=[],i=[];return e.forEach(t=>{a.push(t.localedate),i.push(t.y)}),{labels:a,data:i}}return{labels:[],data:[]}}getStatisticData(){let t=[];return this.getEntitieslist().forEach(e=>{let a={};if(e.seriesdata&&e.seriesdata.data){const t=e.seriesdata.data.map(t=>t.y);t.length&&(a.max=arrStatistics.max(t),a.min=arrStatistics.min(t),a.sum=arrStatistics.sum(t),a.mean=arrStatistics.mean(t),a.last=t[t.length-1],a.first=t[0])}a.name=e.name,a.entity=e.entity,a.color=e.style.backgroundColor||e.style.color,e.style.gradient&&e.style.gradient.colors&&(a.color=a.color||e.style.gradient.colors[0]),a.current=e.state,a.unit=e.unit||"",a.timestamp=e.last_changed,t.push(a)}),t}getSeriesData(){let t=[];const e=this.getEntityIds();for(const a of e){const e=this.items[a];e.seriesdata&&t.push(e.seriesdata)}return t}}function convertColor(t,e=1){return window.Chart3&&window.Chart3.helpers&&window.Chart3.helpers.color&&window.Chart3.helpers.color(t).alpha(e).rgbString()||t}function logInfo(t,...e){t&&console.info(`%cLOGINFO ${(new Date).toISOString()}:`,"color:white;background:#0275d8;padding:4px",...e)}function getAttributeValue(t,e){try{return e.split(".").reduce(function(t,e){return t[e]},t)}catch(t){return null}}String.prototype.isChartType=function(t){return this.toString().toLowerCase()===t.toLowerCase()};const cssAttr=function(t){return"number"==typeof t?t+"px":t},_parseNumber=t=>t===parseInt(t)?Number(parseInt(t)):Number(parseFloat(t).toFixed(3)),roundToBase=(t=0,e=3)=>Math.pow(e,Math.floor(Math.log(t)/Math.log(e))),_formatNumber=(t,e)=>new Intl.NumberFormat(t).format(_parseNumber(e)),_safeParseFloat=function(t){return t=parseFloat(t),isFinite(t)?+t.toFixed(3):0};function isNumeric(t){return!isNaN(parseFloat(t))&&isFinite(t)}function validItem(t,e=!1){return e?0!=t&&isNumeric(t):isNumeric(t)}function msToTime(t){return t>1e3?Number(parseFloat(t/1e3).toFixed(2))+" s":Number(parseFloat(t).toFixed(4))+" ms"}function strToDate(t){if(!t)return null;const e=new Date(t.replace(/-|\ |\./gi,"/"));return isNaN(e)?(console.error("Not a valid date string",t),null):e}function localDatetime(t,e="at-DE"){if(!t)return"";e||(e=navigator.language||navigator.userLanguage||"en-GB");const a=new Date(t);return isNaN(a)?t:new Intl.DateTimeFormat(e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}).format(a)}function checkDate(t){return t=t||new Date,isNaN(t)||"object"==typeof t?"string"==typeof t&&(t=new Date(t)):t=new Date(1e3*t),t}function getLocaleText(t="DE"){return{days_narrow:[...Array(7).keys()].map(e=>new Intl.DateTimeFormat(t,{weekday:"narrow"}).format(new Date(Date.UTC(2021,5,e)))),days_short:[...Array(7).keys()].map(e=>new Intl.DateTimeFormat(t,{weekday:"short"}).format(new Date(Date.UTC(2021,5,e)))),days_long:[...Array(7).keys()].map(e=>new Intl.DateTimeFormat(t,{weekday:"long"}).format(new Date(Date.UTC(2021,5,e)))),month_narrow:[...Array(12).keys()].map(e=>new Intl.DateTimeFormat(t,{month:"narrow"}).format(new Date(Date.UTC(2021,e,1)))),month_short:[...Array(12).keys()].map(e=>new Intl.DateTimeFormat(t,{month:"short"}).format(new Date(Date.UTC(2021,e,1)))),month_long:[...Array(12).keys()].map(e=>new Intl.DateTimeFormat(t,{month:"long"}).format(new Date(Date.UTC(2021,e,1))))}}Date.prototype.getWeek=function(t=0){var e=new Date(this.getFullYear(),0,1);return t=t||0,Math.floor(((this-e)/864e5+e.getDay()-t)/7)};var formatdate=function(){const t=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZWQw]|"[^"]*"|'[^']*'/g,e=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,a=/[^-+\dA-Z]/g,i=function(t,e){for(t=String(t),e=e||2;t.length99?Math.round(f/10):f),t:u<12?"a":"p",tt:u<12?"am":"pm",T:u<12?"A":"P",TT:u<12?"AM":"PM",Z:n?"UTC":(String(s).match(e)||[""]).pop().replace(a,""),o:(D>0?"-":"+")+i(100*Math.floor(Math.abs(D)/60)+Math.abs(D)%60,4)};return r.replace(t,function(t){return t in _?_[t]:t.slice(1,t.length-1)})}}();formatdate.masks={default:"ddd, dd mmm yyyy HH:MM:ss",shortDate:"m.d.yy",mediumDate:"d mmm yyyy",longDate:"d mmmm yyyy",fullDate:"dddd, d mmmm yyyy",shortTime:"H:MM",mediumTime:"HH:MM:ss",longTime:"HH:MM:ss.l",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",week:"W",quater:"Q",datetime:"ddd, d mmmm yyyy HH:MM:ss",millisecond:"HH:MM:ss l",second:"HH:MM:ss",minute:"HH:MM:ss",hour:"ddd, HH:MM",day:"ddd, d.mmm.yy",month:"mmm yyyy",year:"yyyy"};const arrStatistics={max:function(t){return _safeParseFloat(Math.max.apply(null,t))},min:function(t){return _safeParseFloat(Math.min.apply(null,t))},range:function(t){return _safeParseFloat(arrStatistics.max(t)-arrStatistics.min(t))},midrange:function(t){return _safeParseFloat(arrStatistics.range(t)/2)},mean:function(t){return _safeParseFloat(arrStatistics.sum(t)/t.length)},sum:function(t){for(var e=0,a=0,i=t.length;ar?n=1:s"string"!=typeof t?"":t.charAt(0).toUpperCase()+t.slice(1);function filter(t,e){let a=[];return e.forEach(e=>{const i=[];i.push(t=>(function(t,e){let a,i;"object"==typeof e?(a=e.key.split("."),i=e.key):(a=e.split("."),i=e);const s=new RegExp(`^${i.replace(/\*/g,".*")}$`,"i");return 0===t.search(s)})(t,e.entity_filter)),i&&i.length&&Object.keys(t).sort().forEach(s=>{if(Object.keys(t[s]).sort(),i.every(t=>t(`${s}`))){let i;if(e.attribute){if(t[s].attributes[e.attribute]){let a=t[s].attributes.friendly_name?t[s].attributes.friendly_name:s;a+=e.name?" "+e.name:" "+capitalize(e.attribute),(i={entity:s,name:a,unit:e.unit||"",state:t[s].attributes[e.attribute.toLowerCase()],attributes:t[s].attributes,last_changed:t[s].last_changed,field:e.attribute.toLowerCase()}).attributes.friendly_name=i.name}}else i={entity:s,name:t[s].attributes.friendly_name?t[s].attributes.friendly_name:s,state:t[s].state,attributes:t[s].attributes,last_changed:t[s].last_changed};if(i)if(e.options&&(i.options=e.options),i.state&&(e.state_min_value||e.state_max_value)){const t=e.state_min_value||Number.MIN_VALUE,s=e.state_max||Number.MAX_VALUE;i.state=parseFloat(i.state),(i.state-t)*(i.state-s)<=0&&a.push(i)}else a.push(i)}})}),a}class DataProvider{constructor(t){this.dataInfo=t.datainfo,this.datascales=t.datascales,this.datamode=TRANSFORM_MODE.seriesdata,this.DEBUGMODE=t.debugmode,this.DEBUGDATA=t.debugdata,this.locale="DE"|window.Chart3.defaults.locale,this.ready=this._checkParam(),this.version="1.0.1",this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.DATAPROVIDER={start:performance.now()})}_checkParam(){return!!(this.datascales&&this.dataInfo.entity_items&&Object.keys(this.dataInfo.entity_items))&&(this.datascales.range=this.datascales.range||24,this.datascales.aggregate=this.datascales.aggregate||"last",!0)}_setEntityServiceDataInformation(t){t&&(t.datascales.data_count=0,t.datascales.servicemode=TRANSFORM_MODE.seriesdata)}_createTimeSeriesData(t,e){return t.seriesdata=t.seriesdata||[],t.seriesdata.data=t.seriesdata.data||[],t.seriesdata.data=Object.entries(e).map(function(e){const a=e[1].data;if(a&&a.length){let i={x:new Date(e[0]).getTime(),localedate:e[1].localedate,y:arrStatistics[t.aggregate||t.datascales.aggregate](a)};return t.datascales.useStatistics&&(i.statistics={current:t.state,first:a[0],last:a[a.length-1],max:arrStatistics.max(a),min:arrStatistics.min(a),sum:arrStatistics.sum(a),avg:arrStatistics.mean(a)}),i}}),t.datascales.data_count=t.seriesdata.data.length,t.datascales.data_count}getSimpleData(t){return t&&t.length&&t.forEach(t=>{const e=t[0].entity_id,a=this.dataInfo.entity_items[e];if(this._setEntityServiceDataInformation(a),e&&a){const e=a.factor||1,i=t.map(t=>a.field?(getAttributeValue(t,a.field)||0)*e:t.state*e);if(a.datascales.useStatistics){({}).statistics={current:a.state,first:i[0],last:i[i.length-1],max:arrStatistics.max(i),min:arrStatistics.min(i),sum:arrStatistics.sum(i),avg:arrStatistics.mean(i)}}a.datascales.data_count=i.length,a.state=arrStatistics[a.datascales.aggregate](i)}else console.error(`Sensordata ${a} not found !`)}),this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.DATAPROVIDER.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.DATAPROVIDER.start)),!0}getSeriesdata(t){if(this.datamode===TRANSFORM_MODE.statebased)return this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.DATAPROVIDER.mode="simpledata"),this.getSimpleData(t);function e(t,e="label",a="day"){const i={millisecond:"yyyy/m/d H:M:ss.l",datetime:"yyyy/md/ H:M:s",second:"yyyy/m/d H:M:s",minute:"yyyy/m/d H:M:00",hour:"yyyy/m/d H:00:00",day:"yyyy/m/d",month:"yyyy/m/1",year:"yyyy/12/31"};return formatdate(t,"group"==e?i[a]||i.day:a)}return this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.DATAPROVIDER.mode="seriesdata"),t&&t.length?(t.forEach(t=>{const a=t[0].entity_id,i=this.dataInfo.entity_items[a];if(i&&a){const a=i.factor||1;this._setEntityServiceDataInformation(i),i.hasOwnProperty("ignoreZero")||(i.ignoreZero=!1),i.datascales.states_count=t.length;let s=[];t.forEach(function(t){const r=e(t.last_changed,"group",i.datascales.unit);let n=i.field?+getAttributeValue(t,i.field):+t.state;validItem(n,i.ignoreZero)&&(n*=a,s[r]=s[r]||[],s[r].data=s[r].data||[],s[r].localedate=e(t.last_changed,"label",i.datascales.format||i.datascales.unit),s[r].data.push(_safeParseFloat(n)))}),i.datascales.data_count=this._createTimeSeriesData(i,s)}}),this.DEBUGMODE&&(this.DEBUGDATA.PROFILER.DATAPROVIDER.elapsed=msToTime(performance.now()-this.DEBUGDATA.PROFILER.DATAPROVIDER.start)),!0):void 0}}const DEFAULT_COLORS=["rgba(237,212,0,0.85)","rgba(115,210,22,0.85)","rgba(245,121,0,0.85)","rgba(52,101,164,0.85)","rgba(89,161,79,0.85)","rgba(182,153,45,0.85)","rgba(73,152,148,0.85)","rgba(225,87,89,0.85)","rgba(121,112,110,0.85)","rgba(211,114,149,0.85)","rgba(176,122,161,0.85)","rgba(157,118,96,0.85)","rgba(52,152,219,0.85)","rgba(46,204,113,0.85)","rgba(241,196,15,0.85)","rgba(155,89,182,0.85)","rgba(26,188,156,0.85)","rgba(39,174,96,0.85)","rgba(41,128,185,0.85)","rgba(142,68,173,0.85)","rgba(44,62,80,0.85)","rgba(230,126,34,0.85)","rgba(231,76,60,0.85)","rgba(236,240,241,0.85)","rgba(149,165,166,0.85)","rgba(243,156,18,0.85)","rgba(211,84,0,0.85)","rgba(192,57,43,0.85)","rgba(229,28,35,0.85)","rgba(205,220,57,0.85)","rgba(52,152,219,0.85)","rgba(231,76,60,0.85)","rgba(155,89,182,0.85)","rgba(241,196,15,0.85)","rgba(46,204,113,0.85)","rgba(26,188,156,0.85)","rgba(52,73,94,0.85)","rgba(230,126,34,0.85)","rgba(127,140,141,0.85)","rgba(39,174,96,0.85)","rgba(41,128,185,0.85)","rgba(142,68,173,0.85)"],COLOR_RADARCHART="rgba(41, 182, 246, 0.45)",COLOR_BUBBLECHAT="rgba(255, 152, 0, 0.685)",randomColor="#"+Math.floor(16777215*Math.random()).toString(16),randomColor2=DEFAULT_COLORS[Math.floor(Math.random()*DEFAULT_COLORS.length)];class chartData{constructor(t){this.card_config=t.card_config,this.entity_options=t.entityOptions,this.entity_items=t.entity_items,this.DEBUGMODE=t.debugmode,this.data_pointStyles=CT_DATAPOINTSTYLE,this.indicators={up:"▲",down:"▼",equal:"≃"},this.graphData={},this.version="1.0.1"}getDefaultGraphData(){return{data:{datasets:[]},config:{mode:"init",secondaryAxis:!1,series:0,gradient:!1,options:{},segmentbar:!1,timescale:!1,trendline:!1,thresholds:!1}}}createScatterChartData(){if(!this.entity_items.isValid())return null;let t=null,e=this.entity_items.getSize(),a=this.entity_items.getEntitieslist();if(e%2==0){(t=this.getDefaultGraphData()).config.mode="simple";for(let i=0;iNumber(t));const e=Math.max(...t.data),a=(Math.min(...t.data),Chart.helpers);return{data:t.data.map(t=>e-t),backgroundColors:t.backgroundColor.map(t=>a.color(t).alpha(.25).rgbString())}}return null}createChartData(){if(!this.entity_items.isValid())return null;const t=this.entity_items.getChartLabelAndData();if(0===t.length)return console.error("Create Chart Data, no Data present !"),null;let e={mode:"current",unit:""},a=this.getDefaultGraphData();a.config.mode="simple",this.entity_options&&(e={...e,...this.entity_options}),a.data.labels=t.labels,a.data.datasets[0]=e,a.data.datasets[0].label=this.card_config.title||"",this.entity_options&&this.entity_options.unit?a.data.datasets[0].unit=this.entity_options.unit||"":a.data.datasets[0].units=this.entity_items.getEntitieslist().map(t=>t.unit),this.card_config.chart.isChartType("horizontalbar")&&(a.data.datasets[0].indexAxis="y");let i=t.colors;if(this.entity_options&&null!=this.entity_options.gradient&&(a.config.gradient=!0),i.length===a.data.labels.length?(a.data.datasets[0].backgroundColor=i,a.data.datasets[0].showLine=!1):this.card_config.chart.isChartType("radar")?(a.data.datasets[0].backgroundColor=COLOR_RADARCHART,a.data.datasets[0].borderColor=COLOR_RADARCHART,a.data.datasets[0].borderWidth=1,a.data.datasets[0].pointBorderColor=COLOR_RADARCHART,a.data.datasets[0].pointBackgroundColor=COLOR_RADARCHART,a.data.datasets[0].tooltip=!0,a.config.gradient=!1):(i=DEFAULT_COLORS.slice(1,t.data.length+1),a.data.datasets[0].backgroundColor=i,a.data.datasets[0].borderWidth=0,a.data.datasets[0].showLine=!1),a.data.datasets[0].data=t.data,a.config.segmentbar=!1,this.card_config.chart.isChartType("bar")&&this.card_config.chartOptions&&this.card_config.chartOptions.segmented){const t=this.createSimpleBarSegmentedData(a.data.datasets[0]);t&&(a.data.datasets[1]={},a.data.datasets[1].data=t.data,a.data.datasets[1].tooltip=!1,a.data.datasets[1].backgroundColor=t.backgroundColors,a.data.datasets[1].borderWidth=0,a.data.datasets[1].showLine=!1,a.config.segmentbar=0!==t.data.length)}return a}getCurrentGraphData(){try{switch(this.card_config.chart){case"bubble":this.graphData=this.createBubbleChartData();break;case"scatter":this.graphData=this.createScatterChartData();break;default:this.graphData=this.createChartData()}return this.graphData}catch(t){console.error("Current entities GraphData",t.message,t)}return null}createHistoryBubbleData(){if(!this.entity_items.isValid())return null;let t=this.entity_items.getSeriesData();if(t&&t.length%3==0){let e=this.getDefaultGraphData();for(let a=0;a{const a=this.entity_items.items[e];let i={...this.entity_items.getOptions(e)},s={label:a.name||"unkonwn",unit:a.unit||"",pointRadius:0,current:a.state||0,last_changed:a.last_changed||new Date,mode:"history"};if(this.card_config.chart.isChartType("horizontalbar")&&(s.indexAxis="y"),this.card_config.chart.isChartType("radar")&&(s.pointRadius=12,s.hoverRadius=18,s.hitRadius=22),this.entity_options&&(s={...s,...this.entity_options},t.config.options={...t.config.options,...this.entity_options}),s={...s,...i},t.config.options.fill=i.fill||CT_BARCHARTS.includes(this.card_config.chart),i.fill&&i.gradient&&i.gradient.colors){const e="y"===s.indexAxis?"x":"y";s.gradient={backgroundColor:{axis:e,colors:i.gradient.colors}},s.labelcolor=i.gradient.colors[0],s.borderColor=i.gradient.colors[0]||DEFAULT_COLORS[t.config.series],t.config.gradient=!0}else void 0===i.backgroundColor?(s.backgroundColor=DEFAULT_COLORS[t.config.series],s.borderColor=DEFAULT_COLORS[t.config.series]):(s.backgroundColor=s.backgroundColor||s.backgroundColor||s.color,s.borderColor=s.borderColor||s.backgroundColor||s.color);if(i.trendlineLinear&&(t.config.trendline=!0),this.card_config.chartOptions.thresholds&&(t.config.thresholds=!0),t.config.secondaryAxis||(t.config.secondaryAxis=null!=i.yAxisID||null!=i.xAxisID),0==t.config.options.mode.timeaxis){const a=this.entity_items.getDataset(e);t.config.multiseries=!1,a&&a.data&&(t.data.labels=a.labels,(this.card_config.chart.isChartType("pie")||this.card_config.chart.isChartType("doughnut"))&&(t.data.labels=this.entity_items.getNames(),t.config.multiseries=!0),s.data=a.data,t.config.useTimeSeries=t.config.options.mode.timescale)}else a.seriesdata&&a.seriesdata.data&&(s.data=a.seriesdata.data,t.config.datascales=a.datascales,t.config.timescale=t.config.options.mode.timescale);t.data.datasets.push(s),t.config.series++}),t}getHistoryGraphData(){try{switch(this.card_config.chart){case"bubble":this.entity_options.mode=CT_DATASCALEMODES[this.card_config.chart],this.graphData=this.createHistoryBubbleData();break;case"scatter":this.entity_options.mode=CT_DATASCALEMODES[this.card_config.chart],this.graphData=this.createHistoryScatterData();break;case"bar":case"horizontalbar":this.entity_options&&this.entity_options.mode&&this.entity_options.mode.history?this.graphData=this.createHistoryChartData():this.graphData=this.createChartData();break;case"pie":case"doughnut":this.card_config&&this.card_config.chartOptions&&!0===this.card_config.chartOptions.multiseries&&this.entity_options&&this.entity_options.mode&&this.entity_options.mode.history?this.graphData=this.createHistoryChartData():(this.entity_options.mode=CT_DATASCALEMODES[this.card_config.chart],this.graphData=this.createChartData());break;default:this.graphData=this.createHistoryChartData()}if(this.graphData)return this.graphData;console.error("Error getHistoryGraphData, no data present!")}catch(t){console.error("Build History GraphData",t.message,t)}return null}}function xAxisFormat(t,e,a){if(this&&this.options.time&&this.options.time.unit){const e=this.options.time.format||this.options.time.unit;if(e&&Number.isInteger(t))return formatdate(+t,e)}return t}function yAxisFormat(t,e,a){return t}function formatToolTipTitle(t){const e=t[0].chart.config._config.type;return"polarArea"==e?t[0].chart.config._config.data.labels[t[0].dataIndex]||"":"scatter"==e?"":t[0].label&&t[0].raw&&t[0].raw.localedate?t[0].raw.localedate||t[0].label:t[0].label||""}function formatToolTipLabel(t){if(!1===t.dataset.tooltip)return null;let e=t.dataset.label||t.label||t.chart.data.labels[t.dataIndex]||"";const a="bubble"===t.chart.config._config.type?t.parsed._custom:t.formattedValue;return t.dataset.units&&t.dataset.units.length>t.dataIndex?e+=`: ${a} ${t.dataset.units[t.dataIndex]||""}`:e+=`: ${a} ${t.dataset.unit||""}`,e}class graphChart{constructor(t){this.ctx=t.ctx||null,this.canvasId=t.canvasId,this.entity_items=t.entity_items,this.chart_type=t.chart_type||"bar",this.chartconfig=t.chartconfig||{},this.loader=t.loader,this.DEBUGMODE=t.debugmode||0,this.DEBUGDATA=t.debugdata,this.chart=null,this.graphData={},this.graphDataSets=[],this.chart_ready=!1,this.lastUpdate=null,this.ChartControl=window.Chart3||Chart,this.version="1.0.1"}_setChartOptions(){const t=this.loader;let e={hoverOffset:8,layout:{},chartArea:{backgroundColor:"transparent"},elements:{},spanGaps:!0,plugins:{title:{},tooltip:{},legend:{display:CT_SHOWLEGEND.includes(this.chart_type)||!1}},animation:{onComplete:function(){t&&(t.style.display="none")}}};if(!0===this.graphData.config.gradient&&"simple"===this.graphData.config.mode&&(e.gradientcolor={color:!0,type:this.chart_type}),plugin_gradient&&this.graphData.config.gradient&&(e.plugins={plugin_gradient:plugin_gradient}),this.graphData.config.secondaryAxis&&this.graphData&&this.graphData.data&&this.graphData.data.datasets){let t={};this.graphData.data.datasets.forEach(e=>{e.yAxisID&&(t[e.yAxisID]={},t[e.yAxisID].id=e.yAxisID,t[e.yAxisID].type="linear",t[e.yAxisID].position=e.yAxisID,t[e.yAxisID].display=!0,"right"==e.yAxisID.toLowerCase()&&(t[e.yAxisID].grid={drawOnChartArea:!1})),e.xAxisID&&(t[e.xAxisID]={},t[e.xAxisID].id=e.xAxisID,t[e.xAxisID].type="linear",t[e.xAxisID].position=e.xAxisID,t[e.xAxisID].display=!0,"top"==e.xAxisID.toLowerCase()&&(t[e.xAxisID].grid={drawOnChartArea:!1}))}),t&&(e.scales=t)}if(this.chart_type.isChartType("bubble")){const t=this.entity_items.getEntitieslist();let a=t[0].name;a+=t[0].unit?" ("+t[0].unit+")":"";let i=t[1].name;i+=t[1].unit?" ("+t[1].unit+")":"",e.scales={x:{id:"x",title:{display:!0,text:a}},y:{id:"y",title:{display:!0,text:i}}},this.graphData.config.bubbleScale&&(e.elements={point:{radius:t=>{return t.dataset.data[t.dataIndex]._r*this.graphData.config.bubbleScale}}})}this.graphData.config.timescale&&this.graphData.config.datascales&&(e.scales=e.scales||{},e.scales.x=e.scales.x||{},e.scales.x.maxRotation=0,e.scales.x.autoSkip=!0,e.scales.x.major=!0,e.scales.x.type="time",e.scales.x.time={unit:this.graphData.config.datascales.unit,format:this.graphData.config.datascales.format,isoWeekday:this.graphData.config.datascales.isoWeekday},e.scales.x.ticks={callback:xAxisFormat}),!0===this.graphData.config.segmentbar?(e.scales={x:{id:"x",stacked:!0},y:{id:"y",stacked:!0}},e.plugins.legend={labels:{filter:(t,e)=>!1!==e.datasets[t.datasetIndex].tooltip},display:!1},e.plugins.tooltip.callbacks={label:t=>!1!==t.dataset.tooltip&&t.dataset.label?`${t.formattedValue} ${t.dataset.unit||""}`:null},e.interaction={intersect:!1,mode:"index"}):(e.plugins.tooltip={callbacks:{label:formatToolTipLabel,title:formatToolTipTitle}},e.interaction={intersect:!0,mode:"point"}),this.chart_type.isChartType("bubble")&&(e.plugins.legend={display:!1}),!0===this.graphData.config.multiseries&&(e.plugins.legend={labels:{generateLabels:function(t){const e=Chart.overrides.pie.plugins.legend.labels.generateLabels.call(this,t);let a=t.data.datasets.map(function(t){return t.backgroundColor});return a=a.flat(),e.forEach(e=>{e.datasetIndex=e.index,e.hidden=!t.isDatasetVisible(e.datasetIndex),e.fillStyle=a[e.index]}),e}},onClick:function(t,e,a){a.chart.getDatasetMeta(e.datasetIndex).hidden=a.chart.isDatasetVisible(e.datasetIndex),a.chart.update()}},e.plugins.tooltip={callbacks:{label:function(t){const e=t.datasetIndex;return`${t.chart.data.labels[e]}: ${t.formattedValue} ${t.dataset.unit||""}`}}});let a={type:this.chart_type,data:{datasets:[]},options:e};return this.chartconfig.options?a.options=deepMerge(e,this.chartconfig.options):a.options=e,a}sendJSON(t,e){let a=new XMLHttpRequest;a.open("POST",t,!0),a.withCredentials=!1,a.setRequestHeader("Content-Type","application/json"),a.onreadystatechange=function(){4===a.readyState&&200===a.status&&console.info("sendJson",this.responseText)},a.send(JSON.stringify(e))}renderGraph(t){try{if(this.graphData&&this.graphData.data&&this.graphData.config){if(this.graphDataSets&&this.graphDataSets.length&&JSON.stringify(this.graphDataSets)===JSON.stringify(this.graphData.data.datasets))return;let e=this._setChartOptions();e.data={datasets:this.graphData.data.datasets},this.graphData.data.labels&&(e.data.labels=this.graphData.data.labels),this.ctx&&e.data&&e.options&&(t&&this.chart&&this.chart.data?(this.chart.data=e.data,this.chart.update({duration:0,easing:"linear"}),this.DEBUGMODE&&(this.DEBUGDATA.CHARD={chartOptions:e,chartMode:"update data ready",chartjs:window.Chart3.version,chartGraphdata:this.graphData.config})):(!1===this.chart_ready&&this.ChartControl.register&&(this.graphData.config.gradient&&this.ChartControl.register(plugin_gradient),this.graphData.config.trendline&&window.plugin_trendline&&this.ChartControl.register(window.plugin_trendline),this.ChartControl&&this.chartconfig&&this.chartconfig.options&&this.chartconfig.options.chartArea&&""!==this.chartconfig.options.chartArea.backgroundColor&&this.ChartControl.register({id:"chardbackground",beforeDraw:function(t){if(t.config.options.chartArea&&t.config.options.chartArea.backgroundColor){const e=t.chartArea,a=t.ctx;a.save(),a.fillStyle=t.config.options.chartArea.backgroundColor,a.fillRect(e.left,e.top,e.right-e.left,e.bottom-e.top),a.restore()}}}),this.graphData.config.thresholds&&this.ChartControl.register({id:"thresholds",beforeDraw:function(t){const e=t.config.options.thresholds,a=function(t,e){if(e){const a=t.scales[e.yScaleID||e.xScaleID],i=e.xScaleID?"x":"y";return{x:t.chartArea.left,x2:t.chartArea.right,y:"y"===i?a.getPixelForValue(e.value):t.chartArea.top,y2:t.chartArea.bottom,w:"x"===i?t.chartArea.right-a.getPixelForValue(e.value):t.chartArea.width,h:"y"===i?t.chartArea.bottom-a.getPixelForValue(e.value):t.chartArea.height,width:t.chartArea.width,height:t.chartArea.height,axis:i}}return null}(t,e),i=t.ctx;if(e&&e&&a){i.save();const t="y"===a.axis?i.createLinearGradient(0,0,0,a.h):i.createLinearGradient(0,0,a.w,0),s=e.backgroundColor||"rgb(249, 70, 12)";t.addColorStop(0,window.Chart3.helpers.color(s).alpha(.85).rgbString()),t.addColorStop(1,window.Chart3.helpers.color(s).alpha(.15).rgbString()),i.fillStyle=t,i.fillRect(a.x,a.y,a.width,a.h),i.beginPath(),i.lineWidth=1.25,i.strokeStyle=s,"y"===a.axis?(i.moveTo(a.x-5,a.y),i.lineTo(a.x2,a.y)):(i.moveTo(a.x,a.y-5),i.lineTo(a.x,a.y2)),i.stroke(),i.restore()}}})),this.chart&&(this.chart.destroy(),this.chart=null),this.DEBUGMODE&&(this.DEBUGDATA.CHARD={},this.DEBUGDATA.CHARD.cart3Options=e),this.chart=new window.Chart3(this.ctx,e),this.graphDataSets=this.graphData.data.datasets,this.DEBUGMODE&&(this.DEBUGDATA.CHARD={chartOptions:e,chartMode:"new data ready",chartjs:window.Chart3.version,chartmodul:"v "+this.version,chartGraphdata:this.graphData.config}),this.chart&&(this.chart_ready=!0)))}else console.error("Fatal Error, missing graphdata",graphOptions)}catch(t){console.error("Error Render Graph Error on ",this.chart_type,": ",t,t.message)}}} \ No newline at end of file diff --git a/dist/chart-card/chart-card.js b/dist/chart-card/chart-card.js index 58cc361..d2d0b93 100644 --- a/dist/chart-card/chart-card.js +++ b/dist/chart-card/chart-card.js @@ -33,8 +33,8 @@ import "/hacsfiles/chart-card/chart.js?module" const appinfo = { name: "✓ custom:chart-card ", app: "chart-card", - version: "v2.1.6/v3.6.0", - chartjs: Chart.version || "v3.6.0", + version: "v2.1.6/v3.6.1", + chartjs: Chart.version || "v3.6.1", assets: "/hacsfiles/chart-card/assets/", github: "https://github.com/zibous/lovelace-graph-chart-card" } diff --git a/dist/chart-card/chart-min.js b/dist/chart-card/chart-min.js index 4a923fb..e80eb60 100644 --- a/dist/chart-card/chart-min.js +++ b/dist/chart-card/chart-min.js @@ -1 +1 @@ -function LineFitter(){this.count=0,this.sumX=0,this.sumX2=0,this.sumXY=0,this.sumY=0}function addFitter(t,e,i,s,n){if(i&&i.data&&i.data.length){const o="time"===s.options.type,a=i.data.length-1,r=t.data[0].x,l=t.data[a].x,h=new LineFitter;i.data.forEach(function(t,e){h.add(e,o?t.y:t)}),e.lineWidth=i.trendlineLinear.lineStyle||"solid","dotted"===(i.trendlineLinear.lineStyle||"solid")&&e.setLineDash([2,3]),e.beginPath(),e.lineWidth=2,e.moveTo(r,n.getPixelForValue(h.project(0))),e.lineTo(l,n.getPixelForValue(h.project(a))),e.strokeStyle=i.trendlineLinear.color||i.borderColor||"rgba(255, 0, 0, 0.85)",e.stroke()}}!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Chart=e()}(this,function(){"use strict";const t="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function e(e,i,s){const n=s||(t=>Array.prototype.slice.call(t));let o=!1,a=[];return function(...s){a=n(s),o||(o=!0,t.call(window,()=>{o=!1,e.apply(i,a)}))}}function i(t,e){let i;return function(...s){return e?(clearTimeout(i),i=setTimeout(t,e,s)):t.apply(this,s),e}}const s=t=>"start"===t?"left":"end"===t?"right":"center",n=(t,e,i)=>"start"===t?e:"end"===t?i:(e+i)/2,o=(t,e,i,s)=>{return t===(s?"left":"right")?i:"center"===t?(e+i)/2:e};var a=new class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,s){const n=e.listeners[s],o=e.duration;n.forEach(s=>s({chart:t,initial:e.initial,numSteps:o,currentStep:Math.min(i-e.start,o)}))}_refresh(){this._request||(this._running=!0,this._request=t.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((i,s)=>{if(!i.running||!i.items.length)return;const n=i.items;let o,a=n.length-1,r=!1;for(;a>=0;--a)(o=n[a])._active?(o._total>i.duration&&(i.duration=o._total),o.tick(t),r=!0):(n[a]=n[n.length-1],n.pop());r&&(s.draw(),this._notify(s,i,t,"progress")),n.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),e+=n.length}),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((t,e)=>Math.max(t,e._duration),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}};const r={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},l="0123456789ABCDEF",h=t=>l[15&t],c=t=>l[(240&t)>>4]+l[15&t],d=t=>(240&t)>>4==(15&t);function u(t){var e=function(t){return d(t.r)&&d(t.g)&&d(t.b)&&d(t.a)}(t)?h:c;return t?"#"+e(t.r)+e(t.g)+e(t.b)+(t.a<255?e(t.a):""):t}function f(t){return t+.5|0}const g=(t,e,i)=>Math.max(Math.min(t,i),e);function p(t){return g(f(2.55*t),0,255)}function m(t){return g(f(255*t),0,255)}function b(t){return g(f(t/2.55)/100,0,1)}function x(t){return g(f(100*t),0,100)}const _=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const y=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function v(t,e,i){const s=e*Math.min(i,1-i),n=(e,n=(e+t/30)%12)=>i-s*Math.max(Math.min(n-3,9-n,1),-1);return[n(0),n(8),n(4)]}function w(t,e,i){const s=(s,n=(s+t/60)%6)=>i-i*e*Math.max(Math.min(n,4-n,1),0);return[s(5),s(3),s(1)]}function M(t,e,i){const s=v(t,1,.5);let n;for(e+i>1&&(e*=n=1/(e+i),i*=n),n=0;n<3;n++)s[n]*=1-e-i,s[n]+=e;return s}function k(t){const e=t.r/255,i=t.g/255,s=t.b/255,n=Math.max(e,i,s),o=Math.min(e,i,s),a=(n+o)/2;let r,l,h;return n!==o&&(h=n-o,l=a>.5?h/(2-n-o):h/(n+o),r=60*(r=n===e?(i-s)/h+(i>16&255,o>>8&255,255&o]}return t}()).transparent=[0,0,0,0]);const e=A[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}function R(t,e,i){if(t){let s=k(t);s[e]=Math.max(0,Math.min(s[e]+s[e]*i,0===e?360:1)),s=D(s),t.r=s[0],t.g=s[1],t.b=s[2]}}function E(t,e){return t?Object.assign(e||{},t):t}function F(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=m(t[3]))):(e=E(t,{r:0,g:0,b:0,a:1})).a=m(e.a),e}function I(t){return"r"===t.charAt(0)?function(t){const e=_.exec(t);let i,s,n,o=255;if(e){if(e[7]!==i){const t=+e[7];o=255&(e[8]?p(t):255*t)}return i=+e[1],s=+e[3],n=+e[5],{r:i=255&(e[2]?p(i):i),g:s=255&(e[4]?p(s):s),b:n=255&(e[6]?p(n):n),a:o}}}(t):C(t)}class z{constructor(t){if(t instanceof z)return t;const e=typeof t;let i;var s,n,o;"object"===e?i=F(t):"string"===e&&(o=(s=t).length,"#"===s[0]&&(4===o||5===o?n={r:255&17*r[s[1]],g:255&17*r[s[2]],b:255&17*r[s[3]],a:5===o?17*r[s[4]]:255}:7!==o&&9!==o||(n={r:r[s[1]]<<4|r[s[2]],g:r[s[3]]<<4|r[s[4]],b:r[s[5]]<<4|r[s[6]],a:9===o?r[s[7]]<<4|r[s[8]]:255})),i=n||L(t)||I(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=E(this._rgb);return t&&(t.a=b(t.a)),t}set rgb(t){this._rgb=F(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${b(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):this._rgb;var t}hexString(){return this._valid?u(this._rgb):this._rgb}hslString(){return this._valid?function(t){if(!t)return;const e=k(t),i=e[0],s=x(e[1]),n=x(e[2]);return t.a<255?`hsla(${i}, ${s}%, ${n}%, ${b(t.a)})`:`hsl(${i}, ${s}%, ${n}%)`}(this._rgb):this._rgb}mix(t,e){const i=this;if(t){const s=i.rgb,n=t.rgb;let o;const a=e===o?.5:e,r=2*a-1,l=s.a-n.a,h=((r*l==-1?r:(r+l)/(1+r*l))+1)/2;o=1-h,s.r=255&h*s.r+o*n.r+.5,s.g=255&h*s.g+o*n.g+.5,s.b=255&h*s.b+o*n.b+.5,s.a=a*s.a+(1-a)*n.a,i.rgb=s}return i}clone(){return new z(this.rgb)}alpha(t){return this._rgb.a=m(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,e=f(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return R(this._rgb,2,t),this}darken(t){return R(this._rgb,2,-t),this}saturate(t){return R(this._rgb,1,t),this}desaturate(t){return R(this._rgb,1,-t),this}rotate(t){return function(t,e){var i=k(t);i[0]=P(i[0]+e),i=D(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this}}function V(t){return new z(t)}const B=t=>t instanceof CanvasGradient||t instanceof CanvasPattern;function W(t){return B(t)?t:V(t)}function N(t){return B(t)?t:V(t).saturate(.5).darken(.1).hexString()}function H(){}const j=function(){let t=0;return function(){return t++}}();function Y(t){return null==t}function $(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.substr(0,7)&&"Array]"===e.substr(-6)}function U(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}const X=t=>("number"==typeof t||t instanceof Number)&&isFinite(+t);function q(t,e){return X(t)?t:e}function K(t,e){return void 0===t?e:t}const G=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:t/e,Z=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function Q(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function J(t,e,i,s){let n,o,a;if($(t))if(o=t.length,s)for(n=o-1;n>=0;n--)e.call(i,t[n],n);else for(n=0;ni;)t=t[e.substr(i,s-i)],s=ht(e,i=s+1);return t}function dt(t){return t.charAt(0).toUpperCase()+t.slice(1)}const ut=t=>void 0!==t,ft=t=>"function"==typeof t,gt=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0},pt=Object.create(null),mt=Object.create(null);function bt(t,e){if(!e)return t;const i=e.split(".");for(let e=0,s=i.length;et.chart.platform.getDevicePixelRatio()),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=((t,e)=>N(e.backgroundColor)),this.hoverBorderColor=((t,e)=>N(e.borderColor)),this.hoverColor=((t,e)=>N(e.color)),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.describe(t)}set(t,e){return xt(this,t,e)}get(t){return bt(this,t)}describe(t,e){return xt(mt,t,e)}override(t,e){return xt(pt,t,e)}route(t,e,i,s){const n=bt(this,t),o=bt(this,i),a="_"+e;Object.defineProperties(n,{[a]:{value:n[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[a],e=o[s];return U(t)?Object.assign({},e,t):K(t,e)},set(t){this[a]=t}}})}}({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}});const yt=Math.PI,vt=2*yt,wt=vt+yt,Mt=Number.POSITIVE_INFINITY,kt=yt/180,St=yt/2,Dt=yt/4,Pt=2*yt/3,Ct=Math.log10,Ot=Math.sign;function Tt(t){const e=Math.round(t);t=Rt(t,e,t/1e3)?e:t;const i=Math.pow(10,Math.floor(Ct(t))),s=t/i;return(s<=1?1:s<=2?2:s<=5?5:10)*i}function At(t){const e=[],i=Math.sqrt(t);let s;for(s=1;st-e).pop(),e}function Lt(t){return!isNaN(parseFloat(t))&&isFinite(t)}function Rt(t,e,i){return Math.abs(t-e)=t}function Ft(t,e,i){let s,n,o;for(s=0,n=t.length;sl&&hs&&(s=o),s}function qt(t,e,i,s){let n=(s=s||{}).data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==e&&(n=s.data={},o=s.garbageCollect=[],s.font=e),t.save(),t.font=e;let a=0;const r=i.length;let l,h,c,d,u;for(l=0;li.length){for(l=0;l0&&t.stroke()}}function Qt(t,e,i){return i=i||.5,!e||t&&t.x>e.left-i&&t.xe.top-i&&t.y0&&""!==o.strokeColor;let l,h;for(t.save(),t.font=n.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]);Y(e.rotation)||t.rotate(e.rotation);e.color&&(t.fillStyle=e.color);e.textAlign&&(t.textAlign=e.textAlign);e.textBaseline&&(t.textBaseline=e.textBaseline)}(t,o),l=0;lt[i]1;)i(s=o+n>>1)?o=s:n=s;return{lo:o,hi:n}}const re=(t,e,i)=>ae(t,i,s=>t[s][e]ae(t,i,s=>t[s][e]>=i);function he(t,e,i){let s=0,n=t.length;for(;ss&&t[n-1]>i;)n--;return s>0||n{const i="_onData"+dt(e),s=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...e){const n=s.apply(this,e);return t._chartjs.listeners.forEach(t=>{"function"==typeof t[i]&&t[i](...e)}),n}})}))}function ue(t,e){const i=t._chartjs;if(!i)return;const s=i.listeners,n=s.indexOf(e);-1!==n&&s.splice(n,1),s.length>0||(ce.forEach(e=>{delete t[e]}),delete t._chartjs)}function fe(t){const e=new Set;let i,s;for(i=0,s=t.length;iwindow.getComputedStyle(t,null);function xe(t,e){return be(t).getPropertyValue(e)}const _e=["top","right","bottom","left"];function ye(t,e,i){const s={};i=i?"-"+i:"";for(let n=0;n<4;n++){const o=_e[n];s[o]=parseFloat(t[e+"-"+o+i])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}const ve=(t,e,i)=>(t>0||e>0)&&(!i||!i.shadowRoot);function we(t,e){const{canvas:i,currentDevicePixelRatio:s}=e,n=be(i),o="border-box"===n.boxSizing,a=ye(n,"padding"),r=ye(n,"border","width"),{x:l,y:h,box:c}=function(t,e){const i=t.native||t,s=i.touches,n=s&&s.length?s[0]:i,{offsetX:o,offsetY:a}=n;let r,l,h=!1;if(ve(o,a,i.target))r=o,l=a;else{const t=e.getBoundingClientRect();r=n.clientX-t.left,l=n.clientY-t.top,h=!0}return{x:r,y:l,box:h}}(t,i),d=a.left+(c&&r.left),u=a.top+(c&&r.top);let{width:f,height:g}=e;return o&&(f-=a.width+r.width,g-=a.height+r.height),{x:Math.round((l-d)/f*i.width/s),y:Math.round((h-u)/g*i.height/s)}}const Me=t=>Math.round(10*t)/10;function ke(t,e,i,s){const n=be(t),o=ye(n,"margin"),a=me(n.maxWidth,t,"clientWidth")||Mt,r=me(n.maxHeight,t,"clientHeight")||Mt,l=function(t,e,i){let s,n;if(void 0===e||void 0===i){const o=pe(t);if(o){const t=o.getBoundingClientRect(),a=be(o),r=ye(a,"border","width"),l=ye(a,"padding");e=t.width-l.width-r.width,i=t.height-l.height-r.height,s=me(a.maxWidth,o,"clientWidth"),n=me(a.maxHeight,o,"clientHeight")}else e=t.clientWidth,i=t.clientHeight}return{width:e,height:i,maxWidth:s||Mt,maxHeight:n||Mt}}(t,e,i);let{width:h,height:c}=l;if("content-box"===n.boxSizing){const t=ye(n,"border","width"),e=ye(n,"padding");h-=e.width+t.width,c-=e.height+t.height}return h=Math.max(0,h-o.width),c=Math.max(0,s?Math.floor(h/s):c-o.height),h=Me(Math.min(h,a,l.maxWidth)),c=Me(Math.min(c,r,l.maxHeight)),h&&!c&&(c=Me(h/2)),{width:h,height:c}}function Se(t,e,i){const s=e||1,n=Math.floor(t.height*s),o=Math.floor(t.width*s);t.height=n/s,t.width=o/s;const a=t.canvas;return a.style&&(i||!a.style.height&&!a.style.width)&&(a.style.height=`${t.height}px`,a.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(t.currentDevicePixelRatio=s,a.height=n,a.width=o,t.ctx.setTransform(s,0,0,s,0,0),!0)}const De=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}();function Pe(t,e){const i=xe(t,e),s=i&&i.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function Ce(t,e){return"native"in t?{x:t.x,y:t.y}:we(t,e)}function Oe(t,e,i,s){const{controller:n,data:o,_sorted:a}=t,r=n._cachedMeta.iScale;if(r&&e===r.axis&&a&&o.length){const t=r._reversePixels?le:re;if(!s)return t(o,e,i);if(n._sharedOptions){const s=o[0],n="function"==typeof s.getRange&&s.getRange(e);if(n){const s=t(o,e,i-n),a=t(o,e,i+n);return{lo:s.lo,hi:a.hi}}}}return{lo:0,hi:o.length-1}}function Te(t,e,i,s,n){const o=t.getSortedVisibleDatasetMetas(),a=i[e];for(let t=0,i=o.length;t{t[r](n[a],s)&&o.push({element:t,datasetIndex:e,index:i}),t.inRange(n.x,n.y,s)&&(l=!0)}),i.intersect&&!l?[]:o}var Ee={modes:{index(t,e,i,s){const n=Ce(e,t),o=i.axis||"x",a=i.intersect?Ae(t,n,o,s):Le(t,n,o,!1,s),r=[];return a.length?(t.getSortedVisibleDatasetMetas().forEach(t=>{const e=a[0].index,i=t.data[e];i&&!i.skip&&r.push({element:i,datasetIndex:t.index,index:e})}),r):[]},dataset(t,e,i,s){const n=Ce(e,t),o=i.axis||"xy";let a=i.intersect?Ae(t,n,o,s):Le(t,n,o,!1,s);if(a.length>0){const e=a[0].datasetIndex,i=t.getDatasetMeta(e).data;a=[];for(let t=0;tAe(t,Ce(e,t),i.axis||"xy",s),nearest:(t,e,i,s)=>Le(t,Ce(e,t),i.axis||"xy",i.intersect,s),x:(t,e,i,s)=>(i.axis="x",Re(t,e,i,s)),y:(t,e,i,s)=>(i.axis="y",Re(t,e,i,s))}};const Fe=new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/),Ie=new RegExp(/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/);function ze(t,e){const i=(""+t).match(Fe);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}const Ve=t=>+t||0;function Be(t,e){const i={},s=U(e),n=s?Object.keys(e):e,o=U(t)?s?i=>K(t[i],t[e[i]]):e=>t[e]:()=>t;for(const t of n)i[t]=Ve(o(t));return i}function We(t){return Be(t,{top:"y",right:"x",bottom:"y",left:"x"})}function Ne(t){return Be(t,["topLeft","topRight","bottomLeft","bottomRight"])}function He(t){const e=We(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function je(t,e){t=t||{},e=e||_t.font;let i=K(t.size,e.size);"string"==typeof i&&(i=parseInt(i,10));let s=K(t.style,e.style);s&&!(""+s).match(Ie)&&(console.warn('Invalid font style specified: "'+s+'"'),s="");const n={family:K(t.family,e.family),lineHeight:ze(K(t.lineHeight,e.lineHeight),i),size:i,style:s,weight:K(t.weight,e.weight),string:""};return n.string=Ut(n),n}function Ye(t,e,i,s){let n,o,a,r=!0;for(n=0,o=t.length;ni&&0===t?0:t+e;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function Ue(t,e){return Object.assign(Object.create(t),e)}const Xe=["left","top","right","bottom"];function qe(t,e){return t.filter(t=>t.pos===e)}function Ke(t,e){return t.filter(t=>-1===Xe.indexOf(t.pos)&&t.box.axis===e)}function Ge(t,e){return t.sort((t,i)=>{const s=e?i:t,n=e?t:i;return s.weight===n.weight?s.index-n.index:s.weight-n.weight})}function Ze(t,e){const i=function(t){const e={};for(const i of t){const{stack:t,pos:s,stackWeight:n}=i;if(!t||!Xe.includes(s))continue;const o=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=n}return e}(t),{vBoxMaxWidth:s,hBoxMaxHeight:n}=e;let o,a,r;for(o=0,a=t.length;o{s[t]=Math.max(e[t],i[t])}),s}return s(t?["left","right"]:["top","bottom"])}function ii(t,e,i,s){const n=[];let o,a,r,l,h,c;for(o=0,a=t.length,h=0;ot.box.fullSize),!0),s=Ge(qe(e,"left"),!0),n=Ge(qe(e,"right")),o=Ge(qe(e,"top"),!0),a=Ge(qe(e,"bottom")),r=Ke(e,"x"),l=Ke(e,"y");return{fullSize:i,leftAndTop:s.concat(o),rightAndBottom:n.concat(l).concat(a).concat(r),chartArea:qe(e,"chartArea"),vertical:s.concat(n).concat(l),horizontal:o.concat(a).concat(r)}}(t.boxes),l=r.vertical,h=r.horizontal;J(t.boxes,t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()});const c=l.reduce((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1,0)||1,d=Object.freeze({outerWidth:e,outerHeight:i,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/c,hBoxMaxHeight:a/2}),u=Object.assign({},n);Je(u,He(s));const f=Object.assign({maxPadding:u,w:o,h:a,x:n.left,y:n.top},n),g=Ze(l.concat(h),d);ii(r.fullSize,f,d,g),ii(l,f,d,g),ii(h,f,d,g)&&ii(l,f,d,g),function(t){const e=t.maxPadding;function i(i){const s=Math.max(e[i]-t[i],0);return t[i]+=s,s}t.y+=i("top"),t.x+=i("left"),i("right"),i("bottom")}(f),ni(r.leftAndTop,f,d,g),f.x+=f.w,f.y+=f.h,ni(r.rightAndBottom,f,d,g),t.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},J(r.chartArea,e=>{const i=e.box;Object.assign(i,t.chartArea),i.update(f.w,f.h)})}};function ai(t,e=[""],i=t,s,n=(()=>t[0])){return ut(s)||(s=bi("_fallback",t)),new Proxy({[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:i,_fallback:s,_getTarget:n,override:n=>ai([n,...t],e,i,s)},{deleteProperty:(e,i)=>(delete e[i],delete e._keys,delete t[0][i],!0),get:(i,s)=>di(i,s,()=>(function(t,e,i,s){let n;for(const o of e)if(n=bi(hi(o,t),i),ut(n))return ci(t,n)?pi(i,s,t,n):n})(s,e,t,i)),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>xi(t).includes(e),ownKeys:t=>xi(t),set:(t,e,i)=>((t._storage||(t._storage=n()))[e]=i,delete t[e],delete t._keys,!0)})}function ri(t,e,i,s){const n={_cacheable:!1,_proxy:t,_context:e,_subProxy:i,_stack:new Set,_descriptors:li(t,s),setContext:e=>ri(t,e,i,s),override:n=>ri(t.override(n),e,i,s)};return new Proxy(n,{deleteProperty:(e,i)=>(delete e[i],delete t[i],!0),get:(t,e,i)=>di(t,e,()=>(function(t,e,i){const{_proxy:s,_context:n,_subProxy:o,_descriptors:a}=t;let r=s[e];ft(r)&&a.isScriptable(e)&&(r=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_stack:r}=i;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);r.add(t),e=e(o,a||s),r.delete(t),U(e)&&(e=pi(n._scopes,n,t,e));return e}(e,r,t,i));$(r)&&r.length&&(r=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_descriptors:r}=i;if(ut(o.index)&&s(t))e=e[o.index%e.length];else if(U(e[0])){const i=e,s=n._scopes.filter(t=>t!==i);e=[];for(const l of i){const i=pi(s,n,t,l);e.push(ri(i,o,a&&a[t],r))}}return e}(e,r,t,a.isIndexable));ci(e,r)&&(r=ri(r,n,o&&o[e],a));return r})(t,e,i)),getOwnPropertyDescriptor:(e,i)=>e._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,i)=>Reflect.has(t,i),ownKeys:()=>Reflect.ownKeys(t),set:(e,i,s)=>(t[i]=s,delete e[i],!0)})}function li(t,e={scriptable:!0,indexable:!0}){const{_scriptable:i=e.scriptable,_indexable:s=e.indexable,_allKeys:n=e.allKeys}=t;return{allKeys:n,scriptable:i,indexable:s,isScriptable:ft(i)?i:()=>i,isIndexable:ft(s)?s:()=>s}}const hi=(t,e)=>t?t+dt(e):e,ci=(t,e)=>U(e)&&"adapters"!==t;function di(t,e,i){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];const s=i();return t[e]=s,s}function ui(t,e,i){return ft(t)?t(e,i):t}const fi=(t,e)=>!0===t?e:"string"==typeof t?ct(e,t):void 0;function gi(t,e,i,s){for(const n of e){const e=fi(i,n);if(e){t.add(e);const n=ui(e._fallback,i,e);if(ut(n)&&n!==i&&n!==s)return n}else if(!1===e&&ut(s)&&i!==s)return null}return!1}function pi(t,e,i,s){const n=e._rootScopes,o=ui(e._fallback,i,s),a=[...t,...n],r=new Set;r.add(s);let l=mi(r,a,i,o||i);return null!==l&&((!ut(o)||o===i||null!==(l=mi(r,a,o,l)))&&ai(Array.from(r),[""],n,o,()=>(function(t,e,i){const s=t._getTarget();e in s||(s[e]={});const n=s[e];if($(n)&&U(i))return i;return n})(e,i,s)))}function mi(t,e,i,s){for(;i;)i=gi(t,e,i,s);return i}function bi(t,e){for(const i of e){if(!i)continue;const e=i[t];if(ut(e))return e}}function xi(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const i of t)for(const t of Object.keys(i).filter(t=>!t.startsWith("_")))e.add(t);return Array.from(e)}(t._scopes)),e}const _i=Number.EPSILON||1e-14,yi=(t,e)=>e"x"===t?"y":"x";function wi(t,e,i,s){const n=t.skip?e:t,o=e,a=i.skip?e:i,r=Wt(o,n),l=Wt(a,o);let h=r/(r+l),c=l/(r+l);const d=s*(h=isNaN(h)?0:h),u=s*(c=isNaN(c)?0:c);return{previous:{x:o.x-d*(a.x-n.x),y:o.y-d*(a.y-n.y)},next:{x:o.x+u*(a.x-n.x),y:o.y+u*(a.y-n.y)}}}function Mi(t,e="x"){const i=vi(e),s=t.length,n=Array(s).fill(0),o=Array(s);let a,r,l,h=yi(t,0);for(a=0;a!t.skip)),"monotone"===e.cubicInterpolationMode)Mi(t,n);else{let i=s?t[t.length-1]:t[0];for(o=0,a=t.length;o0===t||1===t,Pi=(t,e,i)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*vt/i),Ci=(t,e,i)=>Math.pow(2,-10*t)*Math.sin((t-e)*vt/i)+1,Oi={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*St),easeOutSine:t=>Math.sin(t*St),easeInOutSine:t=>-.5*(Math.cos(yt*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>Di(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>Di(t)?t:Pi(t,.075,.3),easeOutElastic:t=>Di(t)?t:Ci(t,.075,.3),easeInOutElastic:t=>Di(t)?t:t<.5?.5*Pi(2*t,.1125,.45):.5+.5*Ci(2*t-1,.1125,.45),easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-Oi.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},easeInOutBounce:t=>t<.5?.5*Oi.easeInBounce(2*t):.5*Oi.easeOutBounce(2*t-1)+.5};function Ti(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:t.y+i*(e.y-t.y)}}function Ai(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:"middle"===s?i<.5?t.y:e.y:"after"===s?i<1?t.y:e.y:i>0?e.y:t.y}}function Li(t,e,i,s){const n={x:t.cp2x,y:t.cp2y},o={x:e.cp1x,y:e.cp1y},a=Ti(t,n,i),r=Ti(n,o,i),l=Ti(o,e,i),h=Ti(a,r,i),c=Ti(r,l,i);return Ti(h,c,i)}const Ri=new Map;function Ei(t,e,i){return function(t,e){e=e||{};const i=t+JSON.stringify(e);let s=Ri.get(i);return s||(s=new Intl.NumberFormat(t,e),Ri.set(i,s)),s}(e,i).format(t)}const Fi=function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}},Ii=function(){return{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}};function zi(t,e,i){return t?Fi(e,i):Ii()}function Vi(t,e){let i,s;"ltr"!==e&&"rtl"!==e||(s=[(i=t.canvas.style).getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=s)}function Bi(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Wi(t){return"angle"===t?{between:jt,compare:Nt,normalize:Ht}:{between:(t,e,i)=>t>=Math.min(e,i)&&t<=Math.max(i,e),compare:(t,e)=>t-e,normalize:t=>t}}function Ni({start:t,end:e,count:i,loop:s,style:n}){return{start:t%i,end:e%i,loop:s&&(e-t+1)%i==0,style:n}}function Hi(t,e,i){if(!i)return[t];const{property:s,start:n,end:o}=i,a=e.length,{compare:r,between:l,normalize:h}=Wi(s),{start:c,end:d,loop:u,style:f}=function(t,e,i){const{property:s,start:n,end:o}=i,{between:a,normalize:r}=Wi(s),l=e.length;let h,c,{start:d,end:u,loop:f}=t;if(f){for(d+=l,u+=l,h=0,c=l;hx||(()=>l(n,b,p)&&0!==r(n,b))(),v=()=>!x||(()=>0===r(o,p)||l(o,b,p))();for(let t=c,i=c;t<=d;++t)(m=e[t%a]).skip||(p=h(m[s]))!==b&&(x=l(p,n,o),null===_&&y()&&(_=0===r(p,n)?t:i),null!==_&&v()&&(g.push(Ni({start:_,end:t,loop:u,count:a,style:f})),_=null),i=t,b=p);return null!==_&&g.push(Ni({start:_,end:d,loop:u,count:a,style:f})),g}function ji(t,e){const i=[],s=t.segments;for(let n=0;nn&&t[o%e].skip;)o--;return{start:n,end:o%=e}}(i,n,o,s);return $i(t,!0===s?[{start:a,end:r,loop:o}]:function(t,e,i,s){const n=t.length,o=[];let a,r=e,l=t[e];for(a=e+1;a<=i;++a){const i=t[a%n];i.skip||i.stop?l.skip||(s=!1,o.push({start:e%n,end:(a-1)%n,loop:s}),e=r=i.stop?a:null):(r=a,l.skip&&(e=a)),l=i}return null!==r&&o.push({start:e%n,end:r%n,loop:s}),o}(i,a,rnull===t||""===t;const ts=!!De&&{passive:!0};function es(t,e,i){t.canvas.removeEventListener(e,i,ts)}function is(t,e,i){const s=t.canvas,n=new MutationObserver(t=>{for(const e of t)for(const t of e.addedNodes)if(t===s||t.contains(s))return i()});return n.observe(document,{childList:!0,subtree:!0}),n}function ss(t,e,i){const s=t.canvas,n=new MutationObserver(t=>{for(const e of t)for(const t of e.removedNodes)if(t===s||t.contains(s))return i()});return n.observe(document,{childList:!0,subtree:!0}),n}const ns=new Map;let os=0;function as(){const t=window.devicePixelRatio;t!==os&&(os=t,ns.forEach((e,i)=>{i.currentDevicePixelRatio!==t&&e()}))}function rs(t,i,s){const n=t.canvas,o=n&&pe(n);if(!o)return;const a=e((t,e)=>{const i=o.clientWidth;s(t,e),i{const e=t[0],i=e.contentRect.width,s=e.contentRect.height;0===i&&0===s||a(i,s)});return r.observe(o),function(t,e){ns.size||window.addEventListener("resize",as),ns.set(t,e)}(t,a),r}function ls(t,e,i){i&&i.disconnect(),"resize"===e&&function(t){ns.delete(t),ns.size||window.removeEventListener("resize",as)}(t)}function hs(t,i,s){const n=t.canvas,o=e(e=>{null!==t.ctx&&s(function(t,e){const i=Qi[t.type]||t.type,{x:s,y:n}=we(t,e);return{type:i,chart:e,native:t,x:void 0!==s?s:null,y:void 0!==n?n:null}}(e,t))},t,t=>{const e=t[0];return[e,e.offsetX,e.offsetY]});return function(t,e,i){t.addEventListener(e,i,ts)}(n,i,o),o}class cs extends Ki{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(function(t,e){const i=t.style,s=t.getAttribute("height"),n=t.getAttribute("width");if(t[Zi]={initial:{height:s,width:n,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",Ji(n)){const e=Pe(t,"width");void 0!==e&&(t.width=e)}if(Ji(s))if(""===t.style.height)t.height=t.width/(e||2);else{const e=Pe(t,"height");void 0!==e&&(t.height=e)}}(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e[Zi])return!1;const i=e[Zi].initial;["height","width"].forEach(t=>{const s=i[t];Y(s)?e.removeAttribute(t):e.setAttribute(t,s)});const s=i.style||{};return Object.keys(s).forEach(t=>{e.style[t]=s[t]}),e.width=e.width,delete e[Zi],!0}addEventListener(t,e,i){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),n={attach:is,detach:ss,resize:rs}[e]||hs;s[e]=n(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];s&&(({attach:ls,detach:ls,resize:ls}[e]||es)(t,e,s),i[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return ke(t,e,i,s)}isAttached(t){const e=pe(t);return!(!e||!e.isConnected)}}function ds(t){return!ge()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?Gi:cs}var us=Object.freeze({__proto__:null,_detectPlatform:ds,BasePlatform:Ki,BasicPlatform:Gi,DomPlatform:cs});const fs={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const s=W(t||"transparent"),n=s.valid&&W(e||"transparent");return n&&n.valid?n.mix(s,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class gs{constructor(t,e,i,s){const n=e[i];s=Ye([t.to,s,n,t.from]);const o=Ye([t.from,n,s]);this._active=!0,this._fn=t.fn||fs[t.type||typeof o],this._easing=Oi[t.easing]||Oi.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=o,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const s=this._target[this._prop],n=i-this._start,o=this._duration-n;this._start=i,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=n,this._loop=!!t.loop,this._to=Ye([t.to,e,s,t.from]),this._from=Ye([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,s=this._prop,n=this._from,o=this._loop,a=this._to;let r;if(this._active=n!==a&&(o||e1?2-r:r,r=this._easing(Math.min(1,Math.max(0,r))),this._target[s]=this._fn(n,a,r))}wait(){const t=this._promises||(this._promises=[]);return new Promise((e,i)=>{t.push({res:e,rej:i})})}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let t=0;t"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),_t.set("animations",{colors:{type:"color",properties:["color","borderColor","backgroundColor"]},numbers:{type:"number",properties:["x","y","borderWidth","radius","tension"]}}),_t.describe("animations",{_fallback:"animation"}),_t.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}});class ms{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!U(t))return;const e=this._properties;Object.getOwnPropertyNames(t).forEach(i=>{const s=t[i];if(!U(s))return;const n={};for(const t of ps)n[t]=s[t];($(s.properties)&&s.properties||[i]).forEach(t=>{t!==i&&e.has(t)||e.set(t,n)})})}_animateOptions(t,e){const i=e.options,s=function(t,e){if(!e)return;let i=t.options;if(!i)return void(t.options=e);i.$shared&&(t.options=i=Object.assign({},i,{$shared:!1,$animations:{}}));return i}(t,i);if(!s)return[];const n=this._createAnimations(s,i);return i.$shared&&function(t,e){const i=[],s=Object.keys(e);for(let e=0;e{t.options=i},()=>{}),n}_createAnimations(t,e){const i=this._properties,s=[],n=t.$animations||(t.$animations={}),o=Object.keys(e),a=Date.now();let r;for(r=o.length-1;r>=0;--r){const l=o[r];if("$"===l.charAt(0))continue;if("options"===l){s.push(...this._animateOptions(t,e));continue}const h=e[l];let c=n[l];const d=i.get(l);if(c){if(d&&c.active()){c.update(d,h,a);continue}c.cancel()}d&&d.duration?(n[l]=c=new gs(d,t,l,h),s.push(c)):t[l]=h}return s}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(a.add(this._chart,i),!0):void 0}}function bs(t,e){const i=t&&t.options||{},s=i.reverse,n=void 0===i.min?e:0,o=void 0===i.max?e:0;return{start:s?o:n,end:s?n:o}}function xs(t,e){const i=[],s=t._getSortedDatasetMetas(e);let n,o;for(n=0,o=s.length;n0||!i&&e<0)return n.index}return null}function Ms(t,e){const{chart:i,_cachedMeta:s}=t,n=i._stacks||(i._stacks={}),{iScale:o,vScale:a,index:r}=s,l=o.axis,h=a.axis,c=function(t,e,i){return`${t.id}.${e.id}.${i.stack||i.type}`}(o,a,s),d=e.length;let u;for(let t=0;ti[t].axis===e).shift()}function Ss(t,e){const i=t.controller.index,s=t.vScale&&t.vScale.axis;if(s){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[s]||void 0===e[s][i])return;delete e[s][i]}}}const Ds=t=>"reset"===t||"none"===t,Ps=(t,e)=>e?t:Object.assign({},t),Cs=(t,e,i)=>t&&!e.hidden&&e._stacked&&{keys:xs(i,!0),values:null};class Os{constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.$context=void 0,this._syncList=[],this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=ys(t.vScale,t),this.addElements()}updateIndex(t){this.index!==t&&Ss(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(t,e,i,s)=>"x"===t?e:"r"===t?s:i,n=e.xAxisID=K(i.xAxisID,ks(t,"x")),o=e.yAxisID=K(i.yAxisID,ks(t,"y")),a=e.rAxisID=K(i.rAxisID,ks(t,"r")),r=e.indexAxis,l=e.iAxisID=s(r,n,o,a),h=e.vAxisID=s(r,o,n,a);e.xScale=this.getScaleForId(n),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(l),e.vScale=this.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&ue(this._data,this),t._stacked&&Ss(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(U(e))this._data=function(t){const e=Object.keys(t),i=new Array(e.length);let s,n,o;for(s=0,n=e.length;s0&&i._parsed[t-1];if(!1===this._parsing)i._parsed=s,i._sorted=!0,h=s;else{h=$(s[t])?this.parseArrayData(i,s,t,e):U(s[t])?this.parseObjectData(i,s,t,e):this.parsePrimitiveData(i,s,t,e);const n=()=>null===l[a]||d&&l[a]e||c=0;--d)if(!f()){this.updateRangeFromParsed(l,t,u,r);break}return l}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,n,o;for(s=0,n=e.length;s=0&&tthis.getContext(i,s),c);return f.$shared&&(f.$shared=r,n[o]=Object.freeze(Ps(f,r))),f}_resolveAnimations(t,e,i){const s=this.chart,n=this._cachedDataOpts,o=`animation-${e}`,a=n[o];if(a)return a;let r;if(!1!==s.options.animation){const s=this.chart.config,n=s.datasetAnimationScopeKeys(this._type,e),o=s.getOptionScopes(this.getDataset(),n);r=s.createResolver(o,this.getContext(t,i,e))}const l=new ms(s,r&&r.animations);return r&&r._cacheable&&(n[o]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Ds(t)||this.chart._animationsDisabled}updateElement(t,e,i,s){Ds(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!Ds(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,s){t.active=s;const n=this.getStyle(e,s);this._resolveAnimations(e,i,s).update(t,{options:!s&&this.getSharedOptions(n)||n})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,i=this._cachedMeta.data;for(const[t,e,i]of this._syncList)this[t](e,i);this._syncList=[];const s=i.length,n=e.length,o=Math.min(n,s);o&&this.parse(0,o),n>s?this._insertElements(s,n-s,t):n{for(t.length+=e,a=t.length-1;a>=o;a--)t[a]=t[a-e]};for(r(n),a=t;a{s[t]=i[t]&&i[t].active()?i[t]._to:this[t]}),s}}Ts.defaults={},Ts.defaultRoutes=void 0;const As={values:t=>$(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const s=this.chart.options.locale;let n,o=t;if(i.length>1){const e=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));(e<1e-4||e>1e15)&&(n="scientific"),o=function(t,e){let i=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;Math.abs(i)>=1&&t!==Math.floor(t)&&(i=t-Math.floor(t));return i}(t,i)}const a=Ct(Math.abs(o)),r=Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:n,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),Ei(t,s,l)},logarithmic(t,e,i){if(0===t)return"0";const s=t/Math.pow(10,Math.floor(Ct(t)));return 1===s||2===s||5===s?As.numeric.call(this,t,e,i):""}};var Ls={formatters:As};function Rs(t,e){const i=t.options.ticks,s=i.maxTicksLimit||function(t){const e=t.options.offset,i=t._tickSize(),s=t._length/i+(e?0:1),n=t._maxLength/i;return Math.floor(Math.min(s,n))}(t),n=i.major.enabled?function(t){const e=[];let i,s;for(i=0,s=t.length;is)return function(t,e,i,s){let n,o=0,a=i[0];for(s=Math.ceil(s),n=0;nn)return e}return Math.max(n,1)}(n,e,s);if(o>0){let t,i;const s=o>1?Math.round((r-a)/(o-1)):null;for(Es(e,l,h,Y(s)?0:a-s,a),t=0,i=o-1;te.lineWidth,tickColor:(t,e)=>e.color,offset:!1,borderDash:[],borderDashOffset:0,borderWidth:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Ls.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),_t.route("scale.ticks","color","","color"),_t.route("scale.grid","color","","borderColor"),_t.route("scale.grid","borderColor","","borderColor"),_t.route("scale.title","color","","color"),_t.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t}),_t.describe("scales",{_fallback:"scale"}),_t.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t});const Fs=t=>"left"===t?"right":"right"===t?"left":t,Is=(t,e,i)=>"top"===e||"left"===e?t[e]+i:t[e]-i;function zs(t,e){const i=[],s=t.length/e,n=t.length;let o=0;for(;oa+1e-6)))return l}function Bs(t){return t.drawTicks?t.tickLength:0}function Ws(t,e){if(!t.display)return 0;const i=je(t.font,e),s=He(t.padding);return($(t.text)?t.text.length:1)*i.lineHeight+s.height}function Ns(t,e,i){let n=s(t);return(i&&"right"!==e||!i&&"right"===e)&&(n=Fs(n)),n}class Hs extends Ts{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:i,_suggestedMax:s}=this;return t=q(t,Number.POSITIVE_INFINITY),e=q(e,Number.NEGATIVE_INFINITY),i=q(i,Number.POSITIVE_INFINITY),s=q(s,Number.NEGATIVE_INFINITY),{min:q(t,i),max:q(e,s),minDefined:X(t),maxDefined:X(e)}}getMinMax(t){let e,{min:i,max:s,minDefined:n,maxDefined:o}=this.getUserBounds();if(n&&o)return{min:i,max:s};const a=this.getMatchingVisibleMetas();for(let r=0,l=a.length;rs?s:i,q(s=n&&i>s?i:s,i)),max:q(s,q(i,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){Q(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:n,ticks:o}=this.options,a=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=$e(this,n,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const r=a=n||i<=1||!this.isHorizontal())return void(this.labelRotation=s);const h=this._getLabelSizes(),c=h.widest.width,d=h.highest.height,u=Yt(this.chart.width-c,0,this.maxWidth);c+6>(o=t.offset?this.maxWidth/i:u/(i-1))&&(o=u/(i-(t.offset?.5:1)),a=this.maxHeight-Bs(t.grid)-e.padding-Ws(t.title,this.chart.options.font),r=Math.sqrt(c*c+d*d),l=zt(Math.min(Math.asin(Yt((h.highest.height+6)/o,-1,1)),Math.asin(Yt(a/r,-1,1))-Math.asin(Yt(d/r,-1,1)))),l=Math.max(s,Math.min(n,l))),this.labelRotation=l}afterCalculateLabelRotation(){Q(this.options.afterCalculateLabelRotation,[this])}beforeFit(){Q(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:n}}=this,o=this._isVisible(),a=this.isHorizontal();if(o){const o=Ws(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=Bs(n)+o):(t.height=this.maxHeight,t.width=Bs(n)+o),i.display&&this.ticks.length){const{first:e,last:s,widest:n,highest:o}=this._getLabelSizes(),r=2*i.padding,l=It(this.labelRotation),h=Math.cos(l),c=Math.sin(l);if(a){const e=i.mirror?0:c*n.width+h*o.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=i.mirror?0:h*n.width+c*o.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,s,c,h)}}this._handleMargins(),a?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,s){const{ticks:{align:n,padding:o},position:a}=this.options,r=0!==this.labelRotation,l="top"!==a&&"x"===this.axis;if(this.isHorizontal()){const a=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1);let c=0,d=0;r?l?(c=s*t.width,d=i*e.height):(c=i*t.height,d=s*e.width):"start"===n?d=e.width:"end"===n?c=t.width:(c=t.width/2,d=e.width/2),this.paddingLeft=Math.max((c-a+o)*this.width/(this.width-a),0),this.paddingRight=Math.max((d-h+o)*this.width/(this.width-h),0)}else{let i=e.height/2,s=t.height/2;"start"===n?(i=0,s=t.height):"end"===n&&(i=e.height,s=0),this.paddingTop=i+o,this.paddingBottom=s+o}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){Q(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,i;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,i=t.length;e{const i=t.gc,s=i.length/2;let n;if(s>e){for(n=0;n({width:n[t]||0,height:o[t]||0});return{first:v(0),last:v(e-1),widest:v(_),highest:v(y),widths:n,heights:o}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return $t(this._alignToPixels?Kt(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&ta*s?a/i:r/s:r*s0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:n,position:o}=s,a=n.offset,r=this.isHorizontal(),l=this.ticks.length+(a?1:0),h=Bs(n),c=[],d=n.setContext(this.getContext()),u=d.drawBorder?d.borderWidth:0,f=u/2,g=function(t){return Kt(i,t,u)};let p,m,b,x,_,y,v,w,M,k,S,D;if("top"===o)p=g(this.bottom),y=this.bottom-h,w=p-f,k=g(t.top)+f,D=t.bottom;else if("bottom"===o)p=g(this.top),k=t.top,D=g(t.bottom)-f,y=p+f,w=this.top+h;else if("left"===o)p=g(this.right),_=this.right-h,v=p-f,M=g(t.left)+f,S=t.right;else if("right"===o)p=g(this.left),M=t.left,S=g(t.right)-f,_=p+f,v=this.left+h;else if("x"===e){if("center"===o)p=g((t.top+t.bottom)/2+.5);else if(U(o)){const t=Object.keys(o)[0],e=o[t];p=g(this.chart.scales[t].getPixelForValue(e))}k=t.top,D=t.bottom,w=(y=p+f)+h}else if("y"===e){if("center"===o)p=g((t.left+t.right)/2);else if(U(o)){const t=Object.keys(o)[0],e=o[t];p=g(this.chart.scales[t].getPixelForValue(e))}v=(_=p-f)-h,M=t.left,S=t.right}const P=K(s.ticks.maxTicksLimit,l),C=Math.max(1,Math.ceil(l/P));for(m=0;me.value===t);if(i>=0){return e.setContext(this.getContext(i)).lineWidth}return 0}drawGrid(t){const e=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let n,o;const a=(t,e,s)=>{s.width&&s.color&&(i.save(),i.lineWidth=s.width,i.strokeStyle=s.color,i.setLineDash(s.borderDash||[]),i.lineDashOffset=s.borderDashOffset,i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke(),i.restore())};if(e.display)for(n=0,o=s.length;n{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:i+1,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let n,o;for(n=0,o=e.length;n{const s=i.split("."),n=s.pop(),o=[t].concat(s).join("."),a=e[i].split("."),r=a.pop(),l=a.join(".");_t.route(o,n,l,r)})}(e,t.defaultRoutes);t.descriptors&&_t.describe(e,t.descriptors)}(t,o,i),this.override&&_t.override(t.id,t.overrides),o)}get(t){return this.items[t]}unregister(t){const e=this.items,i=t.id,s=this.scope;i in e&&delete e[i],s&&i in _t[s]&&(delete _t[s][i],this.override&&delete pt[i])}}var Ys=new class{constructor(){this.controllers=new js(Os,"datasets",!0),this.elements=new js(Ts,"elements"),this.plugins=new js(Object,"plugins"),this.scales=new js(Hs,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){[...e].forEach(e=>{const s=i||this._getRegistryForType(e);i||s.isForType(e)||s===this.plugins&&e.id?this._exec(t,s,e):J(e,e=>{const s=i||this._getRegistryForType(e);this._exec(t,s,e)})})}_exec(t,e,i){const s=dt(t);Q(i["before"+s],[],i),e[t](i),Q(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;et.filter(t=>!e.some(e=>t.plugin.id===e.plugin.id));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function Us(t,e){return e||!1!==t?!0===t?{}:t:null}function Xs(t,e,i,s){const n=t.pluginScopeKeys(e),o=t.getOptionScopes(i,n);return t.createResolver(o,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function qs(t,e){const i=_t.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function Ks(t,e){return"x"===t||"y"===t?t:e.axis||("top"===(i=e.position)||"bottom"===i?"x":"left"===i||"right"===i?"y":void 0)||t.charAt(0).toLowerCase();var i}function Gs(t){const e=t.options||(t.options={});e.plugins=K(e.plugins,{}),e.scales=function(t,e){const i=pt[t.type]||{scales:{}},s=e.scales||{},n=qs(t.type,e),o=Object.create(null),a=Object.create(null);return Object.keys(s).forEach(t=>{const e=s[t];if(!U(e))return console.error(`Invalid scale configuration for scale: ${t}`);if(e._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);const r=Ks(t,e),l=function(t,e){return t===e?"_index_":"_value_"}(r,n),h=i.scales||{};o[r]=o[r]||t,a[t]=ot(Object.create(null),[{axis:r},e,h[r],h[l]])}),t.data.datasets.forEach(i=>{const n=i.type||t.type,r=i.indexAxis||qs(n,e),l=(pt[n]||{}).scales||{};Object.keys(l).forEach(t=>{const e=function(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}(t,r),n=i[e+"AxisID"]||o[e]||e;a[n]=a[n]||Object.create(null),ot(a[n],[{axis:e},s[n],l[t]])})}),Object.keys(a).forEach(t=>{const e=a[t];ot(e,[_t.scales[e.type],_t.scale])}),a}(t,e)}function Zs(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const Qs=new Map,Js=new Set;function tn(t,e){let i=Qs.get(t);return i||(i=e(),Qs.set(t,i),Js.add(i)),i}const en=(t,e,i)=>{const s=ct(e,i);void 0!==s&&t.add(s)};class sn{constructor(t){this._config=function(t){return(t=t||{}).data=Zs(t.data),Gs(t),t}(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Zs(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Gs(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return tn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return tn(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return tn(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id;return tn(`${this.type}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){const i=this._scopeCache;let s=i.get(t);return s&&!e||(s=new Map,i.set(t,s)),s}getOptionScopes(t,e,i){const{options:s,type:n}=this,o=this._cachedScopes(t,i),a=o.get(e);if(a)return a;const r=new Set;e.forEach(e=>{t&&(r.add(t),e.forEach(e=>en(r,t,e))),e.forEach(t=>en(r,s,t)),e.forEach(t=>en(r,pt[n]||{},t)),e.forEach(t=>en(r,_t,t)),e.forEach(t=>en(r,mt,t))});const l=Array.from(r);return 0===l.length&&l.push(Object.create(null)),Js.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,pt[e]||{},_t.datasets[e]||{},{type:e},_t,mt]}resolveNamedOptions(t,e,i,s=[""]){const n={$shared:!0},{resolver:o,subPrefixes:a}=nn(this._resolverCache,t,s);let r=o;if(function(t,e){const{isScriptable:i,isIndexable:s}=li(t);for(const n of e){const e=i(n),o=s(n),a=(o||e)&&t[n];if(e&&(ft(a)||on(a))||o&&$(a))return!0}return!1}(o,e)){n.$shared=!1,r=ri(o,i=ft(i)?i():i,this.createResolver(t,i,a))}for(const t of e)n[t]=r[t];return n}createResolver(t,e,i=[""],s){const{resolver:n}=nn(this._resolverCache,t,i);return U(e)?ri(n,e,void 0,s):n}}function nn(t,e,i){let s=t.get(e);s||(s=new Map,t.set(e,s));const n=i.join();let o=s.get(n);if(!o){o={resolver:ai(e,i),subPrefixes:i.filter(t=>!t.toLowerCase().includes("hover"))},s.set(n,o)}return o}const on=t=>U(t)&&Object.getOwnPropertyNames(t).reduce((e,i)=>e||ft(t[i]),!1);const an=["top","bottom","left","right","chartArea"];function rn(t,e){return"top"===t||"bottom"===t||-1===an.indexOf(t)&&"x"===e}function ln(t,e){return function(i,s){return i[t]===s[t]?i[e]-s[e]:i[t]-s[t]}}function hn(t){const e=t.chart,i=e.options.animation;e.notifyPlugins("afterRender"),Q(i&&i.onComplete,[t],e)}function cn(t){const e=t.chart,i=e.options.animation;Q(i&&i.onProgress,[t],e)}function dn(t){return ge()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const un={},fn=t=>{const e=dn(t);return Object.values(un).filter(t=>t.canvas===e).pop()};class gn{constructor(t,e){const s=this.config=new sn(e),n=dn(t),o=fn(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas can be reused.");const r=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||ds(n)),this.platform.updateConfig(s);const l=this.platform.acquireContext(n,r.aspectRatio),h=l&&l.canvas,c=h&&h.height,d=h&&h.width;this.id=j(),this.ctx=l,this.canvas=h,this.width=d,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new $s,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=i(t=>this.update(t),r.resizeDelay||0),un[this.id]=this,l&&h?(a.listen(this,"complete",hn),a.listen(this,"progress",cn),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:s,_aspectRatio:n}=this;return Y(t)?e&&n?n:s?i/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Se(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Gt(this.canvas,this.ctx),this}stop(){return a.stop(this),this}resize(t,e){a.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,s=this.canvas,n=i.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(s,t,e,n),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,Se(this,a,!0)&&(this.notifyPlugins("resize",{size:o}),Q(i.onResize,[this,o],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){J(this.options.scales||{},(t,e)=>{t.id=e})}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce((t,e)=>(t[e]=!1,t),{});let n=[];e&&(n=n.concat(Object.keys(e).map(t=>{const i=e[t],s=Ks(t,i),n="r"===s,o="x"===s;return{options:i,dposition:n?"chartArea":o?"bottom":"left",dtype:n?"radialLinear":o?"category":"linear"}}))),J(n,e=>{const n=e.options,o=n.id,a=Ks(o,n),r=K(n.type,e.dtype);void 0!==n.position&&rn(n.position,a)===rn(e.dposition)||(n.position=e.dposition),s[o]=!0;let l=null;if(o in i&&i[o].type===r)l=i[o];else{l=new(Ys.getScale(r))({id:o,type:r,ctx:this.ctx,chart:this}),i[l.id]=l}l.init(n,t)}),J(s,(t,e)=>{t||delete i[e]}),J(i,t=>{oi.configure(this,t,t.options),oi.addBox(this,t)})}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort((t,e)=>t.index-e.index),i>e){for(let t=e;te.length&&delete this._stacks,t.forEach((t,i)=>{0===e.filter(e=>e===t._dataset).length&&this._destroyDatasetMeta(i)})}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=e.length;i{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext());J(this.scales,t=>{oi.removeBox(this,t)});const s=this._animationsDisabled=!i.animation;this.ensureScalesHaveIDs(),this.buildOrUpdateScales();const n=new Set(Object.keys(this._listeners)),o=new Set(i.events);if(gt(n,o)&&!!this._responsiveListeners===i.responsive||(this.unbindEvents(),this.bindEvents()),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const a=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let t=0,e=this.data.datasets.length;t{t.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(ln("z","_idx")),this._lastEvent&&this._eventHandler(this._lastEvent,!0),this.render()}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;oi.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],J(this.boxes,t=>{i&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))},this),this._layers.forEach((t,e)=>{t._idx=e}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let e=0,i=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,s=!i.disabled,n=this.chartArea,o={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",o)&&(s&&Jt(e,{left:!1===i.left?0:n.left-i.left,right:!1===i.right?this.width:n.right+i.right,top:!1===i.top?0:n.top-i.top,bottom:!1===i.bottom?this.height:n.bottom+i.bottom}),t.controller.draw(),s&&te(e),o.cancelable=!1,this.notifyPlugins("afterDatasetDraw",o))}getElementsAtEventForMode(t,e,i,s){const n=Ee.modes[e];return"function"==typeof n?n(this,t,i,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let s=i.filter(t=>t&&t._dataset===e).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=Ue(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",n=this.getDatasetMeta(t),o=n.controller._resolveAnimations(void 0,s);ut(e)?(n.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),o.update(n,{visible:i}),this.update(e=>e.datasetIndex===t?s:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),a.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,i,s),t[i]=s},s=(t,e,i)=>{t.offsetX=e,t.offsetY=i,this._eventHandler(t)};J(this.options.events,t=>i(t,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(i,s)=>{e.addEventListener(this,i,s),t[i]=s},s=(i,s)=>{t[i]&&(e.removeEventListener(this,i,s),delete t[i])},n=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",n),i("detach",o)};o=(()=>{this.attached=!1,s("resize",n),this._stop(),this._resize(0,0),i("attach",a)}),e.isAttached(this.canvas)?a():o()}unbindEvents(){J(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},J(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const s=i?"set":"remove";let n,o,a,r;for("dataset"===e&&(n=this.getDatasetMeta(t[0].datasetIndex)).controller["_"+s+"DatasetHoverStyle"](),a=0,r=t.length;a{const i=this.getDatasetMeta(t);if(!i)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:i.data[e],index:e}});!tt(i,e)&&(this._active=i,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}_updateHoverStyles(t,e,i){const s=this.options.hover,n=(t,e)=>t.filter(t=>!e.some(e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)),o=n(e,t),a=i?t:n(t,e);o.length&&this.updateHoverStyle(o,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0},s=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",i,s))return;const n=this._handleEvent(t,e);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(n||i.changed)&&this.render(),this}_handleEvent(t,e){const{_active:i=[],options:s}=this,n=s.hover,o=e;let a=[],r=!1,l=null;return"mouseout"!==t.type&&(a=this.getElementsAtEventForMode(t,n.mode,n,o),l="click"===t.type?this._lastEvent:t),this._lastEvent=null,Qt(t,this.chartArea,this._minPadding)&&(Q(s.onHover,[t,a,this],this),"mouseup"!==t.type&&"click"!==t.type&&"contextmenu"!==t.type||Q(s.onClick,[t,a,this],this)),((r=!tt(a,i))||e)&&(this._active=a,this._updateHoverStyles(a,i,e)),this._lastEvent=l,r}}const pn=()=>J(gn.instances,t=>t._plugins.invalidate());function mn(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}Object.defineProperties(gn,{defaults:{enumerable:!0,value:_t},instances:{enumerable:!0,value:un},overrides:{enumerable:!0,value:pt},registry:{enumerable:!0,value:Ys},version:{enumerable:!0,value:"3.6.0"},getChart:{enumerable:!0,value:fn},register:{enumerable:!0,value:(...t)=>{Ys.add(...t),pn()}},unregister:{enumerable:!0,value:(...t)=>{Ys.remove(...t),pn()}}});class bn{constructor(t){this.options=t||{}}formats(){return mn()}parse(t,e){return mn()}format(t,e){return mn()}add(t,e,i){return mn()}diff(t,e,i){return mn()}startOf(t,e,i){return mn()}endOf(t,e){return mn()}}bn.override=function(t){Object.assign(bn.prototype,t)};var xn={_date:bn};function _n(t){const e=t.iScale,i=function(t,e){if(!t._cache.$bar){const i=t.getMatchingVisibleMetas(e);let s=[];for(let e=0,n=i.length;et-e))}return t._cache.$bar}(e,t.type);let s,n,o,a,r=e._length;const l=()=>{32767!==o&&-32768!==o&&(ut(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(s=0,n=i.length;sMath.abs(r)&&(l=r,h=a),e[i.axis]=h,e._custom={barStart:l,barEnd:h,start:n,end:o,min:a,max:r}}(t,e,i,s):e[i.axis]=i.parse(t,s),e}function vn(t,e,i,s){const n=t.iScale,o=t.vScale,a=n.getLabels(),r=n===o,l=[];let h,c,d,u;for(h=i,c=i+s;ht.x,i="left",s="right"):(e=t.base=i?1:-1)}(c,e,o)*n,d===o&&(p-=c/2),h=p+c),p===e.getPixelForValue(o)){const t=Ot(c)*e.getLineWidthForValue(o)/2;p+=t,c-=t}return{size:c,base:p,head:h,center:h+c/2}}_calculateBarIndexPixels(t,e){const i=e.scale,s=this.options,n=s.skipNull,o=K(s.maxBarThickness,1/0);let a,r;if(e.grouped){const i=n?this._getStackCount(t):e.stackCount,l="flex"===s.barThickness?function(t,e,i,s){const n=e.pixels,o=n[t];let a=t>0?n[t-1]:null,r=t=0;--i)e=Math.max(e,t[i].size(this.resolveDataElementOptions(i))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,{xScale:i,yScale:s}=e,n=this.getParsed(t),o=i.getLabelForValue(n.x),a=s.getLabelForValue(n.y),r=n._custom;return{label:e.label,value:"("+o+", "+a+(r?", "+r:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a}=this._cachedMeta,r=this.resolveDataElementOptions(e,s),l=this.getSharedOptions(r),h=this.includeOptions(s,l),c=o.axis,d=a.axis;for(let r=e;r""}}}};class On extends Os{constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,s=this._cachedMeta;if(!1===this._parsing)s._parsed=i;else{let n,o,a=t=>+i[t];if(U(i[t])){const{key:t="value"}=this._parsing;a=(e=>+ct(i[e],t))}for(n=t,o=t+e;njt(t,r,l,!0)?1:Math.max(e,e*i,s,s*i),g=(t,e,s)=>jt(t,r,l,!0)?-1:Math.min(e,e*i,s,s*i),p=f(0,h,d),m=f(St,c,u),b=g(yt,h,d),x=g(yt+St,c,u);s=(p-b)/2,n=(m-x)/2,o=-(p+b)/2,a=-(m+x)/2}return{ratioX:s,ratioY:n,offsetX:o,offsetY:a}}(c,h,r),p=(i.width-o)/d,m=(i.height-o)/u,b=Math.max(Math.min(p,m)/2,0),x=Z(this.options.radius,b),_=(x-Math.max(x*r,0))/this._getVisibleDatasetWeightTotal();this.offsetX=f*x,this.offsetY=g*x,s.total=this.calculateTotal(),this.outerRadius=x-_*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-_*l,0),this.updateElements(n,0,n.length,t)}_circumference(t,e){const i=this.options,s=this._cachedMeta,n=this._getCircumference();return e&&i.animation.animateRotate||!this.chart.getDataVisibility(t)||null===s._parsed[t]||s.data[t].hidden?0:this.calculateCircumference(s._parsed[t]*n/vt)}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.chartArea,r=o.options.animation,l=(a.left+a.right)/2,h=(a.top+a.bottom)/2,c=n&&r.animateScale,d=c?0:this.innerRadius,u=c?0:this.outerRadius,f=this.resolveDataElementOptions(e,s),g=this.getSharedOptions(f),p=this.includeOptions(s,g);let m,b=this._getRotation();for(m=0;m0&&!isNaN(t)?vt*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=Ei(e._parsed[t],i.options.locale);return{label:s[t]||"",value:n}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,n,o,a,r;if(!t)for(s=0,n=i.data.datasets.length;s"spacing"!==t,_indexable:t=>"spacing"!==t},On.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label(t){let e=t.label;const i=": "+t.formattedValue;return $(e)?(e=e.slice())[0]+=i:e+=i,e}}}}};class Tn extends Os{initialize(){this.enableOptionSharing=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:i,data:s=[],_dataset:n}=e,o=this.chart._animationsDisabled;let{start:a,count:r}=function(t,e,i){const s=e.length;let n=0,o=s;if(t._sorted){const{iScale:a,_parsed:r}=t,l=a.axis,{min:h,max:c,minDefined:d,maxDefined:u}=a.getUserBounds();d&&(n=Yt(Math.min(re(r,a.axis,h).lo,i?s:re(e,l,a.getPixelForValue(h)).lo),0,s-1)),o=u?Yt(Math.max(re(r,a.axis,c).hi+1,i?0:re(e,l,a.getPixelForValue(c)).hi+1),n,s)-n:s-n}return{start:n,count:o}}(e,s,o);this._drawStart=a,this._drawCount=r,function(t){const{xScale:e,yScale:i,_scaleRanges:s}=t,n={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!s)return t._scaleRanges=n,!0;const o=s.xmin!==e.min||s.xmax!==e.max||s.ymin!==i.min||s.ymax!==i.max;return Object.assign(s,n),o}(e)&&(a=0,r=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!n._decimated,i.points=s;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(i,void 0,{animated:!o,options:l},t),this.updateElements(s,a,r,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,h=this.resolveDataElementOptions(e,s),c=this.getSharedOptions(h),d=this.includeOptions(s,c),u=o.axis,f=a.axis,{spanGaps:g,segment:p}=this.options,m=Lt(g)?g:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||n||"none"===s;let x=e>0&&this.getParsed(e-1);for(let h=e;h0&&i[u]-x[u]>m,p&&(g.parsed=i,g.raw=l.data[h]),d&&(g.options=c||this.resolveDataElementOptions(h,e.active?"active":s)),b||this.updateElement(e,h,g,s),x=i}this.updateSharedOptions(c,s,h)}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,n,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}Tn.id="line",Tn.defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1},Tn.overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};class An extends Os{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=Ei(e._parsed[t].r,i.options.locale);return{label:s[t]||"",value:n}}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),n=Math.max(s/2,0),o=(n-Math.max(i.cutoutPercentage?n/100*i.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=n-o*this.index,this.innerRadius=this.outerRadius-o}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=this.getDataset(),r=o.options.animation,l=this._cachedMeta.rScale,h=l.xCenter,c=l.yCenter,d=l.getIndexAngle(0)-.5*yt;let u,f=d;const g=360/this.countVisibleElements();for(u=0;u{!isNaN(t.data[s])&&this.chart.getDataVisibility(s)&&i++}),i}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?It(this.resolveDataElementOptions(t,e).angle||i):0}}An.id="polarArea",An.defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0},An.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label:t=>t.chart.data.labels[t.dataIndex]+": "+t.formattedValue}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};class Ln extends On{}Ln.id="pie",Ln.defaults={cutout:0,rotation:0,circumference:360,radius:"100%"};class Rn extends Os{getLabelAndValue(t){const e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}update(t){const e=this._cachedMeta,i=e.dataset,s=e.data||[],n=e.iScale.getLabels();if(i.points=s,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:!0,_fullLoop:n.length===s.length,options:e};this.updateElement(i,void 0,o,t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,i,s){const n=this.getDataset(),o=this._cachedMeta.rScale,a="reset"===s;for(let r=e;r"",label:t=>"("+t.label+", "+t.formattedValue+")"}}},scales:{x:{type:"linear"},y:{type:"linear"}}};var Fn=Object.freeze({__proto__:null,BarController:Pn,BubbleController:Cn,DoughnutController:On,LineController:Tn,PolarAreaController:An,PieController:Ln,RadarController:Rn,ScatterController:En});function In(t,e,i){const{startAngle:s,pixelMargin:n,x:o,y:a,outerRadius:r,innerRadius:l}=e;let h=n/r;t.beginPath(),t.arc(o,a,r,s-h,i+h),l>n?(h=n/l,t.arc(o,a,l,i+h,s-h,!0)):t.arc(o,a,n,i+St,s-St),t.closePath(),t.clip()}function zn(t,e,i,s){const n=Be(t.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]);const o=(i-e)/2,a=Math.min(o,s*e/2),r=t=>{const e=(i-Math.min(o,t))*s/2;return Yt(t,0,Math.min(o,e))};return{outerStart:r(n.outerStart),outerEnd:r(n.outerEnd),innerStart:Yt(n.innerStart,0,a),innerEnd:Yt(n.innerEnd,0,a)}}function Vn(t,e,i,s){return{x:i+t*Math.cos(e),y:s+t*Math.sin(e)}}function Bn(t,e,i,s,n){const{x:o,y:a,startAngle:r,pixelMargin:l,innerRadius:h}=e,c=Math.max(e.outerRadius+s+i-l,0),d=h>0?h+s+i+l:0;let u=0;const f=n-r;if(s){const t=((h>0?h-s:0)+(c>0?c-s:0))/2;u=(f-(0!==t?f*t/(t+s):f))/2}const g=(f-Math.max(.001,f*c-i/yt)/c)/2,p=r+g+u,m=n-g-u,{outerStart:b,outerEnd:x,innerStart:_,innerEnd:y}=zn(e,d,c,m-p),v=c-b,w=c-x,M=p+b/v,k=m-x/w,S=d+_,D=d+y,P=p+_/S,C=m-y/D;if(t.beginPath(),t.arc(o,a,c,M,k),x>0){const e=Vn(w,k,o,a);t.arc(e.x,e.y,x,k,m+St)}const O=Vn(D,m,o,a);if(t.lineTo(O.x,O.y),y>0){const e=Vn(D,C,o,a);t.arc(e.x,e.y,y,m+St,C+Math.PI)}if(t.arc(o,a,d,m-y/d,p+_/d,!0),_>0){const e=Vn(S,P,o,a);t.arc(e.x,e.y,_,P+Math.PI,p-St)}const T=Vn(v,p,o,a);if(t.lineTo(T.x,T.y),b>0){const e=Vn(v,M,o,a);t.arc(e.x,e.y,b,p-St,M)}t.closePath()}function Wn(t,e,i,s,n){const{options:o}=e,a="inner"===o.borderAlign;o.borderWidth&&(a?(t.lineWidth=2*o.borderWidth,t.lineJoin="round"):(t.lineWidth=o.borderWidth,t.lineJoin="bevel"),e.fullCircles&&function(t,e,i){const{x:s,y:n,startAngle:o,pixelMargin:a,fullCircles:r}=e,l=Math.max(e.outerRadius-a,0),h=e.innerRadius+a;let c;for(i&&In(t,e,o+vt),t.beginPath(),t.arc(s,n,h,o+vt,o,!0),c=0;c=vt||jt(n,a,r))&&(o>=l+d&&o<=h+d)}getCenterPoint(t){const{x:e,y:i,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius","circumference"],t),{offset:r,spacing:l}=this.options,h=(s+n)/2,c=(o+a+l+r)/2;return{x:e+Math.cos(h)*c,y:i+Math.sin(h)*c}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:i}=this,s=(e.offset||0)/2,n=(e.spacing||0)/2;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=i>vt?Math.floor(i/vt):0,0===i||this.innerRadius<0||this.outerRadius<0)return;t.save();let o=0;if(s){o=s/2;const e=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(e)*o,Math.sin(e)*o),this.circumference>=yt&&(o=s)}t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor;const a=function(t,e,i,s){const{fullCircles:n,startAngle:o,circumference:a}=e;let r=e.endAngle;if(n){Bn(t,e,i,s,o+vt);for(let e=0;er&&o>r;return{count:s,start:l,loop:e.loop,ilen:h(a+(h?r-t:t))%o,_=()=>{f!==g&&(t.lineTo(m,g),t.lineTo(m,f),t.lineTo(m,p))};for(l&&(d=n[x(0)],t.moveTo(d.x,d.y)),c=0;c<=r;++c){if((d=n[x(c)]).skip)continue;const e=d.x,i=d.y,s=0|e;s===u?(ig&&(g=i),m=(b*m+e)/++b):(_(),t.lineTo(e,i),u=s,b=0,f=g=i),p=i}_()}function Xn(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||i)?Un:$n}Nn.id="arc",Nn.defaults={borderAlign:"center",borderColor:"#fff",borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0},Nn.defaultRoutes={backgroundColor:"backgroundColor"};const qn="function"==typeof Path2D;function Kn(t,e,i,s){qn&&!e.options.segment?function(t,e,i,s){let n=e._path;n||(n=e._path=new Path2D,e.path(n,i,s)&&n.closePath()),Hn(t,e.options),t.stroke(n)}(t,e,i,s):function(t,e,i,s){const{segments:n,options:o}=e,a=Xn(e);for(const r of n)Hn(t,o,r.style),t.beginPath(),a(t,e,r,{start:i,end:i+s-1})&&t.closePath(),t.stroke()}(t,e,i,s)}class Gn extends Ts{constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const i=this.options;if((i.tension||"monotone"===i.cubicInterpolationMode)&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;Si(this._points,i,t,s,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Yi(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],n=this.points,o=ji(this,{property:e,start:s,end:s});if(!o.length)return;const a=[],r=function(t){return t.stepped?Ai:t.tension||"monotone"===t.cubicInterpolationMode?Li:Ti}(i);let l,h;for(l=0,h=o.length;l"borderDash"!==t&&"fill"!==t};class Qn extends Ts{constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,e,i){const s=this.options,{x:n,y:o}=this.getProps(["x","y"],i);return Math.pow(t-n,2)+Math.pow(e-o,2)=a.left&&e<=a.right)&&(o||i>=a.top&&i<=a.bottom)}function so(t,e){t.rect(e.x,e.y,e.w,e.h)}function no(t,e,i={}){const s=t.x!==i.x?-e:0,n=t.y!==i.y?-e:0,o=(t.x+t.w!==i.x+i.w?e:0)-s,a=(t.y+t.h!==i.y+i.h?e:0)-n;return{x:t.x+s,y:t.y+n,w:t.w+o,h:t.h+a,radius:t.radius}}Qn.id="point",Qn.defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0},Qn.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};class oo extends Ts{constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:e,options:{borderColor:i,backgroundColor:s}}=this,{inner:n,outer:o}=eo(this),a=(r=o.radius).topLeft||r.topRight||r.bottomLeft||r.bottomRight?oe:so;var r;t.save(),o.w===n.w&&o.h===n.h||(t.beginPath(),a(t,no(o,e,n)),t.clip(),a(t,no(n,-e,o)),t.fillStyle=i,t.fill("evenodd")),t.beginPath(),a(t,no(n,e)),t.fillStyle=s,t.fill(),t.restore()}inRange(t,e,i){return io(this,t,e,i)}inXRange(t,e){return io(this,t,null,e)}inYRange(t,e){return io(this,null,t,e)}getCenterPoint(t){const{x:e,y:i,base:s,horizontal:n}=this.getProps(["x","y","base","horizontal"],t);return{x:n?(e+s)/2:e,y:n?i:(i+s)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}}oo.id="bar",oo.defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0},oo.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};var ao=Object.freeze({__proto__:null,ArcElement:Nn,LineElement:Gn,PointElement:Qn,BarElement:oo});function ro(t){if(t._decimated){const e=t._data;delete t._decimated,delete t._data,Object.defineProperty(t,"data",{value:e})}}function lo(t){t.data.datasets.forEach(t=>{ro(t)})}var ho={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,i)=>{if(!i.enabled)return void lo(t);const s=t.width;t.data.datasets.forEach((e,n)=>{const{_data:o,indexAxis:a}=e,r=t.getDatasetMeta(n),l=o||e.data;if("y"===Ye([a,t.options.indexAxis]))return;if("line"!==r.type)return;const h=t.scales[r.xAxisID];if("linear"!==h.type&&"time"!==h.type)return;if(t.options.parsing)return;let{start:c,count:d}=function(t,e){const i=e.length;let s,n=0;const{iScale:o}=t,{min:a,max:r,minDefined:l,maxDefined:h}=o.getUserBounds();return l&&(n=Yt(re(e,o.axis,a).lo,0,i-1)),{start:n,count:s=h?Yt(re(e,o.axis,r).hi+1,n,i)-n:i-n}}(r,l);if(d<=(i.threshold||4*s))return void ro(e);let u;switch(Y(o)&&(e._data=l,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),i.algorithm){case"lttb":u=function(t,e,i,s,n){const o=n.samples||s;if(o>=i)return t.slice(e,e+i);const a=[],r=(i-2)/(o-2);let l=0;const h=e+i-1;let c,d,u,f,g,p=e;for(a[l++]=t[p],c=0;cu&&(u=f,d=t[s],g=s);a[l++]=d,p=g}return a[l++]=t[h],a}(l,c,d,s,i);break;case"min-max":u=function(t,e,i,s){let n,o,a,r,l,h,c,d,u,f,g=0,p=0;const m=[],b=e+i-1,x=t[e].x,_=t[b].x-x;for(n=e;nf&&(f=r,c=n),g=(p*g+o.x)/++p;else{const i=n-1;if(!Y(h)&&!Y(c)){const e=Math.min(h,c),s=Math.max(h,c);e!==d&&e!==i&&m.push({...t[e],x:g}),s!==d&&s!==i&&m.push({...t[s],x:g})}n>0&&i!==d&&m.push(t[i]),m.push(o),l=e,p=0,u=f=r,h=c=d=n}}return m}(l,c,d,s);break;default:throw new Error(`Unsupported decimation algorithm '${i.algorithm}'`)}e._decimated=u})},destroy(t){lo(t)}};function co(t,e,i){const s=function(t){const e=t.options,i=e.fill;let s=K(i&&i.target,i);return void 0===s&&(s=!!e.backgroundColor),!1!==s&&null!==s&&(!0===s?"origin":s)}(t);if(U(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return X(n)&&Math.floor(n)===n?("-"!==s[0]&&"+"!==s[0]||(n=e+n),!(n===e||n<0||n>=i)&&n):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}class uo{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){const{x:s,y:n,radius:o}=this;return e=e||{start:0,end:vt},t.arc(s,n,o,e.end,e.start,!0),!i.bounds}interpolate(t){const{x:e,y:i,radius:s}=this,n=t.angle;return{x:e+Math.cos(n)*s,y:i+Math.sin(n)*s,angle:n}}}function fo(t){return(t.scale||{}).getPointPositionForValue?function(t){const{scale:e,fill:i}=t,s=e.options,n=e.getLabels().length,o=[],a=s.reverse?e.max:e.min,r=s.reverse?e.min:e.max;let l,h,c;if(c="start"===i?a:"end"===i?r:U(i)?i.value:e.getBaseValue(),s.grid.circular)return h=e.getPointPositionForValue(0,a),new uo({x:h.x,y:h.y,radius:e.getDistanceFromCenterForValue(c)});for(l=0;lt;e--){const t=i[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function po(t,e,i){const s=[];for(let n=0;n=s&&n<=h){r=n===s,l=n===h;break}}return{first:r,last:l,point:s}}function bo(t){const{chart:e,fill:i,line:s}=t;if(X(i))return function(t,e){const i=t.getDatasetMeta(e);return i&&t.isDatasetVisible(e)?i.dataset:null}(e,i);if("stack"===i)return function(t){const{scale:e,index:i,line:s}=t,n=[],o=s.segments,a=s.points,r=function(t,e){const i=[],s=t.getMatchingVisibleMetas("line");for(let t=0;t{e=go(t,e,n);const a=n[t],r=n[e];null!==s?(o.push({x:a.x,y:s}),o.push({x:r.x,y:s})):null!==i&&(o.push({x:i,y:a.y}),o.push({x:i,y:r.y}))}),o}(t,e),i.length?new Gn({points:i,options:{tension:0},_loop:s,_fullLoop:s}):null}function _o(t,e,i){let s=t[e].fill;const n=[e];let o;if(!i)return s;for(;!1!==s&&-1===n.indexOf(s);){if(!X(s))return s;if(!(o=t[s]))return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function yo(t,e,i){t.beginPath(),e.path(t),t.lineTo(e.last().x,i),t.lineTo(e.first().x,i),t.closePath(),t.clip()}function vo(t,e,i,s){if(s)return;let n=e[t],o=i[t];return"angle"===t&&(n=Ht(n),o=Ht(o)),{property:t,start:n,end:o}}function wo(t,e,i,s){return t&&e?s(t[i],e[i]):t?t[i]:e?e[i]:0}function Mo(t,e,i){const{top:s,bottom:n}=e.chart.chartArea,{property:o,start:a,end:r}=i||{};"x"===o&&(t.beginPath(),t.rect(a,s,r-a,n-s),t.clip())}function ko(t,e,i,s){const n=e.interpolate(i,s);n&&t.lineTo(n.x,n.y)}function So(t,e){const{line:i,target:s,property:n,color:o,scale:a}=e,r=function(t,e,i){const s=t.segments,n=t.points,o=e.points,a=[];for(const t of s){let{start:s,end:r}=t;r=go(s,r,n);const l=vo(i,n[s],n[r],t.loop);if(!e.segments){a.push({source:t,target:l,start:n[s],end:n[r]});continue}const h=ji(e,l);for(const e of h){const s=vo(i,o[e.start],o[e.end],e.loop),r=Hi(t,n,s);for(const t of r)a.push({source:t,target:e,start:{[i]:wo(l,s,"start",Math.max)},end:{[i]:wo(l,s,"end",Math.min)}})}}return a}(i,s,n);for(const{source:e,target:l,start:h,end:c}of r){const{style:{backgroundColor:r=o}={}}=e,d=!0!==s;t.save(),t.fillStyle=r,Mo(t,a,d&&vo(n,h,c)),t.beginPath();const u=!!i.pathSegment(t,e);let f;if(d){u?t.closePath():ko(t,s,c,n);const e=!!s.pathSegment(t,l,{move:u,reverse:!0});(f=u&&e)||ko(t,s,h,n)}t.closePath(),t.fill(f?"evenodd":"nonzero"),t.restore()}}function Do(t,e,i){const s=bo(e),{line:n,scale:o,axis:a}=e,r=n.options,l=r.fill,h=r.backgroundColor,{above:c=h,below:d=h}=l||{};s&&n.points.length&&(Jt(t,i),function(t,e){const{line:i,target:s,above:n,below:o,area:a,scale:r}=e,l=i._loop?"angle":e.axis;t.save(),"x"===l&&o!==n&&(yo(t,s,a.top),So(t,{line:i,target:s,color:n,scale:r,property:l}),t.restore(),t.save(),yo(t,s,a.bottom)),So(t,{line:i,target:s,color:o,scale:r,property:l}),t.restore()}(t,{line:n,target:s,above:c,below:d,area:i,scale:o,axis:a}),te(t))}var Po={id:"filler",afterDatasetsUpdate(t,e,i){const s=(t.data.datasets||[]).length,n=[];let o,a,r,l;for(a=0;a=0;--e){const i=n[e].$filler;i&&(i.line.updateControlPoints(o,i.axis),s&&Do(t.ctx,i,o))}},beforeDatasetsDraw(t,e,i){if("beforeDatasetsDraw"!==i.drawTime)return;const s=t.getSortedVisibleDatasetMetas();for(let e=s.length-1;e>=0;--e){const i=s[e].$filler;i&&Do(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,i){const s=e.meta.$filler;s&&!1!==s.fill&&"beforeDatasetDraw"===i.drawTime&&Do(t.ctx,s,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const Co=(t,e)=>{let{boxHeight:i=e,boxWidth:s=e}=t;return t.usePointStyle&&(i=Math.min(i,e),s=Math.min(s,e)),{boxWidth:s,boxHeight:i,itemHeight:Math.max(e,i)}},Oo=(t,e)=>null!==t&&null!==e&&t.datasetIndex===e.datasetIndex&&t.index===e.index;class To extends Ts{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=Q(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(e=>t.filter(e,this.chart.data))),t.sort&&(e=e.sort((e,i)=>t.sort(e,i,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const i=t.labels,s=je(i.font),n=s.size,o=this._computeTitleHeight(),{boxWidth:a,itemHeight:r}=Co(i,n);let l,h;e.font=s.string,this.isHorizontal()?(l=this.maxWidth,h=this._fitRows(o,n,a,r)+10):(h=this.maxHeight,l=this._fitCols(o,n,a,r)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:n,maxWidth:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.lineWidths=[0],h=s+a;let c=t;n.textAlign="left",n.textBaseline="middle";let d=-1,u=-h;return this.legendItems.forEach((t,f)=>{const g=i+e/2+n.measureText(t.text).width;(0===f||l[l.length-1]+g+2*a>o)&&(c+=h,l[l.length-(f>0?0:1)]=0,u+=h,d++),r[f]={left:0,top:u,row:d,width:g,height:s},l[l.length-1]+=g+a}),c}_fitCols(t,e,i,s){const{ctx:n,maxHeight:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.columnSizes=[],h=o-t;let c=a,d=0,u=0,f=0,g=0;return this.legendItems.forEach((t,o)=>{const p=i+e/2+n.measureText(t.text).width;o>0&&u+s+2*a>h&&(c+=d+a,l.push({width:d,height:u}),f+=d+a,g++,d=u=0),r[o]={left:f,top:u,col:g,width:p,height:s},d=Math.max(d,p),u+=s+a}),c+=d,l.push({width:d,height:u}),c}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:o}}=this,a=zi(o,this.left,this.width);if(this.isHorizontal()){let o=0,r=n(i,this.left+s,this.right-this.lineWidths[o]);for(const l of e)o!==l.row&&(o=l.row,r=n(i,this.left+s,this.right-this.lineWidths[o])),l.top+=this.top+t+s,l.left=a.leftForLtr(a.x(r),l.width),r+=l.width+s}else{let o=0,r=n(i,this.top+t+s,this.bottom-this.columnSizes[o].height);for(const l of e)l.col!==o&&(o=l.col,r=n(i,this.top+t+s,this.bottom-this.columnSizes[o].height)),l.top=r,l.left+=this.left+s,l.left=a.leftForLtr(a.x(l.left),l.width),r+=l.height+s}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;Jt(t,this),this._draw(),te(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:a,labels:r}=t,l=_t.color,h=zi(t.rtl,this.left,this.width),c=je(r.font),{color:d,padding:u}=r,f=c.size,g=f/2;let p;this.drawTitle(),s.textAlign=h.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:m,boxHeight:b,itemHeight:x}=Co(r,f),_=this.isHorizontal(),y=this._computeTitleHeight();p=_?{x:n(a,this.left+u,this.right-i[0]),y:this.top+u+y,line:0}:{x:this.left+u,y:n(a,this.top+y+u,this.bottom-e[0].height),line:0},Vi(this.ctx,t.textDirection);const v=x+u;this.legendItems.forEach((w,M)=>{s.strokeStyle=w.fontColor||d,s.fillStyle=w.fontColor||d;const k=s.measureText(w.text).width,S=h.textAlign(w.textAlign||(w.textAlign=r.textAlign)),D=m+g+k;let P=p.x,C=p.y;h.setWidth(this.width),_?M>0&&P+D+u>this.right&&(C=p.y+=v,p.line++,P=p.x=n(a,this.left+u,this.right-i[p.line])):M>0&&C+v>this.bottom&&(P=p.x=P+e[p.line].width+u,p.line++,C=p.y=n(a,this.top+y+u,this.bottom-e[p.line].height)),function(t,e,i){if(isNaN(m)||m<=0||isNaN(b)||b<0)return;s.save();const n=K(i.lineWidth,1);if(s.fillStyle=K(i.fillStyle,l),s.lineCap=K(i.lineCap,"butt"),s.lineDashOffset=K(i.lineDashOffset,0),s.lineJoin=K(i.lineJoin,"miter"),s.lineWidth=n,s.strokeStyle=K(i.strokeStyle,l),s.setLineDash(K(i.lineDash,[])),r.usePointStyle){const o={radius:m*Math.SQRT2/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:n},a=h.xPlus(t,m/2);Zt(s,o,a,e+g)}else{const o=e+Math.max((f-b)/2,0),a=h.leftForLtr(t,m),r=Ne(i.borderRadius);s.beginPath(),Object.values(r).some(t=>0!==t)?oe(s,{x:a,y:o,w:m,h:b,radius:r}):s.rect(a,o,m,b),s.fill(),0!==n&&s.stroke()}s.restore()}(h.x(P),C,w),P=o(S,P+m+g,_?P+D:this.right,t.rtl),function(t,e,i){se(s,i.text,t,e+x/2,c,{strikethrough:i.hidden,textAlign:h.textAlign(i.textAlign)})}(h.x(P),C,w),_?p.x+=D+u:p.y+=v}),Bi(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=je(e.font),o=He(e.padding);if(!e.display)return;const a=zi(t.rtl,this.left,this.width),r=this.ctx,l=e.position,h=i.size/2,c=o.top+h;let d,u=this.left,f=this.width;if(this.isHorizontal())f=Math.max(...this.lineWidths),d=this.top+c,u=n(t.align,u,this.right-f);else{const e=this.columnSizes.reduce((t,e)=>Math.max(t,e.height),0);d=c+n(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const g=n(l,u,u+f);r.textAlign=a.textAlign(s(l)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=i.string,se(r,e.text,g,d,i)}_computeTitleHeight(){const t=this.options.title,e=je(t.font),i=He(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,n;if(t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom)for(n=this.legendHitBoxes,i=0;i=(s=n[i]).left&&t<=s.left+s.width&&e>=s.top&&e<=s.top+s.height)return this.legendItems[i];return null}handleEvent(t){const e=this.options;if(!function(t,e){if("mousemove"===t&&(e.onHover||e.onLeave))return!0;if(e.onClick&&("click"===t||"mouseup"===t))return!0;return!1}(t.type,e))return;const i=this._getLegendItemAt(t.x,t.y);if("mousemove"===t.type){const s=this._hoveredItem,n=Oo(s,i);s&&!n&&Q(e.onLeave,[t,s,this],this),this._hoveredItem=i,i&&!n&&Q(e.onHover,[t,i,this],this)}else i&&Q(e.onClick,[t,i,this],this)}}var Ao={id:"legend",_element:To,start(t,e,i){const s=t.legend=new To({ctx:t.ctx,options:i,chart:t});oi.configure(t,s,i),oi.addBox(t,s)},stop(t){oi.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,i){const s=t.legend;oi.configure(t,s,i),s.options=i},afterUpdate(t){const e=t.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(t,e){e.replay||t.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,e,i){const s=e.datasetIndex,n=i.chart;n.isDatasetVisible(s)?(n.hide(s),e.hidden=!0):(n.show(s),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:i,pointStyle:s,textAlign:n,color:o}}=t.legend.options;return t._getSortedDatasetMetas().map(t=>{const a=t.controller.getStyle(i?0:void 0),r=He(a.borderWidth);return{text:e[t.index].label,fillStyle:a.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:a.borderCapStyle,lineDash:a.borderDash,lineDashOffset:a.borderDashOffset,lineJoin:a.borderJoinStyle,lineWidth:(r.width+r.height)/4,strokeStyle:a.borderColor,pointStyle:s||a.pointStyle,rotation:a.rotation,textAlign:n||a.textAlign,borderRadius:0,datasetIndex:t.index}},this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class Lo extends Ts{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this.options;if(this.left=0,this.top=0,!i.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const s=$(i.text)?i.text.length:1;this._padding=He(i.padding);const n=s*je(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=n:this.width=n}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:s,right:o,options:a}=this,r=a.align;let l,h,c,d=0;return this.isHorizontal()?(h=n(r,i,o),c=e+t,l=o-i):("left"===a.position?(h=i+t,c=n(r,s,e),d=-.5*yt):(h=o-t,c=n(r,e,s),d=.5*yt),l=s-e),{titleX:h,titleY:c,maxWidth:l,rotation:d}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=je(e.font),n=i.lineHeight/2+this._padding.top,{titleX:o,titleY:a,maxWidth:r,rotation:l}=this._drawArgs(n);se(t,e.text,0,0,i,{color:e.color,maxWidth:r,rotation:l,textAlign:s(e.align),textBaseline:"middle",translation:[o,a]})}}var Ro={id:"title",_element:Lo,start(t,e,i){!function(t,e){const i=new Lo({ctx:t.ctx,options:e,chart:t});oi.configure(t,i,e),oi.addBox(t,i),t.titleBlock=i}(t,i)},stop(t){const e=t.titleBlock;oi.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){const s=t.titleBlock;oi.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Eo=new WeakMap;var Fo={id:"subtitle",start(t,e,i){const s=new Lo({ctx:t.ctx,options:i,chart:t});oi.configure(t,s,i),oi.addBox(t,s),Eo.set(t,s)},stop(t){oi.removeBox(t,Eo.get(t)),Eo.delete(t)},beforeUpdate(t,e,i){const s=Eo.get(t);oi.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Io={average(t){if(!t.length)return!1;let e,i,s=0,n=0,o=0;for(e=0,i=t.length;e-1?t.split("\n"):t}function Bo(t,e){const{element:i,datasetIndex:s,index:n}=e,o=t.getDatasetMeta(s).controller,{label:a,value:r}=o.getLabelAndValue(n);return{chart:t,label:a,parsed:o.getParsed(n),raw:t.data.datasets[s].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:i}}function Wo(t,e){const i=t._chart.ctx,{body:s,footer:n,title:o}=t,{boxWidth:a,boxHeight:r}=e,l=je(e.bodyFont),h=je(e.titleFont),c=je(e.footerFont),d=o.length,u=n.length,f=s.length,g=He(e.padding);let p=g.height,m=0,b=s.reduce((t,e)=>t+e.before.length+e.lines.length+e.after.length,0);if(b+=t.beforeBody.length+t.afterBody.length,d&&(p+=d*h.lineHeight+(d-1)*e.titleSpacing+e.titleMarginBottom),b){p+=f*(e.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(b-f)*l.lineHeight+(b-1)*e.bodySpacing}u&&(p+=e.footerMarginTop+u*c.lineHeight+(u-1)*e.footerSpacing);let x=0;const _=function(t){m=Math.max(m,i.measureText(t).width+x)};return i.save(),i.font=h.string,J(t.title,_),i.font=l.string,J(t.beforeBody.concat(t.afterBody),_),x=e.displayColors?a+2+e.boxPadding:0,J(s,t=>{J(t.before,_),J(t.lines,_),J(t.after,_)}),x=0,i.font=c.string,J(t.footer,_),i.restore(),{width:m+=g.width,height:p}}function No(t,e,i,s){const{x:n,width:o}=i,{width:a,chartArea:{left:r,right:l}}=t;let h="center";return"center"===s?h=n<=(r+l)/2?"left":"right":n<=o/2?h="left":n>=a-o/2&&(h="right"),function(t,e,i,s){const{x:n,width:o}=s,a=i.caretSize+i.caretPadding;return"left"===t&&n+o+a>e.width||"right"===t&&n-o-a<0||void 0}(h,t,e,i)&&(h="center"),h}function Ho(t,e,i){const s=e.yAlign||function(t,e){const{y:i,height:s}=e;return it.height-s/2?"bottom":"center"}(t,i);return{xAlign:e.xAlign||No(t,e,i,s),yAlign:s}}function jo(t,e,i,s){const{caretSize:n,caretPadding:o,cornerRadius:a}=t,{xAlign:r,yAlign:l}=i,h=n+o,{topLeft:c,topRight:d,bottomLeft:u,bottomRight:f}=Ne(a);let g=function(t,e){let{x:i,width:s}=t;return"right"===e?i-=s:"center"===e&&(i-=s/2),i}(e,r);const p=function(t,e,i){let{y:s,height:n}=t;return"top"===e?s+=i:s-="bottom"===e?n+i:n/2,s}(e,l,h);return"center"===l?"left"===r?g+=h:"right"===r&&(g-=h):"left"===r?g-=Math.max(c,u)+o:"right"===r&&(g+=Math.max(d,f)+o),{x:Yt(g,0,s.width-e.width),y:Yt(p,0,s.height-e.height)}}function Yo(t,e,i){const s=He(i.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-s.right:t.x+s.left}function $o(t){return zo([],Vo(t))}function Uo(t,e){const i=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return i?t.override(i):t}class Xo extends Ts{constructor(t){super(),this.opacity=0,this._active=[],this._chart=t._chart,this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this._chart,i=this.options.setContext(this.getContext()),s=i.enabled&&e.options.animation&&i.animations,n=new ms(this._chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(n)),n}getContext(){return this.$context||(this.$context=(t=this._chart.getContext(),e=this,i=this._tooltipItems,Ue(t,{tooltip:e,tooltipItems:i,type:"tooltip"})));var t,e,i}getTitle(t,e){const{callbacks:i}=e,s=i.beforeTitle.apply(this,[t]),n=i.title.apply(this,[t]),o=i.afterTitle.apply(this,[t]);let a=[];return a=zo(a,Vo(s)),a=zo(a,Vo(n)),a=zo(a,Vo(o))}getBeforeBody(t,e){return $o(e.callbacks.beforeBody.apply(this,[t]))}getBody(t,e){const{callbacks:i}=e,s=[];return J(t,t=>{const e={before:[],lines:[],after:[]},n=Uo(i,t);zo(e.before,Vo(n.beforeLabel.call(this,t))),zo(e.lines,n.label.call(this,t)),zo(e.after,Vo(n.afterLabel.call(this,t))),s.push(e)}),s}getAfterBody(t,e){return $o(e.callbacks.afterBody.apply(this,[t]))}getFooter(t,e){const{callbacks:i}=e,s=i.beforeFooter.apply(this,[t]),n=i.footer.apply(this,[t]),o=i.afterFooter.apply(this,[t]);let a=[];return a=zo(a,Vo(s)),a=zo(a,Vo(n)),a=zo(a,Vo(o))}_createItems(t){const e=this._active,i=this._chart.data,s=[],n=[],o=[];let a,r,l=[];for(a=0,r=e.length;at.filter(e,s,n,i))),t.itemSort&&(l=l.sort((e,s)=>t.itemSort(e,s,i))),J(l,e=>{const i=Uo(t.callbacks,e);s.push(i.labelColor.call(this,e)),n.push(i.labelPointStyle.call(this,e)),o.push(i.labelTextColor.call(this,e))}),this.labelColors=s,this.labelPointStyles=n,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let n,o=[];if(s.length){const t=Io[i.position].call(this,s,this._eventPosition);o=this._createItems(i),this.title=this.getTitle(o,i),this.beforeBody=this.getBeforeBody(o,i),this.body=this.getBody(o,i),this.afterBody=this.getAfterBody(o,i),this.footer=this.getFooter(o,i);const e=this._size=Wo(this,i),a=Object.assign({},t,e),r=Ho(this._chart,i,a),l=jo(i,a,r,this._chart);this.xAlign=r.xAlign,this.yAlign=r.yAlign,n={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(n={opacity:0});this._tooltipItems=o,this.$context=void 0,n&&this._resolveAnimations().update(this,n),t&&i.external&&i.external.call(this,{chart:this._chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const n=this.getCaretPosition(t,i,s);e.lineTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:n}=this,{caretSize:o,cornerRadius:a}=i,{topLeft:r,topRight:l,bottomLeft:h,bottomRight:c}=Ne(a),{x:d,y:u}=t,{width:f,height:g}=e;let p,m,b,x,_,y;return"center"===n?(_=u+g/2,"left"===s?(m=(p=d)-o,x=_+o,y=_-o):(m=(p=d+f)+o,x=_-o,y=_+o),b=p):(m="left"===s?d+Math.max(r,h)+o:"right"===s?d+f-Math.max(l,c)-o:this.caretX,"top"===n?(_=(x=u)-o,p=m-o,b=m+o):(_=(x=u+g)+o,p=m+o,b=m-o),y=x),{x1:p,x2:m,x3:b,y1:x,y2:_,y3:y}}drawTitle(t,e,i){const s=this.title,n=s.length;let o,a,r;if(n){const l=zi(i.rtl,this.x,this.width);for(t.x=Yo(this,i.titleAlign,i),e.textAlign=l.textAlign(i.titleAlign),e.textBaseline="middle",o=je(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=o.string,r=0;r0!==t)?(t.beginPath(),t.fillStyle=n.multiKeyBackground,oe(t,{x:e,y:g,w:l,h:r,radius:a}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),oe(t,{x:i,y:g+1,w:l-2,h:r-2,radius:a}),t.fill()):(t.fillStyle=n.multiKeyBackground,t.fillRect(e,g,l,r),t.strokeRect(e,g,l,r),t.fillStyle=o.backgroundColor,t.fillRect(i,g+1,l-2,r-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:n,bodyAlign:o,displayColors:a,boxHeight:r,boxWidth:l,boxPadding:h}=i,c=je(i.bodyFont);let d=c.lineHeight,u=0;const f=zi(i.rtl,this.x,this.width),g=function(i){e.fillText(i,f.x(t.x+u),t.y+d/2),t.y+=d+n},p=f.textAlign(o);let m,b,x,_,y,v,w;for(e.textAlign=o,e.textBaseline="middle",e.font=c.string,t.x=Yo(this,p,i),e.fillStyle=i.bodyColor,J(this.beforeBody,g),u=a&&"right"!==p?"center"===o?l/2+h:l+2+h:0,_=0,v=s.length;_0&&e.stroke()}_updateAnimationTarget(t){const e=this._chart,i=this.$animations,s=i&&i.x,n=i&&i.y;if(s||n){const i=Io[t.position].call(this,this._active,this._eventPosition);if(!i)return;const o=this._size=Wo(this,t),a=Object.assign({},i,this._size),r=Ho(e,t,a),l=jo(t,a,r,e);s._to===l.x&&n._to===l.y||(this.xAlign=r.xAlign,this.yAlign=r.yAlign,this.width=o.width,this.height=o.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,l))}}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},n={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const o=He(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(n,t,s,e),Vi(t,e.textDirection),n.y+=o.top,this.drawTitle(n,t,e),this.drawBody(n,t,e),this.drawFooter(n,t,e),Bi(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map(({datasetIndex:t,index:e})=>{const i=this._chart.getDatasetMeta(t);if(!i)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:i.data[e],index:e}}),n=!tt(i,s),o=this._positionChanged(s,e);(n||o)&&(this._active=s,this._eventPosition=e,this.update(!0))}handleEvent(t,e){const i=this.options,s=this._active||[];let n=!1,o=[];"mouseout"!==t.type&&(o=this._chart.getElementsAtEventForMode(t,i.mode,i,e),i.reverse&&o.reverse());const a=this._positionChanged(o,t);return(n=e||!tt(o,s)||a)&&(this._active=o,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),n}_positionChanged(t,e){const{caretX:i,caretY:s,options:n}=this,o=Io[n.position].call(this,t,e);return!1!==o&&(i!==o.x||s!==o.y)}}Xo.positioners=Io;var qo={id:"tooltip",_element:Xo,positioners:Io,afterInit(t,e,i){i&&(t.tooltip=new Xo({_chart:t,options:i}))},beforeUpdate(t,e,i){t.tooltip&&t.tooltip.initialize(i)},reset(t,e,i){t.tooltip&&t.tooltip.initialize(i)},afterDraw(t){const e=t.tooltip,i={tooltip:e};!1!==t.notifyPlugins("beforeTooltipDraw",i)&&(e&&e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i))},afterEvent(t,e){if(t.tooltip){const i=e.replay;t.tooltip.handleEvent(e.event,i)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:{beforeTitle:H,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,s=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(s>0&&e.dataIndex"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},Ko=Object.freeze({__proto__:null,Decimation:ho,Filler:Po,Legend:Ao,SubTitle:Fo,Title:Ro,Tooltip:qo});const Go=(t,e,i)=>"string"==typeof e?t.push(e)-1:isNaN(e)?null:i;const Zo=(t,e)=>null===t?null:Yt(Math.round(t),0,e);class Qo extends Hs{constructor(t){super(t),this._startValue=void 0,this._valueRange=0}parse(t,e){if(Y(t))return null;const i=this.getLabels();return e=isFinite(e)&&i[e]===t?e:function(t,e,i){const s=t.indexOf(e);return-1===s?Go(t,e,i):s!==t.lastIndexOf(e)?i:s}(i,t,K(e,t)),Zo(e,i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(i=0),e||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,e=this.max,i=this.options.offset,s=[];let n=this.getLabels();n=0===t&&e===n.length-1?n:n.slice(t,e+1),this._valueRange=Math.max(n.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let i=t;i<=e;i++)s.push({value:i});return s}getLabelForValue(t){const e=this.getLabels();return t>=0&&te.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function Jo(t,e,{horizontal:i,minRotation:s}){const n=It(s),o=(i?Math.sin(n):Math.cos(n))||.001,a=.75*e*(""+t).length;return Math.min(e/o,a)}Qo.id="category",Qo.defaults={ticks:{callback:Qo.prototype.getLabelForValue}};class ta extends Hs{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return Y(t)?null:("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:s,max:n}=this;const o=t=>s=e?s:t,a=t=>n=i?n:t;if(t){const t=Ot(s),e=Ot(n);t<0&&e<0?a(0):t>0&&e>0&&o(0)}if(s===n){let e=1;(n>=Number.MAX_SAFE_INTEGER||s<=Number.MIN_SAFE_INTEGER)&&(e=Math.abs(.05*n)),a(n+e),t||o(s-e)}this.min=s,this.max=n}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:i,stepSize:s}=t;return s?(e=Math.ceil(this.max/s)-Math.floor(this.min/s)+1)>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3):(e=this.computeTickLimit(),i=i||11),i&&(e=Math.min(i,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();const s=function(t,e){const i=[],{bounds:s,step:n,min:o,max:a,precision:r,count:l,maxTicks:h,maxDigits:c,includeBounds:d}=t,u=n||1,f=h-1,{min:g,max:p}=e,m=!Y(o),b=!Y(a),x=!Y(l),_=(p-g)/(c+1);let y,v,w,M,k=Tt((p-g)/f/u)*u;if(k<1e-14&&!m&&!b)return[{value:g},{value:p}];(M=Math.ceil(p/k)-Math.floor(g/k))>f&&(k=Tt(M*k/f/u)*u),Y(r)||(y=Math.pow(10,r),k=Math.ceil(k*y)/y),"ticks"===s?(v=Math.floor(g/k)*k,w=Math.ceil(p/k)*k):(v=g,w=p),m&&b&&n&&Et((a-o)/n,k/1e3)?(k=(a-o)/(M=Math.round(Math.min((a-o)/k,h))),v=o,w=a):x?k=((w=b?a:w)-(v=m?o:v))/(M=l-1):M=Rt(M=(w-v)/k,Math.round(M),k/1e3)?Math.round(M):Math.ceil(M);const S=Math.max(Vt(k),Vt(v));y=Math.pow(10,Y(r)?S:r),v=Math.round(v*y)/y,w=Math.round(w*y)/y;let D=0;for(m&&(d&&v!==o?(i.push({value:o}),v0?i:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=X(t)?Math.max(0,t):null,this.max=X(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const n=e=>i=t?i:e,o=t=>s=e?s:t,a=(t,e)=>Math.pow(10,Math.floor(Ct(t))+e);i===s&&(i<=0?(n(1),o(10)):(n(a(i,-1)),o(a(s,1)))),i<=0&&n(a(s,-1)),s<=0&&o(a(i,1)),this._zero&&this.min!==this._suggestedMin&&i===a(this.min,0)&&n(a(i,-1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e=function(t,e){const i=Math.floor(Ct(e.max)),s=Math.ceil(e.max/Math.pow(10,i)),n=[];let o=q(t.min,Math.pow(10,Math.floor(Ct(e.min)))),a=Math.floor(Ct(o)),r=Math.floor(o/Math.pow(10,a)),l=a<0?Math.pow(10,Math.abs(a)):1;do{n.push({value:o,major:ia(o)}),10==++r&&(r=1,l=++a>=0?1:l),o=Math.round(r*Math.pow(10,a)*l)/l}while(an?{start:e-i,end:e}:{start:e,end:e+i}}function aa(t){const e={l:0,r:t.width,t:0,b:t.height-t.paddingTop},i={},s=[],n=[],o=t.getLabels().length;for(let h=0;he.r&&(e.r=p.end,i.r=f),m.starte.b&&(e.b=m.end,i.b=f)}var a,r,l;t._setReductions(t.drawingArea,e,i),t._pointLabelItems=function(t,e,i){const s=[],n=t.getLabels().length,o=t.options,a=na(o),r=t.getDistanceFromCenterForValue(o.ticks.reverse?t.min:t.max);for(let o=0;o270||i<90)&&(t-=e),t}function ca(t,e,i,s){const{ctx:n}=t;if(i)n.arc(t.xCenter,t.yCenter,e,0,vt);else{let i=t.getPointPosition(0,e);n.moveTo(i.x,i.y);for(let o=1;o{const i=Q(this.options.pointLabels.callback,[t,e],this);return i||0===i?i:""})}fit(){const t=this.options;t.display&&t.pointLabels.display?aa(this):this.setCenterPoint(0,0,0,0)}_setReductions(t,e,i){let s=e.l/Math.sin(i.l),n=Math.max(e.r-this.width,0)/Math.sin(i.r),o=-e.t/Math.cos(i.t),a=-Math.max(e.b-(this.height-this.paddingTop),0)/Math.cos(i.b);s=da(s),n=da(n),o=da(o),a=da(a),this.drawingArea=Math.max(t/2,Math.min(Math.floor(t-(s+n)/2),Math.floor(t-(o+a)/2))),this.setCenterPoint(s,n,o,a)}setCenterPoint(t,e,i,s){const n=this.width-e-this.drawingArea,o=t+this.drawingArea,a=i+this.drawingArea,r=this.height-this.paddingTop-s-this.drawingArea;this.xCenter=Math.floor((o+n)/2+this.left),this.yCenter=Math.floor((a+r)/2+this.top+this.paddingTop)}getIndexAngle(t){return Ht(t*(vt/this.getLabels().length)+It(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(Y(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(Y(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t=0;n--){const e=s.setContext(t.getPointLabelContext(n)),o=je(e.font),{x:a,y:r,textAlign:l,left:h,top:c,right:d,bottom:u}=t._pointLabelItems[n],{backdropColor:f}=e;if(!Y(f)){const t=He(e.backdropPadding);i.fillStyle=f,i.fillRect(h-t.left,c-t.top,d-h+t.width,u-c+t.height)}se(i,t._pointLabels[n],a,r+o.lineHeight/2,o,{color:e.color,textAlign:l,textBaseline:"middle"})}}(this,n),s.display&&this.ticks.forEach((t,e)=>{if(0!==e){a=this.getDistanceFromCenterForValue(t.value),function(t,e,i,s){const n=t.ctx,o=e.circular,{color:a,lineWidth:r}=e;!o&&!s||!a||!r||i<0||(n.save(),n.strokeStyle=a,n.lineWidth=r,n.setLineDash(e.borderDash),n.lineDashOffset=e.borderDashOffset,n.beginPath(),ca(t,i,o,s),n.closePath(),n.stroke(),n.restore())}(this,s.setContext(this.getContext(e-1)),a,n)}}),i.display){for(t.save(),o=this.getLabels().length-1;o>=0;o--){const s=i.setContext(this.getPointLabelContext(o)),{color:n,lineWidth:l}=s;l&&n&&(t.lineWidth=l,t.strokeStyle=n,t.setLineDash(s.borderDash),t.lineDashOffset=s.borderDashOffset,a=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),r=this.getPointPosition(o,a),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(r.x,r.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let n,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((s,a)=>{if(0===a&&!e.reverse)return;const r=i.setContext(this.getContext(a)),l=je(r.font);if(n=this.getDistanceFromCenterForValue(this.ticks[a].value),r.showLabelBackdrop){t.font=l.string,o=t.measureText(s.label).width,t.fillStyle=r.backdropColor;const e=He(r.backdropPadding);t.fillRect(-o/2-e.left,-n-l.size/2-e.top,o+e.width,l.size+e.height)}se(t,s.label,0,-n,l,{color:r.color})}),t.restore()}drawTitle(){}}ua.id="radialLinear",ua.defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Ls.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback:t=>t,padding:5}},ua.defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"},ua.descriptors={angleLines:{_fallback:"grid"}};const fa={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},ga=Object.keys(fa);function pa(t,e){return t-e}function ma(t,e){if(Y(e))return null;const i=t._adapter,{parser:s,round:n,isoWeekday:o}=t._parseOpts;let a=e;return"function"==typeof s&&(a=s(a)),X(a)||(a="string"==typeof s?i.parse(a,s):i.parse(a)),null===a?null:(n&&(a="week"!==n||!Lt(o)&&!0!==o?i.startOf(a,n):i.startOf(a,"isoWeek",o)),+a)}function ba(t,e,i,s){const n=ga.length;for(let o=ga.indexOf(t);o=e?i[s]:i[n]]=!0}}else t[e]=!0}function _a(t,e,i){const s=[],n={},o=e.length;let a,r;for(a=0;a=0&&(e[l].major=!0);return e}(t,s,n,i):s}class ya extends Hs{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e){const i=t.time||(t.time={}),s=this._adapter=new xn._date(t.adapters.date);ot(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:ma(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,i=t.time.unit||"day";let{min:s,max:n,minDefined:o,maxDefined:a}=this.getUserBounds();function r(t){o||isNaN(t.min)||(s=Math.min(s,t.min)),a||isNaN(t.max)||(n=Math.max(n,t.max))}o&&a||(r(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||r(this.getMinMax(!1))),s=X(s)&&!isNaN(s)?s:+e.startOf(Date.now(),i),n=X(n)&&!isNaN(n)?n:+e.endOf(Date.now(),i)+1,this.min=Math.min(s,n-1),this.max=Math.max(s+1,n)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this.options,e=t.time,i=t.ticks,s="labels"===i.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const n=this.min,o=he(s,n,this.max);return this._unit=e.unit||(i.autoSkip?ba(e.minUnit,this.min,this.max,this._getLabelCapacity(n)):function(t,e,i,s,n){for(let o=ga.length-1;o>=ga.indexOf(i);o--){const i=ga[o];if(fa[i].common&&t._adapter.diff(n,s,i)>=e-1)return i}return ga[i?ga.indexOf(i):0]}(this,o.length,e.minUnit,this.min,this.max)),this._majorUnit=i.major.enabled&&"year"!==this._unit?function(t){for(let e=ga.indexOf(t)+1,i=ga.length;e1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+o);const f="data"===s.ticks.source&&this.getDataTimestamps();for(c=u,d=0;ct-e).map(t=>+t)}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}_tickFormatFunction(t,e,i,s){const n=this.options,o=n.time.displayFormats,a=this._unit,r=this._majorUnit,l=a&&o[a],h=r&&o[r],c=i[e],d=r&&h&&c&&c.major,u=this._adapter.format(t,s||(d?h:l)),f=n.ticks.callback;return f?Q(f,[u,e,i],this):u}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t,e,i=this._cache.data||[];if(i.length)return i;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(t=0,e=s.length;t=t[r].pos&&e<=t[l].pos&&({lo:r,hi:l}=re(t,"pos",e)),({pos:s,time:o}=t[r]),({pos:n,time:a}=t[l])):(e>=t[r].time&&e<=t[l].time&&({lo:r,hi:l}=re(t,"time",e)),({time:s,pos:o}=t[r]),({time:n,pos:a}=t[l]));const h=n-s;return h?o+(a-o)*(e-s)/h:o}ya.id="time",ya.defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",major:{enabled:!1}}};class wa extends ya{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=va(e,this.min),this._tableRange=va(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],n=[];let o,a,r,l,h;for(o=0,a=t.length;o=e&&l<=i&&s.push(l);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(o=0,a=s.length;o"string"==typeof t,e=Chart.helpers;let i=null;new Map;return window.plugin_gradient={id:"gradient",beforeDatasetsUpdate(s){const n=s.ctx,o=s.chartArea;if(!o)return null;if(s.options.gradientcolor&&void 0!==s.options.gradientcolor.type){const a=s.data.datasets[0].type||s.config.type;if(null===i){const r=s.data.datasets[0].backgroundColor;i=function(i,s,n,o){let a=[];switch(s.toLowerCase()){case"pie":case"doughnut":if(o&&o.length&&t(o[0])){const t=(n.left+n.right)/2,s=(n.top+n.bottom)/2,r=1;return Object.entries(o).forEach(([,n],o)=>{let l=i.createRadialGradient(t,s,0,t,s,r);l.addColorStop(0,e.color(n).alpha(.4).rgbString()),l.addColorStop(1,e.color(n).alpha(1).rgbString()),a.push(l)}),a}case"bar":return Object.entries(o).forEach(([,s],o)=>{if(t(s)){let t=i.createLinearGradient(0,n.bottom,0,n.top);t.addColorStop(0,e.color(s).alpha(1).rgbString()),t.addColorStop(.5,e.color(s).alpha(.5).rgbString()),t.addColorStop(1,e.color(s).alpha(1).rgbString()),a.push(t)}else a.push(s)}),a}return o}(n,a,o,r),s.data.datasets[0].backgroundColor=i}}else s.data.datasets.forEach((t,s)=>{const a=t.gradient;a&&o&&Object.keys(a).forEach(s=>{const{axis:r,colors:l}=a[s];l&&l.length&&(i=function(t,i,s,n){if(s.bottom&&s.top&&s.left&&s.right){const o="y"===i?t.createLinearGradient(0,s.bottom,0,s.top):t.createLinearGradient(s.left,0,s.right,0);if(n&&1==n.length)o.addColorStop(0,e.color(color).alpha(.2).rgbString()),o.addColorStop(.3,e.color(color).alpha(.4).rgbString()),o.addColorStop(.5,e.color(color).alpha(.6).rgbString()),o.addColorStop(1,e.color(color).alpha(1).rgbString());else{const t=1/(n.length-1);Object.entries(n).forEach(([,e],i)=>{o.addColorStop(t*i,e)})}return o}}(n,r,o,l),t.backgroundColor=i)})})}},plugin_gradient}),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self)["chartjs-background"]=e()}(this,function(){"use strict";return{id:"chardbackground",beforeDraw:function(t){if(t.config.options.chartArea&&t.config.options.chartArea.backgroundColor){const e=t.chartArea,i=t.ctx;i.save(),i.fillStyle=t.config.options.chartArea.backgroundColor,i.fillRect(e.left,e.top,e.right-e.left,e.bottom-e.top),i.restore()}}}}),LineFitter.prototype={add:function(t,e){this.count++,this.sumX+=t,this.sumX2+=t*t,this.sumXY+=t*e,this.sumY+=e},project:function(t){const e=this.count*this.sumX2-this.sumX*this.sumX;return(this.sumX2*this.sumY-this.sumX*this.sumXY)/e+t*((this.count*this.sumXY-this.sumX*this.sumY)/e)}},window.plugin_trendline={id:"trendline",afterDatasetsDraw:function(t){const e=t.ctx;e&&(t.data.datasets.forEach(function(i,s){if(i.trendlineLinear){const n=t.scales.x||t.scales[i.xAxisID],o=t.scales.y||t.scales[i.yAxisID];addFitter(t.getDatasetMeta(s),e,i,n,o)}}),e.setLineDash([]))}},function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("chart.js")):"function"==typeof define&&define.amd?define(["chart.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Chart)}(this,function(t){"use strict";function e(t){if(null===t||!0===t||!1===t)return NaN;var e=Number(t);return isNaN(e)?e:e<0?Math.ceil(e):Math.floor(e)}function i(t,e){if(e.length1?"s":"")+" required, but only "+e.length+" present")}function s(t){i(1,arguments);var e=Object.prototype.toString.call(t);return t instanceof Date||"object"==typeof t&&"[object Date]"===e?new Date(t.getTime()):"number"==typeof t||"[object Number]"===e?new Date(t):("string"!=typeof t&&"[object String]"!==e||"undefined"==typeof console||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn((new Error).stack)),new Date(NaN))}function n(t,n){i(2,arguments);var o=s(t),a=e(n);return isNaN(a)?new Date(NaN):a?(o.setDate(o.getDate()+a),o):o}function o(t,n){i(2,arguments);var o=s(t),a=e(n);if(isNaN(a))return new Date(NaN);if(!a)return o;var r=o.getDate(),l=new Date(o.getTime());return l.setMonth(o.getMonth()+a+1,0),r>=l.getDate()?l:(o.setFullYear(l.getFullYear(),l.getMonth(),r),o)}function a(t,n){i(2,arguments);var o=s(t).getTime(),a=e(n);return new Date(o+a)}function r(t,n){i(1,arguments);var o=n||{},a=o.locale,r=a&&a.options&&a.options.weekStartsOn,l=null==r?0:e(r),h=null==o.weekStartsOn?l:e(o.weekStartsOn);if(!(h>=0&&h<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var c=s(t),d=c.getDay(),u=(d0?1:a}function f(t,e){var i=t.getFullYear()-e.getFullYear()||t.getMonth()-e.getMonth()||t.getDate()-e.getDate()||t.getHours()-e.getHours()||t.getMinutes()-e.getMinutes()||t.getSeconds()-e.getSeconds()||t.getMilliseconds()-e.getMilliseconds();return i<0?-1:i>0?1:i}function g(t,e){i(2,arguments);var n=s(t),o=s(e),a=f(n,o),r=Math.abs(d(n,o));n.setDate(n.getDate()-a*r);var l=a*(r-(f(n,o)===-a));return 0===l?0:l}function p(t,e){i(2,arguments);var n=s(t),o=s(e);return n.getTime()-o.getTime()}function m(t){i(1,arguments);var e=s(t);return e.setHours(23,59,59,999),e}function b(t){i(1,arguments);var e=s(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function x(t,e){i(2,arguments);var n,o=s(t),a=s(e),r=u(o,a),l=Math.abs(function(t,e){i(2,arguments);var n=s(t),o=s(e);return 12*(n.getFullYear()-o.getFullYear())+(n.getMonth()-o.getMonth())}(o,a));if(l<1)n=0;else{1===o.getMonth()&&o.getDate()>27&&o.setDate(30),o.setMonth(o.getMonth()-r*l);var h=u(o,a)===-r;(function(t){i(1,arguments);var e=s(t);return m(e).getTime()===b(e).getTime()})(s(t))&&1===l&&1===u(t,a)&&(h=!1),n=r*(l-h)}return 0===n?0:n}const _={datetime:"F d, yyyy, H:i:s",millisecond:"default",second:"longTime",minute:"longTime",hour:"default",day:"fullDate",week:"W",month:"M yyyy",quarter:"quater",year:"yyyy"};t._adapters._date.override({_id:"date-fns",formats:function(){return _},parse:function(t,e){return t},format:function(t,e){return t},add:function(t,s,r){switch(r){case"millisecond":return a(t,s);case"second":return function(t,s){return i(2,arguments),a(t,1e3*e(s))}(t,s);case"minute":return function(t,s){return i(2,arguments),a(t,6e4*e(s))}(t,s);case"hour":return function(t,s){return i(2,arguments),a(t,36e5*e(s))}(t,s);case"day":return n(t,s);case"week":return function(t,s){return i(2,arguments),n(t,7*e(s))}(t,s);case"month":return o(t,s);case"quarter":return function(t,s){return i(2,arguments),o(t,3*e(s))}(t,s);case"year":return function(t,s){return i(2,arguments),o(t,12*e(s))}(t,s);default:return t}},diff:function(t,e,n){switch(n){case"millisecond":return p(t,e);case"second":return function(t,e){i(2,arguments);var s=p(t,e)/1e3;return s>0?Math.floor(s):Math.ceil(s)}(t,e);case"minute":return function(t,e){i(2,arguments);var s=p(t,e)/6e4;return s>0?Math.floor(s):Math.ceil(s)}(t,e);case"hour":return function(t,e){i(2,arguments);var s=p(t,e)/36e5;return s>0?Math.floor(s):Math.ceil(s)}(t,e);case"day":return g(t,e);case"week":return function(t,e){i(2,arguments);var s=g(t,e)/7;return s>0?Math.floor(s):Math.ceil(s)}(t,e);case"month":return x(t,e);case"quarter":return function(t,e){i(2,arguments);var s=x(t,e)/3;return s>0?Math.floor(s):Math.ceil(s)}(t,e);case"year":return function(t,e){i(2,arguments);var n=s(t),o=s(e),a=u(n,o),r=Math.abs(function(t,e){i(2,arguments);var n=s(t),o=s(e);return n.getFullYear()-o.getFullYear()}(n,o));n.setFullYear("1584"),o.setFullYear("1584");var l=a*(r-(u(n,o)===-a));return 0===l?0:l}(t,e);default:return 0}},startOf:function(t,e,n){switch(e){case"second":return function(t){i(1,arguments);var e=s(t);return e.setMilliseconds(0),e}(t);case"minute":return function(t){i(1,arguments);var e=s(t);return e.setSeconds(0,0),e}(t);case"hour":return function(t){i(1,arguments);var e=s(t);return e.setMinutes(0,0,0),e}(t);case"day":return h(t);case"week":return r(t);case"isoWeek":return r(t,{weekStartsOn:+n});case"month":return function(t){i(1,arguments);var e=s(t);return e.setDate(1),e.setHours(0,0,0,0),e}(t);case"quarter":return function(t){i(1,arguments);var e=s(t),n=e.getMonth(),o=n-n%3;return e.setMonth(o,1),e.setHours(0,0,0,0),e}(t);case"year":return function(t){i(1,arguments);var e=s(t),n=new Date(0);return n.setFullYear(e.getFullYear(),0,1),n.setHours(0,0,0,0),n}(t);default:return t}},endOf:function(t,n){switch(n){case"second":return function(t){i(1,arguments);var e=s(t);return e.setMilliseconds(999),e}(t);case"minute":return function(t){i(1,arguments);var e=s(t);return e.setSeconds(59,999),e}(t);case"hour":return function(t){i(1,arguments);var e=s(t);return e.setMinutes(59,59,999),e}(t);case"day":return m(t);case"week":return function(t,n){i(1,arguments);var o={},a=o.locale,r=a&&a.options&&a.options.weekStartsOn,l=null==r?0:e(r),h=null==o.weekStartsOn?l:e(o.weekStartsOn);if(!(h>=0&&h<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var c=s(t),d=c.getDay(),u=6+(dArray.prototype.slice.call(t));let o=!1,a=[];return function(...s){a=n(s),o||(o=!0,t.call(window,()=>{o=!1,e.apply(i,a)}))}}function i(t,e){let i;return function(...s){return e?(clearTimeout(i),i=setTimeout(t,e,s)):t.apply(this,s),e}}const s=t=>"start"===t?"left":"end"===t?"right":"center",n=(t,e,i)=>"start"===t?e:"end"===t?i:(e+i)/2,o=(t,e,i,s)=>{return t===(s?"left":"right")?i:"center"===t?(e+i)/2:e};var a=new class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,s){const n=e.listeners[s],o=e.duration;n.forEach(s=>s({chart:t,initial:e.initial,numSteps:o,currentStep:Math.min(i-e.start,o)}))}_refresh(){this._request||(this._running=!0,this._request=t.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((i,s)=>{if(!i.running||!i.items.length)return;const n=i.items;let o,a=n.length-1,r=!1;for(;a>=0;--a)(o=n[a])._active?(o._total>i.duration&&(i.duration=o._total),o.tick(t),r=!0):(n[a]=n[n.length-1],n.pop());r&&(s.draw(),this._notify(s,i,t,"progress")),n.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),e+=n.length}),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((t,e)=>Math.max(t,e._duration),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}};const r={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},l="0123456789ABCDEF",h=t=>l[15&t],c=t=>l[(240&t)>>4]+l[15&t],d=t=>(240&t)>>4==(15&t);function u(t){var e=function(t){return d(t.r)&&d(t.g)&&d(t.b)&&d(t.a)}(t)?h:c;return t?"#"+e(t.r)+e(t.g)+e(t.b)+(t.a<255?e(t.a):""):t}function f(t){return t+.5|0}const g=(t,e,i)=>Math.max(Math.min(t,i),e);function p(t){return g(f(2.55*t),0,255)}function m(t){return g(f(255*t),0,255)}function b(t){return g(f(t/2.55)/100,0,1)}function x(t){return g(f(100*t),0,100)}const _=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const y=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function v(t,e,i){const s=e*Math.min(i,1-i),n=(e,n=(e+t/30)%12)=>i-s*Math.max(Math.min(n-3,9-n,1),-1);return[n(0),n(8),n(4)]}function w(t,e,i){const s=(s,n=(s+t/60)%6)=>i-i*e*Math.max(Math.min(n,4-n,1),0);return[s(5),s(3),s(1)]}function M(t,e,i){const s=v(t,1,.5);let n;for(e+i>1&&(e*=n=1/(e+i),i*=n),n=0;n<3;n++)s[n]*=1-e-i,s[n]+=e;return s}function k(t){const e=t.r/255,i=t.g/255,s=t.b/255,n=Math.max(e,i,s),o=Math.min(e,i,s),a=(n+o)/2;let r,l,h;return n!==o&&(h=n-o,l=a>.5?h/(2-n-o):h/(n+o),r=60*(r=n===e?(i-s)/h+(i>16&255,o>>8&255,255&o]}return t}()).transparent=[0,0,0,0]);const e=A[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}function R(t,e,i){if(t){let s=k(t);s[e]=Math.max(0,Math.min(s[e]+s[e]*i,0===e?360:1)),s=D(s),t.r=s[0],t.g=s[1],t.b=s[2]}}function E(t,e){return t?Object.assign(e||{},t):t}function F(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=m(t[3]))):(e=E(t,{r:0,g:0,b:0,a:1})).a=m(e.a),e}function I(t){return"r"===t.charAt(0)?function(t){const e=_.exec(t);let i,s,n,o=255;if(e){if(e[7]!==i){const t=+e[7];o=255&(e[8]?p(t):255*t)}return i=+e[1],s=+e[3],n=+e[5],{r:i=255&(e[2]?p(i):i),g:s=255&(e[4]?p(s):s),b:n=255&(e[6]?p(n):n),a:o}}}(t):C(t)}class z{constructor(t){if(t instanceof z)return t;const e=typeof t;let i;var s,n,o;"object"===e?i=F(t):"string"===e&&(o=(s=t).length,"#"===s[0]&&(4===o||5===o?n={r:255&17*r[s[1]],g:255&17*r[s[2]],b:255&17*r[s[3]],a:5===o?17*r[s[4]]:255}:7!==o&&9!==o||(n={r:r[s[1]]<<4|r[s[2]],g:r[s[3]]<<4|r[s[4]],b:r[s[5]]<<4|r[s[6]],a:9===o?r[s[7]]<<4|r[s[8]]:255})),i=n||L(t)||I(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=E(this._rgb);return t&&(t.a=b(t.a)),t}set rgb(t){this._rgb=F(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${b(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):this._rgb;var t}hexString(){return this._valid?u(this._rgb):this._rgb}hslString(){return this._valid?function(t){if(!t)return;const e=k(t),i=e[0],s=x(e[1]),n=x(e[2]);return t.a<255?`hsla(${i}, ${s}%, ${n}%, ${b(t.a)})`:`hsl(${i}, ${s}%, ${n}%)`}(this._rgb):this._rgb}mix(t,e){const i=this;if(t){const s=i.rgb,n=t.rgb;let o;const a=e===o?.5:e,r=2*a-1,l=s.a-n.a,h=((r*l==-1?r:(r+l)/(1+r*l))+1)/2;o=1-h,s.r=255&h*s.r+o*n.r+.5,s.g=255&h*s.g+o*n.g+.5,s.b=255&h*s.b+o*n.b+.5,s.a=a*s.a+(1-a)*n.a,i.rgb=s}return i}clone(){return new z(this.rgb)}alpha(t){return this._rgb.a=m(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,e=f(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return R(this._rgb,2,t),this}darken(t){return R(this._rgb,2,-t),this}saturate(t){return R(this._rgb,1,t),this}desaturate(t){return R(this._rgb,1,-t),this}rotate(t){return function(t,e){var i=k(t);i[0]=P(i[0]+e),i=D(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this}}function B(t){return new z(t)}const V=t=>t instanceof CanvasGradient||t instanceof CanvasPattern;function N(t){return V(t)?t:B(t)}function W(t){return V(t)?t:B(t).saturate(.5).darken(.1).hexString()}function H(){}const j=function(){let t=0;return function(){return t++}}();function Y(t){return null==t}function $(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.substr(0,7)&&"Array]"===e.substr(-6)}function U(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}const X=t=>("number"==typeof t||t instanceof Number)&&isFinite(+t);function q(t,e){return X(t)?t:e}function K(t,e){return void 0===t?e:t}const G=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:t/e,Z=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function Q(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function J(t,e,i,s){let n,o,a;if($(t))if(o=t.length,s)for(n=o-1;n>=0;n--)e.call(i,t[n],n);else for(n=0;ni;)t=t[e.substr(i,s-i)],s=ht(e,i=s+1);return t}function dt(t){return t.charAt(0).toUpperCase()+t.slice(1)}const ut=t=>void 0!==t,ft=t=>"function"==typeof t,gt=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0},pt=Object.create(null),mt=Object.create(null);function bt(t,e){if(!e)return t;const i=e.split(".");for(let e=0,s=i.length;et.chart.platform.getDevicePixelRatio()),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=((t,e)=>W(e.backgroundColor)),this.hoverBorderColor=((t,e)=>W(e.borderColor)),this.hoverColor=((t,e)=>W(e.color)),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.describe(t)}set(t,e){return xt(this,t,e)}get(t){return bt(this,t)}describe(t,e){return xt(mt,t,e)}override(t,e){return xt(pt,t,e)}route(t,e,i,s){const n=bt(this,t),o=bt(this,i),a="_"+e;Object.defineProperties(n,{[a]:{value:n[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[a],e=o[s];return U(t)?Object.assign({},e,t):K(t,e)},set(t){this[a]=t}}})}}({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}});const yt=Math.PI,vt=2*yt,wt=vt+yt,Mt=Number.POSITIVE_INFINITY,kt=yt/180,St=yt/2,Dt=yt/4,Pt=2*yt/3,Ct=Math.log10,Ot=Math.sign;function Tt(t){const e=Math.round(t);t=Rt(t,e,t/1e3)?e:t;const i=Math.pow(10,Math.floor(Ct(t))),s=t/i;return(s<=1?1:s<=2?2:s<=5?5:10)*i}function At(t){const e=[],i=Math.sqrt(t);let s;for(s=1;st-e).pop(),e}function Lt(t){return!isNaN(parseFloat(t))&&isFinite(t)}function Rt(t,e,i){return Math.abs(t-e)=t}function Ft(t,e,i){let s,n,o;for(s=0,n=t.length;sl&&h=Math.min(e,i)-s&&t<=Math.max(e,i)+s}function Xt(t){return!t||Y(t.size)||Y(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}function qt(t,e,i,s,n){let o=e[n];return o||(o=e[n]=t.measureText(n).width,i.push(n)),o>s&&(s=o),s}function Kt(t,e,i,s){let n=(s=s||{}).data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==e&&(n=s.data={},o=s.garbageCollect=[],s.font=e),t.save(),t.font=e;let a=0;const r=i.length;let l,h,c,d,u;for(l=0;li.length){for(l=0;l0&&t.stroke()}}function Jt(t,e,i){return i=i||.5,!e||t&&t.x>e.left-i&&t.xe.top-i&&t.y0&&""!==o.strokeColor;let l,h;for(t.save(),t.font=n.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]);Y(e.rotation)||t.rotate(e.rotation);e.color&&(t.fillStyle=e.color);e.textAlign&&(t.textAlign=e.textAlign);e.textBaseline&&(t.textBaseline=e.textBaseline)}(t,o),l=0;lt[i]1;)i(s=o+n>>1)?o=s:n=s;return{lo:o,hi:n}}const le=(t,e,i)=>re(t,i,s=>t[s][e]re(t,i,s=>t[s][e]>=i);function ce(t,e,i){let s=0,n=t.length;for(;ss&&t[n-1]>i;)n--;return s>0||n{const i="_onData"+dt(e),s=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...e){const n=s.apply(this,e);return t._chartjs.listeners.forEach(t=>{"function"==typeof t[i]&&t[i](...e)}),n}})}))}function fe(t,e){const i=t._chartjs;if(!i)return;const s=i.listeners,n=s.indexOf(e);-1!==n&&s.splice(n,1),s.length>0||(de.forEach(e=>{delete t[e]}),delete t._chartjs)}function ge(t){const e=new Set;let i,s;for(i=0,s=t.length;iwindow.getComputedStyle(t,null);function _e(t,e){return xe(t).getPropertyValue(e)}const ye=["top","right","bottom","left"];function ve(t,e,i){const s={};i=i?"-"+i:"";for(let n=0;n<4;n++){const o=ye[n];s[o]=parseFloat(t[e+"-"+o+i])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}const we=(t,e,i)=>(t>0||e>0)&&(!i||!i.shadowRoot);function Me(t,e){const{canvas:i,currentDevicePixelRatio:s}=e,n=xe(i),o="border-box"===n.boxSizing,a=ve(n,"padding"),r=ve(n,"border","width"),{x:l,y:h,box:c}=function(t,e){const i=t.native||t,s=i.touches,n=s&&s.length?s[0]:i,{offsetX:o,offsetY:a}=n;let r,l,h=!1;if(we(o,a,i.target))r=o,l=a;else{const t=e.getBoundingClientRect();r=n.clientX-t.left,l=n.clientY-t.top,h=!0}return{x:r,y:l,box:h}}(t,i),d=a.left+(c&&r.left),u=a.top+(c&&r.top);let{width:f,height:g}=e;return o&&(f-=a.width+r.width,g-=a.height+r.height),{x:Math.round((l-d)/f*i.width/s),y:Math.round((h-u)/g*i.height/s)}}const ke=t=>Math.round(10*t)/10;function Se(t,e,i,s){const n=xe(t),o=ve(n,"margin"),a=be(n.maxWidth,t,"clientWidth")||Mt,r=be(n.maxHeight,t,"clientHeight")||Mt,l=function(t,e,i){let s,n;if(void 0===e||void 0===i){const o=me(t);if(o){const t=o.getBoundingClientRect(),a=xe(o),r=ve(a,"border","width"),l=ve(a,"padding");e=t.width-l.width-r.width,i=t.height-l.height-r.height,s=be(a.maxWidth,o,"clientWidth"),n=be(a.maxHeight,o,"clientHeight")}else e=t.clientWidth,i=t.clientHeight}return{width:e,height:i,maxWidth:s||Mt,maxHeight:n||Mt}}(t,e,i);let{width:h,height:c}=l;if("content-box"===n.boxSizing){const t=ve(n,"border","width"),e=ve(n,"padding");h-=e.width+t.width,c-=e.height+t.height}return h=Math.max(0,h-o.width),c=Math.max(0,s?Math.floor(h/s):c-o.height),h=ke(Math.min(h,a,l.maxWidth)),c=ke(Math.min(c,r,l.maxHeight)),h&&!c&&(c=ke(h/2)),{width:h,height:c}}function De(t,e,i){const s=e||1,n=Math.floor(t.height*s),o=Math.floor(t.width*s);t.height=n/s,t.width=o/s;const a=t.canvas;return a.style&&(i||!a.style.height&&!a.style.width)&&(a.style.height=`${t.height}px`,a.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(t.currentDevicePixelRatio=s,a.height=n,a.width=o,t.ctx.setTransform(s,0,0,s,0,0),!0)}const Pe=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}();function Ce(t,e){const i=_e(t,e),s=i&&i.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function Oe(t,e){return"native"in t?{x:t.x,y:t.y}:Me(t,e)}function Te(t,e,i,s){const{controller:n,data:o,_sorted:a}=t,r=n._cachedMeta.iScale;if(r&&e===r.axis&&a&&o.length){const t=r._reversePixels?he:le;if(!s)return t(o,e,i);if(n._sharedOptions){const s=o[0],n="function"==typeof s.getRange&&s.getRange(e);if(n){const s=t(o,e,i-n),a=t(o,e,i+n);return{lo:s.lo,hi:a.hi}}}}return{lo:0,hi:o.length-1}}function Ae(t,e,i,s,n){const o=t.getSortedVisibleDatasetMetas(),a=i[e];for(let t=0,i=o.length;t{t[r](n[a],s)&&o.push({element:t,datasetIndex:e,index:i}),t.inRange(n.x,n.y,s)&&(l=!0)}),i.intersect&&!l?[]:o}var Fe={modes:{index(t,e,i,s){const n=Oe(e,t),o=i.axis||"x",a=i.intersect?Le(t,n,o,s):Re(t,n,o,!1,s),r=[];return a.length?(t.getSortedVisibleDatasetMetas().forEach(t=>{const e=a[0].index,i=t.data[e];i&&!i.skip&&r.push({element:i,datasetIndex:t.index,index:e})}),r):[]},dataset(t,e,i,s){const n=Oe(e,t),o=i.axis||"xy";let a=i.intersect?Le(t,n,o,s):Re(t,n,o,!1,s);if(a.length>0){const e=a[0].datasetIndex,i=t.getDatasetMeta(e).data;a=[];for(let t=0;tLe(t,Oe(e,t),i.axis||"xy",s),nearest:(t,e,i,s)=>Re(t,Oe(e,t),i.axis||"xy",i.intersect,s),x:(t,e,i,s)=>(i.axis="x",Ee(t,e,i,s)),y:(t,e,i,s)=>(i.axis="y",Ee(t,e,i,s))}};const Ie=new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/),ze=new RegExp(/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/);function Be(t,e){const i=(""+t).match(Ie);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}const Ve=t=>+t||0;function Ne(t,e){const i={},s=U(e),n=s?Object.keys(e):e,o=U(t)?s?i=>K(t[i],t[e[i]]):e=>t[e]:()=>t;for(const t of n)i[t]=Ve(o(t));return i}function We(t){return Ne(t,{top:"y",right:"x",bottom:"y",left:"x"})}function He(t){return Ne(t,["topLeft","topRight","bottomLeft","bottomRight"])}function je(t){const e=We(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function Ye(t,e){t=t||{},e=e||_t.font;let i=K(t.size,e.size);"string"==typeof i&&(i=parseInt(i,10));let s=K(t.style,e.style);s&&!(""+s).match(ze)&&(console.warn('Invalid font style specified: "'+s+'"'),s="");const n={family:K(t.family,e.family),lineHeight:Be(K(t.lineHeight,e.lineHeight),i),size:i,style:s,weight:K(t.weight,e.weight),string:""};return n.string=Xt(n),n}function $e(t,e,i,s){let n,o,a,r=!0;for(n=0,o=t.length;ni&&0===t?0:t+e;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function Xe(t,e){return Object.assign(Object.create(t),e)}const qe=["left","top","right","bottom"];function Ke(t,e){return t.filter(t=>t.pos===e)}function Ge(t,e){return t.filter(t=>-1===qe.indexOf(t.pos)&&t.box.axis===e)}function Ze(t,e){return t.sort((t,i)=>{const s=e?i:t,n=e?t:i;return s.weight===n.weight?s.index-n.index:s.weight-n.weight})}function Qe(t,e){const i=function(t){const e={};for(const i of t){const{stack:t,pos:s,stackWeight:n}=i;if(!t||!qe.includes(s))continue;const o=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=n}return e}(t),{vBoxMaxWidth:s,hBoxMaxHeight:n}=e;let o,a,r;for(o=0,a=t.length;o{s[t]=Math.max(e[t],i[t])}),s}return s(t?["left","right"]:["top","bottom"])}function si(t,e,i,s){const n=[];let o,a,r,l,h,c;for(o=0,a=t.length,h=0;ot.box.fullSize),!0),s=Ze(Ke(e,"left"),!0),n=Ze(Ke(e,"right")),o=Ze(Ke(e,"top"),!0),a=Ze(Ke(e,"bottom")),r=Ge(e,"x"),l=Ge(e,"y");return{fullSize:i,leftAndTop:s.concat(o),rightAndBottom:n.concat(l).concat(a).concat(r),chartArea:Ke(e,"chartArea"),vertical:s.concat(n).concat(l),horizontal:o.concat(a).concat(r)}}(t.boxes),l=r.vertical,h=r.horizontal;J(t.boxes,t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()});const c=l.reduce((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1,0)||1,d=Object.freeze({outerWidth:e,outerHeight:i,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/c,hBoxMaxHeight:a/2}),u=Object.assign({},n);ti(u,je(s));const f=Object.assign({maxPadding:u,w:o,h:a,x:n.left,y:n.top},n),g=Qe(l.concat(h),d);si(r.fullSize,f,d,g),si(l,f,d,g),si(h,f,d,g)&&si(l,f,d,g),function(t){const e=t.maxPadding;function i(i){const s=Math.max(e[i]-t[i],0);return t[i]+=s,s}t.y+=i("top"),t.x+=i("left"),i("right"),i("bottom")}(f),oi(r.leftAndTop,f,d,g),f.x+=f.w,f.y+=f.h,oi(r.rightAndBottom,f,d,g),t.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},J(r.chartArea,e=>{const i=e.box;Object.assign(i,t.chartArea),i.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}};function ri(t,e=[""],i=t,s,n=(()=>t[0])){return ut(s)||(s=xi("_fallback",t)),new Proxy({[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:i,_fallback:s,_getTarget:n,override:n=>ri([n,...t],e,i,s)},{deleteProperty:(e,i)=>(delete e[i],delete e._keys,delete t[0][i],!0),get:(i,s)=>ui(i,s,()=>(function(t,e,i,s){let n;for(const o of e)if(n=xi(ci(o,t),i),ut(n))return di(t,n)?mi(i,s,t,n):n})(s,e,t,i)),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>_i(t).includes(e),ownKeys:t=>_i(t),set:(t,e,i)=>((t._storage||(t._storage=n()))[e]=i,delete t[e],delete t._keys,!0)})}function li(t,e,i,s){const n={_cacheable:!1,_proxy:t,_context:e,_subProxy:i,_stack:new Set,_descriptors:hi(t,s),setContext:e=>li(t,e,i,s),override:n=>li(t.override(n),e,i,s)};return new Proxy(n,{deleteProperty:(e,i)=>(delete e[i],delete t[i],!0),get:(t,e,i)=>ui(t,e,()=>(function(t,e,i){const{_proxy:s,_context:n,_subProxy:o,_descriptors:a}=t;let r=s[e];ft(r)&&a.isScriptable(e)&&(r=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_stack:r}=i;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);r.add(t),e=e(o,a||s),r.delete(t),di(t,e)&&(e=mi(n._scopes,n,t,e));return e}(e,r,t,i));$(r)&&r.length&&(r=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_descriptors:r}=i;if(ut(o.index)&&s(t))e=e[o.index%e.length];else if(U(e[0])){const i=e,s=n._scopes.filter(t=>t!==i);e=[];for(const l of i){const i=mi(s,n,t,l);e.push(li(i,o,a&&a[t],r))}}return e}(e,r,t,a.isIndexable));di(e,r)&&(r=li(r,n,o&&o[e],a));return r})(t,e,i)),getOwnPropertyDescriptor:(e,i)=>e._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,i)=>Reflect.has(t,i),ownKeys:()=>Reflect.ownKeys(t),set:(e,i,s)=>(t[i]=s,delete e[i],!0)})}function hi(t,e={scriptable:!0,indexable:!0}){const{_scriptable:i=e.scriptable,_indexable:s=e.indexable,_allKeys:n=e.allKeys}=t;return{allKeys:n,scriptable:i,indexable:s,isScriptable:ft(i)?i:()=>i,isIndexable:ft(s)?s:()=>s}}const ci=(t,e)=>t?t+dt(e):e,di=(t,e)=>U(e)&&"adapters"!==t&&(null===Object.getPrototypeOf(e)||e.constructor===Object);function ui(t,e,i){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];const s=i();return t[e]=s,s}function fi(t,e,i){return ft(t)?t(e,i):t}const gi=(t,e)=>!0===t?e:"string"==typeof t?ct(e,t):void 0;function pi(t,e,i,s){for(const n of e){const e=gi(i,n);if(e){t.add(e);const n=fi(e._fallback,i,e);if(ut(n)&&n!==i&&n!==s)return n}else if(!1===e&&ut(s)&&i!==s)return null}return!1}function mi(t,e,i,s){const n=e._rootScopes,o=fi(e._fallback,i,s),a=[...t,...n],r=new Set;r.add(s);let l=bi(r,a,i,o||i);return null!==l&&((!ut(o)||o===i||null!==(l=bi(r,a,o,l)))&&ri(Array.from(r),[""],n,o,()=>(function(t,e,i){const s=t._getTarget();e in s||(s[e]={});const n=s[e];if($(n)&&U(i))return i;return n})(e,i,s)))}function bi(t,e,i,s){for(;i;)i=pi(t,e,i,s);return i}function xi(t,e){for(const i of e){if(!i)continue;const e=i[t];if(ut(e))return e}}function _i(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const i of t)for(const t of Object.keys(i).filter(t=>!t.startsWith("_")))e.add(t);return Array.from(e)}(t._scopes)),e}const yi=Number.EPSILON||1e-14,vi=(t,e)=>e"x"===t?"y":"x";function Mi(t,e,i,s){const n=t.skip?e:t,o=e,a=i.skip?e:i,r=Nt(o,n),l=Nt(a,o);let h=r/(r+l),c=l/(r+l);const d=s*(h=isNaN(h)?0:h),u=s*(c=isNaN(c)?0:c);return{previous:{x:o.x-d*(a.x-n.x),y:o.y-d*(a.y-n.y)},next:{x:o.x+u*(a.x-n.x),y:o.y+u*(a.y-n.y)}}}function ki(t,e="x"){const i=wi(e),s=t.length,n=Array(s).fill(0),o=Array(s);let a,r,l,h=vi(t,0);for(a=0;a!t.skip)),"monotone"===e.cubicInterpolationMode)ki(t,n);else{let i=s?t[t.length-1]:t[0];for(o=0,a=t.length;o0===t||1===t,Ci=(t,e,i)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*vt/i),Oi=(t,e,i)=>Math.pow(2,-10*t)*Math.sin((t-e)*vt/i)+1,Ti={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*St),easeOutSine:t=>Math.sin(t*St),easeInOutSine:t=>-.5*(Math.cos(yt*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>Pi(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>Pi(t)?t:Ci(t,.075,.3),easeOutElastic:t=>Pi(t)?t:Oi(t,.075,.3),easeInOutElastic:t=>Pi(t)?t:t<.5?.5*Ci(2*t,.1125,.45):.5+.5*Oi(2*t-1,.1125,.45),easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-Ti.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},easeInOutBounce:t=>t<.5?.5*Ti.easeInBounce(2*t):.5*Ti.easeOutBounce(2*t-1)+.5};function Ai(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:t.y+i*(e.y-t.y)}}function Li(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:"middle"===s?i<.5?t.y:e.y:"after"===s?i<1?t.y:e.y:i>0?e.y:t.y}}function Ri(t,e,i,s){const n={x:t.cp2x,y:t.cp2y},o={x:e.cp1x,y:e.cp1y},a=Ai(t,n,i),r=Ai(n,o,i),l=Ai(o,e,i),h=Ai(a,r,i),c=Ai(r,l,i);return Ai(h,c,i)}const Ei=new Map;function Fi(t,e,i){return function(t,e){e=e||{};const i=t+JSON.stringify(e);let s=Ei.get(i);return s||(s=new Intl.NumberFormat(t,e),Ei.set(i,s)),s}(e,i).format(t)}const Ii=function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}},zi=function(){return{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}};function Bi(t,e,i){return t?Ii(e,i):zi()}function Vi(t,e){let i,s;"ltr"!==e&&"rtl"!==e||(s=[(i=t.canvas.style).getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=s)}function Ni(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Wi(t){return"angle"===t?{between:jt,compare:Wt,normalize:Ht}:{between:Ut,compare:(t,e)=>t-e,normalize:t=>t}}function Hi({start:t,end:e,count:i,loop:s,style:n}){return{start:t%i,end:e%i,loop:s&&(e-t+1)%i==0,style:n}}function ji(t,e,i){if(!i)return[t];const{property:s,start:n,end:o}=i,a=e.length,{compare:r,between:l,normalize:h}=Wi(s),{start:c,end:d,loop:u,style:f}=function(t,e,i){const{property:s,start:n,end:o}=i,{between:a,normalize:r}=Wi(s),l=e.length;let h,c,{start:d,end:u,loop:f}=t;if(f){for(d+=l,u+=l,h=0,c=l;hx||(()=>l(n,b,p)&&0!==r(n,b))(),v=()=>!x||(()=>0===r(o,p)||l(o,b,p))();for(let t=c,i=c;t<=d;++t)(m=e[t%a]).skip||(p=h(m[s]))!==b&&(x=l(p,n,o),null===_&&y()&&(_=0===r(p,n)?t:i),null!==_&&v()&&(g.push(Hi({start:_,end:t,loop:u,count:a,style:f})),_=null),i=t,b=p);return null!==_&&g.push(Hi({start:_,end:d,loop:u,count:a,style:f})),g}function Yi(t,e){const i=[],s=t.segments;for(let n=0;nn&&t[o%e].skip;)o--;return{start:n,end:o%=e}}(i,n,o,s);return Ui(t,!0===s?[{start:a,end:r,loop:o}]:function(t,e,i,s){const n=t.length,o=[];let a,r=e,l=t[e];for(a=e+1;a<=i;++a){const i=t[a%n];i.skip||i.stop?l.skip||(s=!1,o.push({start:e%n,end:(a-1)%n,loop:s}),e=r=i.stop?a:null):(r=a,l.skip&&(e=a)),l=i}return null!==r&&o.push({start:e%n,end:r%n,loop:s}),o}(i,a,rnull===t||""===t;const es=!!Pe&&{passive:!0};function is(t,e,i){t.canvas.removeEventListener(e,i,es)}function ss(t,e){for(const i of t)if(i===e||i.contains(e))return!0}function ns(t,e,i){const s=t.canvas,n=new MutationObserver(t=>{let e=!1;for(const i of t)e=(e=e||ss(i.addedNodes,s))&&!ss(i.removedNodes,s);e&&i()});return n.observe(document,{childList:!0,subtree:!0}),n}function os(t,e,i){const s=t.canvas,n=new MutationObserver(t=>{let e=!1;for(const i of t)e=(e=e||ss(i.removedNodes,s))&&!ss(i.addedNodes,s);e&&i()});return n.observe(document,{childList:!0,subtree:!0}),n}const as=new Map;let rs=0;function ls(){const t=window.devicePixelRatio;t!==rs&&(rs=t,as.forEach((e,i)=>{i.currentDevicePixelRatio!==t&&e()}))}function hs(t,i,s){const n=t.canvas,o=n&&me(n);if(!o)return;const a=e((t,e)=>{const i=o.clientWidth;s(t,e),i{const e=t[0],i=e.contentRect.width,s=e.contentRect.height;0===i&&0===s||a(i,s)});return r.observe(o),function(t,e){as.size||window.addEventListener("resize",ls),as.set(t,e)}(t,a),r}function cs(t,e,i){i&&i.disconnect(),"resize"===e&&function(t){as.delete(t),as.size||window.removeEventListener("resize",ls)}(t)}function ds(t,i,s){const n=t.canvas,o=e(e=>{null!==t.ctx&&s(function(t,e){const i=Ji[t.type]||t.type,{x:s,y:n}=Me(t,e);return{type:i,chart:e,native:t,x:void 0!==s?s:null,y:void 0!==n?n:null}}(e,t))},t,t=>{const e=t[0];return[e,e.offsetX,e.offsetY]});return function(t,e,i){t.addEventListener(e,i,es)}(n,i,o),o}class us extends Gi{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(function(t,e){const i=t.style,s=t.getAttribute("height"),n=t.getAttribute("width");if(t[Qi]={initial:{height:s,width:n,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",ts(n)){const e=Ce(t,"width");void 0!==e&&(t.width=e)}if(ts(s))if(""===t.style.height)t.height=t.width/(e||2);else{const e=Ce(t,"height");void 0!==e&&(t.height=e)}}(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e[Qi])return!1;const i=e[Qi].initial;["height","width"].forEach(t=>{const s=i[t];Y(s)?e.removeAttribute(t):e.setAttribute(t,s)});const s=i.style||{};return Object.keys(s).forEach(t=>{e.style[t]=s[t]}),e.width=e.width,delete e[Qi],!0}addEventListener(t,e,i){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),n={attach:ns,detach:os,resize:hs}[e]||ds;s[e]=n(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];s&&(({attach:cs,detach:cs,resize:cs}[e]||is)(t,e,s),i[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return Se(t,e,i,s)}isAttached(t){const e=me(t);return!(!e||!e.isConnected)}}function fs(t){return!pe()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?Zi:us}var gs=Object.freeze({__proto__:null,_detectPlatform:fs,BasePlatform:Gi,BasicPlatform:Zi,DomPlatform:us});const ps={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const s=N(t||"transparent"),n=s.valid&&N(e||"transparent");return n&&n.valid?n.mix(s,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class ms{constructor(t,e,i,s){const n=e[i];s=$e([t.to,s,n,t.from]);const o=$e([t.from,n,s]);this._active=!0,this._fn=t.fn||ps[t.type||typeof o],this._easing=Ti[t.easing]||Ti.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=o,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const s=this._target[this._prop],n=i-this._start,o=this._duration-n;this._start=i,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=n,this._loop=!!t.loop,this._to=$e([t.to,e,s,t.from]),this._from=$e([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,s=this._prop,n=this._from,o=this._loop,a=this._to;let r;if(this._active=n!==a&&(o||e1?2-r:r,r=this._easing(Math.min(1,Math.max(0,r))),this._target[s]=this._fn(n,a,r))}wait(){const t=this._promises||(this._promises=[]);return new Promise((e,i)=>{t.push({res:e,rej:i})})}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let t=0;t"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),_t.set("animations",{colors:{type:"color",properties:["color","borderColor","backgroundColor"]},numbers:{type:"number",properties:["x","y","borderWidth","radius","tension"]}}),_t.describe("animations",{_fallback:"animation"}),_t.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}});class xs{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!U(t))return;const e=this._properties;Object.getOwnPropertyNames(t).forEach(i=>{const s=t[i];if(!U(s))return;const n={};for(const t of bs)n[t]=s[t];($(s.properties)&&s.properties||[i]).forEach(t=>{t!==i&&e.has(t)||e.set(t,n)})})}_animateOptions(t,e){const i=e.options,s=function(t,e){if(!e)return;let i=t.options;if(!i)return void(t.options=e);i.$shared&&(t.options=i=Object.assign({},i,{$shared:!1,$animations:{}}));return i}(t,i);if(!s)return[];const n=this._createAnimations(s,i);return i.$shared&&function(t,e){const i=[],s=Object.keys(e);for(let e=0;e{t.options=i},()=>{}),n}_createAnimations(t,e){const i=this._properties,s=[],n=t.$animations||(t.$animations={}),o=Object.keys(e),a=Date.now();let r;for(r=o.length-1;r>=0;--r){const l=o[r];if("$"===l.charAt(0))continue;if("options"===l){s.push(...this._animateOptions(t,e));continue}const h=e[l];let c=n[l];const d=i.get(l);if(c){if(d&&c.active()){c.update(d,h,a);continue}c.cancel()}d&&d.duration?(n[l]=c=new ms(d,t,l,h),s.push(c)):t[l]=h}return s}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(a.add(this._chart,i),!0):void 0}}function _s(t,e){const i=t&&t.options||{},s=i.reverse,n=void 0===i.min?e:0,o=void 0===i.max?e:0;return{start:s?o:n,end:s?n:o}}function ys(t,e){const i=[],s=t._getSortedDatasetMetas(e);let n,o;for(n=0,o=s.length;n0||!i&&e<0)return n.index}return null}function Ss(t,e){const{chart:i,_cachedMeta:s}=t,n=i._stacks||(i._stacks={}),{iScale:o,vScale:a,index:r}=s,l=o.axis,h=a.axis,c=function(t,e,i){return`${t.id}.${e.id}.${i.stack||i.type}`}(o,a,s),d=e.length;let u;for(let t=0;ti[t].axis===e).shift()}function Ps(t,e){const i=t.controller.index,s=t.vScale&&t.vScale.axis;if(s){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[s]||void 0===e[s][i])return;delete e[s][i]}}}const Cs=t=>"reset"===t||"none"===t,Os=(t,e)=>e?t:Object.assign({},t),Ts=(t,e,i)=>t&&!e.hidden&&e._stacked&&{keys:ys(i,!0),values:null};class As{constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.$context=void 0,this._syncList=[],this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=ws(t.vScale,t),this.addElements()}updateIndex(t){this.index!==t&&Ps(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(t,e,i,s)=>"x"===t?e:"r"===t?s:i,n=e.xAxisID=K(i.xAxisID,Ds(t,"x")),o=e.yAxisID=K(i.yAxisID,Ds(t,"y")),a=e.rAxisID=K(i.rAxisID,Ds(t,"r")),r=e.indexAxis,l=e.iAxisID=s(r,n,o,a),h=e.vAxisID=s(r,o,n,a);e.xScale=this.getScaleForId(n),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(l),e.vScale=this.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&fe(this._data,this),t._stacked&&Ps(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(U(e))this._data=function(t){const e=Object.keys(t),i=new Array(e.length);let s,n,o;for(s=0,n=e.length;s0&&i._parsed[t-1];if(!1===this._parsing)i._parsed=s,i._sorted=!0,h=s;else{h=$(s[t])?this.parseArrayData(i,s,t,e):U(s[t])?this.parseObjectData(i,s,t,e):this.parsePrimitiveData(i,s,t,e);const n=()=>null===l[a]||d&&l[a]e||c=0;--d)if(!f()){this.updateRangeFromParsed(l,t,u,r);break}return l}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,n,o;for(s=0,n=e.length;s=0&&tthis.getContext(i,s),c);return f.$shared&&(f.$shared=r,n[o]=Object.freeze(Os(f,r))),f}_resolveAnimations(t,e,i){const s=this.chart,n=this._cachedDataOpts,o=`animation-${e}`,a=n[o];if(a)return a;let r;if(!1!==s.options.animation){const s=this.chart.config,n=s.datasetAnimationScopeKeys(this._type,e),o=s.getOptionScopes(this.getDataset(),n);r=s.createResolver(o,this.getContext(t,i,e))}const l=new xs(s,r&&r.animations);return r&&r._cacheable&&(n[o]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Cs(t)||this.chart._animationsDisabled}updateElement(t,e,i,s){Cs(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!Cs(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,s){t.active=s;const n=this.getStyle(e,s);this._resolveAnimations(e,i,s).update(t,{options:!s&&this.getSharedOptions(n)||n})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,i=this._cachedMeta.data;for(const[t,e,i]of this._syncList)this[t](e,i);this._syncList=[];const s=i.length,n=e.length,o=Math.min(n,s);o&&this.parse(0,o),n>s?this._insertElements(s,n-s,t):n{for(t.length+=e,a=t.length-1;a>=o;a--)t[a]=t[a-e]};for(r(n),a=t;a{s[t]=i[t]&&i[t].active()?i[t]._to:this[t]}),s}}Ls.defaults={},Ls.defaultRoutes=void 0;const Rs={values:t=>$(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const s=this.chart.options.locale;let n,o=t;if(i.length>1){const e=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));(e<1e-4||e>1e15)&&(n="scientific"),o=function(t,e){let i=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;Math.abs(i)>=1&&t!==Math.floor(t)&&(i=t-Math.floor(t));return i}(t,i)}const a=Ct(Math.abs(o)),r=Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:n,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),Fi(t,s,l)},logarithmic(t,e,i){if(0===t)return"0";const s=t/Math.pow(10,Math.floor(Ct(t)));return 1===s||2===s||5===s?Rs.numeric.call(this,t,e,i):""}};var Es={formatters:Rs};function Fs(t,e){const i=t.options.ticks,s=i.maxTicksLimit||function(t){const e=t.options.offset,i=t._tickSize(),s=t._length/i+(e?0:1),n=t._maxLength/i;return Math.floor(Math.min(s,n))}(t),n=i.major.enabled?function(t){const e=[];let i,s;for(i=0,s=t.length;is)return function(t,e,i,s){let n,o=0,a=i[0];for(s=Math.ceil(s),n=0;nn)return e}return Math.max(n,1)}(n,e,s);if(o>0){let t,i;const s=o>1?Math.round((r-a)/(o-1)):null;for(Is(e,l,h,Y(s)?0:a-s,a),t=0,i=o-1;te.lineWidth,tickColor:(t,e)=>e.color,offset:!1,borderDash:[],borderDashOffset:0,borderWidth:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Es.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),_t.route("scale.ticks","color","","color"),_t.route("scale.grid","color","","borderColor"),_t.route("scale.grid","borderColor","","borderColor"),_t.route("scale.title","color","","color"),_t.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t}),_t.describe("scales",{_fallback:"scale"}),_t.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t});const zs=t=>"left"===t?"right":"right"===t?"left":t,Bs=(t,e,i)=>"top"===e||"left"===e?t[e]+i:t[e]-i;function Vs(t,e){const i=[],s=t.length/e,n=t.length;let o=0;for(;oa+1e-6)))return l}function Ws(t){return t.drawTicks?t.tickLength:0}function Hs(t,e){if(!t.display)return 0;const i=Ye(t.font,e),s=je(t.padding);return($(t.text)?t.text.length:1)*i.lineHeight+s.height}function js(t,e,i){let n=s(t);return(i&&"right"!==e||!i&&"right"===e)&&(n=zs(n)),n}class Ys extends Ls{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:i,_suggestedMax:s}=this;return t=q(t,Number.POSITIVE_INFINITY),e=q(e,Number.NEGATIVE_INFINITY),i=q(i,Number.POSITIVE_INFINITY),s=q(s,Number.NEGATIVE_INFINITY),{min:q(t,i),max:q(e,s),minDefined:X(t),maxDefined:X(e)}}getMinMax(t){let e,{min:i,max:s,minDefined:n,maxDefined:o}=this.getUserBounds();if(n&&o)return{min:i,max:s};const a=this.getMatchingVisibleMetas();for(let r=0,l=a.length;rs?s:i,q(s=n&&i>s?i:s,i)),max:q(s,q(i,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){Q(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:n,ticks:o}=this.options,a=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Ue(this,n,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const r=a=n||i<=1||!this.isHorizontal())return void(this.labelRotation=s);const h=this._getLabelSizes(),c=h.widest.width,d=h.highest.height,u=Yt(this.chart.width-c,0,this.maxWidth);c+6>(o=t.offset?this.maxWidth/i:u/(i-1))&&(o=u/(i-(t.offset?.5:1)),a=this.maxHeight-Ws(t.grid)-e.padding-Hs(t.title,this.chart.options.font),r=Math.sqrt(c*c+d*d),l=zt(Math.min(Math.asin(Yt((h.highest.height+6)/o,-1,1)),Math.asin(Yt(a/r,-1,1))-Math.asin(Yt(d/r,-1,1)))),l=Math.max(s,Math.min(n,l))),this.labelRotation=l}afterCalculateLabelRotation(){Q(this.options.afterCalculateLabelRotation,[this])}beforeFit(){Q(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:n}}=this,o=this._isVisible(),a=this.isHorizontal();if(o){const o=Hs(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=Ws(n)+o):(t.height=this.maxHeight,t.width=Ws(n)+o),i.display&&this.ticks.length){const{first:e,last:s,widest:n,highest:o}=this._getLabelSizes(),r=2*i.padding,l=It(this.labelRotation),h=Math.cos(l),c=Math.sin(l);if(a){const e=i.mirror?0:c*n.width+h*o.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=i.mirror?0:h*n.width+c*o.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,s,c,h)}}this._handleMargins(),a?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,s){const{ticks:{align:n,padding:o},position:a}=this.options,r=0!==this.labelRotation,l="top"!==a&&"x"===this.axis;if(this.isHorizontal()){const a=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1);let c=0,d=0;r?l?(c=s*t.width,d=i*e.height):(c=i*t.height,d=s*e.width):"start"===n?d=e.width:"end"===n?c=t.width:(c=t.width/2,d=e.width/2),this.paddingLeft=Math.max((c-a+o)*this.width/(this.width-a),0),this.paddingRight=Math.max((d-h+o)*this.width/(this.width-h),0)}else{let i=e.height/2,s=t.height/2;"start"===n?(i=0,s=t.height):"end"===n&&(i=e.height,s=0),this.paddingTop=i+o,this.paddingBottom=s+o}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){Q(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,i;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,i=t.length;e{const i=t.gc,s=i.length/2;let n;if(s>e){for(n=0;n({width:n[t]||0,height:o[t]||0});return{first:v(0),last:v(e-1),widest:v(_),highest:v(y),widths:n,heights:o}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return $t(this._alignToPixels?Gt(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&ta*s?a/i:r/s:r*s0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:n,position:o}=s,a=n.offset,r=this.isHorizontal(),l=this.ticks.length+(a?1:0),h=Ws(n),c=[],d=n.setContext(this.getContext()),u=d.drawBorder?d.borderWidth:0,f=u/2,g=function(t){return Gt(i,t,u)};let p,m,b,x,_,y,v,w,M,k,S,D;if("top"===o)p=g(this.bottom),y=this.bottom-h,w=p-f,k=g(t.top)+f,D=t.bottom;else if("bottom"===o)p=g(this.top),k=t.top,D=g(t.bottom)-f,y=p+f,w=this.top+h;else if("left"===o)p=g(this.right),_=this.right-h,v=p-f,M=g(t.left)+f,S=t.right;else if("right"===o)p=g(this.left),M=t.left,S=g(t.right)-f,_=p+f,v=this.left+h;else if("x"===e){if("center"===o)p=g((t.top+t.bottom)/2+.5);else if(U(o)){const t=Object.keys(o)[0],e=o[t];p=g(this.chart.scales[t].getPixelForValue(e))}k=t.top,D=t.bottom,w=(y=p+f)+h}else if("y"===e){if("center"===o)p=g((t.left+t.right)/2);else if(U(o)){const t=Object.keys(o)[0],e=o[t];p=g(this.chart.scales[t].getPixelForValue(e))}v=(_=p-f)-h,M=t.left,S=t.right}const P=K(s.ticks.maxTicksLimit,l),C=Math.max(1,Math.ceil(l/P));for(m=0;me.value===t);if(i>=0){return e.setContext(this.getContext(i)).lineWidth}return 0}drawGrid(t){const e=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let n,o;const a=(t,e,s)=>{s.width&&s.color&&(i.save(),i.lineWidth=s.width,i.strokeStyle=s.color,i.setLineDash(s.borderDash||[]),i.lineDashOffset=s.borderDashOffset,i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke(),i.restore())};if(e.display)for(n=0,o=s.length;n{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:i+1,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let n,o;for(n=0,o=e.length;n{const s=i.split("."),n=s.pop(),o=[t].concat(s).join("."),a=e[i].split("."),r=a.pop(),l=a.join(".");_t.route(o,n,l,r)})}(e,t.defaultRoutes);t.descriptors&&_t.describe(e,t.descriptors)}(t,o,i),this.override&&_t.override(t.id,t.overrides),o)}get(t){return this.items[t]}unregister(t){const e=this.items,i=t.id,s=this.scope;i in e&&delete e[i],s&&i in _t[s]&&(delete _t[s][i],this.override&&delete pt[i])}}var Us=new class{constructor(){this.controllers=new $s(As,"datasets",!0),this.elements=new $s(Ls,"elements"),this.plugins=new $s(Object,"plugins"),this.scales=new $s(Ys,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){[...e].forEach(e=>{const s=i||this._getRegistryForType(e);i||s.isForType(e)||s===this.plugins&&e.id?this._exec(t,s,e):J(e,e=>{const s=i||this._getRegistryForType(e);this._exec(t,s,e)})})}_exec(t,e,i){const s=dt(t);Q(i["before"+s],[],i),e[t](i),Q(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;et.filter(t=>!e.some(e=>t.plugin.id===e.plugin.id));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function qs(t,e){return e||!1!==t?!0===t?{}:t:null}function Ks(t,e,i,s){const n=t.pluginScopeKeys(e),o=t.getOptionScopes(i,n);return t.createResolver(o,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Gs(t,e){const i=_t.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function Zs(t,e){return"x"===t||"y"===t?t:e.axis||("top"===(i=e.position)||"bottom"===i?"x":"left"===i||"right"===i?"y":void 0)||t.charAt(0).toLowerCase();var i}function Qs(t){const e=t.options||(t.options={});e.plugins=K(e.plugins,{}),e.scales=function(t,e){const i=pt[t.type]||{scales:{}},s=e.scales||{},n=Gs(t.type,e),o=Object.create(null),a=Object.create(null);return Object.keys(s).forEach(t=>{const e=s[t];if(!U(e))return console.error(`Invalid scale configuration for scale: ${t}`);if(e._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);const r=Zs(t,e),l=function(t,e){return t===e?"_index_":"_value_"}(r,n),h=i.scales||{};o[r]=o[r]||t,a[t]=ot(Object.create(null),[{axis:r},e,h[r],h[l]])}),t.data.datasets.forEach(i=>{const n=i.type||t.type,r=i.indexAxis||Gs(n,e),l=(pt[n]||{}).scales||{};Object.keys(l).forEach(t=>{const e=function(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}(t,r),n=i[e+"AxisID"]||o[e]||e;a[n]=a[n]||Object.create(null),ot(a[n],[{axis:e},s[n],l[t]])})}),Object.keys(a).forEach(t=>{const e=a[t];ot(e,[_t.scales[e.type],_t.scale])}),a}(t,e)}function Js(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const tn=new Map,en=new Set;function sn(t,e){let i=tn.get(t);return i||(i=e(),tn.set(t,i),en.add(i)),i}const nn=(t,e,i)=>{const s=ct(e,i);void 0!==s&&t.add(s)};class on{constructor(t){this._config=function(t){return(t=t||{}).data=Js(t.data),Qs(t),t}(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Js(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Qs(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return sn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return sn(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return sn(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id;return sn(`${this.type}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){const i=this._scopeCache;let s=i.get(t);return s&&!e||(s=new Map,i.set(t,s)),s}getOptionScopes(t,e,i){const{options:s,type:n}=this,o=this._cachedScopes(t,i),a=o.get(e);if(a)return a;const r=new Set;e.forEach(e=>{t&&(r.add(t),e.forEach(e=>nn(r,t,e))),e.forEach(t=>nn(r,s,t)),e.forEach(t=>nn(r,pt[n]||{},t)),e.forEach(t=>nn(r,_t,t)),e.forEach(t=>nn(r,mt,t))});const l=Array.from(r);return 0===l.length&&l.push(Object.create(null)),en.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,pt[e]||{},_t.datasets[e]||{},{type:e},_t,mt]}resolveNamedOptions(t,e,i,s=[""]){const n={$shared:!0},{resolver:o,subPrefixes:a}=an(this._resolverCache,t,s);let r=o;if(function(t,e){const{isScriptable:i,isIndexable:s}=hi(t);for(const n of e){const e=i(n),o=s(n),a=(o||e)&&t[n];if(e&&(ft(a)||rn(a))||o&&$(a))return!0}return!1}(o,e)){n.$shared=!1,r=li(o,i=ft(i)?i():i,this.createResolver(t,i,a))}for(const t of e)n[t]=r[t];return n}createResolver(t,e,i=[""],s){const{resolver:n}=an(this._resolverCache,t,i);return U(e)?li(n,e,void 0,s):n}}function an(t,e,i){let s=t.get(e);s||(s=new Map,t.set(e,s));const n=i.join();let o=s.get(n);if(!o){o={resolver:ri(e,i),subPrefixes:i.filter(t=>!t.toLowerCase().includes("hover"))},s.set(n,o)}return o}const rn=t=>U(t)&&Object.getOwnPropertyNames(t).reduce((e,i)=>e||ft(t[i]),!1);const ln=["top","bottom","left","right","chartArea"];function hn(t,e){return"top"===t||"bottom"===t||-1===ln.indexOf(t)&&"x"===e}function cn(t,e){return function(i,s){return i[t]===s[t]?i[e]-s[e]:i[t]-s[t]}}function dn(t){const e=t.chart,i=e.options.animation;e.notifyPlugins("afterRender"),Q(i&&i.onComplete,[t],e)}function un(t){const e=t.chart,i=e.options.animation;Q(i&&i.onProgress,[t],e)}function fn(t){return pe()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const gn={},pn=t=>{const e=fn(t);return Object.values(gn).filter(t=>t.canvas===e).pop()};function mn(t,e,i){const s=Object.keys(t);for(const n of s){const s=+n;if(s>=e){const o=t[n];delete t[n],(i>0||s>e)&&(t[s+i]=o)}}}class bn{constructor(t,e){const s=this.config=new on(e),n=fn(t),o=pn(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas can be reused.");const r=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||fs(n)),this.platform.updateConfig(s);const l=this.platform.acquireContext(n,r.aspectRatio),h=l&&l.canvas,c=h&&h.height,d=h&&h.width;this.id=j(),this.ctx=l,this.canvas=h,this.width=d,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Xs,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=i(t=>this.update(t),r.resizeDelay||0),this._dataChanges=[],gn[this.id]=this,l&&h?(a.listen(this,"complete",dn),a.listen(this,"progress",un),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:s,_aspectRatio:n}=this;return Y(t)?e&&n?n:s?i/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():De(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Zt(this.canvas,this.ctx),this}stop(){return a.stop(this),this}resize(t,e){a.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,s=this.canvas,n=i.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(s,t,e,n),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,De(this,a,!0)&&(this.notifyPlugins("resize",{size:o}),Q(i.onResize,[this,o],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){J(this.options.scales||{},(t,e)=>{t.id=e})}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce((t,e)=>(t[e]=!1,t),{});let n=[];e&&(n=n.concat(Object.keys(e).map(t=>{const i=e[t],s=Zs(t,i),n="r"===s,o="x"===s;return{options:i,dposition:n?"chartArea":o?"bottom":"left",dtype:n?"radialLinear":o?"category":"linear"}}))),J(n,e=>{const n=e.options,o=n.id,a=Zs(o,n),r=K(n.type,e.dtype);void 0!==n.position&&hn(n.position,a)===hn(e.dposition)||(n.position=e.dposition),s[o]=!0;let l=null;if(o in i&&i[o].type===r)l=i[o];else{l=new(Us.getScale(r))({id:o,type:r,ctx:this.ctx,chart:this}),i[l.id]=l}l.init(n,t)}),J(s,(t,e)=>{t||delete i[e]}),J(i,t=>{ai.configure(this,t,t.options),ai.addBox(this,t)})}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort((t,e)=>t.index-e.index),i>e){for(let t=e;te.length&&delete this._stacks,t.forEach((t,i)=>{0===e.filter(e=>e===t._dataset).length&&this._destroyDatasetMeta(i)})}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=e.length;i{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const n=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let t=0,e=this.data.datasets.length;t{t.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(cn("z","_idx")),this._lastEvent&&this._eventHandler(this._lastEvent,!0),this.render()}_updateScales(){J(this.scales,t=>{ai.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);gt(e,i)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:n}of e){mn(t,s,"_removeElements"===i?-n:n)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,i=e=>new Set(t.filter(t=>t[0]===e).map((t,e)=>e+","+t.splice(1).join(","))),s=i(0);for(let t=1;tt.split(",")).map(t=>({method:t[1],start:+t[2],count:+t[3]}))}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;ai.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],J(this.boxes,t=>{i&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))},this),this._layers.forEach((t,e)=>{t._idx=e}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let t=0,e=this.data.datasets.length;t=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,s=!i.disabled,n=this.chartArea,o={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",o)&&(s&&te(e,{left:!1===i.left?0:n.left-i.left,right:!1===i.right?this.width:n.right+i.right,top:!1===i.top?0:n.top-i.top,bottom:!1===i.bottom?this.height:n.bottom+i.bottom}),t.controller.draw(),s&&ee(e),o.cancelable=!1,this.notifyPlugins("afterDatasetDraw",o))}getElementsAtEventForMode(t,e,i,s){const n=Fe.modes[e];return"function"==typeof n?n(this,t,i,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let s=i.filter(t=>t&&t._dataset===e).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=Xe(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",n=this.getDatasetMeta(t),o=n.controller._resolveAnimations(void 0,s);ut(e)?(n.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),o.update(n,{visible:i}),this.update(e=>e.datasetIndex===t?s:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),a.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,i,s),t[i]=s},s=(t,e,i)=>{t.offsetX=e,t.offsetY=i,this._eventHandler(t)};J(this.options.events,t=>i(t,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(i,s)=>{e.addEventListener(this,i,s),t[i]=s},s=(i,s)=>{t[i]&&(e.removeEventListener(this,i,s),delete t[i])},n=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",n),i("detach",o)};o=(()=>{this.attached=!1,s("resize",n),this._stop(),this._resize(0,0),i("attach",a)}),e.isAttached(this.canvas)?a():o()}unbindEvents(){J(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},J(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const s=i?"set":"remove";let n,o,a,r;for("dataset"===e&&(n=this.getDatasetMeta(t[0].datasetIndex)).controller["_"+s+"DatasetHoverStyle"](),a=0,r=t.length;a{const i=this.getDatasetMeta(t);if(!i)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:i.data[e],index:e}});!tt(i,e)&&(this._active=i,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}_updateHoverStyles(t,e,i){const s=this.options.hover,n=(t,e)=>t.filter(t=>!e.some(e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)),o=n(e,t),a=i?t:n(t,e);o.length&&this.updateHoverStyle(o,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0},s=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",i,s))return;const n=this._handleEvent(t,e);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(n||i.changed)&&this.render(),this}_handleEvent(t,e){const{_active:i=[],options:s}=this,n=s.hover,o=e;let a=[],r=!1,l=null;return"mouseout"!==t.type&&(a=this.getElementsAtEventForMode(t,n.mode,n,o),l="click"===t.type?this._lastEvent:t),this._lastEvent=null,Jt(t,this.chartArea,this._minPadding)&&(Q(s.onHover,[t,a,this],this),"mouseup"!==t.type&&"click"!==t.type&&"contextmenu"!==t.type||Q(s.onClick,[t,a,this],this)),((r=!tt(a,i))||e)&&(this._active=a,this._updateHoverStyles(a,i,e)),this._lastEvent=l,r}}const xn=()=>J(bn.instances,t=>t._plugins.invalidate());function _n(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}Object.defineProperties(bn,{defaults:{enumerable:!0,value:_t},instances:{enumerable:!0,value:gn},overrides:{enumerable:!0,value:pt},registry:{enumerable:!0,value:Us},version:{enumerable:!0,value:"3.6.1"},getChart:{enumerable:!0,value:pn},register:{enumerable:!0,value:(...t)=>{Us.add(...t),xn()}},unregister:{enumerable:!0,value:(...t)=>{Us.remove(...t),xn()}}});class yn{constructor(t){this.options=t||{}}formats(){return _n()}parse(t,e){return _n()}format(t,e){return _n()}add(t,e,i){return _n()}diff(t,e,i){return _n()}startOf(t,e,i){return _n()}endOf(t,e){return _n()}}yn.override=function(t){Object.assign(yn.prototype,t)};var vn={_date:yn};function wn(t){const e=t.iScale,i=function(t,e){if(!t._cache.$bar){const i=t.getMatchingVisibleMetas(e);let s=[];for(let e=0,n=i.length;et-e))}return t._cache.$bar}(e,t.type);let s,n,o,a,r=e._length;const l=()=>{32767!==o&&-32768!==o&&(ut(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(s=0,n=i.length;sMath.abs(r)&&(l=r,h=a),e[i.axis]=h,e._custom={barStart:l,barEnd:h,start:n,end:o,min:a,max:r}}(t,e,i,s):e[i.axis]=i.parse(t,s),e}function kn(t,e,i,s){const n=t.iScale,o=t.vScale,a=n.getLabels(),r=n===o,l=[];let h,c,d,u;for(h=i,c=i+s;ht.x,i="left",s="right"):(e=t.base=i?1:-1)}(c,e,o)*n,d===o&&(p-=c/2),h=p+c),p===e.getPixelForValue(o)){const t=Ot(c)*e.getLineWidthForValue(o)/2;p+=t,c-=t}return{size:c,base:p,head:h,center:h+c/2}}_calculateBarIndexPixels(t,e){const i=e.scale,s=this.options,n=s.skipNull,o=K(s.maxBarThickness,1/0);let a,r;if(e.grouped){const i=n?this._getStackCount(t):e.stackCount,l="flex"===s.barThickness?function(t,e,i,s){const n=e.pixels,o=n[t];let a=t>0?n[t-1]:null,r=t=0;--i)e=Math.max(e,t[i].size(this.resolveDataElementOptions(i))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,{xScale:i,yScale:s}=e,n=this.getParsed(t),o=i.getLabelForValue(n.x),a=s.getLabelForValue(n.y),r=n._custom;return{label:e.label,value:"("+o+", "+a+(r?", "+r:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a}=this._cachedMeta,r=this.resolveDataElementOptions(e,s),l=this.getSharedOptions(r),h=this.includeOptions(s,l),c=o.axis,d=a.axis;for(let r=e;r""}}}};class Ln extends As{constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,s=this._cachedMeta;if(!1===this._parsing)s._parsed=i;else{let n,o,a=t=>+i[t];if(U(i[t])){const{key:t="value"}=this._parsing;a=(e=>+ct(i[e],t))}for(n=t,o=t+e;njt(t,r,l,!0)?1:Math.max(e,e*i,s,s*i),g=(t,e,s)=>jt(t,r,l,!0)?-1:Math.min(e,e*i,s,s*i),p=f(0,h,d),m=f(St,c,u),b=g(yt,h,d),x=g(yt+St,c,u);s=(p-b)/2,n=(m-x)/2,o=-(p+b)/2,a=-(m+x)/2}return{ratioX:s,ratioY:n,offsetX:o,offsetY:a}}(c,h,r),p=(i.width-o)/d,m=(i.height-o)/u,b=Math.max(Math.min(p,m)/2,0),x=Z(this.options.radius,b),_=(x-Math.max(x*r,0))/this._getVisibleDatasetWeightTotal();this.offsetX=f*x,this.offsetY=g*x,s.total=this.calculateTotal(),this.outerRadius=x-_*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-_*l,0),this.updateElements(n,0,n.length,t)}_circumference(t,e){const i=this.options,s=this._cachedMeta,n=this._getCircumference();return e&&i.animation.animateRotate||!this.chart.getDataVisibility(t)||null===s._parsed[t]||s.data[t].hidden?0:this.calculateCircumference(s._parsed[t]*n/vt)}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.chartArea,r=o.options.animation,l=(a.left+a.right)/2,h=(a.top+a.bottom)/2,c=n&&r.animateScale,d=c?0:this.innerRadius,u=c?0:this.outerRadius,f=this.resolveDataElementOptions(e,s),g=this.getSharedOptions(f),p=this.includeOptions(s,g);let m,b=this._getRotation();for(m=0;m0&&!isNaN(t)?vt*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=Fi(e._parsed[t],i.options.locale);return{label:s[t]||"",value:n}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,n,o,a,r;if(!t)for(s=0,n=i.data.datasets.length;s"spacing"!==t,_indexable:t=>"spacing"!==t},Ln.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label(t){let e=t.label;const i=": "+t.formattedValue;return $(e)?(e=e.slice())[0]+=i:e+=i,e}}}}};class Rn extends As{initialize(){this.enableOptionSharing=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:i,data:s=[],_dataset:n}=e,o=this.chart._animationsDisabled;let{start:a,count:r}=function(t,e,i){const s=e.length;let n=0,o=s;if(t._sorted){const{iScale:a,_parsed:r}=t,l=a.axis,{min:h,max:c,minDefined:d,maxDefined:u}=a.getUserBounds();d&&(n=Yt(Math.min(le(r,a.axis,h).lo,i?s:le(e,l,a.getPixelForValue(h)).lo),0,s-1)),o=u?Yt(Math.max(le(r,a.axis,c).hi+1,i?0:le(e,l,a.getPixelForValue(c)).hi+1),n,s)-n:s-n}return{start:n,count:o}}(e,s,o);this._drawStart=a,this._drawCount=r,function(t){const{xScale:e,yScale:i,_scaleRanges:s}=t,n={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!s)return t._scaleRanges=n,!0;const o=s.xmin!==e.min||s.xmax!==e.max||s.ymin!==i.min||s.ymax!==i.max;return Object.assign(s,n),o}(e)&&(a=0,r=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!n._decimated,i.points=s;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(i,void 0,{animated:!o,options:l},t),this.updateElements(s,a,r,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,h=this.resolveDataElementOptions(e,s),c=this.getSharedOptions(h),d=this.includeOptions(s,c),u=o.axis,f=a.axis,{spanGaps:g,segment:p}=this.options,m=Lt(g)?g:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||n||"none"===s;let x=e>0&&this.getParsed(e-1);for(let h=e;h0&&i[u]-x[u]>m,p&&(g.parsed=i,g.raw=l.data[h]),d&&(g.options=c||this.resolveDataElementOptions(h,e.active?"active":s)),b||this.updateElement(e,h,g,s),x=i}this.updateSharedOptions(c,s,h)}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,n,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}Rn.id="line",Rn.defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1},Rn.overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};class En extends As{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=Fi(e._parsed[t].r,i.options.locale);return{label:s[t]||"",value:n}}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),n=Math.max(s/2,0),o=(n-Math.max(i.cutoutPercentage?n/100*i.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=n-o*this.index,this.innerRadius=this.outerRadius-o}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=this.getDataset(),r=o.options.animation,l=this._cachedMeta.rScale,h=l.xCenter,c=l.yCenter,d=l.getIndexAngle(0)-.5*yt;let u,f=d;const g=360/this.countVisibleElements();for(u=0;u{!isNaN(t.data[s])&&this.chart.getDataVisibility(s)&&i++}),i}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?It(this.resolveDataElementOptions(t,e).angle||i):0}}En.id="polarArea",En.defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0},En.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label:t=>t.chart.data.labels[t.dataIndex]+": "+t.formattedValue}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};class Fn extends Ln{}Fn.id="pie",Fn.defaults={cutout:0,rotation:0,circumference:360,radius:"100%"};class In extends As{getLabelAndValue(t){const e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}update(t){const e=this._cachedMeta,i=e.dataset,s=e.data||[],n=e.iScale.getLabels();if(i.points=s,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:!0,_fullLoop:n.length===s.length,options:e};this.updateElement(i,void 0,o,t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,i,s){const n=this.getDataset(),o=this._cachedMeta.rScale,a="reset"===s;for(let r=e;r"",label:t=>"("+t.label+", "+t.formattedValue+")"}}},scales:{x:{type:"linear"},y:{type:"linear"}}};var Bn=Object.freeze({__proto__:null,BarController:Tn,BubbleController:An,DoughnutController:Ln,LineController:Rn,PolarAreaController:En,PieController:Fn,RadarController:In,ScatterController:zn});function Vn(t,e,i){const{startAngle:s,pixelMargin:n,x:o,y:a,outerRadius:r,innerRadius:l}=e;let h=n/r;t.beginPath(),t.arc(o,a,r,s-h,i+h),l>n?(h=n/l,t.arc(o,a,l,i+h,s-h,!0)):t.arc(o,a,n,i+St,s-St),t.closePath(),t.clip()}function Nn(t,e,i,s){const n=Ne(t.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]);const o=(i-e)/2,a=Math.min(o,s*e/2),r=t=>{const e=(i-Math.min(o,t))*s/2;return Yt(t,0,Math.min(o,e))};return{outerStart:r(n.outerStart),outerEnd:r(n.outerEnd),innerStart:Yt(n.innerStart,0,a),innerEnd:Yt(n.innerEnd,0,a)}}function Wn(t,e,i,s){return{x:i+t*Math.cos(e),y:s+t*Math.sin(e)}}function Hn(t,e,i,s,n){const{x:o,y:a,startAngle:r,pixelMargin:l,innerRadius:h}=e,c=Math.max(e.outerRadius+s+i-l,0),d=h>0?h+s+i+l:0;let u=0;const f=n-r;if(s){const t=((h>0?h-s:0)+(c>0?c-s:0))/2;u=(f-(0!==t?f*t/(t+s):f))/2}const g=(f-Math.max(.001,f*c-i/yt)/c)/2,p=r+g+u,m=n-g-u,{outerStart:b,outerEnd:x,innerStart:_,innerEnd:y}=Nn(e,d,c,m-p),v=c-b,w=c-x,M=p+b/v,k=m-x/w,S=d+_,D=d+y,P=p+_/S,C=m-y/D;if(t.beginPath(),t.arc(o,a,c,M,k),x>0){const e=Wn(w,k,o,a);t.arc(e.x,e.y,x,k,m+St)}const O=Wn(D,m,o,a);if(t.lineTo(O.x,O.y),y>0){const e=Wn(D,C,o,a);t.arc(e.x,e.y,y,m+St,C+Math.PI)}if(t.arc(o,a,d,m-y/d,p+_/d,!0),_>0){const e=Wn(S,P,o,a);t.arc(e.x,e.y,_,P+Math.PI,p-St)}const T=Wn(v,p,o,a);if(t.lineTo(T.x,T.y),b>0){const e=Wn(v,M,o,a);t.arc(e.x,e.y,b,p-St,M)}t.closePath()}function jn(t,e,i,s,n){const{options:o}=e,a="inner"===o.borderAlign;o.borderWidth&&(a?(t.lineWidth=2*o.borderWidth,t.lineJoin="round"):(t.lineWidth=o.borderWidth,t.lineJoin="bevel"),e.fullCircles&&function(t,e,i){const{x:s,y:n,startAngle:o,pixelMargin:a,fullCircles:r}=e,l=Math.max(e.outerRadius-a,0),h=e.innerRadius+a;let c;for(i&&Vn(t,e,o+vt),t.beginPath(),t.arc(s,n,h,o+vt,o,!0),c=0;c=vt||jt(n,a,r),f=Ut(o,l+d,h+d);return u&&f}getCenterPoint(t){const{x:e,y:i,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius","circumference"],t),{offset:r,spacing:l}=this.options,h=(s+n)/2,c=(o+a+l+r)/2;return{x:e+Math.cos(h)*c,y:i+Math.sin(h)*c}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:i}=this,s=(e.offset||0)/2,n=(e.spacing||0)/2;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=i>vt?Math.floor(i/vt):0,0===i||this.innerRadius<0||this.outerRadius<0)return;t.save();let o=0;if(s){o=s/2;const e=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(e)*o,Math.sin(e)*o),this.circumference>=yt&&(o=s)}t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor;const a=function(t,e,i,s){const{fullCircles:n,startAngle:o,circumference:a}=e;let r=e.endAngle;if(n){Hn(t,e,i,s,o+vt);for(let e=0;er&&o>r;return{count:s,start:l,loop:e.loop,ilen:h(a+(h?r-t:t))%o,_=()=>{f!==g&&(t.lineTo(m,g),t.lineTo(m,f),t.lineTo(m,p))};for(l&&(d=n[x(0)],t.moveTo(d.x,d.y)),c=0;c<=r;++c){if((d=n[x(c)]).skip)continue;const e=d.x,i=d.y,s=0|e;s===u?(ig&&(g=i),m=(b*m+e)/++b):(_(),t.lineTo(e,i),u=s,b=0,f=g=i),p=i}_()}function Gn(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||i)?Kn:qn}Yn.id="arc",Yn.defaults={borderAlign:"center",borderColor:"#fff",borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0},Yn.defaultRoutes={backgroundColor:"backgroundColor"};const Zn="function"==typeof Path2D;function Qn(t,e,i,s){Zn&&!e.options.segment?function(t,e,i,s){let n=e._path;n||(n=e._path=new Path2D,e.path(n,i,s)&&n.closePath()),$n(t,e.options),t.stroke(n)}(t,e,i,s):function(t,e,i,s){const{segments:n,options:o}=e,a=Gn(e);for(const r of n)$n(t,o,r.style),t.beginPath(),a(t,e,r,{start:i,end:i+s-1})&&t.closePath(),t.stroke()}(t,e,i,s)}class Jn extends Ls{constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const i=this.options;if((i.tension||"monotone"===i.cubicInterpolationMode)&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;Di(this._points,i,t,s,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=$i(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],n=this.points,o=Yi(this,{property:e,start:s,end:s});if(!o.length)return;const a=[],r=function(t){return t.stepped?Li:t.tension||"monotone"===t.cubicInterpolationMode?Ri:Ai}(i);let l,h;for(l=0,h=o.length;l"borderDash"!==t&&"fill"!==t};class eo extends Ls{constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,e,i){const s=this.options,{x:n,y:o}=this.getProps(["x","y"],i);return Math.pow(t-n,2)+Math.pow(e-o,2){co(t)})}var fo={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,i)=>{if(!i.enabled)return void uo(t);const s=t.width;t.data.datasets.forEach((e,n)=>{const{_data:o,indexAxis:a}=e,r=t.getDatasetMeta(n),l=o||e.data;if("y"===$e([a,t.options.indexAxis]))return;if("line"!==r.type)return;const h=t.scales[r.xAxisID];if("linear"!==h.type&&"time"!==h.type)return;if(t.options.parsing)return;let{start:c,count:d}=function(t,e){const i=e.length;let s,n=0;const{iScale:o}=t,{min:a,max:r,minDefined:l,maxDefined:h}=o.getUserBounds();return l&&(n=Yt(le(e,o.axis,a).lo,0,i-1)),{start:n,count:s=h?Yt(le(e,o.axis,r).hi+1,n,i)-n:i-n}}(r,l);if(d<=(i.threshold||4*s))return void co(e);let u;switch(Y(o)&&(e._data=l,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),i.algorithm){case"lttb":u=function(t,e,i,s,n){const o=n.samples||s;if(o>=i)return t.slice(e,e+i);const a=[],r=(i-2)/(o-2);let l=0;const h=e+i-1;let c,d,u,f,g,p=e;for(a[l++]=t[p],c=0;cu&&(u=f,d=t[s],g=s);a[l++]=d,p=g}return a[l++]=t[h],a}(l,c,d,s,i);break;case"min-max":u=function(t,e,i,s){let n,o,a,r,l,h,c,d,u,f,g=0,p=0;const m=[],b=e+i-1,x=t[e].x,_=t[b].x-x;for(n=e;nf&&(f=r,c=n),g=(p*g+o.x)/++p;else{const i=n-1;if(!Y(h)&&!Y(c)){const e=Math.min(h,c),s=Math.max(h,c);e!==d&&e!==i&&m.push({...t[e],x:g}),s!==d&&s!==i&&m.push({...t[s],x:g})}n>0&&i!==d&&m.push(t[i]),m.push(o),l=e,p=0,u=f=r,h=c=d=n}}return m}(l,c,d,s);break;default:throw new Error(`Unsupported decimation algorithm '${i.algorithm}'`)}e._decimated=u})},destroy(t){uo(t)}};function go(t,e,i){const s=function(t){const e=t.options,i=e.fill;let s=K(i&&i.target,i);return void 0===s&&(s=!!e.backgroundColor),!1!==s&&null!==s&&(!0===s?"origin":s)}(t);if(U(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return X(n)&&Math.floor(n)===n?("-"!==s[0]&&"+"!==s[0]||(n=e+n),!(n===e||n<0||n>=i)&&n):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}class po{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){const{x:s,y:n,radius:o}=this;return e=e||{start:0,end:vt},t.arc(s,n,o,e.end,e.start,!0),!i.bounds}interpolate(t){const{x:e,y:i,radius:s}=this,n=t.angle;return{x:e+Math.cos(n)*s,y:i+Math.sin(n)*s,angle:n}}}function mo(t){return(t.scale||{}).getPointPositionForValue?function(t){const{scale:e,fill:i}=t,s=e.options,n=e.getLabels().length,o=[],a=s.reverse?e.max:e.min,r=s.reverse?e.min:e.max;let l,h,c;if(c="start"===i?a:"end"===i?r:U(i)?i.value:e.getBaseValue(),s.grid.circular)return h=e.getPointPositionForValue(0,a),new po({x:h.x,y:h.y,radius:e.getDistanceFromCenterForValue(c)});for(l=0;lt;e--){const t=i[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function xo(t,e,i){const s=[];for(let n=0;n{e=bo(t,e,n);const a=n[t],r=n[e];null!==s?(o.push({x:a.x,y:s}),o.push({x:r.x,y:s})):null!==i&&(o.push({x:i,y:a.y}),o.push({x:i,y:r.y}))}),o}(t,e),i.length?new Jn({points:i,options:{tension:0},_loop:s,_fullLoop:s}):null}function wo(t,e,i){let s=t[e].fill;const n=[e];let o;if(!i)return s;for(;!1!==s&&-1===n.indexOf(s);){if(!X(s))return s;if(!(o=t[s]))return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function Mo(t,e,i){t.beginPath(),e.path(t),t.lineTo(e.last().x,i),t.lineTo(e.first().x,i),t.closePath(),t.clip()}function ko(t,e,i,s){if(s)return;let n=e[t],o=i[t];return"angle"===t&&(n=Ht(n),o=Ht(o)),{property:t,start:n,end:o}}function So(t,e,i,s){return t&&e?s(t[i],e[i]):t?t[i]:e?e[i]:0}function Do(t,e,i){const{top:s,bottom:n}=e.chart.chartArea,{property:o,start:a,end:r}=i||{};"x"===o&&(t.beginPath(),t.rect(a,s,r-a,n-s),t.clip())}function Po(t,e,i,s){const n=e.interpolate(i,s);n&&t.lineTo(n.x,n.y)}function Co(t,e){const{line:i,target:s,property:n,color:o,scale:a}=e,r=function(t,e,i){const s=t.segments,n=t.points,o=e.points,a=[];for(const t of s){let{start:s,end:r}=t;r=bo(s,r,n);const l=ko(i,n[s],n[r],t.loop);if(!e.segments){a.push({source:t,target:l,start:n[s],end:n[r]});continue}const h=Yi(e,l);for(const e of h){const s=ko(i,o[e.start],o[e.end],e.loop),r=ji(t,n,s);for(const t of r)a.push({source:t,target:e,start:{[i]:So(l,s,"start",Math.max)},end:{[i]:So(l,s,"end",Math.min)}})}}return a}(i,s,n);for(const{source:e,target:l,start:h,end:c}of r){const{style:{backgroundColor:r=o}={}}=e,d=!0!==s;t.save(),t.fillStyle=r,Do(t,a,d&&ko(n,h,c)),t.beginPath();const u=!!i.pathSegment(t,e);let f;if(d){u?t.closePath():Po(t,s,c,n);const e=!!s.pathSegment(t,l,{move:u,reverse:!0});(f=u&&e)||Po(t,s,h,n)}t.closePath(),t.fill(f?"evenodd":"nonzero"),t.restore()}}function Oo(t,e,i){const s=yo(e),{line:n,scale:o,axis:a}=e,r=n.options,l=r.fill,h=r.backgroundColor,{above:c=h,below:d=h}=l||{};s&&n.points.length&&(te(t,i),function(t,e){const{line:i,target:s,above:n,below:o,area:a,scale:r}=e,l=i._loop?"angle":e.axis;t.save(),"x"===l&&o!==n&&(Mo(t,s,a.top),Co(t,{line:i,target:s,color:n,scale:r,property:l}),t.restore(),t.save(),Mo(t,s,a.bottom)),Co(t,{line:i,target:s,color:o,scale:r,property:l}),t.restore()}(t,{line:n,target:s,above:c,below:d,area:i,scale:o,axis:a}),ee(t))}var To={id:"filler",afterDatasetsUpdate(t,e,i){const s=(t.data.datasets||[]).length,n=[];let o,a,r,l;for(a=0;a=0;--e){const i=n[e].$filler;i&&(i.line.updateControlPoints(o,i.axis),s&&Oo(t.ctx,i,o))}},beforeDatasetsDraw(t,e,i){if("beforeDatasetsDraw"!==i.drawTime)return;const s=t.getSortedVisibleDatasetMetas();for(let e=s.length-1;e>=0;--e){const i=s[e].$filler;i&&Oo(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,i){const s=e.meta.$filler;s&&!1!==s.fill&&"beforeDatasetDraw"===i.drawTime&&Oo(t.ctx,s,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const Ao=(t,e)=>{let{boxHeight:i=e,boxWidth:s=e}=t;return t.usePointStyle&&(i=Math.min(i,e),s=Math.min(s,e)),{boxWidth:s,boxHeight:i,itemHeight:Math.max(e,i)}},Lo=(t,e)=>null!==t&&null!==e&&t.datasetIndex===e.datasetIndex&&t.index===e.index;class Ro extends Ls{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=Q(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(e=>t.filter(e,this.chart.data))),t.sort&&(e=e.sort((e,i)=>t.sort(e,i,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const i=t.labels,s=Ye(i.font),n=s.size,o=this._computeTitleHeight(),{boxWidth:a,itemHeight:r}=Ao(i,n);let l,h;e.font=s.string,this.isHorizontal()?(l=this.maxWidth,h=this._fitRows(o,n,a,r)+10):(h=this.maxHeight,l=this._fitCols(o,n,a,r)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:n,maxWidth:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.lineWidths=[0],h=s+a;let c=t;n.textAlign="left",n.textBaseline="middle";let d=-1,u=-h;return this.legendItems.forEach((t,f)=>{const g=i+e/2+n.measureText(t.text).width;(0===f||l[l.length-1]+g+2*a>o)&&(c+=h,l[l.length-(f>0?0:1)]=0,u+=h,d++),r[f]={left:0,top:u,row:d,width:g,height:s},l[l.length-1]+=g+a}),c}_fitCols(t,e,i,s){const{ctx:n,maxHeight:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.columnSizes=[],h=o-t;let c=a,d=0,u=0,f=0,g=0;return this.legendItems.forEach((t,o)=>{const p=i+e/2+n.measureText(t.text).width;o>0&&u+s+2*a>h&&(c+=d+a,l.push({width:d,height:u}),f+=d+a,g++,d=u=0),r[o]={left:f,top:u,col:g,width:p,height:s},d=Math.max(d,p),u+=s+a}),c+=d,l.push({width:d,height:u}),c}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:o}}=this,a=Bi(o,this.left,this.width);if(this.isHorizontal()){let o=0,r=n(i,this.left+s,this.right-this.lineWidths[o]);for(const l of e)o!==l.row&&(o=l.row,r=n(i,this.left+s,this.right-this.lineWidths[o])),l.top+=this.top+t+s,l.left=a.leftForLtr(a.x(r),l.width),r+=l.width+s}else{let o=0,r=n(i,this.top+t+s,this.bottom-this.columnSizes[o].height);for(const l of e)l.col!==o&&(o=l.col,r=n(i,this.top+t+s,this.bottom-this.columnSizes[o].height)),l.top=r,l.left+=this.left+s,l.left=a.leftForLtr(a.x(l.left),l.width),r+=l.height+s}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;te(t,this),this._draw(),ee(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:a,labels:r}=t,l=_t.color,h=Bi(t.rtl,this.left,this.width),c=Ye(r.font),{color:d,padding:u}=r,f=c.size,g=f/2;let p;this.drawTitle(),s.textAlign=h.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:m,boxHeight:b,itemHeight:x}=Ao(r,f),_=this.isHorizontal(),y=this._computeTitleHeight();p=_?{x:n(a,this.left+u,this.right-i[0]),y:this.top+u+y,line:0}:{x:this.left+u,y:n(a,this.top+y+u,this.bottom-e[0].height),line:0},Vi(this.ctx,t.textDirection);const v=x+u;this.legendItems.forEach((w,M)=>{s.strokeStyle=w.fontColor||d,s.fillStyle=w.fontColor||d;const k=s.measureText(w.text).width,S=h.textAlign(w.textAlign||(w.textAlign=r.textAlign)),D=m+g+k;let P=p.x,C=p.y;h.setWidth(this.width),_?M>0&&P+D+u>this.right&&(C=p.y+=v,p.line++,P=p.x=n(a,this.left+u,this.right-i[p.line])):M>0&&C+v>this.bottom&&(P=p.x=P+e[p.line].width+u,p.line++,C=p.y=n(a,this.top+y+u,this.bottom-e[p.line].height)),function(t,e,i){if(isNaN(m)||m<=0||isNaN(b)||b<0)return;s.save();const n=K(i.lineWidth,1);if(s.fillStyle=K(i.fillStyle,l),s.lineCap=K(i.lineCap,"butt"),s.lineDashOffset=K(i.lineDashOffset,0),s.lineJoin=K(i.lineJoin,"miter"),s.lineWidth=n,s.strokeStyle=K(i.strokeStyle,l),s.setLineDash(K(i.lineDash,[])),r.usePointStyle){const o={radius:m*Math.SQRT2/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:n},a=h.xPlus(t,m/2);Qt(s,o,a,e+g)}else{const o=e+Math.max((f-b)/2,0),a=h.leftForLtr(t,m),r=He(i.borderRadius);s.beginPath(),Object.values(r).some(t=>0!==t)?ae(s,{x:a,y:o,w:m,h:b,radius:r}):s.rect(a,o,m,b),s.fill(),0!==n&&s.stroke()}s.restore()}(h.x(P),C,w),P=o(S,P+m+g,_?P+D:this.right,t.rtl),function(t,e,i){ne(s,i.text,t,e+x/2,c,{strikethrough:i.hidden,textAlign:h.textAlign(i.textAlign)})}(h.x(P),C,w),_?p.x+=D+u:p.y+=v}),Ni(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=Ye(e.font),o=je(e.padding);if(!e.display)return;const a=Bi(t.rtl,this.left,this.width),r=this.ctx,l=e.position,h=i.size/2,c=o.top+h;let d,u=this.left,f=this.width;if(this.isHorizontal())f=Math.max(...this.lineWidths),d=this.top+c,u=n(t.align,u,this.right-f);else{const e=this.columnSizes.reduce((t,e)=>Math.max(t,e.height),0);d=c+n(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const g=n(l,u,u+f);r.textAlign=a.textAlign(s(l)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=i.string,ne(r,e.text,g,d,i)}_computeTitleHeight(){const t=this.options.title,e=Ye(t.font),i=je(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,n;if(Ut(t,this.left,this.right)&&Ut(e,this.top,this.bottom))for(n=this.legendHitBoxes,i=0;it.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:i,pointStyle:s,textAlign:n,color:o}}=t.legend.options;return t._getSortedDatasetMetas().map(t=>{const a=t.controller.getStyle(i?0:void 0),r=je(a.borderWidth);return{text:e[t.index].label,fillStyle:a.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:a.borderCapStyle,lineDash:a.borderDash,lineDashOffset:a.borderDashOffset,lineJoin:a.borderJoinStyle,lineWidth:(r.width+r.height)/4,strokeStyle:a.borderColor,pointStyle:s||a.pointStyle,rotation:a.rotation,textAlign:n||a.textAlign,borderRadius:0,datasetIndex:t.index}},this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class Fo extends Ls{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this.options;if(this.left=0,this.top=0,!i.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const s=$(i.text)?i.text.length:1;this._padding=je(i.padding);const n=s*Ye(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=n:this.width=n}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:s,right:o,options:a}=this,r=a.align;let l,h,c,d=0;return this.isHorizontal()?(h=n(r,i,o),c=e+t,l=o-i):("left"===a.position?(h=i+t,c=n(r,s,e),d=-.5*yt):(h=o-t,c=n(r,e,s),d=.5*yt),l=s-e),{titleX:h,titleY:c,maxWidth:l,rotation:d}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=Ye(e.font),n=i.lineHeight/2+this._padding.top,{titleX:o,titleY:a,maxWidth:r,rotation:l}=this._drawArgs(n);ne(t,e.text,0,0,i,{color:e.color,maxWidth:r,rotation:l,textAlign:s(e.align),textBaseline:"middle",translation:[o,a]})}}var Io={id:"title",_element:Fo,start(t,e,i){!function(t,e){const i=new Fo({ctx:t.ctx,options:e,chart:t});ai.configure(t,i,e),ai.addBox(t,i),t.titleBlock=i}(t,i)},stop(t){const e=t.titleBlock;ai.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){const s=t.titleBlock;ai.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const zo=new WeakMap;var Bo={id:"subtitle",start(t,e,i){const s=new Fo({ctx:t.ctx,options:i,chart:t});ai.configure(t,s,i),ai.addBox(t,s),zo.set(t,s)},stop(t){ai.removeBox(t,zo.get(t)),zo.delete(t)},beforeUpdate(t,e,i){const s=zo.get(t);ai.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Vo={average(t){if(!t.length)return!1;let e,i,s=0,n=0,o=0;for(e=0,i=t.length;e-1?t.split("\n"):t}function Ho(t,e){const{element:i,datasetIndex:s,index:n}=e,o=t.getDatasetMeta(s).controller,{label:a,value:r}=o.getLabelAndValue(n);return{chart:t,label:a,parsed:o.getParsed(n),raw:t.data.datasets[s].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:i}}function jo(t,e){const i=t._chart.ctx,{body:s,footer:n,title:o}=t,{boxWidth:a,boxHeight:r}=e,l=Ye(e.bodyFont),h=Ye(e.titleFont),c=Ye(e.footerFont),d=o.length,u=n.length,f=s.length,g=je(e.padding);let p=g.height,m=0,b=s.reduce((t,e)=>t+e.before.length+e.lines.length+e.after.length,0);if(b+=t.beforeBody.length+t.afterBody.length,d&&(p+=d*h.lineHeight+(d-1)*e.titleSpacing+e.titleMarginBottom),b){p+=f*(e.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(b-f)*l.lineHeight+(b-1)*e.bodySpacing}u&&(p+=e.footerMarginTop+u*c.lineHeight+(u-1)*e.footerSpacing);let x=0;const _=function(t){m=Math.max(m,i.measureText(t).width+x)};return i.save(),i.font=h.string,J(t.title,_),i.font=l.string,J(t.beforeBody.concat(t.afterBody),_),x=e.displayColors?a+2+e.boxPadding:0,J(s,t=>{J(t.before,_),J(t.lines,_),J(t.after,_)}),x=0,i.font=c.string,J(t.footer,_),i.restore(),{width:m+=g.width,height:p}}function Yo(t,e,i,s){const{x:n,width:o}=i,{width:a,chartArea:{left:r,right:l}}=t;let h="center";return"center"===s?h=n<=(r+l)/2?"left":"right":n<=o/2?h="left":n>=a-o/2&&(h="right"),function(t,e,i,s){const{x:n,width:o}=s,a=i.caretSize+i.caretPadding;return"left"===t&&n+o+a>e.width||"right"===t&&n-o-a<0||void 0}(h,t,e,i)&&(h="center"),h}function $o(t,e,i){const s=e.yAlign||function(t,e){const{y:i,height:s}=e;return it.height-s/2?"bottom":"center"}(t,i);return{xAlign:e.xAlign||Yo(t,e,i,s),yAlign:s}}function Uo(t,e,i,s){const{caretSize:n,caretPadding:o,cornerRadius:a}=t,{xAlign:r,yAlign:l}=i,h=n+o,{topLeft:c,topRight:d,bottomLeft:u,bottomRight:f}=He(a);let g=function(t,e){let{x:i,width:s}=t;return"right"===e?i-=s:"center"===e&&(i-=s/2),i}(e,r);const p=function(t,e,i){let{y:s,height:n}=t;return"top"===e?s+=i:s-="bottom"===e?n+i:n/2,s}(e,l,h);return"center"===l?"left"===r?g+=h:"right"===r&&(g-=h):"left"===r?g-=Math.max(c,u)+n:"right"===r&&(g+=Math.max(d,f)+n),{x:Yt(g,0,s.width-e.width),y:Yt(p,0,s.height-e.height)}}function Xo(t,e,i){const s=je(i.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-s.right:t.x+s.left}function qo(t){return No([],Wo(t))}function Ko(t,e){const i=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return i?t.override(i):t}class Go extends Ls{constructor(t){super(),this.opacity=0,this._active=[],this._chart=t._chart,this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this._chart,i=this.options.setContext(this.getContext()),s=i.enabled&&e.options.animation&&i.animations,n=new xs(this._chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(n)),n}getContext(){return this.$context||(this.$context=(t=this._chart.getContext(),e=this,i=this._tooltipItems,Xe(t,{tooltip:e,tooltipItems:i,type:"tooltip"})));var t,e,i}getTitle(t,e){const{callbacks:i}=e,s=i.beforeTitle.apply(this,[t]),n=i.title.apply(this,[t]),o=i.afterTitle.apply(this,[t]);let a=[];return a=No(a,Wo(s)),a=No(a,Wo(n)),a=No(a,Wo(o))}getBeforeBody(t,e){return qo(e.callbacks.beforeBody.apply(this,[t]))}getBody(t,e){const{callbacks:i}=e,s=[];return J(t,t=>{const e={before:[],lines:[],after:[]},n=Ko(i,t);No(e.before,Wo(n.beforeLabel.call(this,t))),No(e.lines,n.label.call(this,t)),No(e.after,Wo(n.afterLabel.call(this,t))),s.push(e)}),s}getAfterBody(t,e){return qo(e.callbacks.afterBody.apply(this,[t]))}getFooter(t,e){const{callbacks:i}=e,s=i.beforeFooter.apply(this,[t]),n=i.footer.apply(this,[t]),o=i.afterFooter.apply(this,[t]);let a=[];return a=No(a,Wo(s)),a=No(a,Wo(n)),a=No(a,Wo(o))}_createItems(t){const e=this._active,i=this._chart.data,s=[],n=[],o=[];let a,r,l=[];for(a=0,r=e.length;at.filter(e,s,n,i))),t.itemSort&&(l=l.sort((e,s)=>t.itemSort(e,s,i))),J(l,e=>{const i=Ko(t.callbacks,e);s.push(i.labelColor.call(this,e)),n.push(i.labelPointStyle.call(this,e)),o.push(i.labelTextColor.call(this,e))}),this.labelColors=s,this.labelPointStyles=n,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let n,o=[];if(s.length){const t=Vo[i.position].call(this,s,this._eventPosition);o=this._createItems(i),this.title=this.getTitle(o,i),this.beforeBody=this.getBeforeBody(o,i),this.body=this.getBody(o,i),this.afterBody=this.getAfterBody(o,i),this.footer=this.getFooter(o,i);const e=this._size=jo(this,i),a=Object.assign({},t,e),r=$o(this._chart,i,a),l=Uo(i,a,r,this._chart);this.xAlign=r.xAlign,this.yAlign=r.yAlign,n={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(n={opacity:0});this._tooltipItems=o,this.$context=void 0,n&&this._resolveAnimations().update(this,n),t&&i.external&&i.external.call(this,{chart:this._chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const n=this.getCaretPosition(t,i,s);e.lineTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:n}=this,{caretSize:o,cornerRadius:a}=i,{topLeft:r,topRight:l,bottomLeft:h,bottomRight:c}=He(a),{x:d,y:u}=t,{width:f,height:g}=e;let p,m,b,x,_,y;return"center"===n?(_=u+g/2,"left"===s?(m=(p=d)-o,x=_+o,y=_-o):(m=(p=d+f)+o,x=_-o,y=_+o),b=p):(m="left"===s?d+Math.max(r,h)+o:"right"===s?d+f-Math.max(l,c)-o:this.caretX,"top"===n?(_=(x=u)-o,p=m-o,b=m+o):(_=(x=u+g)+o,p=m+o,b=m-o),y=x),{x1:p,x2:m,x3:b,y1:x,y2:_,y3:y}}drawTitle(t,e,i){const s=this.title,n=s.length;let o,a,r;if(n){const l=Bi(i.rtl,this.x,this.width);for(t.x=Xo(this,i.titleAlign,i),e.textAlign=l.textAlign(i.titleAlign),e.textBaseline="middle",o=Ye(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=o.string,r=0;r0!==t)?(t.beginPath(),t.fillStyle=n.multiKeyBackground,ae(t,{x:e,y:g,w:l,h:r,radius:a}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),ae(t,{x:i,y:g+1,w:l-2,h:r-2,radius:a}),t.fill()):(t.fillStyle=n.multiKeyBackground,t.fillRect(e,g,l,r),t.strokeRect(e,g,l,r),t.fillStyle=o.backgroundColor,t.fillRect(i,g+1,l-2,r-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:n,bodyAlign:o,displayColors:a,boxHeight:r,boxWidth:l,boxPadding:h}=i,c=Ye(i.bodyFont);let d=c.lineHeight,u=0;const f=Bi(i.rtl,this.x,this.width),g=function(i){e.fillText(i,f.x(t.x+u),t.y+d/2),t.y+=d+n},p=f.textAlign(o);let m,b,x,_,y,v,w;for(e.textAlign=o,e.textBaseline="middle",e.font=c.string,t.x=Xo(this,p,i),e.fillStyle=i.bodyColor,J(this.beforeBody,g),u=a&&"right"!==p?"center"===o?l/2+h:l+2+h:0,_=0,v=s.length;_0&&e.stroke()}_updateAnimationTarget(t){const e=this._chart,i=this.$animations,s=i&&i.x,n=i&&i.y;if(s||n){const i=Vo[t.position].call(this,this._active,this._eventPosition);if(!i)return;const o=this._size=jo(this,t),a=Object.assign({},i,this._size),r=$o(e,t,a),l=Uo(t,a,r,e);s._to===l.x&&n._to===l.y||(this.xAlign=r.xAlign,this.yAlign=r.yAlign,this.width=o.width,this.height=o.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,l))}}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},n={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const o=je(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(n,t,s,e),Vi(t,e.textDirection),n.y+=o.top,this.drawTitle(n,t,e),this.drawBody(n,t,e),this.drawFooter(n,t,e),Ni(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map(({datasetIndex:t,index:e})=>{const i=this._chart.getDatasetMeta(t);if(!i)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:i.data[e],index:e}}),n=!tt(i,s),o=this._positionChanged(s,e);(n||o)&&(this._active=s,this._eventPosition=e,this.update(!0))}handleEvent(t,e){const i=this.options,s=this._active||[];let n=!1,o=[];"mouseout"!==t.type&&(o=this._chart.getElementsAtEventForMode(t,i.mode,i,e),i.reverse&&o.reverse());const a=this._positionChanged(o,t);return(n=e||!tt(o,s)||a)&&(this._active=o,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),n}_positionChanged(t,e){const{caretX:i,caretY:s,options:n}=this,o=Vo[n.position].call(this,t,e);return!1!==o&&(i!==o.x||s!==o.y)}}Go.positioners=Vo;var Zo={id:"tooltip",_element:Go,positioners:Vo,afterInit(t,e,i){i&&(t.tooltip=new Go({_chart:t,options:i}))},beforeUpdate(t,e,i){t.tooltip&&t.tooltip.initialize(i)},reset(t,e,i){t.tooltip&&t.tooltip.initialize(i)},afterDraw(t){const e=t.tooltip,i={tooltip:e};!1!==t.notifyPlugins("beforeTooltipDraw",i)&&(e&&e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i))},afterEvent(t,e){if(t.tooltip){const i=e.replay;t.tooltip.handleEvent(e.event,i)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:{beforeTitle:H,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,s=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(s>0&&e.dataIndex"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},Qo=Object.freeze({__proto__:null,Decimation:fo,Filler:To,Legend:Eo,SubTitle:Bo,Title:Io,Tooltip:Zo});const Jo=(t,e,i,s)=>("string"==typeof e?(i=t.push(e)-1,s.unshift({index:i,label:e})):isNaN(e)&&(i=null),i);const ta=(t,e)=>null===t?null:Yt(Math.round(t),0,e);class ea extends Ys{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const e=this._addedLabels;if(e.length){const t=this.getLabels();for(const{index:i,label:s}of e)t[i]===s&&t.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(Y(t))return null;const i=this.getLabels();return e=isFinite(e)&&i[e]===t?e:function(t,e,i,s){const n=t.indexOf(e);return-1===n?Jo(t,e,i,s):n!==t.lastIndexOf(e)?i:n}(i,t,K(e,t),this._addedLabels),ta(e,i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(i=0),e||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,e=this.max,i=this.options.offset,s=[];let n=this.getLabels();n=0===t&&e===n.length-1?n:n.slice(t,e+1),this._valueRange=Math.max(n.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let i=t;i<=e;i++)s.push({value:i});return s}getLabelForValue(t){const e=this.getLabels();return t>=0&&te.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function ia(t,e,{horizontal:i,minRotation:s}){const n=It(s),o=(i?Math.sin(n):Math.cos(n))||.001,a=.75*e*(""+t).length;return Math.min(e/o,a)}ea.id="category",ea.defaults={ticks:{callback:ea.prototype.getLabelForValue}};class sa extends Ys{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return Y(t)?null:("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:s,max:n}=this;const o=t=>s=e?s:t,a=t=>n=i?n:t;if(t){const t=Ot(s),e=Ot(n);t<0&&e<0?a(0):t>0&&e>0&&o(0)}if(s===n){let e=1;(n>=Number.MAX_SAFE_INTEGER||s<=Number.MIN_SAFE_INTEGER)&&(e=Math.abs(.05*n)),a(n+e),t||o(s-e)}this.min=s,this.max=n}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:i,stepSize:s}=t;return s?(e=Math.ceil(this.max/s)-Math.floor(this.min/s)+1)>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3):(e=this.computeTickLimit(),i=i||11),i&&(e=Math.min(i,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();const s=function(t,e){const i=[],{bounds:s,step:n,min:o,max:a,precision:r,count:l,maxTicks:h,maxDigits:c,includeBounds:d}=t,u=n||1,f=h-1,{min:g,max:p}=e,m=!Y(o),b=!Y(a),x=!Y(l),_=(p-g)/(c+1);let y,v,w,M,k=Tt((p-g)/f/u)*u;if(k<1e-14&&!m&&!b)return[{value:g},{value:p}];(M=Math.ceil(p/k)-Math.floor(g/k))>f&&(k=Tt(M*k/f/u)*u),Y(r)||(y=Math.pow(10,r),k=Math.ceil(k*y)/y),"ticks"===s?(v=Math.floor(g/k)*k,w=Math.ceil(p/k)*k):(v=g,w=p),m&&b&&n&&Et((a-o)/n,k/1e3)?(k=(a-o)/(M=Math.round(Math.min((a-o)/k,h))),v=o,w=a):x?k=((w=b?a:w)-(v=m?o:v))/(M=l-1):M=Rt(M=(w-v)/k,Math.round(M),k/1e3)?Math.round(M):Math.ceil(M);const S=Math.max(Bt(k),Bt(v));y=Math.pow(10,Y(r)?S:r),v=Math.round(v*y)/y,w=Math.round(w*y)/y;let D=0;for(m&&(d&&v!==o?(i.push({value:o}),v0?i:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=X(t)?Math.max(0,t):null,this.max=X(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const n=e=>i=t?i:e,o=t=>s=e?s:t,a=(t,e)=>Math.pow(10,Math.floor(Ct(t))+e);i===s&&(i<=0?(n(1),o(10)):(n(a(i,-1)),o(a(s,1)))),i<=0&&n(a(s,-1)),s<=0&&o(a(i,1)),this._zero&&this.min!==this._suggestedMin&&i===a(this.min,0)&&n(a(i,-1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e=function(t,e){const i=Math.floor(Ct(e.max)),s=Math.ceil(e.max/Math.pow(10,i)),n=[];let o=q(t.min,Math.pow(10,Math.floor(Ct(e.min)))),a=Math.floor(Ct(o)),r=Math.floor(o/Math.pow(10,a)),l=a<0?Math.pow(10,Math.abs(a)):1;do{n.push({value:o,major:oa(o)}),10==++r&&(r=1,l=++a>=0?1:l),o=Math.round(r*Math.pow(10,a)*l)/l}while(an?{start:e-i,end:e}:{start:e,end:e+i}}function ha(t){const e={l:0,r:t.width,t:0,b:t.height-t.paddingTop},i={},s=[],n=[],o=t.getLabels().length;for(let h=0;he.r&&(e.r=p.end,i.r=f),m.starte.b&&(e.b=m.end,i.b=f)}var a,r,l;t._setReductions(t.drawingArea,e,i),t._pointLabelItems=function(t,e,i){const s=[],n=t.getLabels().length,o=t.options,a=ra(o),r=t.getDistanceFromCenterForValue(o.ticks.reverse?t.min:t.max);for(let o=0;o270||i<90)&&(t-=e),t}function fa(t,e,i,s){const{ctx:n}=t;if(i)n.arc(t.xCenter,t.yCenter,e,0,vt);else{let i=t.getPointPosition(0,e);n.moveTo(i.x,i.y);for(let o=1;o{const i=Q(this.options.pointLabels.callback,[t,e],this);return i||0===i?i:""})}fit(){const t=this.options;t.display&&t.pointLabels.display?ha(this):this.setCenterPoint(0,0,0,0)}_setReductions(t,e,i){let s=e.l/Math.sin(i.l),n=Math.max(e.r-this.width,0)/Math.sin(i.r),o=-e.t/Math.cos(i.t),a=-Math.max(e.b-(this.height-this.paddingTop),0)/Math.cos(i.b);s=ga(s),n=ga(n),o=ga(o),a=ga(a),this.drawingArea=Math.max(t/2,Math.min(Math.floor(t-(s+n)/2),Math.floor(t-(o+a)/2))),this.setCenterPoint(s,n,o,a)}setCenterPoint(t,e,i,s){const n=this.width-e-this.drawingArea,o=t+this.drawingArea,a=i+this.drawingArea,r=this.height-this.paddingTop-s-this.drawingArea;this.xCenter=Math.floor((o+n)/2+this.left),this.yCenter=Math.floor((a+r)/2+this.top+this.paddingTop)}getIndexAngle(t){return Ht(t*(vt/this.getLabels().length)+It(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(Y(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(Y(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t=0;n--){const e=s.setContext(t.getPointLabelContext(n)),o=Ye(e.font),{x:a,y:r,textAlign:l,left:h,top:c,right:d,bottom:u}=t._pointLabelItems[n],{backdropColor:f}=e;if(!Y(f)){const t=je(e.backdropPadding);i.fillStyle=f,i.fillRect(h-t.left,c-t.top,d-h+t.width,u-c+t.height)}ne(i,t._pointLabels[n],a,r+o.lineHeight/2,o,{color:e.color,textAlign:l,textBaseline:"middle"})}}(this,n),s.display&&this.ticks.forEach((t,e)=>{if(0!==e){a=this.getDistanceFromCenterForValue(t.value),function(t,e,i,s){const n=t.ctx,o=e.circular,{color:a,lineWidth:r}=e;!o&&!s||!a||!r||i<0||(n.save(),n.strokeStyle=a,n.lineWidth=r,n.setLineDash(e.borderDash),n.lineDashOffset=e.borderDashOffset,n.beginPath(),fa(t,i,o,s),n.closePath(),n.stroke(),n.restore())}(this,s.setContext(this.getContext(e-1)),a,n)}}),i.display){for(t.save(),o=this.getLabels().length-1;o>=0;o--){const s=i.setContext(this.getPointLabelContext(o)),{color:n,lineWidth:l}=s;l&&n&&(t.lineWidth=l,t.strokeStyle=n,t.setLineDash(s.borderDash),t.lineDashOffset=s.borderDashOffset,a=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),r=this.getPointPosition(o,a),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(r.x,r.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let n,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((s,a)=>{if(0===a&&!e.reverse)return;const r=i.setContext(this.getContext(a)),l=Ye(r.font);if(n=this.getDistanceFromCenterForValue(this.ticks[a].value),r.showLabelBackdrop){t.font=l.string,o=t.measureText(s.label).width,t.fillStyle=r.backdropColor;const e=je(r.backdropPadding);t.fillRect(-o/2-e.left,-n-l.size/2-e.top,o+e.width,l.size+e.height)}ne(t,s.label,0,-n,l,{color:r.color})}),t.restore()}drawTitle(){}}pa.id="radialLinear",pa.defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Es.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback:t=>t,padding:5}},pa.defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"},pa.descriptors={angleLines:{_fallback:"grid"}};const ma={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},ba=Object.keys(ma);function xa(t,e){return t-e}function _a(t,e){if(Y(e))return null;const i=t._adapter,{parser:s,round:n,isoWeekday:o}=t._parseOpts;let a=e;return"function"==typeof s&&(a=s(a)),X(a)||(a="string"==typeof s?i.parse(a,s):i.parse(a)),null===a?null:(n&&(a="week"!==n||!Lt(o)&&!0!==o?i.startOf(a,n):i.startOf(a,"isoWeek",o)),+a)}function ya(t,e,i,s){const n=ba.length;for(let o=ba.indexOf(t);o=e?i[s]:i[n]]=!0}}else t[e]=!0}function wa(t,e,i){const s=[],n={},o=e.length;let a,r;for(a=0;a=0&&(e[l].major=!0);return e}(t,s,n,i):s}class Ma extends Ys{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e){const i=t.time||(t.time={}),s=this._adapter=new vn._date(t.adapters.date);ot(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:_a(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,i=t.time.unit||"day";let{min:s,max:n,minDefined:o,maxDefined:a}=this.getUserBounds();function r(t){o||isNaN(t.min)||(s=Math.min(s,t.min)),a||isNaN(t.max)||(n=Math.max(n,t.max))}o&&a||(r(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||r(this.getMinMax(!1))),s=X(s)&&!isNaN(s)?s:+e.startOf(Date.now(),i),n=X(n)&&!isNaN(n)?n:+e.endOf(Date.now(),i)+1,this.min=Math.min(s,n-1),this.max=Math.max(s+1,n)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this.options,e=t.time,i=t.ticks,s="labels"===i.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const n=this.min,o=ce(s,n,this.max);return this._unit=e.unit||(i.autoSkip?ya(e.minUnit,this.min,this.max,this._getLabelCapacity(n)):function(t,e,i,s,n){for(let o=ba.length-1;o>=ba.indexOf(i);o--){const i=ba[o];if(ma[i].common&&t._adapter.diff(n,s,i)>=e-1)return i}return ba[i?ba.indexOf(i):0]}(this,o.length,e.minUnit,this.min,this.max)),this._majorUnit=i.major.enabled&&"year"!==this._unit?function(t){for(let e=ba.indexOf(t)+1,i=ba.length;e1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+o);const f="data"===s.ticks.source&&this.getDataTimestamps();for(c=u,d=0;ct-e).map(t=>+t)}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}_tickFormatFunction(t,e,i,s){const n=this.options,o=n.time.displayFormats,a=this._unit,r=this._majorUnit,l=a&&o[a],h=r&&o[r],c=i[e],d=r&&h&&c&&c.major,u=this._adapter.format(t,s||(d?h:l)),f=n.ticks.callback;return f?Q(f,[u,e,i],this):u}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t,e,i=this._cache.data||[];if(i.length)return i;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(t=0,e=s.length;t=t[r].pos&&e<=t[l].pos&&({lo:r,hi:l}=le(t,"pos",e)),({pos:s,time:o}=t[r]),({pos:n,time:a}=t[l])):(e>=t[r].time&&e<=t[l].time&&({lo:r,hi:l}=le(t,"time",e)),({time:s,pos:o}=t[r]),({time:n,pos:a}=t[l]));const h=n-s;return h?o+(a-o)*(e-s)/h:o}Ma.id="time",Ma.defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",major:{enabled:!1}}};class Sa extends Ma{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=ka(e,this.min),this._tableRange=ka(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],n=[];let o,a,r,l,h;for(o=0,a=t.length;o=e&&l<=i&&s.push(l);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(o=0,a=s.length;o"string"==typeof t,e=Chart.helpers;let i=null;new Map;return window.plugin_gradient={id:"gradient",beforeDatasetsUpdate(s){const n=s.ctx,o=s.chartArea;if(!o)return null;if(s.options.gradientcolor&&void 0!==s.options.gradientcolor.type){const a=s.data.datasets[0].type||s.config.type;if(null===i){const r=s.data.datasets[0].backgroundColor;i=function(i,s,n,o){let a=[];switch(s.toLowerCase()){case"pie":case"doughnut":if(o&&o.length&&t(o[0])){const t=(n.left+n.right)/2,s=(n.top+n.bottom)/2,r=1;return Object.entries(o).forEach(([,n],o)=>{let l=i.createRadialGradient(t,s,0,t,s,r);l.addColorStop(0,e.color(n).alpha(.4).rgbString()),l.addColorStop(1,e.color(n).alpha(1).rgbString()),a.push(l)}),a}case"bar":return Object.entries(o).forEach(([,s],o)=>{if(t(s)){let t=i.createLinearGradient(0,n.bottom,0,n.top);t.addColorStop(0,e.color(s).alpha(1).rgbString()),t.addColorStop(.5,e.color(s).alpha(.5).rgbString()),t.addColorStop(1,e.color(s).alpha(1).rgbString()),a.push(t)}else a.push(s)}),a}return o}(n,a,o,r),s.data.datasets[0].backgroundColor=i}}else s.data.datasets.forEach((t,s)=>{const a=t.gradient;a&&o&&Object.keys(a).forEach(s=>{const{axis:r,colors:l}=a[s];l&&l.length&&(i=function(t,i,s,n){if(s.bottom&&s.top&&s.left&&s.right){const o="y"===i?t.createLinearGradient(0,s.bottom,0,s.top):t.createLinearGradient(s.left,0,s.right,0);if(n&&1==n.length)o.addColorStop(0,e.color(color).alpha(.2).rgbString()),o.addColorStop(.3,e.color(color).alpha(.4).rgbString()),o.addColorStop(.5,e.color(color).alpha(.6).rgbString()),o.addColorStop(1,e.color(color).alpha(1).rgbString());else{const t=1/(n.length-1);Object.entries(n).forEach(([,e],i)=>{o.addColorStop(t*i,e)})}return o}}(n,r,o,l),t.backgroundColor=i)})})}},plugin_gradient}),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self)["chartjs-background"]=e()}(this,function(){"use strict";return{id:"chardbackground",beforeDraw:function(t){if(t.config.options.chartArea&&t.config.options.chartArea.backgroundColor){const e=t.chartArea,i=t.ctx;i.save(),i.fillStyle=t.config.options.chartArea.backgroundColor,i.fillRect(e.left,e.top,e.right-e.left,e.bottom-e.top),i.restore()}}}}),LineFitter.prototype={add:function(t,e){this.count++,this.sumX+=t,this.sumX2+=t*t,this.sumXY+=t*e,this.sumY+=e},project:function(t){const e=this.count*this.sumX2-this.sumX*this.sumX;return(this.sumX2*this.sumY-this.sumX*this.sumXY)/e+t*((this.count*this.sumXY-this.sumX*this.sumY)/e)}},window.plugin_trendline={id:"trendline",afterDatasetsDraw:function(t){const e=t.ctx;e&&(t.data.datasets.forEach(function(i,s){if(i.trendlineLinear){const n=t.scales.x||t.scales[i.xAxisID],o=t.scales.y||t.scales[i.yAxisID];addFitter(t.getDatasetMeta(s),e,i,n,o)}}),e.setLineDash([]))}},function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("chart.js")):"function"==typeof define&&define.amd?define(["chart.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Chart)}(this,function(t){"use strict";function e(t){if(null===t||!0===t||!1===t)return NaN;var e=Number(t);return isNaN(e)?e:e<0?Math.ceil(e):Math.floor(e)}function i(t,e){if(e.length1?"s":"")+" required, but only "+e.length+" present")}function s(t){i(1,arguments);var e=Object.prototype.toString.call(t);return t instanceof Date||"object"==typeof t&&"[object Date]"===e?new Date(t.getTime()):"number"==typeof t||"[object Number]"===e?new Date(t):("string"!=typeof t&&"[object String]"!==e||"undefined"==typeof console||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn((new Error).stack)),new Date(NaN))}function n(t,n){i(2,arguments);var o=s(t),a=e(n);return isNaN(a)?new Date(NaN):a?(o.setDate(o.getDate()+a),o):o}function o(t,n){i(2,arguments);var o=s(t),a=e(n);if(isNaN(a))return new Date(NaN);if(!a)return o;var r=o.getDate(),l=new Date(o.getTime());return l.setMonth(o.getMonth()+a+1,0),r>=l.getDate()?l:(o.setFullYear(l.getFullYear(),l.getMonth(),r),o)}function a(t,n){i(2,arguments);var o=s(t).getTime(),a=e(n);return new Date(o+a)}function r(t,n){i(1,arguments);var o=n||{},a=o.locale,r=a&&a.options&&a.options.weekStartsOn,l=null==r?0:e(r),h=null==o.weekStartsOn?l:e(o.weekStartsOn);if(!(h>=0&&h<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var c=s(t),d=c.getDay(),u=(d0?1:a}function f(t,e){var i=t.getFullYear()-e.getFullYear()||t.getMonth()-e.getMonth()||t.getDate()-e.getDate()||t.getHours()-e.getHours()||t.getMinutes()-e.getMinutes()||t.getSeconds()-e.getSeconds()||t.getMilliseconds()-e.getMilliseconds();return i<0?-1:i>0?1:i}function g(t,e){i(2,arguments);var n=s(t),o=s(e),a=f(n,o),r=Math.abs(d(n,o));n.setDate(n.getDate()-a*r);var l=a*(r-(f(n,o)===-a));return 0===l?0:l}function p(t,e){i(2,arguments);var n=s(t),o=s(e);return n.getTime()-o.getTime()}function m(t){i(1,arguments);var e=s(t);return e.setHours(23,59,59,999),e}function b(t){i(1,arguments);var e=s(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function x(t,e){i(2,arguments);var n,o=s(t),a=s(e),r=u(o,a),l=Math.abs(function(t,e){i(2,arguments);var n=s(t),o=s(e);return 12*(n.getFullYear()-o.getFullYear())+(n.getMonth()-o.getMonth())}(o,a));if(l<1)n=0;else{1===o.getMonth()&&o.getDate()>27&&o.setDate(30),o.setMonth(o.getMonth()-r*l);var h=u(o,a)===-r;(function(t){i(1,arguments);var e=s(t);return m(e).getTime()===b(e).getTime()})(s(t))&&1===l&&1===u(t,a)&&(h=!1),n=r*(l-h)}return 0===n?0:n}const _={datetime:"F d, yyyy, H:i:s",millisecond:"default",second:"longTime",minute:"longTime",hour:"default",day:"fullDate",week:"W",month:"M yyyy",quarter:"quater",year:"yyyy"};t._adapters._date.override({_id:"date-fns",formats:function(){return _},parse:function(t,e){return t},format:function(t,e){return t},add:function(t,s,r){switch(r){case"millisecond":return a(t,s);case"second":return function(t,s){return i(2,arguments),a(t,1e3*e(s))}(t,s);case"minute":return function(t,s){return i(2,arguments),a(t,6e4*e(s))}(t,s);case"hour":return function(t,s){return i(2,arguments),a(t,36e5*e(s))}(t,s);case"day":return n(t,s);case"week":return function(t,s){return i(2,arguments),n(t,7*e(s))}(t,s);case"month":return o(t,s);case"quarter":return function(t,s){return i(2,arguments),o(t,3*e(s))}(t,s);case"year":return function(t,s){return i(2,arguments),o(t,12*e(s))}(t,s);default:return t}},diff:function(t,e,n){switch(n){case"millisecond":return p(t,e);case"second":return function(t,e){i(2,arguments);var s=p(t,e)/1e3;return s>0?Math.floor(s):Math.ceil(s)}(t,e);case"minute":return function(t,e){i(2,arguments);var s=p(t,e)/6e4;return s>0?Math.floor(s):Math.ceil(s)}(t,e);case"hour":return function(t,e){i(2,arguments);var s=p(t,e)/36e5;return s>0?Math.floor(s):Math.ceil(s)}(t,e);case"day":return g(t,e);case"week":return function(t,e){i(2,arguments);var s=g(t,e)/7;return s>0?Math.floor(s):Math.ceil(s)}(t,e);case"month":return x(t,e);case"quarter":return function(t,e){i(2,arguments);var s=x(t,e)/3;return s>0?Math.floor(s):Math.ceil(s)}(t,e);case"year":return function(t,e){i(2,arguments);var n=s(t),o=s(e),a=u(n,o),r=Math.abs(function(t,e){i(2,arguments);var n=s(t),o=s(e);return n.getFullYear()-o.getFullYear()}(n,o));n.setFullYear("1584"),o.setFullYear("1584");var l=a*(r-(u(n,o)===-a));return 0===l?0:l}(t,e);default:return 0}},startOf:function(t,e,n){switch(e){case"second":return function(t){i(1,arguments);var e=s(t);return e.setMilliseconds(0),e}(t);case"minute":return function(t){i(1,arguments);var e=s(t);return e.setSeconds(0,0),e}(t);case"hour":return function(t){i(1,arguments);var e=s(t);return e.setMinutes(0,0,0),e}(t);case"day":return h(t);case"week":return r(t);case"isoWeek":return r(t,{weekStartsOn:+n});case"month":return function(t){i(1,arguments);var e=s(t);return e.setDate(1),e.setHours(0,0,0,0),e}(t);case"quarter":return function(t){i(1,arguments);var e=s(t),n=e.getMonth(),o=n-n%3;return e.setMonth(o,1),e.setHours(0,0,0,0),e}(t);case"year":return function(t){i(1,arguments);var e=s(t),n=new Date(0);return n.setFullYear(e.getFullYear(),0,1),n.setHours(0,0,0,0),n}(t);default:return t}},endOf:function(t,n){switch(n){case"second":return function(t){i(1,arguments);var e=s(t);return e.setMilliseconds(999),e}(t);case"minute":return function(t){i(1,arguments);var e=s(t);return e.setSeconds(59,999),e}(t);case"hour":return function(t){i(1,arguments);var e=s(t);return e.setMinutes(59,59,999),e}(t);case"day":return m(t);case"week":return function(t,n){i(1,arguments);var o={},a=o.locale,r=a&&a.options&&a.options.weekStartsOn,l=null==r?0:e(r),h=null==o.weekStartsOn?l:e(o.weekStartsOn);if(!(h>=0&&h<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var c=s(t),d=c.getDay(),u=6+(d= Math.min(start, end) - epsilon && value <= Math.max(start, end) + epsilon; +} function toFontString(font) { if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) { @@ -2301,7 +2304,7 @@ var layouts = { each(boxes.chartArea, (layout) => { const box = layout.box; Object.assign(box, chart.chartArea); - box.update(chartArea.w, chartArea.h); + box.update(chartArea.w, chartArea.h, {left: 0, top: 0, right: 0, bottom: 0}); }); } }; @@ -2404,7 +2407,8 @@ function _descriptors(proxy, defaults = {scriptable: true, indexable: true}) { }; } const readKey = (prefix, name) => prefix ? prefix + _capitalize(name) : name; -const needsSubResolver = (prop, value) => isObject(value) && prop !== 'adapters'; +const needsSubResolver = (prop, value) => isObject(value) && prop !== 'adapters' && + (Object.getPrototypeOf(value) === null || value.constructor === Object); function _cached(target, prop, resolve) { if (Object.prototype.hasOwnProperty.call(target, prop)) { return target[prop]; @@ -2435,7 +2439,7 @@ function _resolveScriptable(prop, value, target, receiver) { _stack.add(prop); value = value(_context, _subProxy || receiver); _stack.delete(prop); - if (isObject(value)) { + if (needsSubResolver(prop, value)) { value = createSubResolver(_proxy._scopes, _proxy, prop, value); } return value; @@ -2900,7 +2904,7 @@ function propertyFn(property) { }; } return { - between: (n, s, e) => n >= Math.min(s, e) && n <= Math.max(e, s), + between: _isBetween, compare: (a, b) => a - b, normalize: x => x }; @@ -3236,6 +3240,7 @@ _normalizeAngle: _normalizeAngle, _angleBetween: _angleBetween, _limitValue: _limitValue, _int16Range: _int16Range, +_isBetween: _isBetween, getRtlAdapter: getRtlAdapter, overrideTextDirection: overrideTextDirection, restoreTextDirection: restoreTextDirection, @@ -3344,15 +3349,23 @@ function fromNativeEvent(event, chart) { y: y !== undefined ? y : null, }; } +function nodeListContains(nodeList, canvas) { + for (const node of nodeList) { + if (node === canvas || node.contains(canvas)) { + return true; + } + } +} function createAttachObserver(chart, type, listener) { const canvas = chart.canvas; const observer = new MutationObserver(entries => { + let trigger = false; for (const entry of entries) { - for (const node of entry.addedNodes) { - if (node === canvas || node.contains(canvas)) { - return listener(); - } - } + trigger = trigger || nodeListContains(entry.addedNodes, canvas); + trigger = trigger && !nodeListContains(entry.removedNodes, canvas); + } + if (trigger) { + listener(); } }); observer.observe(document, {childList: true, subtree: true}); @@ -3361,12 +3374,13 @@ function createAttachObserver(chart, type, listener) { function createDetachObserver(chart, type, listener) { const canvas = chart.canvas; const observer = new MutationObserver(entries => { + let trigger = false; for (const entry of entries) { - for (const node of entry.removedNodes) { - if (node === canvas || node.contains(canvas)) { - return listener(); - } - } + trigger = trigger || nodeListContains(entry.removedNodes, canvas); + trigger = trigger && !nodeListContains(entry.addedNodes, canvas); + } + if (trigger) { + listener(); } }); observer.observe(document, {childList: true, subtree: true}); @@ -4111,6 +4125,7 @@ class DatasetController { const scopes = config.getOptionScopes(this.getDataset(), scopeKeys, true); this.options = config.createResolver(scopes, this.getContext()); this._parsing = this.options.parsing; + this._cachedDataOpts = {}; } parse(start, count) { const {_cachedMeta: meta, _data: data} = this; @@ -4282,8 +4297,6 @@ class DatasetController { } _update(mode) { const meta = this._cachedMeta; - this.configure(); - this._cachedDataOpts = {}; this.update(mode || 'default'); meta._clip = toClip(valueOrDefault(this.options.clip, defaultClip(meta.xScale, meta.yScale, this.getMaxOverflow()))); } @@ -4497,6 +4510,7 @@ class DatasetController { const [method, arg1, arg2] = args; this[method](arg1, arg2); } + this.chart._dataChanges.push([this.index, ...args]); } _onDataPush() { const count = arguments.length; @@ -4509,8 +4523,13 @@ class DatasetController { this._sync(['_removeElements', 0, 1]); } _onDataSplice(start, count) { - this._sync(['_removeElements', start, count]); - this._sync(['_insertElements', start, arguments.length - 2]); + if (count) { + this._sync(['_removeElements', start, count]); + } + const newCount = arguments.length - 2; + if (newCount) { + this._sync(['_insertElements', start, newCount]); + } } _onDataUnshift() { this._sync(['_insertElements', 0, arguments.length]); @@ -6507,7 +6526,7 @@ function needContext(proxy, names) { return false; } -var version = "3.6.0"; +var version = "3.6.1"; const KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea']; function positionIsHorizontal(position, axis) { @@ -6547,6 +6566,19 @@ const getChart = (key) => { const canvas = getCanvas(key); return Object.values(instances).filter((c) => c.canvas === canvas).pop(); }; +function moveNumericKeys(obj, start, move) { + const keys = Object.keys(obj); + for (const key of keys) { + const intKey = +key; + if (intKey >= start) { + const value = obj[key]; + delete obj[key]; + if (move > 0 || intKey > start) { + obj[intKey + move] = value; + } + } + } +} class Chart { constructor(item, userConfig) { const config = this.config = new Config(userConfig); @@ -6591,6 +6623,7 @@ class Chart { this._animationsDisabled = undefined; this.$context = undefined; this._doResize = debounce(mode => this.update(mode), options.resizeDelay || 0); + this._dataChanges = []; instances[this.id] = this; if (!context || !canvas) { console.error("Failed to create chart: can't acquire context from the given item"); @@ -6810,18 +6843,10 @@ class Chart { const config = this.config; config.update(); const options = this._options = config.createResolver(config.chartOptionScopes(), this.getContext()); - each(this.scales, (scale) => { - layouts.removeBox(this, scale); - }); const animsDisabled = this._animationsDisabled = !options.animation; - this.ensureScalesHaveIDs(); - this.buildOrUpdateScales(); - const existingEvents = new Set(Object.keys(this._listeners)); - const newEvents = new Set(options.events); - if (!setsEqual(existingEvents, newEvents) || !!this._responsiveListeners !== options.responsive) { - this.unbindEvents(); - this.bindEvents(); - } + this._updateScales(); + this._checkEventBindings(); + this._updateHiddenIndices(); this._plugins.invalidate(); if (this.notifyPlugins('beforeUpdate', {mode, cancelable: true}) === false) { return; @@ -6850,6 +6875,52 @@ class Chart { } this.render(); } + _updateScales() { + each(this.scales, (scale) => { + layouts.removeBox(this, scale); + }); + this.ensureScalesHaveIDs(); + this.buildOrUpdateScales(); + } + _checkEventBindings() { + const options = this.options; + const existingEvents = new Set(Object.keys(this._listeners)); + const newEvents = new Set(options.events); + if (!setsEqual(existingEvents, newEvents) || !!this._responsiveListeners !== options.responsive) { + this.unbindEvents(); + this.bindEvents(); + } + } + _updateHiddenIndices() { + const {_hiddenIndices} = this; + const changes = this._getUniformDataChanges() || []; + for (const {method, start, count} of changes) { + const move = method === '_removeElements' ? -count : count; + moveNumericKeys(_hiddenIndices, start, move); + } + } + _getUniformDataChanges() { + const _dataChanges = this._dataChanges; + if (!_dataChanges || !_dataChanges.length) { + return; + } + this._dataChanges = []; + const datasetCount = this.data.datasets.length; + const makeSet = (idx) => new Set( + _dataChanges + .filter(c => c[0] === idx) + .map((c, i) => i + ',' + c.splice(1).join(',')) + ); + const changeSet = makeSet(0); + for (let i = 1; i < datasetCount; i++) { + if (!setsEqual(changeSet, makeSet(i))) { + return; + } + } + return Array.from(changeSet) + .map(c => c.split(',')) + .map(a => ({method: a[1], start: +a[2], count: +a[3]})); + } _updateLayout(minPadding) { if (this.notifyPlugins('beforeLayout', {cancelable: true}) === false) { return; @@ -6876,6 +6947,9 @@ class Chart { if (this.notifyPlugins('beforeDatasetsUpdate', {mode, cancelable: true}) === false) { return; } + for (let i = 0, ilen = this.data.datasets.length; i < ilen; ++i) { + this.getDatasetMeta(i).controller.configure(); + } for (let i = 0, ilen = this.data.datasets.length; i < ilen; ++i) { this._updateDataset(i, isFunction(mode) ? mode({datasetIndex: i}) : mode); } @@ -8102,9 +8176,6 @@ class DoughnutController extends DatasetController { meta = chart.getDatasetMeta(i); arcs = meta.data; controller = meta.controller; - if (controller !== this) { - controller.configure(); - } break; } } @@ -8835,8 +8906,9 @@ class ArcElement extends Element { 'circumference' ], useFinalPosition); const rAdjust = this.options.spacing / 2; - const betweenAngles = circumference >= TAU || _angleBetween(angle, startAngle, endAngle); - const withinRadius = (distance >= innerRadius + rAdjust && distance <= outerRadius + rAdjust); + const _circumference = valueOrDefault(circumference, endAngle - startAngle); + const betweenAngles = _circumference >= TAU || _angleBetween(angle, startAngle, endAngle); + const withinRadius = _isBetween(distance, innerRadius + rAdjust, outerRadius + rAdjust); return (betweenAngles && withinRadius); } getCenterPoint(useFinalPosition) { @@ -9324,8 +9396,8 @@ function inRange(bar, x, y, useFinalPosition) { const skipBoth = skipX && skipY; const bounds = bar && !skipBoth && getBarBounds(bar, useFinalPosition); return bounds - && (skipX || x >= bounds.left && x <= bounds.right) - && (skipY || y >= bounds.top && y <= bounds.bottom); + && (skipX || _isBetween(x, bounds.left, bounds.right)) + && (skipY || _isBetween(y, bounds.top, bounds.bottom)); } function hasRadius(radius) { return radius.topLeft || radius.topRight || radius.bottomLeft || radius.bottomRight; @@ -9822,7 +9894,7 @@ function findPoint(line, sourcePoint, property) { const segment = segments[i]; const firstValue = linePoints[segment.start][property]; const lastValue = linePoints[segment.end][property]; - if (pointValue >= firstValue && pointValue <= lastValue) { + if (_isBetween(pointValue, firstValue, lastValue)) { first = pointValue === firstValue; last = pointValue === lastValue; break; @@ -10441,11 +10513,13 @@ class Legend extends Element { } _getLegendItemAt(x, y) { let i, hitBox, lh; - if (x >= this.left && x <= this.right && y >= this.top && y <= this.bottom) { + if (_isBetween(x, this.left, this.right) + && _isBetween(y, this.top, this.bottom)) { lh = this.legendHitBoxes; for (i = 0; i < lh.length; ++i) { hitBox = lh[i]; - if (x >= hitBox.left && x <= hitBox.left + hitBox.width && y >= hitBox.top && y <= hitBox.top + hitBox.height) { + if (_isBetween(x, hitBox.left, hitBox.left + hitBox.width) + && _isBetween(y, hitBox.top, hitBox.top + hitBox.height)) { return this.legendItems[i]; } } @@ -10961,9 +11035,9 @@ function getBackgroundPoint(options, size, alignment, chart) { x -= paddingAndSize; } } else if (xAlign === 'left') { - x -= Math.max(topLeft, bottomLeft) + caretPadding; + x -= Math.max(topLeft, bottomLeft) + caretSize; } else if (xAlign === 'right') { - x += Math.max(topRight, bottomRight) + caretPadding; + x += Math.max(topRight, bottomRight) + caretSize; } return { x: _limitValue(x, 0, chart.width - size.width), @@ -11695,13 +11769,19 @@ Title: plugin_title, Tooltip: plugin_tooltip }); -const addIfString = (labels, raw, index) => typeof raw === 'string' - ? labels.push(raw) - 1 - : isNaN(raw) ? null : index; -function findOrAddLabel(labels, raw, index) { +const addIfString = (labels, raw, index, addedLabels) => { + if (typeof raw === 'string') { + index = labels.push(raw) - 1; + addedLabels.unshift({index, label: raw}); + } else if (isNaN(raw)) { + index = null; + } + return index; +}; +function findOrAddLabel(labels, raw, index, addedLabels) { const first = labels.indexOf(raw); if (first === -1) { - return addIfString(labels, raw, index); + return addIfString(labels, raw, index, addedLabels); } const last = labels.lastIndexOf(raw); return first !== last ? index : first; @@ -11712,6 +11792,20 @@ class CategoryScale extends Scale { super(cfg); this._startValue = undefined; this._valueRange = 0; + this._addedLabels = []; + } + init(scaleOptions) { + const added = this._addedLabels; + if (added.length) { + const labels = this.getLabels(); + for (const {index, label} of added) { + if (labels[index] === label) { + labels.splice(index, 1); + } + } + this._addedLabels = []; + } + super.init(scaleOptions); } parse(raw, index) { if (isNullOrUndef(raw)) { @@ -11719,7 +11813,7 @@ class CategoryScale extends Scale { } const labels = this.getLabels(); index = isFinite(index) && labels[index] === raw ? index - : findOrAddLabel(labels, raw, valueOrDefault(index, raw)); + : findOrAddLabel(labels, raw, valueOrDefault(index, raw), this._addedLabels); return validIndex(index, labels.length - 1); } determineDataLimits() { @@ -11996,7 +12090,7 @@ class LinearScaleBase extends Scale { this._valueRange = end - start; } getLabelForValue(value) { - return formatNumber(value, this.chart.options.locale); + return formatNumber(value, this.chart.options.locale, this.options.ticks.format); } } @@ -12129,7 +12223,9 @@ class LogarithmicScale extends Scale { return ticks; } getLabelForValue(value) { - return value === undefined ? '0' : formatNumber(value, this.chart.options.locale); + return value === undefined + ? '0' + : formatNumber(value, this.chart.options.locale, this.options.ticks.format); } configure() { const start = this.min; diff --git a/src/const.js b/src/const.js index 959e5d9..d434bd3 100644 --- a/src/const.js +++ b/src/const.js @@ -24,8 +24,8 @@ import "/hacsfiles/chart-card/chart.js?module" const appinfo = { name: "✓ custom:chart-card ", app: "chart-card", - version: "v2.1.6/v3.6.0", - chartjs: Chart.version || "v3.6.0", + version: "v2.1.6/v3.6.1", + chartjs: Chart.version || "v3.6.1", assets: "/hacsfiles/chart-card/assets/", github: "https://github.com/zibous/lovelace-graph-chart-card" } diff --git a/src/libs/chartjs/chart.js b/src/libs/chartjs/chart.js index d4e6683..8f13c71 100644 --- a/src/libs/chartjs/chart.js +++ b/src/libs/chartjs/chart.js @@ -1,5 +1,5 @@ /*! - * Chart.js v3.6.0 + * Chart.js v3.6.1 * https://www.chartjs.org * (c) 2021 Chart.js Contributors * Released under the MIT License @@ -1166,6 +1166,9 @@ function _limitValue(value, min, max) { function _int16Range(value) { return _limitValue(value, -32768, 32767); } +function _isBetween(value, start, end, epsilon = 1e-6) { + return value >= Math.min(start, end) - epsilon && value <= Math.max(start, end) + epsilon; +} function toFontString(font) { if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) { @@ -2301,7 +2304,7 @@ var layouts = { each(boxes.chartArea, (layout) => { const box = layout.box; Object.assign(box, chart.chartArea); - box.update(chartArea.w, chartArea.h); + box.update(chartArea.w, chartArea.h, {left: 0, top: 0, right: 0, bottom: 0}); }); } }; @@ -2404,7 +2407,8 @@ function _descriptors(proxy, defaults = {scriptable: true, indexable: true}) { }; } const readKey = (prefix, name) => prefix ? prefix + _capitalize(name) : name; -const needsSubResolver = (prop, value) => isObject(value) && prop !== 'adapters'; +const needsSubResolver = (prop, value) => isObject(value) && prop !== 'adapters' && + (Object.getPrototypeOf(value) === null || value.constructor === Object); function _cached(target, prop, resolve) { if (Object.prototype.hasOwnProperty.call(target, prop)) { return target[prop]; @@ -2435,7 +2439,7 @@ function _resolveScriptable(prop, value, target, receiver) { _stack.add(prop); value = value(_context, _subProxy || receiver); _stack.delete(prop); - if (isObject(value)) { + if (needsSubResolver(prop, value)) { value = createSubResolver(_proxy._scopes, _proxy, prop, value); } return value; @@ -2900,7 +2904,7 @@ function propertyFn(property) { }; } return { - between: (n, s, e) => n >= Math.min(s, e) && n <= Math.max(e, s), + between: _isBetween, compare: (a, b) => a - b, normalize: x => x }; @@ -3236,6 +3240,7 @@ _normalizeAngle: _normalizeAngle, _angleBetween: _angleBetween, _limitValue: _limitValue, _int16Range: _int16Range, +_isBetween: _isBetween, getRtlAdapter: getRtlAdapter, overrideTextDirection: overrideTextDirection, restoreTextDirection: restoreTextDirection, @@ -3344,15 +3349,23 @@ function fromNativeEvent(event, chart) { y: y !== undefined ? y : null, }; } +function nodeListContains(nodeList, canvas) { + for (const node of nodeList) { + if (node === canvas || node.contains(canvas)) { + return true; + } + } +} function createAttachObserver(chart, type, listener) { const canvas = chart.canvas; const observer = new MutationObserver(entries => { + let trigger = false; for (const entry of entries) { - for (const node of entry.addedNodes) { - if (node === canvas || node.contains(canvas)) { - return listener(); - } - } + trigger = trigger || nodeListContains(entry.addedNodes, canvas); + trigger = trigger && !nodeListContains(entry.removedNodes, canvas); + } + if (trigger) { + listener(); } }); observer.observe(document, {childList: true, subtree: true}); @@ -3361,12 +3374,13 @@ function createAttachObserver(chart, type, listener) { function createDetachObserver(chart, type, listener) { const canvas = chart.canvas; const observer = new MutationObserver(entries => { + let trigger = false; for (const entry of entries) { - for (const node of entry.removedNodes) { - if (node === canvas || node.contains(canvas)) { - return listener(); - } - } + trigger = trigger || nodeListContains(entry.removedNodes, canvas); + trigger = trigger && !nodeListContains(entry.addedNodes, canvas); + } + if (trigger) { + listener(); } }); observer.observe(document, {childList: true, subtree: true}); @@ -4111,6 +4125,7 @@ class DatasetController { const scopes = config.getOptionScopes(this.getDataset(), scopeKeys, true); this.options = config.createResolver(scopes, this.getContext()); this._parsing = this.options.parsing; + this._cachedDataOpts = {}; } parse(start, count) { const {_cachedMeta: meta, _data: data} = this; @@ -4282,8 +4297,6 @@ class DatasetController { } _update(mode) { const meta = this._cachedMeta; - this.configure(); - this._cachedDataOpts = {}; this.update(mode || 'default'); meta._clip = toClip(valueOrDefault(this.options.clip, defaultClip(meta.xScale, meta.yScale, this.getMaxOverflow()))); } @@ -4497,6 +4510,7 @@ class DatasetController { const [method, arg1, arg2] = args; this[method](arg1, arg2); } + this.chart._dataChanges.push([this.index, ...args]); } _onDataPush() { const count = arguments.length; @@ -4509,8 +4523,13 @@ class DatasetController { this._sync(['_removeElements', 0, 1]); } _onDataSplice(start, count) { - this._sync(['_removeElements', start, count]); - this._sync(['_insertElements', start, arguments.length - 2]); + if (count) { + this._sync(['_removeElements', start, count]); + } + const newCount = arguments.length - 2; + if (newCount) { + this._sync(['_insertElements', start, newCount]); + } } _onDataUnshift() { this._sync(['_insertElements', 0, arguments.length]); @@ -6507,7 +6526,7 @@ function needContext(proxy, names) { return false; } -var version = "3.6.0"; +var version = "3.6.1"; const KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea']; function positionIsHorizontal(position, axis) { @@ -6547,6 +6566,19 @@ const getChart = (key) => { const canvas = getCanvas(key); return Object.values(instances).filter((c) => c.canvas === canvas).pop(); }; +function moveNumericKeys(obj, start, move) { + const keys = Object.keys(obj); + for (const key of keys) { + const intKey = +key; + if (intKey >= start) { + const value = obj[key]; + delete obj[key]; + if (move > 0 || intKey > start) { + obj[intKey + move] = value; + } + } + } +} class Chart { constructor(item, userConfig) { const config = this.config = new Config(userConfig); @@ -6591,6 +6623,7 @@ class Chart { this._animationsDisabled = undefined; this.$context = undefined; this._doResize = debounce(mode => this.update(mode), options.resizeDelay || 0); + this._dataChanges = []; instances[this.id] = this; if (!context || !canvas) { console.error("Failed to create chart: can't acquire context from the given item"); @@ -6810,18 +6843,10 @@ class Chart { const config = this.config; config.update(); const options = this._options = config.createResolver(config.chartOptionScopes(), this.getContext()); - each(this.scales, (scale) => { - layouts.removeBox(this, scale); - }); const animsDisabled = this._animationsDisabled = !options.animation; - this.ensureScalesHaveIDs(); - this.buildOrUpdateScales(); - const existingEvents = new Set(Object.keys(this._listeners)); - const newEvents = new Set(options.events); - if (!setsEqual(existingEvents, newEvents) || !!this._responsiveListeners !== options.responsive) { - this.unbindEvents(); - this.bindEvents(); - } + this._updateScales(); + this._checkEventBindings(); + this._updateHiddenIndices(); this._plugins.invalidate(); if (this.notifyPlugins('beforeUpdate', {mode, cancelable: true}) === false) { return; @@ -6850,6 +6875,52 @@ class Chart { } this.render(); } + _updateScales() { + each(this.scales, (scale) => { + layouts.removeBox(this, scale); + }); + this.ensureScalesHaveIDs(); + this.buildOrUpdateScales(); + } + _checkEventBindings() { + const options = this.options; + const existingEvents = new Set(Object.keys(this._listeners)); + const newEvents = new Set(options.events); + if (!setsEqual(existingEvents, newEvents) || !!this._responsiveListeners !== options.responsive) { + this.unbindEvents(); + this.bindEvents(); + } + } + _updateHiddenIndices() { + const {_hiddenIndices} = this; + const changes = this._getUniformDataChanges() || []; + for (const {method, start, count} of changes) { + const move = method === '_removeElements' ? -count : count; + moveNumericKeys(_hiddenIndices, start, move); + } + } + _getUniformDataChanges() { + const _dataChanges = this._dataChanges; + if (!_dataChanges || !_dataChanges.length) { + return; + } + this._dataChanges = []; + const datasetCount = this.data.datasets.length; + const makeSet = (idx) => new Set( + _dataChanges + .filter(c => c[0] === idx) + .map((c, i) => i + ',' + c.splice(1).join(',')) + ); + const changeSet = makeSet(0); + for (let i = 1; i < datasetCount; i++) { + if (!setsEqual(changeSet, makeSet(i))) { + return; + } + } + return Array.from(changeSet) + .map(c => c.split(',')) + .map(a => ({method: a[1], start: +a[2], count: +a[3]})); + } _updateLayout(minPadding) { if (this.notifyPlugins('beforeLayout', {cancelable: true}) === false) { return; @@ -6876,6 +6947,9 @@ class Chart { if (this.notifyPlugins('beforeDatasetsUpdate', {mode, cancelable: true}) === false) { return; } + for (let i = 0, ilen = this.data.datasets.length; i < ilen; ++i) { + this.getDatasetMeta(i).controller.configure(); + } for (let i = 0, ilen = this.data.datasets.length; i < ilen; ++i) { this._updateDataset(i, isFunction(mode) ? mode({datasetIndex: i}) : mode); } @@ -8102,9 +8176,6 @@ class DoughnutController extends DatasetController { meta = chart.getDatasetMeta(i); arcs = meta.data; controller = meta.controller; - if (controller !== this) { - controller.configure(); - } break; } } @@ -8835,8 +8906,9 @@ class ArcElement extends Element { 'circumference' ], useFinalPosition); const rAdjust = this.options.spacing / 2; - const betweenAngles = circumference >= TAU || _angleBetween(angle, startAngle, endAngle); - const withinRadius = (distance >= innerRadius + rAdjust && distance <= outerRadius + rAdjust); + const _circumference = valueOrDefault(circumference, endAngle - startAngle); + const betweenAngles = _circumference >= TAU || _angleBetween(angle, startAngle, endAngle); + const withinRadius = _isBetween(distance, innerRadius + rAdjust, outerRadius + rAdjust); return (betweenAngles && withinRadius); } getCenterPoint(useFinalPosition) { @@ -9324,8 +9396,8 @@ function inRange(bar, x, y, useFinalPosition) { const skipBoth = skipX && skipY; const bounds = bar && !skipBoth && getBarBounds(bar, useFinalPosition); return bounds - && (skipX || x >= bounds.left && x <= bounds.right) - && (skipY || y >= bounds.top && y <= bounds.bottom); + && (skipX || _isBetween(x, bounds.left, bounds.right)) + && (skipY || _isBetween(y, bounds.top, bounds.bottom)); } function hasRadius(radius) { return radius.topLeft || radius.topRight || radius.bottomLeft || radius.bottomRight; @@ -9822,7 +9894,7 @@ function findPoint(line, sourcePoint, property) { const segment = segments[i]; const firstValue = linePoints[segment.start][property]; const lastValue = linePoints[segment.end][property]; - if (pointValue >= firstValue && pointValue <= lastValue) { + if (_isBetween(pointValue, firstValue, lastValue)) { first = pointValue === firstValue; last = pointValue === lastValue; break; @@ -10441,11 +10513,13 @@ class Legend extends Element { } _getLegendItemAt(x, y) { let i, hitBox, lh; - if (x >= this.left && x <= this.right && y >= this.top && y <= this.bottom) { + if (_isBetween(x, this.left, this.right) + && _isBetween(y, this.top, this.bottom)) { lh = this.legendHitBoxes; for (i = 0; i < lh.length; ++i) { hitBox = lh[i]; - if (x >= hitBox.left && x <= hitBox.left + hitBox.width && y >= hitBox.top && y <= hitBox.top + hitBox.height) { + if (_isBetween(x, hitBox.left, hitBox.left + hitBox.width) + && _isBetween(y, hitBox.top, hitBox.top + hitBox.height)) { return this.legendItems[i]; } } @@ -10961,9 +11035,9 @@ function getBackgroundPoint(options, size, alignment, chart) { x -= paddingAndSize; } } else if (xAlign === 'left') { - x -= Math.max(topLeft, bottomLeft) + caretPadding; + x -= Math.max(topLeft, bottomLeft) + caretSize; } else if (xAlign === 'right') { - x += Math.max(topRight, bottomRight) + caretPadding; + x += Math.max(topRight, bottomRight) + caretSize; } return { x: _limitValue(x, 0, chart.width - size.width), @@ -11695,13 +11769,19 @@ Title: plugin_title, Tooltip: plugin_tooltip }); -const addIfString = (labels, raw, index) => typeof raw === 'string' - ? labels.push(raw) - 1 - : isNaN(raw) ? null : index; -function findOrAddLabel(labels, raw, index) { +const addIfString = (labels, raw, index, addedLabels) => { + if (typeof raw === 'string') { + index = labels.push(raw) - 1; + addedLabels.unshift({index, label: raw}); + } else if (isNaN(raw)) { + index = null; + } + return index; +}; +function findOrAddLabel(labels, raw, index, addedLabels) { const first = labels.indexOf(raw); if (first === -1) { - return addIfString(labels, raw, index); + return addIfString(labels, raw, index, addedLabels); } const last = labels.lastIndexOf(raw); return first !== last ? index : first; @@ -11712,6 +11792,20 @@ class CategoryScale extends Scale { super(cfg); this._startValue = undefined; this._valueRange = 0; + this._addedLabels = []; + } + init(scaleOptions) { + const added = this._addedLabels; + if (added.length) { + const labels = this.getLabels(); + for (const {index, label} of added) { + if (labels[index] === label) { + labels.splice(index, 1); + } + } + this._addedLabels = []; + } + super.init(scaleOptions); } parse(raw, index) { if (isNullOrUndef(raw)) { @@ -11719,7 +11813,7 @@ class CategoryScale extends Scale { } const labels = this.getLabels(); index = isFinite(index) && labels[index] === raw ? index - : findOrAddLabel(labels, raw, valueOrDefault(index, raw)); + : findOrAddLabel(labels, raw, valueOrDefault(index, raw), this._addedLabels); return validIndex(index, labels.length - 1); } determineDataLimits() { @@ -11996,7 +12090,7 @@ class LinearScaleBase extends Scale { this._valueRange = end - start; } getLabelForValue(value) { - return formatNumber(value, this.chart.options.locale); + return formatNumber(value, this.chart.options.locale, this.options.ticks.format); } } @@ -12129,7 +12223,9 @@ class LogarithmicScale extends Scale { return ticks; } getLabelForValue(value) { - return value === undefined ? '0' : formatNumber(value, this.chart.options.locale); + return value === undefined + ? '0' + : formatNumber(value, this.chart.options.locale, this.options.ticks.format); } configure() { const start = this.min; diff --git a/src/libs/chartjs/chart.min.js b/src/libs/chartjs/chart.min.js index b711490..6972476 100644 --- a/src/libs/chartjs/chart.min.js +++ b/src/libs/chartjs/chart.min.js @@ -1,5 +1,5 @@ /*! - * Chart.js v3.6.0 + * Chart.js v3.6.1 * https://www.chartjs.org * (c) 2021 Chart.js Contributors * Released under the MIT License @@ -10,4 +10,4 @@ * https://github.com/kurkle/color#readme * (c) 2020 Jukka Kurkela * Released under the MIT License - */const r={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},l="0123456789ABCDEF",h=t=>l[15&t],c=t=>l[(240&t)>>4]+l[15&t],d=t=>(240&t)>>4==(15&t);function u(t){var e=function(t){return d(t.r)&&d(t.g)&&d(t.b)&&d(t.a)}(t)?h:c;return t?"#"+e(t.r)+e(t.g)+e(t.b)+(t.a<255?e(t.a):""):t}function f(t){return t+.5|0}const g=(t,e,i)=>Math.max(Math.min(t,i),e);function p(t){return g(f(2.55*t),0,255)}function m(t){return g(f(255*t),0,255)}function x(t){return g(f(t/2.55)/100,0,1)}function b(t){return g(f(100*t),0,100)}const _=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const y=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function v(t,e,i){const s=e*Math.min(i,1-i),n=(e,n=(e+t/30)%12)=>i-s*Math.max(Math.min(n-3,9-n,1),-1);return[n(0),n(8),n(4)]}function w(t,e,i){const s=(s,n=(s+t/60)%6)=>i-i*e*Math.max(Math.min(n,4-n,1),0);return[s(5),s(3),s(1)]}function M(t,e,i){const s=v(t,1,.5);let n;for(e+i>1&&(n=1/(e+i),e*=n,i*=n),n=0;n<3;n++)s[n]*=1-e-i,s[n]+=e;return s}function k(t){const e=t.r/255,i=t.g/255,s=t.b/255,n=Math.max(e,i,s),o=Math.min(e,i,s),a=(n+o)/2;let r,l,h;return n!==o&&(h=n-o,l=a>.5?h/(2-n-o):h/(n+o),r=n===e?(i-s)/h+(i>16&255,o>>8&255,255&o]}return t}(),T.transparent=[0,0,0,0]);const e=T[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}function R(t,e,i){if(t){let s=k(t);s[e]=Math.max(0,Math.min(s[e]+s[e]*i,0===e?360:1)),s=P(s),t.r=s[0],t.g=s[1],t.b=s[2]}}function E(t,e){return t?Object.assign(e||{},t):t}function I(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=m(t[3]))):(e=E(t,{r:0,g:0,b:0,a:1})).a=m(e.a),e}function z(t){return"r"===t.charAt(0)?function(t){const e=_.exec(t);let i,s,n,o=255;if(e){if(e[7]!==i){const t=+e[7];o=255&(e[8]?p(t):255*t)}return i=+e[1],s=+e[3],n=+e[5],i=255&(e[2]?p(i):i),s=255&(e[4]?p(s):s),n=255&(e[6]?p(n):n),{r:i,g:s,b:n,a:o}}}(t):C(t)}class F{constructor(t){if(t instanceof F)return t;const e=typeof t;let i;var s,n,o;"object"===e?i=I(t):"string"===e&&(o=(s=t).length,"#"===s[0]&&(4===o||5===o?n={r:255&17*r[s[1]],g:255&17*r[s[2]],b:255&17*r[s[3]],a:5===o?17*r[s[4]]:255}:7!==o&&9!==o||(n={r:r[s[1]]<<4|r[s[2]],g:r[s[3]]<<4|r[s[4]],b:r[s[5]]<<4|r[s[6]],a:9===o?r[s[7]]<<4|r[s[8]]:255})),i=n||L(t)||z(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=E(this._rgb);return t&&(t.a=x(t.a)),t}set rgb(t){this._rgb=I(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${x(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):this._rgb;var t}hexString(){return this._valid?u(this._rgb):this._rgb}hslString(){return this._valid?function(t){if(!t)return;const e=k(t),i=e[0],s=b(e[1]),n=b(e[2]);return t.a<255?`hsla(${i}, ${s}%, ${n}%, ${x(t.a)})`:`hsl(${i}, ${s}%, ${n}%)`}(this._rgb):this._rgb}mix(t,e){const i=this;if(t){const s=i.rgb,n=t.rgb;let o;const a=e===o?.5:e,r=2*a-1,l=s.a-n.a,h=((r*l==-1?r:(r+l)/(1+r*l))+1)/2;o=1-h,s.r=255&h*s.r+o*n.r+.5,s.g=255&h*s.g+o*n.g+.5,s.b=255&h*s.b+o*n.b+.5,s.a=a*s.a+(1-a)*n.a,i.rgb=s}return i}clone(){return new F(this.rgb)}alpha(t){return this._rgb.a=m(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,e=f(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return R(this._rgb,2,t),this}darken(t){return R(this._rgb,2,-t),this}saturate(t){return R(this._rgb,1,t),this}desaturate(t){return R(this._rgb,1,-t),this}rotate(t){return function(t,e){var i=k(t);i[0]=D(i[0]+e),i=P(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this}}function B(t){return new F(t)}const V=t=>t instanceof CanvasGradient||t instanceof CanvasPattern;function W(t){return V(t)?t:B(t)}function N(t){return V(t)?t:B(t).saturate(.5).darken(.1).hexString()}function H(){}const j=function(){let t=0;return function(){return t++}}();function $(t){return null==t}function Y(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.substr(0,7)&&"Array]"===e.substr(-6)}function U(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}const X=t=>("number"==typeof t||t instanceof Number)&&isFinite(+t);function q(t,e){return X(t)?t:e}function K(t,e){return void 0===t?e:t}const G=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:t/e,Z=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function Q(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function J(t,e,i,s){let n,o,a;if(Y(t))if(o=t.length,s)for(n=o-1;n>=0;n--)e.call(i,t[n],n);else for(n=0;ni;)t=t[e.substr(i,s-i)],i=s+1,s=rt(e,i);return t}function ht(t){return t.charAt(0).toUpperCase()+t.slice(1)}const ct=t=>void 0!==t,dt=t=>"function"==typeof t,ut=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0},ft=Object.create(null),gt=Object.create(null);function pt(t,e){if(!e)return t;const i=e.split(".");for(let e=0,s=i.length;et.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(t,e)=>N(e.backgroundColor),this.hoverBorderColor=(t,e)=>N(e.borderColor),this.hoverColor=(t,e)=>N(e.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.describe(t)}set(t,e){return mt(this,t,e)}get(t){return pt(this,t)}describe(t,e){return mt(gt,t,e)}override(t,e){return mt(ft,t,e)}route(t,e,i,s){const n=pt(this,t),o=pt(this,i),a="_"+e;Object.defineProperties(n,{[a]:{value:n[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[a],e=o[s];return U(t)?Object.assign({},e,t):K(t,e)},set(t){this[a]=t}}})}}({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}});const bt=Math.PI,_t=2*bt,yt=_t+bt,vt=Number.POSITIVE_INFINITY,wt=bt/180,Mt=bt/2,kt=bt/4,St=2*bt/3,Pt=Math.log10,Dt=Math.sign;function Ct(t){const e=Math.round(t);t=Tt(t,e,t/1e3)?e:t;const i=Math.pow(10,Math.floor(Pt(t))),s=t/i;return(s<=1?1:s<=2?2:s<=5?5:10)*i}function Ot(t){const e=[],i=Math.sqrt(t);let s;for(s=1;st-e)).pop(),e}function At(t){return!isNaN(parseFloat(t))&&isFinite(t)}function Tt(t,e,i){return Math.abs(t-e)=t}function Rt(t,e,i){let s,n,o;for(s=0,n=t.length;sl&&hs&&(s=o),s}function Ut(t,e,i,s){let n=(s=s||{}).data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==e&&(n=s.data={},o=s.garbageCollect=[],s.font=e),t.save(),t.font=e;let a=0;const r=i.length;let l,h,c,d,u;for(l=0;li.length){for(l=0;l0&&t.stroke()}}function Gt(t,e,i){return i=i||.5,!e||t&&t.x>e.left-i&&t.xe.top-i&&t.y0&&""!==o.strokeColor;let l,h;for(t.save(),t.font=n.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]);$(e.rotation)||t.rotate(e.rotation);e.color&&(t.fillStyle=e.color);e.textAlign&&(t.textAlign=e.textAlign);e.textBaseline&&(t.textBaseline=e.textBaseline)}(t,o),l=0;lt[i]1;)s=o+n>>1,i(s)?o=s:n=s;return{lo:o,hi:n}}const oe=(t,e,i)=>ne(t,i,(s=>t[s][e]ne(t,i,(s=>t[s][e]>=i));function re(t,e,i){let s=0,n=t.length;for(;ss&&t[n-1]>i;)n--;return s>0||n{const i="_onData"+ht(e),s=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...e){const n=s.apply(this,e);return t._chartjs.listeners.forEach((t=>{"function"==typeof t[i]&&t[i](...e)})),n}})})))}function ce(t,e){const i=t._chartjs;if(!i)return;const s=i.listeners,n=s.indexOf(e);-1!==n&&s.splice(n,1),s.length>0||(le.forEach((e=>{delete t[e]})),delete t._chartjs)}function de(t){const e=new Set;let i,s;for(i=0,s=t.length;iwindow.getComputedStyle(t,null);function me(t,e){return pe(t).getPropertyValue(e)}const xe=["top","right","bottom","left"];function be(t,e,i){const s={};i=i?"-"+i:"";for(let n=0;n<4;n++){const o=xe[n];s[o]=parseFloat(t[e+"-"+o+i])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}function _e(t,e){const{canvas:i,currentDevicePixelRatio:s}=e,n=pe(i),o="border-box"===n.boxSizing,a=be(n,"padding"),r=be(n,"border","width"),{x:l,y:h,box:c}=function(t,e){const i=t.native||t,s=i.touches,n=s&&s.length?s[0]:i,{offsetX:o,offsetY:a}=n;let r,l,h=!1;if(((t,e,i)=>(t>0||e>0)&&(!i||!i.shadowRoot))(o,a,i.target))r=o,l=a;else{const t=e.getBoundingClientRect();r=n.clientX-t.left,l=n.clientY-t.top,h=!0}return{x:r,y:l,box:h}}(t,i),d=a.left+(c&&r.left),u=a.top+(c&&r.top);let{width:f,height:g}=e;return o&&(f-=a.width+r.width,g-=a.height+r.height),{x:Math.round((l-d)/f*i.width/s),y:Math.round((h-u)/g*i.height/s)}}const ye=t=>Math.round(10*t)/10;function ve(t,e,i,s){const n=pe(t),o=be(n,"margin"),a=ge(n.maxWidth,t,"clientWidth")||vt,r=ge(n.maxHeight,t,"clientHeight")||vt,l=function(t,e,i){let s,n;if(void 0===e||void 0===i){const o=fe(t);if(o){const t=o.getBoundingClientRect(),a=pe(o),r=be(a,"border","width"),l=be(a,"padding");e=t.width-l.width-r.width,i=t.height-l.height-r.height,s=ge(a.maxWidth,o,"clientWidth"),n=ge(a.maxHeight,o,"clientHeight")}else e=t.clientWidth,i=t.clientHeight}return{width:e,height:i,maxWidth:s||vt,maxHeight:n||vt}}(t,e,i);let{width:h,height:c}=l;if("content-box"===n.boxSizing){const t=be(n,"border","width"),e=be(n,"padding");h-=e.width+t.width,c-=e.height+t.height}return h=Math.max(0,h-o.width),c=Math.max(0,s?Math.floor(h/s):c-o.height),h=ye(Math.min(h,a,l.maxWidth)),c=ye(Math.min(c,r,l.maxHeight)),h&&!c&&(c=ye(h/2)),{width:h,height:c}}function we(t,e,i){const s=e||1,n=Math.floor(t.height*s),o=Math.floor(t.width*s);t.height=n/s,t.width=o/s;const a=t.canvas;return a.style&&(i||!a.style.height&&!a.style.width)&&(a.style.height=`${t.height}px`,a.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(t.currentDevicePixelRatio=s,a.height=n,a.width=o,t.ctx.setTransform(s,0,0,s,0,0),!0)}const Me=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}();function ke(t,e){const i=me(t,e),s=i&&i.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function Se(t,e){return"native"in t?{x:t.x,y:t.y}:_e(t,e)}function Pe(t,e,i,s){const{controller:n,data:o,_sorted:a}=t,r=n._cachedMeta.iScale;if(r&&e===r.axis&&a&&o.length){const t=r._reversePixels?ae:oe;if(!s)return t(o,e,i);if(n._sharedOptions){const s=o[0],n="function"==typeof s.getRange&&s.getRange(e);if(n){const s=t(o,e,i-n),a=t(o,e,i+n);return{lo:s.lo,hi:a.hi}}}}return{lo:0,hi:o.length-1}}function De(t,e,i,s,n){const o=t.getSortedVisibleDatasetMetas(),a=i[e];for(let t=0,i=o.length;t{t[r](n[a],s)&&o.push({element:t,datasetIndex:e,index:i}),t.inRange(n.x,n.y,s)&&(l=!0)})),i.intersect&&!l?[]:o}var Te={modes:{index(t,e,i,s){const n=Se(e,t),o=i.axis||"x",a=i.intersect?Ce(t,n,o,s):Oe(t,n,o,!1,s),r=[];return a.length?(t.getSortedVisibleDatasetMetas().forEach((t=>{const e=a[0].index,i=t.data[e];i&&!i.skip&&r.push({element:i,datasetIndex:t.index,index:e})})),r):[]},dataset(t,e,i,s){const n=Se(e,t),o=i.axis||"xy";let a=i.intersect?Ce(t,n,o,s):Oe(t,n,o,!1,s);if(a.length>0){const e=a[0].datasetIndex,i=t.getDatasetMeta(e).data;a=[];for(let t=0;tCe(t,Se(e,t),i.axis||"xy",s),nearest:(t,e,i,s)=>Oe(t,Se(e,t),i.axis||"xy",i.intersect,s),x:(t,e,i,s)=>(i.axis="x",Ae(t,e,i,s)),y:(t,e,i,s)=>(i.axis="y",Ae(t,e,i,s))}};const Le=new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/),Re=new RegExp(/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/);function Ee(t,e){const i=(""+t).match(Le);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}function Ie(t,e){const i={},s=U(e),n=s?Object.keys(e):e,o=U(t)?s?i=>K(t[i],t[e[i]]):e=>t[e]:()=>t;for(const t of n)i[t]=+o(t)||0;return i}function ze(t){return Ie(t,{top:"y",right:"x",bottom:"y",left:"x"})}function Fe(t){return Ie(t,["topLeft","topRight","bottomLeft","bottomRight"])}function Be(t){const e=ze(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function Ve(t,e){t=t||{},e=e||xt.font;let i=K(t.size,e.size);"string"==typeof i&&(i=parseInt(i,10));let s=K(t.style,e.style);s&&!(""+s).match(Re)&&(console.warn('Invalid font style specified: "'+s+'"'),s="");const n={family:K(t.family,e.family),lineHeight:Ee(K(t.lineHeight,e.lineHeight),i),size:i,style:s,weight:K(t.weight,e.weight),string:""};return n.string=$t(n),n}function We(t,e,i,s){let n,o,a,r=!0;for(n=0,o=t.length;ni&&0===t?0:t+e;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function He(t,e){return Object.assign(Object.create(t),e)}const je=["left","top","right","bottom"];function $e(t,e){return t.filter((t=>t.pos===e))}function Ye(t,e){return t.filter((t=>-1===je.indexOf(t.pos)&&t.box.axis===e))}function Ue(t,e){return t.sort(((t,i)=>{const s=e?i:t,n=e?t:i;return s.weight===n.weight?s.index-n.index:s.weight-n.weight}))}function Xe(t,e){const i=function(t){const e={};for(const i of t){const{stack:t,pos:s,stackWeight:n}=i;if(!t||!je.includes(s))continue;const o=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=n}return e}(t),{vBoxMaxWidth:s,hBoxMaxHeight:n}=e;let o,a,r;for(o=0,a=t.length;o{s[t]=Math.max(e[t],i[t])})),s}return s(t?["left","right"]:["top","bottom"])}function Qe(t,e,i,s){const n=[];let o,a,r,l,h,c;for(o=0,a=t.length,h=0;ot.box.fullSize)),!0),s=Ue($e(e,"left"),!0),n=Ue($e(e,"right")),o=Ue($e(e,"top"),!0),a=Ue($e(e,"bottom")),r=Ye(e,"x"),l=Ye(e,"y");return{fullSize:i,leftAndTop:s.concat(o),rightAndBottom:n.concat(l).concat(a).concat(r),chartArea:$e(e,"chartArea"),vertical:s.concat(n).concat(l),horizontal:o.concat(a).concat(r)}}(t.boxes),l=r.vertical,h=r.horizontal;J(t.boxes,(t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()}));const c=l.reduce(((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1),0)||1,d=Object.freeze({outerWidth:e,outerHeight:i,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/c,hBoxMaxHeight:a/2}),u=Object.assign({},n);Ke(u,Be(s));const f=Object.assign({maxPadding:u,w:o,h:a,x:n.left,y:n.top},n),g=Xe(l.concat(h),d);Qe(r.fullSize,f,d,g),Qe(l,f,d,g),Qe(h,f,d,g)&&Qe(l,f,d,g),function(t){const e=t.maxPadding;function i(i){const s=Math.max(e[i]-t[i],0);return t[i]+=s,s}t.y+=i("top"),t.x+=i("left"),i("right"),i("bottom")}(f),ti(r.leftAndTop,f,d,g),f.x+=f.w,f.y+=f.h,ti(r.rightAndBottom,f,d,g),t.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},J(r.chartArea,(e=>{const i=e.box;Object.assign(i,t.chartArea),i.update(f.w,f.h)}))}};function ii(t,e=[""],i=t,s,n=(()=>t[0])){ct(s)||(s=fi("_fallback",t));const o={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:i,_fallback:s,_getTarget:n,override:n=>ii([n,...t],e,i,s)};return new Proxy(o,{deleteProperty:(e,i)=>(delete e[i],delete e._keys,delete t[0][i],!0),get:(i,s)=>ri(i,s,(()=>function(t,e,i,s){let n;for(const o of e)if(n=fi(oi(o,t),i),ct(n))return ai(t,n)?di(i,s,t,n):n}(s,e,t,i))),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>gi(t).includes(e),ownKeys:t=>gi(t),set:(t,e,i)=>((t._storage||(t._storage=n()))[e]=i,delete t[e],delete t._keys,!0)})}function si(t,e,i,s){const n={_cacheable:!1,_proxy:t,_context:e,_subProxy:i,_stack:new Set,_descriptors:ni(t,s),setContext:e=>si(t,e,i,s),override:n=>si(t.override(n),e,i,s)};return new Proxy(n,{deleteProperty:(e,i)=>(delete e[i],delete t[i],!0),get:(t,e,i)=>ri(t,e,(()=>function(t,e,i){const{_proxy:s,_context:n,_subProxy:o,_descriptors:a}=t;let r=s[e];dt(r)&&a.isScriptable(e)&&(r=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_stack:r}=i;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);r.add(t),e=e(o,a||s),r.delete(t),U(e)&&(e=di(n._scopes,n,t,e));return e}(e,r,t,i));Y(r)&&r.length&&(r=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_descriptors:r}=i;if(ct(o.index)&&s(t))e=e[o.index%e.length];else if(U(e[0])){const i=e,s=n._scopes.filter((t=>t!==i));e=[];for(const l of i){const i=di(s,n,t,l);e.push(si(i,o,a&&a[t],r))}}return e}(e,r,t,a.isIndexable));ai(e,r)&&(r=si(r,n,o&&o[e],a));return r}(t,e,i))),getOwnPropertyDescriptor:(e,i)=>e._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,i)=>Reflect.has(t,i),ownKeys:()=>Reflect.ownKeys(t),set:(e,i,s)=>(t[i]=s,delete e[i],!0)})}function ni(t,e={scriptable:!0,indexable:!0}){const{_scriptable:i=e.scriptable,_indexable:s=e.indexable,_allKeys:n=e.allKeys}=t;return{allKeys:n,scriptable:i,indexable:s,isScriptable:dt(i)?i:()=>i,isIndexable:dt(s)?s:()=>s}}const oi=(t,e)=>t?t+ht(e):e,ai=(t,e)=>U(e)&&"adapters"!==t;function ri(t,e,i){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];const s=i();return t[e]=s,s}function li(t,e,i){return dt(t)?t(e,i):t}const hi=(t,e)=>!0===t?e:"string"==typeof t?lt(e,t):void 0;function ci(t,e,i,s){for(const n of e){const e=hi(i,n);if(e){t.add(e);const n=li(e._fallback,i,e);if(ct(n)&&n!==i&&n!==s)return n}else if(!1===e&&ct(s)&&i!==s)return null}return!1}function di(t,e,i,s){const n=e._rootScopes,o=li(e._fallback,i,s),a=[...t,...n],r=new Set;r.add(s);let l=ui(r,a,i,o||i);return null!==l&&((!ct(o)||o===i||(l=ui(r,a,o,l),null!==l))&&ii(Array.from(r),[""],n,o,(()=>function(t,e,i){const s=t._getTarget();e in s||(s[e]={});const n=s[e];if(Y(n)&&U(i))return i;return n}(e,i,s))))}function ui(t,e,i,s){for(;i;)i=ci(t,e,i,s);return i}function fi(t,e){for(const i of e){if(!i)continue;const e=i[t];if(ct(e))return e}}function gi(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const i of t)for(const t of Object.keys(i).filter((t=>!t.startsWith("_"))))e.add(t);return Array.from(e)}(t._scopes)),e}const pi=Number.EPSILON||1e-14,mi=(t,e)=>e"x"===t?"y":"x";function bi(t,e,i,s){const n=t.skip?e:t,o=e,a=i.skip?e:i,r=Bt(o,n),l=Bt(a,o);let h=r/(r+l),c=l/(r+l);h=isNaN(h)?0:h,c=isNaN(c)?0:c;const d=s*h,u=s*c;return{previous:{x:o.x-d*(a.x-n.x),y:o.y-d*(a.y-n.y)},next:{x:o.x+u*(a.x-n.x),y:o.y+u*(a.y-n.y)}}}function _i(t,e="x"){const i=xi(e),s=t.length,n=Array(s).fill(0),o=Array(s);let a,r,l,h=mi(t,0);for(a=0;a!t.skip))),"monotone"===e.cubicInterpolationMode)_i(t,n);else{let i=s?t[t.length-1]:t[0];for(o=0,a=t.length;o0===t||1===t,Mi=(t,e,i)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*_t/i),ki=(t,e,i)=>Math.pow(2,-10*t)*Math.sin((t-e)*_t/i)+1,Si={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*Mt),easeOutSine:t=>Math.sin(t*Mt),easeInOutSine:t=>-.5*(Math.cos(bt*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>wi(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>wi(t)?t:Mi(t,.075,.3),easeOutElastic:t=>wi(t)?t:ki(t,.075,.3),easeInOutElastic(t){const e=.1125;return wi(t)?t:t<.5?.5*Mi(2*t,e,.45):.5+.5*ki(2*t-1,e,.45)},easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-Si.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},easeInOutBounce:t=>t<.5?.5*Si.easeInBounce(2*t):.5*Si.easeOutBounce(2*t-1)+.5};function Pi(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:t.y+i*(e.y-t.y)}}function Di(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:"middle"===s?i<.5?t.y:e.y:"after"===s?i<1?t.y:e.y:i>0?e.y:t.y}}function Ci(t,e,i,s){const n={x:t.cp2x,y:t.cp2y},o={x:e.cp1x,y:e.cp1y},a=Pi(t,n,i),r=Pi(n,o,i),l=Pi(o,e,i),h=Pi(a,r,i),c=Pi(r,l,i);return Pi(h,c,i)}const Oi=new Map;function Ai(t,e,i){return function(t,e){e=e||{};const i=t+JSON.stringify(e);let s=Oi.get(i);return s||(s=new Intl.NumberFormat(t,e),Oi.set(i,s)),s}(e,i).format(t)}function Ti(t,e,i){return t?function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}}(e,i):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function Li(t,e){let i,s;"ltr"!==e&&"rtl"!==e||(i=t.canvas.style,s=[i.getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=s)}function Ri(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Ei(t){return"angle"===t?{between:Nt,compare:Vt,normalize:Wt}:{between:(t,e,i)=>t>=Math.min(e,i)&&t<=Math.max(i,e),compare:(t,e)=>t-e,normalize:t=>t}}function Ii({start:t,end:e,count:i,loop:s,style:n}){return{start:t%i,end:e%i,loop:s&&(e-t+1)%i==0,style:n}}function zi(t,e,i){if(!i)return[t];const{property:s,start:n,end:o}=i,a=e.length,{compare:r,between:l,normalize:h}=Ei(s),{start:c,end:d,loop:u,style:f}=function(t,e,i){const{property:s,start:n,end:o}=i,{between:a,normalize:r}=Ei(s),l=e.length;let h,c,{start:d,end:u,loop:f}=t;if(f){for(d+=l,u+=l,h=0,c=l;hb||l(n,x,p)&&0!==r(n,x),v=()=>!b||0===r(o,p)||l(o,x,p);for(let t=c,i=c;t<=d;++t)m=e[t%a],m.skip||(p=h(m[s]),p!==x&&(b=l(p,n,o),null===_&&y()&&(_=0===r(p,n)?t:i),null!==_&&v()&&(g.push(Ii({start:_,end:t,loop:u,count:a,style:f})),_=null),i=t,x=p));return null!==_&&g.push(Ii({start:_,end:d,loop:u,count:a,style:f})),g}function Fi(t,e){const i=[],s=t.segments;for(let n=0;nn&&t[o%e].skip;)o--;return o%=e,{start:n,end:o}}(i,n,o,s);if(!0===s)return Vi(t,[{start:a,end:r,loop:o}],i,e);return Vi(t,function(t,e,i,s){const n=t.length,o=[];let a,r=e,l=t[e];for(a=e+1;a<=i;++a){const i=t[a%n];i.skip||i.stop?l.skip||(s=!1,o.push({start:e%n,end:(a-1)%n,loop:s}),e=r=i.stop?a:null):(r=a,l.skip&&(e=a)),l=i}return null!==r&&o.push({start:e%n,end:r%n,loop:s}),o}(i,a,rnull===t||""===t;const Xi=!!Me&&{passive:!0};function qi(t,e,i){t.canvas.removeEventListener(e,i,Xi)}function Ki(t,e,i){const s=t.canvas,n=new MutationObserver((t=>{for(const e of t)for(const t of e.addedNodes)if(t===s||t.contains(s))return i()}));return n.observe(document,{childList:!0,subtree:!0}),n}function Gi(t,e,i){const s=t.canvas,n=new MutationObserver((t=>{for(const e of t)for(const t of e.removedNodes)if(t===s||t.contains(s))return i()}));return n.observe(document,{childList:!0,subtree:!0}),n}const Zi=new Map;let Qi=0;function Ji(){const t=window.devicePixelRatio;t!==Qi&&(Qi=t,Zi.forEach(((e,i)=>{i.currentDevicePixelRatio!==t&&e()})))}function ts(t,i,s){const n=t.canvas,o=n&&fe(n);if(!o)return;const a=e(((t,e)=>{const i=o.clientWidth;s(t,e),i{const e=t[0],i=e.contentRect.width,s=e.contentRect.height;0===i&&0===s||a(i,s)}));return r.observe(o),function(t,e){Zi.size||window.addEventListener("resize",Ji),Zi.set(t,e)}(t,a),r}function es(t,e,i){i&&i.disconnect(),"resize"===e&&function(t){Zi.delete(t),Zi.size||window.removeEventListener("resize",Ji)}(t)}function is(t,i,s){const n=t.canvas,o=e((e=>{null!==t.ctx&&s(function(t,e){const i=Yi[t.type]||t.type,{x:s,y:n}=_e(t,e);return{type:i,chart:e,native:t,x:void 0!==s?s:null,y:void 0!==n?n:null}}(e,t))}),t,(t=>{const e=t[0];return[e,e.offsetX,e.offsetY]}));return function(t,e,i){t.addEventListener(e,i,Xi)}(n,i,o),o}class ss extends ji{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(function(t,e){const i=t.style,s=t.getAttribute("height"),n=t.getAttribute("width");if(t.$chartjs={initial:{height:s,width:n,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",Ui(n)){const e=ke(t,"width");void 0!==e&&(t.width=e)}if(Ui(s))if(""===t.style.height)t.height=t.width/(e||2);else{const e=ke(t,"height");void 0!==e&&(t.height=e)}}(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e.$chartjs)return!1;const i=e.$chartjs.initial;["height","width"].forEach((t=>{const s=i[t];$(s)?e.removeAttribute(t):e.setAttribute(t,s)}));const s=i.style||{};return Object.keys(s).forEach((t=>{e.style[t]=s[t]})),e.width=e.width,delete e.$chartjs,!0}addEventListener(t,e,i){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),n={attach:Ki,detach:Gi,resize:ts}[e]||is;s[e]=n(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];if(!s)return;({attach:es,detach:es,resize:es}[e]||qi)(t,e,s),i[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return ve(t,e,i,s)}isAttached(t){const e=fe(t);return!(!e||!e.isConnected)}}function ns(t){return!ue()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?$i:ss}var os=Object.freeze({__proto__:null,_detectPlatform:ns,BasePlatform:ji,BasicPlatform:$i,DomPlatform:ss});const as="transparent",rs={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const s=W(t||as),n=s.valid&&W(e||as);return n&&n.valid?n.mix(s,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class ls{constructor(t,e,i,s){const n=e[i];s=We([t.to,s,n,t.from]);const o=We([t.from,n,s]);this._active=!0,this._fn=t.fn||rs[t.type||typeof o],this._easing=Si[t.easing]||Si.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=o,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const s=this._target[this._prop],n=i-this._start,o=this._duration-n;this._start=i,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=n,this._loop=!!t.loop,this._to=We([t.to,e,s,t.from]),this._from=We([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,s=this._prop,n=this._from,o=this._loop,a=this._to;let r;if(this._active=n!==a&&(o||e1?2-r:r,r=this._easing(Math.min(1,Math.max(0,r))),this._target[s]=this._fn(n,a,r))}wait(){const t=this._promises||(this._promises=[]);return new Promise(((e,i)=>{t.push({res:e,rej:i})}))}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let t=0;t"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),xt.set("animations",{colors:{type:"color",properties:["color","borderColor","backgroundColor"]},numbers:{type:"number",properties:["x","y","borderWidth","radius","tension"]}}),xt.describe("animations",{_fallback:"animation"}),xt.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}});class cs{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!U(t))return;const e=this._properties;Object.getOwnPropertyNames(t).forEach((i=>{const s=t[i];if(!U(s))return;const n={};for(const t of hs)n[t]=s[t];(Y(s.properties)&&s.properties||[i]).forEach((t=>{t!==i&&e.has(t)||e.set(t,n)}))}))}_animateOptions(t,e){const i=e.options,s=function(t,e){if(!e)return;let i=t.options;if(!i)return void(t.options=e);i.$shared&&(t.options=i=Object.assign({},i,{$shared:!1,$animations:{}}));return i}(t,i);if(!s)return[];const n=this._createAnimations(s,i);return i.$shared&&function(t,e){const i=[],s=Object.keys(e);for(let e=0;e{t.options=i}),(()=>{})),n}_createAnimations(t,e){const i=this._properties,s=[],n=t.$animations||(t.$animations={}),o=Object.keys(e),a=Date.now();let r;for(r=o.length-1;r>=0;--r){const l=o[r];if("$"===l.charAt(0))continue;if("options"===l){s.push(...this._animateOptions(t,e));continue}const h=e[l];let c=n[l];const d=i.get(l);if(c){if(d&&c.active()){c.update(d,h,a);continue}c.cancel()}d&&d.duration?(n[l]=c=new ls(d,t,l,h),s.push(c)):t[l]=h}return s}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(a.add(this._chart,i),!0):void 0}}function ds(t,e){const i=t&&t.options||{},s=i.reverse,n=void 0===i.min?e:0,o=void 0===i.max?e:0;return{start:s?o:n,end:s?n:o}}function us(t,e){const i=[],s=t._getSortedDatasetMetas(e);let n,o;for(n=0,o=s.length;n0||!i&&e<0)return n.index}return null}function xs(t,e){const{chart:i,_cachedMeta:s}=t,n=i._stacks||(i._stacks={}),{iScale:o,vScale:a,index:r}=s,l=o.axis,h=a.axis,c=function(t,e,i){return`${t.id}.${e.id}.${i.stack||i.type}`}(o,a,s),d=e.length;let u;for(let t=0;ti[t].axis===e)).shift()}function _s(t,e){const i=t.controller.index,s=t.vScale&&t.vScale.axis;if(s){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[s]||void 0===e[s][i])return;delete e[s][i]}}}const ys=t=>"reset"===t||"none"===t,vs=(t,e)=>e?t:Object.assign({},t);class ws{constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.$context=void 0,this._syncList=[],this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=gs(t.vScale,t),this.addElements()}updateIndex(t){this.index!==t&&_s(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(t,e,i,s)=>"x"===t?e:"r"===t?s:i,n=e.xAxisID=K(i.xAxisID,bs(t,"x")),o=e.yAxisID=K(i.yAxisID,bs(t,"y")),a=e.rAxisID=K(i.rAxisID,bs(t,"r")),r=e.indexAxis,l=e.iAxisID=s(r,n,o,a),h=e.vAxisID=s(r,o,n,a);e.xScale=this.getScaleForId(n),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(l),e.vScale=this.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&ce(this._data,this),t._stacked&&_s(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(U(e))this._data=function(t){const e=Object.keys(t),i=new Array(e.length);let s,n,o;for(s=0,n=e.length;s0&&i._parsed[t-1];if(!1===this._parsing)i._parsed=s,i._sorted=!0,h=s;else{h=Y(s[t])?this.parseArrayData(i,s,t,e):U(s[t])?this.parseObjectData(i,s,t,e):this.parsePrimitiveData(i,s,t,e);const n=()=>null===l[a]||d&&l[a]t&&!e.hidden&&e._stacked&&{keys:us(i,!0),values:null})(e,i,this.chart),l={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:h,max:c}=function(t){const{min:e,max:i,minDefined:s,maxDefined:n}=t.getUserBounds();return{min:s?e:Number.NEGATIVE_INFINITY,max:n?i:Number.POSITIVE_INFINITY}}(a);let d,u;function f(){u=s[d];const e=u[a.axis];return!X(u[t.axis])||h>e||c=0;--d)if(!f()){this.updateRangeFromParsed(l,t,u,r);break}return l}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,n,o;for(s=0,n=e.length;s=0&&tthis.getContext(i,s)),c);return f.$shared&&(f.$shared=r,n[o]=Object.freeze(vs(f,r))),f}_resolveAnimations(t,e,i){const s=this.chart,n=this._cachedDataOpts,o=`animation-${e}`,a=n[o];if(a)return a;let r;if(!1!==s.options.animation){const s=this.chart.config,n=s.datasetAnimationScopeKeys(this._type,e),o=s.getOptionScopes(this.getDataset(),n);r=s.createResolver(o,this.getContext(t,i,e))}const l=new cs(s,r&&r.animations);return r&&r._cacheable&&(n[o]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||ys(t)||this.chart._animationsDisabled}updateElement(t,e,i,s){ys(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!ys(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,s){t.active=s;const n=this.getStyle(e,s);this._resolveAnimations(e,i,s).update(t,{options:!s&&this.getSharedOptions(n)||n})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,i=this._cachedMeta.data;for(const[t,e,i]of this._syncList)this[t](e,i);this._syncList=[];const s=i.length,n=e.length,o=Math.min(n,s);o&&this.parse(0,o),n>s?this._insertElements(s,n-s,t):n{for(t.length+=e,a=t.length-1;a>=o;a--)t[a]=t[a-e]};for(r(n),a=t;a{s[t]=i[t]&&i[t].active()?i[t]._to:this[t]})),s}}Ms.defaults={},Ms.defaultRoutes=void 0;const ks={values:t=>Y(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const s=this.chart.options.locale;let n,o=t;if(i.length>1){const e=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));(e<1e-4||e>1e15)&&(n="scientific"),o=function(t,e){let i=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;Math.abs(i)>=1&&t!==Math.floor(t)&&(i=t-Math.floor(t));return i}(t,i)}const a=Pt(Math.abs(o)),r=Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:n,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),Ai(t,s,l)},logarithmic(t,e,i){if(0===t)return"0";const s=t/Math.pow(10,Math.floor(Pt(t)));return 1===s||2===s||5===s?ks.numeric.call(this,t,e,i):""}};var Ss={formatters:ks};function Ps(t,e){const i=t.options.ticks,s=i.maxTicksLimit||function(t){const e=t.options.offset,i=t._tickSize(),s=t._length/i+(e?0:1),n=t._maxLength/i;return Math.floor(Math.min(s,n))}(t),n=i.major.enabled?function(t){const e=[];let i,s;for(i=0,s=t.length;is)return function(t,e,i,s){let n,o=0,a=i[0];for(s=Math.ceil(s),n=0;nn)return e}return Math.max(n,1)}(n,e,s);if(o>0){let t,i;const s=o>1?Math.round((r-a)/(o-1)):null;for(Ds(e,l,h,$(s)?0:a-s,a),t=0,i=o-1;te.lineWidth,tickColor:(t,e)=>e.color,offset:!1,borderDash:[],borderDashOffset:0,borderWidth:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Ss.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),xt.route("scale.ticks","color","","color"),xt.route("scale.grid","color","","borderColor"),xt.route("scale.grid","borderColor","","borderColor"),xt.route("scale.title","color","","color"),xt.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t}),xt.describe("scales",{_fallback:"scale"}),xt.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t});const Cs=(t,e,i)=>"top"===e||"left"===e?t[e]+i:t[e]-i;function Os(t,e){const i=[],s=t.length/e,n=t.length;let o=0;for(;oa+r)))return h}function Ts(t){return t.drawTicks?t.tickLength:0}function Ls(t,e){if(!t.display)return 0;const i=Ve(t.font,e),s=Be(t.padding);return(Y(t.text)?t.text.length:1)*i.lineHeight+s.height}function Rs(t,e,i){let n=s(t);return(i&&"right"!==e||!i&&"right"===e)&&(n=(t=>"left"===t?"right":"right"===t?"left":t)(n)),n}class Es extends Ms{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:i,_suggestedMax:s}=this;return t=q(t,Number.POSITIVE_INFINITY),e=q(e,Number.NEGATIVE_INFINITY),i=q(i,Number.POSITIVE_INFINITY),s=q(s,Number.NEGATIVE_INFINITY),{min:q(t,i),max:q(e,s),minDefined:X(t),maxDefined:X(e)}}getMinMax(t){let e,{min:i,max:s,minDefined:n,maxDefined:o}=this.getUserBounds();if(n&&o)return{min:i,max:s};const a=this.getMatchingVisibleMetas();for(let r=0,l=a.length;rs?s:i,s=n&&i>s?i:s,{min:q(i,q(s,i)),max:q(s,q(i,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){Q(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:n,ticks:o}=this.options,a=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Ne(this,n,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const r=a=n||i<=1||!this.isHorizontal())return void(this.labelRotation=s);const h=this._getLabelSizes(),c=h.widest.width,d=h.highest.height,u=Ht(this.chart.width-c,0,this.maxWidth);o=t.offset?this.maxWidth/i:u/(i-1),c+6>o&&(o=u/(i-(t.offset?.5:1)),a=this.maxHeight-Ts(t.grid)-e.padding-Ls(t.title,this.chart.options.font),r=Math.sqrt(c*c+d*d),l=It(Math.min(Math.asin(Ht((h.highest.height+6)/o,-1,1)),Math.asin(Ht(a/r,-1,1))-Math.asin(Ht(d/r,-1,1)))),l=Math.max(s,Math.min(n,l))),this.labelRotation=l}afterCalculateLabelRotation(){Q(this.options.afterCalculateLabelRotation,[this])}beforeFit(){Q(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:n}}=this,o=this._isVisible(),a=this.isHorizontal();if(o){const o=Ls(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=Ts(n)+o):(t.height=this.maxHeight,t.width=Ts(n)+o),i.display&&this.ticks.length){const{first:e,last:s,widest:n,highest:o}=this._getLabelSizes(),r=2*i.padding,l=Et(this.labelRotation),h=Math.cos(l),c=Math.sin(l);if(a){const e=i.mirror?0:c*n.width+h*o.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=i.mirror?0:h*n.width+c*o.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,s,c,h)}}this._handleMargins(),a?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,s){const{ticks:{align:n,padding:o},position:a}=this.options,r=0!==this.labelRotation,l="top"!==a&&"x"===this.axis;if(this.isHorizontal()){const a=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1);let c=0,d=0;r?l?(c=s*t.width,d=i*e.height):(c=i*t.height,d=s*e.width):"start"===n?d=e.width:"end"===n?c=t.width:(c=t.width/2,d=e.width/2),this.paddingLeft=Math.max((c-a+o)*this.width/(this.width-a),0),this.paddingRight=Math.max((d-h+o)*this.width/(this.width-h),0)}else{let i=e.height/2,s=t.height/2;"start"===n?(i=0,s=t.height):"end"===n&&(i=e.height,s=0),this.paddingTop=i+o,this.paddingBottom=s+o}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){Q(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,i;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,i=t.length;e{const i=t.gc,s=i.length/2;let n;if(s>e){for(n=0;n({width:n[t]||0,height:o[t]||0});return{first:v(0),last:v(e-1),widest:v(_),highest:v(y),widths:n,heights:o}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return jt(this._alignToPixels?Xt(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&ta*s?a/i:r/s:r*s0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:n,position:o}=s,a=n.offset,r=this.isHorizontal(),l=this.ticks.length+(a?1:0),h=Ts(n),c=[],d=n.setContext(this.getContext()),u=d.drawBorder?d.borderWidth:0,f=u/2,g=function(t){return Xt(i,t,u)};let p,m,x,b,_,y,v,w,M,k,S,P;if("top"===o)p=g(this.bottom),y=this.bottom-h,w=p-f,k=g(t.top)+f,P=t.bottom;else if("bottom"===o)p=g(this.top),k=t.top,P=g(t.bottom)-f,y=p+f,w=this.top+h;else if("left"===o)p=g(this.right),_=this.right-h,v=p-f,M=g(t.left)+f,S=t.right;else if("right"===o)p=g(this.left),M=t.left,S=g(t.right)-f,_=p+f,v=this.left+h;else if("x"===e){if("center"===o)p=g((t.top+t.bottom)/2+.5);else if(U(o)){const t=Object.keys(o)[0],e=o[t];p=g(this.chart.scales[t].getPixelForValue(e))}k=t.top,P=t.bottom,y=p+f,w=y+h}else if("y"===e){if("center"===o)p=g((t.left+t.right)/2);else if(U(o)){const t=Object.keys(o)[0],e=o[t];p=g(this.chart.scales[t].getPixelForValue(e))}_=p-f,v=_-h,M=t.left,S=t.right}const D=K(s.ticks.maxTicksLimit,l),C=Math.max(1,Math.ceil(l/D));for(m=0;me.value===t));if(i>=0){return e.setContext(this.getContext(i)).lineWidth}return 0}drawGrid(t){const e=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let n,o;const a=(t,e,s)=>{s.width&&s.color&&(i.save(),i.lineWidth=s.width,i.strokeStyle=s.color,i.setLineDash(s.borderDash||[]),i.lineDashOffset=s.borderDashOffset,i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke(),i.restore())};if(e.display)for(n=0,o=s.length;n{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:i+1,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let n,o;for(n=0,o=e.length;n{const s=i.split("."),n=s.pop(),o=[t].concat(s).join("."),a=e[i].split("."),r=a.pop(),l=a.join(".");xt.route(o,n,l,r)}))}(e,t.defaultRoutes);t.descriptors&&xt.describe(e,t.descriptors)}(t,o,i),this.override&&xt.override(t.id,t.overrides)),o}get(t){return this.items[t]}unregister(t){const e=this.items,i=t.id,s=this.scope;i in e&&delete e[i],s&&i in xt[s]&&(delete xt[s][i],this.override&&delete ft[i])}}var zs=new class{constructor(){this.controllers=new Is(ws,"datasets",!0),this.elements=new Is(Ms,"elements"),this.plugins=new Is(Object,"plugins"),this.scales=new Is(Es,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){[...e].forEach((e=>{const s=i||this._getRegistryForType(e);i||s.isForType(e)||s===this.plugins&&e.id?this._exec(t,s,e):J(e,(e=>{const s=i||this._getRegistryForType(e);this._exec(t,s,e)}))}))}_exec(t,e,i){const s=ht(t);Q(i["before"+s],[],i),e[t](i),Q(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;et.filter((t=>!e.some((e=>t.plugin.id===e.plugin.id))));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function Bs(t,e){return e||!1!==t?!0===t?{}:t:null}function Vs(t,e,i,s){const n=t.pluginScopeKeys(e),o=t.getOptionScopes(i,n);return t.createResolver(o,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Ws(t,e){const i=xt.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function Ns(t,e){return"x"===t||"y"===t?t:e.axis||("top"===(i=e.position)||"bottom"===i?"x":"left"===i||"right"===i?"y":void 0)||t.charAt(0).toLowerCase();var i}function Hs(t){const e=t.options||(t.options={});e.plugins=K(e.plugins,{}),e.scales=function(t,e){const i=ft[t.type]||{scales:{}},s=e.scales||{},n=Ws(t.type,e),o=Object.create(null),a=Object.create(null);return Object.keys(s).forEach((t=>{const e=s[t];if(!U(e))return console.error(`Invalid scale configuration for scale: ${t}`);if(e._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);const r=Ns(t,e),l=function(t,e){return t===e?"_index_":"_value_"}(r,n),h=i.scales||{};o[r]=o[r]||t,a[t]=ot(Object.create(null),[{axis:r},e,h[r],h[l]])})),t.data.datasets.forEach((i=>{const n=i.type||t.type,r=i.indexAxis||Ws(n,e),l=(ft[n]||{}).scales||{};Object.keys(l).forEach((t=>{const e=function(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}(t,r),n=i[e+"AxisID"]||o[e]||e;a[n]=a[n]||Object.create(null),ot(a[n],[{axis:e},s[n],l[t]])}))})),Object.keys(a).forEach((t=>{const e=a[t];ot(e,[xt.scales[e.type],xt.scale])})),a}(t,e)}function js(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const $s=new Map,Ys=new Set;function Us(t,e){let i=$s.get(t);return i||(i=e(),$s.set(t,i),Ys.add(i)),i}const Xs=(t,e,i)=>{const s=lt(e,i);void 0!==s&&t.add(s)};class qs{constructor(t){this._config=function(t){return(t=t||{}).data=js(t.data),Hs(t),t}(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=js(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Hs(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Us(t,(()=>[[`datasets.${t}`,""]]))}datasetAnimationScopeKeys(t,e){return Us(`${t}.transition.${e}`,(()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]]))}datasetElementScopeKeys(t,e){return Us(`${t}-${e}`,(()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]]))}pluginScopeKeys(t){const e=t.id;return Us(`${this.type}-plugin-${e}`,(()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]]))}_cachedScopes(t,e){const i=this._scopeCache;let s=i.get(t);return s&&!e||(s=new Map,i.set(t,s)),s}getOptionScopes(t,e,i){const{options:s,type:n}=this,o=this._cachedScopes(t,i),a=o.get(e);if(a)return a;const r=new Set;e.forEach((e=>{t&&(r.add(t),e.forEach((e=>Xs(r,t,e)))),e.forEach((t=>Xs(r,s,t))),e.forEach((t=>Xs(r,ft[n]||{},t))),e.forEach((t=>Xs(r,xt,t))),e.forEach((t=>Xs(r,gt,t)))}));const l=Array.from(r);return 0===l.length&&l.push(Object.create(null)),Ys.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,ft[e]||{},xt.datasets[e]||{},{type:e},xt,gt]}resolveNamedOptions(t,e,i,s=[""]){const n={$shared:!0},{resolver:o,subPrefixes:a}=Ks(this._resolverCache,t,s);let r=o;if(function(t,e){const{isScriptable:i,isIndexable:s}=ni(t);for(const n of e){const e=i(n),o=s(n),a=(o||e)&&t[n];if(e&&(dt(a)||Gs(a))||o&&Y(a))return!0}return!1}(o,e)){n.$shared=!1;r=si(o,i=dt(i)?i():i,this.createResolver(t,i,a))}for(const t of e)n[t]=r[t];return n}createResolver(t,e,i=[""],s){const{resolver:n}=Ks(this._resolverCache,t,i);return U(e)?si(n,e,void 0,s):n}}function Ks(t,e,i){let s=t.get(e);s||(s=new Map,t.set(e,s));const n=i.join();let o=s.get(n);if(!o){o={resolver:ii(e,i),subPrefixes:i.filter((t=>!t.toLowerCase().includes("hover")))},s.set(n,o)}return o}const Gs=t=>U(t)&&Object.getOwnPropertyNames(t).reduce(((e,i)=>e||dt(t[i])),!1);const Zs=["top","bottom","left","right","chartArea"];function Qs(t,e){return"top"===t||"bottom"===t||-1===Zs.indexOf(t)&&"x"===e}function Js(t,e){return function(i,s){return i[t]===s[t]?i[e]-s[e]:i[t]-s[t]}}function tn(t){const e=t.chart,i=e.options.animation;e.notifyPlugins("afterRender"),Q(i&&i.onComplete,[t],e)}function en(t){const e=t.chart,i=e.options.animation;Q(i&&i.onProgress,[t],e)}function sn(t){return ue()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const nn={},on=t=>{const e=sn(t);return Object.values(nn).filter((t=>t.canvas===e)).pop()};class an{constructor(t,e){const s=this.config=new qs(e),n=sn(t),o=on(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas can be reused.");const r=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||ns(n)),this.platform.updateConfig(s);const l=this.platform.acquireContext(n,r.aspectRatio),h=l&&l.canvas,c=h&&h.height,d=h&&h.width;this.id=j(),this.ctx=l,this.canvas=h,this.width=d,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Fs,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=i((t=>this.update(t)),r.resizeDelay||0),nn[this.id]=this,l&&h?(a.listen(this,"complete",tn),a.listen(this,"progress",en),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:s,_aspectRatio:n}=this;return $(t)?e&&n?n:s?i/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():we(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return qt(this.canvas,this.ctx),this}stop(){return a.stop(this),this}resize(t,e){a.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,s=this.canvas,n=i.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(s,t,e,n),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,we(this,a,!0)&&(this.notifyPlugins("resize",{size:o}),Q(i.onResize,[this,o],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){J(this.options.scales||{},((t,e)=>{t.id=e}))}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce(((t,e)=>(t[e]=!1,t)),{});let n=[];e&&(n=n.concat(Object.keys(e).map((t=>{const i=e[t],s=Ns(t,i),n="r"===s,o="x"===s;return{options:i,dposition:n?"chartArea":o?"bottom":"left",dtype:n?"radialLinear":o?"category":"linear"}})))),J(n,(e=>{const n=e.options,o=n.id,a=Ns(o,n),r=K(n.type,e.dtype);void 0!==n.position&&Qs(n.position,a)===Qs(e.dposition)||(n.position=e.dposition),s[o]=!0;let l=null;if(o in i&&i[o].type===r)l=i[o];else{l=new(zs.getScale(r))({id:o,type:r,ctx:this.ctx,chart:this}),i[l.id]=l}l.init(n,t)})),J(s,((t,e)=>{t||delete i[e]})),J(i,(t=>{ei.configure(this,t,t.options),ei.addBox(this,t)}))}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort(((t,e)=>t.index-e.index)),i>e){for(let t=e;te.length&&delete this._stacks,t.forEach(((t,i)=>{0===e.filter((e=>e===t._dataset)).length&&this._destroyDatasetMeta(i)}))}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=e.length;i{this.getDatasetMeta(e).controller.reset()}),this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext());J(this.scales,(t=>{ei.removeBox(this,t)}));const s=this._animationsDisabled=!i.animation;this.ensureScalesHaveIDs(),this.buildOrUpdateScales();const n=new Set(Object.keys(this._listeners)),o=new Set(i.events);if(ut(n,o)&&!!this._responsiveListeners===i.responsive||(this.unbindEvents(),this.bindEvents()),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const a=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let t=0,e=this.data.datasets.length;t{t.reset()})),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Js("z","_idx")),this._lastEvent&&this._eventHandler(this._lastEvent,!0),this.render()}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;ei.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],J(this.boxes,(t=>{i&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))}),this),this._layers.forEach(((t,e)=>{t._idx=e})),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let e=0,i=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,s=!i.disabled,n=this.chartArea,o={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",o)&&(s&&Zt(e,{left:!1===i.left?0:n.left-i.left,right:!1===i.right?this.width:n.right+i.right,top:!1===i.top?0:n.top-i.top,bottom:!1===i.bottom?this.height:n.bottom+i.bottom}),t.controller.draw(),s&&Qt(e),o.cancelable=!1,this.notifyPlugins("afterDatasetDraw",o))}getElementsAtEventForMode(t,e,i,s){const n=Te.modes[e];return"function"==typeof n?n(this,t,i,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let s=i.filter((t=>t&&t._dataset===e)).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=He(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",n=this.getDatasetMeta(t),o=n.controller._resolveAnimations(void 0,s);ct(e)?(n.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),o.update(n,{visible:i}),this.update((e=>e.datasetIndex===t?s:void 0)))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),a.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,i,s),t[i]=s},s=(t,e,i)=>{t.offsetX=e,t.offsetY=i,this._eventHandler(t)};J(this.options.events,(t=>i(t,s)))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(i,s)=>{e.addEventListener(this,i,s),t[i]=s},s=(i,s)=>{t[i]&&(e.removeEventListener(this,i,s),delete t[i])},n=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",n),i("detach",o)};o=()=>{this.attached=!1,s("resize",n),this._stop(),this._resize(0,0),i("attach",a)},e.isAttached(this.canvas)?a():o()}unbindEvents(){J(this._listeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._listeners={},J(this._responsiveListeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const s=i?"set":"remove";let n,o,a,r;for("dataset"===e&&(n=this.getDatasetMeta(t[0].datasetIndex),n.controller["_"+s+"DatasetHoverStyle"]()),a=0,r=t.length;a{const i=this.getDatasetMeta(t);if(!i)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:i.data[e],index:e}}));!tt(i,e)&&(this._active=i,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}_updateHoverStyles(t,e,i){const s=this.options.hover,n=(t,e)=>t.filter((t=>!e.some((e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)))),o=n(e,t),a=i?t:n(t,e);o.length&&this.updateHoverStyle(o,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0},s=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",i,s))return;const n=this._handleEvent(t,e);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(n||i.changed)&&this.render(),this}_handleEvent(t,e){const{_active:i=[],options:s}=this,n=s.hover,o=e;let a=[],r=!1,l=null;return"mouseout"!==t.type&&(a=this.getElementsAtEventForMode(t,n.mode,n,o),l="click"===t.type?this._lastEvent:t),this._lastEvent=null,Gt(t,this.chartArea,this._minPadding)&&(Q(s.onHover,[t,a,this],this),"mouseup"!==t.type&&"click"!==t.type&&"contextmenu"!==t.type||Q(s.onClick,[t,a,this],this)),r=!tt(a,i),(r||e)&&(this._active=a,this._updateHoverStyles(a,i,e)),this._lastEvent=l,r}}const rn=()=>J(an.instances,(t=>t._plugins.invalidate())),ln=!0;function hn(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}Object.defineProperties(an,{defaults:{enumerable:ln,value:xt},instances:{enumerable:ln,value:nn},overrides:{enumerable:ln,value:ft},registry:{enumerable:ln,value:zs},version:{enumerable:ln,value:"3.6.0"},getChart:{enumerable:ln,value:on},register:{enumerable:ln,value:(...t)=>{zs.add(...t),rn()}},unregister:{enumerable:ln,value:(...t)=>{zs.remove(...t),rn()}}});class cn{constructor(t){this.options=t||{}}formats(){return hn()}parse(t,e){return hn()}format(t,e){return hn()}add(t,e,i){return hn()}diff(t,e,i){return hn()}startOf(t,e,i){return hn()}endOf(t,e){return hn()}}cn.override=function(t){Object.assign(cn.prototype,t)};var dn={_date:cn};function un(t){const e=t.iScale,i=function(t,e){if(!t._cache.$bar){const i=t.getMatchingVisibleMetas(e);let s=[];for(let e=0,n=i.length;et-e)))}return t._cache.$bar}(e,t.type);let s,n,o,a,r=e._length;const l=()=>{32767!==o&&-32768!==o&&(ct(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(s=0,n=i.length;sMath.abs(r)&&(l=r,h=a),e[i.axis]=h,e._custom={barStart:l,barEnd:h,start:n,end:o,min:a,max:r}}(t,e,i,s):e[i.axis]=i.parse(t,s),e}function gn(t,e,i,s){const n=t.iScale,o=t.vScale,a=n.getLabels(),r=n===o,l=[];let h,c,d,u;for(h=i,c=i+s;ht.x,i="left",s="right"):(e=t.base=i?1:-1)}(c,e,o)*n,d===o&&(p-=c/2),h=p+c),p===e.getPixelForValue(o)){const t=Dt(c)*e.getLineWidthForValue(o)/2;p+=t,c-=t}return{size:c,base:p,head:h,center:h+c/2}}_calculateBarIndexPixels(t,e){const i=e.scale,s=this.options,n=s.skipNull,o=K(s.maxBarThickness,1/0);let a,r;if(e.grouped){const i=n?this._getStackCount(t):e.stackCount,l="flex"===s.barThickness?function(t,e,i,s){const n=e.pixels,o=n[t];let a=t>0?n[t-1]:null,r=t=0;--i)e=Math.max(e,t[i].size(this.resolveDataElementOptions(i))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,{xScale:i,yScale:s}=e,n=this.getParsed(t),o=i.getLabelForValue(n.x),a=s.getLabelForValue(n.y),r=n._custom;return{label:e.label,value:"("+o+", "+a+(r?", "+r:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a}=this._cachedMeta,r=this.resolveDataElementOptions(e,s),l=this.getSharedOptions(r),h=this.includeOptions(s,l),c=o.axis,d=a.axis;for(let r=e;r""}}}};class wn extends ws{constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,s=this._cachedMeta;if(!1===this._parsing)s._parsed=i;else{let n,o,a=t=>+i[t];if(U(i[t])){const{key:t="value"}=this._parsing;a=e=>+lt(i[e],t)}for(n=t,o=t+e;nNt(t,r,l,!0)?1:Math.max(e,e*i,s,s*i),g=(t,e,s)=>Nt(t,r,l,!0)?-1:Math.min(e,e*i,s,s*i),p=f(0,h,d),m=f(Mt,c,u),x=g(bt,h,d),b=g(bt+Mt,c,u);s=(p-x)/2,n=(m-b)/2,o=-(p+x)/2,a=-(m+b)/2}return{ratioX:s,ratioY:n,offsetX:o,offsetY:a}}(c,h,r),p=(i.width-o)/d,m=(i.height-o)/u,x=Math.max(Math.min(p,m)/2,0),b=Z(this.options.radius,x),_=(b-Math.max(b*r,0))/this._getVisibleDatasetWeightTotal();this.offsetX=f*b,this.offsetY=g*b,s.total=this.calculateTotal(),this.outerRadius=b-_*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-_*l,0),this.updateElements(n,0,n.length,t)}_circumference(t,e){const i=this.options,s=this._cachedMeta,n=this._getCircumference();return e&&i.animation.animateRotate||!this.chart.getDataVisibility(t)||null===s._parsed[t]||s.data[t].hidden?0:this.calculateCircumference(s._parsed[t]*n/_t)}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.chartArea,r=o.options.animation,l=(a.left+a.right)/2,h=(a.top+a.bottom)/2,c=n&&r.animateScale,d=c?0:this.innerRadius,u=c?0:this.outerRadius,f=this.resolveDataElementOptions(e,s),g=this.getSharedOptions(f),p=this.includeOptions(s,g);let m,x=this._getRotation();for(m=0;m0&&!isNaN(t)?_t*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=Ai(e._parsed[t],i.options.locale);return{label:s[t]||"",value:n}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,n,o,a,r;if(!t)for(s=0,n=i.data.datasets.length;s"spacing"!==t,_indexable:t=>"spacing"!==t},wn.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map(((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label(t){let e=t.label;const i=": "+t.formattedValue;return Y(e)?(e=e.slice(),e[0]+=i):e+=i,e}}}}};class Mn extends ws{initialize(){this.enableOptionSharing=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:i,data:s=[],_dataset:n}=e,o=this.chart._animationsDisabled;let{start:a,count:r}=function(t,e,i){const s=e.length;let n=0,o=s;if(t._sorted){const{iScale:a,_parsed:r}=t,l=a.axis,{min:h,max:c,minDefined:d,maxDefined:u}=a.getUserBounds();d&&(n=Ht(Math.min(oe(r,a.axis,h).lo,i?s:oe(e,l,a.getPixelForValue(h)).lo),0,s-1)),o=u?Ht(Math.max(oe(r,a.axis,c).hi+1,i?0:oe(e,l,a.getPixelForValue(c)).hi+1),n,s)-n:s-n}return{start:n,count:o}}(e,s,o);this._drawStart=a,this._drawCount=r,function(t){const{xScale:e,yScale:i,_scaleRanges:s}=t,n={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!s)return t._scaleRanges=n,!0;const o=s.xmin!==e.min||s.xmax!==e.max||s.ymin!==i.min||s.ymax!==i.max;return Object.assign(s,n),o}(e)&&(a=0,r=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!n._decimated,i.points=s;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(i,void 0,{animated:!o,options:l},t),this.updateElements(s,a,r,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,h=this.resolveDataElementOptions(e,s),c=this.getSharedOptions(h),d=this.includeOptions(s,c),u=o.axis,f=a.axis,{spanGaps:g,segment:p}=this.options,m=At(g)?g:Number.POSITIVE_INFINITY,x=this.chart._animationsDisabled||n||"none"===s;let b=e>0&&this.getParsed(e-1);for(let h=e;h0&&i[u]-b[u]>m,p&&(g.parsed=i,g.raw=l.data[h]),d&&(g.options=c||this.resolveDataElementOptions(h,e.active?"active":s)),x||this.updateElement(e,h,g,s),b=i}this.updateSharedOptions(c,s,h)}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,n,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}Mn.id="line",Mn.defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1},Mn.overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};class kn extends ws{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=Ai(e._parsed[t].r,i.options.locale);return{label:s[t]||"",value:n}}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),n=Math.max(s/2,0),o=(n-Math.max(i.cutoutPercentage?n/100*i.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=n-o*this.index,this.innerRadius=this.outerRadius-o}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=this.getDataset(),r=o.options.animation,l=this._cachedMeta.rScale,h=l.xCenter,c=l.yCenter,d=l.getIndexAngle(0)-.5*bt;let u,f=d;const g=360/this.countVisibleElements();for(u=0;u{!isNaN(t.data[s])&&this.chart.getDataVisibility(s)&&i++})),i}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?Et(this.resolveDataElementOptions(t,e).angle||i):0}}kn.id="polarArea",kn.defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0},kn.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map(((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label:t=>t.chart.data.labels[t.dataIndex]+": "+t.formattedValue}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};class Sn extends wn{}Sn.id="pie",Sn.defaults={cutout:0,rotation:0,circumference:360,radius:"100%"};class Pn extends ws{getLabelAndValue(t){const e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}update(t){const e=this._cachedMeta,i=e.dataset,s=e.data||[],n=e.iScale.getLabels();if(i.points=s,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:!0,_fullLoop:n.length===s.length,options:e};this.updateElement(i,void 0,o,t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,i,s){const n=this.getDataset(),o=this._cachedMeta.rScale,a="reset"===s;for(let r=e;r"",label:t=>"("+t.label+", "+t.formattedValue+")"}}},scales:{x:{type:"linear"},y:{type:"linear"}}};var Cn=Object.freeze({__proto__:null,BarController:yn,BubbleController:vn,DoughnutController:wn,LineController:Mn,PolarAreaController:kn,PieController:Sn,RadarController:Pn,ScatterController:Dn});function On(t,e,i){const{startAngle:s,pixelMargin:n,x:o,y:a,outerRadius:r,innerRadius:l}=e;let h=n/r;t.beginPath(),t.arc(o,a,r,s-h,i+h),l>n?(h=n/l,t.arc(o,a,l,i+h,s-h,!0)):t.arc(o,a,n,i+Mt,s-Mt),t.closePath(),t.clip()}function An(t,e,i,s){const n=Ie(t.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]);const o=(i-e)/2,a=Math.min(o,s*e/2),r=t=>{const e=(i-Math.min(o,t))*s/2;return Ht(t,0,Math.min(o,e))};return{outerStart:r(n.outerStart),outerEnd:r(n.outerEnd),innerStart:Ht(n.innerStart,0,a),innerEnd:Ht(n.innerEnd,0,a)}}function Tn(t,e,i,s){return{x:i+t*Math.cos(e),y:s+t*Math.sin(e)}}function Ln(t,e,i,s,n){const{x:o,y:a,startAngle:r,pixelMargin:l,innerRadius:h}=e,c=Math.max(e.outerRadius+s+i-l,0),d=h>0?h+s+i+l:0;let u=0;const f=n-r;if(s){const t=((h>0?h-s:0)+(c>0?c-s:0))/2;u=(f-(0!==t?f*t/(t+s):f))/2}const g=(f-Math.max(.001,f*c-i/bt)/c)/2,p=r+g+u,m=n-g-u,{outerStart:x,outerEnd:b,innerStart:_,innerEnd:y}=An(e,d,c,m-p),v=c-x,w=c-b,M=p+x/v,k=m-b/w,S=d+_,P=d+y,D=p+_/S,C=m-y/P;if(t.beginPath(),t.arc(o,a,c,M,k),b>0){const e=Tn(w,k,o,a);t.arc(e.x,e.y,b,k,m+Mt)}const O=Tn(P,m,o,a);if(t.lineTo(O.x,O.y),y>0){const e=Tn(P,C,o,a);t.arc(e.x,e.y,y,m+Mt,C+Math.PI)}if(t.arc(o,a,d,m-y/d,p+_/d,!0),_>0){const e=Tn(S,D,o,a);t.arc(e.x,e.y,_,D+Math.PI,p-Mt)}const A=Tn(v,p,o,a);if(t.lineTo(A.x,A.y),x>0){const e=Tn(v,M,o,a);t.arc(e.x,e.y,x,p-Mt,M)}t.closePath()}function Rn(t,e,i,s,n){const{options:o}=e,a="inner"===o.borderAlign;o.borderWidth&&(a?(t.lineWidth=2*o.borderWidth,t.lineJoin="round"):(t.lineWidth=o.borderWidth,t.lineJoin="bevel"),e.fullCircles&&function(t,e,i){const{x:s,y:n,startAngle:o,pixelMargin:a,fullCircles:r}=e,l=Math.max(e.outerRadius-a,0),h=e.innerRadius+a;let c;for(i&&On(t,e,o+_t),t.beginPath(),t.arc(s,n,h,o+_t,o,!0),c=0;c=_t||Nt(n,a,r))&&(o>=l+d&&o<=h+d)}getCenterPoint(t){const{x:e,y:i,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius","circumference"],t),{offset:r,spacing:l}=this.options,h=(s+n)/2,c=(o+a+l+r)/2;return{x:e+Math.cos(h)*c,y:i+Math.sin(h)*c}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:i}=this,s=(e.offset||0)/2,n=(e.spacing||0)/2;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=i>_t?Math.floor(i/_t):0,0===i||this.innerRadius<0||this.outerRadius<0)return;t.save();let o=0;if(s){o=s/2;const e=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(e)*o,Math.sin(e)*o),this.circumference>=bt&&(o=s)}t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor;const a=function(t,e,i,s){const{fullCircles:n,startAngle:o,circumference:a}=e;let r=e.endAngle;if(n){Ln(t,e,i,s,o+_t);for(let e=0;er&&o>r;return{count:s,start:l,loop:e.loop,ilen:h(a+(h?r-t:t))%o,_=()=>{f!==g&&(t.lineTo(m,g),t.lineTo(m,f),t.lineTo(m,p))};for(l&&(d=n[b(0)],t.moveTo(d.x,d.y)),c=0;c<=r;++c){if(d=n[b(c)],d.skip)continue;const e=d.x,i=d.y,s=0|e;s===u?(ig&&(g=i),m=(x*m+e)/++x):(_(),t.lineTo(e,i),u=s,x=0,f=g=i),p=i}_()}function Wn(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||i)?Vn:Bn}En.id="arc",En.defaults={borderAlign:"center",borderColor:"#fff",borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0},En.defaultRoutes={backgroundColor:"backgroundColor"};const Nn="function"==typeof Path2D;function Hn(t,e,i,s){Nn&&!e.options.segment?function(t,e,i,s){let n=e._path;n||(n=e._path=new Path2D,e.path(n,i,s)&&n.closePath()),In(t,e.options),t.stroke(n)}(t,e,i,s):function(t,e,i,s){const{segments:n,options:o}=e,a=Wn(e);for(const r of n)In(t,o,r.style),t.beginPath(),a(t,e,r,{start:i,end:i+s-1})&&t.closePath(),t.stroke()}(t,e,i,s)}class jn extends Ms{constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const i=this.options;if((i.tension||"monotone"===i.cubicInterpolationMode)&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;vi(this._points,i,t,s,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Bi(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],n=this.points,o=Fi(this,{property:e,start:s,end:s});if(!o.length)return;const a=[],r=function(t){return t.stepped?Di:t.tension||"monotone"===t.cubicInterpolationMode?Ci:Pi}(i);let l,h;for(l=0,h=o.length;l"borderDash"!==t&&"fill"!==t};class Yn extends Ms{constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,e,i){const s=this.options,{x:n,y:o}=this.getProps(["x","y"],i);return Math.pow(t-n,2)+Math.pow(e-o,2)=a.left&&e<=a.right)&&(o||i>=a.top&&i<=a.bottom)}function Gn(t,e){t.rect(e.x,e.y,e.w,e.h)}function Zn(t,e,i={}){const s=t.x!==i.x?-e:0,n=t.y!==i.y?-e:0,o=(t.x+t.w!==i.x+i.w?e:0)-s,a=(t.y+t.h!==i.y+i.h?e:0)-n;return{x:t.x+s,y:t.y+n,w:t.w+o,h:t.h+a,radius:t.radius}}Yn.id="point",Yn.defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0},Yn.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};class Qn extends Ms{constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:e,options:{borderColor:i,backgroundColor:s}}=this,{inner:n,outer:o}=qn(this),a=(r=o.radius).topLeft||r.topRight||r.bottomLeft||r.bottomRight?se:Gn;var r;t.save(),o.w===n.w&&o.h===n.h||(t.beginPath(),a(t,Zn(o,e,n)),t.clip(),a(t,Zn(n,-e,o)),t.fillStyle=i,t.fill("evenodd")),t.beginPath(),a(t,Zn(n,e)),t.fillStyle=s,t.fill(),t.restore()}inRange(t,e,i){return Kn(this,t,e,i)}inXRange(t,e){return Kn(this,t,null,e)}inYRange(t,e){return Kn(this,null,t,e)}getCenterPoint(t){const{x:e,y:i,base:s,horizontal:n}=this.getProps(["x","y","base","horizontal"],t);return{x:n?(e+s)/2:e,y:n?i:(i+s)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}}Qn.id="bar",Qn.defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0},Qn.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};var Jn=Object.freeze({__proto__:null,ArcElement:En,LineElement:jn,PointElement:Yn,BarElement:Qn});function to(t){if(t._decimated){const e=t._data;delete t._decimated,delete t._data,Object.defineProperty(t,"data",{value:e})}}function eo(t){t.data.datasets.forEach((t=>{to(t)}))}var io={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,i)=>{if(!i.enabled)return void eo(t);const s=t.width;t.data.datasets.forEach(((e,n)=>{const{_data:o,indexAxis:a}=e,r=t.getDatasetMeta(n),l=o||e.data;if("y"===We([a,t.options.indexAxis]))return;if("line"!==r.type)return;const h=t.scales[r.xAxisID];if("linear"!==h.type&&"time"!==h.type)return;if(t.options.parsing)return;let{start:c,count:d}=function(t,e){const i=e.length;let s,n=0;const{iScale:o}=t,{min:a,max:r,minDefined:l,maxDefined:h}=o.getUserBounds();return l&&(n=Ht(oe(e,o.axis,a).lo,0,i-1)),s=h?Ht(oe(e,o.axis,r).hi+1,n,i)-n:i-n,{start:n,count:s}}(r,l);if(d<=(i.threshold||4*s))return void to(e);let u;switch($(o)&&(e._data=l,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),i.algorithm){case"lttb":u=function(t,e,i,s,n){const o=n.samples||s;if(o>=i)return t.slice(e,e+i);const a=[],r=(i-2)/(o-2);let l=0;const h=e+i-1;let c,d,u,f,g,p=e;for(a[l++]=t[p],c=0;cu&&(u=f,d=t[s],g=s);a[l++]=d,p=g}return a[l++]=t[h],a}(l,c,d,s,i);break;case"min-max":u=function(t,e,i,s){let n,o,a,r,l,h,c,d,u,f,g=0,p=0;const m=[],x=e+i-1,b=t[e].x,_=t[x].x-b;for(n=e;nf&&(f=r,c=n),g=(p*g+o.x)/++p;else{const i=n-1;if(!$(h)&&!$(c)){const e=Math.min(h,c),s=Math.max(h,c);e!==d&&e!==i&&m.push({...t[e],x:g}),s!==d&&s!==i&&m.push({...t[s],x:g})}n>0&&i!==d&&m.push(t[i]),m.push(o),l=e,p=0,u=f=r,h=c=d=n}}return m}(l,c,d,s);break;default:throw new Error(`Unsupported decimation algorithm '${i.algorithm}'`)}e._decimated=u}))},destroy(t){eo(t)}};function so(t,e,i){const s=function(t){const e=t.options,i=e.fill;let s=K(i&&i.target,i);return void 0===s&&(s=!!e.backgroundColor),!1!==s&&null!==s&&(!0===s?"origin":s)}(t);if(U(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return X(n)&&Math.floor(n)===n?("-"!==s[0]&&"+"!==s[0]||(n=e+n),!(n===e||n<0||n>=i)&&n):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}class no{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){const{x:s,y:n,radius:o}=this;return e=e||{start:0,end:_t},t.arc(s,n,o,e.end,e.start,!0),!i.bounds}interpolate(t){const{x:e,y:i,radius:s}=this,n=t.angle;return{x:e+Math.cos(n)*s,y:i+Math.sin(n)*s,angle:n}}}function oo(t){return(t.scale||{}).getPointPositionForValue?function(t){const{scale:e,fill:i}=t,s=e.options,n=e.getLabels().length,o=[],a=s.reverse?e.max:e.min,r=s.reverse?e.min:e.max;let l,h,c;if(c="start"===i?a:"end"===i?r:U(i)?i.value:e.getBaseValue(),s.grid.circular)return h=e.getPointPositionForValue(0,a),new no({x:h.x,y:h.y,radius:e.getDistanceFromCenterForValue(c)});for(l=0;lt;e--){const t=i[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function ro(t,e,i){const s=[];for(let n=0;n=s&&n<=h){r=n===s,l=n===h;break}}return{first:r,last:l,point:s}}function ho(t){const{chart:e,fill:i,line:s}=t;if(X(i))return function(t,e){const i=t.getDatasetMeta(e);return i&&t.isDatasetVisible(e)?i.dataset:null}(e,i);if("stack"===i)return function(t){const{scale:e,index:i,line:s}=t,n=[],o=s.segments,a=s.points,r=function(t,e){const i=[],s=t.getMatchingVisibleMetas("line");for(let t=0;t{e=ao(t,e,n);const a=n[t],r=n[e];null!==s?(o.push({x:a.x,y:s}),o.push({x:r.x,y:s})):null!==i&&(o.push({x:i,y:a.y}),o.push({x:i,y:r.y}))})),o}(t,e),i.length?new jn({points:i,options:{tension:0},_loop:s,_fullLoop:s}):null}function uo(t,e,i){let s=t[e].fill;const n=[e];let o;if(!i)return s;for(;!1!==s&&-1===n.indexOf(s);){if(!X(s))return s;if(o=t[s],!o)return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function fo(t,e,i){t.beginPath(),e.path(t),t.lineTo(e.last().x,i),t.lineTo(e.first().x,i),t.closePath(),t.clip()}function go(t,e,i,s){if(s)return;let n=e[t],o=i[t];return"angle"===t&&(n=Wt(n),o=Wt(o)),{property:t,start:n,end:o}}function po(t,e,i,s){return t&&e?s(t[i],e[i]):t?t[i]:e?e[i]:0}function mo(t,e,i){const{top:s,bottom:n}=e.chart.chartArea,{property:o,start:a,end:r}=i||{};"x"===o&&(t.beginPath(),t.rect(a,s,r-a,n-s),t.clip())}function xo(t,e,i,s){const n=e.interpolate(i,s);n&&t.lineTo(n.x,n.y)}function bo(t,e){const{line:i,target:s,property:n,color:o,scale:a}=e,r=function(t,e,i){const s=t.segments,n=t.points,o=e.points,a=[];for(const t of s){let{start:s,end:r}=t;r=ao(s,r,n);const l=go(i,n[s],n[r],t.loop);if(!e.segments){a.push({source:t,target:l,start:n[s],end:n[r]});continue}const h=Fi(e,l);for(const e of h){const s=go(i,o[e.start],o[e.end],e.loop),r=zi(t,n,s);for(const t of r)a.push({source:t,target:e,start:{[i]:po(l,s,"start",Math.max)},end:{[i]:po(l,s,"end",Math.min)}})}}return a}(i,s,n);for(const{source:e,target:l,start:h,end:c}of r){const{style:{backgroundColor:r=o}={}}=e,d=!0!==s;t.save(),t.fillStyle=r,mo(t,a,d&&go(n,h,c)),t.beginPath();const u=!!i.pathSegment(t,e);let f;if(d){u?t.closePath():xo(t,s,c,n);const e=!!s.pathSegment(t,l,{move:u,reverse:!0});f=u&&e,f||xo(t,s,h,n)}t.closePath(),t.fill(f?"evenodd":"nonzero"),t.restore()}}function _o(t,e,i){const s=ho(e),{line:n,scale:o,axis:a}=e,r=n.options,l=r.fill,h=r.backgroundColor,{above:c=h,below:d=h}=l||{};s&&n.points.length&&(Zt(t,i),function(t,e){const{line:i,target:s,above:n,below:o,area:a,scale:r}=e,l=i._loop?"angle":e.axis;t.save(),"x"===l&&o!==n&&(fo(t,s,a.top),bo(t,{line:i,target:s,color:n,scale:r,property:l}),t.restore(),t.save(),fo(t,s,a.bottom)),bo(t,{line:i,target:s,color:o,scale:r,property:l}),t.restore()}(t,{line:n,target:s,above:c,below:d,area:i,scale:o,axis:a}),Qt(t))}var yo={id:"filler",afterDatasetsUpdate(t,e,i){const s=(t.data.datasets||[]).length,n=[];let o,a,r,l;for(a=0;a=0;--e){const i=n[e].$filler;i&&(i.line.updateControlPoints(o,i.axis),s&&_o(t.ctx,i,o))}},beforeDatasetsDraw(t,e,i){if("beforeDatasetsDraw"!==i.drawTime)return;const s=t.getSortedVisibleDatasetMetas();for(let e=s.length-1;e>=0;--e){const i=s[e].$filler;i&&_o(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,i){const s=e.meta.$filler;s&&!1!==s.fill&&"beforeDatasetDraw"===i.drawTime&&_o(t.ctx,s,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const vo=(t,e)=>{let{boxHeight:i=e,boxWidth:s=e}=t;return t.usePointStyle&&(i=Math.min(i,e),s=Math.min(s,e)),{boxWidth:s,boxHeight:i,itemHeight:Math.max(e,i)}};class wo extends Ms{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=Q(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter((e=>t.filter(e,this.chart.data)))),t.sort&&(e=e.sort(((e,i)=>t.sort(e,i,this.chart.data)))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const i=t.labels,s=Ve(i.font),n=s.size,o=this._computeTitleHeight(),{boxWidth:a,itemHeight:r}=vo(i,n);let l,h;e.font=s.string,this.isHorizontal()?(l=this.maxWidth,h=this._fitRows(o,n,a,r)+10):(h=this.maxHeight,l=this._fitCols(o,n,a,r)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:n,maxWidth:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.lineWidths=[0],h=s+a;let c=t;n.textAlign="left",n.textBaseline="middle";let d=-1,u=-h;return this.legendItems.forEach(((t,f)=>{const g=i+e/2+n.measureText(t.text).width;(0===f||l[l.length-1]+g+2*a>o)&&(c+=h,l[l.length-(f>0?0:1)]=0,u+=h,d++),r[f]={left:0,top:u,row:d,width:g,height:s},l[l.length-1]+=g+a})),c}_fitCols(t,e,i,s){const{ctx:n,maxHeight:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.columnSizes=[],h=o-t;let c=a,d=0,u=0,f=0,g=0;return this.legendItems.forEach(((t,o)=>{const p=i+e/2+n.measureText(t.text).width;o>0&&u+s+2*a>h&&(c+=d+a,l.push({width:d,height:u}),f+=d+a,g++,d=u=0),r[o]={left:f,top:u,col:g,width:p,height:s},d=Math.max(d,p),u+=s+a})),c+=d,l.push({width:d,height:u}),c}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:o}}=this,a=Ti(o,this.left,this.width);if(this.isHorizontal()){let o=0,r=n(i,this.left+s,this.right-this.lineWidths[o]);for(const l of e)o!==l.row&&(o=l.row,r=n(i,this.left+s,this.right-this.lineWidths[o])),l.top+=this.top+t+s,l.left=a.leftForLtr(a.x(r),l.width),r+=l.width+s}else{let o=0,r=n(i,this.top+t+s,this.bottom-this.columnSizes[o].height);for(const l of e)l.col!==o&&(o=l.col,r=n(i,this.top+t+s,this.bottom-this.columnSizes[o].height)),l.top=r,l.left+=this.left+s,l.left=a.leftForLtr(a.x(l.left),l.width),r+=l.height+s}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;Zt(t,this),this._draw(),Qt(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:a,labels:r}=t,l=xt.color,h=Ti(t.rtl,this.left,this.width),c=Ve(r.font),{color:d,padding:u}=r,f=c.size,g=f/2;let p;this.drawTitle(),s.textAlign=h.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:m,boxHeight:x,itemHeight:b}=vo(r,f),_=this.isHorizontal(),y=this._computeTitleHeight();p=_?{x:n(a,this.left+u,this.right-i[0]),y:this.top+u+y,line:0}:{x:this.left+u,y:n(a,this.top+y+u,this.bottom-e[0].height),line:0},Li(this.ctx,t.textDirection);const v=b+u;this.legendItems.forEach(((w,M)=>{s.strokeStyle=w.fontColor||d,s.fillStyle=w.fontColor||d;const k=s.measureText(w.text).width,S=h.textAlign(w.textAlign||(w.textAlign=r.textAlign)),P=m+g+k;let D=p.x,C=p.y;h.setWidth(this.width),_?M>0&&D+P+u>this.right&&(C=p.y+=v,p.line++,D=p.x=n(a,this.left+u,this.right-i[p.line])):M>0&&C+v>this.bottom&&(D=p.x=D+e[p.line].width+u,p.line++,C=p.y=n(a,this.top+y+u,this.bottom-e[p.line].height));!function(t,e,i){if(isNaN(m)||m<=0||isNaN(x)||x<0)return;s.save();const n=K(i.lineWidth,1);if(s.fillStyle=K(i.fillStyle,l),s.lineCap=K(i.lineCap,"butt"),s.lineDashOffset=K(i.lineDashOffset,0),s.lineJoin=K(i.lineJoin,"miter"),s.lineWidth=n,s.strokeStyle=K(i.strokeStyle,l),s.setLineDash(K(i.lineDash,[])),r.usePointStyle){const o={radius:m*Math.SQRT2/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:n},a=h.xPlus(t,m/2);Kt(s,o,a,e+g)}else{const o=e+Math.max((f-x)/2,0),a=h.leftForLtr(t,m),r=Fe(i.borderRadius);s.beginPath(),Object.values(r).some((t=>0!==t))?se(s,{x:a,y:o,w:m,h:x,radius:r}):s.rect(a,o,m,x),s.fill(),0!==n&&s.stroke()}s.restore()}(h.x(D),C,w),D=o(S,D+m+g,_?D+P:this.right,t.rtl),function(t,e,i){ee(s,i.text,t,e+b/2,c,{strikethrough:i.hidden,textAlign:h.textAlign(i.textAlign)})}(h.x(D),C,w),_?p.x+=P+u:p.y+=v})),Ri(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=Ve(e.font),o=Be(e.padding);if(!e.display)return;const a=Ti(t.rtl,this.left,this.width),r=this.ctx,l=e.position,h=i.size/2,c=o.top+h;let d,u=this.left,f=this.width;if(this.isHorizontal())f=Math.max(...this.lineWidths),d=this.top+c,u=n(t.align,u,this.right-f);else{const e=this.columnSizes.reduce(((t,e)=>Math.max(t,e.height)),0);d=c+n(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const g=n(l,u,u+f);r.textAlign=a.textAlign(s(l)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=i.string,ee(r,e.text,g,d,i)}_computeTitleHeight(){const t=this.options.title,e=Ve(t.font),i=Be(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,n;if(t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom)for(n=this.legendHitBoxes,i=0;i=s.left&&t<=s.left+s.width&&e>=s.top&&e<=s.top+s.height)return this.legendItems[i];return null}handleEvent(t){const e=this.options;if(!function(t,e){if("mousemove"===t&&(e.onHover||e.onLeave))return!0;if(e.onClick&&("click"===t||"mouseup"===t))return!0;return!1}(t.type,e))return;const i=this._getLegendItemAt(t.x,t.y);if("mousemove"===t.type){const o=this._hoveredItem,a=(n=i,null!==(s=o)&&null!==n&&s.datasetIndex===n.datasetIndex&&s.index===n.index);o&&!a&&Q(e.onLeave,[t,o,this],this),this._hoveredItem=i,i&&!a&&Q(e.onHover,[t,i,this],this)}else i&&Q(e.onClick,[t,i,this],this);var s,n}}var Mo={id:"legend",_element:wo,start(t,e,i){const s=t.legend=new wo({ctx:t.ctx,options:i,chart:t});ei.configure(t,s,i),ei.addBox(t,s)},stop(t){ei.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,i){const s=t.legend;ei.configure(t,s,i),s.options=i},afterUpdate(t){const e=t.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(t,e){e.replay||t.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,e,i){const s=e.datasetIndex,n=i.chart;n.isDatasetVisible(s)?(n.hide(s),e.hidden=!0):(n.show(s),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:i,pointStyle:s,textAlign:n,color:o}}=t.legend.options;return t._getSortedDatasetMetas().map((t=>{const a=t.controller.getStyle(i?0:void 0),r=Be(a.borderWidth);return{text:e[t.index].label,fillStyle:a.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:a.borderCapStyle,lineDash:a.borderDash,lineDashOffset:a.borderDashOffset,lineJoin:a.borderJoinStyle,lineWidth:(r.width+r.height)/4,strokeStyle:a.borderColor,pointStyle:s||a.pointStyle,rotation:a.rotation,textAlign:n||a.textAlign,borderRadius:0,datasetIndex:t.index}}),this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class ko extends Ms{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this.options;if(this.left=0,this.top=0,!i.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const s=Y(i.text)?i.text.length:1;this._padding=Be(i.padding);const n=s*Ve(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=n:this.width=n}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:s,right:o,options:a}=this,r=a.align;let l,h,c,d=0;return this.isHorizontal()?(h=n(r,i,o),c=e+t,l=o-i):("left"===a.position?(h=i+t,c=n(r,s,e),d=-.5*bt):(h=o-t,c=n(r,e,s),d=.5*bt),l=s-e),{titleX:h,titleY:c,maxWidth:l,rotation:d}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=Ve(e.font),n=i.lineHeight/2+this._padding.top,{titleX:o,titleY:a,maxWidth:r,rotation:l}=this._drawArgs(n);ee(t,e.text,0,0,i,{color:e.color,maxWidth:r,rotation:l,textAlign:s(e.align),textBaseline:"middle",translation:[o,a]})}}var So={id:"title",_element:ko,start(t,e,i){!function(t,e){const i=new ko({ctx:t.ctx,options:e,chart:t});ei.configure(t,i,e),ei.addBox(t,i),t.titleBlock=i}(t,i)},stop(t){const e=t.titleBlock;ei.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){const s=t.titleBlock;ei.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Po=new WeakMap;var Do={id:"subtitle",start(t,e,i){const s=new ko({ctx:t.ctx,options:i,chart:t});ei.configure(t,s,i),ei.addBox(t,s),Po.set(t,s)},stop(t){ei.removeBox(t,Po.get(t)),Po.delete(t)},beforeUpdate(t,e,i){const s=Po.get(t);ei.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Co={average(t){if(!t.length)return!1;let e,i,s=0,n=0,o=0;for(e=0,i=t.length;e-1?t.split("\n"):t}function To(t,e){const{element:i,datasetIndex:s,index:n}=e,o=t.getDatasetMeta(s).controller,{label:a,value:r}=o.getLabelAndValue(n);return{chart:t,label:a,parsed:o.getParsed(n),raw:t.data.datasets[s].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:i}}function Lo(t,e){const i=t._chart.ctx,{body:s,footer:n,title:o}=t,{boxWidth:a,boxHeight:r}=e,l=Ve(e.bodyFont),h=Ve(e.titleFont),c=Ve(e.footerFont),d=o.length,u=n.length,f=s.length,g=Be(e.padding);let p=g.height,m=0,x=s.reduce(((t,e)=>t+e.before.length+e.lines.length+e.after.length),0);if(x+=t.beforeBody.length+t.afterBody.length,d&&(p+=d*h.lineHeight+(d-1)*e.titleSpacing+e.titleMarginBottom),x){p+=f*(e.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(x-f)*l.lineHeight+(x-1)*e.bodySpacing}u&&(p+=e.footerMarginTop+u*c.lineHeight+(u-1)*e.footerSpacing);let b=0;const _=function(t){m=Math.max(m,i.measureText(t).width+b)};return i.save(),i.font=h.string,J(t.title,_),i.font=l.string,J(t.beforeBody.concat(t.afterBody),_),b=e.displayColors?a+2+e.boxPadding:0,J(s,(t=>{J(t.before,_),J(t.lines,_),J(t.after,_)})),b=0,i.font=c.string,J(t.footer,_),i.restore(),m+=g.width,{width:m,height:p}}function Ro(t,e,i,s){const{x:n,width:o}=i,{width:a,chartArea:{left:r,right:l}}=t;let h="center";return"center"===s?h=n<=(r+l)/2?"left":"right":n<=o/2?h="left":n>=a-o/2&&(h="right"),function(t,e,i,s){const{x:n,width:o}=s,a=i.caretSize+i.caretPadding;return"left"===t&&n+o+a>e.width||"right"===t&&n-o-a<0||void 0}(h,t,e,i)&&(h="center"),h}function Eo(t,e,i){const s=e.yAlign||function(t,e){const{y:i,height:s}=e;return it.height-s/2?"bottom":"center"}(t,i);return{xAlign:e.xAlign||Ro(t,e,i,s),yAlign:s}}function Io(t,e,i,s){const{caretSize:n,caretPadding:o,cornerRadius:a}=t,{xAlign:r,yAlign:l}=i,h=n+o,{topLeft:c,topRight:d,bottomLeft:u,bottomRight:f}=Fe(a);let g=function(t,e){let{x:i,width:s}=t;return"right"===e?i-=s:"center"===e&&(i-=s/2),i}(e,r);const p=function(t,e,i){let{y:s,height:n}=t;return"top"===e?s+=i:s-="bottom"===e?n+i:n/2,s}(e,l,h);return"center"===l?"left"===r?g+=h:"right"===r&&(g-=h):"left"===r?g-=Math.max(c,u)+o:"right"===r&&(g+=Math.max(d,f)+o),{x:Ht(g,0,s.width-e.width),y:Ht(p,0,s.height-e.height)}}function zo(t,e,i){const s=Be(i.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-s.right:t.x+s.left}function Fo(t){return Oo([],Ao(t))}function Bo(t,e){const i=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return i?t.override(i):t}class Vo extends Ms{constructor(t){super(),this.opacity=0,this._active=[],this._chart=t._chart,this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this._chart,i=this.options.setContext(this.getContext()),s=i.enabled&&e.options.animation&&i.animations,n=new cs(this._chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(n)),n}getContext(){return this.$context||(this.$context=(t=this._chart.getContext(),e=this,i=this._tooltipItems,He(t,{tooltip:e,tooltipItems:i,type:"tooltip"})));var t,e,i}getTitle(t,e){const{callbacks:i}=e,s=i.beforeTitle.apply(this,[t]),n=i.title.apply(this,[t]),o=i.afterTitle.apply(this,[t]);let a=[];return a=Oo(a,Ao(s)),a=Oo(a,Ao(n)),a=Oo(a,Ao(o)),a}getBeforeBody(t,e){return Fo(e.callbacks.beforeBody.apply(this,[t]))}getBody(t,e){const{callbacks:i}=e,s=[];return J(t,(t=>{const e={before:[],lines:[],after:[]},n=Bo(i,t);Oo(e.before,Ao(n.beforeLabel.call(this,t))),Oo(e.lines,n.label.call(this,t)),Oo(e.after,Ao(n.afterLabel.call(this,t))),s.push(e)})),s}getAfterBody(t,e){return Fo(e.callbacks.afterBody.apply(this,[t]))}getFooter(t,e){const{callbacks:i}=e,s=i.beforeFooter.apply(this,[t]),n=i.footer.apply(this,[t]),o=i.afterFooter.apply(this,[t]);let a=[];return a=Oo(a,Ao(s)),a=Oo(a,Ao(n)),a=Oo(a,Ao(o)),a}_createItems(t){const e=this._active,i=this._chart.data,s=[],n=[],o=[];let a,r,l=[];for(a=0,r=e.length;at.filter(e,s,n,i)))),t.itemSort&&(l=l.sort(((e,s)=>t.itemSort(e,s,i)))),J(l,(e=>{const i=Bo(t.callbacks,e);s.push(i.labelColor.call(this,e)),n.push(i.labelPointStyle.call(this,e)),o.push(i.labelTextColor.call(this,e))})),this.labelColors=s,this.labelPointStyles=n,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let n,o=[];if(s.length){const t=Co[i.position].call(this,s,this._eventPosition);o=this._createItems(i),this.title=this.getTitle(o,i),this.beforeBody=this.getBeforeBody(o,i),this.body=this.getBody(o,i),this.afterBody=this.getAfterBody(o,i),this.footer=this.getFooter(o,i);const e=this._size=Lo(this,i),a=Object.assign({},t,e),r=Eo(this._chart,i,a),l=Io(i,a,r,this._chart);this.xAlign=r.xAlign,this.yAlign=r.yAlign,n={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(n={opacity:0});this._tooltipItems=o,this.$context=void 0,n&&this._resolveAnimations().update(this,n),t&&i.external&&i.external.call(this,{chart:this._chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const n=this.getCaretPosition(t,i,s);e.lineTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:n}=this,{caretSize:o,cornerRadius:a}=i,{topLeft:r,topRight:l,bottomLeft:h,bottomRight:c}=Fe(a),{x:d,y:u}=t,{width:f,height:g}=e;let p,m,x,b,_,y;return"center"===n?(_=u+g/2,"left"===s?(p=d,m=p-o,b=_+o,y=_-o):(p=d+f,m=p+o,b=_-o,y=_+o),x=p):(m="left"===s?d+Math.max(r,h)+o:"right"===s?d+f-Math.max(l,c)-o:this.caretX,"top"===n?(b=u,_=b-o,p=m-o,x=m+o):(b=u+g,_=b+o,p=m+o,x=m-o),y=b),{x1:p,x2:m,x3:x,y1:b,y2:_,y3:y}}drawTitle(t,e,i){const s=this.title,n=s.length;let o,a,r;if(n){const l=Ti(i.rtl,this.x,this.width);for(t.x=zo(this,i.titleAlign,i),e.textAlign=l.textAlign(i.titleAlign),e.textBaseline="middle",o=Ve(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=o.string,r=0;r0!==t))?(t.beginPath(),t.fillStyle=n.multiKeyBackground,se(t,{x:e,y:g,w:l,h:r,radius:a}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),se(t,{x:i,y:g+1,w:l-2,h:r-2,radius:a}),t.fill()):(t.fillStyle=n.multiKeyBackground,t.fillRect(e,g,l,r),t.strokeRect(e,g,l,r),t.fillStyle=o.backgroundColor,t.fillRect(i,g+1,l-2,r-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:n,bodyAlign:o,displayColors:a,boxHeight:r,boxWidth:l,boxPadding:h}=i,c=Ve(i.bodyFont);let d=c.lineHeight,u=0;const f=Ti(i.rtl,this.x,this.width),g=function(i){e.fillText(i,f.x(t.x+u),t.y+d/2),t.y+=d+n},p=f.textAlign(o);let m,x,b,_,y,v,w;for(e.textAlign=o,e.textBaseline="middle",e.font=c.string,t.x=zo(this,p,i),e.fillStyle=i.bodyColor,J(this.beforeBody,g),u=a&&"right"!==p?"center"===o?l/2+h:l+2+h:0,_=0,v=s.length;_0&&e.stroke()}_updateAnimationTarget(t){const e=this._chart,i=this.$animations,s=i&&i.x,n=i&&i.y;if(s||n){const i=Co[t.position].call(this,this._active,this._eventPosition);if(!i)return;const o=this._size=Lo(this,t),a=Object.assign({},i,this._size),r=Eo(e,t,a),l=Io(t,a,r,e);s._to===l.x&&n._to===l.y||(this.xAlign=r.xAlign,this.yAlign=r.yAlign,this.width=o.width,this.height=o.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,l))}}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},n={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const o=Be(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(n,t,s,e),Li(t,e.textDirection),n.y+=o.top,this.drawTitle(n,t,e),this.drawBody(n,t,e),this.drawFooter(n,t,e),Ri(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map((({datasetIndex:t,index:e})=>{const i=this._chart.getDatasetMeta(t);if(!i)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:i.data[e],index:e}})),n=!tt(i,s),o=this._positionChanged(s,e);(n||o)&&(this._active=s,this._eventPosition=e,this.update(!0))}handleEvent(t,e){const i=this.options,s=this._active||[];let n=!1,o=[];"mouseout"!==t.type&&(o=this._chart.getElementsAtEventForMode(t,i.mode,i,e),i.reverse&&o.reverse());const a=this._positionChanged(o,t);return n=e||!tt(o,s)||a,n&&(this._active=o,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),n}_positionChanged(t,e){const{caretX:i,caretY:s,options:n}=this,o=Co[n.position].call(this,t,e);return!1!==o&&(i!==o.x||s!==o.y)}}Vo.positioners=Co;var Wo={id:"tooltip",_element:Vo,positioners:Co,afterInit(t,e,i){i&&(t.tooltip=new Vo({_chart:t,options:i}))},beforeUpdate(t,e,i){t.tooltip&&t.tooltip.initialize(i)},reset(t,e,i){t.tooltip&&t.tooltip.initialize(i)},afterDraw(t){const e=t.tooltip,i={tooltip:e};!1!==t.notifyPlugins("beforeTooltipDraw",i)&&(e&&e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i))},afterEvent(t,e){if(t.tooltip){const i=e.replay;t.tooltip.handleEvent(e.event,i)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:{beforeTitle:H,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,s=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(s>0&&e.dataIndex"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},No=Object.freeze({__proto__:null,Decimation:io,Filler:yo,Legend:Mo,SubTitle:Do,Title:So,Tooltip:Wo});function Ho(t,e,i){const s=t.indexOf(e);if(-1===s)return((t,e,i)=>"string"==typeof e?t.push(e)-1:isNaN(e)?null:i)(t,e,i);return s!==t.lastIndexOf(e)?i:s}class jo extends Es{constructor(t){super(t),this._startValue=void 0,this._valueRange=0}parse(t,e){if($(t))return null;const i=this.getLabels();return((t,e)=>null===t?null:Ht(Math.round(t),0,e))(e=isFinite(e)&&i[e]===t?e:Ho(i,t,K(e,t)),i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(i=0),e||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,e=this.max,i=this.options.offset,s=[];let n=this.getLabels();n=0===t&&e===n.length-1?n:n.slice(t,e+1),this._valueRange=Math.max(n.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let i=t;i<=e;i++)s.push({value:i});return s}getLabelForValue(t){const e=this.getLabels();return t>=0&&te.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function $o(t,e,{horizontal:i,minRotation:s}){const n=Et(s),o=(i?Math.sin(n):Math.cos(n))||.001,a=.75*e*(""+t).length;return Math.min(e/o,a)}jo.id="category",jo.defaults={ticks:{callback:jo.prototype.getLabelForValue}};class Yo extends Es{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return $(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:s,max:n}=this;const o=t=>s=e?s:t,a=t=>n=i?n:t;if(t){const t=Dt(s),e=Dt(n);t<0&&e<0?a(0):t>0&&e>0&&o(0)}if(s===n){let e=1;(n>=Number.MAX_SAFE_INTEGER||s<=Number.MIN_SAFE_INTEGER)&&(e=Math.abs(.05*n)),a(n+e),t||o(s-e)}this.min=s,this.max=n}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:i,stepSize:s}=t;return s?(e=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),i=i||11),i&&(e=Math.min(i,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const s=function(t,e){const i=[],{bounds:s,step:n,min:o,max:a,precision:r,count:l,maxTicks:h,maxDigits:c,includeBounds:d}=t,u=n||1,f=h-1,{min:g,max:p}=e,m=!$(o),x=!$(a),b=!$(l),_=(p-g)/(c+1);let y,v,w,M,k=Ct((p-g)/f/u)*u;if(k<1e-14&&!m&&!x)return[{value:g},{value:p}];M=Math.ceil(p/k)-Math.floor(g/k),M>f&&(k=Ct(M*k/f/u)*u),$(r)||(y=Math.pow(10,r),k=Math.ceil(k*y)/y),"ticks"===s?(v=Math.floor(g/k)*k,w=Math.ceil(p/k)*k):(v=g,w=p),m&&x&&n&&Lt((a-o)/n,k/1e3)?(M=Math.round(Math.min((a-o)/k,h)),k=(a-o)/M,v=o,w=a):b?(v=m?o:v,w=x?a:w,M=l-1,k=(w-v)/M):(M=(w-v)/k,M=Tt(M,Math.round(M),k/1e3)?Math.round(M):Math.ceil(M));const S=Math.max(zt(k),zt(v));y=Math.pow(10,$(r)?S:r),v=Math.round(v*y)/y,w=Math.round(w*y)/y;let P=0;for(m&&(d&&v!==o?(i.push({value:o}),v0?i:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=X(t)?Math.max(0,t):null,this.max=X(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const n=e=>i=t?i:e,o=t=>s=e?s:t,a=(t,e)=>Math.pow(10,Math.floor(Pt(t))+e);i===s&&(i<=0?(n(1),o(10)):(n(a(i,-1)),o(a(s,1)))),i<=0&&n(a(s,-1)),s<=0&&o(a(i,1)),this._zero&&this.min!==this._suggestedMin&&i===a(this.min,0)&&n(a(i,-1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e=function(t,e){const i=Math.floor(Pt(e.max)),s=Math.ceil(e.max/Math.pow(10,i)),n=[];let o=q(t.min,Math.pow(10,Math.floor(Pt(e.min)))),a=Math.floor(Pt(o)),r=Math.floor(o/Math.pow(10,a)),l=a<0?Math.pow(10,Math.abs(a)):1;do{n.push({value:o,major:Xo(o)}),++r,10===r&&(r=1,++a,l=a>=0?1:l),o=Math.round(r*Math.pow(10,a)*l)/l}while(an?{start:e-i,end:e}:{start:e,end:e+i}}function Zo(t){const e={l:0,r:t.width,t:0,b:t.height-t.paddingTop},i={},s=[],n=[],o=t.getLabels().length;for(let h=0;he.r&&(e.r=p.end,i.r=f),m.starte.b&&(e.b=m.end,i.b=f)}var a,r,l;t._setReductions(t.drawingArea,e,i),t._pointLabelItems=function(t,e,i){const s=[],n=t.getLabels().length,o=t.options,a=Ko(o),r=t.getDistanceFromCenterForValue(o.ticks.reverse?t.min:t.max);for(let o=0;o270||i<90)&&(t-=e),t}function ea(t,e,i,s){const{ctx:n}=t;if(i)n.arc(t.xCenter,t.yCenter,e,0,_t);else{let i=t.getPointPosition(0,e);n.moveTo(i.x,i.y);for(let o=1;o{const i=Q(this.options.pointLabels.callback,[t,e],this);return i||0===i?i:""}))}fit(){const t=this.options;t.display&&t.pointLabels.display?Zo(this):this.setCenterPoint(0,0,0,0)}_setReductions(t,e,i){let s=e.l/Math.sin(i.l),n=Math.max(e.r-this.width,0)/Math.sin(i.r),o=-e.t/Math.cos(i.t),a=-Math.max(e.b-(this.height-this.paddingTop),0)/Math.cos(i.b);s=ia(s),n=ia(n),o=ia(o),a=ia(a),this.drawingArea=Math.max(t/2,Math.min(Math.floor(t-(s+n)/2),Math.floor(t-(o+a)/2))),this.setCenterPoint(s,n,o,a)}setCenterPoint(t,e,i,s){const n=this.width-e-this.drawingArea,o=t+this.drawingArea,a=i+this.drawingArea,r=this.height-this.paddingTop-s-this.drawingArea;this.xCenter=Math.floor((o+n)/2+this.left),this.yCenter=Math.floor((a+r)/2+this.top+this.paddingTop)}getIndexAngle(t){return Wt(t*(_t/this.getLabels().length)+Et(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if($(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if($(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t=0;n--){const e=s.setContext(t.getPointLabelContext(n)),o=Ve(e.font),{x:a,y:r,textAlign:l,left:h,top:c,right:d,bottom:u}=t._pointLabelItems[n],{backdropColor:f}=e;if(!$(f)){const t=Be(e.backdropPadding);i.fillStyle=f,i.fillRect(h-t.left,c-t.top,d-h+t.width,u-c+t.height)}ee(i,t._pointLabels[n],a,r+o.lineHeight/2,o,{color:e.color,textAlign:l,textBaseline:"middle"})}}(this,n),s.display&&this.ticks.forEach(((t,e)=>{if(0!==e){a=this.getDistanceFromCenterForValue(t.value);!function(t,e,i,s){const n=t.ctx,o=e.circular,{color:a,lineWidth:r}=e;!o&&!s||!a||!r||i<0||(n.save(),n.strokeStyle=a,n.lineWidth=r,n.setLineDash(e.borderDash),n.lineDashOffset=e.borderDashOffset,n.beginPath(),ea(t,i,o,s),n.closePath(),n.stroke(),n.restore())}(this,s.setContext(this.getContext(e-1)),a,n)}})),i.display){for(t.save(),o=this.getLabels().length-1;o>=0;o--){const s=i.setContext(this.getPointLabelContext(o)),{color:n,lineWidth:l}=s;l&&n&&(t.lineWidth=l,t.strokeStyle=n,t.setLineDash(s.borderDash),t.lineDashOffset=s.borderDashOffset,a=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),r=this.getPointPosition(o,a),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(r.x,r.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let n,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach(((s,a)=>{if(0===a&&!e.reverse)return;const r=i.setContext(this.getContext(a)),l=Ve(r.font);if(n=this.getDistanceFromCenterForValue(this.ticks[a].value),r.showLabelBackdrop){t.font=l.string,o=t.measureText(s.label).width,t.fillStyle=r.backdropColor;const e=Be(r.backdropPadding);t.fillRect(-o/2-e.left,-n-l.size/2-e.top,o+e.width,l.size+e.height)}ee(t,s.label,0,-n,l,{color:r.color})})),t.restore()}drawTitle(){}}sa.id="radialLinear",sa.defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Ss.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback:t=>t,padding:5}},sa.defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"},sa.descriptors={angleLines:{_fallback:"grid"}};const na={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},oa=Object.keys(na);function aa(t,e){return t-e}function ra(t,e){if($(e))return null;const i=t._adapter,{parser:s,round:n,isoWeekday:o}=t._parseOpts;let a=e;return"function"==typeof s&&(a=s(a)),X(a)||(a="string"==typeof s?i.parse(a,s):i.parse(a)),null===a?null:(n&&(a="week"!==n||!At(o)&&!0!==o?i.startOf(a,n):i.startOf(a,"isoWeek",o)),+a)}function la(t,e,i,s){const n=oa.length;for(let o=oa.indexOf(t);o=e?i[s]:i[n]]=!0}}else t[e]=!0}function ca(t,e,i){const s=[],n={},o=e.length;let a,r;for(a=0;a=0&&(e[l].major=!0);return e}(t,s,n,i):s}class da extends Es{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e){const i=t.time||(t.time={}),s=this._adapter=new dn._date(t.adapters.date);ot(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:ra(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,i=t.time.unit||"day";let{min:s,max:n,minDefined:o,maxDefined:a}=this.getUserBounds();function r(t){o||isNaN(t.min)||(s=Math.min(s,t.min)),a||isNaN(t.max)||(n=Math.max(n,t.max))}o&&a||(r(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||r(this.getMinMax(!1))),s=X(s)&&!isNaN(s)?s:+e.startOf(Date.now(),i),n=X(n)&&!isNaN(n)?n:+e.endOf(Date.now(),i)+1,this.min=Math.min(s,n-1),this.max=Math.max(s+1,n)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this.options,e=t.time,i=t.ticks,s="labels"===i.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const n=this.min,o=re(s,n,this.max);return this._unit=e.unit||(i.autoSkip?la(e.minUnit,this.min,this.max,this._getLabelCapacity(n)):function(t,e,i,s,n){for(let o=oa.length-1;o>=oa.indexOf(i);o--){const i=oa[o];if(na[i].common&&t._adapter.diff(n,s,i)>=e-1)return i}return oa[i?oa.indexOf(i):0]}(this,o.length,e.minUnit,this.min,this.max)),this._majorUnit=i.major.enabled&&"year"!==this._unit?function(t){for(let e=oa.indexOf(t)+1,i=oa.length;e1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+o);const f="data"===s.ticks.source&&this.getDataTimestamps();for(c=u,d=0;ct-e)).map((t=>+t))}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}_tickFormatFunction(t,e,i,s){const n=this.options,o=n.time.displayFormats,a=this._unit,r=this._majorUnit,l=a&&o[a],h=r&&o[r],c=i[e],d=r&&h&&c&&c.major,u=this._adapter.format(t,s||(d?h:l)),f=n.ticks.callback;return f?Q(f,[u,e,i],this):u}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t,e,i=this._cache.data||[];if(i.length)return i;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(t=0,e=s.length;t=t[r].pos&&e<=t[l].pos&&({lo:r,hi:l}=oe(t,"pos",e)),({pos:s,time:o}=t[r]),({pos:n,time:a}=t[l])):(e>=t[r].time&&e<=t[l].time&&({lo:r,hi:l}=oe(t,"time",e)),({time:s,pos:o}=t[r]),({time:n,pos:a}=t[l]));const h=n-s;return h?o+(a-o)*(e-s)/h:o}da.id="time",da.defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",major:{enabled:!1}}};class fa extends da{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=ua(e,this.min),this._tableRange=ua(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],n=[];let o,a,r,l,h;for(o=0,a=t.length;o=e&&l<=i&&s.push(l);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(o=0,a=s.length;ol[15&t],c=t=>l[(240&t)>>4]+l[15&t],d=t=>(240&t)>>4==(15&t);function u(t){var e=function(t){return d(t.r)&&d(t.g)&&d(t.b)&&d(t.a)}(t)?h:c;return t?"#"+e(t.r)+e(t.g)+e(t.b)+(t.a<255?e(t.a):""):t}function f(t){return t+.5|0}const g=(t,e,i)=>Math.max(Math.min(t,i),e);function p(t){return g(f(2.55*t),0,255)}function m(t){return g(f(255*t),0,255)}function x(t){return g(f(t/2.55)/100,0,1)}function b(t){return g(f(100*t),0,100)}const _=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const y=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function v(t,e,i){const s=e*Math.min(i,1-i),n=(e,n=(e+t/30)%12)=>i-s*Math.max(Math.min(n-3,9-n,1),-1);return[n(0),n(8),n(4)]}function w(t,e,i){const s=(s,n=(s+t/60)%6)=>i-i*e*Math.max(Math.min(n,4-n,1),0);return[s(5),s(3),s(1)]}function M(t,e,i){const s=v(t,1,.5);let n;for(e+i>1&&(n=1/(e+i),e*=n,i*=n),n=0;n<3;n++)s[n]*=1-e-i,s[n]+=e;return s}function k(t){const e=t.r/255,i=t.g/255,s=t.b/255,n=Math.max(e,i,s),o=Math.min(e,i,s),a=(n+o)/2;let r,l,h;return n!==o&&(h=n-o,l=a>.5?h/(2-n-o):h/(n+o),r=n===e?(i-s)/h+(i>16&255,o>>8&255,255&o]}return t}(),T.transparent=[0,0,0,0]);const e=T[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}function R(t,e,i){if(t){let s=k(t);s[e]=Math.max(0,Math.min(s[e]+s[e]*i,0===e?360:1)),s=P(s),t.r=s[0],t.g=s[1],t.b=s[2]}}function E(t,e){return t?Object.assign(e||{},t):t}function I(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=m(t[3]))):(e=E(t,{r:0,g:0,b:0,a:1})).a=m(e.a),e}function z(t){return"r"===t.charAt(0)?function(t){const e=_.exec(t);let i,s,n,o=255;if(e){if(e[7]!==i){const t=+e[7];o=255&(e[8]?p(t):255*t)}return i=+e[1],s=+e[3],n=+e[5],i=255&(e[2]?p(i):i),s=255&(e[4]?p(s):s),n=255&(e[6]?p(n):n),{r:i,g:s,b:n,a:o}}}(t):C(t)}class F{constructor(t){if(t instanceof F)return t;const e=typeof t;let i;var s,n,o;"object"===e?i=I(t):"string"===e&&(o=(s=t).length,"#"===s[0]&&(4===o||5===o?n={r:255&17*r[s[1]],g:255&17*r[s[2]],b:255&17*r[s[3]],a:5===o?17*r[s[4]]:255}:7!==o&&9!==o||(n={r:r[s[1]]<<4|r[s[2]],g:r[s[3]]<<4|r[s[4]],b:r[s[5]]<<4|r[s[6]],a:9===o?r[s[7]]<<4|r[s[8]]:255})),i=n||L(t)||z(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=E(this._rgb);return t&&(t.a=x(t.a)),t}set rgb(t){this._rgb=I(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${x(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):this._rgb;var t}hexString(){return this._valid?u(this._rgb):this._rgb}hslString(){return this._valid?function(t){if(!t)return;const e=k(t),i=e[0],s=b(e[1]),n=b(e[2]);return t.a<255?`hsla(${i}, ${s}%, ${n}%, ${x(t.a)})`:`hsl(${i}, ${s}%, ${n}%)`}(this._rgb):this._rgb}mix(t,e){const i=this;if(t){const s=i.rgb,n=t.rgb;let o;const a=e===o?.5:e,r=2*a-1,l=s.a-n.a,h=((r*l==-1?r:(r+l)/(1+r*l))+1)/2;o=1-h,s.r=255&h*s.r+o*n.r+.5,s.g=255&h*s.g+o*n.g+.5,s.b=255&h*s.b+o*n.b+.5,s.a=a*s.a+(1-a)*n.a,i.rgb=s}return i}clone(){return new F(this.rgb)}alpha(t){return this._rgb.a=m(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,e=f(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return R(this._rgb,2,t),this}darken(t){return R(this._rgb,2,-t),this}saturate(t){return R(this._rgb,1,t),this}desaturate(t){return R(this._rgb,1,-t),this}rotate(t){return function(t,e){var i=k(t);i[0]=D(i[0]+e),i=P(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this}}function B(t){return new F(t)}const V=t=>t instanceof CanvasGradient||t instanceof CanvasPattern;function W(t){return V(t)?t:B(t)}function N(t){return V(t)?t:B(t).saturate(.5).darken(.1).hexString()}function H(){}const j=function(){let t=0;return function(){return t++}}();function $(t){return null==t}function Y(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.substr(0,7)&&"Array]"===e.substr(-6)}function U(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}const X=t=>("number"==typeof t||t instanceof Number)&&isFinite(+t);function q(t,e){return X(t)?t:e}function K(t,e){return void 0===t?e:t}const G=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:t/e,Z=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function Q(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function J(t,e,i,s){let n,o,a;if(Y(t))if(o=t.length,s)for(n=o-1;n>=0;n--)e.call(i,t[n],n);else for(n=0;ni;)t=t[e.substr(i,s-i)],i=s+1,s=rt(e,i);return t}function ht(t){return t.charAt(0).toUpperCase()+t.slice(1)}const ct=t=>void 0!==t,dt=t=>"function"==typeof t,ut=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0},ft=Object.create(null),gt=Object.create(null);function pt(t,e){if(!e)return t;const i=e.split(".");for(let e=0,s=i.length;et.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(t,e)=>N(e.backgroundColor),this.hoverBorderColor=(t,e)=>N(e.borderColor),this.hoverColor=(t,e)=>N(e.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.describe(t)}set(t,e){return mt(this,t,e)}get(t){return pt(this,t)}describe(t,e){return mt(gt,t,e)}override(t,e){return mt(ft,t,e)}route(t,e,i,s){const n=pt(this,t),o=pt(this,i),a="_"+e;Object.defineProperties(n,{[a]:{value:n[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[a],e=o[s];return U(t)?Object.assign({},e,t):K(t,e)},set(t){this[a]=t}}})}}({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}});const bt=Math.PI,_t=2*bt,yt=_t+bt,vt=Number.POSITIVE_INFINITY,wt=bt/180,Mt=bt/2,kt=bt/4,St=2*bt/3,Pt=Math.log10,Dt=Math.sign;function Ct(t){const e=Math.round(t);t=Tt(t,e,t/1e3)?e:t;const i=Math.pow(10,Math.floor(Pt(t))),s=t/i;return(s<=1?1:s<=2?2:s<=5?5:10)*i}function Ot(t){const e=[],i=Math.sqrt(t);let s;for(s=1;st-e)).pop(),e}function At(t){return!isNaN(parseFloat(t))&&isFinite(t)}function Tt(t,e,i){return Math.abs(t-e)=t}function Rt(t,e,i){let s,n,o;for(s=0,n=t.length;sl&&h=Math.min(e,i)-s&&t<=Math.max(e,i)+s}function Yt(t){return!t||$(t.size)||$(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}function Ut(t,e,i,s,n){let o=e[n];return o||(o=e[n]=t.measureText(n).width,i.push(n)),o>s&&(s=o),s}function Xt(t,e,i,s){let n=(s=s||{}).data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==e&&(n=s.data={},o=s.garbageCollect=[],s.font=e),t.save(),t.font=e;let a=0;const r=i.length;let l,h,c,d,u;for(l=0;li.length){for(l=0;l0&&t.stroke()}}function Zt(t,e,i){return i=i||.5,!e||t&&t.x>e.left-i&&t.xe.top-i&&t.y0&&""!==o.strokeColor;let l,h;for(t.save(),t.font=n.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]);$(e.rotation)||t.rotate(e.rotation);e.color&&(t.fillStyle=e.color);e.textAlign&&(t.textAlign=e.textAlign);e.textBaseline&&(t.textBaseline=e.textBaseline)}(t,o),l=0;lt[i]1;)s=o+n>>1,i(s)?o=s:n=s;return{lo:o,hi:n}}const ae=(t,e,i)=>oe(t,i,(s=>t[s][e]oe(t,i,(s=>t[s][e]>=i));function le(t,e,i){let s=0,n=t.length;for(;ss&&t[n-1]>i;)n--;return s>0||n{const i="_onData"+ht(e),s=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...e){const n=s.apply(this,e);return t._chartjs.listeners.forEach((t=>{"function"==typeof t[i]&&t[i](...e)})),n}})})))}function de(t,e){const i=t._chartjs;if(!i)return;const s=i.listeners,n=s.indexOf(e);-1!==n&&s.splice(n,1),s.length>0||(he.forEach((e=>{delete t[e]})),delete t._chartjs)}function ue(t){const e=new Set;let i,s;for(i=0,s=t.length;iwindow.getComputedStyle(t,null);function xe(t,e){return me(t).getPropertyValue(e)}const be=["top","right","bottom","left"];function _e(t,e,i){const s={};i=i?"-"+i:"";for(let n=0;n<4;n++){const o=be[n];s[o]=parseFloat(t[e+"-"+o+i])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}function ye(t,e){const{canvas:i,currentDevicePixelRatio:s}=e,n=me(i),o="border-box"===n.boxSizing,a=_e(n,"padding"),r=_e(n,"border","width"),{x:l,y:h,box:c}=function(t,e){const i=t.native||t,s=i.touches,n=s&&s.length?s[0]:i,{offsetX:o,offsetY:a}=n;let r,l,h=!1;if(((t,e,i)=>(t>0||e>0)&&(!i||!i.shadowRoot))(o,a,i.target))r=o,l=a;else{const t=e.getBoundingClientRect();r=n.clientX-t.left,l=n.clientY-t.top,h=!0}return{x:r,y:l,box:h}}(t,i),d=a.left+(c&&r.left),u=a.top+(c&&r.top);let{width:f,height:g}=e;return o&&(f-=a.width+r.width,g-=a.height+r.height),{x:Math.round((l-d)/f*i.width/s),y:Math.round((h-u)/g*i.height/s)}}const ve=t=>Math.round(10*t)/10;function we(t,e,i,s){const n=me(t),o=_e(n,"margin"),a=pe(n.maxWidth,t,"clientWidth")||vt,r=pe(n.maxHeight,t,"clientHeight")||vt,l=function(t,e,i){let s,n;if(void 0===e||void 0===i){const o=ge(t);if(o){const t=o.getBoundingClientRect(),a=me(o),r=_e(a,"border","width"),l=_e(a,"padding");e=t.width-l.width-r.width,i=t.height-l.height-r.height,s=pe(a.maxWidth,o,"clientWidth"),n=pe(a.maxHeight,o,"clientHeight")}else e=t.clientWidth,i=t.clientHeight}return{width:e,height:i,maxWidth:s||vt,maxHeight:n||vt}}(t,e,i);let{width:h,height:c}=l;if("content-box"===n.boxSizing){const t=_e(n,"border","width"),e=_e(n,"padding");h-=e.width+t.width,c-=e.height+t.height}return h=Math.max(0,h-o.width),c=Math.max(0,s?Math.floor(h/s):c-o.height),h=ve(Math.min(h,a,l.maxWidth)),c=ve(Math.min(c,r,l.maxHeight)),h&&!c&&(c=ve(h/2)),{width:h,height:c}}function Me(t,e,i){const s=e||1,n=Math.floor(t.height*s),o=Math.floor(t.width*s);t.height=n/s,t.width=o/s;const a=t.canvas;return a.style&&(i||!a.style.height&&!a.style.width)&&(a.style.height=`${t.height}px`,a.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(t.currentDevicePixelRatio=s,a.height=n,a.width=o,t.ctx.setTransform(s,0,0,s,0,0),!0)}const ke=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}();function Se(t,e){const i=xe(t,e),s=i&&i.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function Pe(t,e){return"native"in t?{x:t.x,y:t.y}:ye(t,e)}function De(t,e,i,s){const{controller:n,data:o,_sorted:a}=t,r=n._cachedMeta.iScale;if(r&&e===r.axis&&a&&o.length){const t=r._reversePixels?re:ae;if(!s)return t(o,e,i);if(n._sharedOptions){const s=o[0],n="function"==typeof s.getRange&&s.getRange(e);if(n){const s=t(o,e,i-n),a=t(o,e,i+n);return{lo:s.lo,hi:a.hi}}}}return{lo:0,hi:o.length-1}}function Ce(t,e,i,s,n){const o=t.getSortedVisibleDatasetMetas(),a=i[e];for(let t=0,i=o.length;t{t[r](n[a],s)&&o.push({element:t,datasetIndex:e,index:i}),t.inRange(n.x,n.y,s)&&(l=!0)})),i.intersect&&!l?[]:o}var Le={modes:{index(t,e,i,s){const n=Pe(e,t),o=i.axis||"x",a=i.intersect?Oe(t,n,o,s):Ae(t,n,o,!1,s),r=[];return a.length?(t.getSortedVisibleDatasetMetas().forEach((t=>{const e=a[0].index,i=t.data[e];i&&!i.skip&&r.push({element:i,datasetIndex:t.index,index:e})})),r):[]},dataset(t,e,i,s){const n=Pe(e,t),o=i.axis||"xy";let a=i.intersect?Oe(t,n,o,s):Ae(t,n,o,!1,s);if(a.length>0){const e=a[0].datasetIndex,i=t.getDatasetMeta(e).data;a=[];for(let t=0;tOe(t,Pe(e,t),i.axis||"xy",s),nearest:(t,e,i,s)=>Ae(t,Pe(e,t),i.axis||"xy",i.intersect,s),x:(t,e,i,s)=>(i.axis="x",Te(t,e,i,s)),y:(t,e,i,s)=>(i.axis="y",Te(t,e,i,s))}};const Re=new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/),Ee=new RegExp(/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/);function Ie(t,e){const i=(""+t).match(Re);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}function ze(t,e){const i={},s=U(e),n=s?Object.keys(e):e,o=U(t)?s?i=>K(t[i],t[e[i]]):e=>t[e]:()=>t;for(const t of n)i[t]=+o(t)||0;return i}function Fe(t){return ze(t,{top:"y",right:"x",bottom:"y",left:"x"})}function Be(t){return ze(t,["topLeft","topRight","bottomLeft","bottomRight"])}function Ve(t){const e=Fe(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function We(t,e){t=t||{},e=e||xt.font;let i=K(t.size,e.size);"string"==typeof i&&(i=parseInt(i,10));let s=K(t.style,e.style);s&&!(""+s).match(Ee)&&(console.warn('Invalid font style specified: "'+s+'"'),s="");const n={family:K(t.family,e.family),lineHeight:Ie(K(t.lineHeight,e.lineHeight),i),size:i,style:s,weight:K(t.weight,e.weight),string:""};return n.string=Yt(n),n}function Ne(t,e,i,s){let n,o,a,r=!0;for(n=0,o=t.length;ni&&0===t?0:t+e;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function je(t,e){return Object.assign(Object.create(t),e)}const $e=["left","top","right","bottom"];function Ye(t,e){return t.filter((t=>t.pos===e))}function Ue(t,e){return t.filter((t=>-1===$e.indexOf(t.pos)&&t.box.axis===e))}function Xe(t,e){return t.sort(((t,i)=>{const s=e?i:t,n=e?t:i;return s.weight===n.weight?s.index-n.index:s.weight-n.weight}))}function qe(t,e){const i=function(t){const e={};for(const i of t){const{stack:t,pos:s,stackWeight:n}=i;if(!t||!$e.includes(s))continue;const o=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=n}return e}(t),{vBoxMaxWidth:s,hBoxMaxHeight:n}=e;let o,a,r;for(o=0,a=t.length;o{s[t]=Math.max(e[t],i[t])})),s}return s(t?["left","right"]:["top","bottom"])}function Je(t,e,i,s){const n=[];let o,a,r,l,h,c;for(o=0,a=t.length,h=0;ot.box.fullSize)),!0),s=Xe(Ye(e,"left"),!0),n=Xe(Ye(e,"right")),o=Xe(Ye(e,"top"),!0),a=Xe(Ye(e,"bottom")),r=Ue(e,"x"),l=Ue(e,"y");return{fullSize:i,leftAndTop:s.concat(o),rightAndBottom:n.concat(l).concat(a).concat(r),chartArea:Ye(e,"chartArea"),vertical:s.concat(n).concat(l),horizontal:o.concat(a).concat(r)}}(t.boxes),l=r.vertical,h=r.horizontal;J(t.boxes,(t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()}));const c=l.reduce(((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1),0)||1,d=Object.freeze({outerWidth:e,outerHeight:i,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/c,hBoxMaxHeight:a/2}),u=Object.assign({},n);Ge(u,Ve(s));const f=Object.assign({maxPadding:u,w:o,h:a,x:n.left,y:n.top},n),g=qe(l.concat(h),d);Je(r.fullSize,f,d,g),Je(l,f,d,g),Je(h,f,d,g)&&Je(l,f,d,g),function(t){const e=t.maxPadding;function i(i){const s=Math.max(e[i]-t[i],0);return t[i]+=s,s}t.y+=i("top"),t.x+=i("left"),i("right"),i("bottom")}(f),ei(r.leftAndTop,f,d,g),f.x+=f.w,f.y+=f.h,ei(r.rightAndBottom,f,d,g),t.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},J(r.chartArea,(e=>{const i=e.box;Object.assign(i,t.chartArea),i.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})}))}};function si(t,e=[""],i=t,s,n=(()=>t[0])){ct(s)||(s=gi("_fallback",t));const o={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:i,_fallback:s,_getTarget:n,override:n=>si([n,...t],e,i,s)};return new Proxy(o,{deleteProperty:(e,i)=>(delete e[i],delete e._keys,delete t[0][i],!0),get:(i,s)=>li(i,s,(()=>function(t,e,i,s){let n;for(const o of e)if(n=gi(ai(o,t),i),ct(n))return ri(t,n)?ui(i,s,t,n):n}(s,e,t,i))),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>pi(t).includes(e),ownKeys:t=>pi(t),set:(t,e,i)=>((t._storage||(t._storage=n()))[e]=i,delete t[e],delete t._keys,!0)})}function ni(t,e,i,s){const n={_cacheable:!1,_proxy:t,_context:e,_subProxy:i,_stack:new Set,_descriptors:oi(t,s),setContext:e=>ni(t,e,i,s),override:n=>ni(t.override(n),e,i,s)};return new Proxy(n,{deleteProperty:(e,i)=>(delete e[i],delete t[i],!0),get:(t,e,i)=>li(t,e,(()=>function(t,e,i){const{_proxy:s,_context:n,_subProxy:o,_descriptors:a}=t;let r=s[e];dt(r)&&a.isScriptable(e)&&(r=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_stack:r}=i;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);r.add(t),e=e(o,a||s),r.delete(t),ri(t,e)&&(e=ui(n._scopes,n,t,e));return e}(e,r,t,i));Y(r)&&r.length&&(r=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_descriptors:r}=i;if(ct(o.index)&&s(t))e=e[o.index%e.length];else if(U(e[0])){const i=e,s=n._scopes.filter((t=>t!==i));e=[];for(const l of i){const i=ui(s,n,t,l);e.push(ni(i,o,a&&a[t],r))}}return e}(e,r,t,a.isIndexable));ri(e,r)&&(r=ni(r,n,o&&o[e],a));return r}(t,e,i))),getOwnPropertyDescriptor:(e,i)=>e._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,i)=>Reflect.has(t,i),ownKeys:()=>Reflect.ownKeys(t),set:(e,i,s)=>(t[i]=s,delete e[i],!0)})}function oi(t,e={scriptable:!0,indexable:!0}){const{_scriptable:i=e.scriptable,_indexable:s=e.indexable,_allKeys:n=e.allKeys}=t;return{allKeys:n,scriptable:i,indexable:s,isScriptable:dt(i)?i:()=>i,isIndexable:dt(s)?s:()=>s}}const ai=(t,e)=>t?t+ht(e):e,ri=(t,e)=>U(e)&&"adapters"!==t&&(null===Object.getPrototypeOf(e)||e.constructor===Object);function li(t,e,i){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];const s=i();return t[e]=s,s}function hi(t,e,i){return dt(t)?t(e,i):t}const ci=(t,e)=>!0===t?e:"string"==typeof t?lt(e,t):void 0;function di(t,e,i,s){for(const n of e){const e=ci(i,n);if(e){t.add(e);const n=hi(e._fallback,i,e);if(ct(n)&&n!==i&&n!==s)return n}else if(!1===e&&ct(s)&&i!==s)return null}return!1}function ui(t,e,i,s){const n=e._rootScopes,o=hi(e._fallback,i,s),a=[...t,...n],r=new Set;r.add(s);let l=fi(r,a,i,o||i);return null!==l&&((!ct(o)||o===i||(l=fi(r,a,o,l),null!==l))&&si(Array.from(r),[""],n,o,(()=>function(t,e,i){const s=t._getTarget();e in s||(s[e]={});const n=s[e];if(Y(n)&&U(i))return i;return n}(e,i,s))))}function fi(t,e,i,s){for(;i;)i=di(t,e,i,s);return i}function gi(t,e){for(const i of e){if(!i)continue;const e=i[t];if(ct(e))return e}}function pi(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const i of t)for(const t of Object.keys(i).filter((t=>!t.startsWith("_"))))e.add(t);return Array.from(e)}(t._scopes)),e}const mi=Number.EPSILON||1e-14,xi=(t,e)=>e"x"===t?"y":"x";function _i(t,e,i,s){const n=t.skip?e:t,o=e,a=i.skip?e:i,r=Bt(o,n),l=Bt(a,o);let h=r/(r+l),c=l/(r+l);h=isNaN(h)?0:h,c=isNaN(c)?0:c;const d=s*h,u=s*c;return{previous:{x:o.x-d*(a.x-n.x),y:o.y-d*(a.y-n.y)},next:{x:o.x+u*(a.x-n.x),y:o.y+u*(a.y-n.y)}}}function yi(t,e="x"){const i=bi(e),s=t.length,n=Array(s).fill(0),o=Array(s);let a,r,l,h=xi(t,0);for(a=0;a!t.skip))),"monotone"===e.cubicInterpolationMode)yi(t,n);else{let i=s?t[t.length-1]:t[0];for(o=0,a=t.length;o0===t||1===t,ki=(t,e,i)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*_t/i),Si=(t,e,i)=>Math.pow(2,-10*t)*Math.sin((t-e)*_t/i)+1,Pi={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*Mt),easeOutSine:t=>Math.sin(t*Mt),easeInOutSine:t=>-.5*(Math.cos(bt*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>Mi(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>Mi(t)?t:ki(t,.075,.3),easeOutElastic:t=>Mi(t)?t:Si(t,.075,.3),easeInOutElastic(t){const e=.1125;return Mi(t)?t:t<.5?.5*ki(2*t,e,.45):.5+.5*Si(2*t-1,e,.45)},easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-Pi.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},easeInOutBounce:t=>t<.5?.5*Pi.easeInBounce(2*t):.5*Pi.easeOutBounce(2*t-1)+.5};function Di(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:t.y+i*(e.y-t.y)}}function Ci(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:"middle"===s?i<.5?t.y:e.y:"after"===s?i<1?t.y:e.y:i>0?e.y:t.y}}function Oi(t,e,i,s){const n={x:t.cp2x,y:t.cp2y},o={x:e.cp1x,y:e.cp1y},a=Di(t,n,i),r=Di(n,o,i),l=Di(o,e,i),h=Di(a,r,i),c=Di(r,l,i);return Di(h,c,i)}const Ai=new Map;function Ti(t,e,i){return function(t,e){e=e||{};const i=t+JSON.stringify(e);let s=Ai.get(i);return s||(s=new Intl.NumberFormat(t,e),Ai.set(i,s)),s}(e,i).format(t)}function Li(t,e,i){return t?function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}}(e,i):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function Ri(t,e){let i,s;"ltr"!==e&&"rtl"!==e||(i=t.canvas.style,s=[i.getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=s)}function Ei(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Ii(t){return"angle"===t?{between:Nt,compare:Vt,normalize:Wt}:{between:$t,compare:(t,e)=>t-e,normalize:t=>t}}function zi({start:t,end:e,count:i,loop:s,style:n}){return{start:t%i,end:e%i,loop:s&&(e-t+1)%i==0,style:n}}function Fi(t,e,i){if(!i)return[t];const{property:s,start:n,end:o}=i,a=e.length,{compare:r,between:l,normalize:h}=Ii(s),{start:c,end:d,loop:u,style:f}=function(t,e,i){const{property:s,start:n,end:o}=i,{between:a,normalize:r}=Ii(s),l=e.length;let h,c,{start:d,end:u,loop:f}=t;if(f){for(d+=l,u+=l,h=0,c=l;hb||l(n,x,p)&&0!==r(n,x),v=()=>!b||0===r(o,p)||l(o,x,p);for(let t=c,i=c;t<=d;++t)m=e[t%a],m.skip||(p=h(m[s]),p!==x&&(b=l(p,n,o),null===_&&y()&&(_=0===r(p,n)?t:i),null!==_&&v()&&(g.push(zi({start:_,end:t,loop:u,count:a,style:f})),_=null),i=t,x=p));return null!==_&&g.push(zi({start:_,end:d,loop:u,count:a,style:f})),g}function Bi(t,e){const i=[],s=t.segments;for(let n=0;nn&&t[o%e].skip;)o--;return o%=e,{start:n,end:o}}(i,n,o,s);if(!0===s)return Wi(t,[{start:a,end:r,loop:o}],i,e);return Wi(t,function(t,e,i,s){const n=t.length,o=[];let a,r=e,l=t[e];for(a=e+1;a<=i;++a){const i=t[a%n];i.skip||i.stop?l.skip||(s=!1,o.push({start:e%n,end:(a-1)%n,loop:s}),e=r=i.stop?a:null):(r=a,l.skip&&(e=a)),l=i}return null!==r&&o.push({start:e%n,end:r%n,loop:s}),o}(i,a,rnull===t||""===t;const qi=!!ke&&{passive:!0};function Ki(t,e,i){t.canvas.removeEventListener(e,i,qi)}function Gi(t,e){for(const i of t)if(i===e||i.contains(e))return!0}function Zi(t,e,i){const s=t.canvas,n=new MutationObserver((t=>{let e=!1;for(const i of t)e=e||Gi(i.addedNodes,s),e=e&&!Gi(i.removedNodes,s);e&&i()}));return n.observe(document,{childList:!0,subtree:!0}),n}function Qi(t,e,i){const s=t.canvas,n=new MutationObserver((t=>{let e=!1;for(const i of t)e=e||Gi(i.removedNodes,s),e=e&&!Gi(i.addedNodes,s);e&&i()}));return n.observe(document,{childList:!0,subtree:!0}),n}const Ji=new Map;let ts=0;function es(){const t=window.devicePixelRatio;t!==ts&&(ts=t,Ji.forEach(((e,i)=>{i.currentDevicePixelRatio!==t&&e()})))}function is(t,i,s){const n=t.canvas,o=n&&ge(n);if(!o)return;const a=e(((t,e)=>{const i=o.clientWidth;s(t,e),i{const e=t[0],i=e.contentRect.width,s=e.contentRect.height;0===i&&0===s||a(i,s)}));return r.observe(o),function(t,e){Ji.size||window.addEventListener("resize",es),Ji.set(t,e)}(t,a),r}function ss(t,e,i){i&&i.disconnect(),"resize"===e&&function(t){Ji.delete(t),Ji.size||window.removeEventListener("resize",es)}(t)}function ns(t,i,s){const n=t.canvas,o=e((e=>{null!==t.ctx&&s(function(t,e){const i=Ui[t.type]||t.type,{x:s,y:n}=ye(t,e);return{type:i,chart:e,native:t,x:void 0!==s?s:null,y:void 0!==n?n:null}}(e,t))}),t,(t=>{const e=t[0];return[e,e.offsetX,e.offsetY]}));return function(t,e,i){t.addEventListener(e,i,qi)}(n,i,o),o}class os extends $i{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(function(t,e){const i=t.style,s=t.getAttribute("height"),n=t.getAttribute("width");if(t.$chartjs={initial:{height:s,width:n,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",Xi(n)){const e=Se(t,"width");void 0!==e&&(t.width=e)}if(Xi(s))if(""===t.style.height)t.height=t.width/(e||2);else{const e=Se(t,"height");void 0!==e&&(t.height=e)}}(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e.$chartjs)return!1;const i=e.$chartjs.initial;["height","width"].forEach((t=>{const s=i[t];$(s)?e.removeAttribute(t):e.setAttribute(t,s)}));const s=i.style||{};return Object.keys(s).forEach((t=>{e.style[t]=s[t]})),e.width=e.width,delete e.$chartjs,!0}addEventListener(t,e,i){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),n={attach:Zi,detach:Qi,resize:is}[e]||ns;s[e]=n(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];if(!s)return;({attach:ss,detach:ss,resize:ss}[e]||Ki)(t,e,s),i[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return we(t,e,i,s)}isAttached(t){const e=ge(t);return!(!e||!e.isConnected)}}function as(t){return!fe()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?Yi:os}var rs=Object.freeze({__proto__:null,_detectPlatform:as,BasePlatform:$i,BasicPlatform:Yi,DomPlatform:os});const ls="transparent",hs={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const s=W(t||ls),n=s.valid&&W(e||ls);return n&&n.valid?n.mix(s,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class cs{constructor(t,e,i,s){const n=e[i];s=Ne([t.to,s,n,t.from]);const o=Ne([t.from,n,s]);this._active=!0,this._fn=t.fn||hs[t.type||typeof o],this._easing=Pi[t.easing]||Pi.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=o,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const s=this._target[this._prop],n=i-this._start,o=this._duration-n;this._start=i,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=n,this._loop=!!t.loop,this._to=Ne([t.to,e,s,t.from]),this._from=Ne([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,s=this._prop,n=this._from,o=this._loop,a=this._to;let r;if(this._active=n!==a&&(o||e1?2-r:r,r=this._easing(Math.min(1,Math.max(0,r))),this._target[s]=this._fn(n,a,r))}wait(){const t=this._promises||(this._promises=[]);return new Promise(((e,i)=>{t.push({res:e,rej:i})}))}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let t=0;t"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),xt.set("animations",{colors:{type:"color",properties:["color","borderColor","backgroundColor"]},numbers:{type:"number",properties:["x","y","borderWidth","radius","tension"]}}),xt.describe("animations",{_fallback:"animation"}),xt.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>0|t}}}});class us{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!U(t))return;const e=this._properties;Object.getOwnPropertyNames(t).forEach((i=>{const s=t[i];if(!U(s))return;const n={};for(const t of ds)n[t]=s[t];(Y(s.properties)&&s.properties||[i]).forEach((t=>{t!==i&&e.has(t)||e.set(t,n)}))}))}_animateOptions(t,e){const i=e.options,s=function(t,e){if(!e)return;let i=t.options;if(!i)return void(t.options=e);i.$shared&&(t.options=i=Object.assign({},i,{$shared:!1,$animations:{}}));return i}(t,i);if(!s)return[];const n=this._createAnimations(s,i);return i.$shared&&function(t,e){const i=[],s=Object.keys(e);for(let e=0;e{t.options=i}),(()=>{})),n}_createAnimations(t,e){const i=this._properties,s=[],n=t.$animations||(t.$animations={}),o=Object.keys(e),a=Date.now();let r;for(r=o.length-1;r>=0;--r){const l=o[r];if("$"===l.charAt(0))continue;if("options"===l){s.push(...this._animateOptions(t,e));continue}const h=e[l];let c=n[l];const d=i.get(l);if(c){if(d&&c.active()){c.update(d,h,a);continue}c.cancel()}d&&d.duration?(n[l]=c=new cs(d,t,l,h),s.push(c)):t[l]=h}return s}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(a.add(this._chart,i),!0):void 0}}function fs(t,e){const i=t&&t.options||{},s=i.reverse,n=void 0===i.min?e:0,o=void 0===i.max?e:0;return{start:s?o:n,end:s?n:o}}function gs(t,e){const i=[],s=t._getSortedDatasetMetas(e);let n,o;for(n=0,o=s.length;n0||!i&&e<0)return n.index}return null}function _s(t,e){const{chart:i,_cachedMeta:s}=t,n=i._stacks||(i._stacks={}),{iScale:o,vScale:a,index:r}=s,l=o.axis,h=a.axis,c=function(t,e,i){return`${t.id}.${e.id}.${i.stack||i.type}`}(o,a,s),d=e.length;let u;for(let t=0;ti[t].axis===e)).shift()}function vs(t,e){const i=t.controller.index,s=t.vScale&&t.vScale.axis;if(s){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[s]||void 0===e[s][i])return;delete e[s][i]}}}const ws=t=>"reset"===t||"none"===t,Ms=(t,e)=>e?t:Object.assign({},t);class ks{constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.$context=void 0,this._syncList=[],this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=ms(t.vScale,t),this.addElements()}updateIndex(t){this.index!==t&&vs(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(t,e,i,s)=>"x"===t?e:"r"===t?s:i,n=e.xAxisID=K(i.xAxisID,ys(t,"x")),o=e.yAxisID=K(i.yAxisID,ys(t,"y")),a=e.rAxisID=K(i.rAxisID,ys(t,"r")),r=e.indexAxis,l=e.iAxisID=s(r,n,o,a),h=e.vAxisID=s(r,o,n,a);e.xScale=this.getScaleForId(n),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(l),e.vScale=this.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&de(this._data,this),t._stacked&&vs(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(U(e))this._data=function(t){const e=Object.keys(t),i=new Array(e.length);let s,n,o;for(s=0,n=e.length;s0&&i._parsed[t-1];if(!1===this._parsing)i._parsed=s,i._sorted=!0,h=s;else{h=Y(s[t])?this.parseArrayData(i,s,t,e):U(s[t])?this.parseObjectData(i,s,t,e):this.parsePrimitiveData(i,s,t,e);const n=()=>null===l[a]||d&&l[a]t&&!e.hidden&&e._stacked&&{keys:gs(i,!0),values:null})(e,i,this.chart),l={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:h,max:c}=function(t){const{min:e,max:i,minDefined:s,maxDefined:n}=t.getUserBounds();return{min:s?e:Number.NEGATIVE_INFINITY,max:n?i:Number.POSITIVE_INFINITY}}(a);let d,u;function f(){u=s[d];const e=u[a.axis];return!X(u[t.axis])||h>e||c=0;--d)if(!f()){this.updateRangeFromParsed(l,t,u,r);break}return l}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,n,o;for(s=0,n=e.length;s=0&&tthis.getContext(i,s)),c);return f.$shared&&(f.$shared=r,n[o]=Object.freeze(Ms(f,r))),f}_resolveAnimations(t,e,i){const s=this.chart,n=this._cachedDataOpts,o=`animation-${e}`,a=n[o];if(a)return a;let r;if(!1!==s.options.animation){const s=this.chart.config,n=s.datasetAnimationScopeKeys(this._type,e),o=s.getOptionScopes(this.getDataset(),n);r=s.createResolver(o,this.getContext(t,i,e))}const l=new us(s,r&&r.animations);return r&&r._cacheable&&(n[o]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||ws(t)||this.chart._animationsDisabled}updateElement(t,e,i,s){ws(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!ws(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,s){t.active=s;const n=this.getStyle(e,s);this._resolveAnimations(e,i,s).update(t,{options:!s&&this.getSharedOptions(n)||n})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,i=this._cachedMeta.data;for(const[t,e,i]of this._syncList)this[t](e,i);this._syncList=[];const s=i.length,n=e.length,o=Math.min(n,s);o&&this.parse(0,o),n>s?this._insertElements(s,n-s,t):n{for(t.length+=e,a=t.length-1;a>=o;a--)t[a]=t[a-e]};for(r(n),a=t;a{s[t]=i[t]&&i[t].active()?i[t]._to:this[t]})),s}}Ss.defaults={},Ss.defaultRoutes=void 0;const Ps={values:t=>Y(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const s=this.chart.options.locale;let n,o=t;if(i.length>1){const e=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));(e<1e-4||e>1e15)&&(n="scientific"),o=function(t,e){let i=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;Math.abs(i)>=1&&t!==Math.floor(t)&&(i=t-Math.floor(t));return i}(t,i)}const a=Pt(Math.abs(o)),r=Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:n,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),Ti(t,s,l)},logarithmic(t,e,i){if(0===t)return"0";const s=t/Math.pow(10,Math.floor(Pt(t)));return 1===s||2===s||5===s?Ps.numeric.call(this,t,e,i):""}};var Ds={formatters:Ps};function Cs(t,e){const i=t.options.ticks,s=i.maxTicksLimit||function(t){const e=t.options.offset,i=t._tickSize(),s=t._length/i+(e?0:1),n=t._maxLength/i;return Math.floor(Math.min(s,n))}(t),n=i.major.enabled?function(t){const e=[];let i,s;for(i=0,s=t.length;is)return function(t,e,i,s){let n,o=0,a=i[0];for(s=Math.ceil(s),n=0;nn)return e}return Math.max(n,1)}(n,e,s);if(o>0){let t,i;const s=o>1?Math.round((r-a)/(o-1)):null;for(Os(e,l,h,$(s)?0:a-s,a),t=0,i=o-1;te.lineWidth,tickColor:(t,e)=>e.color,offset:!1,borderDash:[],borderDashOffset:0,borderWidth:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Ds.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),xt.route("scale.ticks","color","","color"),xt.route("scale.grid","color","","borderColor"),xt.route("scale.grid","borderColor","","borderColor"),xt.route("scale.title","color","","color"),xt.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t}),xt.describe("scales",{_fallback:"scale"}),xt.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t});const As=(t,e,i)=>"top"===e||"left"===e?t[e]+i:t[e]-i;function Ts(t,e){const i=[],s=t.length/e,n=t.length;let o=0;for(;oa+r)))return h}function Rs(t){return t.drawTicks?t.tickLength:0}function Es(t,e){if(!t.display)return 0;const i=We(t.font,e),s=Ve(t.padding);return(Y(t.text)?t.text.length:1)*i.lineHeight+s.height}function Is(t,e,i){let n=s(t);return(i&&"right"!==e||!i&&"right"===e)&&(n=(t=>"left"===t?"right":"right"===t?"left":t)(n)),n}class zs extends Ss{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:i,_suggestedMax:s}=this;return t=q(t,Number.POSITIVE_INFINITY),e=q(e,Number.NEGATIVE_INFINITY),i=q(i,Number.POSITIVE_INFINITY),s=q(s,Number.NEGATIVE_INFINITY),{min:q(t,i),max:q(e,s),minDefined:X(t),maxDefined:X(e)}}getMinMax(t){let e,{min:i,max:s,minDefined:n,maxDefined:o}=this.getUserBounds();if(n&&o)return{min:i,max:s};const a=this.getMatchingVisibleMetas();for(let r=0,l=a.length;rs?s:i,s=n&&i>s?i:s,{min:q(i,q(s,i)),max:q(s,q(i,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){Q(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:n,ticks:o}=this.options,a=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=He(this,n,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const r=a=n||i<=1||!this.isHorizontal())return void(this.labelRotation=s);const h=this._getLabelSizes(),c=h.widest.width,d=h.highest.height,u=Ht(this.chart.width-c,0,this.maxWidth);o=t.offset?this.maxWidth/i:u/(i-1),c+6>o&&(o=u/(i-(t.offset?.5:1)),a=this.maxHeight-Rs(t.grid)-e.padding-Es(t.title,this.chart.options.font),r=Math.sqrt(c*c+d*d),l=It(Math.min(Math.asin(Ht((h.highest.height+6)/o,-1,1)),Math.asin(Ht(a/r,-1,1))-Math.asin(Ht(d/r,-1,1)))),l=Math.max(s,Math.min(n,l))),this.labelRotation=l}afterCalculateLabelRotation(){Q(this.options.afterCalculateLabelRotation,[this])}beforeFit(){Q(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:n}}=this,o=this._isVisible(),a=this.isHorizontal();if(o){const o=Es(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=Rs(n)+o):(t.height=this.maxHeight,t.width=Rs(n)+o),i.display&&this.ticks.length){const{first:e,last:s,widest:n,highest:o}=this._getLabelSizes(),r=2*i.padding,l=Et(this.labelRotation),h=Math.cos(l),c=Math.sin(l);if(a){const e=i.mirror?0:c*n.width+h*o.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=i.mirror?0:h*n.width+c*o.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,s,c,h)}}this._handleMargins(),a?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,s){const{ticks:{align:n,padding:o},position:a}=this.options,r=0!==this.labelRotation,l="top"!==a&&"x"===this.axis;if(this.isHorizontal()){const a=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1);let c=0,d=0;r?l?(c=s*t.width,d=i*e.height):(c=i*t.height,d=s*e.width):"start"===n?d=e.width:"end"===n?c=t.width:(c=t.width/2,d=e.width/2),this.paddingLeft=Math.max((c-a+o)*this.width/(this.width-a),0),this.paddingRight=Math.max((d-h+o)*this.width/(this.width-h),0)}else{let i=e.height/2,s=t.height/2;"start"===n?(i=0,s=t.height):"end"===n&&(i=e.height,s=0),this.paddingTop=i+o,this.paddingBottom=s+o}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){Q(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,i;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,i=t.length;e{const i=t.gc,s=i.length/2;let n;if(s>e){for(n=0;n({width:n[t]||0,height:o[t]||0});return{first:v(0),last:v(e-1),widest:v(_),highest:v(y),widths:n,heights:o}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return jt(this._alignToPixels?qt(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&ta*s?a/i:r/s:r*s0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:n,position:o}=s,a=n.offset,r=this.isHorizontal(),l=this.ticks.length+(a?1:0),h=Rs(n),c=[],d=n.setContext(this.getContext()),u=d.drawBorder?d.borderWidth:0,f=u/2,g=function(t){return qt(i,t,u)};let p,m,x,b,_,y,v,w,M,k,S,P;if("top"===o)p=g(this.bottom),y=this.bottom-h,w=p-f,k=g(t.top)+f,P=t.bottom;else if("bottom"===o)p=g(this.top),k=t.top,P=g(t.bottom)-f,y=p+f,w=this.top+h;else if("left"===o)p=g(this.right),_=this.right-h,v=p-f,M=g(t.left)+f,S=t.right;else if("right"===o)p=g(this.left),M=t.left,S=g(t.right)-f,_=p+f,v=this.left+h;else if("x"===e){if("center"===o)p=g((t.top+t.bottom)/2+.5);else if(U(o)){const t=Object.keys(o)[0],e=o[t];p=g(this.chart.scales[t].getPixelForValue(e))}k=t.top,P=t.bottom,y=p+f,w=y+h}else if("y"===e){if("center"===o)p=g((t.left+t.right)/2);else if(U(o)){const t=Object.keys(o)[0],e=o[t];p=g(this.chart.scales[t].getPixelForValue(e))}_=p-f,v=_-h,M=t.left,S=t.right}const D=K(s.ticks.maxTicksLimit,l),C=Math.max(1,Math.ceil(l/D));for(m=0;me.value===t));if(i>=0){return e.setContext(this.getContext(i)).lineWidth}return 0}drawGrid(t){const e=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let n,o;const a=(t,e,s)=>{s.width&&s.color&&(i.save(),i.lineWidth=s.width,i.strokeStyle=s.color,i.setLineDash(s.borderDash||[]),i.lineDashOffset=s.borderDashOffset,i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke(),i.restore())};if(e.display)for(n=0,o=s.length;n{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:i+1,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let n,o;for(n=0,o=e.length;n{const s=i.split("."),n=s.pop(),o=[t].concat(s).join("."),a=e[i].split("."),r=a.pop(),l=a.join(".");xt.route(o,n,l,r)}))}(e,t.defaultRoutes);t.descriptors&&xt.describe(e,t.descriptors)}(t,o,i),this.override&&xt.override(t.id,t.overrides)),o}get(t){return this.items[t]}unregister(t){const e=this.items,i=t.id,s=this.scope;i in e&&delete e[i],s&&i in xt[s]&&(delete xt[s][i],this.override&&delete ft[i])}}var Bs=new class{constructor(){this.controllers=new Fs(ks,"datasets",!0),this.elements=new Fs(Ss,"elements"),this.plugins=new Fs(Object,"plugins"),this.scales=new Fs(zs,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){[...e].forEach((e=>{const s=i||this._getRegistryForType(e);i||s.isForType(e)||s===this.plugins&&e.id?this._exec(t,s,e):J(e,(e=>{const s=i||this._getRegistryForType(e);this._exec(t,s,e)}))}))}_exec(t,e,i){const s=ht(t);Q(i["before"+s],[],i),e[t](i),Q(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;et.filter((t=>!e.some((e=>t.plugin.id===e.plugin.id))));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function Ws(t,e){return e||!1!==t?!0===t?{}:t:null}function Ns(t,e,i,s){const n=t.pluginScopeKeys(e),o=t.getOptionScopes(i,n);return t.createResolver(o,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Hs(t,e){const i=xt.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function js(t,e){return"x"===t||"y"===t?t:e.axis||("top"===(i=e.position)||"bottom"===i?"x":"left"===i||"right"===i?"y":void 0)||t.charAt(0).toLowerCase();var i}function $s(t){const e=t.options||(t.options={});e.plugins=K(e.plugins,{}),e.scales=function(t,e){const i=ft[t.type]||{scales:{}},s=e.scales||{},n=Hs(t.type,e),o=Object.create(null),a=Object.create(null);return Object.keys(s).forEach((t=>{const e=s[t];if(!U(e))return console.error(`Invalid scale configuration for scale: ${t}`);if(e._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);const r=js(t,e),l=function(t,e){return t===e?"_index_":"_value_"}(r,n),h=i.scales||{};o[r]=o[r]||t,a[t]=ot(Object.create(null),[{axis:r},e,h[r],h[l]])})),t.data.datasets.forEach((i=>{const n=i.type||t.type,r=i.indexAxis||Hs(n,e),l=(ft[n]||{}).scales||{};Object.keys(l).forEach((t=>{const e=function(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}(t,r),n=i[e+"AxisID"]||o[e]||e;a[n]=a[n]||Object.create(null),ot(a[n],[{axis:e},s[n],l[t]])}))})),Object.keys(a).forEach((t=>{const e=a[t];ot(e,[xt.scales[e.type],xt.scale])})),a}(t,e)}function Ys(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const Us=new Map,Xs=new Set;function qs(t,e){let i=Us.get(t);return i||(i=e(),Us.set(t,i),Xs.add(i)),i}const Ks=(t,e,i)=>{const s=lt(e,i);void 0!==s&&t.add(s)};class Gs{constructor(t){this._config=function(t){return(t=t||{}).data=Ys(t.data),$s(t),t}(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Ys(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),$s(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return qs(t,(()=>[[`datasets.${t}`,""]]))}datasetAnimationScopeKeys(t,e){return qs(`${t}.transition.${e}`,(()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]]))}datasetElementScopeKeys(t,e){return qs(`${t}-${e}`,(()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]]))}pluginScopeKeys(t){const e=t.id;return qs(`${this.type}-plugin-${e}`,(()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]]))}_cachedScopes(t,e){const i=this._scopeCache;let s=i.get(t);return s&&!e||(s=new Map,i.set(t,s)),s}getOptionScopes(t,e,i){const{options:s,type:n}=this,o=this._cachedScopes(t,i),a=o.get(e);if(a)return a;const r=new Set;e.forEach((e=>{t&&(r.add(t),e.forEach((e=>Ks(r,t,e)))),e.forEach((t=>Ks(r,s,t))),e.forEach((t=>Ks(r,ft[n]||{},t))),e.forEach((t=>Ks(r,xt,t))),e.forEach((t=>Ks(r,gt,t)))}));const l=Array.from(r);return 0===l.length&&l.push(Object.create(null)),Xs.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,ft[e]||{},xt.datasets[e]||{},{type:e},xt,gt]}resolveNamedOptions(t,e,i,s=[""]){const n={$shared:!0},{resolver:o,subPrefixes:a}=Zs(this._resolverCache,t,s);let r=o;if(function(t,e){const{isScriptable:i,isIndexable:s}=oi(t);for(const n of e){const e=i(n),o=s(n),a=(o||e)&&t[n];if(e&&(dt(a)||Qs(a))||o&&Y(a))return!0}return!1}(o,e)){n.$shared=!1;r=ni(o,i=dt(i)?i():i,this.createResolver(t,i,a))}for(const t of e)n[t]=r[t];return n}createResolver(t,e,i=[""],s){const{resolver:n}=Zs(this._resolverCache,t,i);return U(e)?ni(n,e,void 0,s):n}}function Zs(t,e,i){let s=t.get(e);s||(s=new Map,t.set(e,s));const n=i.join();let o=s.get(n);if(!o){o={resolver:si(e,i),subPrefixes:i.filter((t=>!t.toLowerCase().includes("hover")))},s.set(n,o)}return o}const Qs=t=>U(t)&&Object.getOwnPropertyNames(t).reduce(((e,i)=>e||dt(t[i])),!1);const Js=["top","bottom","left","right","chartArea"];function tn(t,e){return"top"===t||"bottom"===t||-1===Js.indexOf(t)&&"x"===e}function en(t,e){return function(i,s){return i[t]===s[t]?i[e]-s[e]:i[t]-s[t]}}function sn(t){const e=t.chart,i=e.options.animation;e.notifyPlugins("afterRender"),Q(i&&i.onComplete,[t],e)}function nn(t){const e=t.chart,i=e.options.animation;Q(i&&i.onProgress,[t],e)}function on(t){return fe()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const an={},rn=t=>{const e=on(t);return Object.values(an).filter((t=>t.canvas===e)).pop()};function ln(t,e,i){const s=Object.keys(t);for(const n of s){const s=+n;if(s>=e){const o=t[n];delete t[n],(i>0||s>e)&&(t[s+i]=o)}}}class hn{constructor(t,e){const s=this.config=new Gs(e),n=on(t),o=rn(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas can be reused.");const r=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||as(n)),this.platform.updateConfig(s);const l=this.platform.acquireContext(n,r.aspectRatio),h=l&&l.canvas,c=h&&h.height,d=h&&h.width;this.id=j(),this.ctx=l,this.canvas=h,this.width=d,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Vs,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=i((t=>this.update(t)),r.resizeDelay||0),this._dataChanges=[],an[this.id]=this,l&&h?(a.listen(this,"complete",sn),a.listen(this,"progress",nn),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:s,_aspectRatio:n}=this;return $(t)?e&&n?n:s?i/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Me(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Kt(this.canvas,this.ctx),this}stop(){return a.stop(this),this}resize(t,e){a.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,s=this.canvas,n=i.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(s,t,e,n),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,Me(this,a,!0)&&(this.notifyPlugins("resize",{size:o}),Q(i.onResize,[this,o],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){J(this.options.scales||{},((t,e)=>{t.id=e}))}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce(((t,e)=>(t[e]=!1,t)),{});let n=[];e&&(n=n.concat(Object.keys(e).map((t=>{const i=e[t],s=js(t,i),n="r"===s,o="x"===s;return{options:i,dposition:n?"chartArea":o?"bottom":"left",dtype:n?"radialLinear":o?"category":"linear"}})))),J(n,(e=>{const n=e.options,o=n.id,a=js(o,n),r=K(n.type,e.dtype);void 0!==n.position&&tn(n.position,a)===tn(e.dposition)||(n.position=e.dposition),s[o]=!0;let l=null;if(o in i&&i[o].type===r)l=i[o];else{l=new(Bs.getScale(r))({id:o,type:r,ctx:this.ctx,chart:this}),i[l.id]=l}l.init(n,t)})),J(s,((t,e)=>{t||delete i[e]})),J(i,(t=>{ii.configure(this,t,t.options),ii.addBox(this,t)}))}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort(((t,e)=>t.index-e.index)),i>e){for(let t=e;te.length&&delete this._stacks,t.forEach(((t,i)=>{0===e.filter((e=>e===t._dataset)).length&&this._destroyDatasetMeta(i)}))}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=e.length;i{this.getDatasetMeta(e).controller.reset()}),this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const n=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let t=0,e=this.data.datasets.length;t{t.reset()})),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(en("z","_idx")),this._lastEvent&&this._eventHandler(this._lastEvent,!0),this.render()}_updateScales(){J(this.scales,(t=>{ii.removeBox(this,t)})),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);ut(e,i)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:n}of e){ln(t,s,"_removeElements"===i?-n:n)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,i=e=>new Set(t.filter((t=>t[0]===e)).map(((t,e)=>e+","+t.splice(1).join(",")))),s=i(0);for(let t=1;tt.split(","))).map((t=>({method:t[1],start:+t[2],count:+t[3]})))}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;ii.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],J(this.boxes,(t=>{i&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))}),this),this._layers.forEach(((t,e)=>{t._idx=e})),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let t=0,e=this.data.datasets.length;t=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,s=!i.disabled,n=this.chartArea,o={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",o)&&(s&&Qt(e,{left:!1===i.left?0:n.left-i.left,right:!1===i.right?this.width:n.right+i.right,top:!1===i.top?0:n.top-i.top,bottom:!1===i.bottom?this.height:n.bottom+i.bottom}),t.controller.draw(),s&&Jt(e),o.cancelable=!1,this.notifyPlugins("afterDatasetDraw",o))}getElementsAtEventForMode(t,e,i,s){const n=Le.modes[e];return"function"==typeof n?n(this,t,i,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let s=i.filter((t=>t&&t._dataset===e)).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=je(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",n=this.getDatasetMeta(t),o=n.controller._resolveAnimations(void 0,s);ct(e)?(n.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),o.update(n,{visible:i}),this.update((e=>e.datasetIndex===t?s:void 0)))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),a.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,i,s),t[i]=s},s=(t,e,i)=>{t.offsetX=e,t.offsetY=i,this._eventHandler(t)};J(this.options.events,(t=>i(t,s)))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(i,s)=>{e.addEventListener(this,i,s),t[i]=s},s=(i,s)=>{t[i]&&(e.removeEventListener(this,i,s),delete t[i])},n=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",n),i("detach",o)};o=()=>{this.attached=!1,s("resize",n),this._stop(),this._resize(0,0),i("attach",a)},e.isAttached(this.canvas)?a():o()}unbindEvents(){J(this._listeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._listeners={},J(this._responsiveListeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const s=i?"set":"remove";let n,o,a,r;for("dataset"===e&&(n=this.getDatasetMeta(t[0].datasetIndex),n.controller["_"+s+"DatasetHoverStyle"]()),a=0,r=t.length;a{const i=this.getDatasetMeta(t);if(!i)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:i.data[e],index:e}}));!tt(i,e)&&(this._active=i,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}_updateHoverStyles(t,e,i){const s=this.options.hover,n=(t,e)=>t.filter((t=>!e.some((e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)))),o=n(e,t),a=i?t:n(t,e);o.length&&this.updateHoverStyle(o,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0},s=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",i,s))return;const n=this._handleEvent(t,e);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(n||i.changed)&&this.render(),this}_handleEvent(t,e){const{_active:i=[],options:s}=this,n=s.hover,o=e;let a=[],r=!1,l=null;return"mouseout"!==t.type&&(a=this.getElementsAtEventForMode(t,n.mode,n,o),l="click"===t.type?this._lastEvent:t),this._lastEvent=null,Zt(t,this.chartArea,this._minPadding)&&(Q(s.onHover,[t,a,this],this),"mouseup"!==t.type&&"click"!==t.type&&"contextmenu"!==t.type||Q(s.onClick,[t,a,this],this)),r=!tt(a,i),(r||e)&&(this._active=a,this._updateHoverStyles(a,i,e)),this._lastEvent=l,r}}const cn=()=>J(hn.instances,(t=>t._plugins.invalidate())),dn=!0;function un(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}Object.defineProperties(hn,{defaults:{enumerable:dn,value:xt},instances:{enumerable:dn,value:an},overrides:{enumerable:dn,value:ft},registry:{enumerable:dn,value:Bs},version:{enumerable:dn,value:"3.6.1"},getChart:{enumerable:dn,value:rn},register:{enumerable:dn,value:(...t)=>{Bs.add(...t),cn()}},unregister:{enumerable:dn,value:(...t)=>{Bs.remove(...t),cn()}}});class fn{constructor(t){this.options=t||{}}formats(){return un()}parse(t,e){return un()}format(t,e){return un()}add(t,e,i){return un()}diff(t,e,i){return un()}startOf(t,e,i){return un()}endOf(t,e){return un()}}fn.override=function(t){Object.assign(fn.prototype,t)};var gn={_date:fn};function pn(t){const e=t.iScale,i=function(t,e){if(!t._cache.$bar){const i=t.getMatchingVisibleMetas(e);let s=[];for(let e=0,n=i.length;et-e)))}return t._cache.$bar}(e,t.type);let s,n,o,a,r=e._length;const l=()=>{32767!==o&&-32768!==o&&(ct(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(s=0,n=i.length;sMath.abs(r)&&(l=r,h=a),e[i.axis]=h,e._custom={barStart:l,barEnd:h,start:n,end:o,min:a,max:r}}(t,e,i,s):e[i.axis]=i.parse(t,s),e}function xn(t,e,i,s){const n=t.iScale,o=t.vScale,a=n.getLabels(),r=n===o,l=[];let h,c,d,u;for(h=i,c=i+s;ht.x,i="left",s="right"):(e=t.base=i?1:-1)}(c,e,o)*n,d===o&&(p-=c/2),h=p+c),p===e.getPixelForValue(o)){const t=Dt(c)*e.getLineWidthForValue(o)/2;p+=t,c-=t}return{size:c,base:p,head:h,center:h+c/2}}_calculateBarIndexPixels(t,e){const i=e.scale,s=this.options,n=s.skipNull,o=K(s.maxBarThickness,1/0);let a,r;if(e.grouped){const i=n?this._getStackCount(t):e.stackCount,l="flex"===s.barThickness?function(t,e,i,s){const n=e.pixels,o=n[t];let a=t>0?n[t-1]:null,r=t=0;--i)e=Math.max(e,t[i].size(this.resolveDataElementOptions(i))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,{xScale:i,yScale:s}=e,n=this.getParsed(t),o=i.getLabelForValue(n.x),a=s.getLabelForValue(n.y),r=n._custom;return{label:e.label,value:"("+o+", "+a+(r?", "+r:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a}=this._cachedMeta,r=this.resolveDataElementOptions(e,s),l=this.getSharedOptions(r),h=this.includeOptions(s,l),c=o.axis,d=a.axis;for(let r=e;r""}}}};class Sn extends ks{constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,s=this._cachedMeta;if(!1===this._parsing)s._parsed=i;else{let n,o,a=t=>+i[t];if(U(i[t])){const{key:t="value"}=this._parsing;a=e=>+lt(i[e],t)}for(n=t,o=t+e;nNt(t,r,l,!0)?1:Math.max(e,e*i,s,s*i),g=(t,e,s)=>Nt(t,r,l,!0)?-1:Math.min(e,e*i,s,s*i),p=f(0,h,d),m=f(Mt,c,u),x=g(bt,h,d),b=g(bt+Mt,c,u);s=(p-x)/2,n=(m-b)/2,o=-(p+x)/2,a=-(m+b)/2}return{ratioX:s,ratioY:n,offsetX:o,offsetY:a}}(c,h,r),p=(i.width-o)/d,m=(i.height-o)/u,x=Math.max(Math.min(p,m)/2,0),b=Z(this.options.radius,x),_=(b-Math.max(b*r,0))/this._getVisibleDatasetWeightTotal();this.offsetX=f*b,this.offsetY=g*b,s.total=this.calculateTotal(),this.outerRadius=b-_*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-_*l,0),this.updateElements(n,0,n.length,t)}_circumference(t,e){const i=this.options,s=this._cachedMeta,n=this._getCircumference();return e&&i.animation.animateRotate||!this.chart.getDataVisibility(t)||null===s._parsed[t]||s.data[t].hidden?0:this.calculateCircumference(s._parsed[t]*n/_t)}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.chartArea,r=o.options.animation,l=(a.left+a.right)/2,h=(a.top+a.bottom)/2,c=n&&r.animateScale,d=c?0:this.innerRadius,u=c?0:this.outerRadius,f=this.resolveDataElementOptions(e,s),g=this.getSharedOptions(f),p=this.includeOptions(s,g);let m,x=this._getRotation();for(m=0;m0&&!isNaN(t)?_t*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=Ti(e._parsed[t],i.options.locale);return{label:s[t]||"",value:n}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,n,o,a,r;if(!t)for(s=0,n=i.data.datasets.length;s"spacing"!==t,_indexable:t=>"spacing"!==t},Sn.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map(((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label(t){let e=t.label;const i=": "+t.formattedValue;return Y(e)?(e=e.slice(),e[0]+=i):e+=i,e}}}}};class Pn extends ks{initialize(){this.enableOptionSharing=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:i,data:s=[],_dataset:n}=e,o=this.chart._animationsDisabled;let{start:a,count:r}=function(t,e,i){const s=e.length;let n=0,o=s;if(t._sorted){const{iScale:a,_parsed:r}=t,l=a.axis,{min:h,max:c,minDefined:d,maxDefined:u}=a.getUserBounds();d&&(n=Ht(Math.min(ae(r,a.axis,h).lo,i?s:ae(e,l,a.getPixelForValue(h)).lo),0,s-1)),o=u?Ht(Math.max(ae(r,a.axis,c).hi+1,i?0:ae(e,l,a.getPixelForValue(c)).hi+1),n,s)-n:s-n}return{start:n,count:o}}(e,s,o);this._drawStart=a,this._drawCount=r,function(t){const{xScale:e,yScale:i,_scaleRanges:s}=t,n={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!s)return t._scaleRanges=n,!0;const o=s.xmin!==e.min||s.xmax!==e.max||s.ymin!==i.min||s.ymax!==i.max;return Object.assign(s,n),o}(e)&&(a=0,r=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!n._decimated,i.points=s;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(i,void 0,{animated:!o,options:l},t),this.updateElements(s,a,r,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a,_stacked:r,_dataset:l}=this._cachedMeta,h=this.resolveDataElementOptions(e,s),c=this.getSharedOptions(h),d=this.includeOptions(s,c),u=o.axis,f=a.axis,{spanGaps:g,segment:p}=this.options,m=At(g)?g:Number.POSITIVE_INFINITY,x=this.chart._animationsDisabled||n||"none"===s;let b=e>0&&this.getParsed(e-1);for(let h=e;h0&&i[u]-b[u]>m,p&&(g.parsed=i,g.raw=l.data[h]),d&&(g.options=c||this.resolveDataElementOptions(h,e.active?"active":s)),x||this.updateElement(e,h,g,s),b=i}this.updateSharedOptions(c,s,h)}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,n,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}Pn.id="line",Pn.defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1},Pn.overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};class Dn extends ks{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=Ti(e._parsed[t].r,i.options.locale);return{label:s[t]||"",value:n}}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),n=Math.max(s/2,0),o=(n-Math.max(i.cutoutPercentage?n/100*i.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=n-o*this.index,this.innerRadius=this.outerRadius-o}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=this.getDataset(),r=o.options.animation,l=this._cachedMeta.rScale,h=l.xCenter,c=l.yCenter,d=l.getIndexAngle(0)-.5*bt;let u,f=d;const g=360/this.countVisibleElements();for(u=0;u{!isNaN(t.data[s])&&this.chart.getDataVisibility(s)&&i++})),i}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?Et(this.resolveDataElementOptions(t,e).angle||i):0}}Dn.id="polarArea",Dn.defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0},Dn.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i}}=t.legend.options;return e.labels.map(((e,s)=>{const n=t.getDatasetMeta(0).controller.getStyle(s);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(s),index:s}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label:t=>t.chart.data.labels[t.dataIndex]+": "+t.formattedValue}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};class Cn extends Sn{}Cn.id="pie",Cn.defaults={cutout:0,rotation:0,circumference:360,radius:"100%"};class On extends ks{getLabelAndValue(t){const e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}update(t){const e=this._cachedMeta,i=e.dataset,s=e.data||[],n=e.iScale.getLabels();if(i.points=s,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:!0,_fullLoop:n.length===s.length,options:e};this.updateElement(i,void 0,o,t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,i,s){const n=this.getDataset(),o=this._cachedMeta.rScale,a="reset"===s;for(let r=e;r"",label:t=>"("+t.label+", "+t.formattedValue+")"}}},scales:{x:{type:"linear"},y:{type:"linear"}}};var Tn=Object.freeze({__proto__:null,BarController:Mn,BubbleController:kn,DoughnutController:Sn,LineController:Pn,PolarAreaController:Dn,PieController:Cn,RadarController:On,ScatterController:An});function Ln(t,e,i){const{startAngle:s,pixelMargin:n,x:o,y:a,outerRadius:r,innerRadius:l}=e;let h=n/r;t.beginPath(),t.arc(o,a,r,s-h,i+h),l>n?(h=n/l,t.arc(o,a,l,i+h,s-h,!0)):t.arc(o,a,n,i+Mt,s-Mt),t.closePath(),t.clip()}function Rn(t,e,i,s){const n=ze(t.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]);const o=(i-e)/2,a=Math.min(o,s*e/2),r=t=>{const e=(i-Math.min(o,t))*s/2;return Ht(t,0,Math.min(o,e))};return{outerStart:r(n.outerStart),outerEnd:r(n.outerEnd),innerStart:Ht(n.innerStart,0,a),innerEnd:Ht(n.innerEnd,0,a)}}function En(t,e,i,s){return{x:i+t*Math.cos(e),y:s+t*Math.sin(e)}}function In(t,e,i,s,n){const{x:o,y:a,startAngle:r,pixelMargin:l,innerRadius:h}=e,c=Math.max(e.outerRadius+s+i-l,0),d=h>0?h+s+i+l:0;let u=0;const f=n-r;if(s){const t=((h>0?h-s:0)+(c>0?c-s:0))/2;u=(f-(0!==t?f*t/(t+s):f))/2}const g=(f-Math.max(.001,f*c-i/bt)/c)/2,p=r+g+u,m=n-g-u,{outerStart:x,outerEnd:b,innerStart:_,innerEnd:y}=Rn(e,d,c,m-p),v=c-x,w=c-b,M=p+x/v,k=m-b/w,S=d+_,P=d+y,D=p+_/S,C=m-y/P;if(t.beginPath(),t.arc(o,a,c,M,k),b>0){const e=En(w,k,o,a);t.arc(e.x,e.y,b,k,m+Mt)}const O=En(P,m,o,a);if(t.lineTo(O.x,O.y),y>0){const e=En(P,C,o,a);t.arc(e.x,e.y,y,m+Mt,C+Math.PI)}if(t.arc(o,a,d,m-y/d,p+_/d,!0),_>0){const e=En(S,D,o,a);t.arc(e.x,e.y,_,D+Math.PI,p-Mt)}const A=En(v,p,o,a);if(t.lineTo(A.x,A.y),x>0){const e=En(v,M,o,a);t.arc(e.x,e.y,x,p-Mt,M)}t.closePath()}function zn(t,e,i,s,n){const{options:o}=e,a="inner"===o.borderAlign;o.borderWidth&&(a?(t.lineWidth=2*o.borderWidth,t.lineJoin="round"):(t.lineWidth=o.borderWidth,t.lineJoin="bevel"),e.fullCircles&&function(t,e,i){const{x:s,y:n,startAngle:o,pixelMargin:a,fullCircles:r}=e,l=Math.max(e.outerRadius-a,0),h=e.innerRadius+a;let c;for(i&&Ln(t,e,o+_t),t.beginPath(),t.arc(s,n,h,o+_t,o,!0),c=0;c=_t||Nt(n,a,r),f=$t(o,l+d,h+d);return u&&f}getCenterPoint(t){const{x:e,y:i,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius","circumference"],t),{offset:r,spacing:l}=this.options,h=(s+n)/2,c=(o+a+l+r)/2;return{x:e+Math.cos(h)*c,y:i+Math.sin(h)*c}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:i}=this,s=(e.offset||0)/2,n=(e.spacing||0)/2;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=i>_t?Math.floor(i/_t):0,0===i||this.innerRadius<0||this.outerRadius<0)return;t.save();let o=0;if(s){o=s/2;const e=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(e)*o,Math.sin(e)*o),this.circumference>=bt&&(o=s)}t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor;const a=function(t,e,i,s){const{fullCircles:n,startAngle:o,circumference:a}=e;let r=e.endAngle;if(n){In(t,e,i,s,o+_t);for(let e=0;er&&o>r;return{count:s,start:l,loop:e.loop,ilen:h(a+(h?r-t:t))%o,_=()=>{f!==g&&(t.lineTo(m,g),t.lineTo(m,f),t.lineTo(m,p))};for(l&&(d=n[b(0)],t.moveTo(d.x,d.y)),c=0;c<=r;++c){if(d=n[b(c)],d.skip)continue;const e=d.x,i=d.y,s=0|e;s===u?(ig&&(g=i),m=(x*m+e)/++x):(_(),t.lineTo(e,i),u=s,x=0,f=g=i),p=i}_()}function jn(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||i)?Hn:Nn}Fn.id="arc",Fn.defaults={borderAlign:"center",borderColor:"#fff",borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0},Fn.defaultRoutes={backgroundColor:"backgroundColor"};const $n="function"==typeof Path2D;function Yn(t,e,i,s){$n&&!e.options.segment?function(t,e,i,s){let n=e._path;n||(n=e._path=new Path2D,e.path(n,i,s)&&n.closePath()),Bn(t,e.options),t.stroke(n)}(t,e,i,s):function(t,e,i,s){const{segments:n,options:o}=e,a=jn(e);for(const r of n)Bn(t,o,r.style),t.beginPath(),a(t,e,r,{start:i,end:i+s-1})&&t.closePath(),t.stroke()}(t,e,i,s)}class Un extends Ss{constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const i=this.options;if((i.tension||"monotone"===i.cubicInterpolationMode)&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;wi(this._points,i,t,s,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Vi(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],n=this.points,o=Bi(this,{property:e,start:s,end:s});if(!o.length)return;const a=[],r=function(t){return t.stepped?Ci:t.tension||"monotone"===t.cubicInterpolationMode?Oi:Di}(i);let l,h;for(l=0,h=o.length;l"borderDash"!==t&&"fill"!==t};class qn extends Ss{constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,e,i){const s=this.options,{x:n,y:o}=this.getProps(["x","y"],i);return Math.pow(t-n,2)+Math.pow(e-o,2){so(t)}))}var oo={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,i)=>{if(!i.enabled)return void no(t);const s=t.width;t.data.datasets.forEach(((e,n)=>{const{_data:o,indexAxis:a}=e,r=t.getDatasetMeta(n),l=o||e.data;if("y"===Ne([a,t.options.indexAxis]))return;if("line"!==r.type)return;const h=t.scales[r.xAxisID];if("linear"!==h.type&&"time"!==h.type)return;if(t.options.parsing)return;let{start:c,count:d}=function(t,e){const i=e.length;let s,n=0;const{iScale:o}=t,{min:a,max:r,minDefined:l,maxDefined:h}=o.getUserBounds();return l&&(n=Ht(ae(e,o.axis,a).lo,0,i-1)),s=h?Ht(ae(e,o.axis,r).hi+1,n,i)-n:i-n,{start:n,count:s}}(r,l);if(d<=(i.threshold||4*s))return void so(e);let u;switch($(o)&&(e._data=l,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),i.algorithm){case"lttb":u=function(t,e,i,s,n){const o=n.samples||s;if(o>=i)return t.slice(e,e+i);const a=[],r=(i-2)/(o-2);let l=0;const h=e+i-1;let c,d,u,f,g,p=e;for(a[l++]=t[p],c=0;cu&&(u=f,d=t[s],g=s);a[l++]=d,p=g}return a[l++]=t[h],a}(l,c,d,s,i);break;case"min-max":u=function(t,e,i,s){let n,o,a,r,l,h,c,d,u,f,g=0,p=0;const m=[],x=e+i-1,b=t[e].x,_=t[x].x-b;for(n=e;nf&&(f=r,c=n),g=(p*g+o.x)/++p;else{const i=n-1;if(!$(h)&&!$(c)){const e=Math.min(h,c),s=Math.max(h,c);e!==d&&e!==i&&m.push({...t[e],x:g}),s!==d&&s!==i&&m.push({...t[s],x:g})}n>0&&i!==d&&m.push(t[i]),m.push(o),l=e,p=0,u=f=r,h=c=d=n}}return m}(l,c,d,s);break;default:throw new Error(`Unsupported decimation algorithm '${i.algorithm}'`)}e._decimated=u}))},destroy(t){no(t)}};function ao(t,e,i){const s=function(t){const e=t.options,i=e.fill;let s=K(i&&i.target,i);return void 0===s&&(s=!!e.backgroundColor),!1!==s&&null!==s&&(!0===s?"origin":s)}(t);if(U(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return X(n)&&Math.floor(n)===n?("-"!==s[0]&&"+"!==s[0]||(n=e+n),!(n===e||n<0||n>=i)&&n):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}class ro{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){const{x:s,y:n,radius:o}=this;return e=e||{start:0,end:_t},t.arc(s,n,o,e.end,e.start,!0),!i.bounds}interpolate(t){const{x:e,y:i,radius:s}=this,n=t.angle;return{x:e+Math.cos(n)*s,y:i+Math.sin(n)*s,angle:n}}}function lo(t){return(t.scale||{}).getPointPositionForValue?function(t){const{scale:e,fill:i}=t,s=e.options,n=e.getLabels().length,o=[],a=s.reverse?e.max:e.min,r=s.reverse?e.min:e.max;let l,h,c;if(c="start"===i?a:"end"===i?r:U(i)?i.value:e.getBaseValue(),s.grid.circular)return h=e.getPointPositionForValue(0,a),new ro({x:h.x,y:h.y,radius:e.getDistanceFromCenterForValue(c)});for(l=0;lt;e--){const t=i[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function co(t,e,i){const s=[];for(let n=0;n{e=ho(t,e,n);const a=n[t],r=n[e];null!==s?(o.push({x:a.x,y:s}),o.push({x:r.x,y:s})):null!==i&&(o.push({x:i,y:a.y}),o.push({x:i,y:r.y}))})),o}(t,e),i.length?new Un({points:i,options:{tension:0},_loop:s,_fullLoop:s}):null}function po(t,e,i){let s=t[e].fill;const n=[e];let o;if(!i)return s;for(;!1!==s&&-1===n.indexOf(s);){if(!X(s))return s;if(o=t[s],!o)return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function mo(t,e,i){t.beginPath(),e.path(t),t.lineTo(e.last().x,i),t.lineTo(e.first().x,i),t.closePath(),t.clip()}function xo(t,e,i,s){if(s)return;let n=e[t],o=i[t];return"angle"===t&&(n=Wt(n),o=Wt(o)),{property:t,start:n,end:o}}function bo(t,e,i,s){return t&&e?s(t[i],e[i]):t?t[i]:e?e[i]:0}function _o(t,e,i){const{top:s,bottom:n}=e.chart.chartArea,{property:o,start:a,end:r}=i||{};"x"===o&&(t.beginPath(),t.rect(a,s,r-a,n-s),t.clip())}function yo(t,e,i,s){const n=e.interpolate(i,s);n&&t.lineTo(n.x,n.y)}function vo(t,e){const{line:i,target:s,property:n,color:o,scale:a}=e,r=function(t,e,i){const s=t.segments,n=t.points,o=e.points,a=[];for(const t of s){let{start:s,end:r}=t;r=ho(s,r,n);const l=xo(i,n[s],n[r],t.loop);if(!e.segments){a.push({source:t,target:l,start:n[s],end:n[r]});continue}const h=Bi(e,l);for(const e of h){const s=xo(i,o[e.start],o[e.end],e.loop),r=Fi(t,n,s);for(const t of r)a.push({source:t,target:e,start:{[i]:bo(l,s,"start",Math.max)},end:{[i]:bo(l,s,"end",Math.min)}})}}return a}(i,s,n);for(const{source:e,target:l,start:h,end:c}of r){const{style:{backgroundColor:r=o}={}}=e,d=!0!==s;t.save(),t.fillStyle=r,_o(t,a,d&&xo(n,h,c)),t.beginPath();const u=!!i.pathSegment(t,e);let f;if(d){u?t.closePath():yo(t,s,c,n);const e=!!s.pathSegment(t,l,{move:u,reverse:!0});f=u&&e,f||yo(t,s,h,n)}t.closePath(),t.fill(f?"evenodd":"nonzero"),t.restore()}}function wo(t,e,i){const s=fo(e),{line:n,scale:o,axis:a}=e,r=n.options,l=r.fill,h=r.backgroundColor,{above:c=h,below:d=h}=l||{};s&&n.points.length&&(Qt(t,i),function(t,e){const{line:i,target:s,above:n,below:o,area:a,scale:r}=e,l=i._loop?"angle":e.axis;t.save(),"x"===l&&o!==n&&(mo(t,s,a.top),vo(t,{line:i,target:s,color:n,scale:r,property:l}),t.restore(),t.save(),mo(t,s,a.bottom)),vo(t,{line:i,target:s,color:o,scale:r,property:l}),t.restore()}(t,{line:n,target:s,above:c,below:d,area:i,scale:o,axis:a}),Jt(t))}var Mo={id:"filler",afterDatasetsUpdate(t,e,i){const s=(t.data.datasets||[]).length,n=[];let o,a,r,l;for(a=0;a=0;--e){const i=n[e].$filler;i&&(i.line.updateControlPoints(o,i.axis),s&&wo(t.ctx,i,o))}},beforeDatasetsDraw(t,e,i){if("beforeDatasetsDraw"!==i.drawTime)return;const s=t.getSortedVisibleDatasetMetas();for(let e=s.length-1;e>=0;--e){const i=s[e].$filler;i&&wo(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,i){const s=e.meta.$filler;s&&!1!==s.fill&&"beforeDatasetDraw"===i.drawTime&&wo(t.ctx,s,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const ko=(t,e)=>{let{boxHeight:i=e,boxWidth:s=e}=t;return t.usePointStyle&&(i=Math.min(i,e),s=Math.min(s,e)),{boxWidth:s,boxHeight:i,itemHeight:Math.max(e,i)}};class So extends Ss{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=Q(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter((e=>t.filter(e,this.chart.data)))),t.sort&&(e=e.sort(((e,i)=>t.sort(e,i,this.chart.data)))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const i=t.labels,s=We(i.font),n=s.size,o=this._computeTitleHeight(),{boxWidth:a,itemHeight:r}=ko(i,n);let l,h;e.font=s.string,this.isHorizontal()?(l=this.maxWidth,h=this._fitRows(o,n,a,r)+10):(h=this.maxHeight,l=this._fitCols(o,n,a,r)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:n,maxWidth:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.lineWidths=[0],h=s+a;let c=t;n.textAlign="left",n.textBaseline="middle";let d=-1,u=-h;return this.legendItems.forEach(((t,f)=>{const g=i+e/2+n.measureText(t.text).width;(0===f||l[l.length-1]+g+2*a>o)&&(c+=h,l[l.length-(f>0?0:1)]=0,u+=h,d++),r[f]={left:0,top:u,row:d,width:g,height:s},l[l.length-1]+=g+a})),c}_fitCols(t,e,i,s){const{ctx:n,maxHeight:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.columnSizes=[],h=o-t;let c=a,d=0,u=0,f=0,g=0;return this.legendItems.forEach(((t,o)=>{const p=i+e/2+n.measureText(t.text).width;o>0&&u+s+2*a>h&&(c+=d+a,l.push({width:d,height:u}),f+=d+a,g++,d=u=0),r[o]={left:f,top:u,col:g,width:p,height:s},d=Math.max(d,p),u+=s+a})),c+=d,l.push({width:d,height:u}),c}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:o}}=this,a=Li(o,this.left,this.width);if(this.isHorizontal()){let o=0,r=n(i,this.left+s,this.right-this.lineWidths[o]);for(const l of e)o!==l.row&&(o=l.row,r=n(i,this.left+s,this.right-this.lineWidths[o])),l.top+=this.top+t+s,l.left=a.leftForLtr(a.x(r),l.width),r+=l.width+s}else{let o=0,r=n(i,this.top+t+s,this.bottom-this.columnSizes[o].height);for(const l of e)l.col!==o&&(o=l.col,r=n(i,this.top+t+s,this.bottom-this.columnSizes[o].height)),l.top=r,l.left+=this.left+s,l.left=a.leftForLtr(a.x(l.left),l.width),r+=l.height+s}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;Qt(t,this),this._draw(),Jt(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:a,labels:r}=t,l=xt.color,h=Li(t.rtl,this.left,this.width),c=We(r.font),{color:d,padding:u}=r,f=c.size,g=f/2;let p;this.drawTitle(),s.textAlign=h.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:m,boxHeight:x,itemHeight:b}=ko(r,f),_=this.isHorizontal(),y=this._computeTitleHeight();p=_?{x:n(a,this.left+u,this.right-i[0]),y:this.top+u+y,line:0}:{x:this.left+u,y:n(a,this.top+y+u,this.bottom-e[0].height),line:0},Ri(this.ctx,t.textDirection);const v=b+u;this.legendItems.forEach(((w,M)=>{s.strokeStyle=w.fontColor||d,s.fillStyle=w.fontColor||d;const k=s.measureText(w.text).width,S=h.textAlign(w.textAlign||(w.textAlign=r.textAlign)),P=m+g+k;let D=p.x,C=p.y;h.setWidth(this.width),_?M>0&&D+P+u>this.right&&(C=p.y+=v,p.line++,D=p.x=n(a,this.left+u,this.right-i[p.line])):M>0&&C+v>this.bottom&&(D=p.x=D+e[p.line].width+u,p.line++,C=p.y=n(a,this.top+y+u,this.bottom-e[p.line].height));!function(t,e,i){if(isNaN(m)||m<=0||isNaN(x)||x<0)return;s.save();const n=K(i.lineWidth,1);if(s.fillStyle=K(i.fillStyle,l),s.lineCap=K(i.lineCap,"butt"),s.lineDashOffset=K(i.lineDashOffset,0),s.lineJoin=K(i.lineJoin,"miter"),s.lineWidth=n,s.strokeStyle=K(i.strokeStyle,l),s.setLineDash(K(i.lineDash,[])),r.usePointStyle){const o={radius:m*Math.SQRT2/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:n},a=h.xPlus(t,m/2);Gt(s,o,a,e+g)}else{const o=e+Math.max((f-x)/2,0),a=h.leftForLtr(t,m),r=Be(i.borderRadius);s.beginPath(),Object.values(r).some((t=>0!==t))?ne(s,{x:a,y:o,w:m,h:x,radius:r}):s.rect(a,o,m,x),s.fill(),0!==n&&s.stroke()}s.restore()}(h.x(D),C,w),D=o(S,D+m+g,_?D+P:this.right,t.rtl),function(t,e,i){ie(s,i.text,t,e+b/2,c,{strikethrough:i.hidden,textAlign:h.textAlign(i.textAlign)})}(h.x(D),C,w),_?p.x+=P+u:p.y+=v})),Ei(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=We(e.font),o=Ve(e.padding);if(!e.display)return;const a=Li(t.rtl,this.left,this.width),r=this.ctx,l=e.position,h=i.size/2,c=o.top+h;let d,u=this.left,f=this.width;if(this.isHorizontal())f=Math.max(...this.lineWidths),d=this.top+c,u=n(t.align,u,this.right-f);else{const e=this.columnSizes.reduce(((t,e)=>Math.max(t,e.height)),0);d=c+n(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const g=n(l,u,u+f);r.textAlign=a.textAlign(s(l)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=i.string,ie(r,e.text,g,d,i)}_computeTitleHeight(){const t=this.options.title,e=We(t.font),i=Ve(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,n;if($t(t,this.left,this.right)&&$t(e,this.top,this.bottom))for(n=this.legendHitBoxes,i=0;it.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:i,pointStyle:s,textAlign:n,color:o}}=t.legend.options;return t._getSortedDatasetMetas().map((t=>{const a=t.controller.getStyle(i?0:void 0),r=Ve(a.borderWidth);return{text:e[t.index].label,fillStyle:a.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:a.borderCapStyle,lineDash:a.borderDash,lineDashOffset:a.borderDashOffset,lineJoin:a.borderJoinStyle,lineWidth:(r.width+r.height)/4,strokeStyle:a.borderColor,pointStyle:s||a.pointStyle,rotation:a.rotation,textAlign:n||a.textAlign,borderRadius:0,datasetIndex:t.index}}),this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class Do extends Ss{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const i=this.options;if(this.left=0,this.top=0,!i.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const s=Y(i.text)?i.text.length:1;this._padding=Ve(i.padding);const n=s*We(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=n:this.width=n}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:s,right:o,options:a}=this,r=a.align;let l,h,c,d=0;return this.isHorizontal()?(h=n(r,i,o),c=e+t,l=o-i):("left"===a.position?(h=i+t,c=n(r,s,e),d=-.5*bt):(h=o-t,c=n(r,e,s),d=.5*bt),l=s-e),{titleX:h,titleY:c,maxWidth:l,rotation:d}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=We(e.font),n=i.lineHeight/2+this._padding.top,{titleX:o,titleY:a,maxWidth:r,rotation:l}=this._drawArgs(n);ie(t,e.text,0,0,i,{color:e.color,maxWidth:r,rotation:l,textAlign:s(e.align),textBaseline:"middle",translation:[o,a]})}}var Co={id:"title",_element:Do,start(t,e,i){!function(t,e){const i=new Do({ctx:t.ctx,options:e,chart:t});ii.configure(t,i,e),ii.addBox(t,i),t.titleBlock=i}(t,i)},stop(t){const e=t.titleBlock;ii.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){const s=t.titleBlock;ii.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Oo=new WeakMap;var Ao={id:"subtitle",start(t,e,i){const s=new Do({ctx:t.ctx,options:i,chart:t});ii.configure(t,s,i),ii.addBox(t,s),Oo.set(t,s)},stop(t){ii.removeBox(t,Oo.get(t)),Oo.delete(t)},beforeUpdate(t,e,i){const s=Oo.get(t);ii.configure(t,s,i),s.options=i},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const To={average(t){if(!t.length)return!1;let e,i,s=0,n=0,o=0;for(e=0,i=t.length;e-1?t.split("\n"):t}function Eo(t,e){const{element:i,datasetIndex:s,index:n}=e,o=t.getDatasetMeta(s).controller,{label:a,value:r}=o.getLabelAndValue(n);return{chart:t,label:a,parsed:o.getParsed(n),raw:t.data.datasets[s].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:i}}function Io(t,e){const i=t._chart.ctx,{body:s,footer:n,title:o}=t,{boxWidth:a,boxHeight:r}=e,l=We(e.bodyFont),h=We(e.titleFont),c=We(e.footerFont),d=o.length,u=n.length,f=s.length,g=Ve(e.padding);let p=g.height,m=0,x=s.reduce(((t,e)=>t+e.before.length+e.lines.length+e.after.length),0);if(x+=t.beforeBody.length+t.afterBody.length,d&&(p+=d*h.lineHeight+(d-1)*e.titleSpacing+e.titleMarginBottom),x){p+=f*(e.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(x-f)*l.lineHeight+(x-1)*e.bodySpacing}u&&(p+=e.footerMarginTop+u*c.lineHeight+(u-1)*e.footerSpacing);let b=0;const _=function(t){m=Math.max(m,i.measureText(t).width+b)};return i.save(),i.font=h.string,J(t.title,_),i.font=l.string,J(t.beforeBody.concat(t.afterBody),_),b=e.displayColors?a+2+e.boxPadding:0,J(s,(t=>{J(t.before,_),J(t.lines,_),J(t.after,_)})),b=0,i.font=c.string,J(t.footer,_),i.restore(),m+=g.width,{width:m,height:p}}function zo(t,e,i,s){const{x:n,width:o}=i,{width:a,chartArea:{left:r,right:l}}=t;let h="center";return"center"===s?h=n<=(r+l)/2?"left":"right":n<=o/2?h="left":n>=a-o/2&&(h="right"),function(t,e,i,s){const{x:n,width:o}=s,a=i.caretSize+i.caretPadding;return"left"===t&&n+o+a>e.width||"right"===t&&n-o-a<0||void 0}(h,t,e,i)&&(h="center"),h}function Fo(t,e,i){const s=e.yAlign||function(t,e){const{y:i,height:s}=e;return it.height-s/2?"bottom":"center"}(t,i);return{xAlign:e.xAlign||zo(t,e,i,s),yAlign:s}}function Bo(t,e,i,s){const{caretSize:n,caretPadding:o,cornerRadius:a}=t,{xAlign:r,yAlign:l}=i,h=n+o,{topLeft:c,topRight:d,bottomLeft:u,bottomRight:f}=Be(a);let g=function(t,e){let{x:i,width:s}=t;return"right"===e?i-=s:"center"===e&&(i-=s/2),i}(e,r);const p=function(t,e,i){let{y:s,height:n}=t;return"top"===e?s+=i:s-="bottom"===e?n+i:n/2,s}(e,l,h);return"center"===l?"left"===r?g+=h:"right"===r&&(g-=h):"left"===r?g-=Math.max(c,u)+n:"right"===r&&(g+=Math.max(d,f)+n),{x:Ht(g,0,s.width-e.width),y:Ht(p,0,s.height-e.height)}}function Vo(t,e,i){const s=Ve(i.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-s.right:t.x+s.left}function Wo(t){return Lo([],Ro(t))}function No(t,e){const i=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return i?t.override(i):t}class Ho extends Ss{constructor(t){super(),this.opacity=0,this._active=[],this._chart=t._chart,this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this._chart,i=this.options.setContext(this.getContext()),s=i.enabled&&e.options.animation&&i.animations,n=new us(this._chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(n)),n}getContext(){return this.$context||(this.$context=(t=this._chart.getContext(),e=this,i=this._tooltipItems,je(t,{tooltip:e,tooltipItems:i,type:"tooltip"})));var t,e,i}getTitle(t,e){const{callbacks:i}=e,s=i.beforeTitle.apply(this,[t]),n=i.title.apply(this,[t]),o=i.afterTitle.apply(this,[t]);let a=[];return a=Lo(a,Ro(s)),a=Lo(a,Ro(n)),a=Lo(a,Ro(o)),a}getBeforeBody(t,e){return Wo(e.callbacks.beforeBody.apply(this,[t]))}getBody(t,e){const{callbacks:i}=e,s=[];return J(t,(t=>{const e={before:[],lines:[],after:[]},n=No(i,t);Lo(e.before,Ro(n.beforeLabel.call(this,t))),Lo(e.lines,n.label.call(this,t)),Lo(e.after,Ro(n.afterLabel.call(this,t))),s.push(e)})),s}getAfterBody(t,e){return Wo(e.callbacks.afterBody.apply(this,[t]))}getFooter(t,e){const{callbacks:i}=e,s=i.beforeFooter.apply(this,[t]),n=i.footer.apply(this,[t]),o=i.afterFooter.apply(this,[t]);let a=[];return a=Lo(a,Ro(s)),a=Lo(a,Ro(n)),a=Lo(a,Ro(o)),a}_createItems(t){const e=this._active,i=this._chart.data,s=[],n=[],o=[];let a,r,l=[];for(a=0,r=e.length;at.filter(e,s,n,i)))),t.itemSort&&(l=l.sort(((e,s)=>t.itemSort(e,s,i)))),J(l,(e=>{const i=No(t.callbacks,e);s.push(i.labelColor.call(this,e)),n.push(i.labelPointStyle.call(this,e)),o.push(i.labelTextColor.call(this,e))})),this.labelColors=s,this.labelPointStyles=n,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let n,o=[];if(s.length){const t=To[i.position].call(this,s,this._eventPosition);o=this._createItems(i),this.title=this.getTitle(o,i),this.beforeBody=this.getBeforeBody(o,i),this.body=this.getBody(o,i),this.afterBody=this.getAfterBody(o,i),this.footer=this.getFooter(o,i);const e=this._size=Io(this,i),a=Object.assign({},t,e),r=Fo(this._chart,i,a),l=Bo(i,a,r,this._chart);this.xAlign=r.xAlign,this.yAlign=r.yAlign,n={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(n={opacity:0});this._tooltipItems=o,this.$context=void 0,n&&this._resolveAnimations().update(this,n),t&&i.external&&i.external.call(this,{chart:this._chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const n=this.getCaretPosition(t,i,s);e.lineTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:n}=this,{caretSize:o,cornerRadius:a}=i,{topLeft:r,topRight:l,bottomLeft:h,bottomRight:c}=Be(a),{x:d,y:u}=t,{width:f,height:g}=e;let p,m,x,b,_,y;return"center"===n?(_=u+g/2,"left"===s?(p=d,m=p-o,b=_+o,y=_-o):(p=d+f,m=p+o,b=_-o,y=_+o),x=p):(m="left"===s?d+Math.max(r,h)+o:"right"===s?d+f-Math.max(l,c)-o:this.caretX,"top"===n?(b=u,_=b-o,p=m-o,x=m+o):(b=u+g,_=b+o,p=m+o,x=m-o),y=b),{x1:p,x2:m,x3:x,y1:b,y2:_,y3:y}}drawTitle(t,e,i){const s=this.title,n=s.length;let o,a,r;if(n){const l=Li(i.rtl,this.x,this.width);for(t.x=Vo(this,i.titleAlign,i),e.textAlign=l.textAlign(i.titleAlign),e.textBaseline="middle",o=We(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=o.string,r=0;r0!==t))?(t.beginPath(),t.fillStyle=n.multiKeyBackground,ne(t,{x:e,y:g,w:l,h:r,radius:a}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),ne(t,{x:i,y:g+1,w:l-2,h:r-2,radius:a}),t.fill()):(t.fillStyle=n.multiKeyBackground,t.fillRect(e,g,l,r),t.strokeRect(e,g,l,r),t.fillStyle=o.backgroundColor,t.fillRect(i,g+1,l-2,r-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:n,bodyAlign:o,displayColors:a,boxHeight:r,boxWidth:l,boxPadding:h}=i,c=We(i.bodyFont);let d=c.lineHeight,u=0;const f=Li(i.rtl,this.x,this.width),g=function(i){e.fillText(i,f.x(t.x+u),t.y+d/2),t.y+=d+n},p=f.textAlign(o);let m,x,b,_,y,v,w;for(e.textAlign=o,e.textBaseline="middle",e.font=c.string,t.x=Vo(this,p,i),e.fillStyle=i.bodyColor,J(this.beforeBody,g),u=a&&"right"!==p?"center"===o?l/2+h:l+2+h:0,_=0,v=s.length;_0&&e.stroke()}_updateAnimationTarget(t){const e=this._chart,i=this.$animations,s=i&&i.x,n=i&&i.y;if(s||n){const i=To[t.position].call(this,this._active,this._eventPosition);if(!i)return;const o=this._size=Io(this,t),a=Object.assign({},i,this._size),r=Fo(e,t,a),l=Bo(t,a,r,e);s._to===l.x&&n._to===l.y||(this.xAlign=r.xAlign,this.yAlign=r.yAlign,this.width=o.width,this.height=o.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,l))}}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},n={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const o=Ve(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(n,t,s,e),Ri(t,e.textDirection),n.y+=o.top,this.drawTitle(n,t,e),this.drawBody(n,t,e),this.drawFooter(n,t,e),Ei(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map((({datasetIndex:t,index:e})=>{const i=this._chart.getDatasetMeta(t);if(!i)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:i.data[e],index:e}})),n=!tt(i,s),o=this._positionChanged(s,e);(n||o)&&(this._active=s,this._eventPosition=e,this.update(!0))}handleEvent(t,e){const i=this.options,s=this._active||[];let n=!1,o=[];"mouseout"!==t.type&&(o=this._chart.getElementsAtEventForMode(t,i.mode,i,e),i.reverse&&o.reverse());const a=this._positionChanged(o,t);return n=e||!tt(o,s)||a,n&&(this._active=o,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),n}_positionChanged(t,e){const{caretX:i,caretY:s,options:n}=this,o=To[n.position].call(this,t,e);return!1!==o&&(i!==o.x||s!==o.y)}}Ho.positioners=To;var jo={id:"tooltip",_element:Ho,positioners:To,afterInit(t,e,i){i&&(t.tooltip=new Ho({_chart:t,options:i}))},beforeUpdate(t,e,i){t.tooltip&&t.tooltip.initialize(i)},reset(t,e,i){t.tooltip&&t.tooltip.initialize(i)},afterDraw(t){const e=t.tooltip,i={tooltip:e};!1!==t.notifyPlugins("beforeTooltipDraw",i)&&(e&&e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i))},afterEvent(t,e){if(t.tooltip){const i=e.replay;t.tooltip.handleEvent(e.event,i)&&(e.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:{beforeTitle:H,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,s=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(s>0&&e.dataIndex"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},$o=Object.freeze({__proto__:null,Decimation:oo,Filler:Mo,Legend:Po,SubTitle:Ao,Title:Co,Tooltip:jo});function Yo(t,e,i,s){const n=t.indexOf(e);if(-1===n)return((t,e,i,s)=>("string"==typeof e?(i=t.push(e)-1,s.unshift({index:i,label:e})):isNaN(e)&&(i=null),i))(t,e,i,s);return n!==t.lastIndexOf(e)?i:n}class Uo extends zs{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const e=this._addedLabels;if(e.length){const t=this.getLabels();for(const{index:i,label:s}of e)t[i]===s&&t.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,e){if($(t))return null;const i=this.getLabels();return((t,e)=>null===t?null:Ht(Math.round(t),0,e))(e=isFinite(e)&&i[e]===t?e:Yo(i,t,K(e,t),this._addedLabels),i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(i=0),e||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,e=this.max,i=this.options.offset,s=[];let n=this.getLabels();n=0===t&&e===n.length-1?n:n.slice(t,e+1),this._valueRange=Math.max(n.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let i=t;i<=e;i++)s.push({value:i});return s}getLabelForValue(t){const e=this.getLabels();return t>=0&&te.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function Xo(t,e,{horizontal:i,minRotation:s}){const n=Et(s),o=(i?Math.sin(n):Math.cos(n))||.001,a=.75*e*(""+t).length;return Math.min(e/o,a)}Uo.id="category",Uo.defaults={ticks:{callback:Uo.prototype.getLabelForValue}};class qo extends zs{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return $(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:s,max:n}=this;const o=t=>s=e?s:t,a=t=>n=i?n:t;if(t){const t=Dt(s),e=Dt(n);t<0&&e<0?a(0):t>0&&e>0&&o(0)}if(s===n){let e=1;(n>=Number.MAX_SAFE_INTEGER||s<=Number.MIN_SAFE_INTEGER)&&(e=Math.abs(.05*n)),a(n+e),t||o(s-e)}this.min=s,this.max=n}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:i,stepSize:s}=t;return s?(e=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),i=i||11),i&&(e=Math.min(i,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const s=function(t,e){const i=[],{bounds:s,step:n,min:o,max:a,precision:r,count:l,maxTicks:h,maxDigits:c,includeBounds:d}=t,u=n||1,f=h-1,{min:g,max:p}=e,m=!$(o),x=!$(a),b=!$(l),_=(p-g)/(c+1);let y,v,w,M,k=Ct((p-g)/f/u)*u;if(k<1e-14&&!m&&!x)return[{value:g},{value:p}];M=Math.ceil(p/k)-Math.floor(g/k),M>f&&(k=Ct(M*k/f/u)*u),$(r)||(y=Math.pow(10,r),k=Math.ceil(k*y)/y),"ticks"===s?(v=Math.floor(g/k)*k,w=Math.ceil(p/k)*k):(v=g,w=p),m&&x&&n&&Lt((a-o)/n,k/1e3)?(M=Math.round(Math.min((a-o)/k,h)),k=(a-o)/M,v=o,w=a):b?(v=m?o:v,w=x?a:w,M=l-1,k=(w-v)/M):(M=(w-v)/k,M=Tt(M,Math.round(M),k/1e3)?Math.round(M):Math.ceil(M));const S=Math.max(zt(k),zt(v));y=Math.pow(10,$(r)?S:r),v=Math.round(v*y)/y,w=Math.round(w*y)/y;let P=0;for(m&&(d&&v!==o?(i.push({value:o}),v0?i:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=X(t)?Math.max(0,t):null,this.max=X(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const n=e=>i=t?i:e,o=t=>s=e?s:t,a=(t,e)=>Math.pow(10,Math.floor(Pt(t))+e);i===s&&(i<=0?(n(1),o(10)):(n(a(i,-1)),o(a(s,1)))),i<=0&&n(a(s,-1)),s<=0&&o(a(i,1)),this._zero&&this.min!==this._suggestedMin&&i===a(this.min,0)&&n(a(i,-1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e=function(t,e){const i=Math.floor(Pt(e.max)),s=Math.ceil(e.max/Math.pow(10,i)),n=[];let o=q(t.min,Math.pow(10,Math.floor(Pt(e.min)))),a=Math.floor(Pt(o)),r=Math.floor(o/Math.pow(10,a)),l=a<0?Math.pow(10,Math.abs(a)):1;do{n.push({value:o,major:Go(o)}),++r,10===r&&(r=1,++a,l=a>=0?1:l),o=Math.round(r*Math.pow(10,a)*l)/l}while(an?{start:e-i,end:e}:{start:e,end:e+i}}function ta(t){const e={l:0,r:t.width,t:0,b:t.height-t.paddingTop},i={},s=[],n=[],o=t.getLabels().length;for(let h=0;he.r&&(e.r=p.end,i.r=f),m.starte.b&&(e.b=m.end,i.b=f)}var a,r,l;t._setReductions(t.drawingArea,e,i),t._pointLabelItems=function(t,e,i){const s=[],n=t.getLabels().length,o=t.options,a=Qo(o),r=t.getDistanceFromCenterForValue(o.ticks.reverse?t.min:t.max);for(let o=0;o270||i<90)&&(t-=e),t}function na(t,e,i,s){const{ctx:n}=t;if(i)n.arc(t.xCenter,t.yCenter,e,0,_t);else{let i=t.getPointPosition(0,e);n.moveTo(i.x,i.y);for(let o=1;o{const i=Q(this.options.pointLabels.callback,[t,e],this);return i||0===i?i:""}))}fit(){const t=this.options;t.display&&t.pointLabels.display?ta(this):this.setCenterPoint(0,0,0,0)}_setReductions(t,e,i){let s=e.l/Math.sin(i.l),n=Math.max(e.r-this.width,0)/Math.sin(i.r),o=-e.t/Math.cos(i.t),a=-Math.max(e.b-(this.height-this.paddingTop),0)/Math.cos(i.b);s=oa(s),n=oa(n),o=oa(o),a=oa(a),this.drawingArea=Math.max(t/2,Math.min(Math.floor(t-(s+n)/2),Math.floor(t-(o+a)/2))),this.setCenterPoint(s,n,o,a)}setCenterPoint(t,e,i,s){const n=this.width-e-this.drawingArea,o=t+this.drawingArea,a=i+this.drawingArea,r=this.height-this.paddingTop-s-this.drawingArea;this.xCenter=Math.floor((o+n)/2+this.left),this.yCenter=Math.floor((a+r)/2+this.top+this.paddingTop)}getIndexAngle(t){return Wt(t*(_t/this.getLabels().length)+Et(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if($(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if($(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t=0;n--){const e=s.setContext(t.getPointLabelContext(n)),o=We(e.font),{x:a,y:r,textAlign:l,left:h,top:c,right:d,bottom:u}=t._pointLabelItems[n],{backdropColor:f}=e;if(!$(f)){const t=Ve(e.backdropPadding);i.fillStyle=f,i.fillRect(h-t.left,c-t.top,d-h+t.width,u-c+t.height)}ie(i,t._pointLabels[n],a,r+o.lineHeight/2,o,{color:e.color,textAlign:l,textBaseline:"middle"})}}(this,n),s.display&&this.ticks.forEach(((t,e)=>{if(0!==e){a=this.getDistanceFromCenterForValue(t.value);!function(t,e,i,s){const n=t.ctx,o=e.circular,{color:a,lineWidth:r}=e;!o&&!s||!a||!r||i<0||(n.save(),n.strokeStyle=a,n.lineWidth=r,n.setLineDash(e.borderDash),n.lineDashOffset=e.borderDashOffset,n.beginPath(),na(t,i,o,s),n.closePath(),n.stroke(),n.restore())}(this,s.setContext(this.getContext(e-1)),a,n)}})),i.display){for(t.save(),o=this.getLabels().length-1;o>=0;o--){const s=i.setContext(this.getPointLabelContext(o)),{color:n,lineWidth:l}=s;l&&n&&(t.lineWidth=l,t.strokeStyle=n,t.setLineDash(s.borderDash),t.lineDashOffset=s.borderDashOffset,a=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),r=this.getPointPosition(o,a),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(r.x,r.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let n,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach(((s,a)=>{if(0===a&&!e.reverse)return;const r=i.setContext(this.getContext(a)),l=We(r.font);if(n=this.getDistanceFromCenterForValue(this.ticks[a].value),r.showLabelBackdrop){t.font=l.string,o=t.measureText(s.label).width,t.fillStyle=r.backdropColor;const e=Ve(r.backdropPadding);t.fillRect(-o/2-e.left,-n-l.size/2-e.top,o+e.width,l.size+e.height)}ie(t,s.label,0,-n,l,{color:r.color})})),t.restore()}drawTitle(){}}aa.id="radialLinear",aa.defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Ds.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback:t=>t,padding:5}},aa.defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"},aa.descriptors={angleLines:{_fallback:"grid"}};const ra={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},la=Object.keys(ra);function ha(t,e){return t-e}function ca(t,e){if($(e))return null;const i=t._adapter,{parser:s,round:n,isoWeekday:o}=t._parseOpts;let a=e;return"function"==typeof s&&(a=s(a)),X(a)||(a="string"==typeof s?i.parse(a,s):i.parse(a)),null===a?null:(n&&(a="week"!==n||!At(o)&&!0!==o?i.startOf(a,n):i.startOf(a,"isoWeek",o)),+a)}function da(t,e,i,s){const n=la.length;for(let o=la.indexOf(t);o=e?i[s]:i[n]]=!0}}else t[e]=!0}function fa(t,e,i){const s=[],n={},o=e.length;let a,r;for(a=0;a=0&&(e[l].major=!0);return e}(t,s,n,i):s}class ga extends zs{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e){const i=t.time||(t.time={}),s=this._adapter=new gn._date(t.adapters.date);ot(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:ca(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,i=t.time.unit||"day";let{min:s,max:n,minDefined:o,maxDefined:a}=this.getUserBounds();function r(t){o||isNaN(t.min)||(s=Math.min(s,t.min)),a||isNaN(t.max)||(n=Math.max(n,t.max))}o&&a||(r(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||r(this.getMinMax(!1))),s=X(s)&&!isNaN(s)?s:+e.startOf(Date.now(),i),n=X(n)&&!isNaN(n)?n:+e.endOf(Date.now(),i)+1,this.min=Math.min(s,n-1),this.max=Math.max(s+1,n)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this.options,e=t.time,i=t.ticks,s="labels"===i.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const n=this.min,o=le(s,n,this.max);return this._unit=e.unit||(i.autoSkip?da(e.minUnit,this.min,this.max,this._getLabelCapacity(n)):function(t,e,i,s,n){for(let o=la.length-1;o>=la.indexOf(i);o--){const i=la[o];if(ra[i].common&&t._adapter.diff(n,s,i)>=e-1)return i}return la[i?la.indexOf(i):0]}(this,o.length,e.minUnit,this.min,this.max)),this._majorUnit=i.major.enabled&&"year"!==this._unit?function(t){for(let e=la.indexOf(t)+1,i=la.length;e1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+o);const f="data"===s.ticks.source&&this.getDataTimestamps();for(c=u,d=0;ct-e)).map((t=>+t))}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}_tickFormatFunction(t,e,i,s){const n=this.options,o=n.time.displayFormats,a=this._unit,r=this._majorUnit,l=a&&o[a],h=r&&o[r],c=i[e],d=r&&h&&c&&c.major,u=this._adapter.format(t,s||(d?h:l)),f=n.ticks.callback;return f?Q(f,[u,e,i],this):u}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t,e,i=this._cache.data||[];if(i.length)return i;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(t=0,e=s.length;t=t[r].pos&&e<=t[l].pos&&({lo:r,hi:l}=ae(t,"pos",e)),({pos:s,time:o}=t[r]),({pos:n,time:a}=t[l])):(e>=t[r].time&&e<=t[l].time&&({lo:r,hi:l}=ae(t,"time",e)),({time:s,pos:o}=t[r]),({time:n,pos:a}=t[l]));const h=n-s;return h?o+(a-o)*(e-s)/h:o}ga.id="time",ga.defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",major:{enabled:!1}}};class ma extends ga{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=pa(e,this.min),this._tableRange=pa(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],n=[];let o,a,r,l,h;for(o=0,a=t.length;o=e&&l<=i&&s.push(l);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(o=0,a=s.length;o