Files
2022-02-21 18:30:21 +01:00

1 line
172 KiB
JavaScript

import{r as requestAnimFrame,a as resolve,e as effects,c as color,d as defaults,i as isObject,b as isArray,v as valueOrDefault,u as unlistenArrayEvents,l as listenArrayEvents,f as resolveObjectKey,g as isNumberFinite,h as createContext,j as defined,s as sign,k as isNullOrUndef,_ as _arrayUnique,t as toRadians,m as toPercentage,n as toDimension,T as TAU,o as formatNumber,p as _angleBetween,H as HALF_PI,P as PI,q as isNumber,w as _limitValue,x as _lookupByKey,y as getRelativePosition$1,z as _isPointInArea,A as _rlookupByKey,B as getAngleFromPoint,C as toPadding,D as each,E as getMaximumSize,F as _getParentNode,G as readUsedSize,I as throttled,J as supportsEventListenerOptions,K as _isDomSupported,L as log10,M as _factorize,N as finiteOrDefault,O as callback,Q as _addGrace,R as toDegrees,S as _measureText,U as _int16Range,V as _alignPixel,W as clipArea,X as renderText,Y as unclipArea,Z as toFont,$ as _toLeftRightCenter,a0 as _alignStartEnd,a1 as overrides,a2 as merge,a3 as _capitalize,a4 as descriptors,a5 as isFunction,a6 as _attachContext,a7 as _createResolver,a8 as _descriptors,a9 as mergeIf,aa as uid,ab as debounce,ac as retinaScale,ad as clearCanvas,ae as setsEqual,af as _elementsEqual,ag as _isClickEvent,ah as _isBetween,ai as _readValueToProps,aj as _updateBezierControlPoints,ak as _computeSegments,al as _boundSegments,am as _steppedInterpolation,an as _bezierInterpolation,ao as _pointInLine,ap as _steppedLineTo,aq as _bezierCurveTo,ar as drawPoint,as as addRoundedRectPath,at as toTRBL,au as toTRBLCorners,av as _boundSegment,aw as _normalizeAngle,ax as getRtlAdapter,ay as overrideTextDirection,az as _textX,aA as restoreTextDirection,aB as noop,aC as distanceBetweenPoints,aD as _setMinAndMaxByKey,aE as niceNum,aF as almostWhole,aG as almostEquals,aH as _decimalPlaces,aI as _longestText,aJ as _filterBetween,aK as _lookup}from"./chunks/helpers.segment.js";export{d as defaults}from"./chunks/helpers.segment.js";class Animator{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(e,i,a,t){const s=i.listeners[t],r=i.duration;s.forEach(t=>t({chart:e,initial:i.initial,numSteps:r,currentStep:Math.min(a-i.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=requestAnimFrame.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(n=Date.now()){let o=0;this._charts.forEach((a,s)=>{if(a.running&&a.items.length){const r=a.items;let t=r.length-1,e=!1,i;for(;0<=t;--t)i=r[t],i._active?(i._total>a.duration&&(a.duration=i._total),i.tick(n),e=!0):(r[t]=r[r.length-1],r.pop());e&&(s.draw(),this._notify(s,a,n,"progress")),r.length||(a.running=!1,this._notify(s,a,n,"complete"),a.initial=!1),o+=r.length}}),this._lastDate=n,0===o&&(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 0<this._getAnims(t).items.length}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;t=this._charts.get(t);return!!(t&&t.running&&t.items.length)}stop(e){const i=this._charts.get(e);if(i&&i.items.length){const a=i.items;let t=a.length-1;for(;0<=t;--t)a[t].cancel();i.items=[],this._notify(e,i,Date.now(),"complete")}}remove(t){return this._charts.delete(t)}}var animator=new Animator;const transparent="transparent",interpolators={boolean(t,e,i){return.5<i?e:t},color(t,e,i){t=color(t||transparent);const a=t.valid&&color(e||transparent);return a&&a.valid?a.mix(t,i).hexString():e},number(t,e,i){return t+(e-t)*i}};class Animation{constructor(t,e,i,a){var s=e[i];a=resolve([t.to,a,s,t.from]);s=resolve([t.from,s,a]);this._active=!0,this._fn=t.fn||interpolators[t.type||typeof s],this._easing=effects[t.easing]||effects.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=s,this._to=a,this._promises=void 0}active(){return this._active}update(t,e,i){var a,s,r;this._active&&(this._notify(!1),a=this._target[this._prop],s=i-this._start,r=this._duration-s,this._start=i,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=s,this._loop=!!t.loop,this._to=resolve([t.to,e,a,t.from]),this._from=resolve([t.from,a,e]))}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){var e=t-this._start,i=this._duration,a=this._prop,s=this._from,r=this._loop,t=this._to;let n;if(this._active=s!==t&&(r||e<i),!this._active)return this._target[a]=t,void this._notify(!0);e<0?this._target[a]=s:(n=e/i%2,n=r&&1<n?2-n:n,n=this._easing(Math.min(1,Math.max(0,n))),this._target[a]=this._fn(s,t,n))}wait(){const i=this._promises||(this._promises=[]);return new Promise((t,e)=>{i.push({res:t,rej:e})})}_notify(t){var e=t?"res":"rej";const i=this._promises||[];for(let t=0;t<i.length;t++)i[t][e]()}}const numbers=["x","y","borderWidth","radius","tension"],colors=["color","borderColor","backgroundColor"];defaults.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0});const animationOptions=Object.keys(defaults.animation);defaults.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),defaults.set("animations",{colors:{type:"color",properties:colors},numbers:{type:"number",properties:numbers}}),defaults.describe("animations",{_fallback:"animation"}),defaults.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 Animations{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(s){if(isObject(s)){const r=this._properties;Object.getOwnPropertyNames(s).forEach(e=>{const t=s[e];if(isObject(t)){const i={};for(const a of animationOptions)i[a]=t[a];(isArray(t.properties)&&t.properties||[e]).forEach(t=>{t!==e&&r.has(t)||r.set(t,i)})}})}}_animateOptions(t,e){const i=e.options;e=resolveTargetOptions(t,i);if(!e)return[];e=this._createAnimations(e,i);return i.$shared&&awaitAll(t.options.$animations,i).then(()=>{t.options=i},()=>{}),e}_createAnimations(e,i){const a=this._properties,s=[],r=e.$animations||(e.$animations={});var t=Object.keys(i),n=Date.now();let o;for(o=t.length-1;0<=o;--o){const d=t[o];if("$"!==d.charAt(0))if("options"!==d){var l=i[d];let t=r[d];var h=a.get(d);if(t){if(h&&t.active()){t.update(h,l,n);continue}t.cancel()}h&&h.duration?(r[d]=t=new Animation(h,e,d,l),s.push(t)):e[d]=l}else s.push(...this._animateOptions(e,i))}return s}update(t,e){if(0!==this._properties.size){var i=this._createAnimations(t,e);return i.length?(animator.add(this._chart,i),!0):void 0}Object.assign(t,e)}}function awaitAll(e,t){const i=[];var a=Object.keys(t);for(let t=0;t<a.length;t++){const s=e[a[t]];s&&s.active()&&i.push(s.wait())}return Promise.all(i)}function resolveTargetOptions(e,i){if(i){let t=e.options;if(t)return t.$shared&&(e.options=t=Object.assign({},t,{$shared:!1,$animations:{}})),t;e.options=i}}function scaleClip(t,e){var i=t&&t.options||{},a=i.reverse,t=void 0===i.min?e:0,e=void 0===i.max?e:0;return{start:a?e:t,end:a?t:e}}function defaultClip(t,e,i){if(!1===i)return!1;t=scaleClip(t,i),i=scaleClip(e,i);return{top:i.end,right:t.end,bottom:i.start,left:t.start}}function toClip(t){let e,i,a,s;return isObject(t)?(e=t.top,i=t.right,a=t.bottom,s=t.left):e=i=a=s=t,{top:e,right:i,bottom:a,left:s,disabled:!1===t}}function getSortedDatasetIndices(t,e){const i=[];var a=t._getSortedDatasetMetas(e);let s,r;for(s=0,r=a.length;s<r;++s)i.push(a[s].index);return i}function applyStack(t,e,i,a={}){var s=t.keys,r="single"===a.mode;let n,o,l,h;if(null!==e){for(n=0,o=s.length;n<o;++n){if((l=+s[n])===i){if(a.all)continue;break}h=t.values[l],isNumberFinite(h)&&(r||0===e||sign(e)===sign(h))&&(e+=h)}return e}}function convertObjectDataToArray(t){var e=Object.keys(t);const i=new Array(e.length);let a,s,r;for(a=0,s=e.length;a<s;++a)r=e[a],i[a]={x:r,y:t[r]};return i}function isStacked(t,e){t=t&&t.options.stacked;return t||void 0===t&&void 0!==e.stack}function getStackKey(t,e,i){return`${t.id}.${e.id}.${i.stack||i.type}`}function getUserBounds(t){var{min:e,max:i,minDefined:a,maxDefined:t}=t.getUserBounds();return{min:a?e:Number.NEGATIVE_INFINITY,max:t?i:Number.POSITIVE_INFINITY}}function getOrCreateStack(t,e,i){const a=t[e]||(t[e]={});return a[i]||(a[i]={})}function getLastIndexInStack(t,e,i,a){for(const r of e.getMatchingVisibleMetas(a).reverse()){var s=t[r.index];if(i&&0<s||!i&&s<0)return r.index}return null}function updateStacks(t,e){const{chart:i,_cachedMeta:a}=t;var s=i._stacks||(i._stacks={}),{iScale:t,vScale:r,index:n}=a,o=t.axis,l=r.axis,h=getStackKey(t,r,a),d=e.length;let c;for(let t=0;t<d;++t){const p=e[t];var{[o]:u,[l]:g}=p;const f=p._stacks||(p._stacks={});c=f[l]=getOrCreateStack(s,h,u),c[n]=g,c._top=getLastIndexInStack(c,r,!0,a.type),c._bottom=getLastIndexInStack(c,r,!1,a.type)}}function getFirstScaleId(t,e){const i=t.scales;return Object.keys(i).filter(t=>i[t].axis===e).shift()}function createDatasetContext(t,e){return createContext(t,{active:!1,dataset:void 0,datasetIndex:e,index:e,mode:"default",type:"dataset"})}function createDataContext(t,e,i){return createContext(t,{active:!1,dataIndex:e,parsed:void 0,raw:void 0,element:i,index:e,mode:"default",type:"data"})}function clearStacks(t,e){var i=t.controller.index,a=t.vScale&&t.vScale.axis;if(a)for(const s of e=e||t._parsed){const r=s._stacks;if(!r||void 0===r[a]||void 0===r[a][i])return;delete r[a][i]}}const isDirectUpdateMode=t=>"reset"===t||"none"===t,cloneIfNotShared=(t,e)=>e?t:Object.assign({},t),createStack=(t,e,i)=>t&&!e.hidden&&e._stacked&&{keys:getSortedDatasetIndices(i,!0),values:null};class DatasetController{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=isStacked(t.vScale,t),this.addElements()}updateIndex(t){this.index!==t&&clearStacks(this._cachedMeta),this.index=t}linkScales(){var t=this.chart;const e=this._cachedMeta;var i=this.getDataset(),a=(t,e,i,a)=>"x"===t?e:"r"===t?a:i,s=e.xAxisID=valueOrDefault(i.xAxisID,getFirstScaleId(t,"x")),r=e.yAxisID=valueOrDefault(i.yAxisID,getFirstScaleId(t,"y")),n=e.rAxisID=valueOrDefault(i.rAxisID,getFirstScaleId(t,"r")),i=e.indexAxis,t=e.iAxisID=a(i,s,r,n),i=e.vAxisID=a(i,r,s,n);e.xScale=this.getScaleForId(s),e.yScale=this.getScaleForId(r),e.rScale=this.getScaleForId(n),e.iScale=this.getScaleForId(t),e.vScale=this.getScaleForId(i)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){var e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){var t=this._cachedMeta;this._data&&unlistenArrayEvents(this._data,this),t._stacked&&clearStacks(t)}_dataCheck(){const t=this.getDataset();var e=t.data||(t.data=[]),i=this._data;if(isObject(e))this._data=convertObjectDataToArray(e);else if(i!==e){if(i){unlistenArrayEvents(i,this);const a=this._cachedMeta;clearStacks(a),a._parsed=[]}e&&Object.isExtensible(e)&&listenArrayEvents(e,this),this._syncList=[],this._data=e}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta;var i=this.getDataset();let a=!1;this._dataCheck();var s=e._stacked;e._stacked=isStacked(e.vScale,e),e.stack!==i.stack&&(a=!0,clearStacks(e),e.stack=i.stack),this._resyncElements(t),!a&&s===e._stacked||updateStacks(this,e._parsed)}configure(){const t=this.chart.config;var e=t.datasetScopeKeys(this._type),e=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(e,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:i,_data:a}=this;var{iScale:s,_stacked:r}=i;const n=s.axis;let o=0===t&&e===a.length||i._sorted,l=0<t&&i._parsed[t-1],h,d,c;if(!1===this._parsing)i._parsed=a,i._sorted=!0,c=a;else{c=isArray(a[t])?this.parseArrayData(i,a,t,e):isObject(a[t])?this.parseObjectData(i,a,t,e):this.parsePrimitiveData(i,a,t,e);for(h=0;h<e;++h)i._parsed[h+t]=d=c[h],o&&((null===d[n]||l&&d[n]<l[n])&&(o=!1),l=d);i._sorted=o}r&&updateStacks(this,c)}parsePrimitiveData(t,e,i,a){const{iScale:s,vScale:r}=t;var n=s.axis,o=r.axis,l=s.getLabels(),h=s===r;const d=new Array(a);let c,u,g;for(c=0,u=a;c<u;++c)g=c+i,d[c]={[n]:h||s.parse(l[g],g),[o]:r.parse(e[g],g)};return d}parseArrayData(t,e,i,a){const{xScale:s,yScale:r}=t,n=new Array(a);let o,l,h,d;for(o=0,l=a;o<l;++o)d=e[h=o+i],n[o]={x:s.parse(d[0],h),y:r.parse(d[1],h)};return n}parseObjectData(t,e,i,a){const{xScale:s,yScale:r}=t;var{xAxisKey:n="x",yAxisKey:o="y"}=this._parsing;const l=new Array(a);let h,d,c,u;for(h=0,d=a;h<d;++h)u=e[c=h+i],l[h]={x:s.parse(resolveObjectKey(u,n),c),y:r.parse(resolveObjectKey(u,o),c)};return l}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,e,i){var a=this.chart,s=this._cachedMeta,r=e[t.axis];return applyStack({keys:getSortedDatasetIndices(a,!0),values:e._stacks[t.axis]},r,s.index,{mode:i})}updateRangeFromParsed(t,e,i,a){var s=i[e.axis];let r=null===s?NaN:s;e=a&&i._stacks[e.axis];a&&e&&(a.values=e,r=applyStack(a,s,this._cachedMeta.index)),t.min=Math.min(t.min,r),t.max=Math.max(t.max,r)}getMinMax(e,t){var i=this._cachedMeta;const a=i._parsed;var s=i._sorted&&e===i.iScale,r=a.length;const n=this._getOtherScale(e);var o=createStack(t,i,this.chart),l={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};const{min:h,max:d}=getUserBounds(n);let c,u;function g(){u=a[c];var t=u[n.axis];return!isNumberFinite(u[e.axis])||h>t||d<t}for(c=0;c<r&&(g()||(this.updateRangeFromParsed(l,e,u,o),!s));++c);if(s)for(c=r-1;0<=c;--c)if(!g()){this.updateRangeFromParsed(l,e,u,o);break}return l}getAllParsedValues(t){var e=this._cachedMeta._parsed;const i=[];let a,s,r;for(a=0,s=e.length;a<s;++a)r=e[a][t.axis],isNumberFinite(r)&&i.push(r);return i}getMaxOverflow(){return!1}getLabelAndValue(t){var e=this._cachedMeta;const i=e.iScale,a=e.vScale;t=this.getParsed(t);return{label:i?""+i.getLabelForValue(t[i.axis]):"",value:a?""+a.getLabelForValue(t[a.axis]):""}}_update(t){const e=this._cachedMeta;this.update(t||"default"),e._clip=toClip(valueOrDefault(this.options.clip,defaultClip(e.xScale,e.yScale,this.getMaxOverflow())))}update(t){}draw(){var t=this._ctx,e=this.chart;const i=this._cachedMeta;var a=i.data||[],s=e.chartArea;const r=[];var n=this._drawStart||0,o=this._drawCount||a.length-n,l=this.options.drawActiveElementsOnTop;let h;for(i.dataset&&i.dataset.draw(t,s,n,o),h=n;h<n+o;++h){const d=a[h];d.hidden||(d.active&&l?r.push(d):d.draw(t,s))}for(h=0;h<r.length;++h)r[h].draw(t,s)}getStyle(t,e){e=e?"active":"default";return void 0===t&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(e):this.resolveDataElementOptions(t||0,e)}getContext(t,e,i){var a=this.getDataset();let s;if(0<=t&&t<this._cachedMeta.data.length){const r=this._cachedMeta.data[t];s=r.$context||(r.$context=createDataContext(this.getContext(),t,r)),s.parsed=this.getParsed(t),s.raw=a.data[t],s.index=s.dataIndex=t}else s=this.$context||(this.$context=createDatasetContext(this.chart.getContext(),this.index)),s.dataset=a,s.index=s.datasetIndex=this.index;return s.active=!!e,s.mode=i,s}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,e){return this._resolveElementOptions(this.dataElementType.id,e,t)}_resolveElementOptions(t,e="default",i){const a="active"===e,s=this._cachedDataOpts;var r=t+"-"+e,n=s[r],o=this.enableOptionSharing&&defined(i);if(n)return cloneIfNotShared(n,o);const l=this.chart.config;e=l.datasetElementScopeKeys(this._type,t),n=a?[`${t}Hover`,"hover",t,""]:[t,""],e=l.getOptionScopes(this.getDataset(),e),t=Object.keys(defaults.elements[t]);const h=l.resolveNamedOptions(e,t,()=>this.getContext(i,a),n);return h.$shared&&(h.$shared=o,s[r]=Object.freeze(cloneIfNotShared(h,o))),h}_resolveAnimations(t,e,i){var a=this.chart;const s=this._cachedDataOpts;var r=`animation-${e}`,n=s[r];if(n)return n;let o;if(!1!==a.options.animation){const l=this.chart.config;n=l.datasetAnimationScopeKeys(this._type,e),n=l.getOptionScopes(this.getDataset(),n);o=l.createResolver(n,this.getContext(t,i,e))}a=new Animations(a,o&&o.animations);return o&&o._cacheable&&(s[r]=Object.freeze(a)),a}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||isDirectUpdateMode(t)||this.chart._animationsDisabled}updateElement(t,e,i,a){isDirectUpdateMode(a)?Object.assign(t,i):this._resolveAnimations(e,a).update(t,i)}updateSharedOptions(t,e,i){t&&!isDirectUpdateMode(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,a){t.active=a;var s=this.getStyle(e,a);this._resolveAnimations(e,i,a).update(t,{options:!a&&this.getSharedOptions(s)||s})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){var t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){var t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){var e,i,a,s=this._data,r=this._cachedMeta.data;for([e,i,a]of this._syncList)this[e](i,a);this._syncList=[];var n=r.length,r=s.length,s=Math.min(r,n);s&&this.parse(0,s),n<r?this._insertElements(n,r-n,t):r<n&&this._removeElements(r,n-r)}_insertElements(t,e,i=!0){var a=this._cachedMeta;const s=a.data,r=t+e;let n;var o=t=>{for(t.length+=e,n=t.length-1;n>=r;n--)t[n]=t[n-e]};for(o(s),n=t;n<r;++n)s[n]=new this.dataElementType;this._parsing&&o(a._parsed),this.parse(t,e),i&&this.updateElements(s,t,e,"reset")}updateElements(t,e,i,a){}_removeElements(t,e){const i=this._cachedMeta;var a;this._parsing&&(a=i._parsed.splice(t,e),i._stacked&&clearStacks(i,a)),i.data.splice(t,e)}_sync(t){var e,i,a;this._parsing?this._syncList.push(t):([e,i,a]=t,this[e](i,a)),this.chart._dataChanges.push([this.index,...t])}_onDataPush(){var t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,e){e&&this._sync(["_removeElements",t,e]);var i=arguments.length-2;i&&this._sync(["_insertElements",t,i])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}function getAllScaleValues(a,t){if(!a._cache.$bar){const s=a.getMatchingVisibleMetas(t);let i=[];for(let t=0,e=s.length;t<e;t++)i=i.concat(s[t].controller.getAllParsedValues(a));a._cache.$bar=_arrayUnique(i.sort((t,e)=>t-e))}return a._cache.$bar}function computeMinSampleSize(t){const e=t.iScale;var i=getAllScaleValues(e,t.type);let a=e._length,s,r,n,o;var l=()=>{32767!==n&&-32768!==n&&(defined(o)&&(a=Math.min(a,Math.abs(n-o)||a)),o=n)};for(s=0,r=i.length;s<r;++s)n=e.getPixelForValue(i[s]),l();for(o=void 0,s=0,r=e.ticks.length;s<r;++s)n=e.getPixelForTick(s),l();return a}function computeFitCategoryTraits(t,e,i,a){var s=i.barThickness;let r,n;return n=isNullOrUndef(s)?(r=e.min*i.categoryPercentage,i.barPercentage):(r=s*a,1),{chunk:r/a,ratio:n,start:e.pixels[t]-r/2}}function computeFlexCategoryTraits(t,e,i,a){var s=e.pixels,r=s[t];let n=0<t?s[t-1]:null,o=t<s.length-1?s[t+1]:null;t=i.categoryPercentage;null===n&&(n=r-(null===o?e.end-e.start:o-r)),null===o&&(o=r+r-n);r-=(r-Math.min(n,o))/2*t;return{chunk:Math.abs(o-n)/2*t/a,ratio:i.barPercentage,start:r}}function parseFloatBar(t,e,i,a){var s=i.parse(t[0],a),r=i.parse(t[1],a),t=Math.min(s,r),a=Math.max(s,r);let n=t,o=a;Math.abs(t)>Math.abs(a)&&(n=a,o=t),e[i.axis]=o,e._custom={barStart:n,barEnd:o,start:s,end:r,min:t,max:a}}function parseValue(t,e,i,a){return isArray(t)?parseFloatBar(t,e,i,a):e[i.axis]=i.parse(t,a),e}function parseArrayOrPrimitive(t,e,i,a){const s=t.iScale;var r=t.vScale,n=s.getLabels(),o=s===r;const l=[];let h,d,c,u;for(d=(h=i)+a;h<d;++h)u=e[h],c={},c[s.axis]=o||s.parse(n[h],h),l.push(parseValue(u,c,r,h));return l}function isFloatBar(t){return t&&void 0!==t.barStart&&void 0!==t.barEnd}function barSign(t,e,i){return 0!==t?sign(t):(e.isHorizontal()?1:-1)*(e.min>=i?1:-1)}function borderProps(t){let e,i,a,s,r;return a=t.horizontal?(e=t.base>t.x,i="left","right"):(e=t.base<t.y,i="bottom","top"),r=e?(s="end","start"):(s="start","end"),{start:i,end:a,reverse:e,top:s,bottom:r}}function setBorderSkipped(t,e,i,a){let s=e.borderSkipped;const r={};var n,o,l,h;s&&({start:n,end:o,reverse:l,top:h,bottom:e}=borderProps(t),"middle"===s&&i&&(t.enableBorderRadius=!0,s=(i._top||0)===a?h:(i._bottom||0)===a?e:(r[parseEdge(e,n,o,l)]=!0,h)),r[parseEdge(s,n,o,l)]=!0),t.borderSkipped=r}function parseEdge(t,e,i,a){return t=a?startEnd(t=swap(t,e,i),i,e):startEnd(t,e,i)}function swap(t,e,i){return t===e?i:t===i?e:t}function startEnd(t,e,i){return"start"===t?e:"end"===t?i:t}function setInflateAmount(t,{inflateAmount:e},i){t.inflateAmount="auto"===e?1===i?.33:0:e}DatasetController.defaults={},DatasetController.prototype.datasetElementType=null,DatasetController.prototype.dataElementType=null;class BarController extends DatasetController{parsePrimitiveData(t,e,i,a){return parseArrayOrPrimitive(t,e,i,a)}parseArrayData(t,e,i,a){return parseArrayOrPrimitive(t,e,i,a)}parseObjectData(t,e,i,a){const{iScale:s,vScale:r}=t;var{xAxisKey:n="x",yAxisKey:t="y"}=this._parsing,o="x"===s.axis?n:t,l="x"===r.axis?n:t;const h=[];let d,c,u,g;for(c=(d=i)+a;d<c;++d)g=e[d],u={},u[s.axis]=s.parse(resolveObjectKey(g,o),d),h.push(parseValue(resolveObjectKey(g,l),u,r,d));return h}updateRangeFromParsed(t,e,i,a){super.updateRangeFromParsed(t,e,i,a);i=i._custom;i&&e===this._cachedMeta.vScale&&(t.min=Math.min(t.min,i.min),t.max=Math.max(t.max,i.max))}getMaxOverflow(){return 0}getLabelAndValue(t){const{iScale:e,vScale:i}=this._cachedMeta;var a=this.getParsed(t),t=a._custom,t=isFloatBar(t)?"["+t.start+", "+t.end+"]":""+i.getLabelForValue(a[i.axis]);return{label:""+e.getLabelForValue(a[e.axis]),value:t}}initialize(){this.enableOptionSharing=!0,super.initialize();const t=this._cachedMeta;t.stack=this.getDataset().stack}update(t){var e=this._cachedMeta;this.updateElements(e.data,0,e.data.length,t)}updateElements(e,i,a,s){var r="reset"===s;const{index:n,_cachedMeta:{vScale:o}}=this;var l=o.getBasePixel(),h=o.isHorizontal(),d=this._getRuler(),t=this.resolveDataElementOptions(i,s),c=this.getSharedOptions(t),u=this.includeOptions(s,c);this.updateSharedOptions(c,s,t);for(let t=i;t<i+a;t++){var g=this.getParsed(t),p=r||isNullOrUndef(g[o.axis])?{base:l,head:l}:this._calculateBarValuePixels(t),f=this._calculateBarIndexPixels(t,d),m=(g._stacks||{})[o.axis];const v={horizontal:h,base:p.base,enableBorderRadius:!m||isFloatBar(g._custom)||n===m._top||n===m._bottom,x:h?p.head:f.center,y:h?f.center:p.head,height:h?f.size:Math.abs(p.size),width:h?Math.abs(p.size):f.size};u&&(v.options=c||this.resolveDataElementOptions(t,e[t].active?"active":s));f=v.options||e[t].options;setBorderSkipped(v,f,m,n),setInflateAmount(v,f,d.ratio),this.updateElement(e[t],t,v,s)}}_getStacks(t,e){const i=this._cachedMeta.iScale;var a=i.getMatchingVisibleMetas(this._type),s=i.options.stacked,r=a.length;const n=[];let o,l;for(o=0;o<r;++o)if(l=a[o],l.controller.options.grouped){if(void 0!==e){var h=l.controller.getParsed(e)[l.controller._cachedMeta.vScale.axis];if(isNullOrUndef(h)||isNaN(h))continue}if((!1===s||-1===n.indexOf(l.stack)||void 0===s&&void 0===l.stack)&&n.push(l.stack),l.index===t)break}return n.length||n.push(void 0),n}_getStackCount(t){return this._getStacks(void 0,t).length}_getStackIndex(t,e,i){const a=this._getStacks(t,i);e=void 0!==e?a.indexOf(e):-1;return-1===e?a.length-1:e}_getRuler(){var t=this.options,e=this._cachedMeta;const i=e.iScale,a=[];let s,r;for(s=0,r=e.data.length;s<r;++s)a.push(i.getPixelForValue(this.getParsed(s)[i.axis],s));var n=t.barThickness;return{min:n||computeMinSampleSize(e),pixels:a,start:i._startPixel,end:i._endPixel,stackCount:this._getStackCount(),scale:i,grouped:t.grouped,ratio:n?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:e,_stacked:i},options:{base:a,minBarLength:s}}=this;var r=a||0,n=this.getParsed(t),o=n._custom,l=isFloatBar(o);let h=n[e.axis],d=0,c=i?this.applyStack(e,n,i):h,u,g;c!==h&&(d=c-h,c=h),l&&(h=o.barStart,c=o.barEnd-o.barStart,0!==h&&sign(h)!==sign(o.barEnd)&&(d=0),d+=h);l=isNullOrUndef(a)||l?d:a;let p=e.getPixelForValue(l);return u=this.chart.getDataVisibility(t)?e.getPixelForValue(d+c):p,g=u-p,Math.abs(g)<s&&(g=barSign(g,e,r)*s,h===r&&(p-=g/2),u=p+g),p===e.getPixelForValue(r)&&(r=sign(g)*e.getLineWidthForValue(r)/2,p+=r,g-=r),{size:g,base:p,head:u,center:u+g/2}}_calculateBarIndexPixels(t,e){const i=e.scale;var a,s=this.options,r=s.skipNull,n=valueOrDefault(s.maxBarThickness,1/0);let o,l;return l=e.grouped?(a=r?this._getStackCount(t):e.stackCount,a=("flex"===s.barThickness?computeFlexCategoryTraits:computeFitCategoryTraits)(t,e,s,a),r=this._getStackIndex(this.index,this._cachedMeta.stack,r?t:void 0),o=a.start+a.chunk*r+a.chunk/2,Math.min(n,a.chunk*a.ratio)):(o=i.getPixelForValue(this.getParsed(t)[i.axis],t),Math.min(n,e.min*e.ratio)),{base:o-l/2,head:o+l/2,center:o,size:l}}draw(){var t=this._cachedMeta,e=t.vScale;const i=t.data;var a=i.length;let s=0;for(;s<a;++s)null!==this.getParsed(s)[e.axis]&&i[s].draw(this._ctx)}}BarController.id="bar",BarController.defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}},BarController.overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};class BubbleController extends DatasetController{initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(t,e,i,a){const s=super.parsePrimitiveData(t,e,i,a);for(let t=0;t<s.length;t++)s[t]._custom=this.resolveDataElementOptions(t+i).radius;return s}parseArrayData(t,e,i,a){const s=super.parseArrayData(t,e,i,a);for(let t=0;t<s.length;t++){var r=e[i+t];s[t]._custom=valueOrDefault(r[2],this.resolveDataElementOptions(t+i).radius)}return s}parseObjectData(t,e,i,a){const s=super.parseObjectData(t,e,i,a);for(let t=0;t<s.length;t++){var r=e[i+t];s[t]._custom=valueOrDefault(r&&r.r&&+r.r,this.resolveDataElementOptions(t+i).radius)}return s}getMaxOverflow(){const e=this._cachedMeta.data;let i=0;for(let t=e.length-1;0<=t;--t)i=Math.max(i,e[t].size(this.resolveDataElementOptions(t))/2);return 0<i&&i}getLabelAndValue(t){var e=this._cachedMeta;const{xScale:i,yScale:a}=e;var s=this.getParsed(t),r=i.getLabelForValue(s.x),t=a.getLabelForValue(s.y),s=s._custom;return{label:e.label,value:"("+r+", "+t+(s?", "+s:"")+")"}}update(t){var e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(e,i,a,s){var r="reset"===s;const{iScale:n,vScale:o}=this._cachedMeta;var t=this.resolveDataElementOptions(i,s),l=this.getSharedOptions(t),h=this.includeOptions(s,l),d=n.axis,c=o.axis;for(let t=i;t<i+a;t++){var u=e[t],g=!r&&this.getParsed(t);const f={};var p=f[d]=r?n.getPixelForDecimal(.5):n.getPixelForValue(g[d]),g=f[c]=r?o.getBasePixel():o.getPixelForValue(g[c]);f.skip=isNaN(p)||isNaN(g),h&&(f.options=this.resolveDataElementOptions(t,u.active?"active":s),r&&(f.options.radius=0)),this.updateElement(u,t,f,s)}this.updateSharedOptions(l,s,t)}resolveDataElementOptions(t,e){var i=this.getParsed(t);let a=super.resolveDataElementOptions(t,e);a.$shared&&(a=Object.assign({},a,{$shared:!1}));t=a.radius;return"active"!==e&&(a.radius=0),a.radius+=valueOrDefault(i&&i._custom,t),a}}function getRatioAndOffset(t,e,a){let i=1,s=1,r=0,n=0;if(e<TAU){const u=t,g=u+e;var o=Math.cos(u),l=Math.sin(u),h=Math.cos(g),d=Math.sin(g),c=(t,e,i)=>_angleBetween(t,u,g,!0)?1:Math.max(e,e*a,i,i*a),t=(t,e,i)=>_angleBetween(t,u,g,!0)?-1:Math.min(e,e*a,i,i*a),e=c(0,o,h),c=c(HALF_PI,l,d),h=t(PI,o,h),d=t(PI+HALF_PI,l,d);i=(e-h)/2,s=(c-d)/2,r=-(e+h)/2,n=-(c+d)/2}return{ratioX:i,ratioY:s,offsetX:r,offsetY:n}}BubbleController.id="bubble",BubbleController.defaults={datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}},BubbleController.overrides={scales:{x:{type:"linear"},y:{type:"linear"}},plugins:{tooltip:{callbacks:{title(){return""}}}}};class DoughnutController extends DatasetController{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(a,s){const r=this.getDataset().data,n=this._cachedMeta;if(!1===this._parsing)n._parsed=r;else{let t=t=>+r[t];if(isObject(r[a])){const{key:o="value"}=this._parsing;t=t=>+resolveObjectKey(r[t],o)}let e,i;for(i=(e=a)+s;e<i;++e)n._parsed[e]=t(e)}}_getRotation(){return toRadians(this.options.rotation-90)}_getCircumference(){return toRadians(this.options.circumference)}_getRotationExtents(){let e=TAU,i=-TAU;for(let t=0;t<this.chart.data.datasets.length;++t)if(this.chart.isDatasetVisible(t)){const r=this.chart.getDatasetMeta(t).controller;var a=r._getRotation(),s=r._getCircumference();e=Math.min(e,a),i=Math.max(i,a+s)}return{rotation:e,circumference:i-e}}update(t){var e=this.chart["chartArea"];const i=this._cachedMeta;var a=i.data,s=this.getMaxBorderWidth()+this.getMaxOffset(a)+this.options.spacing,r=Math.max((Math.min(e.width,e.height)-s)/2,0),n=Math.min(toPercentage(this.options.cutout,r),1),o=this._getRingWeight(this.index),{circumference:l,rotation:h}=this._getRotationExtents(),{ratioX:d,ratioY:r,offsetX:h,offsetY:l}=getRatioAndOffset(h,l,n),d=(e.width-s)/d,r=(e.height-s)/r,r=Math.max(Math.min(d,r)/2,0),r=toDimension(this.options.radius,r),n=(r-Math.max(r*n,0))/this._getVisibleDatasetWeightTotal();this.offsetX=h*r,this.offsetY=l*r,i.total=this.calculateTotal(),this.outerRadius=r-n*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-n*o,0),this.updateElements(a,0,a.length,t)}_circumference(t,e){var i=this.options,a=this._cachedMeta,s=this._getCircumference();return e&&i.animation.animateRotate||!this.chart.getDataVisibility(t)||null===a._parsed[t]||a.data[t].hidden?0:this.calculateCircumference(a._parsed[t]*s/TAU)}updateElements(t,e,i,a){var s="reset"===a,r=this.chart,n=r.chartArea,r=r.options.animation,o=(n.left+n.right)/2,l=(n.top+n.bottom)/2,r=s&&r.animateScale,h=r?0:this.innerRadius,d=r?0:this.outerRadius,r=this.resolveDataElementOptions(e,a),c=this.getSharedOptions(r),u=this.includeOptions(a,c);let g=this._getRotation(),p;for(p=0;p<e;++p)g+=this._circumference(p,s);for(p=e;p<e+i;++p){var f=this._circumference(p,s),m=t[p];const v={x:o+this.offsetX,y:l+this.offsetY,startAngle:g,endAngle:g+f,circumference:f,outerRadius:d,innerRadius:h};u&&(v.options=c||this.resolveDataElementOptions(p,m.active?"active":a)),g+=f,this.updateElement(m,p,v,a)}this.updateSharedOptions(c,a,r)}calculateTotal(){var t=this._cachedMeta,e=t.data;let i=0,a;for(a=0;a<e.length;a++){var s=t._parsed[a];null===s||isNaN(s)||!this.chart.getDataVisibility(a)||e[a].hidden||(i+=Math.abs(s))}return i}calculateCircumference(t){var e=this._cachedMeta.total;return 0<e&&!isNaN(t)?TAU*(Math.abs(t)/e):0}getLabelAndValue(t){var e=this._cachedMeta,i=this.chart,a=i.data.labels||[],i=formatNumber(e._parsed[t],i.options.locale);return{label:a[t]||"",value:i}}getMaxBorderWidth(t){let e=0;const i=this.chart;let a,s,r,n,o;if(!t)for(a=0,s=i.data.datasets.length;a<s;++a)if(i.isDatasetVisible(a)){t=(r=i.getDatasetMeta(a)).data,n=r.controller;break}if(!t)return 0;for(a=0,s=t.length;a<s;++a)"inner"!==(o=n.resolveDataElementOptions(a)).borderAlign&&(e=Math.max(e,o.borderWidth||0,o.hoverBorderWidth||0));return e}getMaxOffset(i){let a=0;for(let t=0,e=i.length;t<e;++t){var s=this.resolveDataElementOptions(t);a=Math.max(a,s.offset||0,s.hoverOffset||0)}return a}_getRingWeightOffset(e){let i=0;for(let t=0;t<e;++t)this.chart.isDatasetVisible(t)&&(i+=this._getRingWeight(t));return i}_getRingWeight(t){return Math.max(valueOrDefault(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}DoughnutController.id="doughnut",DoughnutController.defaults={datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"},DoughnutController.descriptors={_scriptable:t=>"spacing"!==t,_indexable:t=>"spacing"!==t},DoughnutController.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(s){const t=s.data;if(t.labels.length&&t.datasets.length){const{labels:{pointStyle:r}}=s.legend.options;return t.labels.map((t,e)=>{const i=s.getDatasetMeta(0);var a=i.controller.getStyle(e);return{text:t,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,lineWidth:a.borderWidth,pointStyle:r,hidden:!s.getDataVisibility(e),index:e}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title(){return""},label(t){let e=t.label;t=": "+t.formattedValue;return isArray(e)?(e=e.slice(),e[0]+=t):e+=t,e}}}}};class LineController extends DatasetController{initialize(){this.enableOptionSharing=!0,super.initialize()}update(t){var e=this._cachedMeta;const{dataset:i,data:a=[],_dataset:s}=e;var r=this.chart._animationsDisabled;let{start:n,count:o}=getStartAndCountOfVisiblePoints(e,a,r);this._drawStart=n,this._drawCount=o,scaleRangesChanged(e)&&(n=0,o=a.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!s._decimated,i.points=a;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(i,void 0,{animated:!r,options:l},t),this.updateElements(a,n,o,t)}updateElements(e,i,a,s){var r="reset"===s;const{iScale:n,vScale:o,_stacked:l,_dataset:h}=this._cachedMeta;var t=this.resolveDataElementOptions(i,s),d=this.getSharedOptions(t),c=this.includeOptions(s,d),u=n.axis,g=o.axis,{spanGaps:p,segment:f}=this.options,m=isNumber(p)?p:Number.POSITIVE_INFINITY,v=this.chart._animationsDisabled||r||"none"===s;let x=0<i&&this.getParsed(i-1);for(let t=i;t<i+a;++t){var b=e[t],_=this.getParsed(t);const M=v?b:{};var y=isNullOrUndef(_[g]),S=M[u]=n.getPixelForValue(_[u],t),k=M[g]=r||y?o.getBasePixel():o.getPixelForValue(l?this.applyStack(o,_,l):_[g],t);M.skip=isNaN(S)||isNaN(k)||y,M.stop=0<t&&_[u]-x[u]>m,f&&(M.parsed=_,M.raw=h.data[t]),c&&(M.options=d||this.resolveDataElementOptions(t,b.active?"active":s)),v||this.updateElement(b,t,M,s),x=_}this.updateSharedOptions(d,s,t)}getMaxOverflow(){var t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0;const a=t.data||[];if(!a.length)return i;e=a[0].size(this.resolveDataElementOptions(0)),t=a[a.length-1].size(this.resolveDataElementOptions(a.length-1));return Math.max(i,e,t)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}function getStartAndCountOfVisiblePoints(t,e,i){var a=e.length;let s=0,r=a;if(t._sorted){const{iScale:d,_parsed:c}=t;var n=d.axis,{min:o,max:l,minDefined:h,maxDefined:t}=d.getUserBounds();h&&(s=_limitValue(Math.min(_lookupByKey(c,d.axis,o).lo,i?a:_lookupByKey(e,n,d.getPixelForValue(o)).lo),0,a-1)),r=t?_limitValue(Math.max(_lookupByKey(c,d.axis,l).hi+1,i?0:_lookupByKey(e,n,d.getPixelForValue(l)).hi+1),s,a)-s:a-s}return{start:s,count:r}}function scaleRangesChanged(t){var{xScale:e,yScale:i,_scaleRanges:a}=t,s={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!a)return t._scaleRanges=s,!0;i=a.xmin!==e.min||a.xmax!==e.max||a.ymin!==i.min||a.ymax!==i.max;return Object.assign(a,s),i}LineController.id="line",LineController.defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1},LineController.overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};class PolarAreaController extends DatasetController{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){var e=this._cachedMeta,i=this.chart,a=i.data.labels||[],i=formatNumber(e._parsed[t].r,i.options.locale);return{label:a[t]||"",value:i}}update(t){var e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}_updateRadius(){const t=this.chart;var e=t.chartArea,i=t.options,e=Math.min(e.right-e.left,e.bottom-e.top),e=Math.max(e/2,0),i=(e-Math.max(i.cutoutPercentage?e/100*i.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=e-i*this.index,this.innerRadius=this.outerRadius-i}updateElements(a,t,e,s){var r="reset"===s;const n=this.chart;var o=this.getDataset(),l=n.options.animation;const h=this._cachedMeta.rScale;var d=h.xCenter,c=h.yCenter,u=h.getIndexAngle(0)-.5*PI;let g=u,p;var f=360/this.countVisibleElements();for(p=0;p<t;++p)g+=this._computeAngle(p,s,f);for(p=t;p<t+e;p++){var m=a[p];let t=g,e=g+this._computeAngle(p,s,f),i=n.getDataVisibility(p)?h.getDistanceFromCenterForValue(o.data[p]):0;g=e,r&&(l.animateScale&&(i=0),l.animateRotate&&(t=e=u));var v={x:d,y:c,innerRadius:0,outerRadius:i,startAngle:t,endAngle:e,options:this.resolveDataElementOptions(p,m.active?"active":s)};this.updateElement(m,p,v,s)}}countVisibleElements(){const i=this.getDataset(),t=this._cachedMeta;let a=0;return t.data.forEach((t,e)=>{!isNaN(i.data[e])&&this.chart.getDataVisibility(e)&&a++}),a}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?toRadians(this.resolveDataElementOptions(t,e).angle||i):0}}PolarAreaController.id="polarArea",PolarAreaController.defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0},PolarAreaController.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(s){const t=s.data;if(t.labels.length&&t.datasets.length){const{labels:{pointStyle:r}}=s.legend.options;return t.labels.map((t,e)=>{const i=s.getDatasetMeta(0);var a=i.controller.getStyle(e);return{text:t,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,lineWidth:a.borderWidth,pointStyle:r,hidden:!s.getDataVisibility(e),index:e}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title(){return""},label(t){return 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 PieController extends DoughnutController{}PieController.id="pie",PieController.defaults={cutout:0,rotation:0,circumference:360,radius:"100%"};class RadarController extends DatasetController{getLabelAndValue(t){const e=this._cachedMeta.vScale;var i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}update(t){const e=this._cachedMeta,i=e.dataset;var a=e.data||[],s=e.iScale.getLabels();if(i.points=a,"resize"!==t){const r=this.resolveDatasetElementOptions(t);this.options.showLine||(r.borderWidth=0);s={_loop:!0,_fullLoop:s.length===a.length,options:r};this.updateElement(i,void 0,s,t)}this.updateElements(a,0,a.length,t)}updateElements(e,i,a,s){var r=this.getDataset();const n=this._cachedMeta.rScale;var o="reset"===s;for(let t=i;t<i+a;t++){var l=e[t],h=this.resolveDataElementOptions(t,l.active?"active":s),d=n.getPointPositionForValue(t,r.data[t]),c=o?n.xCenter:d.x,u=o?n.yCenter:d.y,h={x:c,y:u,angle:d.angle,skip:isNaN(c)||isNaN(u),options:h};this.updateElement(l,t,h,s)}}}RadarController.id="radar",RadarController.defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}},RadarController.overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};class ScatterController extends LineController{}ScatterController.id="scatter",ScatterController.defaults={showLine:!1,fill:!1},ScatterController.overrides={interaction:{mode:"point"},plugins:{tooltip:{callbacks:{title(){return""},label(t){return"("+t.label+", "+t.formattedValue+")"}}}},scales:{x:{type:"linear"},y:{type:"linear"}}};var controllers=Object.freeze({__proto__:null,BarController:BarController,BubbleController:BubbleController,DoughnutController:DoughnutController,LineController:LineController,PolarAreaController:PolarAreaController,PieController:PieController,RadarController:RadarController,ScatterController:ScatterController});function abstract(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class DateAdapter{constructor(t){this.options=t||{}}formats(){return abstract()}parse(t,e){return abstract()}format(t,e){return abstract()}add(t,e,i){return abstract()}diff(t,e,i){return abstract()}startOf(t,e,i){return abstract()}endOf(t,e){return abstract()}}DateAdapter.override=function(t){Object.assign(DateAdapter.prototype,t)};var adapters={_date:DateAdapter};function getRelativePosition(t,e){return"native"in t?{x:t.x,y:t.y}:getRelativePosition$1(t,e)}function evaluateAllVisibleItems(t,i){var a,s,r,n=t.getSortedVisibleDatasetMetas();for(let t=0,e=n.length;t<e;++t){({index:a,data:s}=n[t]);for(let t=0,e=s.length;t<e;++t)(r=s[t]).skip||i(r,a,t)}}function binarySearch(t,e,i,a){var{controller:s,data:r,_sorted:n}=t,t=s._cachedMeta.iScale;if(t&&e===t.axis&&"r"!==e&&n&&r.length){const o=t._reversePixels?_rlookupByKey:_lookupByKey;if(!a)return o(r,e,i);if(s._sharedOptions){const l=r[0];a="function"==typeof l.getRange&&l.getRange(e);if(a){s=o(r,e,i-a),a=o(r,e,i+a);return{lo:s.lo,hi:a.hi}}}}return{lo:0,hi:r.length-1}}function optimizedEvaluateItems(t,i,e,a,s){var r=t.getSortedVisibleDatasetMetas(),n=e[i];for(let t=0,e=r.length;t<e;++t){var{index:o,data:l}=r[t],{lo:h,hi:d}=binarySearch(r[t],i,n,s);for(let t=h;t<=d;++t){var c=l[t];c.skip||a(c,o,t)}}}function getDistanceMetricForAxis(t){const a=-1!==t.indexOf("x"),s=-1!==t.indexOf("y");return function(t,e){var i=a?Math.abs(t.x-e.x):0,e=s?Math.abs(t.y-e.y):0;return Math.sqrt(Math.pow(i,2)+Math.pow(e,2))}}function getIntersectItems(t,a,e,s){const r=[];if(!_isPointInArea(a,t.chartArea,t._minPadding))return r;return optimizedEvaluateItems(t,e,a,function(t,e,i){t.inRange(a.x,a.y,s)&&r.push({element:t,datasetIndex:e,index:i})},!0),r}function getNearestRadialItems(t,n,e,o){let l=[];return optimizedEvaluateItems(t,e,n,function(t,e,i){var{startAngle:a,endAngle:s}=t.getProps(["startAngle","endAngle"],o),r=getAngleFromPoint(t,{x:n.x,y:n.y})["angle"];_angleBetween(r,a,s)&&l.push({element:t,datasetIndex:e,index:i})}),l}function getNearestCartesianItems(r,n,t,o,l){let h=[];const d=getDistanceMetricForAxis(t);let c=Number.POSITIVE_INFINITY;return optimizedEvaluateItems(r,t,n,function(t,e,i){var a,s=t.inRange(n.x,n.y,l);o&&!s||(a=t.getCenterPoint(l),(_isPointInArea(a,r.chartArea,r._minPadding)||s)&&((a=d(n,a))<c?(h=[{element:t,datasetIndex:e,index:i}],c=a):a===c&&h.push({element:t,datasetIndex:e,index:i})))}),h}function getNearestItems(t,e,i,a,s){return _isPointInArea(e,t.chartArea,t._minPadding)?"r"!==i||a?getNearestCartesianItems(t,e,i,a,s):getNearestRadialItems(t,e,i,s):[]}function getAxisItems(t,e,i,a){const s=getRelativePosition(e,t),r=[],n=i.axis,o="x"===n?"inXRange":"inYRange";let l=!1;return evaluateAllVisibleItems(t,(t,e,i)=>{t[o](s[n],a)&&r.push({element:t,datasetIndex:e,index:i}),t.inRange(s.x,s.y,a)&&(l=!0)}),i.intersect&&!l?[]:r}var Interaction={modes:{index(t,e,i,a){var s=getRelativePosition(e,t),e=i.axis||"x";const r=i.intersect?getIntersectItems(t,s,e,a):getNearestItems(t,s,e,!1,a),n=[];return r.length?(t.getSortedVisibleDatasetMetas().forEach(t=>{var e=r[0].index,i=t.data[e];i&&!i.skip&&n.push({element:i,datasetIndex:t.index,index:e})}),n):[]},dataset(t,e,i,a){var s=getRelativePosition(e,t),e=i.axis||"xy";let r=i.intersect?getIntersectItems(t,s,e,a):getNearestItems(t,s,e,!1,a);if(0<r.length){var n=r[0].datasetIndex,o=t.getDatasetMeta(n).data;r=[];for(let t=0;t<o.length;++t)r.push({element:o[t],datasetIndex:n,index:t})}return r},point(t,e,i,a){return getIntersectItems(t,getRelativePosition(e,t),i.axis||"xy",a)},nearest(t,e,i,a){return getNearestItems(t,getRelativePosition(e,t),i.axis||"xy",i.intersect,a)},x(t,e,i,a){return getAxisItems(t,e,{axis:"x",intersect:i.intersect},a)},y(t,e,i,a){return getAxisItems(t,e,{axis:"y",intersect:i.intersect},a)}}};const STATIC_POSITIONS=["left","top","right","bottom"];function filterByPosition(t,e){return t.filter(t=>t.pos===e)}function filterDynamicPositionByAxis(t,e){return t.filter(t=>-1===STATIC_POSITIONS.indexOf(t.pos)&&t.box.axis===e)}function sortByWeight(t,a){return t.sort((t,e)=>{var i=a?e:t,e=a?t:e;return i.weight===e.weight?i.index-e.index:i.weight-e.weight})}function wrapBoxes(t){const e=[];let i,a,s,r,n,o;for(i=0,a=(t||[]).length;i<a;++i)s=t[i],{position:r,options:{stack:n,stackWeight:o=1}}=s,e.push({index:i,box:s,pos:r,horizontal:s.isHorizontal(),weight:s.weight,stack:n&&r+n,stackWeight:o});return e}function buildStacks(t){const e={};for(const r of t){var{stack:i,pos:a,stackWeight:s}=r;if(i&&STATIC_POSITIONS.includes(a)){const n=e[i]||(e[i]={count:0,placed:0,weight:0,size:0});n.count++,n.weight+=s}}return e}function setLayoutDims(t,e){var i=buildStacks(t),{vBoxMaxWidth:a,hBoxMaxHeight:s}=e;let r,n,o;for(r=0,n=t.length;r<n;++r){o=t[r];var l=o.box["fullSize"],h=i[o.stack],h=h&&o.stackWeight/h.weight;o.horizontal?(o.width=h?h*a:l&&e.availableWidth,o.height=s):(o.width=a,o.height=h?h*s:l&&e.availableHeight)}return i}function buildLayoutBoxes(t){const e=wrapBoxes(t);var i=sortByWeight(e.filter(t=>t.box.fullSize),!0);const a=sortByWeight(filterByPosition(e,"left"),!0),s=sortByWeight(filterByPosition(e,"right")),r=sortByWeight(filterByPosition(e,"top"),!0);var n=sortByWeight(filterByPosition(e,"bottom")),o=filterDynamicPositionByAxis(e,"x"),t=filterDynamicPositionByAxis(e,"y");return{fullSize:i,leftAndTop:a.concat(r),rightAndBottom:s.concat(t).concat(n).concat(o),chartArea:filterByPosition(e,"chartArea"),vertical:a.concat(s).concat(t),horizontal:r.concat(n).concat(o)}}function getCombinedMax(t,e,i,a){return Math.max(t[i],e[i])+Math.max(t[a],e[a])}function updateMaxPadding(t,e){t.top=Math.max(t.top,e.top),t.left=Math.max(t.left,e.left),t.bottom=Math.max(t.bottom,e.bottom),t.right=Math.max(t.right,e.right)}function updateDims(t,e,i,a){const{pos:s,box:r}=i;var n=t.maxPadding;if(!isObject(s)){i.size&&(t[s]-=i.size);const l=a[i.stack]||{size:0,count:1};l.size=Math.max(l.size,i.horizontal?r.height:r.width),i.size=l.size/l.count,t[s]+=i.size}r.getPadding&&updateMaxPadding(n,r.getPadding());var o=Math.max(0,e.outerWidth-getCombinedMax(n,t,"left","right")),a=Math.max(0,e.outerHeight-getCombinedMax(n,t,"top","bottom")),e=o!==t.w,n=a!==t.h;return t.w=o,t.h=a,i.horizontal?{same:e,other:n}:{same:n,other:e}}function handleMaxPadding(i){const a=i.maxPadding;function t(t){var e=Math.max(a[t]-i[t],0);return i[t]+=e,e}i.y+=t("top"),i.x+=t("left"),t("right"),t("bottom")}function getMargins(t,i){const a=i.maxPadding;function e(t){const e={left:0,top:0,right:0,bottom:0};return t.forEach(t=>{e[t]=Math.max(i[t],a[t])}),e}return e(t?["left","right"]:["top","bottom"])}function fitBoxes(t,e,i,a){const s=[];let r,n,o,l,h,d;for(r=0,n=t.length,h=0;r<n;++r){o=t[r],l=o.box,l.update(o.width||e.w,o.height||e.h,getMargins(o.horizontal,e));var{same:c,other:u}=updateDims(e,i,o,a);h|=c&&s.length,d=d||u,l.fullSize||s.push(o)}return h&&fitBoxes(s,e,i,a)||d}function setBoxDims(t,e,i,a,s){t.top=i,t.left=e,t.right=e+a,t.bottom=i+s,t.width=a,t.height=s}function placeBoxes(t,e,i,a){var s=i.padding;let{x:r,y:n}=e;for(const c of t){var o=c.box;const u=a[c.stack]||{count:1,placed:0,weight:1};var l,h,d=c.stackWeight/u.weight||1;c.horizontal?(h=e.w*d,l=u.size||o.height,defined(u.start)&&(n=u.start),o.fullSize?setBoxDims(o,s.left,n,i.outerWidth-s.right-s.left,l):setBoxDims(o,e.left+u.placed,n,h,l),u.start=n,u.placed+=h,n=o.bottom):(h=e.h*d,d=u.size||o.width,defined(u.start)&&(r=u.start),o.fullSize?setBoxDims(o,r,s.top,d,i.outerHeight-s.bottom-s.top):setBoxDims(o,r,e.top+u.placed,d,h),u.start=r,u.placed+=h,r=o.right)}e.x=r,e.y=n}defaults.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}});var layouts={addBox(t,e){t.boxes||(t.boxes=[]),e.fullSize=e.fullSize||!1,e.position=e.position||"top",e.weight=e.weight||0,e._layers=e._layers||function(){return[{z:0,draw(t){e.draw(t)}}]},t.boxes.push(e)},removeBox(t,e){e=t.boxes?t.boxes.indexOf(e):-1;-1!==e&&t.boxes.splice(e,1)},configure(t,e,i){e.fullSize=i.fullSize,e.position=i.position,e.weight=i.weight},update(i,t,e,a){if(i){var s=toPadding(i.options.layout.padding),r=Math.max(t-s.width,0),n=Math.max(e-s.height,0),o=buildLayoutBoxes(i.boxes);const d=o.vertical;var l=o.horizontal;each(i.boxes,t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()});var h=d.reduce((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1,0)||1,e=Object.freeze({outerWidth:t,outerHeight:e,padding:s,availableWidth:r,availableHeight:n,vBoxMaxWidth:r/2/h,hBoxMaxHeight:n/2}),h=Object.assign({},s);updateMaxPadding(h,toPadding(a));const c=Object.assign({maxPadding:h,w:r,h:n,x:s.left,y:s.top},s);s=setLayoutDims(d.concat(l),e);fitBoxes(o.fullSize,c,e,s),fitBoxes(d,c,e,s),fitBoxes(l,c,e,s)&&fitBoxes(d,c,e,s),handleMaxPadding(c),placeBoxes(o.leftAndTop,c,e,s),c.x+=c.w,c.y+=c.h,placeBoxes(o.rightAndBottom,c,e,s),i.chartArea={left:c.left,top:c.top,right:c.left+c.w,bottom:c.top+c.h,height:c.h,width:c.w},each(o.chartArea,t=>{const e=t.box;Object.assign(e,i.chartArea),e.update(c.w,c.h,{left:0,top:0,right:0,bottom:0})})}}};class BasePlatform{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,i,a){return e=Math.max(0,e||t.width),i=i||t.height,{width:e,height:Math.max(0,a?Math.floor(e/a):i)}}isAttached(t){return!0}updateConfig(t){}}class BasicPlatform extends BasePlatform{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const EXPANDO_KEY="$chartjs",EVENT_TYPES={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},isNullOrEmpty=t=>null===t||""===t;function initCanvas(t,e){const i=t.style;var a=t.getAttribute("height"),s=t.getAttribute("width");return t[EXPANDO_KEY]={initial:{height:a,width:s,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",!isNullOrEmpty(s)||void 0!==(s=readUsedSize(t,"width"))&&(t.width=s),isNullOrEmpty(a)&&(""===t.style.height?t.height=t.width/(e||2):void 0!==(e=readUsedSize(t,"height"))&&(t.height=e)),t}const eventListenerOptions=!!supportsEventListenerOptions&&{passive:!0};function addListener(t,e,i){t.addEventListener(e,i,eventListenerOptions)}function removeListener(t,e,i){t.canvas.removeEventListener(e,i,eventListenerOptions)}function fromNativeEvent(t,e){var i=EVENT_TYPES[t.type]||t.type,{x:a,y:s}=getRelativePosition$1(t,e);return{type:i,chart:e,native:t,x:void 0!==a?a:null,y:void 0!==s?s:null}}function nodeListContains(t,e){for(const i of t)if(i===e||i.contains(e))return!0}function createAttachObserver(t,e,a){const s=t.canvas,i=new MutationObserver(t=>{let e=!1;for(const i of t)e=e||nodeListContains(i.addedNodes,s),e=e&&!nodeListContains(i.removedNodes,s);e&&a()});return i.observe(document,{childList:!0,subtree:!0}),i}function createDetachObserver(t,e,a){const s=t.canvas,i=new MutationObserver(t=>{let e=!1;for(const i of t)e=e||nodeListContains(i.removedNodes,s),e=e&&!nodeListContains(i.addedNodes,s);e&&a()});return i.observe(document,{childList:!0,subtree:!0}),i}const drpListeningCharts=new Map;let oldDevicePixelRatio=0;function onWindowResize(){const i=window.devicePixelRatio;i!==oldDevicePixelRatio&&(oldDevicePixelRatio=i,drpListeningCharts.forEach((t,e)=>{e.currentDevicePixelRatio!==i&&t()}))}function listenDevicePixelRatioChanges(t,e){drpListeningCharts.size||window.addEventListener("resize",onWindowResize),drpListeningCharts.set(t,e)}function unlistenDevicePixelRatioChanges(t){drpListeningCharts.delete(t),drpListeningCharts.size||window.removeEventListener("resize",onWindowResize)}function createResizeObserver(t,e,a){var i=t.canvas;const s=i&&_getParentNode(i);if(s){const r=throttled((t,e)=>{var i=s.clientWidth;a(t,e),i<s.clientWidth&&a()},window),n=new ResizeObserver(t=>{var e=t[0],t=e.contentRect.width,e=e.contentRect.height;0===t&&0===e||r(t,e)});return n.observe(s),listenDevicePixelRatioChanges(t,r),n}}function releaseObserver(t,e,i){i&&i.disconnect(),"resize"===e&&unlistenDevicePixelRatioChanges(t)}function createProxyAndListen(e,t,i){var a=e.canvas,s=throttled(t=>{null!==e.ctx&&i(fromNativeEvent(t,e))},e,t=>{t=t[0];return[t,t.offsetX,t.offsetY]});return addListener(a,t,s),s}class DomPlatform extends BasePlatform{acquireContext(t,e){var i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(initCanvas(t,e),i):null}releaseContext(t){const i=t.canvas;if(!i[EXPANDO_KEY])return!1;const a=i[EXPANDO_KEY].initial;["height","width"].forEach(t=>{var e=a[t];isNullOrUndef(e)?i.removeAttribute(t):i.setAttribute(t,e)});const e=a.style||{};return Object.keys(e).forEach(t=>{i.style[t]=e[t]}),i.width=i.width,delete i[EXPANDO_KEY],!0}addEventListener(t,e,i){this.removeEventListener(t,e);const a=t.$proxies||(t.$proxies={});const s={attach:createAttachObserver,detach:createDetachObserver,resize:createResizeObserver}[e]||createProxyAndListen;a[e]=s(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={});var a=i[e];if(a){const s={attach:releaseObserver,detach:releaseObserver,resize:releaseObserver}[e]||removeListener;s(t,e,a),i[e]=void 0}}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,a){return getMaximumSize(t,e,i,a)}isAttached(t){t=_getParentNode(t);return!(!t||!t.isConnected)}}function _detectPlatform(t){return!_isDomSupported()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?BasicPlatform:DomPlatform}class Element{constructor(){this.x=void 0,this.y=void 0,this.active=!1,this.options=void 0,this.$animations=void 0}tooltipPosition(t){var{x:e,y:t}=this.getProps(["x","y"],t);return{x:e,y:t}}hasValue(){return isNumber(this.x)&&isNumber(this.y)}getProps(t,e){const i=this.$animations;if(!e||!i)return this;const a={};return t.forEach(t=>{a[t]=i[t]&&i[t].active()?i[t]._to:this[t]}),a}}Element.defaults={},Element.defaultRoutes=void 0;const formatters={values(t){return isArray(t)?t:""+t},numeric(t,e,i){if(0===t)return"0";var a,s=this.chart.options.locale;let r,n=t;1<i.length&&(((a=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value)))<1e-4||1e15<a)&&(r="scientific"),n=calculateDelta(t,i));i=log10(Math.abs(n)),i=Math.max(Math.min(-1*Math.floor(i),20),0),i={notation:r,minimumFractionDigits:i,maximumFractionDigits:i};return Object.assign(i,this.options.ticks.format),formatNumber(t,s,i)},logarithmic(t,e,i){if(0===t)return"0";var a=t/Math.pow(10,Math.floor(log10(t)));return 1==a||2==a||5==a?formatters.numeric.call(this,t,e,i):""}};function calculateDelta(t,e){let i=3<e.length?e[2].value-e[1].value:e[1].value-e[0].value;return 1<=Math.abs(i)&&t!==Math.floor(t)&&(i=t-Math.floor(t)),i}var Ticks={formatters:formatters};function autoSkip(i,a){var s=i.options.ticks,r=s.maxTicksLimit||determineMaxTicks(i),n=s.major.enabled?getMajorIndices(a):[],o=n.length,i=n[0],s=n[o-1],l=[];if(r<o)return skipMajors(a,l,n,o/r),l;var h=calculateSpacing(n,a,r);if(0<o){let t,e;r=1<o?Math.round((s-i)/(o-1)):null;for(skip(a,l,h,isNullOrUndef(r)?0:i-r,i),t=0,e=o-1;t<e;t++)skip(a,l,h,n[t],n[t+1]);return skip(a,l,h,s,isNullOrUndef(r)?a.length:s+r),l}return skip(a,l,h),l}function determineMaxTicks(t){var e=t.options.offset,i=t._tickSize(),e=t._length/i+(e?0:1),i=t._maxLength/i;return Math.floor(Math.min(e,i))}function calculateSpacing(t,e,i){var t=getEvenSpacing(t),a=e.length/i;if(!t)return Math.max(a,1);var s=_factorize(t);for(let t=0,e=s.length-1;t<e;t++){var r=s[t];if(a<r)return r}return Math.max(a,1)}function getMajorIndices(t){const e=[];let i,a;for(i=0,a=t.length;i<a;i++)t[i].major&&e.push(i);return e}function skipMajors(t,e,i,a){let s=0,r=i[0],n;for(a=Math.ceil(a),n=0;n<t.length;n++)n===r&&(e.push(t[n]),s++,r=i[s*a])}function skip(t,e,i,a,s){var r=valueOrDefault(a,0),n=Math.min(valueOrDefault(s,t.length),t.length);let o=0,l,h,d;for(i=Math.ceil(i),s&&(i=(l=s-a)/Math.floor(l/i)),d=r;d<0;)o++,d=Math.round(r+o*i);for(h=Math.max(r,0);h<n;h++)h===d&&(e.push(t[h]),o++,d=Math.round(r+o*i))}function getEvenSpacing(t){var e=t.length;let i,a;if(e<2)return!1;for(a=t[0],i=1;i<e;++i)if(t[i]-t[i-1]!==a)return!1;return a}defaults.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",grace:0,grid:{display:!0,lineWidth:1,drawBorder:!0,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,e)=>e.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:Ticks.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),defaults.route("scale.ticks","color","","color"),defaults.route("scale.grid","color","","borderColor"),defaults.route("scale.grid","borderColor","","borderColor"),defaults.route("scale.title","color","","color"),defaults.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t}),defaults.describe("scales",{_fallback:"scale"}),defaults.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t});const reverseAlign=t=>"left"===t?"right":"right"===t?"left":t,offsetFromEdge=(t,e,i)=>"top"===e||"left"===e?t[e]+i:t[e]-i;function sample(t,e){const i=[];var a=t.length/e,s=t.length;let r=0;for(;r<s;r+=a)i.push(t[Math.floor(r)]);return i}function getPixelForGridLine(t,e,i){var a=t.ticks.length,s=Math.min(e,a-1),r=t._startPixel,n=t._endPixel;let o=t.getPixelForTick(s),l;if(!(i&&(l=1===a?Math.max(o-r,n-o):0===e?(t.getPixelForTick(1)-o)/2:(o-t.getPixelForTick(s-1))/2,o+=s<e?l:-l,o<r-1e-6||o>n+1e-6)))return o}function garbageCollect(t,s){each(t,t=>{const e=t.gc;var i=e.length/2;let a;if(s<i){for(a=0;a<i;++a)delete t.data[e[a]];e.splice(0,i)}})}function getTickMarkLength(t){return t.drawTicks?t.tickLength:0}function getTitleHeight(t,e){if(!t.display)return 0;var i=toFont(t.font,e),e=toPadding(t.padding);return(isArray(t.text)?t.text.length:1)*i.lineHeight+e.height}function createScaleContext(t,e){return createContext(t,{scale:e,type:"scale"})}function createTickContext(t,e,i){return createContext(t,{tick:i,index:e,type:"tick"})}function titleAlign(t,e,i){let a=_toLeftRightCenter(t);return(i&&"right"!==e||!i&&"right"===e)&&(a=reverseAlign(a)),a}function titleArgs(t,e,i,a){var{top:s,left:r,bottom:n,right:o,chart:l}=t;const{chartArea:h,scales:d}=l;let c=0,u,g,p;var f,m=n-s,v=o-r;return t.isHorizontal()?(g=_alignStartEnd(a,r,o),p=isObject(i)?(l=i[f=Object.keys(i)[0]],d[f].getPixelForValue(l)+m-e):"center"===i?(h.bottom+h.top)/2+m-e:offsetFromEdge(t,i,e),u=o-r):(g=isObject(i)?(r=i[o=Object.keys(i)[0]],d[o].getPixelForValue(r)-v+e):"center"===i?(h.left+h.right)/2-v+e:offsetFromEdge(t,i,e),p=_alignStartEnd(a,n,s),c="left"===i?-HALF_PI:HALF_PI),{titleX:g,titleY:p,maxWidth:u,rotation:c}}class Scale extends Element{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(){var{_userMin:t,_userMax:e,_suggestedMin:i,_suggestedMax:a}=this,t=finiteOrDefault(t,Number.POSITIVE_INFINITY),e=finiteOrDefault(e,Number.NEGATIVE_INFINITY),i=finiteOrDefault(i,Number.POSITIVE_INFINITY),a=finiteOrDefault(a,Number.NEGATIVE_INFINITY);return{min:finiteOrDefault(t,i),max:finiteOrDefault(e,a),minDefined:isNumberFinite(t),maxDefined:isNumberFinite(e)}}getMinMax(i){let{min:a,max:s,minDefined:r,maxDefined:n}=this.getUserBounds();var o;if(r&&n)return{min:a,max:s};const l=this.getMatchingVisibleMetas();for(let t=0,e=l.length;t<e;++t)o=l[t].controller.getMinMax(this,i),r||(a=Math.min(a,o.min)),n||(s=Math.max(s,o.max));return a=n&&a>s?s:a,s=r&&a>s?a:s,{min:finiteOrDefault(a,finiteOrDefault(s,a)),max:finiteOrDefault(s,finiteOrDefault(a,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){var t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){callback(this.options.beforeUpdate,[this])}update(t,e,i){var{beginAtZero:a,grace:s,ticks:r}=this.options,n=r.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=_addGrace(this,s,a),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();a=n<this.ticks.length;this._convertTicksToLabels(a?sample(this.ticks,n):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),r.display&&(r.autoSkip||"auto"===r.source)&&(this.ticks=autoSkip(this,this.ticks),this._labelSizes=null),a&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t=this.options.reverse,e,i;this.isHorizontal()?(e=this.left,i=this.right):(e=this.top,i=this.bottom,t=!t),this._startPixel=e,this._endPixel=i,this._reversePixels=t,this._length=i-e,this._alignToPixels=this.options.alignToPixels}afterUpdate(){callback(this.options.afterUpdate,[this])}beforeSetDimensions(){callback(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){callback(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),callback(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){callback(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){var e=this.options.ticks;let i,a,s;for(i=0,a=t.length;i<a;i++)s=t[i],s.label=callback(e.callback,[s.value,i,t],this)}afterTickToLabelConversion(){callback(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){callback(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){var t,e,i,a,s,r=this.options,n=r.ticks,o=this.ticks.length,l=n.minRotation||0,h=n.maxRotation;let d=l;!this._isVisible()||!n.display||h<=l||o<=1||!this.isHorizontal()?this.labelRotation=l:(e=(t=this._getLabelSizes()).widest.width,i=t.highest.height,a=_limitValue(this.chart.width-e,0,this.maxWidth),(s=r.offset?this.maxWidth/o:a/(o-1))<e+6&&(s=a/(o-(r.offset?.5:1)),r=this.maxHeight-getTickMarkLength(r.grid)-n.padding-getTitleHeight(r.title,this.chart.options.font),e=Math.sqrt(e*e+i*i),d=toDegrees(Math.min(Math.asin(_limitValue((t.highest.height+6)/s,-1,1)),Math.asin(_limitValue(r/e,-1,1))-Math.asin(_limitValue(i/e,-1,1)))),d=Math.max(l,Math.min(h,d))),this.labelRotation=d)}afterCalculateLabelRotation(){callback(this.options.afterCalculateLabelRotation,[this])}beforeFit(){callback(this.options.beforeFit,[this])}fit(){const t={width:0,height:0};var e,i,a,s,r,{chart:n,options:{ticks:o,title:l,grid:h}}=this,d=this._isVisible(),c=this.isHorizontal();d&&(s=getTitleHeight(l,n.options.font),c?(t.width=this.maxWidth,t.height=getTickMarkLength(h)+s):(t.height=this.maxHeight,t.width=getTickMarkLength(h)+s),o.display&&this.ticks.length&&({first:e,last:i,widest:a,highest:r}=this._getLabelSizes(),d=2*o.padding,l=toRadians(this.labelRotation),h=Math.cos(l),s=Math.sin(l),c?(l=o.mirror?0:s*a.width+h*r.height,t.height=Math.min(this.maxHeight,t.height+l+d)):(r=o.mirror?0:h*a.width+s*r.height,t.width=Math.min(this.maxWidth,t.width+r+d)),this._calculatePadding(e,i,s,h))),this._handleMargins(),c?(this.width=this._length=n.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=n.height-this._margins.top-this._margins.bottom)}_calculatePadding(i,a,s,r){var{ticks:{align:n,padding:o},position:l}=this.options,h=0!==this.labelRotation,d="top"!==l&&"x"===this.axis;if(this.isHorizontal()){var c=this.getPixelForTick(0)-this.left,l=this.right-this.getPixelForTick(this.ticks.length-1);let t=0,e=0;h?e=d?(t=r*i.width,s*a.height):(t=s*i.height,r*a.width):"start"===n?e=a.width:"end"===n?t=i.width:(t=i.width/2,e=a.width/2),this.paddingLeft=Math.max((t-c+o)*this.width/(this.width-c),0),this.paddingRight=Math.max((e-l+o)*this.width/(this.width-l),0)}else{let t=a.height/2,e=i.height/2;"start"===n?(t=0,e=i.height):"end"===n&&(t=a.height,e=0),this.paddingTop=t+o,this.paddingBottom=e+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(){callback(this.options.afterFit,[this])}isHorizontal(){var{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let e,i;for(e=0,i=t.length;e<i;e++)isNullOrUndef(t[e].label)&&(t.splice(e,1),i--,e--);this.afterTickToLabelConversion()}_getLabelSizes(){let e=this._labelSizes;if(!e){var i=this.options.ticks.sampleSize;let t=this.ticks;i<t.length&&(t=sample(t,i)),this._labelSizes=e=this._computeLabelSizes(t,t.length)}return e}_computeLabelSizes(t,e){const{ctx:i,_longestTextCache:a}=this,s=[],r=[];let n=0,o=0,l,h,d,c,u,g,p,f,m,v,x;for(l=0;l<e;++l){if(c=t[l].label,u=this._resolveTickFontOptions(l),i.font=g=u.string,p=a[g]=a[g]||{data:{},gc:[]},f=u.lineHeight,m=v=0,isNullOrUndef(c)||isArray(c)){if(isArray(c))for(h=0,d=c.length;h<d;++h)x=c[h],isNullOrUndef(x)||isArray(x)||(m=_measureText(i,p.data,p.gc,m,x),v+=f)}else m=_measureText(i,p.data,p.gc,m,c),v=f;s.push(m),r.push(v),n=Math.max(m,n),o=Math.max(v,o)}garbageCollect(a,e);var b=s.indexOf(n),_=r.indexOf(o),y=t=>({width:s[t]||0,height:r[t]||0});return{first:y(0),last:y(e-1),widest:y(b),highest:y(_),widths:s,heights:r}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){var e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);t=this._startPixel+t*this._length;return _int16Range(this._alignToPixels?_alignPixel(this.chart,t,0):t)}getDecimalForPixel(t){t=(t-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){var{min:t,max:e}=this;return t<0&&e<0?e:0<t&&0<e?t:0}getContext(t){var e=this.ticks||[];if(0<=t&&t<e.length){const i=e[t];return i.$context||(i.$context=createTickContext(this.getContext(),t,i))}return this.$context||(this.$context=createScaleContext(this.chart.getContext(),this))}_tickSize(){var t=this.options.ticks,e=toRadians(this.labelRotation),i=Math.abs(Math.cos(e)),a=Math.abs(Math.sin(e)),s=this._getLabelSizes(),e=t.autoSkipPadding||0,t=s?s.widest.width+e:0,e=s?s.highest.height+e:0;return this.isHorizontal()?t*a<e*i?t/i:e/a:e*a<t*i?e/i:t/a}_isVisible(){var t=this.options.display;return"auto"!==t?!!t:0<this.getMatchingVisibleMetas().length}_computeGridLineItems(t){var e=this.axis;const i=this.chart;var a=this.options;const{grid:s,position:r}=a;var n=s.offset,o=this.isHorizontal(),l=this.ticks.length+(n?1:0),h=getTickMarkLength(s);const d=[];var c=s.setContext(this.getContext());const u=c.drawBorder?c.borderWidth:0;function g(t){return _alignPixel(i,t,u)}var p,f=u/2;let m,v,x,b,_,y,S,k,M,P,D,w;"top"===r?(m=g(this.bottom),y=this.bottom-h,k=m-f,P=g(t.top)+f,w=t.bottom):"bottom"===r?(m=g(this.top),P=t.top,w=g(t.bottom)-f,y=m+f,k=this.top+h):"left"===r?(m=g(this.right),_=this.right-h,S=m-f,M=g(t.left)+f,D=t.right):"right"===r?(m=g(this.left),M=t.left,D=g(t.right)-f,_=m+f,S=this.left+h):"x"===e?("center"===r?m=g((t.top+t.bottom)/2+.5):isObject(r)&&(p=r[c=Object.keys(r)[0]],m=g(this.chart.scales[c].getPixelForValue(p))),P=t.top,w=t.bottom,y=m+f,k=y+h):"y"===e&&("center"===r?m=g((t.left+t.right)/2):isObject(r)&&(e=r[p=Object.keys(r)[0]],m=g(this.chart.scales[p].getPixelForValue(e))),_=m-f,S=_-h,M=t.left,D=t.right);var a=valueOrDefault(a.ticks.maxTicksLimit,l),C=Math.max(1,Math.ceil(l/a));for(v=0;v<l;v+=C){var A=s.setContext(this.getContext(v)),L=A.lineWidth,O=A.color,T=s.borderDash||[],E=A.borderDashOffset,R=A.tickWidth,I=A.tickColor,B=A.tickBorderDash||[],A=A.tickBorderDashOffset;void 0!==(x=getPixelForGridLine(this,v,n))&&(b=_alignPixel(i,x,L),o?_=S=M=D=b:y=k=P=w=b,d.push({tx1:_,ty1:y,tx2:S,ty2:k,x1:M,y1:P,x2:D,y2:w,width:L,color:O,borderDash:T,borderDashOffset:E,tickWidth:R,tickColor:I,tickBorderDash:B,tickBorderDashOffset:A}))}return this._ticksLength=l,this._borderValue=m,d}_computeLabelItems(t){var e=this.axis,i=this.options;const{position:a,ticks:s}=i;var r,n,o=this.isHorizontal(),l=this.ticks,{align:h,crossAlign:d,padding:c,mirror:u}=s,g=getTickMarkLength(i.grid),i=g+c,c=u?-c:i,p=-toRadians(this.labelRotation);const f=[];let m,v,x,b,_,y,S,k,M,P,D,w="middle";"top"===a?(_=this.bottom-c,y=this._getXAxisLabelAlignment()):"bottom"===a?(_=this.top+c,y=this._getXAxisLabelAlignment()):"left"===a?(r=this._getYAxisLabelAlignment(g),y=r.textAlign,b=r.x):"right"===a?(n=this._getYAxisLabelAlignment(g),y=n.textAlign,b=n.x):"x"===e?("center"===a?_=(t.top+t.bottom)/2+i:isObject(a)&&(n=a[r=Object.keys(a)[0]],_=this.chart.scales[r].getPixelForValue(n)+i),y=this._getXAxisLabelAlignment()):"y"===e&&("center"===a?b=(t.left+t.right)/2-i:isObject(a)&&(i=a[t=Object.keys(a)[0]],b=this.chart.scales[t].getPixelForValue(i)),y=this._getYAxisLabelAlignment(g).textAlign),"y"===e&&("start"===h?w="top":"end"===h&&(w="bottom"));var C=this._getLabelSizes();for(m=0,v=l.length;m<v;++m){x=l[m].label;var A=s.setContext(this.getContext(m));S=this.getPixelForTick(m)+s.labelOffset,M=(k=this._resolveTickFontOptions(m)).lineHeight;var L=(P=isArray(x)?x.length:1)/2,O=A.color,T=A.textStrokeColor,E=A.textStrokeWidth;o?(b=S,D="top"===a?"near"===d||0!=p?-P*M+M/2:"center"===d?-C.highest.height/2-L*M+M:-C.highest.height+M/2:"near"===d||0!=p?M/2:"center"===d?C.highest.height/2-L*M:C.highest.height-P*M,u&&(D*=-1)):(_=S,D=(1-P)*M/2);let i;if(A.showLabelBackdrop){var L=toPadding(A.backdropPadding),R=C.heights[m],I=C.widths[m];let t=_+D-L.top,e=b-L.left;switch(w){case"middle":t-=R/2;break;case"bottom":t-=R}switch(y){case"center":e-=I/2;break;case"right":e-=I}i={left:e,top:t,width:I+L.width,height:R+L.height,color:A.backdropColor}}f.push({rotation:p,label:x,font:k,color:O,strokeColor:T,strokeWidth:E,textOffset:D,textAlign:y,textBaseline:w,translation:[b,_],backdrop:i})}return f}_getXAxisLabelAlignment(){var{position:t,ticks:e}=this.options;if(-toRadians(this.labelRotation))return"top"===t?"left":"right";let i="center";return"start"===e.align?i="left":"end"===e.align&&(i="right"),i}_getYAxisLabelAlignment(t){var{position:e,ticks:{crossAlign:i,mirror:a,padding:s}}=this.options,r=t+s,t=this._getLabelSizes().widest.width;let n,o;return"left"===e?a?(o=this.right+s,"near"===i?n="left":"center"===i?(n="center",o+=t/2):(n="right",o+=t)):(o=this.right-r,"near"===i?n="right":"center"===i?(n="center",o-=t/2):(n="left",o=this.left)):"right"===e?a?(o=this.left+s,"near"===i?n="right":"center"===i?(n="center",o-=t/2):(n="left",o-=t)):(o=this.left+r,"near"===i?n="left":"center"===i?(n="center",o+=t/2):(n="right",o=this.right)):n="right",{textAlign:n,x:o}}_computeLabelArea(){if(!this.options.ticks.mirror){var t=this.chart,e=this.options.position;return"left"===e||"right"===e?{top:0,left:this.left,bottom:t.height,right:this.right}:"top"===e||"bottom"===e?{top:this.top,left:0,bottom:this.bottom,right:t.width}:void 0}}drawBackground(){const{ctx:t,options:{backgroundColor:e},left:i,top:a,width:s,height:r}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(i,a,s,r),t.restore())}getLineWidthForValue(e){const t=this.options.grid;if(!this._isVisible()||!t.display)return 0;const i=this.ticks;var a=i.findIndex(t=>t.value===e);return 0<=a?t.setContext(this.getContext(a)).lineWidth:0}drawGrid(t){var e=this.options.grid;const a=this.ctx;var i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let s,r;var n=(t,e,i)=>{i.width&&i.color&&(a.save(),a.lineWidth=i.width,a.strokeStyle=i.color,a.setLineDash(i.borderDash||[]),a.lineDashOffset=i.borderDashOffset,a.beginPath(),a.moveTo(t.x,t.y),a.lineTo(e.x,e.y),a.stroke(),a.restore())};if(e.display)for(s=0,r=i.length;s<r;++s){var o=i[s];e.drawOnChartArea&&n({x:o.x1,y:o.y1},{x:o.x2,y:o.y2},o),e.drawTicks&&n({x:o.tx1,y:o.ty1},{x:o.tx2,y:o.ty2},{color:o.tickColor,width:o.tickWidth,borderDash:o.tickBorderDash,borderDashOffset:o.tickBorderDashOffset})}}drawBorder(){const{chart:s,ctx:r,options:{grid:n}}=this;var o=n.setContext(this.getContext()),l=n.drawBorder?o.borderWidth:0;if(l){var h=n.setContext(this.getContext(0)).lineWidth,d=this._borderValue;let t,e,i,a;this.isHorizontal()?(t=_alignPixel(s,this.left,l)-l/2,e=_alignPixel(s,this.right,h)+h/2,i=a=d):(i=_alignPixel(s,this.top,l)-l/2,a=_alignPixel(s,this.bottom,h)+h/2,t=e=d),r.save(),r.lineWidth=o.borderWidth,r.strokeStyle=o.borderColor,r.beginPath(),r.moveTo(t,i),r.lineTo(e,a),r.stroke(),r.restore()}}drawLabels(i){if(this.options.ticks.display){const h=this.ctx;var a=this._computeLabelArea();a&&clipArea(h,a);var s=this._labelItems||(this._labelItems=this._computeLabelItems(i));let t,e;for(t=0,e=s.length;t<e;++t){var r=s[t],n=r.font,o=r.label;r.backdrop&&(h.fillStyle=r.backdrop.color,h.fillRect(r.backdrop.left,r.backdrop.top,r.backdrop.width,r.backdrop.height));var l=r.textOffset;renderText(h,o,0,l,n,r)}a&&unclipArea(h)}}drawTitle(){var{ctx:e,options:{position:i,title:a,reverse:s}}=this;if(a.display){var r=toFont(a.font),n=toPadding(a.padding),o=a.align;let t=r.lineHeight/2;"bottom"===i||"center"===i||isObject(i)?(t+=n.bottom,isArray(a.text)&&(t+=r.lineHeight*(a.text.length-1))):t+=n.top;var{titleX:l,titleY:h,maxWidth:d,rotation:n}=titleArgs(this,t,i,o);renderText(e,a.text,0,0,r,{color:a.color,maxWidth:d,rotation:n,textAlign:titleAlign(o,i,s),textBaseline:"middle",translation:[l,h]})}}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){var t=this.options,e=t.ticks&&t.ticks.z||0,t=valueOrDefault(t.grid&&t.grid.z,-1);return this._isVisible()&&this.draw===Scale.prototype.draw?[{z:t,draw:t=>{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:t+1,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){var e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID";const a=[];let s,r;for(s=0,r=e.length;s<r;++s){var n=e[s];n[i]!==this.id||t&&n.type!==t||a.push(n)}return a}_resolveTickFontOptions(t){t=this.options.ticks.setContext(this.getContext(t));return toFont(t.font)}_maxDigits(){var t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class TypedRegistry{constructor(t,e,i){this.type=t,this.scope=e,this.override=i,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){var e=Object.getPrototypeOf(t);let i;isIChartComponent(e)&&(i=this.register(e));const a=this.items;var s=t.id,e=this.scope+"."+s;if(!s)throw new Error("class does not have id: "+t);return s in a||(registerDefaults(a[s]=t,e,i),this.override&&defaults.override(t.id,t.overrides)),e}get(t){return this.items[t]}unregister(t){const e=this.items;var i=t.id,t=this.scope;i in e&&delete e[i],t&&i in defaults[t]&&(delete defaults[t][i],this.override&&delete overrides[i])}}function registerDefaults(t,e,i){i=merge(Object.create(null),[i?defaults.get(i):{},defaults.get(e),t.defaults]);defaults.set(e,i),t.defaultRoutes&&routeDefaults(e,t.defaultRoutes),t.descriptors&&defaults.describe(e,t.descriptors)}function routeDefaults(n,o){Object.keys(o).forEach(t=>{const e=t.split(".");var i=e.pop(),a=[n].concat(e).join(".");const s=o[t].split(".");var r=s.pop(),t=s.join(".");defaults.route(a,i,t,r)})}function isIChartComponent(t){return"id"in t&&"defaults"in t}class Registry{constructor(){this.controllers=new TypedRegistry(DatasetController,"datasets",!0),this.elements=new TypedRegistry(Element,"elements"),this.plugins=new TypedRegistry(Object,"plugins"),this.scales=new TypedRegistry(Scale,"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(i,t,a){[...t].forEach(t=>{const e=a||this._getRegistryForType(t);a||e.isForType(t)||e===this.plugins&&t.id?this._exec(i,e,t):each(t,t=>{var e=a||this._getRegistryForType(t);this._exec(i,e,t)})})}_exec(t,e,i){var a=_capitalize(t);callback(i["before"+a],[],i),e[t](i),callback(i["after"+a],[],i)}_getRegistryForType(e){for(let t=0;t<this._typedRegistries.length;t++){const i=this._typedRegistries[t];if(i.isForType(e))return i}return this.plugins}_get(t,e,i){e=e.get(t);if(void 0===e)throw new Error('"'+t+'" is not a registered '+i+".");return e}}var registry=new Registry;class PluginService{constructor(){this._init=[]}notify(t,e,i,a){"beforeInit"===e&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install"));a=a?this._descriptors(t).filter(a):this._descriptors(t),i=this._notify(a,t,e,i);return"afterDestroy"===e&&(this._notify(a,t,"stop"),this._notify(this._init,t,"uninstall")),i}_notify(t,e,i,a){a=a||{};for(const o of t){var s=o.plugin,r=s[i],n=[e,a,o.options];if(!1===callback(r,n,s)&&a.cancelable)return!1}return!0}invalidate(){isNullOrUndef(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;var e=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),e}_createDescriptors(t,e){var i=t&&t.config,a=valueOrDefault(i.options&&i.options.plugins,{}),i=allPlugins(i);return!1!==a||e?createDescriptors(t,i,a,e):[]}_notifyStateChanges(t){var e=this._oldCache||[],i=this._cache,a=(t,i)=>t.filter(e=>!i.some(t=>e.plugin.id===t.plugin.id));this._notify(a(e,i),t,"stop"),this._notify(a(i,e),t,"start")}}function allPlugins(t){const e=[];var i=Object.keys(registry.plugins.items);for(let t=0;t<i.length;t++)e.push(registry.getPlugin(i[t]));var a=t.plugins||[];for(let t=0;t<a.length;t++){var s=a[t];-1===e.indexOf(s)&&e.push(s)}return e}function getOpts(t,e){return e||!1!==t?!0===t?{}:t:null}function createDescriptors(e,i,a,s){const r=[];var n=e.getContext();for(let t=0;t<i.length;t++){var o=i[t],l=getOpts(a[o.id],s);null!==l&&r.push({plugin:o,options:pluginOpts(e.config,o,l,n)})}return r}function pluginOpts(t,e,i,a){e=t.pluginScopeKeys(e),e=t.getOptionScopes(i,e);return t.createResolver(e,a,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function getIndexAxis(t,e){var i=defaults.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function getAxisFromDefaultScaleID(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}function getDefaultScaleIDFromAxis(t,e){return t===e?"_index_":"_value_"}function axisFromPosition(t){return"top"===t||"bottom"===t?"x":"left"===t||"right"===t?"y":void 0}function determineAxis(t,e){return"x"===t||"y"===t?t:e.axis||axisFromPosition(e.position)||t.charAt(0).toLowerCase()}function mergeScaleConfig(e,i){const r=overrides[e.type]||{scales:{}},n=i.scales||{},o=getIndexAxis(e.type,i),l=Object.create(null),h=Object.create(null);return Object.keys(n).forEach(t=>{var e=n[t];if(!isObject(e))return console.error(`Invalid scale configuration for scale: ${t}`);if(e._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);var i=determineAxis(t,e),a=getDefaultScaleIDFromAxis(i,o),s=r.scales||{};l[i]=l[i]||t,h[t]=mergeIf(Object.create(null),[{axis:i},e,s[i],s[a]])}),e.data.datasets.forEach(a=>{var t=a.type||e.type;const s=a.indexAxis||getIndexAxis(t,i),r=(overrides[t]||{}).scales||{};Object.keys(r).forEach(t=>{var e=getAxisFromDefaultScaleID(t,s),i=a[e+"AxisID"]||l[e]||e;h[i]=h[i]||Object.create(null),mergeIf(h[i],[{axis:e},n[i],r[t]])})}),Object.keys(h).forEach(t=>{t=h[t];mergeIf(t,[defaults.scales[t.type],defaults.scale])}),h}function initOptions(t){const e=t.options||(t.options={});e.plugins=valueOrDefault(e.plugins,{}),e.scales=mergeScaleConfig(t,e)}function initData(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}function initConfig(t){return(t=t||{}).data=initData(t.data),initOptions(t),t}const keyCache=new Map,keysCached=new Set;function cachedKeys(t,e){let i=keyCache.get(t);return i||(i=e(),keyCache.set(t,i),keysCached.add(i)),i}const addIfFound=(t,e,i)=>{i=resolveObjectKey(e,i);void 0!==i&&t.add(i)};class Config{constructor(t){this._config=initConfig(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=initData(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){var t=this._config;this.clearCache(),initOptions(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return cachedKeys(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return cachedKeys(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return cachedKeys(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id;return cachedKeys(`${this.type}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){const i=this._scopeCache;let a=i.get(t);return a&&!e||(a=new Map,i.set(t,a)),a}getOptionScopes(e,t,i){const{options:a,type:s}=this,r=this._cachedScopes(e,i);i=r.get(t);if(i)return i;const n=new Set;t.forEach(t=>{e&&(n.add(e),t.forEach(t=>addIfFound(n,e,t))),t.forEach(t=>addIfFound(n,a,t)),t.forEach(t=>addIfFound(n,overrides[s]||{},t)),t.forEach(t=>addIfFound(n,defaults,t)),t.forEach(t=>addIfFound(n,descriptors,t))});const o=Array.from(n);return 0===o.length&&o.push(Object.create(null)),keysCached.has(t)&&r.set(t,o),o}chartOptionScopes(){var{options:t,type:e}=this;return[t,overrides[e]||{},defaults.datasets[e]||{},{type:e},defaults,descriptors]}resolveNamedOptions(t,e,i,a=[""]){const s={$shared:!0};var{resolver:r,subPrefixes:a}=getResolver(this._resolverCache,t,a);let n=r;needContext(r,e)&&(s.$shared=!1,i=isFunction(i)?i():i,a=this.createResolver(t,i,a),n=_attachContext(r,i,a));for(const o of e)s[o]=n[o];return s}createResolver(t,e,i=[""],a){var i=getResolver(this._resolverCache,t,i)["resolver"];return isObject(e)?_attachContext(i,e,void 0,a):i}}function getResolver(t,e,i){let a=t.get(e);a||(a=new Map,t.set(e,a));t=i.join();let s=a.get(t);return s||(e=_createResolver(e,i),s={resolver:e,subPrefixes:i.filter(t=>!t.toLowerCase().includes("hover"))},a.set(t,s)),s}const hasFunction=i=>isObject(i)&&Object.getOwnPropertyNames(i).reduce((t,e)=>t||isFunction(i[e]),!1);function needContext(t,e){const{isScriptable:i,isIndexable:a}=_descriptors(t);for(const o of e){var s=i(o),r=a(o),n=(r||s)&&t[o];if(s&&(isFunction(n)||hasFunction(n))||r&&isArray(n))return!0}return!1}var version="3.7.0";const KNOWN_POSITIONS=["top","bottom","left","right","chartArea"];function positionIsHorizontal(t,e){return"top"===t||"bottom"===t||-1===KNOWN_POSITIONS.indexOf(t)&&"x"===e}function compare2Level(i,a){return function(t,e){return t[i]===e[i]?t[a]-e[a]:t[i]-e[i]}}function onAnimationsComplete(t){const e=t.chart;var i=e.options.animation;e.notifyPlugins("afterRender"),callback(i&&i.onComplete,[t],e)}function onAnimationProgress(t){var e=t.chart,i=e.options.animation;callback(i&&i.onProgress,[t],e)}function getCanvas(t){return _isDomSupported()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t=t&&t.canvas?t.canvas:t}const instances={},getChart=t=>{const e=getCanvas(t);return Object.values(instances).filter(t=>t.canvas===e).pop()};function moveNumericKeys(t,e,i){for(const r of Object.keys(t)){var a,s=+r;e<=s&&(a=t[r],delete t[r],(0<i||e<s)&&(t[s+i]=a))}}function determineLastEvent(t,e,i,a){return i&&"mouseout"!==t.type?a?e:t:null}class Chart{constructor(t,e){const i=this.config=new Config(e);var a=getCanvas(t),s=getChart(a);if(s)throw new Error("Canvas is already in use. Chart with ID '"+s.id+"' must be destroyed before the canvas can be reused.");var r=i.createResolver(i.chartOptionScopes(),this.getContext());this.platform=new(i.platform||_detectPlatform(a)),this.platform.updateConfig(i);e=this.platform.acquireContext(a,r.aspectRatio),t=e&&e.canvas,s=t&&t.height,a=t&&t.width;this.id=uid(),this.ctx=e,this.canvas=t,this.width=a,this.height=s,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 PluginService,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=debounce(t=>this.update(t),r.resizeDelay||0),this._dataChanges=[],instances[this.id]=this,e&&t?(animator.listen(this,"complete",onAnimationsComplete),animator.listen(this,"progress",onAnimationProgress),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){var{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:a,_aspectRatio:s}=this;return isNullOrUndef(t)?e&&s?s:a?i/a: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():retinaScale(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return clearCanvas(this.canvas,this.ctx),this}stop(){return animator.stop(this),this}resize(t,e){animator.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){var i=this.options,a=this.canvas,s=i.maintainAspectRatio&&this.aspectRatio,t=this.platform.getMaximumSize(a,t,e,s),e=i.devicePixelRatio||this.platform.getDevicePixelRatio(),s=this.width?"resize":"attach";this.width=t.width,this.height=t.height,this._aspectRatio=this.aspectRatio,retinaScale(this,e,!0)&&(this.notifyPlugins("resize",{size:t}),callback(i.onResize,[this,t],this),this.attached&&this._doResize(s)&&this.render())}ensureScalesHaveIDs(){var t=this.options.scales||{};each(t,(t,e)=>{t.id=e})}buildOrUpdateScales(){const o=this.options,a=o.scales,l=this.scales,h=Object.keys(l).reduce((t,e)=>(t[e]=!1,t),{});let t=[];a&&(t=t.concat(Object.keys(a).map(t=>{var e=a[t],i=determineAxis(t,e),t="r"===i,i="x"===i;return{options:e,dposition:t?"chartArea":i?"bottom":"left",dtype:t?"radialLinear":i?"category":"linear"}}))),each(t,t=>{const e=t.options;var i=e.id,a=determineAxis(i,e),s=valueOrDefault(e.type,t.dtype);void 0!==e.position&&positionIsHorizontal(e.position,a)===positionIsHorizontal(t.dposition)||(e.position=t.dposition),h[i]=!0;let r=null;if(i in l&&l[i].type===s)r=l[i];else{const n=registry.getScale(s);r=new n({id:i,type:s,ctx:this.ctx,chart:this}),l[r.id]=r}r.init(e,o)}),each(h,(t,e)=>{t||delete l[e]}),each(l,t=>{layouts.configure(this,t,t.options),layouts.addBox(this,t)})}_updateMetasets(){const t=this._metasets;var e=this.data.datasets.length,i=t.length;if(t.sort((t,e)=>t.index-e.index),e<i){for(let t=e;t<i;++t)this._destroyDatasetMeta(t);t.splice(e,i-e)}this._sortedMetasets=t.slice(0).sort(compare2Level("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:i}}=this;t.length>i.length&&delete this._stacks,t.forEach((e,t)=>{0===i.filter(t=>t===e._dataset).length&&this._destroyDatasetMeta(t)})}buildOrUpdateControllers(){const e=[];var i=this.data.datasets;let a,t;for(this._removeUnreferencedMetasets(),a=0,t=i.length;a<t;a++){var s=i[a];let t=this.getDatasetMeta(a);var r=s.type||this.config.type;if(t.type&&t.type!==r&&(this._destroyDatasetMeta(a),t=this.getDatasetMeta(a)),t.type=r,t.indexAxis=s.indexAxis||getIndexAxis(r,this.options),t.order=s.order||0,t.index=a,t.label=""+s.label,t.visible=this.isDatasetVisible(a),t.controller)t.controller.updateIndex(a),t.controller.linkScales();else{const n=registry.getController(r);var{datasetElementType:s,dataElementType:r}=defaults.datasets[r];Object.assign(n.prototype,{dataElementType:registry.getElement(r),datasetElementType:s&&registry.getElement(s)}),t.controller=new n(this,a),e.push(t.controller)}}return this._updateMetasets(),e}_resetElements(){each(this.data.datasets,(t,e)=>{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();var a=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!a.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1!==this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})){const n=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let i=0;for(let t=0,e=this.data.datasets.length;t<e;t++){const o=this.getDatasetMeta(t)["controller"];var r=!s&&-1===n.indexOf(o);o.buildOrUpdateElements(r),i=Math.max(+o.getMaxOverflow(),i)}i=this._minPadding=a.layout.autoPadding?i:0,this._updateLayout(i),s||each(n,t=>{t.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(compare2Level("z","_idx"));var{_active:a,_lastEvent:t}=this;t?this._eventHandler(t,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}}_updateScales(){each(this.scales,t=>{layouts.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){var t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);setsEqual(e,i)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){var t,e,i,a=this["_hiddenIndices"];for({method:t,start:e,count:i}of this._getUniformDataChanges()||[]){var s="_removeElements"===t?-i:i;moveNumericKeys(a,e,s)}}_getUniformDataChanges(){const t=this._dataChanges;if(t&&t.length){this._dataChanges=[];var e=this.data.datasets.length,i=e=>new Set(t.filter(t=>t[0]===e).map((t,e)=>e+","+t.splice(1).join(","))),a=i(0);for(let t=1;t<e;t++)if(!setsEqual(a,i(t)))return;return Array.from(a).map(t=>t.split(",")).map(t=>({method:t[1],start:+t[2],count:+t[3]}))}}_updateLayout(t){if(!1!==this.notifyPlugins("beforeLayout",{cancelable:!0})){layouts.update(this,this.width,this.height,t);t=this.chartArea;const e=t.width<=0||t.height<=0;this._layers=[],each(this.boxes,t=>{e&&"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(i){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:i,cancelable:!0})){for(let t=0,e=this.data.datasets.length;t<e;++t)this.getDatasetMeta(t).controller.configure();for(let t=0,e=this.data.datasets.length;t<e;++t)this._updateDataset(t,isFunction(i)?i({datasetIndex:t}):i);this.notifyPlugins("afterDatasetsUpdate",{mode:i})}}_updateDataset(t,e){const i=this.getDatasetMeta(t),a={meta:i,index:t,mode:e,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetUpdate",a)&&(i.controller._update(e),a.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",a))}render(){!1!==this.notifyPlugins("beforeRender",{cancelable:!0})&&(animator.has(this)?this.attached&&!animator.running(this)&&animator.start(this):(this.draw(),onAnimationsComplete({chart:this})))}draw(){let t;var e,i;if(this._resizeBeforeDraw&&({width:e,height:i}=this._resizeBeforeDraw,this._resize(e,i),this._resizeBeforeDraw=null),this.clear(),!(this.width<=0||this.height<=0)&&!1!==this.notifyPlugins("beforeDraw",{cancelable:!0})){const a=this._layers;for(t=0;t<a.length&&a[t].z<=0;++t)a[t].draw(this.chartArea);for(this._drawDatasets();t<a.length;++t)a[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}}_getSortedDatasetMetas(t){var e=this._sortedMetasets;const i=[];let a,s;for(a=0,s=e.length;a<s;++a){var r=e[a];t&&!r.visible||i.push(r)}return i}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(!1!==this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0})){var e=this.getSortedVisibleDatasetMetas();for(let t=e.length-1;0<=t;--t)this._drawDataset(e[t]);this.notifyPlugins("afterDatasetsDraw")}}_drawDataset(t){var e=this.ctx,i=t._clip,a=!i.disabled,s=this.chartArea;const r={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",r)&&(a&&clipArea(e,{left:!1===i.left?0:s.left-i.left,right:!1===i.right?this.width:s.right+i.right,top:!1===i.top?0:s.top-i.top,bottom:!1===i.bottom?this.height:s.bottom+i.bottom}),t.controller.draw(),a&&unclipArea(e),r.cancelable=!1,this.notifyPlugins("afterDatasetDraw",r))}getElementsAtEventForMode(t,e,i,a){const s=Interaction.modes[e];return"function"==typeof s?s(this,t,i,a):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let a=i.filter(t=>t&&t._dataset===e).pop();return a||(a={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(a)),a}getContext(){return this.$context||(this.$context=createContext(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){var e=this.data.datasets[t];if(!e)return!1;t=this.getDatasetMeta(t);return"boolean"==typeof t.hidden?!t.hidden:!e.hidden}setDatasetVisibility(t,e){const i=this.getDatasetMeta(t);i.hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(e,t,i){const a=i?"show":"hide",s=this.getDatasetMeta(e),r=s.controller._resolveAnimations(void 0,a);defined(t)?(s.data[t].hidden=!i,this.update()):(this.setDatasetVisibility(e,i),r.update(s,{visible:i}),this.update(t=>t.datasetIndex===e?a: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(),animator.remove(this),t=0,e=this.data.datasets.length;t<e;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");var{canvas:t,ctx:e}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),clearCanvas(t,e),this.platform.releaseContext(e),this.canvas=null,this.ctx=null),this.notifyPlugins("destroy"),delete instances[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const i=this._listeners,a=this.platform,e=(t,e)=>{a.addEventListener(this,t,e),i[t]=e},s=(t,e,i)=>{t.offsetX=e,t.offsetY=i,this._eventHandler(t)};each(this.options.events,t=>e(t,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const i=this._responsiveListeners,a=this.platform,t=(t,e)=>{a.addEventListener(this,t,e),i[t]=e},e=(t,e)=>{i[t]&&(a.removeEventListener(this,t,e),delete i[t])},s=(t,e)=>{this.canvas&&this.resize(t,e)};let r;const n=()=>{e("attach",n),this.attached=!0,this.resize(),t("resize",s),t("detach",r)};r=()=>{this.attached=!1,e("resize",s),this._stop(),this._resize(0,0),t("attach",n)},(a.isAttached(this.canvas)?n:r)()}unbindEvents(){each(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},each(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){var a=i?"set":"remove";let s,r,n,o;for("dataset"===e&&(s=this.getDatasetMeta(t[0].datasetIndex),s.controller["_"+a+"DatasetHoverStyle"]()),n=0,o=t.length;n<o;++n){const l=(r=t[n])&&this.getDatasetMeta(r.datasetIndex).controller;l&&l[a+"HoverStyle"](r.element,r.datasetIndex,r.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){var e=this._active||[],t=t.map(({datasetIndex:t,index:e})=>{var i=this.getDatasetMeta(t);if(!i)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:i.data[e],index:e}});_elementsEqual(t,e)||(this._active=t,this._lastEvent=null,this._updateHoverStyles(t,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}_updateHoverStyles(t,e,i){var a=this.options.hover,s=(t,i)=>t.filter(e=>!i.some(t=>e.datasetIndex===t.datasetIndex&&e.index===t.index)),r=s(e,t),e=i?t:s(t,e);r.length&&this.updateHoverStyle(r,a.mode,!1),e.length&&a.mode&&this.updateHoverStyle(e,a.mode,!0)}_eventHandler(e,t){const i={event:e,replay:t,cancelable:!0,inChartArea:_isPointInArea(e,this.chartArea,this._minPadding)};var a=t=>(t.options.events||this.options.events).includes(e.native.type);if(!1!==this.notifyPlugins("beforeEvent",i,a)){t=this._handleEvent(e,t,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,a),(t||i.changed)&&this.render(),this}}_handleEvent(t,e,i){var{_active:a=[],options:s}=this,r=this._getActiveElements(t,a,i,e),n=_isClickEvent(t),o=determineLastEvent(t,this._lastEvent,i,n);i&&(this._lastEvent=null,callback(s.onHover,[t,r,this],this),n&&callback(s.onClick,[t,r,this],this));t=!_elementsEqual(r,a);return(t||e)&&(this._active=r,this._updateHoverStyles(r,a,e)),this._lastEvent=o,t}_getActiveElements(t,e,i,a){if("mouseout"===t.type)return[];if(!i)return e;e=this.options.hover;return this.getElementsAtEventForMode(t,e.mode,e,a)}}const invalidatePlugins=()=>each(Chart.instances,t=>t._plugins.invalidate()),enumerable=!0;function clipArc(t,e,i){var{startAngle:a,pixelMargin:s,x:r,y:n,outerRadius:o,innerRadius:l}=e,e=s/o;t.beginPath(),t.arc(r,n,o,a-e,i+e),s<l?t.arc(r,n,l,i+(e=s/l),a-e,!0):t.arc(r,n,s,i+HALF_PI,a-HALF_PI),t.closePath(),t.clip()}function toRadiusCorners(t){return _readValueToProps(t,["outerStart","outerEnd","innerStart","innerEnd"])}function parseBorderRadius$1(t,e,i,a){var s=toRadiusCorners(t.options.borderRadius);const r=(i-e)/2;t=Math.min(r,a*e/2),e=t=>{var e=(i-Math.min(r,t))*a/2;return _limitValue(t,0,Math.min(r,e))};return{outerStart:e(s.outerStart),outerEnd:e(s.outerEnd),innerStart:_limitValue(s.innerStart,0,t),innerEnd:_limitValue(s.innerEnd,0,t)}}function rThetaToXY(t,e,i,a){return{x:i+t*Math.cos(e),y:a+t*Math.sin(e)}}function pathArc(t,e,i,a,s){var{x:r,y:n,startAngle:o,pixelMargin:l,innerRadius:h}=e,d=Math.max(e.outerRadius+a+i-l,0),c=0<h?h+a+i+l:0;let u=0;var g=s-o;a&&(b=((0<h?h-a:0)+(0<d?d-a:0))/2,u=(g-(0!=b?g*b/(b+a):g))/2);var p=(g-Math.max(.001,g*d-i/PI)/d)/2,f=o+p+u,m=s-p-u,{outerStart:v,outerEnd:x,innerStart:l,innerEnd:h}=parseBorderRadius$1(e,c,d,m-f),b=d-v,a=d-x,g=f+v/b,i=m-x/a,o=c+l,s=c+h,p=f+l/o,e=m-h/s;t.beginPath(),t.arc(r,n,d,g,i),0<x&&(a=rThetaToXY(a,i,r,n),t.arc(a.x,a.y,x,i,m+HALF_PI));i=rThetaToXY(s,m,r,n);t.lineTo(i.x,i.y),0<h&&(s=rThetaToXY(s,e,r,n),t.arc(s.x,s.y,h,m+HALF_PI,e+Math.PI)),t.arc(r,n,c,m-h/c,f+l/c,!0),0<l&&(o=rThetaToXY(o,p,r,n),t.arc(o.x,o.y,l,p+Math.PI,f-HALF_PI));p=rThetaToXY(b,f,r,n);t.lineTo(p.x,p.y),0<v&&(n=rThetaToXY(b,g,r,n),t.arc(n.x,n.y,v,f-HALF_PI,g)),t.closePath()}function drawArc(e,t,i,a){var{fullCircles:s,startAngle:r,circumference:n}=t;let o=t.endAngle;if(s){pathArc(e,t,i,a,r+TAU);for(let t=0;t<s;++t)e.fill();isNaN(n)||(o=r+n%TAU,n%TAU==0&&(o+=TAU))}return pathArc(e,t,i,a,o),e.fill(),o}function drawFullCircleBorders(t,e,i){var{x:a,y:s,startAngle:r,pixelMargin:n,fullCircles:o}=e,l=Math.max(e.outerRadius-n,0),n=e.innerRadius+n;let h;for(i&&clipArc(t,e,r+TAU),t.beginPath(),t.arc(a,s,n,r+TAU,r,!0),h=0;h<o;++h)t.stroke();for(t.beginPath(),t.arc(a,s,l,r,r+TAU),h=0;h<o;++h)t.stroke()}function drawBorder(t,e,i,a,s){var r=e["options"],{borderWidth:n,borderJoinStyle:o}=r,r="inner"===r.borderAlign;n&&(r?(t.lineWidth=2*n,t.lineJoin=o||"round"):(t.lineWidth=n,t.lineJoin=o||"bevel"),e.fullCircles&&drawFullCircleBorders(t,e,r),r&&clipArc(t,e,s),pathArc(t,e,i,a,s),t.stroke())}Object.defineProperties(Chart,{defaults:{enumerable:enumerable,value:defaults},instances:{enumerable:enumerable,value:instances},overrides:{enumerable:enumerable,value:overrides},registry:{enumerable:enumerable,value:registry},version:{enumerable:enumerable,value:version},getChart:{enumerable:enumerable,value:getChart},register:{enumerable:enumerable,value:(...t)=>{registry.add(...t),invalidatePlugins()}},unregister:{enumerable:enumerable,value:(...t)=>{registry.remove(...t),invalidatePlugins()}}});class ArcElement extends Element{constructor(t){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,t&&Object.assign(this,t)}inRange(t,e,i){var a=this.getProps(["x","y"],i),{angle:s,distance:r}=getAngleFromPoint(a,{x:t,y:e}),{startAngle:n,endAngle:o,innerRadius:a,outerRadius:t,circumference:e}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),i=this.options.spacing/2,o=valueOrDefault(e,o-n)>=TAU||_angleBetween(s,n,o),i=_isBetween(r,a+i,t+i);return o&&i}getCenterPoint(t){var{x:e,y:i,startAngle:a,endAngle:s,innerRadius:r,outerRadius:n}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius","circumference"],t),{offset:o,spacing:t}=this.options,s=(a+s)/2,o=(r+n+t+o)/2;return{x:e+Math.cos(s)*o,y:i+Math.sin(s)*o}}tooltipPosition(t){return this.getCenterPoint(t)}draw(e){var{options:i,circumference:a}=this,s=(i.offset||0)/2,r=(i.spacing||0)/2;if(this.pixelMargin="inner"===i.borderAlign?.33:0,this.fullCircles=a>TAU?Math.floor(a/TAU):0,!(0===a||this.innerRadius<0||this.outerRadius<0)){e.save();let t=0;s&&(t=s/2,a=(this.startAngle+this.endAngle)/2,e.translate(Math.cos(a)*t,Math.sin(a)*t),this.circumference>=PI&&(t=s)),e.fillStyle=i.backgroundColor,e.strokeStyle=i.borderColor;i=drawArc(e,this,t,r);drawBorder(e,this,t,r,i),e.restore()}}}function setStyle(t,e,i=e){t.lineCap=valueOrDefault(i.borderCapStyle,e.borderCapStyle),t.setLineDash(valueOrDefault(i.borderDash,e.borderDash)),t.lineDashOffset=valueOrDefault(i.borderDashOffset,e.borderDashOffset),t.lineJoin=valueOrDefault(i.borderJoinStyle,e.borderJoinStyle),t.lineWidth=valueOrDefault(i.borderWidth,e.borderWidth),t.strokeStyle=valueOrDefault(i.borderColor,e.borderColor)}function lineTo(t,e,i){t.lineTo(i.x,i.y)}function getLineMethod(t){return t.stepped?_steppedLineTo:t.tension||"monotone"===t.cubicInterpolationMode?_bezierCurveTo:lineTo}function pathVars(t,e,i={}){var a=t.length,{start:s=0,end:r=a-1}=i,{start:n,end:o}=e,t=Math.max(s,n),i=Math.min(r,o);return{count:a,start:t,loop:e.loop,ilen:i<t&&!(s<n&&r<n||o<s&&o<r)?a+i-t:i-t}}function pathSegment(t,e,i,a){var{points:s,options:r}=e,{count:n,start:o,loop:i,ilen:l}=pathVars(s,i,a);const h=getLineMethod(r);let{move:d=!0,reverse:c}=a||{},u,g,p;for(u=0;u<=l;++u)g=s[(o+(c?l-u:u))%n],g.skip||(d?(t.moveTo(g.x,g.y),d=!1):h(t,p,g,c,r.stepped),p=g);return i&&(g=s[(o+(c?l:0))%n],h(t,p,g,c,r.stepped)),!!i}function fastPathSegment(t,e,i,a){var s=e.points;const{count:r,start:n,ilen:o}=pathVars(s,i,a),{move:l=!0,reverse:h}=a||{};let d=0,c=0,u,g,p,f,m,v;var x,b,_,y=t=>(n+(h?o-t:t))%r,S=()=>{f!==m&&(t.lineTo(d,m),t.lineTo(d,f),t.lineTo(d,v))};for(l&&(g=s[y(0)],t.moveTo(g.x,g.y)),u=0;u<=o;++u)g=s[y(u)],g.skip||(x=g.x,b=g.y,(_=0|x)===p?(b<f?f=b:b>m&&(m=b),d=(c*d+x)/++c):(S(),t.lineTo(x,b),p=_,c=0,f=m=b),v=b);S()}function _getSegmentMethod(t){var e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||i)?fastPathSegment:pathSegment}function _getInterpolationMethod(t){return t.stepped?_steppedInterpolation:t.tension||"monotone"===t.cubicInterpolationMode?_bezierInterpolation:_pointInLine}function strokePathWithCache(t,e,i,a){let s=e._path;s||(s=e._path=new Path2D,e.path(s,i,a)&&s.closePath()),setStyle(t,e.options),t.stroke(s)}function strokePathDirect(t,e,i,a){var{segments:s,options:r}=e;const n=_getSegmentMethod(e);for(const o of s)setStyle(t,r,o.style),t.beginPath(),n(t,e,o,{start:i,end:i+a-1})&&t.closePath(),t.stroke()}ArcElement.id="arc",ArcElement.defaults={borderAlign:"center",borderColor:"#fff",borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0},ArcElement.defaultRoutes={backgroundColor:"backgroundColor"};const usePath2D="function"==typeof Path2D;function draw(t,e,i,a){(usePath2D&&!e.options.segment?strokePathWithCache:strokePathDirect)(t,e,i,a)}class LineElement extends Element{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){var i,a=this.options;!a.tension&&"monotone"!==a.cubicInterpolationMode||a.stepped||this._pointsUpdated||(i=a.spanGaps?this._loop:this._fullLoop,_updateBezierControlPoints(this._points,a,t,i,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=_computeSegments(this,this.options.segment))}first(){var t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){var t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(i,a){var s=this.options,r=i[a],n=this.points,o=_boundSegments(this,{property:a,start:r,end:r});if(o.length){const c=[],u=_getInterpolationMethod(s);let t,e;for(t=0,e=o.length;t<e;++t){var{start:l,end:h}=o[t],d=n[l],l=n[h];if(d!==l){h=Math.abs((r-d[a])/(l[a]-d[a]));const g=u(d,l,h,s.stepped);g[a]=i[a],c.push(g)}else c.push(d)}return 1===c.length?c[0]:c}}pathSegment(t,e,i){const a=_getSegmentMethod(this);return a(t,this,e,i)}path(t,e,i){var a=this.segments;const s=_getSegmentMethod(this);let r=this._loop;e=e||0,i=i||this.points.length-e;for(const n of a)r&=s(t,this,n,{start:e,end:e+i-1});return!!r}draw(t,e,i,a){var s=this.options||{};(this.points||[]).length&&s.borderWidth&&(t.save(),draw(t,this,i,a),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}function inRange$1(t,e,i,a){var s=t.options,{[i]:i}=t.getProps([i],a);return Math.abs(e-i)<s.radius+s.hitRadius}LineElement.id="line",LineElement.defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0},LineElement.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"},LineElement.descriptors={_scriptable:!0,_indexable:t=>"borderDash"!==t&&"fill"!==t};class PointElement extends Element{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){var a=this.options,{x:s,y:i}=this.getProps(["x","y"],i);return Math.pow(t-s,2)+Math.pow(e-i,2)<Math.pow(a.hitRadius+a.radius,2)}inXRange(t,e){return inRange$1(this,t,"x",e)}inYRange(t,e){return inRange$1(this,t,"y",e)}getCenterPoint(t){var{x:e,y:t}=this.getProps(["x","y"],t);return{x:e,y:t}}size(t){var e=(t=t||this.options||{}).radius||0;return 2*((e=Math.max(e,e&&t.hoverRadius||0))+(e&&t.borderWidth||0))}draw(t,e){var i=this.options;this.skip||i.radius<.1||!_isPointInArea(this,e,this.size(i)/2)||(t.strokeStyle=i.borderColor,t.lineWidth=i.borderWidth,t.fillStyle=i.backgroundColor,drawPoint(t,i,this.x,this.y))}getRange(){var t=this.options||{};return t.radius+t.hitRadius}}function getBarBounds(t,e){var{x:i,y:a,base:s,width:r,height:e}=t.getProps(["x","y","base","width","height"],e);let n,o,l,h,d;return h=t.horizontal?(d=e/2,n=Math.min(i,s),o=Math.max(i,s),l=a-d,a+d):(d=r/2,n=i-d,o=i+d,l=Math.min(a,s),Math.max(a,s)),{left:n,top:l,right:o,bottom:h}}function skipOrLimit(t,e,i,a){return t?0:_limitValue(e,i,a)}function parseBorderWidth(t,e,i){var a=t.options.borderWidth,t=t.borderSkipped,a=toTRBL(a);return{t:skipOrLimit(t.top,a.top,0,i),r:skipOrLimit(t.right,a.right,0,e),b:skipOrLimit(t.bottom,a.bottom,0,i),l:skipOrLimit(t.left,a.left,0,e)}}function parseBorderRadius(t,e,i){var a=t.getProps(["enableBorderRadius"])["enableBorderRadius"],s=t.options.borderRadius,r=toTRBLCorners(s),i=Math.min(e,i),t=t.borderSkipped,s=a||isObject(s);return{topLeft:skipOrLimit(!s||t.top||t.left,r.topLeft,0,i),topRight:skipOrLimit(!s||t.top||t.right,r.topRight,0,i),bottomLeft:skipOrLimit(!s||t.bottom||t.left,r.bottomLeft,0,i),bottomRight:skipOrLimit(!s||t.bottom||t.right,r.bottomRight,0,i)}}function boundingRects(t){var e=getBarBounds(t),i=e.right-e.left,a=e.bottom-e.top,s=parseBorderWidth(t,i/2,a/2),t=parseBorderRadius(t,i/2,a/2);return{outer:{x:e.left,y:e.top,w:i,h:a,radius:t},inner:{x:e.left+s.l,y:e.top+s.t,w:i-s.l-s.r,h:a-s.t-s.b,radius:{topLeft:Math.max(0,t.topLeft-Math.max(s.t,s.l)),topRight:Math.max(0,t.topRight-Math.max(s.t,s.r)),bottomLeft:Math.max(0,t.bottomLeft-Math.max(s.b,s.l)),bottomRight:Math.max(0,t.bottomRight-Math.max(s.b,s.r))}}}}function inRange(t,e,i,a){var s=null===e,r=null===i,a=t&&!(s&&r)&&getBarBounds(t,a);return a&&(s||_isBetween(e,a.left,a.right))&&(r||_isBetween(i,a.top,a.bottom))}function hasRadius(t){return t.topLeft||t.topRight||t.bottomLeft||t.bottomRight}function addNormalRectPath(t,e){t.rect(e.x,e.y,e.w,e.h)}function inflateRect(t,e,i={}){var a=t.x!==i.x?-e:0,s=t.y!==i.y?-e:0,r=(t.x+t.w!==i.x+i.w?e:0)-a,e=(t.y+t.h!==i.y+i.h?e:0)-s;return{x:t.x+a,y:t.y+s,w:t.w+r,h:t.h+e,radius:t.radius}}PointElement.id="point",PointElement.defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0},PointElement.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};class BarElement extends Element{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){var{inflateAmount:e,options:{borderColor:i,backgroundColor:a}}=this,{inner:s,outer:r}=boundingRects(this);const n=hasRadius(r.radius)?addRoundedRectPath:addNormalRectPath;t.save(),r.w===s.w&&r.h===s.h||(t.beginPath(),n(t,inflateRect(r,e,s)),t.clip(),n(t,inflateRect(s,-e,r)),t.fillStyle=i,t.fill("evenodd")),t.beginPath(),n(t,inflateRect(s,e)),t.fillStyle=a,t.fill(),t.restore()}inRange(t,e,i){return inRange(this,t,e,i)}inXRange(t,e){return inRange(this,t,null,e)}inYRange(t,e){return inRange(this,null,t,e)}getCenterPoint(t){var{x:e,y:i,base:a,horizontal:t}=this.getProps(["x","y","base","horizontal"],t);return{x:t?(e+a)/2:e,y:t?i:(i+a)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}}BarElement.id="bar",BarElement.defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0},BarElement.defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};var elements=Object.freeze({__proto__:null,ArcElement:ArcElement,LineElement:LineElement,PointElement:PointElement,BarElement:BarElement});function lttbDecimation(a,s,r,t,e){var i=e.samples||t;if(r<=i)return a.slice(s,s+r);const n=[];var o=(r-2)/(i-2);let l=0;t=s+r-1;let h=s,d,c,u,g,p;for(n[l++]=a[h],d=0;d<i-2;d++){let t=0,e=0,i;var f=Math.floor((d+1)*o)+1+s,m=Math.min(Math.floor((d+2)*o)+1,r)+s,v=m-f;for(i=f;i<m;i++)t+=a[i].x,e+=a[i].y;t/=v,e/=v;var v=Math.floor(d*o)+1+s,x=Math.min(Math.floor((d+1)*o)+1,r)+s,{x:b,y:_}=a[h];for(u=-1,i=v;i<x;i++)(g=.5*Math.abs((b-t)*(a[i].y-_)-(b-a[i].x)*(e-_)))>u&&(u=g,c=a[i],p=i);n[l++]=c,h=p}return n[l++]=a[t],n}function minMaxDecimation(t,e,i,a){let s=0,r=0,n,o,l,h,d,c,u,g,p,f;const m=[];var v=t[e].x,x=t[e+i-1].x-v;for(n=e;n<e+i;++n){l=((o=t[n]).x-v)/x*a,h=o.y;var b,_,y,S=0|l;S===d?(h<p?(p=h,c=n):h>f&&(f=h,u=n),s=(r*s+o.x)/++r):(b=n-1,isNullOrUndef(c)||isNullOrUndef(u)||(_=Math.min(c,u),y=Math.max(c,u),_!==g&&_!==b&&m.push({...t[_],x:s}),y!==g&&y!==b&&m.push({...t[y],x:s})),0<n&&b!==g&&m.push(t[b]),m.push(o),d=S,r=0,p=f=h,c=u=g=n)}return m}function cleanDecimatedDataset(t){var e;t._decimated&&(e=t._data,delete t._decimated,delete t._data,Object.defineProperty(t,"data",{value:e}))}function cleanDecimatedData(t){t.data.datasets.forEach(t=>{cleanDecimatedDataset(t)})}function getStartAndCountOfVisiblePointsSimplified(t,e){var i=e.length;let a=0,s;const r=t["iScale"];var{min:n,max:o,minDefined:l,maxDefined:t}=r.getUserBounds();return l&&(a=_limitValue(_lookupByKey(e,r.axis,n).lo,0,i-1)),s=t?_limitValue(_lookupByKey(e,r.axis,o).hi+1,a,i)-a:i-a,{start:a,count:s}}var plugin_decimation={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(o,t,l)=>{if(l.enabled){const h=o.width;o.data.datasets.forEach((e,t)=>{var{_data:i,indexAxis:a}=e,t=o.getDatasetMeta(t),s=i||e.data;if("y"!==resolve([a,o.options.indexAxis])&&"line"===t.type){a=o.scales[t.xAxisID];if(("linear"===a.type||"time"===a.type)&&!o.options.parsing){var{start:r,count:n}=getStartAndCountOfVisiblePointsSimplified(t,s);if(n<=(l.threshold||4*h))cleanDecimatedDataset(e);else{isNullOrUndef(i)&&(e._data=s,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}}));let t;switch(l.algorithm){case"lttb":t=lttbDecimation(s,r,n,h,l);break;case"min-max":t=minMaxDecimation(s,r,n,h);break;default:throw new Error(`Unsupported decimation algorithm '${l.algorithm}'`)}e._decimated=t}}}})}else cleanDecimatedData(o)},destroy(t){cleanDecimatedData(t)}};function getLineByIndex(t,e){var i=t.getDatasetMeta(e);return i&&t.isDatasetVisible(e)?i.dataset:null}function parseFillOption(t){var e=t.options,t=e.fill;let i=valueOrDefault(t&&t.target,t);return void 0===i&&(i=!!e.backgroundColor),!1!==i&&null!==i&&(!0===i?"origin":i)}function decodeFill(t,e,i){t=parseFillOption(t);if(isObject(t))return!isNaN(t.value)&&t;let a=parseFloat(t);return isNumberFinite(a)&&Math.floor(a)===a?("-"!==t[0]&&"+"!==t[0]||(a=e+a),!(a===e||a<0||a>=i)&&a):0<=["origin","start","end","stack","shape"].indexOf(t)&&t}function computeLinearBoundary(t){const{scale:e={},fill:i}=t;let a=null;return"start"===i?a=e.bottom:"end"===i?a=e.top:isObject(i)?a=e.getPixelForValue(i.value):e.getBasePixel&&(a=e.getBasePixel()),isNumberFinite(a)?{x:(t=e.isHorizontal())?a:null,y:t?null:a}:null}class simpleArc{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){var{x:a,y:s,radius:r}=this;return e=e||{start:0,end:TAU},t.arc(a,s,r,e.end,e.start,!0),!i.bounds}interpolate(t){var{x:e,y:i,radius:a}=this,t=t.angle;return{x:e+Math.cos(t)*a,y:i+Math.sin(t)*a,angle:t}}}function computeCircularBoundary(t){const{scale:e,fill:i}=t;var a=e.options,s=e.getLabels().length;const r=[];var n=a.reverse?e.max:e.min,t=a.reverse?e.min:e.max;let o,l,h;if(h="start"===i?n:"end"===i?t:isObject(i)?i.value:e.getBaseValue(),a.grid.circular)return l=e.getPointPositionForValue(0,n),new simpleArc({x:l.x,y:l.y,radius:e.getDistanceFromCenterForValue(h)});for(o=0;o<s;++o)r.push(e.getPointPositionForValue(o,h));return r}function computeBoundary(t){return((t.scale||{}).getPointPositionForValue?computeCircularBoundary:computeLinearBoundary)(t)}function findSegmentEnd(t,e,i){for(;t<e;e--){var a=i[e];if(!isNaN(a.x)&&!isNaN(a.y))break}return e}function pointsFromSegments(t,e){const{x:i=null,y:a=null}=t||{},s=e.points,r=[];return e.segments.forEach(({start:t,end:e})=>{e=findSegmentEnd(t,e,s);t=s[t],e=s[e];null!==a?(r.push({x:t.x,y:a}),r.push({x:e.x,y:a})):null!==i&&(r.push({x:i,y:t.y}),r.push({x:i,y:e.y}))}),r}function buildStackLine(t){var{scale:e,index:i,line:t}=t,a=[],s=t.segments,r=t.points;const n=getLinesBelow(e,i);n.push(createBoundaryLine({x:null,y:e.bottom},t));for(let t=0;t<s.length;t++){var o=s[t];for(let t=o.start;t<=o.end;t++)addPointsBelow(a,r[t],n)}return new LineElement({points:a,options:{}})}function getLinesBelow(t,e){const i=[];var a=t.getMatchingVisibleMetas("line");for(let t=0;t<a.length;t++){var s=a[t];if(s.index===e)break;s.hidden||i.unshift(s.dataset)}return i}function addPointsBelow(e,i,a){const s=[];for(let t=0;t<a.length;t++){var{first:r,last:n,point:o}=findPoint(a[t],i,"x");if(!(!o||r&&n))if(r)s.unshift(o);else if(e.push(o),!n)break}e.push(...s)}function findPoint(t,e,i){e=t.interpolate(e,i);if(!e)return{};var a=e[i],s=t.segments,r=t.points;let n=!1,o=!1;for(let t=0;t<s.length;t++){var l=s[t],h=r[l.start][i],l=r[l.end][i];if(_isBetween(a,h,l)){n=a===h,o=a===l;break}}return{first:n,last:o,point:e}}function getTarget(t){var{chart:e,fill:i,line:a}=t;if(isNumberFinite(i))return getLineByIndex(e,i);if("stack"===i)return buildStackLine(t);if("shape"===i)return!0;t=computeBoundary(t);return t instanceof simpleArc?t:createBoundaryLine(t,a)}function createBoundaryLine(t,e){let i=[],a=!1;return i=isArray(t)?(a=!0,t):pointsFromSegments(t,e),i.length?new LineElement({points:i,options:{tension:0},_loop:a,_fullLoop:a}):null}function resolveTarget(t,e,i){var a;let s=t[e].fill;const r=[e];if(!i)return s;for(;!1!==s&&-1===r.indexOf(s);){if(!isNumberFinite(s))return s;if(!(a=t[s]))return!1;if(a.visible)return s;r.push(s),s=a.fill}return!1}function _clip(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 getBounds(i,a,s,t){if(!t){let t=a[i],e=s[i];return"angle"===i&&(t=_normalizeAngle(t),e=_normalizeAngle(e)),{property:i,start:t,end:e}}}function _getEdge(t,e,i,a){return t&&e?a(t[i],e[i]):t?t[i]:e?e[i]:0}function _segments(t,e,i){var a=t.segments,s=t.points,r=e.points;const n=[];for(const c of a){var{start:o,end:l}=c,l=findSegmentEnd(o,l,s),h=getBounds(i,s[o],s[l],c.loop);if(e.segments)for(const u of _boundSegments(e,h)){var d=getBounds(i,r[u.start],r[u.end],u.loop);for(const g of _boundSegment(c,s,d))n.push({source:g,target:u,start:{[i]:_getEdge(h,d,"start",Math.max)},end:{[i]:_getEdge(h,d,"end",Math.min)}})}else n.push({source:c,target:h,start:s[o],end:s[l]})}return n}function clipBounds(t,e,i){var{top:a,bottom:s}=e.chart.chartArea,{property:r,start:e,end:i}=i||{};"x"===r&&(t.beginPath(),t.rect(e,a,i-e,s-a),t.clip())}function interpolatedLineTo(t,e,i,a){a=e.interpolate(i,a);a&&t.lineTo(a.x,a.y)}function _fill(e,t){const{line:i,target:a,property:s,color:r,scale:n}=t;var o,l,h,d;for({source:o,target:l,start:h,end:d}of _segments(i,a,s)){var{style:{backgroundColor:c=r}={}}=o,u=!0!==a;e.save(),e.fillStyle=c,clipBounds(e,n,u&&getBounds(s,h,d)),e.beginPath();c=!!i.pathSegment(e,o);let t;u&&(c?e.closePath():interpolatedLineTo(e,a,d,s),u=!!a.pathSegment(e,l,{move:c,reverse:!0}),t=c&&u,t||interpolatedLineTo(e,a,h,s)),e.closePath(),e.fill(t?"evenodd":"nonzero"),e.restore()}}function doFill(t,e){var{line:i,target:a,above:s,below:r,area:n,scale:o}=e,e=i._loop?"angle":e.axis;t.save(),"x"===e&&r!==s&&(_clip(t,a,n.top),_fill(t,{line:i,target:a,color:s,scale:o,property:e}),t.restore(),t.save(),_clip(t,a,n.bottom)),_fill(t,{line:i,target:a,color:r,scale:o,property:e}),t.restore()}function drawfill(t,e,i){var a=getTarget(e),{line:s,scale:r,axis:n}=e,o=s.options,e=o.fill,o=o.backgroundColor,{above:e=o,below:o=o}=e||{};a&&s.points.length&&(clipArea(t,i),doFill(t,{line:s,target:a,above:e,below:o,area:i,scale:r,axis:n}),unclipArea(t))}var plugin_filler={id:"filler",afterDatasetsUpdate(t,e,i){var a=(t.data.datasets||[]).length;const s=[];let r,n,o,l;for(n=0;n<a;++n)r=t.getDatasetMeta(n),o=r.dataset,l=null,o&&o.options&&o instanceof LineElement&&(l={visible:t.isDatasetVisible(n),index:n,fill:decodeFill(o,n,a),chart:t,axis:r.controller.options.indexAxis,scale:r.vScale,line:o}),r.$filler=l,s.push(l);for(n=0;n<a;++n)l=s[n],l&&!1!==l.fill&&(l.fill=resolveTarget(s,n,i.propagate))},beforeDraw(e,t,i){var a="beforeDraw"===i.drawTime,s=e.getSortedVisibleDatasetMetas(),r=e.chartArea;for(let t=s.length-1;0<=t;--t){const n=s[t].$filler;n&&(n.line.updateControlPoints(r,n.axis),a&&drawfill(e.ctx,n,r))}},beforeDatasetsDraw(e,t,i){if("beforeDatasetsDraw"===i.drawTime){var a=e.getSortedVisibleDatasetMetas();for(let t=a.length-1;0<=t;--t){var s=a[t].$filler;s&&drawfill(e.ctx,s,e.chartArea)}}},beforeDatasetDraw(t,e,i){e=e.meta.$filler;e&&!1!==e.fill&&"beforeDatasetDraw"===i.drawTime&&drawfill(t.ctx,e,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const getBoxSize=(t,e)=>{let{boxHeight:i=e,boxWidth:a=e}=t;return t.usePointStyle&&(i=Math.min(i,e),a=Math.min(a,e)),{boxWidth:a,boxHeight:i,itemHeight:Math.max(e,i)}},itemsEqual=(t,e)=>null!==t&&null!==e&&t.datasetIndex===e.datasetIndex&&t.index===e.index;class Legend extends Element{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 i=this.options.labels||{};let t=callback(i.generateLabels,[this.chart],this)||[];i.filter&&(t=t.filter(t=>i.filter(t,this.chart.data))),i.sort&&(t=t.sort((t,e)=>i.sort(t,e,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){const{options:i,ctx:a}=this;if(i.display){var s=i.labels,r=toFont(s.font),n=r.size,o=this._computeTitleHeight(),{boxWidth:l,itemHeight:s}=getBoxSize(s,n);let t,e;a.font=r.string,this.isHorizontal()?(t=this.maxWidth,e=this._fitRows(o,n,l,s)+10):(e=this.maxHeight,t=this._fitCols(o,n,l,s)+10),this.width=Math.min(t,i.maxWidth||this.maxWidth),this.height=Math.min(e,i.maxHeight||this.maxHeight)}else this.width=this.height=0}_fitRows(t,i,a,s){const{ctx:r,maxWidth:n,options:{labels:{padding:o}}}=this,l=this.legendHitBoxes=[],h=this.lineWidths=[0],d=s+o;let c=t;r.textAlign="left",r.textBaseline="middle";let u=-1,g=-d;return this.legendItems.forEach((t,e)=>{t=a+i/2+r.measureText(t.text).width;(0===e||h[h.length-1]+t+2*o>n)&&(c+=d,h[h.length-(0<e?0:1)]=0,g+=d,u++),l[e]={left:0,top:g,row:u,width:t,height:s},h[h.length-1]+=t+o}),c}_fitCols(t,i,a,s){const{ctx:r,maxHeight:e,options:{labels:{padding:n}}}=this,o=this.legendHitBoxes=[],l=this.columnSizes=[],h=e-t;let d=n,c=0,u=0,g=0,p=0;return this.legendItems.forEach((t,e)=>{t=a+i/2+r.measureText(t.text).width;0<e&&u+s+2*n>h&&(d+=c+n,l.push({width:c,height:u}),g+=c+n,p++,c=u=0),o[e]={left:g,top:u,col:p,width:t,height:s},c=Math.max(c,t),u+=s+n}),d+=c,l.push({width:c,height:u}),d}adjustHitBoxes(){if(this.options.display){var i=this._computeTitleHeight(),{legendHitBoxes:a,options:{align:s,labels:{padding:r},rtl:t}}=this;const n=getRtlAdapter(t,this.left,this.width);if(this.isHorizontal()){let t=0,e=_alignStartEnd(s,this.left+r,this.right-this.lineWidths[t]);for(const o of a)t!==o.row&&(t=o.row,e=_alignStartEnd(s,this.left+r,this.right-this.lineWidths[t])),o.top+=this.top+i+r,o.left=n.leftForLtr(n.x(e),o.width),e+=o.width+r}else{let t=0,e=_alignStartEnd(s,this.top+i+r,this.bottom-this.columnSizes[t].height);for(const l of a)l.col!==t&&(t=l.col,e=_alignStartEnd(s,this.top+i+r,this.bottom-this.columnSizes[t].height)),l.top=e,l.left+=this.left+r,l.left=n.leftForLtr(n.x(l.left),l.width),e+=l.height+r}}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){var t;this.options.display&&(t=this.ctx,clipArea(t,this),this._draw(),unclipArea(t))}_draw(){const{options:u,columnSizes:g,lineWidths:p,ctx:f}=this,{align:m,labels:v}=u,x=defaults.color,b=getRtlAdapter(u.rtl,this.left,this.width),_=toFont(v.font),{color:y,padding:S}=v,k=_.size,M=k/2;let P;this.drawTitle(),f.textAlign=b.textAlign("left"),f.textBaseline="middle",f.lineWidth=.5,f.font=_.string;const{boxWidth:D,boxHeight:w,itemHeight:C}=getBoxSize(v,k),A=this.isHorizontal(),L=this._computeTitleHeight();P=A?{x:_alignStartEnd(m,this.left+S,this.right-p[0]),y:this.top+S+L,line:0}:{x:this.left+S,y:_alignStartEnd(m,this.top+L+S,this.bottom-g[0].height),line:0},overrideTextDirection(this.ctx,u.textDirection);const O=C+S;this.legendItems.forEach((t,e)=>{f.strokeStyle=t.fontColor||y,f.fillStyle=t.fontColor||y;var i=f.measureText(t.text).width,a=b.textAlign(t.textAlign||(t.textAlign=v.textAlign)),s=D+M+i;let r=P.x,n=P.y;b.setWidth(this.width),A?0<e&&r+s+S>this.right&&(n=P.y+=O,P.line++,r=P.x=_alignStartEnd(m,this.left+S,this.right-p[P.line])):0<e&&n+O>this.bottom&&(r=P.x=r+g[P.line].width+S,P.line++,n=P.y=_alignStartEnd(m,this.top+L+S,this.bottom-g[P.line].height));var o,l,h,d,c=b.x(r);o=c,l=n,h=t,isNaN(D)||D<=0||isNaN(w)||w<0||(f.save(),d=valueOrDefault(h.lineWidth,1),f.fillStyle=valueOrDefault(h.fillStyle,x),f.lineCap=valueOrDefault(h.lineCap,"butt"),f.lineDashOffset=valueOrDefault(h.lineDashOffset,0),f.lineJoin=valueOrDefault(h.lineJoin,"miter"),f.lineWidth=d,f.strokeStyle=valueOrDefault(h.strokeStyle,x),f.setLineDash(valueOrDefault(h.lineDash,[])),v.usePointStyle?(i={radius:D*Math.SQRT2/2,pointStyle:h.pointStyle,rotation:h.rotation,borderWidth:d},e=b.xPlus(o,D/2),c=l+M,drawPoint(f,i,e,c)):(l=l+Math.max((k-w)/2,0),o=b.leftForLtr(o,D),h=toTRBLCorners(h.borderRadius),f.beginPath(),Object.values(h).some(t=>0!==t)?addRoundedRectPath(f,{x:o,y:l,w:D,h:w,radius:h}):f.rect(o,l,D,w),f.fill(),0!==d&&f.stroke()),f.restore()),r=_textX(a,r+D+M,A?r+s:this.right,u.rtl),d=b.x(r),a=n,t=t,renderText(f,t.text,d,a+C/2,_,{strikethrough:t.hidden,textAlign:b.textAlign(t.textAlign)}),A?P.x+=s+S:P.y+=O}),restoreTextDirection(this.ctx,u.textDirection)}drawTitle(){var a=this.options,s=a.title,r=toFont(s.font),n=toPadding(s.padding);if(s.display){const h=getRtlAdapter(a.rtl,this.left,this.width),d=this.ctx;var o=s.position,l=r.size/2,n=n.top+l;let t,e=this.left,i=this.width;this.isHorizontal()?(i=Math.max(...this.lineWidths),t=this.top+n,e=_alignStartEnd(a.align,e,this.right-i)):(l=this.columnSizes.reduce((t,e)=>Math.max(t,e.height),0),t=n+_alignStartEnd(a.align,this.top,this.bottom-l-a.labels.padding-this._computeTitleHeight()));a=_alignStartEnd(o,e,e+i);d.textAlign=h.textAlign(_toLeftRightCenter(o)),d.textBaseline="middle",d.strokeStyle=s.color,d.fillStyle=s.color,d.font=r.string,renderText(d,s.text,a,t,r)}}_computeTitleHeight(){var t=this.options.title,e=toFont(t.font),i=toPadding(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,a,s;if(_isBetween(t,this.left,this.right)&&_isBetween(e,this.top,this.bottom))for(s=this.legendHitBoxes,i=0;i<s.length;++i)if(a=s[i],_isBetween(t,a.left,a.left+a.width)&&_isBetween(e,a.top,a.top+a.height))return this.legendItems[i];return null}handleEvent(t){var e,i,a,s=this.options;isListened(t.type,s)&&(e=this._getLegendItemAt(t.x,t.y),"mousemove"===t.type?(i=this._hoveredItem,a=itemsEqual(i,e),i&&!a&&callback(s.onLeave,[t,i,this],this),(this._hoveredItem=e)&&!a&&callback(s.onHover,[t,e,this],this)):e&&callback(s.onClick,[t,e,this],this))}}function isListened(t,e){return!("mousemove"!==t||!e.onHover&&!e.onLeave)||!(!e.onClick||"click"!==t&&"mouseup"!==t)}var plugin_legend={id:"legend",_element:Legend,start(t,e,i){var a=t.legend=new Legend({ctx:t.ctx,options:i,chart:t});layouts.configure(t,a,i),layouts.addBox(t,a)},stop(t){layouts.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,i){const a=t.legend;layouts.configure(t,a,i),a.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){var a=e.datasetIndex;const s=i.chart;s.isDatasetVisible(a)?(s.hide(a),e.hidden=!0):(s.show(a),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const a=t.data.datasets,{labels:{usePointStyle:s,pointStyle:r,textAlign:n,color:o}}=t.legend.options;return t._getSortedDatasetMetas().map(t=>{var e=t.controller.getStyle(s?0:void 0),i=toPadding(e.borderWidth);return{text:a[t.index].label,fillStyle:e.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:e.borderCapStyle,lineDash:e.borderDash,lineDashOffset:e.borderDashOffset,lineJoin:e.borderJoinStyle,lineWidth:(i.width+i.height)/4,strokeStyle:e.borderColor,pointStyle:r||e.pointStyle,rotation:e.rotation,textAlign:n||e.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 Title extends Element{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){var i=this.options;this.left=0,this.top=0,i.display?(this.width=this.right=t,this.height=this.bottom=e,e=isArray(i.text)?i.text.length:1,this._padding=toPadding(i.padding),i=e*toFont(i.font).lineHeight+this._padding.height,this.isHorizontal()?this.height=i:this.width=i):this.width=this.height=this.right=this.bottom=0}isHorizontal(){var t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){var{top:e,left:i,bottom:a,right:s,options:r}=this,n=r.align;let o=0,l,h,d;return l=this.isHorizontal()?(h=_alignStartEnd(n,i,s),d=e+t,s-i):(o="left"===r.position?(h=i+t,d=_alignStartEnd(n,a,e),-.5*PI):(h=s-t,d=_alignStartEnd(n,e,a),.5*PI),a-e),{titleX:h,titleY:d,maxWidth:l,rotation:o}}draw(){var t,e,i,a,s,r=this.ctx,n=this.options;n.display&&(s=(t=toFont(n.font)).lineHeight/2+this._padding.top,{titleX:e,titleY:i,maxWidth:a,rotation:s}=this._drawArgs(s),renderText(r,n.text,0,0,t,{color:n.color,maxWidth:a,rotation:s,textAlign:_toLeftRightCenter(n.align),textBaseline:"middle",translation:[e,i]}))}}function createTitle(t,e){var i=new Title({ctx:t.ctx,options:e,chart:t});layouts.configure(t,i,e),layouts.addBox(t,i),t.titleBlock=i}var plugin_title={id:"title",_element:Title,start(t,e,i){createTitle(t,i)},stop(t){var e=t.titleBlock;layouts.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){const a=t.titleBlock;layouts.configure(t,a,i),a.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 map=new WeakMap;var plugin_subtitle={id:"subtitle",start(t,e,i){var a=new Title({ctx:t.ctx,options:i,chart:t});layouts.configure(t,a,i),layouts.addBox(t,a),map.set(t,a)},stop(t){layouts.removeBox(t,map.get(t)),map.delete(t)},beforeUpdate(t,e,i){const a=map.get(t);layouts.configure(t,a,i),a.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 positioners={average(t){if(!t.length)return!1;let e,i,a=0,s=0,r=0;for(e=0,i=t.length;e<i;++e){const o=t[e].element;var n;o&&o.hasValue()&&(n=o.tooltipPosition(),a+=n.x,s+=n.y,++r)}return{x:a/r,y:s/r}},nearest(t,e){if(!t.length)return!1;let i=e.x,a=e.y,s=Number.POSITIVE_INFINITY,r,n,o;for(r=0,n=t.length;r<n;++r){const d=t[r].element;var l;d&&d.hasValue()&&(l=d.getCenterPoint(),(l=distanceBetweenPoints(e,l))<s&&(s=l,o=d))}var h;return o&&(h=o.tooltipPosition(),i=h.x,a=h.y),{x:i,y:a}}};function pushOrConcat(t,e){return e&&(isArray(e)?Array.prototype.push.apply(t,e):t.push(e)),t}function splitNewlines(t){return("string"==typeof t||t instanceof String)&&-1<t.indexOf("\n")?t.split("\n"):t}function createTooltipItem(t,e){var{element:i,datasetIndex:a,index:s}=e;const r=t.getDatasetMeta(a).controller;var{label:n,value:e}=r.getLabelAndValue(s);return{chart:t,label:n,parsed:r.getParsed(s),raw:t.data.datasets[a].data[s],formattedValue:e,dataset:r.getDataset(),dataIndex:s,datasetIndex:a,element:i}}function getTooltipSize(t,e){const i=t.chart.ctx,{body:a,footer:s,title:r}=t;var{boxWidth:n,boxHeight:o}=e,l=toFont(e.bodyFont),h=toFont(e.titleFont),d=toFont(e.footerFont),c=r.length,u=s.length,g=a.length,p=toPadding(e.padding);let f=p.height,m=0;var v=a.reduce((t,e)=>t+e.before.length+e.lines.length+e.after.length,0);v+=t.beforeBody.length+t.afterBody.length,c&&(f+=c*h.lineHeight+(c-1)*e.titleSpacing+e.titleMarginBottom),v&&(o=e.displayColors?Math.max(o,l.lineHeight):l.lineHeight,f+=g*o+(v-g)*l.lineHeight+(v-1)*e.bodySpacing),u&&(f+=e.footerMarginTop+u*d.lineHeight+(u-1)*e.footerSpacing);let x=0;function b(t){m=Math.max(m,i.measureText(t).width+x)}return i.save(),i.font=h.string,each(t.title,b),i.font=l.string,each(t.beforeBody.concat(t.afterBody),b),x=e.displayColors?n+2+e.boxPadding:0,each(a,t=>{each(t.before,b),each(t.lines,b),each(t.after,b)}),x=0,i.font=d.string,each(t.footer,b),i.restore(),m+=p.width,{width:m,height:f}}function determineYAlign(t,e){var{y:i,height:e}=e;return i<e/2?"top":i>t.height-e/2?"bottom":"center"}function doesNotFitWithAlign(t,e,i,a){var{x:s,width:a}=a,i=i.caretSize+i.caretPadding;return"left"===t&&s+a+i>e.width||("right"===t&&s-a-i<0||void 0)}function determineXAlign(t,e,i,a){var{x:s,width:r}=i,{width:n,chartArea:{left:o,right:l}}=t;let h="center";return"center"===a?h=s<=(o+l)/2?"left":"right":s<=r/2?h="left":n-r/2<=s&&(h="right"),doesNotFitWithAlign(h,t,e,i)&&(h="center"),h}function determineAlignment(t,e,i){var a=i.yAlign||e.yAlign||determineYAlign(t,i);return{xAlign:i.xAlign||e.xAlign||determineXAlign(t,e,i,a),yAlign:a}}function alignX(t,e){let{x:i,width:a}=t;return"right"===e?i-=a:"center"===e&&(i-=a/2),i}function alignY(t,e,i){let{y:a,height:s}=t;return"top"===e?a+=i:a-="bottom"===e?s+i:s/2,a}function getBackgroundPoint(t,e,i,a){var{caretSize:s,caretPadding:r,cornerRadius:n}=t,{xAlign:o,yAlign:l}=i,h=s+r,{topLeft:d,topRight:t,bottomLeft:i,bottomRight:r}=toTRBLCorners(n);let c=alignX(e,o);n=alignY(e,l,h);return"center"===l?"left"===o?c+=h:"right"===o&&(c-=h):"left"===o?c-=Math.max(d,i)+s:"right"===o&&(c+=Math.max(t,r)+s),{x:_limitValue(c,0,a.width-e.width),y:_limitValue(n,0,a.height-e.height)}}function getAlignedX(t,e,i){i=toPadding(i.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-i.right:t.x+i.left}function getBeforeAfterBodyLines(t){return pushOrConcat([],splitNewlines(t))}function createTooltipContext(t,e,i){return createContext(t,{tooltip:e,tooltipItems:i,type:"tooltip"})}function overrideCallbacks(t,e){e=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return e?t.override(e):t}class Tooltip extends Element{constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart||t._chart,this._chart=this.chart,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(){var t=this._cachedAnimations;if(t)return t;var e=this.chart,t=this.options.setContext(this.getContext()),e=t.enabled&&e.options.animation&&t.animations,t=new Animations(this.chart,e);return e._cacheable&&(this._cachedAnimations=Object.freeze(t)),t}getContext(){return this.$context||(this.$context=createTooltipContext(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const i=e["callbacks"];var a=i.beforeTitle.apply(this,[t]),s=i.title.apply(this,[t]),e=i.afterTitle.apply(this,[t]),t=pushOrConcat(t=[],splitNewlines(a));return t=pushOrConcat(t,splitNewlines(s)),t=pushOrConcat(t,splitNewlines(e))}getBeforeBody(t,e){return getBeforeAfterBodyLines(e.callbacks.beforeBody.apply(this,[t]))}getBody(t,e){const a=e["callbacks"],s=[];return each(t,t=>{var e={before:[],lines:[],after:[]};const i=overrideCallbacks(a,t);pushOrConcat(e.before,splitNewlines(i.beforeLabel.call(this,t))),pushOrConcat(e.lines,i.label.call(this,t)),pushOrConcat(e.after,splitNewlines(i.afterLabel.call(this,t))),s.push(e)}),s}getAfterBody(t,e){return getBeforeAfterBodyLines(e.callbacks.afterBody.apply(this,[t]))}getFooter(t,e){const i=e["callbacks"];var a=i.beforeFooter.apply(this,[t]),s=i.footer.apply(this,[t]),e=i.afterFooter.apply(this,[t]),t=pushOrConcat(t=[],splitNewlines(a));return t=pushOrConcat(t,splitNewlines(s)),t=pushOrConcat(t,splitNewlines(e))}_createItems(a){var t=this._active;const s=this.chart.data,i=[],r=[],n=[];let e=[],o,l;for(o=0,l=t.length;o<l;++o)e.push(createTooltipItem(this.chart,t[o]));return a.filter&&(e=e.filter((t,e,i)=>a.filter(t,e,i,s))),a.itemSort&&(e=e.sort((t,e)=>a.itemSort(t,e,s))),each(e,t=>{const e=overrideCallbacks(a.callbacks,t);i.push(e.labelColor.call(this,t)),r.push(e.labelPointStyle.call(this,t)),n.push(e.labelTextColor.call(this,t))}),this.labelColors=i,this.labelPointStyles=r,this.labelTextColors=n,this.dataPoints=e,e}update(t,e){const i=this.options.setContext(this.getContext());var a,s,r,n=this._active;let o,l=[];n.length?(a=positioners[i.position].call(this,n,this._eventPosition),l=this._createItems(i),this.title=this.getTitle(l,i),this.beforeBody=this.getBeforeBody(l,i),this.body=this.getBody(l,i),this.afterBody=this.getAfterBody(l,i),this.footer=this.getFooter(l,i),s=this._size=getTooltipSize(this,i),r=Object.assign({},a,s),n=determineAlignment(this.chart,i,r),r=getBackgroundPoint(i,r,n,this.chart),this.xAlign=n.xAlign,this.yAlign=n.yAlign,o={opacity:1,x:r.x,y:r.y,width:s.width,height:s.height,caretX:a.x,caretY:a.y}):0!==this.opacity&&(o={opacity:0}),this._tooltipItems=l,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,i,a){a=this.getCaretPosition(t,i,a);e.lineTo(a.x1,a.y1),e.lineTo(a.x2,a.y2),e.lineTo(a.x3,a.y3)}getCaretPosition(t,e,i){var{xAlign:a,yAlign:s}=this,{caretSize:r,cornerRadius:n}=i,{topLeft:o,topRight:l,bottomLeft:h,bottomRight:d}=toTRBLCorners(n),{x:i,y:n}=t,{width:t,height:e}=e;let c,u,g,p,f,m;return"center"===s?(f=n+e/2,m="left"===a?(c=i,u=c-r,p=f+r,f-r):(c=i+t,u=c+r,p=f-r,f+r),g=c):(u="left"===a?i+Math.max(o,h)+r:"right"===a?i+t-Math.max(l,d)-r:this.caretX,g="top"===s?(p=n,f=p-r,c=u-r,u+r):(p=n+e,f=p+r,c=u+r,u-r),m=p),{x1:c,x2:u,x3:g,y1:p,y2:f,y3:m}}drawTitle(t,e,i){var a=this.title,s=a.length;let r,n,o;if(s){const l=getRtlAdapter(i.rtl,this.x,this.width);for(t.x=getAlignedX(this,i.titleAlign,i),e.textAlign=l.textAlign(i.titleAlign),e.textBaseline="middle",r=toFont(i.titleFont),n=i.titleSpacing,e.fillStyle=i.titleColor,e.font=r.string,o=0;o<s;++o)e.fillText(a[o],l.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+n,o+1===s&&(t.y+=i.titleMarginBottom-n)}}_drawColorBox(t,e,i,a,s){var r,n=this.labelColors[i],o=this.labelPointStyles[i],{boxHeight:l,boxWidth:h,boxPadding:d}=s,c=toFont(s.bodyFont),u=getAlignedX(this,"left",s),u=a.x(u),c=l<c.lineHeight?(c.lineHeight-l)/2:0,e=e.y+c;s.usePointStyle?(c={radius:Math.min(h,l)/2,pointStyle:o.pointStyle,rotation:o.rotation,borderWidth:1},o=a.leftForLtr(u,h)+h/2,r=e+l/2,t.strokeStyle=s.multiKeyBackground,t.fillStyle=s.multiKeyBackground,drawPoint(t,c,o,r),t.strokeStyle=n.borderColor,t.fillStyle=n.backgroundColor,drawPoint(t,c,o,r)):(t.lineWidth=n.borderWidth||1,t.strokeStyle=n.borderColor,t.setLineDash(n.borderDash||[]),t.lineDashOffset=n.borderDashOffset||0,r=a.leftForLtr(u,h-d),u=a.leftForLtr(a.xPlus(u,1),h-d-2),d=toTRBLCorners(n.borderRadius),Object.values(d).some(t=>0!==t)?(t.beginPath(),t.fillStyle=s.multiKeyBackground,addRoundedRectPath(t,{x:r,y:e,w:h,h:l,radius:d}),t.fill(),t.stroke(),t.fillStyle=n.backgroundColor,t.beginPath(),addRoundedRectPath(t,{x:u,y:e+1,w:h-2,h:l-2,radius:d}),t.fill()):(t.fillStyle=s.multiKeyBackground,t.fillRect(r,e,h,l),t.strokeRect(r,e,h,l),t.fillStyle=n.backgroundColor,t.fillRect(u,e+1,h-2,l-2))),t.fillStyle=this.labelTextColors[i]}drawBody(e,i,t){var a=this["body"];const{bodySpacing:s,bodyAlign:r,displayColors:n,boxHeight:o,boxWidth:l,boxPadding:h}=t;var d=toFont(t.bodyFont);let c=d.lineHeight,u=0;const g=getRtlAdapter(t.rtl,this.x,this.width);function p(t){i.fillText(t,g.x(e.x+u),e.y+c/2),e.y+=c+s}var f=g.textAlign(r);let m,v,x,b,_,y,S;for(i.textAlign=r,i.textBaseline="middle",i.font=d.string,e.x=getAlignedX(this,f,t),i.fillStyle=t.bodyColor,each(this.beforeBody,p),u=n&&"right"!==f?"center"===r?l/2+h:l+2+h:0,b=0,y=a.length;b<y;++b){for(m=a[b],v=this.labelTextColors[b],i.fillStyle=v,each(m.before,p),x=m.lines,n&&x.length&&(this._drawColorBox(i,e,b,g,t),c=Math.max(d.lineHeight,o)),_=0,S=x.length;_<S;++_)p(x[_]),c=d.lineHeight;each(m.after,p)}u=0,c=d.lineHeight,each(this.afterBody,p),e.y-=s}drawFooter(t,e,i){var a=this.footer,s=a.length;let r,n;if(s){const o=getRtlAdapter(i.rtl,this.x,this.width);for(t.x=getAlignedX(this,i.footerAlign,i),t.y+=i.footerMarginTop,e.textAlign=o.textAlign(i.footerAlign),e.textBaseline="middle",r=toFont(i.footerFont),e.fillStyle=i.footerColor,e.font=r.string,n=0;n<s;++n)e.fillText(a[n],o.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+i.footerSpacing}}drawBackground(t,e,i,a){var{xAlign:s,yAlign:r}=this,{x:n,y:o}=t,{width:l,height:h}=i,{topLeft:d,topRight:c,bottomLeft:u,bottomRight:g}=toTRBLCorners(a.cornerRadius);e.fillStyle=a.backgroundColor,e.strokeStyle=a.borderColor,e.lineWidth=a.borderWidth,e.beginPath(),e.moveTo(n+d,o),"top"===r&&this.drawCaret(t,e,i,a),e.lineTo(n+l-c,o),e.quadraticCurveTo(n+l,o,n+l,o+c),"center"===r&&"right"===s&&this.drawCaret(t,e,i,a),e.lineTo(n+l,o+h-g),e.quadraticCurveTo(n+l,o+h,n+l-g,o+h),"bottom"===r&&this.drawCaret(t,e,i,a),e.lineTo(n+u,o+h),e.quadraticCurveTo(n,o+h,n,o+h-u),"center"===r&&"left"===s&&this.drawCaret(t,e,i,a),e.lineTo(n,o+d),e.quadraticCurveTo(n,o,n+d,o),e.closePath(),e.fill(),0<a.borderWidth&&e.stroke()}_updateAnimationTarget(t){var e,i,a=this.chart,s=this.$animations,r=s&&s.x,n=s&&s.y;!r&&!n||(e=positioners[t.position].call(this,this._active,this._eventPosition))&&(i=this._size=getTooltipSize(this,t),a=getBackgroundPoint(t,s=Object.assign({},e,this._size),s=determineAlignment(a,t,s),a),r._to===a.x&&n._to===a.y||(this.xAlign=s.xAlign,this.yAlign=s.yAlign,this.width=i.width,this.height=i.height,this.caretX=e.x,this.caretY=e.y,this._resolveAnimations().update(this,a)))}draw(t){var e=this.options.setContext(this.getContext());let i=this.opacity;if(i){this._updateAnimationTarget(e);var a={width:this.width,height:this.height};const n={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;var s=toPadding(e.padding),r=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&r&&(t.save(),t.globalAlpha=i,this.drawBackground(n,t,a,e),overrideTextDirection(t,e.textDirection),n.y+=s.top,this.drawTitle(n,t,e),this.drawBody(n,t,e),this.drawFooter(n,t,e),restoreTextDirection(t,e.textDirection),t.restore())}}getActiveElements(){return this._active||[]}setActiveElements(t,e){var i=this._active,a=t.map(({datasetIndex:t,index:e})=>{var 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}}),t=!_elementsEqual(i,a),i=this._positionChanged(a,e);(t||i)&&(this._active=a,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,i=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;var a=this.options,s=this._active||[],r=this._getActiveElements(t,s,e,i),i=this._positionChanged(r,t),i=e||!_elementsEqual(r,s)||i;return i&&(this._active=r,(a.enabled||a.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),i}_getActiveElements(t,e,i,a){var s=this.options;if("mouseout"===t.type)return[];if(!a)return e;const r=this.chart.getElementsAtEventForMode(t,s.mode,s,i);return s.reverse&&r.reverse(),r}_positionChanged(t,e){var{caretX:i,caretY:a,options:s}=this,e=positioners[s.position].call(this,t,e);return!1!==e&&(i!==e.x||a!==e.y)}}Tooltip.positioners=positioners;var plugin_tooltip={id:"tooltip",_element:Tooltip,positioners:positioners,afterInit(t,e,i){i&&(t.tooltip=new Tooltip({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;var i={tooltip:e};!1!==t.notifyPlugins("beforeTooltipDraw",i)&&(e&&e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i))},afterEvent(t,e){var i;t.tooltip&&(i=e.replay,t.tooltip.handleEvent(e.event,i,e.inChartArea)&&(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:noop,title(t){if(0<t.length){var e=t[0],i=e.chart.data.labels,t=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(0<t&&e.dataIndex<t)return i[e.dataIndex]}return""},afterTitle:noop,beforeBody:noop,beforeLabel:noop,label(t){if(this&&this.options&&"dataset"===this.options.mode)return t.label+": "+t.formattedValue||t.formattedValue;let e=t.dataset.label||"";e&&(e+=": ");t=t.formattedValue;return isNullOrUndef(t)||(e+=t),e},labelColor(t){const e=t.chart.getDatasetMeta(t.datasetIndex);t=e.controller.getStyle(t.dataIndex);return{borderColor:t.borderColor,backgroundColor:t.backgroundColor,borderWidth:t.borderWidth,borderDash:t.borderDash,borderDashOffset:t.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(t){const e=t.chart.getDatasetMeta(t.datasetIndex);t=e.controller.getStyle(t.dataIndex);return{pointStyle:t.pointStyle,rotation:t.rotation}},afterLabel:noop,afterBody:noop,beforeFooter:noop,footer:noop,afterFooter:noop}},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:t=>"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},plugins=Object.freeze({__proto__:null,Decimation:plugin_decimation,Filler:plugin_filler,Legend:plugin_legend,SubTitle:plugin_subtitle,Title:plugin_title,Tooltip:plugin_tooltip});const addIfString=(t,e,i,a)=>("string"==typeof e?(i=t.push(e)-1,a.unshift({index:i,label:e})):isNaN(e)&&(i=null),i);function findOrAddLabel(t,e,i,a){var s=t.indexOf(e);return-1===s?addIfString(t,e,i,a):s!==t.lastIndexOf(e)?i:s}const validIndex=(t,e)=>null===t?null:_limitValue(Math.round(t),0,e);class CategoryScale extends Scale{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){var e=this._addedLabels;if(e.length){const s=this.getLabels();for(var{index:i,label:a}of e)s[i]===a&&s.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(isNullOrUndef(t))return null;var i=this.getLabels();return e=isFinite(e)&&i[e]===t?e:findOrAddLabel(i,t,valueOrDefault(e,t),this._addedLabels),validIndex(e,i.length-1)}determineDataLimits(){var{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:i,max:a}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(i=0),e||(a=this.getLabels().length-1)),this.min=i,this.max=a}buildTicks(){var e=this.min,i=this.max,t=this.options.offset;const a=[];let s=this.getLabels();s=0===e&&i===s.length-1?s:s.slice(e,i+1),this._valueRange=Math.max(s.length-(t?0:1),1),this._startValue=this.min-(t?.5:0);for(let t=e;t<=i;t++)a.push({value:t});return a}getLabelForValue(t){var e=this.getLabels();return 0<=t&&t<e.length?e[t]:t}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return null===(t="number"!=typeof t?this.parse(t):t)?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){var e=this.ticks;return t<0||t>e.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 generateTicks$1(t,e){const i=[];var{bounds:a,step:s,min:r,max:n,precision:o,count:l,maxTicks:h,maxDigits:d,includeBounds:c}=t,u=s||1,g=h-1,{min:p,max:f}=e,m=!isNullOrUndef(r),v=!isNullOrUndef(n),e=!isNullOrUndef(l),d=(f-p)/(d+1);let x=niceNum((f-p)/g/u)*u,b,_,y,S;if(x<1e-14&&!m&&!v)return[{value:p},{value:f}];S=Math.ceil(f/x)-Math.floor(p/x),S>g&&(x=niceNum(S*x/g/u)*u),isNullOrUndef(o)||(b=Math.pow(10,o),x=Math.ceil(x*b)/b),y="ticks"===a?(_=Math.floor(p/x)*x,Math.ceil(f/x)*x):(_=p,f),m&&v&&s&&almostWhole((n-r)/s,x/1e3)?(S=Math.round(Math.min((n-r)/x,h)),x=(n-r)/S,_=r,y=n):e?(_=m?r:_,y=v?n:y,S=l-1,x=(y-_)/S):(S=(y-_)/x,S=almostEquals(S,Math.round(S),x/1e3)?Math.round(S):Math.ceil(S));l=Math.max(_decimalPlaces(x),_decimalPlaces(_));b=Math.pow(10,isNullOrUndef(o)?l:o),_=Math.round(_*b)/b,y=Math.round(y*b)/b;let k=0;for(m&&(c&&_!==r?(i.push({value:r}),_<r&&k++,almostEquals(Math.round((_+k*x)*b)/b,r,relativeLabelSize(r,d,t))&&k++):_<r&&k++);k<S;++k)i.push({value:Math.round((_+k*x)*b)/b});return v&&c&&y!==n?i.length&&almostEquals(i[i.length-1].value,n,relativeLabelSize(n,d,t))?i[i.length-1].value=n:i.push({value:n}):v&&y!==n||i.push({value:y}),i}function relativeLabelSize(t,e,{horizontal:i,minRotation:a}){a=toRadians(a),a=(i?Math.sin(a):Math.cos(a))||.001;return Math.min(e/a,.75*e*(""+t).length)}CategoryScale.id="category",CategoryScale.defaults={ticks:{callback:CategoryScale.prototype.getLabelForValue}};class LinearScaleBase extends Scale{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 isNullOrUndef(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){var e=this.options["beginAtZero"];const{minDefined:i,maxDefined:a}=this.getUserBounds();let{min:s,max:r}=this;var t,n,o=t=>s=i?s:t,l=t=>r=a?r:t;if(e&&(t=sign(s),n=sign(r),t<0&&n<0?l(0):0<t&&0<n&&o(0)),s===r){let t=1;(r>=Number.MAX_SAFE_INTEGER||s<=Number.MIN_SAFE_INTEGER)&&(t=Math.abs(.05*r)),l(r+t),e||o(s-t)}this.min=s,this.max=r}getTickLimit(){let{maxTicksLimit:t,stepSize:e}=this.options.ticks,i;return e?(i=Math.ceil(this.max/e)-Math.floor(this.min/e)+1,1e3<i&&(console.warn(`scales.${this.id}.ticks.stepSize: ${e} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),t=t||11),t&&(i=Math.min(t,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){var t=this.options,e=t.ticks,i=this.getTickLimit();const a=generateTicks$1({maxTicks:i=Math.max(2,i),bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:!1!==e.includeBounds},this._range||this);return"ticks"===t.bounds&&_setMinAndMaxByKey(a,this,"value"),t.reverse?(a.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),a}configure(){var t=this.ticks;let e=this.min,i=this.max;super.configure(),this.options.offset&&t.length&&(t=(i-e)/Math.max(t.length-1,1)/2,e-=t,i+=t),this._startValue=e,this._endValue=i,this._valueRange=i-e}getLabelForValue(t){return formatNumber(t,this.chart.options.locale,this.options.ticks.format)}}class LinearScale extends LinearScaleBase{determineDataLimits(){var{min:t,max:e}=this.getMinMax(!0);this.min=isNumberFinite(t)?t:0,this.max=isNumberFinite(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){var t=this.isHorizontal(),e=t?this.width:this.height,i=toRadians(this.options.ticks.minRotation),t=(t?Math.sin(i):Math.cos(i))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,i.lineHeight/t))}getPixelForValue(t){return null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}function isMajor(t){return 1==t/Math.pow(10,Math.floor(log10(t)))}function generateTicks(t,e){var i=Math.floor(log10(e.max)),a=Math.ceil(e.max/Math.pow(10,i));const s=[];let r=finiteOrDefault(t.min,Math.pow(10,Math.floor(log10(e.min)))),n=Math.floor(log10(r)),o=Math.floor(r/Math.pow(10,n)),l=n<0?Math.pow(10,Math.abs(n)):1;for(;s.push({value:r,major:isMajor(r)}),++o,10===o&&(o=1,++n,l=0<=n?1:l),r=Math.round(o*Math.pow(10,n)*l)/l,n<i||n===i&&o<a;);t=finiteOrDefault(t.max,r);return s.push({value:t,major:isMajor(r)}),s}LinearScale.id="linear",LinearScale.defaults={ticks:{callback:Ticks.formatters.numeric}};class LogarithmicScale extends Scale{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){e=LinearScaleBase.prototype.parse.apply(this,[t,e]);if(0!==e)return isNumberFinite(e)&&0<e?e:null;this._zero=!0}determineDataLimits(){var{min:t,max:e}=this.getMinMax(!0);this.min=isNumberFinite(t)?Math.max(0,t):null,this.max=isNumberFinite(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:e,maxDefined:i}=this.getUserBounds();let a=this.min,s=this.max;var t=t=>a=e?a:t,r=t=>s=i?s:t,n=(t,e)=>Math.pow(10,Math.floor(log10(t))+e);a===s&&(a<=0?(t(1),r(10)):(t(n(a,-1)),r(n(s,1)))),a<=0&&t(n(s,-1)),s<=0&&r(n(a,1)),this._zero&&this.min!==this._suggestedMin&&a===n(this.min,0)&&t(n(a,-1)),this.min=a,this.max=s}buildTicks(){var t=this.options;const e=generateTicks({min:this._userMin,max:this._userMax},this);return"ticks"===t.bounds&&_setMinAndMaxByKey(e,this,"value"),t.reverse?(e.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),e}getLabelForValue(t){return void 0===t?"0":formatNumber(t,this.chart.options.locale,this.options.ticks.format)}configure(){var t=this.min;super.configure(),this._startValue=log10(t),this._valueRange=log10(this.max)-log10(t)}getPixelForValue(t){return null===(t=void 0===t||0===t?this.min:t)||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(log10(t)-this._startValue)/this._valueRange)}getValueForPixel(t){t=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+t*this._valueRange)}}function getTickBackdropHeight(t){var e=t.ticks;if(e.display&&t.display){t=toPadding(e.backdropPadding);return valueOrDefault(e.font&&e.font.size,defaults.font.size)+t.height}return 0}function measureLabelSize(t,e,i){return i=isArray(i)?i:[i],{w:_longestText(t,e.string,i),h:i.length*e.lineHeight}}function determineLimits(t,e,i,a,s){return t===a||t===s?{start:e-i/2,end:e+i/2}:t<a||s<t?{start:e-i,end:e}:{start:e,end:e+i}}function fitWithPointLabels(e){var i={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},a=Object.assign({},i);const s=[],r=[];var n=e._pointLabels.length;const o=e.options.pointLabels;var l=o.centerPointLabels?PI/n:0;for(let t=0;t<n;t++){var h=o.setContext(e.getPointLabelContext(t));r[t]=h.padding;var d=e.getPointPosition(t,e.drawingArea+r[t],l),c=toFont(h.font),u=measureLabelSize(e.ctx,c,e._pointLabels[t]);s[t]=u;h=_normalizeAngle(e.getIndexAngle(t)+l),c=Math.round(toDegrees(h));updateLimits(a,i,h,determineLimits(c,d.x,u.w,0,180),determineLimits(c,d.y,u.h,90,270))}e.setCenterPoint(i.l-a.l,a.r-i.r,i.t-a.t,a.b-i.b),e._pointLabelItems=buildPointLabelItems(e,s,r)}function updateLimits(t,e,i,a,s){var r=Math.abs(Math.sin(i)),i=Math.abs(Math.cos(i));let n=0,o=0;a.start<e.l?(n=(e.l-a.start)/r,t.l=Math.min(t.l,e.l-n)):a.end>e.r&&(n=(a.end-e.r)/r,t.r=Math.max(t.r,e.r+n)),s.start<e.t?(o=(e.t-s.start)/i,t.t=Math.min(t.t,e.t-o)):s.end>e.b&&(o=(s.end-e.b)/i,t.b=Math.max(t.b,e.b+o))}function buildPointLabelItems(e,i,a){const s=[];var r=e._pointLabels.length,t=e.options,n=getTickBackdropHeight(t)/2,o=e.drawingArea,l=t.pointLabels.centerPointLabels?PI/r:0;for(let t=0;t<r;t++){var h=e.getPointPosition(t,o+n+a[t],l),d=Math.round(toDegrees(_normalizeAngle(h.angle+HALF_PI))),c=i[t],u=yForAngle(h.y,c.h,d),g=getTextAlignForAngle(d),d=leftForTextAlign(h.x,c.w,g);s.push({x:h.x,y:u,textAlign:g,left:d,top:u,right:d+c.w,bottom:u+c.h})}return s}function getTextAlignForAngle(t){return 0===t||180===t?"center":t<180?"left":"right"}function leftForTextAlign(t,e,i){return"right"===i?t-=e:"center"===i&&(t-=e/2),t}function yForAngle(t,e,i){return 90===i||270===i?t-=e/2:(270<i||i<90)&&(t-=e),t}function drawPointLabels(e,i){const{ctx:a,options:{pointLabels:s}}=e;for(let t=i-1;0<=t;t--){var r,n=s.setContext(e.getPointLabelContext(t)),o=toFont(n.font),{x:l,y:h,textAlign:d,left:c,top:u,right:g,bottom:p}=e._pointLabelItems[t],f=n["backdropColor"];isNullOrUndef(f)||(r=toPadding(n.backdropPadding),a.fillStyle=f,a.fillRect(c-r.left,u-r.top,g-c+r.width,p-u+r.height)),renderText(a,e._pointLabels[t],l,h+o.lineHeight/2,o,{color:n.color,textAlign:d,textBaseline:"middle"})}}function pathRadiusLine(e,i,t,a){const s=e["ctx"];if(t)s.arc(e.xCenter,e.yCenter,i,0,TAU);else{var r=e.getPointPosition(0,i);s.moveTo(r.x,r.y);for(let t=1;t<a;t++)r=e.getPointPosition(t,i),s.lineTo(r.x,r.y)}}function drawRadiusLine(t,e,i,a){const s=t.ctx;var r=e.circular,{color:n,lineWidth:o}=e;!r&&!a||!n||!o||i<0||(s.save(),s.strokeStyle=n,s.lineWidth=o,s.setLineDash(e.borderDash),s.lineDashOffset=e.borderDashOffset,s.beginPath(),pathRadiusLine(t,i,r,a),s.closePath(),s.stroke(),s.restore())}function createPointLabelContext(t,e,i){return createContext(t,{label:i,index:e,type:"pointLabel"})}LogarithmicScale.id="logarithmic",LogarithmicScale.defaults={ticks:{callback:Ticks.formatters.logarithmic,major:{enabled:!0}}};class RadialLinearScale extends LinearScaleBase{constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){var t=this._padding=toPadding(getTickBackdropHeight(this.options)/2),e=this.width=this.maxWidth-t.width,i=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+i/2+t.top),this.drawingArea=Math.floor(Math.min(e,i)/2)}determineDataLimits(){var{min:t,max:e}=this.getMinMax(!1);this.min=isNumberFinite(t)&&!isNaN(t)?t:0,this.max=isNumberFinite(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/getTickBackdropHeight(this.options))}generateTickLabels(t){LinearScaleBase.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((t,e)=>{e=callback(this.options.pointLabels.callback,[t,e],this);return e||0===e?e:""}).filter((t,e)=>this.chart.getDataVisibility(e))}fit(){var t=this.options;t.display&&t.pointLabels.display?fitWithPointLabels(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,i,a){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((i-a)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,i,a))}getIndexAngle(t){var e=TAU/(this._pointLabels.length||1),i=this.options.startAngle||0;return _normalizeAngle(t*e+toRadians(i))}getDistanceFromCenterForValue(t){if(isNullOrUndef(t))return NaN;var e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(isNullOrUndef(t))return NaN;t/=this.drawingArea/(this.max-this.min);return this.options.reverse?this.max-t:this.min+t}getPointLabelContext(t){var e=this._pointLabels||[];if(0<=t&&t<e.length){e=e[t];return createPointLabelContext(this.getContext(),t,e)}}getPointPosition(t,e,i=0){i=this.getIndexAngle(t)-HALF_PI+i;return{x:Math.cos(i)*e+this.xCenter,y:Math.sin(i)*e+this.yCenter,angle:i}}getPointPositionForValue(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}getPointLabelPosition(t){var{left:e,top:i,right:a,bottom:t}=this._pointLabelItems[t];return{left:e,top:i,right:a,bottom:t}}drawBackground(){var{backgroundColor:t,grid:{circular:e}}=this.options;if(t){const i=this.ctx;i.save(),i.beginPath(),pathRadiusLine(this,this.getDistanceFromCenterForValue(this._endValue),e,this._pointLabels.length),i.closePath(),i.fillStyle=t,i.fill(),i.restore()}}drawGrid(){const t=this.ctx;var e=this.options;const{angleLines:i,grid:a}=e,s=this._pointLabels.length;let r,n,o;if(e.pointLabels.display&&drawPointLabels(this,s),a.display&&this.ticks.forEach((t,e)=>{0!==e&&(n=this.getDistanceFromCenterForValue(t.value),e=a.setContext(this.getContext(e-1)),drawRadiusLine(this,e,n,s))}),i.display){for(t.save(),r=s-1;0<=r;r--){var l=i.setContext(this.getPointLabelContext(r)),{color:h,lineWidth:d}=l;d&&h&&(t.lineWidth=d,t.strokeStyle=h,t.setLineDash(l.borderDash),t.lineDashOffset=l.borderDashOffset,n=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),o=this.getPointPosition(r,n),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(o.x,o.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const n=this.ctx,o=this.options,l=o.ticks;if(l.display){var t=this.getIndexAngle(0);let s,r;n.save(),n.translate(this.xCenter,this.yCenter),n.rotate(t),n.textAlign="center",n.textBaseline="middle",this.ticks.forEach((t,e)=>{var i,a;0===e&&!o.reverse||(i=l.setContext(this.getContext(e)),a=toFont(i.font),s=this.getDistanceFromCenterForValue(this.ticks[e].value),i.showLabelBackdrop&&(n.font=a.string,r=n.measureText(t.label).width,n.fillStyle=i.backdropColor,e=toPadding(i.backdropPadding),n.fillRect(-r/2-e.left,-s-a.size/2-e.top,r+e.width,a.size+e.height)),renderText(n,t.label,0,-s,a,{color:i.color}))}),n.restore()}}drawTitle(){}}RadialLinearScale.id="radialLinear",RadialLinearScale.defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Ticks.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}},RadialLinearScale.defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};const INTERVALS={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:!(RadialLinearScale.descriptors={angleLines:{_fallback:"grid"}}),size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},UNITS=Object.keys(INTERVALS);function sorter(t,e){return t-e}function parse(t,e){if(isNullOrUndef(e))return null;const i=t._adapter,{parser:a,round:s,isoWeekday:r}=t._parseOpts;let n=e;return"function"==typeof a&&(n=a(n)),isNumberFinite(n)||(n="string"==typeof a?i.parse(n,a):i.parse(n)),null===n?null:(s&&(n="week"!==s||!isNumber(r)&&!0!==r?i.startOf(n,s):i.startOf(n,"isoWeek",r)),+n)}function determineUnitForAutoTicks(e,i,a,s){var r=UNITS.length;for(let t=UNITS.indexOf(e);t<r-1;++t){var n=INTERVALS[UNITS[t]],o=n.steps||Number.MAX_SAFE_INTEGER;if(n.common&&Math.ceil((a-i)/(o*n.size))<=s)return UNITS[t]}return UNITS[r-1]}function determineUnitForFormatting(e,i,a,s,r){for(let t=UNITS.length-1;t>=UNITS.indexOf(a);t--){var n=UNITS[t];if(INTERVALS[n].common&&e._adapter.diff(r,s,n)>=i-1)return n}return UNITS[a?UNITS.indexOf(a):0]}function determineMajorUnit(i){for(let t=UNITS.indexOf(i)+1,e=UNITS.length;t<e;++t)if(INTERVALS[UNITS[t]].common)return UNITS[t]}function addTick(t,e,i){var a,s;i?i.length&&({lo:a,hi:s}=_lookup(i,e),t[i[a]>=e?i[a]:i[s]]=!0):t[e]=!0}function setMajorTicks(t,e,i,a){const s=t._adapter;var t=+s.startOf(e[0].value,a),r=e[e.length-1].value;let n,o;for(n=t;n<=r;n=+s.add(n,1,a))0<=(o=i[n])&&(e[o].major=!0);return e}function ticksFromTimestamps(t,e,i){const a=[],s={};var r=e.length;let n,o;for(n=0;n<r;++n)o=e[n],s[o]=n,a.push({value:o,major:!1});return 0!==r&&i?setMajorTicks(t,a,s,i):a}class TimeScale extends Scale{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){var i=t.time||(t.time={});const a=this._adapter=new adapters._date(t.adapters.date);mergeIf(i.displayFormats,a.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:parse(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){var t=this.options;const e=this._adapter;var i=t.time.unit||"day";let{min:a,max:s,minDefined:r,maxDefined:n}=this.getUserBounds();function o(t){r||isNaN(t.min)||(a=Math.min(a,t.min)),n||isNaN(t.max)||(s=Math.max(s,t.max))}r&&n||(o(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||o(this.getMinMax(!1))),a=isNumberFinite(a)&&!isNaN(a)?a:+e.startOf(Date.now(),i),s=isNumberFinite(s)&&!isNaN(s)?s:+e.endOf(Date.now(),i)+1,this.min=Math.min(a,s-1),this.max=Math.max(a+1,s)}_getLabelBounds(){var 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(){var t=this.options,e=t.time,i=t.ticks,a="labels"===i.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&a.length&&(this.min=this._userMin||a[0],this.max=this._userMax||a[a.length-1]);var s=this.min,r=this.max;const n=_filterBetween(a,s,r);return this._unit=e.unit||(i.autoSkip?determineUnitForAutoTicks(e.minUnit,this.min,this.max,this._getLabelCapacity(s)):determineUnitForFormatting(this,n.length,e.minUnit,this.min,this.max)),this._majorUnit=i.major.enabled&&"year"!==this._unit?determineMajorUnit(this._unit):void 0,this.initOffsets(a),t.reverse&&n.reverse(),ticksFromTimestamps(this,n,this._majorUnit)}initOffsets(t){let e=0,i=0;var a;this.options.offset&&t.length&&(a=this.getDecimalForValue(t[0]),e=1===t.length?1-a:(this.getDecimalForValue(t[1])-a)/2,a=this.getDecimalForValue(t[t.length-1]),i=1===t.length?a:(a-this.getDecimalForValue(t[t.length-2]))/2);t=t.length<3?.5:.25;e=_limitValue(e,0,t),i=_limitValue(i,0,t),this._offsets={start:e,end:i,factor:1/(e+1+i)}}_generate(){const t=this._adapter;var e=this.min,i=this.max,a=this.options,s=a.time,r=s.unit||determineUnitForAutoTicks(s.minUnit,e,i,this._getLabelCapacity(e)),n=valueOrDefault(s.stepSize,1),o="week"===r&&s.isoWeekday,s=isNumber(o)||!0===o,l={};let h=e,d,c;if(s&&(h=+t.startOf(h,"isoWeek",o)),h=+t.startOf(h,s?"day":r),t.diff(i,e,r)>1e5*n)throw new Error(e+" and "+i+" are too far apart with stepSize of "+n+" "+r);var u="data"===a.ticks.source&&this.getDataTimestamps();for(d=h,c=0;d<i;d=+t.add(d,n,r),c++)addTick(l,d,u);return d!==i&&"ticks"!==a.bounds&&1!==c||addTick(l,d,u),Object.keys(l).sort((t,e)=>t-e).map(t=>+t)}getLabelForValue(t){const e=this._adapter;var i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}_tickFormatFunction(t,e,i,a){var s=this.options,r=s.time.displayFormats,n=this._unit,o=this._majorUnit,l=n&&r[n],n=o&&r[o],r=i[e],r=o&&n&&r&&r.major,l=this._adapter.format(t,a||(r?n:l)),s=s.ticks.callback;return s?callback(s,[l,e,i],this):l}generateTickLabels(t){let e,i,a;for(e=0,i=t.length;e<i;++e)a=t[e],a.label=this._tickFormatFunction(a.value,e,t)}getDecimalForValue(t){return null===t?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){var e=this._offsets,t=this.getDecimalForValue(t);return this.getPixelForDecimal((e.start+t)*e.factor)}getValueForPixel(t){var e=this._offsets,e=this.getDecimalForPixel(t)/e.factor-e.end;return this.min+e*(this.max-this.min)}_getLabelSize(t){var e=this.options.ticks,i=this.ctx.measureText(t).width,a=toRadians(this.isHorizontal()?e.maxRotation:e.minRotation),t=Math.cos(a),e=Math.sin(a),a=this._resolveTickFontOptions(0).size;return{w:i*t+a*e,h:i*e+a*t}}_getLabelCapacity(t){var e=this.options.time,i=e.displayFormats,i=i[e.unit]||i.millisecond,i=this._tickFormatFunction(t,0,ticksFromTimestamps(this,[t],this._majorUnit),i),i=this._getLabelSize(i),i=Math.floor(this.isHorizontal()?this.width/i.w:this.height/i.h)-1;return 0<i?i:1}getDataTimestamps(){let t=this._cache.data||[],e,i;if(t.length)return t;const a=this.getMatchingVisibleMetas();if(this._normalized&&a.length)return this._cache.data=a[0].controller.getAllParsedValues(this);for(e=0,i=a.length;e<i;++e)t=t.concat(a[e].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let e,i;if(t.length)return t;var a=this.getLabels();for(e=0,i=a.length;e<i;++e)t.push(parse(this,a[e]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return _arrayUnique(t.sort(sorter))}}function interpolate(t,e,i){let a=0,s=t.length-1,r,n,o,l;i?(e>=t[a].pos&&e<=t[s].pos&&({lo:a,hi:s}=_lookupByKey(t,"pos",e)),{pos:r,time:o}=t[a],{pos:n,time:l}=t[s]):(e>=t[a].time&&e<=t[s].time&&({lo:a,hi:s}=_lookupByKey(t,"time",e)),{time:r,pos:o}=t[a],{time:n,pos:l}=t[s]);t=n-r;return t?o+(l-o)*(e-r)/t:o}TimeScale.id="time",TimeScale.defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",major:{enabled:!1}}};class TimeSeriesScale extends TimeScale{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){var t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=interpolate(e,this.min),this._tableRange=interpolate(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){var{min:e,max:i}=this;const a=[],s=[];let r,n,o,l,h;for(r=0,n=t.length;r<n;++r)l=t[r],l>=e&&l<=i&&a.push(l);if(a.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(r=0,n=a.length;r<n;++r)h=a[r+1],o=a[r-1],l=a[r],Math.round((h+o)/2)!==l&&s.push({time:l,pos:r/(n-1)});return s}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps();var i=this.getLabelTimestamps();return t=e.length&&i.length?this.normalize(e.concat(i)):e.length?e:i,t=this._cache.all=t,t}getDecimalForValue(t){return(interpolate(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){var e=this._offsets,e=this.getDecimalForPixel(t)/e.factor-e.end;return interpolate(this._table,e*this._tableRange+this._minPos,!0)}}TimeSeriesScale.id="timeseries",TimeSeriesScale.defaults=TimeScale.defaults;var scales=Object.freeze({__proto__:null,CategoryScale:CategoryScale,LinearScale:LinearScale,LogarithmicScale:LogarithmicScale,RadialLinearScale:RadialLinearScale,TimeScale:TimeScale,TimeSeriesScale:TimeSeriesScale});const registerables=[controllers,elements,plugins,scales];export{Animation,Animations,ArcElement,BarController,BarElement,BasePlatform,BasicPlatform,BubbleController,CategoryScale,Chart,DatasetController,plugin_decimation as Decimation,DomPlatform,DoughnutController,Element,plugin_filler as Filler,Interaction,plugin_legend as Legend,LineController,LineElement,LinearScale,LogarithmicScale,PieController,PointElement,PolarAreaController,RadarController,RadialLinearScale,Scale,ScatterController,plugin_subtitle as SubTitle,Ticks,TimeScale,TimeSeriesScale,plugin_title as Title,plugin_tooltip as Tooltip,adapters as _adapters,_detectPlatform,animator,controllers,elements,layouts,plugins,registerables,registry,scales};