skadi 0.4.0.beta.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,10 +27,10 @@ var e=Array.isArray,t=Array.prototype.indexOf,n=Array.prototype.includes,r=Array
27
27
  absolute inset-0 left-auto p-2
28
28
  text-night-800 hover:text-black hover:bg-night-50
29
29
  cursor-pointer
30
- "><!></button>`),ua=U(`<p> </p>`),da=U(`<div class="relative w-max"><input type="date"/> <!></div>`),fa=U(`<div class="relative w-max"><input type="number"/> <!></div>`),pa=U(`<option> </option>`),ma=U(`<!>`,1),ha=U(`<select><!></select>`),ga=U(`<div class="flex items-center gap-2 font-normal"> <!> </div>`),_a=U(`<div class="relative flex"><input type="text"/> <!></div>`),va=U(`<textarea></textarea>`),ya=U(`<span class="help-text mb-1"> </span>`),ba=U(`<label><!> <!> <!></label>`);function xa(e,t){qe(t,!0);let n=e=>{var t=Kr(),n=I(t),r=e=>{var t=la();aa(F(t),{name:`clear`}),A(t),H(`click`,t,E),W(e,t)};K(n,e=>{V(_)&&e(r)}),W(e,t)},r=ta(t,`type`,3,`text`),i=ta(t,`model`,7),a=ta(t,`description`,3,null),o=ta(t,`selectOptions`,3,null),s=ta(t,`leftValue`,3,null),c=ta(t,`rightValue`,3,null),l=ta(t,`switchIndeterminate`,3,!1),u=ta(t,`allowEmpty`,3,!1),f=ta(t,`showClear`,3,!0),p=ta(t,`trimOnBlur`,3,!1),m=ta(t,`class`,3,``),h=ea(t,ca),g=j(()=>l()&&i()[t.key]!==c()&&i()[t.key]!==s()?null:i()[t.key]===c()||c()===null&&i()[t.key]===void 0),_=j(()=>f()&&i()[t.key]),v=j(()=>[`date`,`number`,`text`,`textarea`,`contenteditable`].includes(r())?1e3:250),y,b=null,x=()=>{b!==null&&b!==``||u()?i()[t.key]=b:delete i()[t.key]},S=e=>{if(r()===`contenteditable`)b=e.currentTarget.innerText;else if(r()===`number`){let t=e.currentTarget.value.trim();b=t.match(/^-?\d*\.?\d+$/)?Number.parseFloat(t):null}else b=e.currentTarget.value;y&&clearTimeout(y),y=setTimeout(x,V(v))},C=()=>{V(g)?s()===null?delete i()[t.key]:i()[t.key]=s():V(g)===null?i()[t.key]=c():l()||c()===null?delete i()[t.key]:i()[t.key]=c()},w=()=>{y&&(clearTimeout(y),x()),p()&&typeof i()[t.key]==`string`&&(i()[t.key]=i()[t.key].trim())},T=(e,t)=>(e.innerText=t??``,{update(t){document.activeElement!==e&&(e.innerText=t??``)}}),E=()=>{y&&clearTimeout(y),(r()===`text`||r()===`string`)&&u()?i()[t.key]=``:delete i()[t.key]};var D=ba(),ee=F(D);li(ee,()=>t.children);var te=L(ee,2),ne=e=>{var n=ua();Vi(n,()=>({contenteditable:!0,onblur:w,oninput:S,class:`mt-1 whitespace-pre-wrap`,...h}));var r=F(n,!0);A(n),ui(n,(e,t)=>T?.(e,t),()=>i()[t.key]),R(()=>G(r,i()[t.key])),W(e,n)},re=e=>{var r=da(),a=F(r);Fi(a);var o=L(a,2);n(o),A(r),R(()=>{Ii(a,i()[t.key]),bi(a,1,`w-max ${V(_)?`pr-8`:``}`)}),Fr(`blur`,a,w),H(`input`,a,S),W(e,r)},ie=e=>{var r=fa(),a=F(r);Fi(a);var o=L(a,2);n(o),A(r),R(()=>{Ii(a,i()[t.key]),bi(a,1,V(_)?`pr-8`:``)}),Fr(`blur`,a,w),H(`input`,a,S),W(e,r)},ae=e=>{var n=ha();qi(n,()=>{var e=F(n),t=ma(),r=I(t),i=e=>{var t=Kr();q(I(t),17,o,ei,(e,t)=>{var n=Kr(),r=I(n),i=e=>{var n=pa(),r=F(n,!0);A(n);var i={};R(()=>{G(r,V(t)),i!==(i=V(t))&&(n.__value=V(t))}),W(e,n)},a=e=>{var n=pa(),r=F(n,!0);A(n);var i={};R(()=>{G(r,V(t).label??V(t).value),i!==(i=V(t).value)&&(n.value=(n.__value=V(t).value)??``)}),W(e,n)};K(r,e=>{typeof V(t)==`string`?e(i):e(a,-1)}),W(e,n)}),W(e,t)},a=j(()=>Array.isArray(o())),s=e=>{var t=Kr();li(I(t),()=>o()??d),W(e,t)};K(r,e=>{V(a)?e(i):e(s,-1)}),W(e,t)});var r;wi(n),R(()=>{r!==(r=i()[t.key]??``)&&(n.value=(n.__value=i()[t.key]??``)??``,Ci(n,i()[t.key]??``))}),Fr(`blur`,n,w),H(`input`,n,S),W(e,n)},oe=e=>{var n=ga(),r=F(n),i=L(r);{let e=j(()=>t.leftLabel?``:void 0),n=j(()=>t.rightLabel?``:void 0);sa(i,{get value(){return V(g)},onToggle:C,get labelOff(){return V(e)},get labelOn(){return V(n)}})}var a=L(i);A(n),R(()=>{G(r,`${t.leftLabel??``} `),G(a,` ${t.rightLabel??``}`)}),W(e,n)},se=e=>{var r=_a(),a=F(r);Fi(a);var o=L(a,2);n(o),A(r),R(()=>{Ii(a,i()[t.key]),bi(a,1,`grow ${V(_)?`pr-8`:``}`)}),Fr(`blur`,a,w),H(`input`,a,S),W(e,r)},ce=e=>{var n=va();ut(n),Vi(n,()=>({onblur:w,oninput:S,...h,value:i()[t.key]})),W(e,n)};K(te,e=>{r()===`contenteditable`?e(ne):r()===`date`?e(re,1):r()===`number`?e(ie,2):r()===`select`?e(ae,3):r()===`switch`?e(oe,4):r()===`string`||r()===`text`?e(se,5):r()===`textarea`&&e(ce,6)});var le=L(te,2),ue=e=>{var t=ya(),n=F(t,!0);A(t),R(()=>G(n,a())),W(e,t)},de=e=>{var t=Kr();li(I(t),()=>a()??d),W(e,t)};K(le,e=>{typeof a()==`string`?e(ue):e(de,-1)}),A(D),R(()=>bi(D,1,mi(m()))),W(e,D),Je()}Ir([`click`,`input`]);var Sa=U(`<div><button type="button" class="group w-full flex items-center unstyled cursor-pointer py-0.5"><!> <!></button> <div class="contents"><div><div class="flex flex-col gap-3 px-0.5 pb-2 mt-2 overflow-hidden"><!></div></div></div></div>`);function Ca(e,t){qe(t,!0);let n=ta(t,`startOpen`,3,!1),r=ta(t,`wrapperClass`,3,`border-night-700`),i=N(on(br(()=>n())));function a(){P(i,!1)}let o=()=>{P(i,!V(i))};var s={close:a},c=Sa(),l=F(c),u=F(l);li(u,()=>t.title,()=>V(i));var d=L(u,2);{let e=j(()=>V(i)?`chevron_up`:`chevron_down`);aa(d,{get name(){return V(e)},size:24,class:`text-ice-800 group-hover:text-black ml-auto`})}A(l);var f=L(l,2),p=F(f),m=F(p);return li(F(m),()=>t.children),A(m),A(p),A(f),A(c),R(()=>{bi(c,1,`border-l-4 ${r()??``} pl-4 py-0.5`),bi(p,1,`grid transition-[grid-template-rows] ease-in-out overflow-hidden ${V(i)?`grid-rows-[1fr]`:`grid-rows-[0fr]`}`)}),H(`click`,l,o),W(e,c),Je(s)}Ir([`click`]);var wa=JSON.parse(document.querySelector(`[data-dashboard-config]`)?.dataset?.datasetSchema),Ta=e=>e.replace(/_/g,` `).replace(/^[a-z]/,e=>e.toLocaleUpperCase()).replace(/\bSql\b/g,`SQL`).replace(/\bUtm\b/g,`UTM`),Ea={"01":`January`,"02":`February`,"03":`March`,"04":`April`,"05":`May`,"06":`June`,"07":`July`,"08":`August`,"09":`September`,10:`October`,11:`November`,12:`December`},Da={"01":`Jan`,"02":`Feb`,"03":`Mar`,"04":`Apr`,"05":`May`,"06":`Jun`,"07":`Jul`,"08":`Aug`,"09":`Sep`,10:`Oct`,11:`Nov`,12:`Dec`},Oa=(e,t)=>{if(typeof e!=`string`||!e.match(/^\d{4}-\d{2}-\d{2}/))return`${e}`;let[n,r,i]=e.substring(0,10).split(`-`,3);if(!n||!r||!i)return e;switch(t){case`month`:return`${Ea[r]} ${n}`;case`week`:return`w/c ${+i} ${Da[r]} ${n.substring(2,4)}`;case`day`:return`${+i} ${Da[r]} ${n.substring(2,4)}`}},ka=e=>e.type===`percentage`,Aa=e=>e.type===`sql`,ja=e=>!ka(e)&&!Aa(e),Ma=e=>e.operator===`empty`||e.operator===`not empty`,Na={boolean:!0,date:new Date().toISOString().substring(0,10),number:0,one_of:``,string:``},Pa=e=>{if(e.type===`one_of`&&e.options){let t=e.options[0];return typeof t==`string`?t:t?.value??``}return Na[e.type??`string`]},Fa=(e,t)=>{if(!t.includes(`.`))return{datasetType:e.type,targetSchema:wa[e.type],field:t,fieldSchema:wa[e.type]?.fields?.[t]};let[n,r]=t.split(`.`,2);return{datasetType:n,targetSchema:wa[n],field:r,fieldSchema:wa[n]?.fields?.[r],association:`belongs_to`}},Ia=(e,t)=>{if(!e?.fields?.[t.field]?.filter)return!1;let n=e.fields[t.field];if(!n||!Ba(n).includes(t.operator))return!1;if(Ma(t))return!(`value`in t);let r=n.type??`string`;switch(r){case`one_of`:return n.options?.some(e=>typeof e==`string`?e===t.value:e.value===t.value);case`date`:return typeof t.value==`string`&&t.value.match(/^\d{4}-[01]\d-[0-3]\d$/);default:return typeof t.value===r}},La=e=>wa[e]?.label??Ta(e),Ra=(e,t)=>wa[t??``]?.fields?.[e]?.label??Ta(e),za={boolean:[`=`,`!=`,`empty`,`not empty`],date:[`=`,`!=`,`>`,`>=`,`<=`,`<`,`empty`,`not empty`],number:[`=`,`!=`,`>`,`>=`,`<=`,`<`,`empty`,`not empty`],one_of:[`=`,`!=`,`empty`,`not empty`],string:[`=`,`!=`,`like`,`not like`,`empty`,`not empty`]},Ba=e=>za[e?.type??`string`],Va=(e,t)=>{let n=wa[e];return t===e||n?.counts?.[t]||n?.belongs_to?.includes(t)?e:n?.belongs_to?.find(e=>!!wa[e]?.counts?.[t])},Ha=U(`<option> </option>`),Ua=U(`<span class="sr-only"> </span>`),Wa=U(`<p class="help-text -mt-1 mb-1 col-span-4"> </p>`),Ga=U(`<span> </span> <label><span class="sr-only">operator</span> <select></select></label> <!> <button type="button" class="unstyled text-night-800 hover:text-black hover:bg-night-50 p-2 cursor-pointer"><!></button> <!>`,1);function Ka(e,t){qe(t,!0);let n=j(()=>wa[t.datasetType]?.fields?.[t.filter.field]),r=(e,r)=>{if(!t.dataset.filters)return;let i=r.currentTarget.value,a=t.dataset.filters[e],o=Ma(a);a.operator=i,Ma(a)?delete a.value:(o||a.value===void 0)&&(a.value=V(n)?Pa(V(n)):``)};var i=Ga(),a=I(i),o=F(a);A(a);var s=L(a,2),c=L(F(s),2);q(c,21,()=>Ba(V(n)),ei,(e,t)=>{var n=Ha(),r=F(n,!0);A(n);var i={};R(()=>{G(r,V(t)),i!==(i=V(t))&&(n.__value=V(t))}),W(e,n)}),A(c);var l;wi(c),A(s);var u=L(s,2),d=e=>{var r=Kr(),i=I(r),a=e=>{{let r=j(()=>V(n).leftValue!==void 0&&V(n).leftValue),i=j(()=>V(n).rightValue===void 0||V(n).rightValue);xa(e,{type:`switch`,get model(){return t.filter},get leftLabel(){return V(n).leftLabel},get leftValue(){return V(r)},get rightLabel(){return V(n).rightLabel},get rightValue(){return V(i)},key:`value`,class:`ml-1`,children:(e,n)=>{var r=Ua(),i=F(r);A(r),R(e=>G(i,`${e??``} value`),[()=>Ra(t.filter.field,t.datasetType)]),W(e,r)},$$slots:{default:!0}})}},o=e=>{xa(e,{type:`select`,get model(){return t.filter},key:`value`,get selectOptions(){return V(n).options},class:`w-max`,allowEmpty:!0,children:(e,n)=>{var r=Ua(),i=F(r);A(r),R(e=>G(i,`${e??``} value`),[()=>Ra(t.filter.field,t.datasetType)]),W(e,r)},$$slots:{default:!0}})},s=e=>{{let r=j(()=>V(n)?.type??`string`),i=j(()=>!V(n)?.type||V(n)?.type===`string`);xa(e,{get type(){return V(r)},get model(){return t.filter},key:`value`,class:`w-full`,allowEmpty:!0,get showClear(){return V(i)},children:(e,n)=>{var r=Ua(),i=F(r);A(r),R(e=>G(i,`${e??``} value`),[()=>Ra(t.filter.field,t.datasetType)]),W(e,r)},$$slots:{default:!0}})}};K(i,e=>{V(n)?.type===`boolean`?e(a):V(n)?.type===`one_of`?e(o,1):e(s,-1)}),W(e,r)},f=j(()=>!Ma(t.filter));K(u,e=>{V(f)&&e(d)});var p=L(u,2);aa(F(p),{name:`delete`}),A(p);var m=L(p,2),h=e=>{var t=Wa(),r=F(t,!0);A(t),R(()=>G(r,V(n).description)),W(e,t)};K(m,e=>{V(n)?.description&&e(h)}),R((e,n)=>{G(o,`${e??``}:`),bi(s,1,`h-full ${n??``}`),l!==(l=t.filter.operator)&&(c.value=(c.__value=t.filter.operator)??``,Ci(c,t.filter.operator))},[()=>Ra(t.filter.field,t.datasetType),()=>Ma(t.filter)?`col-span-2 w-max`:``]),H(`change`,c,e=>r(t.index,e)),H(`click`,p,function(...e){t.removeFilter?.apply(this,e)}),W(e,i),Je()}Ir([`change`,`click`]);var qa=U(`<p class="text-sm font-medium text-ice-600 mt-2 col-span-4"> </p> <!>`,1),Ja=U(`<div class="grid grid-cols-[auto_4rem_1fr_auto] gap-1 items-center"><!> <!></div>`),Ya=U(`<option> </option>`),Xa=U(`<div class="border-l-2 border-ice-700 pl-4 mt-4 py-0.5 flex flex-col gap-3"><p class="text-sm font-medium text-ice-700">Filters</p> <!> <label><span class="sr-only">Add a filter</span> <select class="text-gray-600"><option selected="">Add a filter</option><!></select></label></div>`);function Za(e,t){qe(t,!0);let n=ta(t,`dataset`,7),r=j(()=>n().filters?.length?!0:n().belongs_to?Object.values(n().belongs_to).some(e=>e.filters?.length):!1),i=e=>{if(!ja(n()))return;let{field:t,datasetType:r,fieldSchema:i,association:a}=Fa(n(),e.currentTarget.value),o=n();a===`belongs_to`&&(n().belongs_to??={},n().belongs_to[r]??={},o=n().belongs_to[r]),i&&(o.filters??=[],o.filters.push({field:t,operator:`=`,value:Pa(i)}),e.currentTarget.value=``)},a=(e,r)=>{if(!ja(n()))return;let i=n();if(r!==null){if(!n().belongs_to?.[r])return;i=n().belongs_to[r]}Array.isArray(i.filters)&&(i.filters.length===1?(delete i.filters,r!==null&&t.pruneBelongsTo()):i.filters.splice(e,1))};var o=Xa(),s=L(F(o),2),c=e=>{var t=Ja(),r=F(t);q(r,17,()=>n().filters??[],ei,(e,t,r)=>{Ka(e,{get dataset(){return n()},get datasetType(){return n().type},get filter(){return V(t)},index:r,removeFilter:()=>a(r,null)})});var i=L(r,2),o=e=>{var t=Kr();q(I(t),17,()=>Object.entries(n().belongs_to),([e,t])=>e,(e,t)=>{var n=j(()=>h(V(t),2));let r=()=>V(n)[0],i=()=>V(n)[1];var o=Kr(),s=I(o),c=e=>{var t=qa(),n=I(t),o=F(n,!0);A(n),q(L(n,2),17,()=>i().filters,ei,(e,t,n)=>{Ka(e,{get dataset(){return i()},get datasetType(){return r()},get filter(){return V(t)},index:n,removeFilter:()=>a(n,r())})}),R(e=>G(o,e),[()=>La(r())]),W(e,t)};K(s,e=>{i().filters?.length&&e(c)}),W(e,o)}),W(e,t)};K(i,e=>{n().belongs_to&&e(o)}),A(t),W(e,t)};K(s,e=>{V(r)&&e(c)});var l=L(s,2),u=L(F(l),2),d=F(u);d.value=d.__value=``,q(L(d),17,()=>t.filterFields,ei,(e,t)=>{var n=Ya(),r=F(n,!0);A(n);var i={};R(()=>{G(r,V(t).label),i!==(i=V(t).value)&&(n.value=(n.__value=V(t).value)??``)}),W(e,n)}),A(u),A(l),A(o),R(()=>bi(l,1,V(r)?`mt-4`:``)),H(`change`,u,i),W(e,o),Je()}Ir([`change`]);var Qa=U(`<div class="flex items-center gap-1 pill pr-0.5"><div class="font-medium"><!> </div> <button type="button" class="unstyled text-night-800 hover:text-black hover:bg-night-50 p-1 cursor-pointer"><!></button></div>`),$a=U(`<div class="flex flex-wrap gap-2"></div>`),eo=U(`<option> </option>`),to=U(`<div class="border-l-2 border-ice-700 pl-4 mt-4 py-0.5 flex flex-col gap-3"><p class="text-sm font-medium text-ice-700">Selected fields</p> <p class="text-xs text-grey-600">If no fields are selected, all fields in the dataset will be returned</p> <!> <label><span class="sr-only">Add a select</span> <select class="text-gray-600"><option selected="">Add a select</option><!></select></label></div>`);function no(e,t){qe(t,!0);let n=ta(t,`dataset`,7),r=e=>{if(!ja(n()))return;let t=e.currentTarget.value;n().selects??=[],n().selects.push(t);let{datasetType:r,association:i}=Fa(n(),t);i===`belongs_to`&&(n().belongs_to??={},n().belongs_to[r]??={}),e.currentTarget.value=``},i=e=>{if(!(!ja(n())||!Array.isArray(n().selects))){if(n().selects.length===1)delete n().selects;else{let t=n().selects.indexOf(e);n().selects.splice(t,1)}e.includes(`.`)&&t.pruneBelongsTo()}};var a=to(),o=L(F(a),4),s=e=>{var t=$a();q(t,21,()=>n().selects,ei,(e,t)=>{let r=j(()=>{let{association:e,field:r,fieldSchema:i,datasetType:a}=Fa(n(),V(t));return{association:e,field:r,fieldSchema:i,datasetType:a}});var a=Qa(),o=F(a),s=F(o),c=e=>{var t=Gr();R(e=>G(t,`${e??``}:`),[()=>La(V(r).datasetType)]),W(e,t)};K(s,e=>{V(r).association===`belongs_to`&&e(c)});var l=L(s);A(o);var u=L(o,2);aa(F(u),{size:`16`,name:`delete`}),A(u),A(a),R(e=>G(l,` ${e??``}`),[()=>V(r).fieldSchema?.label??Ta(V(r).field)]),H(`click`,u,()=>i(V(t))),W(e,a)}),A(t),W(e,t)},c=j(()=>Array.isArray(n().selects));K(o,e=>{V(c)&&e(s)});var l=L(o,2),u=L(F(l),2),d=F(u);d.value=d.__value=``,q(L(d),17,()=>t.selectFields,ei,(e,t)=>{var r=Kr(),i=I(r),a=e=>{var n=eo(),r=F(n,!0);A(n);var i={};R(()=>{G(r,V(t).label),i!==(i=V(t).value)&&(n.value=(n.__value=V(t).value)??``)}),W(e,n)},o=j(()=>!Array.isArray(n().selects)||!n().selects.includes(V(t).value));K(i,e=>{V(o)&&e(a)}),W(e,r)}),A(u),A(l),A(a),H(`change`,u,r),W(e,a),Je()}Ir([`click`,`change`]);var ro=U(`<div class="flex items-center gap-1 pill pr-0.5"><div class="font-medium"> </div> <button type="button" class="unstyled text-night-800 hover:text-black hover:bg-night-50 p-1 cursor-pointer"><!></button></div>`),io=U(`<div class="flex flex-wrap gap-2"></div>`),ao=U(`<p class="text-sm font-medium text-ice-600"> </p> <div class="flex flex-wrap gap-2 -mt-2"></div>`,1),oo=U(`<option> </option>`),so=U(`<div class="border-l-2 border-ice-700 pl-4 mt-4 py-0.5 flex flex-col gap-3"><p class="text-sm font-medium text-ice-700">Splits</p> <p class="-mt-2 text-xs text-grey-600">Shows a separate chart series for each unique value of the given fields</p> <!> <!> <label><span class="sr-only">Add a split</span> <select class="text-gray-600"><option selected="">Add a split</option><!></select></label></div>`);function co(e,t){qe(t,!0);let n=ta(t,`dataset`,7),r=e=>{if(!ja(n()))return;let{datasetType:t,field:r,association:i}=Fa(n(),e.currentTarget.value),a;i===`belongs_to`?(n().belongs_to??={},n().belongs_to[t]??={},a=n().belongs_to[t]):a=n(),a&&(a.split_by??=[],a.split_by.push(r),e.currentTarget.value=``)},i=(e,r)=>{if(!ja(n()))return;let i=n();if(r!==null){if(!n().belongs_to?.[r])return;i=n().belongs_to[r]}if(Array.isArray(i.split_by)){if(i.split_by.length===1)delete i.split_by,r!==null&&t.pruneBelongsTo();else{let t=i.split_by.indexOf(e);i.split_by.splice(t,1)}}};var a=so();{let e=(e,t=d,r)=>{let a=Et(()=>m(r?.(),null));var o=ro(),s=F(o),c=F(s,!0);A(s);var l=L(s,2);aa(F(l),{size:`16`,name:`delete`}),A(l),A(o),R(e=>G(c,e),[()=>Ra(t(),V(a)??n().type)]),H(`click`,l,()=>i(t(),V(a))),W(e,o)};var o=L(F(a),4),s=t=>{var r=io();q(r,21,()=>n().split_by,ei,(t,n)=>{e(t,()=>V(n))}),A(r),W(t,r)},c=j(()=>Array.isArray(n().split_by));K(o,e=>{V(c)&&e(s)});var l=L(o,2),u=t=>{var r=Kr();q(I(r),17,()=>Object.entries(n().belongs_to),([e,t])=>e,(t,n)=>{var r=j(()=>h(V(n),2));let i=()=>V(r)[0],a=()=>V(r)[1];var o=Kr(),s=I(o),c=t=>{var n=ao(),r=I(n),o=F(r,!0);A(r);var s=L(r,2);q(s,21,()=>a().split_by,ei,(t,n)=>{e(t,()=>V(n),i)}),A(s),R(e=>G(o,e),[()=>La(i())]),W(t,n)},l=j(()=>Array.isArray(a().split_by)&&a().split_by.length>0);K(s,e=>{V(l)&&e(c)}),W(t,o)}),W(t,r)};K(l,e=>{n().belongs_to&&e(u)});var f=L(l,2),p=L(F(f),2),g=F(p);g.value=g.__value=``,q(L(g),17,()=>t.splitFields,ei,(e,t)=>{var r=Kr(),i=I(r),a=e=>{var n=oo(),r=F(n,!0);A(n);var i={};R(()=>{G(r,V(t).label),i!==(i=V(t).value)&&(n.value=(n.__value=V(t).value)??``)}),W(e,n)},o=j(()=>!Array.isArray(n().split_by)||!n().split_by.includes(V(t).value));K(i,e=>{V(o)&&e(a)}),W(e,r)}),A(p),A(f),A(a),H(`change`,p,r)}W(e,a),Je()}Ir([`click`,`change`]);var lo=U(`<span class="capitalize"> </span> `,1),uo=U(`<p class="text-sm font-semibold text-night-700 group-hover:text-night-800"><!></p>`),fo=U(`<option> </option>`),po=U(`<label>Count by <select></select></label>`),mo=U(`<div class="sm:grid grid-cols-[auto_1fr] gap-4 sm:gap-12"><!> <!></div> <!>`,1),ho=U(`<!> <!>`,1),go=U(`<span class="help-text">Note: your query must return three columns: <code>date</code>, <code>split</code>, and <code>count</code>. <code>split</code> can be <code>NULL</code></span>`),_o=U(`<label><span class="text-sm font-medium"> </span> <span class="ml-3 text-gray-500 text-xs font-normal">required?</span> <!></label>`),vo=U(`<div class="mt-4 flex flex-wrap gap-y-2 gap-x-4"><p class="text-sm font-medium text-ice-700 mb-0.5 basis-full">Linked tables</p> <!></div>`),yo=U(`<button type="button" class="sm">Duplicate</button>`),bo=U(`<button type="button" class="sm px-1"><!></button>`),xo=U(`<button type="button" class="sm bg-dawn-100 ml-auto">Yes, delete this dataset</button>`),So=U(`<button type="button" class="sm bg-dawn-100 ml-auto">Delete</button>`),Co=U(`<label>Label <input type="text"/> <span class="help-text">Splits can be incorporated into the label using <code>%1</code>, <code>%2</code>, etc. or with a default value if empty using <code>%1(none)</code></span></label> <div class="sm:grid grid-cols-2 gap-x-2 gap-y-4"><label class="only:col-span-2">Type <select></select></label> <!></div> <!> <!> <div class="flex flex-row gap-2 mt-4"><!> <!> <!> <!></div>`,1);function wo(e,t){qe(t,!0);let n=ta(t,`dataset`,7),r=ta(t,`startOpen`,3,!1),i=j(()=>ka(n())?[``,...t.chartConfig.datasets.filter(e=>!(e.type===`percentage`||ja(e)&&e.split_by)).map(e=>({value:e.id,label:e.label}))]:[]),a=j(()=>[...Object.keys(wa),...t.chartConfig.type===`table`?[]:[`percentage`],`sql`]),o=j(()=>wa[n().type]),s=j(()=>{if(!V(o))return{filter:[],select:[],split:[]};let e=wa[n().type]?.fields??{},t=[],r=[],i=[];for(let[n,a]of Object.entries(e)){let e={label:a.label??Ta(n),value:n};a.filter&&t.push(e),a.select&&r.push(e),a.split&&i.push(e)}if(Array.isArray(V(o).belongs_to))for(let e of V(o).belongs_to){let n=wa[e];if(n?.fields)for(let[a,o]of Object.entries(n.fields)){let s={label:`${n.label??Ta(e)}: ${o.label??Ta(a)}`,value:`${e}.${a}`};o.filter&&t.push(s),o.select&&r.push(s),o.split&&i.push(s)}}return{filter:t,select:r,split:i}}),c=j(()=>{if(!ja(n())||t.chartConfig.type===`table`||!V(o))return[];let e=[{label:V(o).counts?.[n().type]?.label??Ta(n().type),value:n().type}];for(let[t,r]of Object.entries(V(o).counts??{}))t!==n().type&&e.push({label:r.label??Ta(t),value:t});if(Array.isArray(V(o).belongs_to))for(let t of V(o).belongs_to){let n=wa[t];e.push({label:n?.counts?.[t]?.label??Ta(t),value:t});for(let[r,i]of Object.entries(n?.counts??{}))r!==t&&e.push({label:i.label??Ta(r),value:r})}return e}),l=N(!1),u=e=>{let r=e.currentTarget.value;if(r===n().type||t.chartConfig.type===`table`&&n().type===`percentage`)return;let i=n().type;n().type=r;let a=[`id`,`type`,`label`,`visible`,`axis`];ja(n())&&(a.push(`filters`,`belongs_to`),t.chartConfig.type===`table`?a.push(`selects`):a.push(`count_by`,`split_by`));for(let e of Object.keys(n()))a.includes(e)||delete n()[e];if(ja(n())){if(Array.isArray(n().filters))for(let e=0;e<n().filters.length;e++)(!V(o)||!Ia(V(o),n().filters[e]))&&(n().filters.splice(e,1),e--);if(n().count_by&&(n().count_by===i?n().count_by=n().type:V(c).find(e=>e.value===n().count_by)||(n().count_by=n().type)),n().selects){for(let e=0;e<n().selects.length;e++){let t=n().selects[e];if(t.includes(`.`)){let[i,a]=t.split(`.`,2);if(i===r&&!n().selects.includes(a)){n().selects[e]=a;continue}if(i&&V(o)?.belongs_to?.includes(i))continue}else if(V(o)?.fields[t]?.select)continue;n().selects.splice(e,1),e--}n().selects.length===0&&delete n().selects}if(n().split_by){for(let e=0;e<n().split_by.length;e++){let t=n().split_by[e];V(o)?.fields[t]?.split||(n().split_by.splice(e,1),e--)}n().split_by.length===0&&delete n().split_by}if(n().belongs_to?.[r]){if(Array.isArray(n().belongs_to[r].filters)){n().filters??=[];for(let e of n().belongs_to[r].filters)n().filters.find(t=>t.field===e.field&&t.operator===e.operator&&t.value===e.value)||n().filters.push(e)}if(Array.isArray(n().belongs_to[r].split_by)){n().split_by??=[];for(let e of n().belongs_to[r].split_by)n().split_by.includes(e)||n().split_by.push(e)}delete n().belongs_to[r]}m()}Aa(n())&&(n().sql=`SELECT
30
+ "><!></button>`),ua=U(`<p> </p>`),da=U(`<div class="relative w-max"><input type="date"/> <!></div>`),fa=U(`<div class="relative w-max"><input type="number"/> <!></div>`),pa=U(`<option> </option>`),ma=U(`<!>`,1),ha=U(`<select><!></select>`),ga=U(`<div class="flex items-center gap-2 font-normal"> <!> </div>`),_a=U(`<div class="relative flex w-max"><input type="text"/> <!></div>`),va=U(`<textarea></textarea>`),ya=U(`<span class="help-text mb-1"> </span>`),ba=U(`<label><!> <!> <!></label>`);function xa(e,t){qe(t,!0);let n=e=>{var t=Kr(),n=I(t),r=e=>{var t=la();aa(F(t),{name:`clear`}),A(t),H(`click`,t,E),W(e,t)};K(n,e=>{V(_)&&e(r)}),W(e,t)},r=ta(t,`type`,3,`text`),i=ta(t,`model`,7),a=ta(t,`description`,3,null),o=ta(t,`selectOptions`,3,null),s=ta(t,`leftValue`,3,null),c=ta(t,`rightValue`,3,null),l=ta(t,`switchIndeterminate`,3,!1),u=ta(t,`allowEmpty`,3,!1),f=ta(t,`showClear`,3,!0),p=ta(t,`trimOnBlur`,3,!1),m=ta(t,`class`,3,``),h=ea(t,ca),g=j(()=>l()&&i()[t.key]!==c()&&i()[t.key]!==s()?null:i()[t.key]===c()||c()===null&&i()[t.key]===void 0),_=j(()=>f()&&i()[t.key]),v=j(()=>[`date`,`number`,`text`,`textarea`,`contenteditable`].includes(r())?1e3:250),y,b=null,x=()=>{b!==null&&b!==``||u()?i()[t.key]=b:delete i()[t.key]},S=e=>{if(r()===`contenteditable`)b=e.currentTarget.innerText;else if(r()===`number`){let t=e.currentTarget.value.trim();b=t.match(/^-?\d*\.?\d+$/)?Number.parseFloat(t):null}else b=e.currentTarget.value;y&&clearTimeout(y),y=setTimeout(x,V(v))},C=()=>{V(g)?s()===null?delete i()[t.key]:i()[t.key]=s():V(g)===null?i()[t.key]=c():l()||c()===null?delete i()[t.key]:i()[t.key]=c()},w=()=>{y&&(clearTimeout(y),x()),p()&&typeof i()[t.key]==`string`&&(i()[t.key]=i()[t.key].trim())},T=(e,t)=>(e.innerText=t??``,{update(t){document.activeElement!==e&&(e.innerText=t??``)}}),E=()=>{y&&clearTimeout(y),(r()===`text`||r()===`string`)&&u()?i()[t.key]=``:delete i()[t.key]};var D=ba(),ee=F(D);li(ee,()=>t.children);var te=L(ee,2),ne=e=>{var n=ua();Vi(n,()=>({contenteditable:!0,onblur:w,oninput:S,class:`mt-1 whitespace-pre-wrap`,...h}));var r=F(n,!0);A(n),ui(n,(e,t)=>T?.(e,t),()=>i()[t.key]),R(()=>G(r,i()[t.key])),W(e,n)},re=e=>{var r=da(),a=F(r);Fi(a);var o=L(a,2);n(o),A(r),R(()=>{Ii(a,i()[t.key]),bi(a,1,`w-max ${V(_)?`pr-8`:``}`)}),Fr(`blur`,a,w),H(`input`,a,S),W(e,r)},ie=e=>{var r=fa(),a=F(r);Fi(a);var o=L(a,2);n(o),A(r),R(()=>{Ii(a,i()[t.key]),bi(a,1,V(_)?`pr-8`:``)}),Fr(`blur`,a,w),H(`input`,a,S),W(e,r)},ae=e=>{var n=ha();qi(n,()=>{var e=F(n),t=ma(),r=I(t),i=e=>{var t=Kr();q(I(t),17,o,ei,(e,t)=>{var n=Kr(),r=I(n),i=e=>{var n=pa(),r=F(n,!0);A(n);var i={};R(()=>{G(r,V(t)),i!==(i=V(t))&&(n.__value=V(t))}),W(e,n)},a=e=>{var n=pa(),r=F(n,!0);A(n);var i={};R(()=>{G(r,V(t).label??V(t).value),i!==(i=V(t).value)&&(n.value=(n.__value=V(t).value)??``)}),W(e,n)};K(r,e=>{typeof V(t)==`string`?e(i):e(a,-1)}),W(e,n)}),W(e,t)},a=j(()=>Array.isArray(o())),s=e=>{var t=Kr();li(I(t),()=>o()??d),W(e,t)};K(r,e=>{V(a)?e(i):e(s,-1)}),W(e,t)});var r;wi(n),R(()=>{r!==(r=i()[t.key]??``)&&(n.value=(n.__value=i()[t.key]??``)??``,Ci(n,i()[t.key]??``))}),Fr(`blur`,n,w),H(`input`,n,S),W(e,n)},oe=e=>{var n=ga(),r=F(n),i=L(r);{let e=j(()=>t.leftLabel?``:void 0),n=j(()=>t.rightLabel?``:void 0);sa(i,{get value(){return V(g)},onToggle:C,get labelOff(){return V(e)},get labelOn(){return V(n)}})}var a=L(i);A(n),R(()=>{G(r,`${t.leftLabel??``} `),G(a,` ${t.rightLabel??``}`)}),W(e,n)},se=e=>{var r=_a(),a=F(r);Fi(a);var o=L(a,2);n(o),A(r),R(()=>{Ii(a,i()[t.key]),bi(a,1,`grow ${V(_)?`pr-8`:``}`)}),Fr(`blur`,a,w),H(`input`,a,S),W(e,r)},ce=e=>{var n=va();ut(n),Vi(n,()=>({onblur:w,oninput:S,...h,value:i()[t.key]})),W(e,n)};K(te,e=>{r()===`contenteditable`?e(ne):r()===`date`?e(re,1):r()===`number`?e(ie,2):r()===`select`?e(ae,3):r()===`switch`?e(oe,4):r()===`string`||r()===`text`?e(se,5):r()===`textarea`&&e(ce,6)});var le=L(te,2),ue=e=>{var t=ya(),n=F(t,!0);A(t),R(()=>G(n,a())),W(e,t)},de=e=>{var t=Kr();li(I(t),()=>a()??d),W(e,t)};K(le,e=>{typeof a()==`string`?e(ue):e(de,-1)}),A(D),R(()=>bi(D,1,mi(m()))),W(e,D),Je()}Ir([`click`,`input`]);var Sa=U(`<div class="fixed bottom-2 right-2 z-10 p-1 bg-ice-50 border border-ice-100 text-ice-700"><p class="text-sm font-medium">Saving your changes...</p></div>`),Ca=U(`<div class="fixed bottom-2 right-2 z-10 p-2 bg-dawn-50 border border-dawn-100 text-dawn-700"><p>Something went wrong when trying to save the dashboard. Retrying in 10 seconds...</p></div>`),wa=U(`<div role="alert" class="fixed bottom-2 right-2 z-10 p-2 max-w-md flex flex-col gap-2 bg-dawn-50 border border-dawn-100 text-dawn-700"><p>Someone else has changed this dashboard. <a class="underline hover:no-underline">Reload</a> to see their changes. Your recent changes have not been saved.</p></div>`);function Ta(e,t){var n=Kr(),r=I(n),i=e=>{W(e,Sa())},a=e=>{W(e,Ca())},o=e=>{var t=wa(),n=F(t);zi(L(F(n)),`href`,window.location.href),Ie(),A(n),A(t),W(e,t)};K(r,e=>{t.status===`pending`||t.status===`saving`?e(i):t.status===`error`?e(a,1):t.status===`conflict`&&e(o,2)}),W(e,n)}var Ea=U(`<div><button type="button" class="group w-full flex items-center unstyled cursor-pointer py-0.5"><!> <!></button> <div class="contents"><div><div class="flex flex-col gap-3 px-0.5 pb-2 mt-2 overflow-hidden"><!></div></div></div></div>`);function Da(e,t){qe(t,!0);let n=ta(t,`startOpen`,3,!1),r=ta(t,`wrapperClass`,3,`border-night-700`),i=N(on(br(()=>n())));function a(){P(i,!1)}let o=()=>{P(i,!V(i))};var s={close:a},c=Ea(),l=F(c),u=F(l);li(u,()=>t.title,()=>V(i));var d=L(u,2);{let e=j(()=>V(i)?`chevron_up`:`chevron_down`);aa(d,{get name(){return V(e)},size:24,class:`text-ice-800 group-hover:text-black ml-auto`})}A(l);var f=L(l,2),p=F(f),m=F(p);return li(F(m),()=>t.children),A(m),A(p),A(f),A(c),R(()=>{bi(c,1,`border-l-4 ${r()??``} pl-4 py-0.5`),bi(p,1,`grid transition-[grid-template-rows] ease-in-out overflow-hidden ${V(i)?`grid-rows-[1fr]`:`grid-rows-[0fr]`}`)}),H(`click`,l,o),W(e,c),Je(s)}Ir([`click`]);var Oa=JSON.parse(document.querySelector(`[data-dashboard-config]`)?.dataset?.datasetSchema),ka=e=>e.replace(/_/g,` `).replace(/^[a-z]/,e=>e.toLocaleUpperCase()).replace(/\bSql\b/g,`SQL`).replace(/\bUtm\b/g,`UTM`),Aa={"01":`January`,"02":`February`,"03":`March`,"04":`April`,"05":`May`,"06":`June`,"07":`July`,"08":`August`,"09":`September`,10:`October`,11:`November`,12:`December`},ja={"01":`Jan`,"02":`Feb`,"03":`Mar`,"04":`Apr`,"05":`May`,"06":`Jun`,"07":`Jul`,"08":`Aug`,"09":`Sep`,10:`Oct`,11:`Nov`,12:`Dec`},Ma=(e,t)=>{if(typeof e!=`string`||!e.match(/^\d{4}-\d{2}-\d{2}/))return`${e}`;let[n,r,i]=e.substring(0,10).split(`-`,3);if(!n||!r||!i)return e;switch(t){case`month`:return`${Aa[r]} ${n}`;case`week`:return`w/c ${+i} ${ja[r]} ${n.substring(2,4)}`;case`day`:return`${+i} ${ja[r]} ${n.substring(2,4)}`}},Na=e=>e.type===`percentage`,Pa=e=>e.type===`sql`,Fa=e=>!Na(e)&&!Pa(e),Ia=e=>e.operator===`empty`||e.operator===`not empty`,La={boolean:!0,date:new Date().toISOString().substring(0,10),number:0,one_of:``,string:``},Ra=e=>{if(e.type===`one_of`&&e.options){let t=e.options[0];return typeof t==`string`?t:t?.value??``}return La[e.type??`string`]},za=(e,t)=>{if(!t.includes(`.`))return{datasetType:e.type,targetSchema:Oa[e.type],field:t,fieldSchema:Oa[e.type]?.fields?.[t]};let[n,r]=t.split(`.`,2);return{datasetType:n,targetSchema:Oa[n],field:r,fieldSchema:Oa[n]?.fields?.[r],association:`belongs_to`}},Ba=(e,t)=>{if(!e?.fields?.[t.field]?.filter)return!1;let n=e.fields[t.field];if(!n||!Wa(n).includes(t.operator))return!1;if(Ia(t))return!(`value`in t);let r=n.type??`string`;switch(r){case`one_of`:return n.options?.some(e=>typeof e==`string`?e===t.value:e.value===t.value);case`date`:return typeof t.value==`string`&&t.value.match(/^\d{4}-[01]\d-[0-3]\d$/);default:return typeof t.value===r}},Va=e=>Oa[e]?.label??ka(e),Ha=(e,t)=>Oa[t??``]?.fields?.[e]?.label??ka(e),Ua={boolean:[`=`,`!=`,`empty`,`not empty`],date:[`=`,`!=`,`>`,`>=`,`<=`,`<`,`empty`,`not empty`],number:[`=`,`!=`,`>`,`>=`,`<=`,`<`,`empty`,`not empty`],one_of:[`=`,`!=`,`empty`,`not empty`],string:[`=`,`!=`,`like`,`not like`,`empty`,`not empty`]},Wa=e=>Ua[e?.type??`string`],Ga=(e,t)=>{let n=Oa[e];return t===e||n?.counts?.[t]||n?.belongs_to?.includes(t)?e:n?.belongs_to?.find(e=>!!Oa[e]?.counts?.[t])},Ka=U(`<option> </option>`),qa=U(`<span class="sr-only"> </span>`),Ja=U(`<p class="help-text -mt-1 mb-1 col-span-4"> </p>`),Ya=U(`<span> </span> <label><span class="sr-only">operator</span> <select></select></label> <!> <button type="button" class="unstyled text-night-800 hover:text-black hover:bg-night-50 p-2 cursor-pointer"><!></button> <!>`,1);function Xa(e,t){qe(t,!0);let n=j(()=>Oa[t.datasetType]?.fields?.[t.filter.field]),r=(e,r)=>{if(!t.dataset.filters)return;let i=r.currentTarget.value,a=t.dataset.filters[e],o=Ia(a);a.operator=i,Ia(a)?delete a.value:(o||a.value===void 0)&&(a.value=V(n)?Ra(V(n)):``)};var i=Ya(),a=I(i),o=F(a);A(a);var s=L(a,2),c=L(F(s),2);q(c,21,()=>Wa(V(n)),ei,(e,t)=>{var n=Ka(),r=F(n,!0);A(n);var i={};R(()=>{G(r,V(t)),i!==(i=V(t))&&(n.__value=V(t))}),W(e,n)}),A(c);var l;wi(c),A(s);var u=L(s,2),d=e=>{var r=Kr(),i=I(r),a=e=>{{let r=j(()=>V(n).leftValue!==void 0&&V(n).leftValue),i=j(()=>V(n).rightValue===void 0||V(n).rightValue);xa(e,{type:`switch`,get model(){return t.filter},get leftLabel(){return V(n).leftLabel},get leftValue(){return V(r)},get rightLabel(){return V(n).rightLabel},get rightValue(){return V(i)},key:`value`,class:`ml-1`,children:(e,n)=>{var r=qa(),i=F(r);A(r),R(e=>G(i,`${e??``} value`),[()=>Ha(t.filter.field,t.datasetType)]),W(e,r)},$$slots:{default:!0}})}},o=e=>{xa(e,{type:`select`,get model(){return t.filter},key:`value`,get selectOptions(){return V(n).options},class:`w-max`,allowEmpty:!0,children:(e,n)=>{var r=qa(),i=F(r);A(r),R(e=>G(i,`${e??``} value`),[()=>Ha(t.filter.field,t.datasetType)]),W(e,r)},$$slots:{default:!0}})},s=e=>{{let r=j(()=>V(n)?.type??`string`),i=j(()=>!V(n)?.type||V(n)?.type===`string`);xa(e,{get type(){return V(r)},get model(){return t.filter},key:`value`,class:`w-full`,allowEmpty:!0,get showClear(){return V(i)},children:(e,n)=>{var r=qa(),i=F(r);A(r),R(e=>G(i,`${e??``} value`),[()=>Ha(t.filter.field,t.datasetType)]),W(e,r)},$$slots:{default:!0}})}};K(i,e=>{V(n)?.type===`boolean`?e(a):V(n)?.type===`one_of`?e(o,1):e(s,-1)}),W(e,r)},f=j(()=>!Ia(t.filter));K(u,e=>{V(f)&&e(d)});var p=L(u,2);aa(F(p),{name:`delete`}),A(p);var m=L(p,2),h=e=>{var t=Ja(),r=F(t,!0);A(t),R(()=>G(r,V(n).description)),W(e,t)};K(m,e=>{V(n)?.description&&e(h)}),R((e,n)=>{G(o,`${e??``}:`),bi(s,1,`h-full ${n??``}`),l!==(l=t.filter.operator)&&(c.value=(c.__value=t.filter.operator)??``,Ci(c,t.filter.operator))},[()=>Ha(t.filter.field,t.datasetType),()=>Ia(t.filter)?`col-span-2 w-max`:``]),H(`change`,c,e=>r(t.index,e)),H(`click`,p,function(...e){t.removeFilter?.apply(this,e)}),W(e,i),Je()}Ir([`change`,`click`]);var Za=U(`<p class="text-sm font-medium text-ice-600 mt-2 col-span-4"> </p> <!>`,1),Qa=U(`<div class="grid grid-cols-[auto_4rem_1fr_auto] gap-1 items-center"><!> <!></div>`),$a=U(`<option> </option>`),eo=U(`<div class="border-l-2 border-ice-700 pl-4 mt-4 py-0.5 flex flex-col gap-3"><p class="text-sm font-medium text-ice-700">Filters</p> <!> <label><span class="sr-only">Add a filter</span> <select class="text-gray-600"><option selected="">Add a filter</option><!></select></label></div>`);function to(e,t){qe(t,!0);let n=ta(t,`dataset`,7),r=j(()=>n().filters?.length?!0:n().belongs_to?Object.values(n().belongs_to).some(e=>e.filters?.length):!1),i=e=>{if(!Fa(n()))return;let{field:t,datasetType:r,fieldSchema:i,association:a}=za(n(),e.currentTarget.value),o=n();a===`belongs_to`&&(n().belongs_to??={},n().belongs_to[r]??={},o=n().belongs_to[r]),i&&(o.filters??=[],o.filters.push({field:t,operator:`=`,value:Ra(i)}),e.currentTarget.value=``)},a=(e,r)=>{if(!Fa(n()))return;let i=n();if(r!==null){if(!n().belongs_to?.[r])return;i=n().belongs_to[r]}Array.isArray(i.filters)&&(i.filters.length===1?(delete i.filters,r!==null&&t.pruneBelongsTo()):i.filters.splice(e,1))};var o=eo(),s=L(F(o),2),c=e=>{var t=Qa(),r=F(t);q(r,17,()=>n().filters??[],ei,(e,t,r)=>{Xa(e,{get dataset(){return n()},get datasetType(){return n().type},get filter(){return V(t)},index:r,removeFilter:()=>a(r,null)})});var i=L(r,2),o=e=>{var t=Kr();q(I(t),17,()=>Object.entries(n().belongs_to),([e,t])=>e,(e,t)=>{var n=j(()=>h(V(t),2));let r=()=>V(n)[0],i=()=>V(n)[1];var o=Kr(),s=I(o),c=e=>{var t=Za(),n=I(t),o=F(n,!0);A(n),q(L(n,2),17,()=>i().filters,ei,(e,t,n)=>{Xa(e,{get dataset(){return i()},get datasetType(){return r()},get filter(){return V(t)},index:n,removeFilter:()=>a(n,r())})}),R(e=>G(o,e),[()=>Va(r())]),W(e,t)};K(s,e=>{i().filters?.length&&e(c)}),W(e,o)}),W(e,t)};K(i,e=>{n().belongs_to&&e(o)}),A(t),W(e,t)};K(s,e=>{V(r)&&e(c)});var l=L(s,2),u=L(F(l),2),d=F(u);d.value=d.__value=``,q(L(d),17,()=>t.filterFields,ei,(e,t)=>{var n=$a(),r=F(n,!0);A(n);var i={};R(()=>{G(r,V(t).label),i!==(i=V(t).value)&&(n.value=(n.__value=V(t).value)??``)}),W(e,n)}),A(u),A(l),A(o),R(()=>bi(l,1,V(r)?`mt-4`:``)),H(`change`,u,i),W(e,o),Je()}Ir([`change`]);var no=U(`<div class="flex items-center gap-1 pill pr-0.5"><div class="font-medium"><!> </div> <button type="button" class="unstyled text-night-800 hover:text-black hover:bg-night-50 p-1 cursor-pointer"><!></button></div>`),ro=U(`<div class="flex flex-wrap gap-2"></div>`),io=U(`<option> </option>`),ao=U(`<div class="border-l-2 border-ice-700 pl-4 mt-4 py-0.5 flex flex-col gap-3"><p class="text-sm font-medium text-ice-700">Selected fields</p> <p class="text-xs text-grey-600">If no fields are selected, all fields in the dataset will be returned</p> <!> <label><span class="sr-only">Add a select</span> <select class="text-gray-600"><option selected="">Add a select</option><!></select></label></div>`);function oo(e,t){qe(t,!0);let n=ta(t,`dataset`,7),r=e=>{if(!Fa(n()))return;let t=e.currentTarget.value;n().selects??=[],n().selects.push(t);let{datasetType:r,association:i}=za(n(),t);i===`belongs_to`&&(n().belongs_to??={},n().belongs_to[r]??={}),e.currentTarget.value=``},i=e=>{if(!(!Fa(n())||!Array.isArray(n().selects))){if(n().selects.length===1)delete n().selects;else{let t=n().selects.indexOf(e);n().selects.splice(t,1)}e.includes(`.`)&&t.pruneBelongsTo()}};var a=ao(),o=L(F(a),4),s=e=>{var t=ro();q(t,21,()=>n().selects,ei,(e,t)=>{let r=j(()=>{let{association:e,field:r,fieldSchema:i,datasetType:a}=za(n(),V(t));return{association:e,field:r,fieldSchema:i,datasetType:a}});var a=no(),o=F(a),s=F(o),c=e=>{var t=Gr();R(e=>G(t,`${e??``}:`),[()=>Va(V(r).datasetType)]),W(e,t)};K(s,e=>{V(r).association===`belongs_to`&&e(c)});var l=L(s);A(o);var u=L(o,2);aa(F(u),{size:`16`,name:`delete`}),A(u),A(a),R(e=>G(l,` ${e??``}`),[()=>V(r).fieldSchema?.label??ka(V(r).field)]),H(`click`,u,()=>i(V(t))),W(e,a)}),A(t),W(e,t)},c=j(()=>Array.isArray(n().selects));K(o,e=>{V(c)&&e(s)});var l=L(o,2),u=L(F(l),2),d=F(u);d.value=d.__value=``,q(L(d),17,()=>t.selectFields,ei,(e,t)=>{var r=Kr(),i=I(r),a=e=>{var n=io(),r=F(n,!0);A(n);var i={};R(()=>{G(r,V(t).label),i!==(i=V(t).value)&&(n.value=(n.__value=V(t).value)??``)}),W(e,n)},o=j(()=>!Array.isArray(n().selects)||!n().selects.includes(V(t).value));K(i,e=>{V(o)&&e(a)}),W(e,r)}),A(u),A(l),A(a),H(`change`,u,r),W(e,a),Je()}Ir([`click`,`change`]);var so=U(`<div class="flex items-center gap-1 pill pr-0.5"><div class="font-medium"> </div> <button type="button" class="unstyled text-night-800 hover:text-black hover:bg-night-50 p-1 cursor-pointer"><!></button></div>`),co=U(`<div class="flex flex-wrap gap-2"></div>`),lo=U(`<p class="text-sm font-medium text-ice-600"> </p> <div class="flex flex-wrap gap-2 -mt-2"></div>`,1),uo=U(`<option> </option>`),fo=U(`<div class="border-l-2 border-ice-700 pl-4 mt-4 py-0.5 flex flex-col gap-3"><p class="text-sm font-medium text-ice-700">Splits</p> <p class="-mt-2 text-xs text-grey-600">Shows a separate chart series for each unique value of the given fields</p> <!> <!> <label><span class="sr-only">Add a split</span> <select class="text-gray-600"><option selected="">Add a split</option><!></select></label></div>`);function po(e,t){qe(t,!0);let n=ta(t,`dataset`,7),r=e=>{if(!Fa(n()))return;let{datasetType:t,field:r,association:i}=za(n(),e.currentTarget.value),a;i===`belongs_to`?(n().belongs_to??={},n().belongs_to[t]??={},a=n().belongs_to[t]):a=n(),a&&(a.split_by??=[],a.split_by.push(r),e.currentTarget.value=``)},i=(e,r)=>{if(!Fa(n()))return;let i=n();if(r!==null){if(!n().belongs_to?.[r])return;i=n().belongs_to[r]}if(Array.isArray(i.split_by)){if(i.split_by.length===1)delete i.split_by,r!==null&&t.pruneBelongsTo();else{let t=i.split_by.indexOf(e);i.split_by.splice(t,1)}}};var a=fo();{let e=(e,t=d,r)=>{let a=Et(()=>m(r?.(),null));var o=so(),s=F(o),c=F(s,!0);A(s);var l=L(s,2);aa(F(l),{size:`16`,name:`delete`}),A(l),A(o),R(e=>G(c,e),[()=>Ha(t(),V(a)??n().type)]),H(`click`,l,()=>i(t(),V(a))),W(e,o)};var o=L(F(a),4),s=t=>{var r=co();q(r,21,()=>n().split_by,ei,(t,n)=>{e(t,()=>V(n))}),A(r),W(t,r)},c=j(()=>Array.isArray(n().split_by));K(o,e=>{V(c)&&e(s)});var l=L(o,2),u=t=>{var r=Kr();q(I(r),17,()=>Object.entries(n().belongs_to),([e,t])=>e,(t,n)=>{var r=j(()=>h(V(n),2));let i=()=>V(r)[0],a=()=>V(r)[1];var o=Kr(),s=I(o),c=t=>{var n=lo(),r=I(n),o=F(r,!0);A(r);var s=L(r,2);q(s,21,()=>a().split_by,ei,(t,n)=>{e(t,()=>V(n),i)}),A(s),R(e=>G(o,e),[()=>Va(i())]),W(t,n)},l=j(()=>Array.isArray(a().split_by)&&a().split_by.length>0);K(s,e=>{V(l)&&e(c)}),W(t,o)}),W(t,r)};K(l,e=>{n().belongs_to&&e(u)});var f=L(l,2),p=L(F(f),2),g=F(p);g.value=g.__value=``,q(L(g),17,()=>t.splitFields,ei,(e,t)=>{var r=Kr(),i=I(r),a=e=>{var n=uo(),r=F(n,!0);A(n);var i={};R(()=>{G(r,V(t).label),i!==(i=V(t).value)&&(n.value=(n.__value=V(t).value)??``)}),W(e,n)},o=j(()=>!Array.isArray(n().split_by)||!n().split_by.includes(V(t).value));K(i,e=>{V(o)&&e(a)}),W(e,r)}),A(p),A(f),A(a),H(`change`,p,r)}W(e,a),Je()}Ir([`click`,`change`]);var mo=U(`<span class="capitalize"> </span> `,1),ho=U(`<p class="text-sm font-semibold text-night-700 group-hover:text-night-800"><!></p>`),go=U(`<option> </option>`),_o=U(`<label>Count by <select></select></label>`),vo=U(`<div class="sm:grid grid-cols-[auto_1fr] gap-4 sm:gap-12"><!> <!></div> <!>`,1),yo=U(`<!> <!>`,1),bo=U(`<span class="help-text">Note: your query must return three columns: <code>date</code>, <code>split</code>, and <code>count</code>. <code>split</code> can be <code>NULL</code></span>`),xo=U(`<label><span class="text-sm font-medium"> </span> <span class="ml-3 text-gray-500 text-xs font-normal">required?</span> <!></label>`),So=U(`<div class="mt-4 flex flex-wrap gap-y-2 gap-x-4"><p class="text-sm font-medium text-ice-700 mb-0.5 basis-full">Linked tables</p> <!></div>`),Co=U(`<button type="button" class="sm">Duplicate</button>`),wo=U(`<button type="button" class="sm px-1"><!></button>`),To=U(`<button type="button" class="sm bg-dawn-100 ml-auto">Yes, delete this dataset</button>`),Eo=U(`<button type="button" class="sm bg-dawn-100 ml-auto">Delete</button>`),Do=U(`<label>Label <input type="text"/> <span class="help-text">Splits can be incorporated into the label using <code>%1</code>, <code>%2</code>, etc. or with a default value if empty using <code>%1(none)</code></span></label> <div class="sm:grid grid-cols-2 gap-x-2 gap-y-4"><label class="only:col-span-2">Type <select></select></label> <!></div> <!> <!> <div class="flex flex-row gap-2 mt-4"><!> <!> <!> <!></div>`,1);function Oo(e,t){qe(t,!0);let n=ta(t,`dataset`,7),r=ta(t,`startOpen`,3,!1),i=j(()=>Na(n())?[``,...t.chartConfig.datasets.filter(e=>!(e.type===`percentage`||Fa(e)&&e.split_by)).map(e=>({value:e.id,label:e.label}))]:[]),a=j(()=>[...Object.keys(Oa),...t.chartConfig.type===`table`?[]:[`percentage`],`sql`]),o=j(()=>Oa[n().type]),s=j(()=>{if(!V(o))return{filter:[],select:[],split:[]};let e=Oa[n().type]?.fields??{},t=[],r=[],i=[];for(let[n,a]of Object.entries(e)){let e={label:a.label??ka(n),value:n};a.filter&&t.push(e),a.select&&r.push(e),a.split&&i.push(e)}if(Array.isArray(V(o).belongs_to))for(let e of V(o).belongs_to){let n=Oa[e];if(n?.fields)for(let[a,o]of Object.entries(n.fields)){let s={label:`${n.label??ka(e)}: ${o.label??ka(a)}`,value:`${e}.${a}`};o.filter&&t.push(s),o.select&&r.push(s),o.split&&i.push(s)}}return{filter:t,select:r,split:i}}),c=j(()=>{if(!Fa(n())||t.chartConfig.type===`table`||!V(o))return[];let e=[{label:V(o).counts?.[n().type]?.label??ka(n().type),value:n().type}];for(let[t,r]of Object.entries(V(o).counts??{}))t!==n().type&&e.push({label:r.label??ka(t),value:t});if(Array.isArray(V(o).belongs_to))for(let t of V(o).belongs_to){let n=Oa[t];e.push({label:n?.counts?.[t]?.label??ka(t),value:t});for(let[r,i]of Object.entries(n?.counts??{}))r!==t&&e.push({label:i.label??ka(r),value:r})}return e}),l=N(!1),u=e=>{let r=e.currentTarget.value;if(r===n().type||t.chartConfig.type===`table`&&n().type===`percentage`)return;let i=n().type;n().type=r;let a=[`id`,`type`,`label`,`visible`,`axis`];Fa(n())&&(a.push(`filters`,`belongs_to`),t.chartConfig.type===`table`?a.push(`selects`):a.push(`count_by`,`split_by`));for(let e of Object.keys(n()))a.includes(e)||delete n()[e];if(Fa(n())){if(Array.isArray(n().filters))for(let e=0;e<n().filters.length;e++)(!V(o)||!Ba(V(o),n().filters[e]))&&(n().filters.splice(e,1),e--);if(n().count_by&&(n().count_by===i?n().count_by=n().type:V(c).find(e=>e.value===n().count_by)||(n().count_by=n().type)),n().selects){for(let e=0;e<n().selects.length;e++){let t=n().selects[e];if(t.includes(`.`)){let[i,a]=t.split(`.`,2);if(i===r&&!n().selects.includes(a)){n().selects[e]=a;continue}if(i&&V(o)?.belongs_to?.includes(i))continue}else if(V(o)?.fields[t]?.select)continue;n().selects.splice(e,1),e--}n().selects.length===0&&delete n().selects}if(n().split_by){for(let e=0;e<n().split_by.length;e++){let t=n().split_by[e];V(o)?.fields[t]?.split||(n().split_by.splice(e,1),e--)}n().split_by.length===0&&delete n().split_by}if(n().belongs_to?.[r]){if(Array.isArray(n().belongs_to[r].filters)){n().filters??=[];for(let e of n().belongs_to[r].filters)n().filters.find(t=>t.field===e.field&&t.operator===e.operator&&t.value===e.value)||n().filters.push(e)}if(Array.isArray(n().belongs_to[r].split_by)){n().split_by??=[];for(let e of n().belongs_to[r].split_by)n().split_by.includes(e)||n().split_by.push(e)}delete n().belongs_to[r]}m()}Pa(n())&&(n().sql=`SELECT
31
31
  skadi_views.created_at as "date",
32
32
  NULL as "split",
33
33
  1 as "count"
34
- FROM skadi_views`)},f=e=>{let t=e.currentTarget.value;if(!ja(n())||n().count_by===t)return;n().count_by=t;let r=Va(n().type,t);r&&r!==n().type&&(n().belongs_to??={},n().belongs_to[r]??={}),m()},p=e=>{ja(n())&&(n().belongs_to?.[e]?.required?(delete n().belongs_to[e].required,m()):(n().belongs_to??={},n().belongs_to[e]??={},n().belongs_to[e].required=!0))},m=()=>{if(!ja(n()))return;let e=new Set;if(n().count_by){let t=Va(n().type,n().count_by);t&&t!==n().type&&e.add(t)}if(n().selects){for(let t of n().selects)if(t.includes(`.`)){let[n,r]=t.split(`.`,2);e.add(n)}}if(!(e.size===0&&!n().belongs_to)){n().belongs_to??={};for(let[t,r]of Object.entries(n().belongs_to))V(o)?.belongs_to?.includes(t)&&(e.has(t)||r.required!==void 0||r.split_by?.length||r.filters?.length)||delete n().belongs_to[t];for(let t of e)n().belongs_to[t]??={};Object.keys(n().belongs_to).length===0&&delete n().belongs_to}},h,g=()=>{t.onDuplicate(),h?.close()};Qi(Ca(e,{wrapperClass:`border-night-700`,get startOpen(){return r()},title:(e,r=d)=>{var i=uo(),a=F(i),o=e=>{var n=Gr();R(()=>G(n,`Dataset ${t.index+1}`)),W(e,n)},s=e=>{var t=lo(),r=I(t),i=F(r,!0);A(r);var a=L(r);R(()=>{G(i,n().type),G(a,` dataset: ${n().label??``}`)}),W(e,t)};K(a,e=>{r()?e(o):e(s,-1)}),A(i),W(e,i)},children:(e,r)=>{var d=Co(),h=I(d),_=L(F(h));Fi(_),Ie(2),A(h);var v=L(h,2),y=F(v),b=L(F(y));q(b,20,()=>V(a),e=>e,(e,t)=>{var n=fo(),r=F(n,!0);A(n);var i={};R(e=>{G(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>Ta(t)]),W(e,n)}),A(b);var x;wi(b),A(y);var S=L(y,2),C=e=>{var t=po(),r=L(F(t));q(r,20,()=>V(c),e=>e,(e,t)=>{var n=fo(),r=F(n,!0);A(n);var i={};R(()=>{G(r,t.label),i!==(i=t.value)&&(n.value=(n.__value=t.value)??``)}),W(e,n)}),A(r);var i;wi(r),A(t),R(()=>{i!==(i=n().count_by??n().type)&&(r.value=(r.__value=n().count_by??n().type)??``,Ci(r,n().count_by??n().type))}),H(`change`,r,f),W(e,t)},w=j(()=>ja(n())&&V(c).length>1&&t.chartConfig.type!==`table`);K(S,e=>{V(w)&&e(C)}),A(v);var T=L(v,2),E=e=>{var t=Kr(),r=I(t),i=e=>{no(e,{get dataset(){return n()},pruneBelongsTo:m,get selectFields(){return V(s).select}})},a=j(()=>ja(n())&&V(s).select.length>0);K(r,e=>{V(a)&&e(i)}),W(e,t)},D=e=>{var t=mo(),r=I(t),i=F(r);xa(i,{type:`switch`,leftValue:!1,get model(){return n()},key:`visible`,children:(e,t)=>{Ie(),W(e,Gr(`Show on chart`))},$$slots:{default:!0}});var a=L(i,2),o=e=>{xa(e,{type:`switch`,leftLabel:`Left`,rightLabel:`Right`,rightValue:`right`,get model(){return n()},key:`axis`,children:(e,t)=>{Ie(),W(e,Gr(`Axis`))},$$slots:{default:!0}})};K(a,e=>{n().visible!==!1&&e(o)}),A(r);var c=L(r,2),l=e=>{var t=Kr(),r=I(t),i=e=>{co(e,{get dataset(){return n()},pruneBelongsTo:m,get splitFields(){return V(s).split}})};K(r,e=>{V(s).split.length>0&&e(i)}),W(e,t)},u=j(()=>ja(n()));K(c,e=>{V(u)&&e(l)}),W(e,t)};K(T,e=>{t.chartConfig.type===`table`?e(E):e(D,-1)});var ee=L(T,2),te=e=>{var t=ho(),r=I(t);xa(r,{type:`select`,get model(){return n()},key:`numerator`,get selectOptions(){return V(i)},description:`The dataset you are using for your target, e.g. a specific page view or event.`,children:(e,t)=>{Ie(),W(e,Gr(`Numerator`))},$$slots:{default:!0}}),xa(L(r,2),{type:`select`,get model(){return n()},key:`denominator`,get selectOptions(){return V(i)},description:`The dataset you are using for comparison, e.g. the number of visits.`,children:(e,t)=>{Ie(),W(e,Gr(`Denominator`))},$$slots:{default:!0}}),W(e,t)},ne=j(()=>ka(n())),re=e=>{{let r=e=>{var n=Kr(),r=I(n),i=e=>{W(e,go())};K(r,e=>{t.chartConfig.type!==`table`&&e(i)}),W(e,n)},i=j(()=>!t.canDangerouslyUseSql);xa(e,{type:`textarea`,get model(){return n()},key:`sql`,class:`font-mono text-red-800 bg-red-50/50 p-1 border border-red-800`,rows:`10`,get readonly(){return V(i)},description:r,children:(e,t)=>{Ie(),W(e,Gr(`SQL Query`))},$$slots:{description:!0,default:!0}})}},ie=j(()=>Aa(n())),ae=e=>{var t=ho(),r=I(t);Za(r,{get dataset(){return n()},pruneBelongsTo:m,get filterFields(){return V(s).filter}});var i=L(r,2),a=e=>{var t=vo();q(L(F(t),2),17,()=>V(o).belongs_to,ei,(e,t)=>{let r=j(()=>n().belongs_to?.[V(t)]?.required??!1);var i=_o(),a=F(i),o=F(a,!0);A(a),sa(L(a,4),{get value(){return V(r)},onToggle:()=>p(V(t))}),A(i),R(e=>{bi(i,1,`flex flex-row items-center gap-2 font-normal pill pl-3 pr-1 ${V(r)?`bg-ice-50/50`:`bg-gray-50/50`}`),G(o,e)},[()=>La(V(t))]),W(e,i)}),A(t),W(e,t)};K(i,e=>{V(o)?.belongs_to&&e(a)}),W(e,t)};K(ee,e=>{V(ne)?e(te):V(ie)?e(re,1):e(ae,-1)});var oe=L(ee,2),se=F(oe),ce=e=>{var t=yo();H(`click`,t,g),W(e,t)};K(se,e=>{(n().type!==`sql`||t.canDangerouslyUseSql)&&t.chartConfig.type!==`table`&&e(ce)});var le=L(se,2),ue=e=>{var n=bo();aa(F(n),{name:`chevron_up`,size:24}),A(n),H(`click`,n,function(...e){t.onMoveUp?.apply(this,e)}),W(e,n)};K(le,e=>{t.onMoveUp!==null&&e(ue)});var de=L(le,2),fe=e=>{var n=bo();aa(F(n),{name:`chevron_down`,size:24}),A(n),H(`click`,n,function(...e){t.onMoveDown?.apply(this,e)}),W(e,n)};K(de,e=>{t.onMoveDown!==null&&e(fe)});var pe=L(de,2),me=e=>{var n=Kr(),r=I(n),i=e=>{var n=xo();H(`click`,n,function(...e){t.onDelete?.apply(this,e)}),W(e,n)},a=e=>{var t=So();H(`click`,t,()=>P(l,!0)),W(e,t)};K(r,e=>{V(l)?e(i):e(a,-1)}),W(e,n)};K(pe,e=>{t.chartConfig.datasets.length>1&&e(me)}),A(oe),R(()=>{x!==(x=n().type)&&(b.value=(b.__value=n().type)??``,Ci(b,n().type))}),Ji(_,()=>n().label,e=>n().label=e),H(`change`,b,u),W(e,d)},$$slots:{title:!0,default:!0}}),e=>h=e,()=>h),Je()}Ir([`change`,`click`]);var To=U(`<option>All time</option>`),Eo=U(`<option>Daily</option>`),Do=U(`<!> <!> <option>Weekly</option> <option>Monthly</option>`,1),Oo=U(`<span class="sr-only">Date from</span>`),ko=U(`<span class="sr-only">Date to</span>`),Ao=U(`<button type="button" class="sm text-sm ghost w-full border-l-4 border-night-100 hover:border-night-700 pl-4 hover:bg-transparent hover:backdrop-filter-none"><!> New dataset</button>`),jo=U(`<div class="p-1 px-2 bg-red-50/50 border border-red-500"><p class="text-red-800 font-semibold">Unable to preview the chart:</p> <pre class="text-red-800 whitespace-pre-wrap"> </pre></div>`),Mo=U(`<button type="button" class="emph bg-ice-600 text-white">Preview</button>`),No=U(`<button type="button" class="emph">Save</button>`),Po=U(`<div class="shrink-0 flex flex-col gap-4 border-l-4 border-ice-400 pl-4"><p class="font-semibold text-ice-700">Editing chart</p> <label>Title <input type="text"/></label> <!> <div class="sm:grid grid-cols-2 gap-x-2 gap-y-4 items-start"><label class="only:col-span-2">Type <select><option>Line chart</option><option>Bar chart</option><option>Table</option></select></label> <!></div> <div class="flex flex-wrap gap-2 items-center"><div class="flex gap-2 items-center sm:contents">Include data from <!></div> <div class="flex gap-2 items-center sm:contents">to <!></div></div> <div class="flex flex-col gap-4 mt-1 max-w-160"><!> <!></div> <!> <div class="flex gap-2 mt-4"><!> <button type="button" class="bg-gray-100">Cancel</button></div></div>`);function Fo(e,t){qe(t,!0);let n=on(Ue(br(()=>t.chartConfig))),r=j(()=>JSON.stringify(t.chartConfig)),i=j(()=>JSON.stringify(n)),a=N(on(br(()=>V(r)))),o=j(()=>V(r)!==V(i)),s=j(()=>V(i)!==V(a)),c=N(null),l=N(null),u=()=>{t.onSave(n)},d=()=>{V(a)!==V(r)&&t.reloadChartData(t.chartConfig),t.onClose()},f=()=>{let e=V(i);t.reloadChartData(Ue(n)).then(()=>{P(a,e,!0),P(c,null)}).catch(e=>{P(c,e.message.trim().replace(/Configuration configuration\[\d+\]\.children\[\d+\]\./g,``),!0)})},p=e=>{let t=e.currentTarget.value;t===`line`&&(n.type=`line`,n.time_series??=`daily`),t===`bar`&&(n.type=`bar`,n.time_series===`daily`&&delete n.time_series),t===`table`&&(n.type=`table`,n.datasets=n.datasets.filter(e=>e.type!==`percentage`),n.datasets.length===0?m():n.datasets.splice(1),[`visible`,`axis`,`split_by`].forEach(e=>{delete n.datasets[0][e]}),delete n.time_series)},m=()=>{let e=crypto.randomUUID();P(l,e,!0),n.datasets.push({id:e,label:`Dataset ${n.datasets.length+1}`,type:`visits`})},h=e=>{n.datasets.splice(e,1)},g=e=>{let t=Ue(n.datasets[e]);t.id=crypto.randomUUID(),P(l,t.id,!0),t.label=`Copy of ${t.label}`,n.datasets.splice(e+1,0,t)},_=e=>{if(e===0)return;let t=n.datasets[e];n.datasets[e]=n.datasets[e-1],n.datasets[e-1]=t},v=e=>{if(e>=n.datasets.length-1)return;let t=n.datasets[e];n.datasets[e]=n.datasets[e+1],n.datasets[e+1]=t};var y=Po(),b=L(F(y),2),x=L(F(b));Fi(x),A(b);var S=L(b,2);xa(S,{type:`contenteditable`,get model(){return n},key:`description`,placeholder:`Enter a description for this chart`,children:(e,t)=>{Ie(),W(e,Gr(`Description`))},$$slots:{default:!0}});var C=L(S,2),w=F(C),T=L(F(w)),E=F(T);E.value=E.__value=`line`;var D=L(E);D.value=D.__value=`bar`;var ee=L(D);ee.value=ee.__value=`table`,A(T);var te;wi(T),A(w);var ne=L(w,2),re=e=>{xa(e,{type:`select`,get model(){return n},key:`time_series`,selectOptions:e=>{var t=Do(),r=I(t),i=e=>{var t=To();t.value=t.__value=``,W(e,t)};K(r,e=>{n.type!==`line`&&e(i)});var a=L(r,2),o=e=>{var t=Eo();t.value=t.__value=`daily`,W(e,t)};K(a,e=>{n.type!==`bar`&&e(o)});var s=L(a,2);s.value=s.__value=`weekly`;var c=L(s,2);c.value=c.__value=`monthly`,W(e,t)},children:(e,t)=>{Ie(),W(e,Gr(`Time series`))},$$slots:{selectOptions:!0,default:!0}})};K(ne,e=>{n.type!==`table`&&e(re)}),A(C);var ie=L(C,2),ae=F(ie);xa(L(F(ae)),{type:`date`,get model(){return n},key:`date_from`,children:(e,t)=>{W(e,Oo())},$$slots:{default:!0}}),A(ae);var oe=L(ae,2);xa(L(F(oe)),{type:`date`,get model(){return n},key:`date_to`,children:(e,t)=>{W(e,ko())},$$slots:{default:!0}}),A(oe),A(ie);var se=L(ie,2),ce=F(se);q(ce,19,()=>n.datasets,e=>e.id,(e,r,i)=>{{let a=j(()=>V(r).id===V(l)),o=j(()=>V(i)===0?null:()=>_(V(i))),s=j(()=>V(i)===n.datasets.length-1?null:()=>v(V(i)));wo(e,{get canDangerouslyUseSql(){return t.canDangerouslyUseSql},get chartConfig(){return n},get dataset(){return V(r)},get index(){return V(i)},get startOpen(){return V(a)},onDelete:()=>h(V(i)),onDuplicate:()=>g(V(i)),get onMoveUp(){return V(o)},get onMoveDown(){return V(s)}})}});var le=L(ce,2),ue=e=>{var t=Ao();aa(F(t),{name:`plus`,size:18,class:`-ml-1 mt-px`}),Ie(),A(t),H(`click`,t,m),W(e,t)};K(le,e=>{n.type!==`table`&&e(ue)}),A(se);var de=L(se,2),fe=e=>{var t=jo(),n=L(F(t),2),r=F(n,!0);A(n),A(t),R(()=>G(r,V(c))),W(e,t)};K(de,e=>{V(c)&&e(fe)});var pe=L(de,2),me=F(pe),he=e=>{var t=Mo();H(`click`,t,f),W(e,t)},ge=e=>{var t=Kr(),n=I(t),r=e=>{var t=No();H(`click`,t,u),W(e,t)};K(n,e=>{V(o)&&e(r)}),W(e,t)};K(me,e=>{V(s)?e(he):e(ge,-1)});var _e=L(me,2);A(pe),A(y),R(()=>{te!==(te=n.type)&&(T.value=(T.__value=n.type)??``,Ci(T,n.type))}),Ji(x,()=>n.title,e=>n.title=e),H(`change`,T,p),H(`click`,_e,d),W(e,y),Je()}Ir([`change`,`click`]);var Io=(e,t)=>{let n={};for(let e of t){let t=e.split?`${e.id} ${e.split}`:e.id;n[t]??=[],n[t].push({x:e.date,y:e.count})}return Ro(e,n),Bo(e,n),Uo(e,n),Lo(e,n)},Lo=(e,t)=>e.datasets.filter(e=>e.visible!==!1).flatMap(n=>{let r={},i=Object.keys(t).filter(e=>e.startsWith(n.id));for(let e of i){let t=e.replace(/^[^ ]+ ?/,``);r[t]=e}return Object.entries(r).map(([r,i])=>{let a=n.label,o=r?r.split(`|~|`):[],s=Math.max(o.length,n.split_by?.length??0);for(let e=0;e<s;e++){let t=RegExp(`%${e+1}(?!\\d)(?:\\(([^)]+)\\))?`,`g`);if(a.match(t))a=a.replace(t,(t,n)=>o[e]?o[e]:n??`n/a`);else{let t=o[e]?o[e]:`n/a`;a=`${a}, ${t}`}}return!e.time_series&&t[i]?.[0]&&(t[i][0].x=a),{dataset:i,split:r,label:a,data:t[i],axis:n.axis===`right`?`right`:`left`}})}),Ro=(e,t)=>{for(let n of e.datasets)if(ka(n)){let r=t[n.numerator],i=t[n.denominator];if(!r||!i){console.error(`Could not find numerator or denominator for percentage dataset ${n.id}`),delete t[n.id];continue}if(e.time_series)t[n.id]=zo(r,i);else{let e=i[0]?.y,a=r[0]?.y;if(e&&typeof a==`number`){let r=a/e;t[n.id]=[{x:n.label,y:Math.round(r*1e3)/10}]}}}},zo=(e,t)=>{let n=0,r=0,i=[];for(;n<e.length&&r<t.length;){let a=e[n]?.x,o=t[r]?.x;if(a===o){let a=e[n]?.y??null,o=t[r]?.y??null;a!==null&&o!==null&&o!==0&&i.push({x:e[n]?.x??null,y:Math.round(a/o*1e3)/10}),n++,r++}else a<o?n++:r++}return i},Bo=(e,t)=>{if(!e.time_series)return;let n=new Set;for(let e of Object.values(t))for(let t of e)n.add(t.x);let r=Array.from(n).sort();Vo(e,r);for(let e of Object.values(t)){e.sort((e,t)=>(e.x??`￿`).localeCompare(t.x??`￿`));for(let t=0;t<r.length;t++){let n=r[t],i=e[t];(!i||(i.x??``)>n)&&e.splice(t,0,{x:n,y:null})}}},Vo=(e,t)=>{if(e.time_series)for(let n=0;n<t.length-1;n++){let r=t[n],i=t[t.length-1];if(!r||!i)continue;let a=new Date(r);e.time_series===`daily`?a.setUTCDate(a.getUTCDate()+1):e.time_series===`weekly`?a.setUTCDate(a.getUTCDate()+7):e.time_series===`monthly`&&a.setUTCMonth(a.getUTCMonth()+1);let o=a.toISOString().substring(0,10);o!==t[n+1]&&o<i&&t.splice(n+1,0,o)}},Ho={monthly:`month`,weekly:`week`,daily:`day`},Uo=(e,t)=>{for(let n of e.datasets){if(!e.time_series)continue;let r=Ho[e.time_series];for(let[e,i]of Object.entries(t))if(e.startsWith(n.id))for(let e of i)e.x&&=Oa(e.x,r)}},Wo=document.querySelector(`[data-dashboard-config]`),Go=Wo?.dataset?.fetchDataPath,Ko=Wo?.dataset?.updateDashboardPath,qo=document.querySelector(`meta[name=csrf-param]`)?.content,Jo=document.querySelector(`meta[name=csrf-token]`)?.content,Yo=e=>e.text().then(t=>{let n=null;if(t)try{n=JSON.parse(t)}catch{}if(!e.ok)throw Error(n?.error??`Request failed with status ${e.status}\n${t}`);return n}),Xo=(e,t,n)=>{let r={[qo]:Jo};return t.date_from&&(r.date_from=t.date_from),t.date_to&&(r.date_to=t.date_to),n.page&&(r.page=n.page),typeof e==`string`?r.chart_id=e:r.configuration=e,fetch(Go,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}).then(Yo)},Zo=e=>fetch(Ko,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({[qo]:Jo,configuration:e})}).then(Yo);function Qo(e){return e+.5|0}var $o=(e,t,n)=>Math.max(Math.min(e,n),t);function es(e){return $o(Qo(e*2.55),0,255)}function ts(e){return $o(Qo(e*255),0,255)}function ns(e){return $o(Qo(e/2.55)/100,0,1)}function rs(e){return $o(Qo(e*100),0,100)}var is={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},as=[...`0123456789ABCDEF`],os=e=>as[e&15],ss=e=>as[(e&240)>>4]+as[e&15],cs=e=>(e&240)>>4==(e&15),ls=e=>cs(e.r)&&cs(e.g)&&cs(e.b)&&cs(e.a);function us(e){var t=e.length,n;return e[0]===`#`&&(t===4||t===5?n={r:255&is[e[1]]*17,g:255&is[e[2]]*17,b:255&is[e[3]]*17,a:t===5?is[e[4]]*17:255}:(t===7||t===9)&&(n={r:is[e[1]]<<4|is[e[2]],g:is[e[3]]<<4|is[e[4]],b:is[e[5]]<<4|is[e[6]],a:t===9?is[e[7]]<<4|is[e[8]]:255})),n}var ds=(e,t)=>e<255?t(e):``;function fs(e){var t=ls(e)?os:ss;return e?`#`+t(e.r)+t(e.g)+t(e.b)+ds(e.a,t):void 0}var ps=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function ms(e,t,n){let r=t*Math.min(n,1-n),i=(t,i=(t+e/30)%12)=>n-r*Math.max(Math.min(i-3,9-i,1),-1);return[i(0),i(8),i(4)]}function hs(e,t,n){let r=(r,i=(r+e/60)%6)=>n-n*t*Math.max(Math.min(i,4-i,1),0);return[r(5),r(3),r(1)]}function gs(e,t,n){let r=ms(e,1,.5),i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)r[i]*=1-t-n,r[i]+=t;return r}function _s(e,t,n,r,i){return e===i?(t-n)/r+(t<n?6:0):t===i?(n-e)/r+2:(e-t)/r+4}function vs(e){let t=e.r/255,n=e.g/255,r=e.b/255,i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2,s,c,l;return i!==a&&(l=i-a,c=o>.5?l/(2-i-a):l/(i+a),s=_s(t,n,r,l,i),s=s*60+.5),[s|0,c||0,o]}function ys(e,t,n,r){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,r)).map(ts)}function bs(e,t,n){return ys(ms,e,t,n)}function xs(e,t,n){return ys(gs,e,t,n)}function Ss(e,t,n){return ys(hs,e,t,n)}function Cs(e){return(e%360+360)%360}function ws(e){let t=ps.exec(e),n=255,r;if(!t)return;t[5]!==r&&(n=t[6]?es(+t[5]):ts(+t[5]));let i=Cs(+t[2]),a=t[3]/100,o=t[4]/100;return r=t[1]===`hwb`?xs(i,a,o):t[1]===`hsv`?Ss(i,a,o):bs(i,a,o),{r:r[0],g:r[1],b:r[2],a:n}}function Ts(e,t){var n=vs(e);n[0]=Cs(n[0]+t),n=bs(n),e.r=n[0],e.g=n[1],e.b=n[2]}function Es(e){if(!e)return;let t=vs(e),n=t[0],r=rs(t[1]),i=rs(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${i}%, ${ns(e.a)})`:`hsl(${n}, ${r}%, ${i}%)`}var Ds={x:`dark`,Z:`light`,Y:`re`,X:`blu`,W:`gr`,V:`medium`,U:`slate`,A:`ee`,T:`ol`,S:`or`,B:`ra`,C:`lateg`,D:`ights`,R:`in`,Q:`turquois`,E:`hi`,P:`ro`,O:`al`,N:`le`,M:`de`,L:`yello`,F:`en`,K:`ch`,G:`arks`,H:`ea`,I:`ightg`,J:`wh`},Os={OiceXe:`f0f8ff`,antiquewEte:`faebd7`,aqua:`ffff`,aquamarRe:`7fffd4`,azuY:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`0`,blanKedOmond:`ffebcd`,Xe:`ff`,XeviTet:`8a2be2`,bPwn:`a52a2a`,burlywood:`deb887`,caMtXe:`5f9ea0`,KartYuse:`7fff00`,KocTate:`d2691e`,cSO:`ff7f50`,cSnflowerXe:`6495ed`,cSnsilk:`fff8dc`,crimson:`dc143c`,cyan:`ffff`,xXe:`8b`,xcyan:`8b8b`,xgTMnPd:`b8860b`,xWay:`a9a9a9`,xgYF:`6400`,xgYy:`a9a9a9`,xkhaki:`bdb76b`,xmagFta:`8b008b`,xTivegYF:`556b2f`,xSange:`ff8c00`,xScEd:`9932cc`,xYd:`8b0000`,xsOmon:`e9967a`,xsHgYF:`8fbc8f`,xUXe:`483d8b`,xUWay:`2f4f4f`,xUgYy:`2f4f4f`,xQe:`ced1`,xviTet:`9400d3`,dAppRk:`ff1493`,dApskyXe:`bfff`,dimWay:`696969`,dimgYy:`696969`,dodgerXe:`1e90ff`,fiYbrick:`b22222`,flSOwEte:`fffaf0`,foYstWAn:`228b22`,fuKsia:`ff00ff`,gaRsbSo:`dcdcdc`,ghostwEte:`f8f8ff`,gTd:`ffd700`,gTMnPd:`daa520`,Way:`808080`,gYF:`8000`,gYFLw:`adff2f`,gYy:`808080`,honeyMw:`f0fff0`,hotpRk:`ff69b4`,RdianYd:`cd5c5c`,Rdigo:`4b0082`,ivSy:`fffff0`,khaki:`f0e68c`,lavFMr:`e6e6fa`,lavFMrXsh:`fff0f5`,lawngYF:`7cfc00`,NmoncEffon:`fffacd`,ZXe:`add8e6`,ZcSO:`f08080`,Zcyan:`e0ffff`,ZgTMnPdLw:`fafad2`,ZWay:`d3d3d3`,ZgYF:`90ee90`,ZgYy:`d3d3d3`,ZpRk:`ffb6c1`,ZsOmon:`ffa07a`,ZsHgYF:`20b2aa`,ZskyXe:`87cefa`,ZUWay:`778899`,ZUgYy:`778899`,ZstAlXe:`b0c4de`,ZLw:`ffffe0`,lime:`ff00`,limegYF:`32cd32`,lRF:`faf0e6`,magFta:`ff00ff`,maPon:`800000`,VaquamarRe:`66cdaa`,VXe:`cd`,VScEd:`ba55d3`,VpurpN:`9370db`,VsHgYF:`3cb371`,VUXe:`7b68ee`,VsprRggYF:`fa9a`,VQe:`48d1cc`,VviTetYd:`c71585`,midnightXe:`191970`,mRtcYam:`f5fffa`,mistyPse:`ffe4e1`,moccasR:`ffe4b5`,navajowEte:`ffdead`,navy:`80`,Tdlace:`fdf5e6`,Tive:`808000`,TivedBb:`6b8e23`,Sange:`ffa500`,SangeYd:`ff4500`,ScEd:`da70d6`,pOegTMnPd:`eee8aa`,pOegYF:`98fb98`,pOeQe:`afeeee`,pOeviTetYd:`db7093`,papayawEp:`ffefd5`,pHKpuff:`ffdab9`,peru:`cd853f`,pRk:`ffc0cb`,plum:`dda0dd`,powMrXe:`b0e0e6`,purpN:`800080`,YbeccapurpN:`663399`,Yd:`ff0000`,Psybrown:`bc8f8f`,PyOXe:`4169e1`,saddNbPwn:`8b4513`,sOmon:`fa8072`,sandybPwn:`f4a460`,sHgYF:`2e8b57`,sHshell:`fff5ee`,siFna:`a0522d`,silver:`c0c0c0`,skyXe:`87ceeb`,UXe:`6a5acd`,UWay:`708090`,UgYy:`708090`,snow:`fffafa`,sprRggYF:`ff7f`,stAlXe:`4682b4`,tan:`d2b48c`,teO:`8080`,tEstN:`d8bfd8`,tomato:`ff6347`,Qe:`40e0d0`,viTet:`ee82ee`,JHt:`f5deb3`,wEte:`ffffff`,wEtesmoke:`f5f5f5`,Lw:`ffff00`,LwgYF:`9acd32`};function ks(){let e={},t=Object.keys(Os),n=Object.keys(Ds),r,i,a,o,s;for(r=0;r<t.length;r++){for(o=s=t[r],i=0;i<n.length;i++)a=n[i],s=s.replace(a,Ds[a]);a=parseInt(Os[o],16),e[s]=[a>>16&255,a>>8&255,a&255]}return e}var As;function js(e){As||(As=ks(),As.transparent=[0,0,0,0]);let t=As[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}var Ms=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Ns(e){let t=Ms.exec(e),n=255,r,i,a;if(t){if(t[7]!==r){let e=+t[7];n=t[8]?es(e):$o(e*255,0,255)}return r=+t[1],i=+t[3],a=+t[5],r=255&(t[2]?es(r):$o(r,0,255)),i=255&(t[4]?es(i):$o(i,0,255)),a=255&(t[6]?es(a):$o(a,0,255)),{r,g:i,b:a,a:n}}}function Ps(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${ns(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}var Fs=e=>e<=.0031308?e*12.92:e**(1/2.4)*1.055-.055,Is=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;function Ls(e,t,n){let r=Is(ns(e.r)),i=Is(ns(e.g)),a=Is(ns(e.b));return{r:ts(Fs(r+n*(Is(ns(t.r))-r))),g:ts(Fs(i+n*(Is(ns(t.g))-i))),b:ts(Fs(a+n*(Is(ns(t.b))-a))),a:e.a+n*(t.a-e.a)}}function Rs(e,t,n){if(e){let r=vs(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=bs(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function zs(e,t){return e&&Object.assign(t||{},e)}function Bs(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=ts(e[3]))):(t=zs(e,{r:0,g:0,b:0,a:1}),t.a=ts(t.a)),t}function Vs(e){return e.charAt(0)===`r`?Ns(e):ws(e)}var Hs=class e{constructor(t){if(t instanceof e)return t;let n=typeof t,r;n===`object`?r=Bs(t):n===`string`&&(r=us(t)||js(t)||Vs(t)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var e=zs(this._rgb);return e&&(e.a=ns(e.a)),e}set rgb(e){this._rgb=Bs(e)}rgbString(){return this._valid?Ps(this._rgb):void 0}hexString(){return this._valid?fs(this._rgb):void 0}hslString(){return this._valid?Es(this._rgb):void 0}mix(e,t){if(e){let n=this.rgb,r=e.rgb,i,a=t===i?.5:t,o=2*a-1,s=n.a-r.a,c=((o*s===-1?o:(o+s)/(1+o*s))+1)/2;i=1-c,n.r=255&c*n.r+i*r.r+.5,n.g=255&c*n.g+i*r.g+.5,n.b=255&c*n.b+i*r.b+.5,n.a=a*n.a+(1-a)*r.a,this.rgb=n}return this}interpolate(e,t){return e&&(this._rgb=Ls(this._rgb,e._rgb,t)),this}clone(){return new e(this.rgb)}alpha(e){return this._rgb.a=ts(e),this}clearer(e){let t=this._rgb;return t.a*=1-e,this}greyscale(){let e=this._rgb;return e.r=e.g=e.b=Qo(e.r*.3+e.g*.59+e.b*.11),this}opaquer(e){let t=this._rgb;return t.a*=1+e,this}negate(){let e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return Rs(this._rgb,2,e),this}darken(e){return Rs(this._rgb,2,-e),this}saturate(e){return Rs(this._rgb,1,e),this}desaturate(e){return Rs(this._rgb,1,-e),this}rotate(e){return Ts(this._rgb,e),this}};function Us(){}var Ws=(()=>{let e=0;return()=>e++})();function J(e){return e==null}function Gs(e){if(Array.isArray&&Array.isArray(e))return!0;let t=Object.prototype.toString.call(e);return t.slice(0,7)===`[object`&&t.slice(-6)===`Array]`}function Y(e){return e!==null&&Object.prototype.toString.call(e)===`[object Object]`}function Ks(e){return(typeof e==`number`||e instanceof Number)&&isFinite(+e)}function qs(e,t){return Ks(e)?e:t}function X(e,t){return e===void 0?t:e}var Js=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100:+e/t,Ys=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100*t:+e;function Z(e,t,n){if(e&&typeof e.call==`function`)return e.apply(n,t)}function Q(e,t,n,r){let i,a,o;if(Gs(e)){if(a=e.length,r)for(i=a-1;i>=0;i--)t.call(n,e[i],i);else for(i=0;i<a;i++)t.call(n,e[i],i)}else if(Y(e))for(o=Object.keys(e),a=o.length,i=0;i<a;i++)t.call(n,e[o[i]],o[i])}function Xs(e,t){let n,r,i,a;if(!e||!t||e.length!==t.length)return!1;for(n=0,r=e.length;n<r;++n)if(i=e[n],a=t[n],i.datasetIndex!==a.datasetIndex||i.index!==a.index)return!1;return!0}function Zs(e){if(Gs(e))return e.map(Zs);if(Y(e)){let t=Object.create(null),n=Object.keys(e),r=n.length,i=0;for(;i<r;++i)t[n[i]]=Zs(e[n[i]]);return t}return e}function Qs(e){return[`__proto__`,`prototype`,`constructor`].indexOf(e)===-1}function $s(e,t,n,r){if(!Qs(e))return;let i=t[e],a=n[e];Y(i)&&Y(a)?ec(i,a,r):t[e]=Zs(a)}function ec(e,t,n){let r=Gs(t)?t:[t],i=r.length;if(!Y(e))return e;n||={};let a=n.merger||$s,o;for(let t=0;t<i;++t){if(o=r[t],!Y(o))continue;let i=Object.keys(o);for(let t=0,r=i.length;t<r;++t)a(i[t],e,o,n)}return e}function tc(e,t){return ec(e,t,{merger:nc})}function nc(e,t,n){if(!Qs(e))return;let r=t[e],i=n[e];Y(r)&&Y(i)?tc(r,i):Object.prototype.hasOwnProperty.call(t,e)||(t[e]=Zs(i))}var rc={"":e=>e,x:e=>e.x,y:e=>e.y};function ic(e){let t=e.split(`.`),n=[],r=``;for(let e of t)r+=e,r.endsWith(`\\`)?r=r.slice(0,-1)+`.`:(n.push(r),r=``);return n}function ac(e){let t=ic(e);return e=>{for(let n of t){if(n===``)break;e&&=e[n]}return e}}function oc(e,t){return(rc[t]||(rc[t]=ac(t)))(e)}function sc(e){return e.charAt(0).toUpperCase()+e.slice(1)}var cc=e=>e!==void 0,lc=e=>typeof e==`function`,uc=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};function dc(e){return e.type===`mouseup`||e.type===`click`||e.type===`contextmenu`}var $=Math.PI,fc=2*$,pc=fc+$,mc=1/0,hc=$/180,gc=$/2,_c=$/4,vc=$*2/3,yc=Math.log10,bc=Math.sign;function xc(e,t,n){return Math.abs(e-t)<n}function Sc(e){let t=Math.round(e);e=xc(e,t,e/1e3)?t:e;let n=10**Math.floor(yc(e)),r=e/n;return(r<=1?1:r<=2?2:r<=5?5:10)*n}function Cc(e){let t=[],n=Math.sqrt(e),r;for(r=1;r<n;r++)e%r===0&&(t.push(r),t.push(e/r));return n===(n|0)&&t.push(n),t.sort((e,t)=>e-t).pop(),t}function wc(e){return typeof e==`symbol`||typeof e==`object`&&!!e&&!(Symbol.toPrimitive in e||`toString`in e||`valueOf`in e)}function Tc(e){return!wc(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function Ec(e,t){let n=Math.round(e);return n-t<=e&&n+t>=e}function Dc(e,t,n){let r,i,a;for(r=0,i=e.length;r<i;r++)a=e[r][n],isNaN(a)||(t.min=Math.min(t.min,a),t.max=Math.max(t.max,a))}function Oc(e){return $/180*e}function kc(e){return 180/$*e}function Ac(e){if(!Ks(e))return;let t=1,n=0;for(;Math.round(e*t)/t!==e;)t*=10,n++;return n}function jc(e,t){let n=t.x-e.x,r=t.y-e.y,i=Math.sqrt(n*n+r*r),a=Math.atan2(r,n);return a<-.5*$&&(a+=fc),{angle:a,distance:i}}function Mc(e,t){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)}function Nc(e,t){return(e-t+pc)%fc-$}function Pc(e){return(e%fc+fc)%fc}function Fc(e,t,n,r){let i=Pc(e),a=Pc(t),o=Pc(n),s=Pc(a-i),c=Pc(o-i),l=Pc(i-a),u=Pc(i-o);return i===a||i===o||r&&a===o||s>c&&l<u}function Ic(e,t,n){return Math.max(t,Math.min(n,e))}function Lc(e){return Ic(e,-32768,32767)}function Rc(e,t,n,r=1e-6){return e>=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function zc(e,t,n){n||=(n=>e[n]<t);let r=e.length-1,i=0,a;for(;r-i>1;)a=i+r>>1,n(a)?i=a:r=a;return{lo:i,hi:r}}var Bc=(e,t,n,r)=>zc(e,n,r?r=>{let i=e[r][t];return i<n||i===n&&e[r+1][t]===n}:r=>e[r][t]<n),Vc=(e,t,n)=>zc(e,n,r=>e[r][t]>=n);function Hc(e,t,n){let r=0,i=e.length;for(;r<i&&e[r]<t;)r++;for(;i>r&&e[i-1]>n;)i--;return r>0||i<e.length?e.slice(r,i):e}var Uc=[`push`,`pop`,`shift`,`splice`,`unshift`];function Wc(e,t){if(e._chartjs){e._chartjs.listeners.push(t);return}Object.defineProperty(e,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[t]}}),Uc.forEach(t=>{let n=`_onData`+sc(t),r=e[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value(...t){let i=r.apply(this,t);return e._chartjs.listeners.forEach(e=>{typeof e[n]==`function`&&e[n](...t)}),i}})})}function Gc(e,t){let n=e._chartjs;if(!n)return;let r=n.listeners,i=r.indexOf(t);i!==-1&&r.splice(i,1),!(r.length>0)&&(Uc.forEach(t=>{delete e[t]}),delete e._chartjs)}function Kc(e){let t=new Set(e);return t.size===e.length?e:Array.from(t)}var qc=function(){return typeof window>`u`?function(e){return e()}:window.requestAnimationFrame}();function Jc(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,qc.call(window,()=>{r=!1,e.apply(t,n)}))}}function Yc(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}var Xc=e=>e===`start`?`left`:e===`end`?`right`:`center`,Zc=(e,t,n)=>e===`start`?t:e===`end`?n:(t+n)/2,Qc=(e,t,n,r)=>e===(r?`left`:`right`)?n:e===`center`?(t+n)/2:t;function $c(e,t,n){let r=t.length,i=0,a=r;if(e._sorted){let{iScale:o,vScale:s,_parsed:c}=e,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=o.axis,{min:d,max:f,minDefined:p,maxDefined:m}=o.getUserBounds();if(p){if(i=Math.min(Bc(c,u,d).lo,n?r:Bc(t,u,o.getPixelForValue(d)).lo),l){let e=c.slice(0,i+1).reverse().findIndex(e=>!J(e[s.axis]));i-=Math.max(0,e)}i=Ic(i,0,r-1)}if(m){let e=Math.max(Bc(c,o.axis,f,!0).hi+1,n?0:Bc(t,u,o.getPixelForValue(f),!0).hi+1);if(l){let t=c.slice(e-1).findIndex(e=>!J(e[s.axis]));e+=Math.max(0,t)}a=Ic(e,i,r)-i}else a=r-i}return{start:i,count:a}}function el(e){let{xScale:t,yScale:n,_scaleRanges:r}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!r)return e._scaleRanges=i,!0;let a=r.xmin!==t.min||r.xmax!==t.max||r.ymin!==n.min||r.ymax!==n.max;return Object.assign(r,i),a}var tl=e=>e===0||e===1,nl=(e,t,n)=>-(2**(10*--e)*Math.sin((e-t)*fc/n)),rl=(e,t,n)=>2**(-10*e)*Math.sin((e-t)*fc/n)+1,il={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-(--e*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>--e*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*gc)+1,easeOutSine:e=>Math.sin(e*gc),easeInOutSine:e=>-.5*(Math.cos($*e)-1),easeInExpo:e=>e===0?0:2**(10*(e-1)),easeOutExpo:e=>e===1?1:-(2**(-10*e))+1,easeInOutExpo:e=>tl(e)?e:e<.5?.5*2**(10*(e*2-1)):.5*(-(2**(-10*(e*2-1)))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1- --e*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>tl(e)?e:nl(e,.075,.3),easeOutElastic:e=>tl(e)?e:rl(e,.075,.3),easeInOutElastic(e){let t=.1125,n=.45;return tl(e)?e:e<.5?.5*nl(e*2,t,n):.5+.5*rl(e*2-1,t,n)},easeInBack(e){return e*e*(2.70158*e-1.70158)},easeOutBack(e){return--e*e*(2.70158*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-il.easeOutBounce(1-e),easeOutBounce(e){let t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},easeInOutBounce:e=>e<.5?il.easeInBounce(e*2)*.5:il.easeOutBounce(e*2-1)*.5+.5};function al(e){if(e&&typeof e==`object`){let t=e.toString();return t===`[object CanvasPattern]`||t===`[object CanvasGradient]`}return!1}function ol(e){return al(e)?e:new Hs(e)}function sl(e){return al(e)?e:new Hs(e).saturate(.5).darken(.1).hexString()}var cl=[`x`,`y`,`borderWidth`,`radius`,`tension`],ll=[`color`,`borderColor`,`backgroundColor`];function ul(e){e.set(`animation`,{delay:void 0,duration:1e3,easing:`easeOutQuart`,fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe(`animation`,{_fallback:!1,_indexable:!1,_scriptable:e=>e!==`onProgress`&&e!==`onComplete`&&e!==`fn`}),e.set(`animations`,{colors:{type:`color`,properties:ll},numbers:{type:`number`,properties:cl}}),e.describe(`animations`,{_fallback:`animation`}),e.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:e=>e|0}}}})}function dl(e){e.set(`layout`,{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var fl=new Map;function pl(e,t){t||={};let n=e+JSON.stringify(t),r=fl.get(n);return r||(r=new Intl.NumberFormat(e,t),fl.set(n,r)),r}function ml(e,t,n){return pl(t,n).format(e)}var hl={values(e){return Gs(e)?e:``+e},numeric(e,t,n){if(e===0)return`0`;let r=this.chart.options.locale,i,a=e;if(n.length>1){let t=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(t<1e-4||t>0x38d7ea4c68000)&&(i=`scientific`),a=gl(e,n)}let o=yc(Math.abs(a)),s=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),c={notation:i,minimumFractionDigits:s,maximumFractionDigits:s};return Object.assign(c,this.options.ticks.format),ml(e,r,c)},logarithmic(e,t,n){if(e===0)return`0`;let r=n[t].significand||e/10**Math.floor(yc(e));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?hl.numeric.call(this,e,t,n):``}};function gl(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var _l={formatters:hl};function vl(e){e.set(`scale`,{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:`ticks`,clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,t)=>t.lineWidth,tickColor:(e,t)=>t.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width: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:_l.formatters.values,minor:{},major:{},align:`center`,crossAlign:`near`,showLabelBackdrop:!1,backdropColor:`rgba(255, 255, 255, 0.75)`,backdropPadding:2}}),e.route(`scale.ticks`,`color`,``,`color`),e.route(`scale.grid`,`color`,``,`borderColor`),e.route(`scale.border`,`color`,``,`borderColor`),e.route(`scale.title`,`color`,``,`color`),e.describe(`scale`,{_fallback:!1,_scriptable:e=>!e.startsWith(`before`)&&!e.startsWith(`after`)&&e!==`callback`&&e!==`parser`,_indexable:e=>e!==`borderDash`&&e!==`tickBorderDash`&&e!==`dash`}),e.describe(`scales`,{_fallback:`scale`}),e.describe(`scale.ticks`,{_scriptable:e=>e!==`backdropPadding`&&e!==`callback`,_indexable:e=>e!==`backdropPadding`})}var yl=Object.create(null),bl=Object.create(null);function xl(e,t){if(!t)return e;let n=t.split(`.`);for(let t=0,r=n.length;t<r;++t){let r=n[t];e=e[r]||(e[r]=Object.create(null))}return e}function Sl(e,t,n){return typeof t==`string`?ec(xl(e,t),n):ec(xl(e,``),t)}var Cl=new class{constructor(e,t){this.animation=void 0,this.backgroundColor=`rgba(0,0,0,0.1)`,this.borderColor=`rgba(0,0,0,0.1)`,this.color=`#666`,this.datasets={},this.devicePixelRatio=e=>e.chart.platform.getDevicePixelRatio(),this.elements={},this.events=[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`],this.font={family:`'Helvetica Neue', 'Helvetica', 'Arial', sans-serif`,size:12,style:`normal`,lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(e,t)=>sl(t.backgroundColor),this.hoverBorderColor=(e,t)=>sl(t.borderColor),this.hoverColor=(e,t)=>sl(t.color),this.indexAxis=`x`,this.interaction={mode:`nearest`,intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(t)}set(e,t){return Sl(this,e,t)}get(e){return xl(this,e)}describe(e,t){return Sl(bl,e,t)}override(e,t){return Sl(yl,e,t)}route(e,t,n,r){let i=xl(this,e),a=xl(this,n),o=`_`+t;Object.defineProperties(i,{[o]:{value:i[t],writable:!0},[t]:{enumerable:!0,get(){let e=this[o],t=a[r];return Y(e)?Object.assign({},t,e):X(e,t)},set(e){this[o]=e}}})}apply(e){e.forEach(e=>e(this))}}({_scriptable:e=>!e.startsWith(`on`),_indexable:e=>e!==`events`,hover:{_fallback:`interaction`},interaction:{_scriptable:!1,_indexable:!1}},[ul,dl,vl]);function wl(e){return!e||J(e.size)||J(e.family)?null:(e.style?e.style+` `:``)+(e.weight?e.weight+` `:``)+e.size+`px `+e.family}function Tl(e,t,n,r,i){let a=t[i];return a||(a=t[i]=e.measureText(i).width,n.push(i)),a>r&&(r=a),r}function El(e,t,n,r){r||={};let i=r.data=r.data||{},a=r.garbageCollect=r.garbageCollect||[];r.font!==t&&(i=r.data={},a=r.garbageCollect=[],r.font=t),e.save(),e.font=t;let o=0,s=n.length,c,l,u,d,f;for(c=0;c<s;c++)if(d=n[c],d!=null&&!Gs(d))o=Tl(e,i,a,o,d);else if(Gs(d))for(l=0,u=d.length;l<u;l++)f=d[l],f!=null&&!Gs(f)&&(o=Tl(e,i,a,o,f));e.restore();let p=a.length/2;if(p>n.length){for(c=0;c<p;c++)delete i[a[c]];a.splice(0,p)}return o}function Dl(e,t,n){let r=e.currentDevicePixelRatio,i=n===0?0:Math.max(n/2,.5);return Math.round((t-i)*r)/r+i}function Ol(e,t){!t&&!e||(t||=e.getContext(`2d`),t.save(),t.resetTransform(),t.clearRect(0,0,e.width,e.height),t.restore())}function kl(e,t,n,r){Al(e,t,n,r,null)}function Al(e,t,n,r,i){let a,o,s,c,l,u,d,f,p=t.pointStyle,m=t.rotation,h=t.radius,g=(m||0)*hc;if(p&&typeof p==`object`&&(a=p.toString(),a===`[object HTMLImageElement]`||a===`[object HTMLCanvasElement]`)){e.save(),e.translate(n,r),e.rotate(g),e.drawImage(p,-p.width/2,-p.height/2,p.width,p.height),e.restore();return}if(!(isNaN(h)||h<=0)){switch(e.beginPath(),p){default:i?e.ellipse(n,r,i/2,h,0,0,fc):e.arc(n,r,h,0,fc),e.closePath();break;case`triangle`:u=i?i/2:h,e.moveTo(n+Math.sin(g)*u,r-Math.cos(g)*h),g+=vc,e.lineTo(n+Math.sin(g)*u,r-Math.cos(g)*h),g+=vc,e.lineTo(n+Math.sin(g)*u,r-Math.cos(g)*h),e.closePath();break;case`rectRounded`:l=h*.516,c=h-l,o=Math.cos(g+_c)*c,d=Math.cos(g+_c)*(i?i/2-l:c),s=Math.sin(g+_c)*c,f=Math.sin(g+_c)*(i?i/2-l:c),e.arc(n-d,r-s,l,g-$,g-gc),e.arc(n+f,r-o,l,g-gc,g),e.arc(n+d,r+s,l,g,g+gc),e.arc(n-f,r+o,l,g+gc,g+$),e.closePath();break;case`rect`:if(!m){c=Math.SQRT1_2*h,u=i?i/2:c,e.rect(n-u,r-c,2*u,2*c);break}g+=_c;case`rectRot`:d=Math.cos(g)*(i?i/2:h),o=Math.cos(g)*h,s=Math.sin(g)*h,f=Math.sin(g)*(i?i/2:h),e.moveTo(n-d,r-s),e.lineTo(n+f,r-o),e.lineTo(n+d,r+s),e.lineTo(n-f,r+o),e.closePath();break;case`crossRot`:g+=_c;case`cross`:d=Math.cos(g)*(i?i/2:h),o=Math.cos(g)*h,s=Math.sin(g)*h,f=Math.sin(g)*(i?i/2:h),e.moveTo(n-d,r-s),e.lineTo(n+d,r+s),e.moveTo(n+f,r-o),e.lineTo(n-f,r+o);break;case`star`:d=Math.cos(g)*(i?i/2:h),o=Math.cos(g)*h,s=Math.sin(g)*h,f=Math.sin(g)*(i?i/2:h),e.moveTo(n-d,r-s),e.lineTo(n+d,r+s),e.moveTo(n+f,r-o),e.lineTo(n-f,r+o),g+=_c,d=Math.cos(g)*(i?i/2:h),o=Math.cos(g)*h,s=Math.sin(g)*h,f=Math.sin(g)*(i?i/2:h),e.moveTo(n-d,r-s),e.lineTo(n+d,r+s),e.moveTo(n+f,r-o),e.lineTo(n-f,r+o);break;case`line`:o=i?i/2:Math.cos(g)*h,s=Math.sin(g)*h,e.moveTo(n-o,r-s),e.lineTo(n+o,r+s);break;case`dash`:e.moveTo(n,r),e.lineTo(n+Math.cos(g)*(i?i/2:h),r+Math.sin(g)*h);break;case!1:e.closePath()}e.fill(),t.borderWidth>0&&e.stroke()}}function jl(e,t,n){return n||=.5,!t||e&&e.x>t.left-n&&e.x<t.right+n&&e.y>t.top-n&&e.y<t.bottom+n}function Ml(e,t){e.save(),e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.clip()}function Nl(e){e.restore()}function Pl(e,t,n,r,i){if(!t)return e.lineTo(n.x,n.y);if(i===`middle`){let r=(t.x+n.x)/2;e.lineTo(r,t.y),e.lineTo(r,n.y)}else i===`after`==!!r?e.lineTo(n.x,t.y):e.lineTo(t.x,n.y);e.lineTo(n.x,n.y)}function Fl(e,t,n,r){if(!t)return e.lineTo(n.x,n.y);e.bezierCurveTo(r?t.cp1x:t.cp2x,r?t.cp1y:t.cp2y,r?n.cp2x:n.cp1x,r?n.cp2y:n.cp1y,n.x,n.y)}function Il(e,t){t.translation&&e.translate(t.translation[0],t.translation[1]),J(t.rotation)||e.rotate(t.rotation),t.color&&(e.fillStyle=t.color),t.textAlign&&(e.textAlign=t.textAlign),t.textBaseline&&(e.textBaseline=t.textBaseline)}function Ll(e,t,n,r,i){if(i.strikethrough||i.underline){let a=e.measureText(r),o=t-a.actualBoundingBoxLeft,s=t+a.actualBoundingBoxRight,c=n-a.actualBoundingBoxAscent,l=n+a.actualBoundingBoxDescent,u=i.strikethrough?(c+l)/2:l;e.strokeStyle=e.fillStyle,e.beginPath(),e.lineWidth=i.decorationWidth||2,e.moveTo(o,u),e.lineTo(s,u),e.stroke()}}function Rl(e,t){let n=e.fillStyle;e.fillStyle=t.color,e.fillRect(t.left,t.top,t.width,t.height),e.fillStyle=n}function zl(e,t,n,r,i,a={}){let o=Gs(t)?t:[t],s=a.strokeWidth>0&&a.strokeColor!==``,c,l;for(e.save(),e.font=i.string,Il(e,a),c=0;c<o.length;++c)l=o[c],a.backdrop&&Rl(e,a.backdrop),s&&(a.strokeColor&&(e.strokeStyle=a.strokeColor),J(a.strokeWidth)||(e.lineWidth=a.strokeWidth),e.strokeText(l,n,r,a.maxWidth)),e.fillText(l,n,r,a.maxWidth),Ll(e,n,r,l,a),r+=Number(i.lineHeight);e.restore()}function Bl(e,t){let{x:n,y:r,w:i,h:a,radius:o}=t;e.arc(n+o.topLeft,r+o.topLeft,o.topLeft,1.5*$,$,!0),e.lineTo(n,r+a-o.bottomLeft),e.arc(n+o.bottomLeft,r+a-o.bottomLeft,o.bottomLeft,$,gc,!0),e.lineTo(n+i-o.bottomRight,r+a),e.arc(n+i-o.bottomRight,r+a-o.bottomRight,o.bottomRight,gc,0,!0),e.lineTo(n+i,r+o.topRight),e.arc(n+i-o.topRight,r+o.topRight,o.topRight,0,-gc,!0),e.lineTo(n+o.topLeft,r)}var Vl=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,Hl=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function Ul(e,t){let n=(``+e).match(Vl);if(!n||n[1]===`normal`)return t*1.2;switch(e=+n[2],n[3]){case`px`:return e;case`%`:e/=100}return t*e}var Wl=e=>+e||0;function Gl(e,t){let n={},r=Y(t),i=r?Object.keys(t):t,a=Y(e)?r?n=>X(e[n],e[t[n]]):t=>e[t]:()=>e;for(let e of i)n[e]=Wl(a(e));return n}function Kl(e){return Gl(e,{top:`y`,right:`x`,bottom:`y`,left:`x`})}function ql(e){return Gl(e,[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`])}function Jl(e){let t=Kl(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function Yl(e,t){e||={},t||=Cl.font;let n=X(e.size,t.size);typeof n==`string`&&(n=parseInt(n,10));let r=X(e.style,t.style);r&&!(``+r).match(Hl)&&(console.warn(`Invalid font style specified: "`+r+`"`),r=void 0);let i={family:X(e.family,t.family),lineHeight:Ul(X(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:X(e.weight,t.weight),string:``};return i.string=wl(i),i}function Xl(e,t,n,r){let i=!0,a,o,s;for(a=0,o=e.length;a<o;++a)if(s=e[a],s!==void 0&&(t!==void 0&&typeof s==`function`&&(s=s(t),i=!1),n!==void 0&&Gs(s)&&(s=s[n%s.length],i=!1),s!==void 0))return r&&!i&&(r.cacheable=!1),s}function Zl(e,t,n){let{min:r,max:i}=e,a=Ys(t,(i-r)/2),o=(e,t)=>n&&e===0?0:e+t;return{min:o(r,-Math.abs(a)),max:o(i,a)}}function Ql(e,t){return Object.assign(Object.create(e),t)}function $l(e,t=[``],n,r,i=()=>e[0]){let a=n||e;return r===void 0&&(r=hu(`_fallback`,e)),new Proxy({[Symbol.toStringTag]:`Object`,_cacheable:!0,_scopes:e,_rootScopes:a,_fallback:r,_getTarget:i,override:n=>$l([n,...e],t,a,r)},{deleteProperty(t,n){return delete t[n],delete t._keys,delete e[0][n],!0},get(n,r){return iu(n,r,()=>mu(r,t,e,n))},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e._scopes[0],t)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(e,t){return gu(e).includes(t)},ownKeys(e){return gu(e)},set(e,t,n){let r=e._storage||=i();return e[t]=r[t]=n,delete e._keys,!0}})}function eu(e,t,n,r){let i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:tu(e,r),setContext:t=>eu(e,t,n,r),override:i=>eu(e.override(i),t,n,r)};return new Proxy(i,{deleteProperty(t,n){return delete t[n],delete e[n],!0},get(e,t,n){return iu(e,t,()=>au(e,t,n))},getOwnPropertyDescriptor(t,n){return t._descriptors.allKeys?Reflect.has(e,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,n)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(t,n){return Reflect.has(e,n)},ownKeys(){return Reflect.ownKeys(e)},set(t,n,r){return e[n]=r,delete t[n],!0}})}function tu(e,t={scriptable:!0,indexable:!0}){let{_scriptable:n=t.scriptable,_indexable:r=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:r,isScriptable:lc(n)?n:()=>n,isIndexable:lc(r)?r:()=>r}}var nu=(e,t)=>e?e+sc(t):t,ru=(e,t)=>Y(t)&&e!==`adapters`&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function iu(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t===`constructor`)return e[t];let r=n();return e[t]=r,r}function au(e,t,n){let{_proxy:r,_context:i,_subProxy:a,_descriptors:o}=e,s=r[t];return lc(s)&&o.isScriptable(t)&&(s=ou(t,s,e,n)),Gs(s)&&s.length&&(s=su(t,s,e,o.isIndexable)),ru(t,s)&&(s=eu(s,i,a&&a[t],o)),s}function ou(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_stack:s}=n;if(s.has(e))throw Error(`Recursion detected: `+Array.from(s).join(`->`)+`->`+e);s.add(e);let c=t(a,o||r);return s.delete(e),ru(e,c)&&(c=du(i._scopes,i,e,c)),c}function su(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_descriptors:s}=n;if(a.index!==void 0&&r(e))return t[a.index%t.length];if(Y(t[0])){let n=t,r=i._scopes.filter(e=>e!==n);t=[];for(let c of n){let n=du(r,i,e,c);t.push(eu(n,a,o&&o[e],s))}}return t}function cu(e,t,n){return lc(e)?e(t,n):e}var lu=(e,t)=>e===!0?t:typeof e==`string`?oc(t,e):void 0;function uu(e,t,n,r,i){for(let a of t){let t=lu(n,a);if(t){e.add(t);let a=cu(t._fallback,n,i);if(a!==void 0&&a!==n&&a!==r)return a}else if(t===!1&&r!==void 0&&n!==r)return null}return!1}function du(e,t,n,r){let i=t._rootScopes,a=cu(t._fallback,n,r),o=[...e,...i],s=new Set;s.add(r);let c=fu(s,o,n,a||n,r);return c===null||a!==void 0&&a!==n&&(c=fu(s,o,a,c,r),c===null)?!1:$l(Array.from(s),[``],i,a,()=>pu(t,n,r))}function fu(e,t,n,r,i){for(;n;)n=uu(e,t,n,r,i);return n}function pu(e,t,n){let r=e._getTarget();t in r||(r[t]={});let i=r[t];return Gs(i)&&Y(n)?n:i||{}}function mu(e,t,n,r){let i;for(let a of t)if(i=hu(nu(a,e),n),i!==void 0)return ru(e,i)?du(n,r,e,i):i}function hu(e,t){for(let n of t){if(!n)continue;let t=n[e];if(t!==void 0)return t}}function gu(e){let t=e._keys;return t||=e._keys=_u(e._scopes),t}function _u(e){let t=new Set;for(let n of e)for(let e of Object.keys(n).filter(e=>!e.startsWith(`_`)))t.add(e);return Array.from(t)}function vu(e,t,n,r){let{iScale:i}=e,{key:a=`r`}=this._parsing,o=Array(r),s,c,l,u;for(s=0,c=r;s<c;++s)l=s+n,u=t[l],o[s]={r:i.parse(oc(u,a),l)};return o}var yu=2**-52||1e-14,bu=(e,t)=>t<e.length&&!e[t].skip&&e[t],xu=e=>e===`x`?`y`:`x`;function Su(e,t,n,r){let i=e.skip?t:e,a=t,o=n.skip?t:n,s=Mc(a,i),c=Mc(o,a),l=s/(s+c),u=c/(s+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;let d=r*l,f=r*u;return{previous:{x:a.x-d*(o.x-i.x),y:a.y-d*(o.y-i.y)},next:{x:a.x+f*(o.x-i.x),y:a.y+f*(o.y-i.y)}}}function Cu(e,t,n){let r=e.length,i,a,o,s,c,l=bu(e,0);for(let u=0;u<r-1;++u)if(c=l,l=bu(e,u+1),!(!c||!l)){if(xc(t[u],0,yu)){n[u]=n[u+1]=0;continue}i=n[u]/t[u],a=n[u+1]/t[u],s=i**2+a**2,!(s<=9)&&(o=3/Math.sqrt(s),n[u]=i*o*t[u],n[u+1]=a*o*t[u])}}function wu(e,t,n=`x`){let r=xu(n),i=e.length,a,o,s,c=bu(e,0);for(let l=0;l<i;++l){if(o=s,s=c,c=bu(e,l+1),!s)continue;let i=s[n],u=s[r];o&&(a=(i-o[n])/3,s[`cp1${n}`]=i-a,s[`cp1${r}`]=u-a*t[l]),c&&(a=(c[n]-i)/3,s[`cp2${n}`]=i+a,s[`cp2${r}`]=u+a*t[l])}}function Tu(e,t=`x`){let n=xu(t),r=e.length,i=Array(r).fill(0),a=Array(r),o,s,c,l=bu(e,0);for(o=0;o<r;++o)if(s=c,c=l,l=bu(e,o+1),c){if(l){let e=l[t]-c[t];i[o]=e===0?0:(l[n]-c[n])/e}a[o]=s?l?bc(i[o-1])===bc(i[o])?(i[o-1]+i[o])/2:0:i[o-1]:i[o]}Cu(e,i,a),wu(e,a,t)}function Eu(e,t,n){return Math.max(Math.min(e,n),t)}function Du(e,t){let n,r,i,a,o,s=jl(e[0],t);for(n=0,r=e.length;n<r;++n)o=a,a=s,s=n<r-1&&jl(e[n+1],t),a&&(i=e[n],o&&(i.cp1x=Eu(i.cp1x,t.left,t.right),i.cp1y=Eu(i.cp1y,t.top,t.bottom)),s&&(i.cp2x=Eu(i.cp2x,t.left,t.right),i.cp2y=Eu(i.cp2y,t.top,t.bottom)))}function Ou(e,t,n,r,i){let a,o,s,c;if(t.spanGaps&&(e=e.filter(e=>!e.skip)),t.cubicInterpolationMode===`monotone`)Tu(e,i);else{let n=r?e[e.length-1]:e[0];for(a=0,o=e.length;a<o;++a)s=e[a],c=Su(n,s,e[Math.min(a+1,o-+!r)%o],t.tension),s.cp1x=c.previous.x,s.cp1y=c.previous.y,s.cp2x=c.next.x,s.cp2y=c.next.y,n=s}t.capBezierPoints&&Du(e,n)}function ku(){return typeof window<`u`&&typeof document<`u`}function Au(e){let t=e.parentNode;return t&&t.toString()===`[object ShadowRoot]`&&(t=t.host),t}function ju(e,t,n){let r;return typeof e==`string`?(r=parseInt(e,10),e.indexOf(`%`)!==-1&&(r=r/100*t.parentNode[n])):r=e,r}var Mu=e=>e.ownerDocument.defaultView.getComputedStyle(e,null);function Nu(e,t){return Mu(e).getPropertyValue(t)}var Pu=[`top`,`right`,`bottom`,`left`];function Fu(e,t,n){let r={};n=n?`-`+n:``;for(let i=0;i<4;i++){let a=Pu[i];r[a]=parseFloat(e[t+`-`+a+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}var Iu=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function Lu(e,t){let n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:a}=r,o=!1,s,c;if(Iu(i,a,e.target))s=i,c=a;else{let e=t.getBoundingClientRect();s=r.clientX-e.left,c=r.clientY-e.top,o=!0}return{x:s,y:c,box:o}}function Ru(e,t){if(`native`in e)return e;let{canvas:n,currentDevicePixelRatio:r}=t,i=Mu(n),a=i.boxSizing===`border-box`,o=Fu(i,`padding`),s=Fu(i,`border`,`width`),{x:c,y:l,box:u}=Lu(e,n),d=o.left+(u&&s.left),f=o.top+(u&&s.top),{width:p,height:m}=t;return a&&(p-=o.width+s.width,m-=o.height+s.height),{x:Math.round((c-d)/p*n.width/r),y:Math.round((l-f)/m*n.height/r)}}function zu(e,t,n){let r,i;if(t===void 0||n===void 0){let a=e&&Au(e);if(!a)t=e.clientWidth,n=e.clientHeight;else{let e=a.getBoundingClientRect(),o=Mu(a),s=Fu(o,`border`,`width`),c=Fu(o,`padding`);t=e.width-c.width-s.width,n=e.height-c.height-s.height,r=ju(o.maxWidth,a,`clientWidth`),i=ju(o.maxHeight,a,`clientHeight`)}}return{width:t,height:n,maxWidth:r||mc,maxHeight:i||mc}}var Bu=e=>Math.round(e*10)/10;function Vu(e,t,n,r){let i=Mu(e),a=Fu(i,`margin`),o=ju(i.maxWidth,e,`clientWidth`)||mc,s=ju(i.maxHeight,e,`clientHeight`)||mc,c=zu(e,t,n),{width:l,height:u}=c;if(i.boxSizing===`content-box`){let e=Fu(i,`border`,`width`),t=Fu(i,`padding`);l-=t.width+e.width,u-=t.height+e.height}return l=Math.max(0,l-a.width),u=Math.max(0,r?l/r:u-a.height),l=Bu(Math.min(l,o,c.maxWidth)),u=Bu(Math.min(u,s,c.maxHeight)),l&&!u&&(u=Bu(l/2)),(t!==void 0||n!==void 0)&&r&&c.height&&u>c.height&&(u=c.height,l=Bu(Math.floor(u*r))),{width:l,height:u}}function Hu(e,t,n){let r=t||1,i=Bu(e.height*r),a=Bu(e.width*r);e.height=Bu(e.height),e.width=Bu(e.width);let o=e.canvas;return o.style&&(n||!o.style.height&&!o.style.width)&&(o.style.height=`${e.height}px`,o.style.width=`${e.width}px`),e.currentDevicePixelRatio!==r||o.height!==i||o.width!==a?(e.currentDevicePixelRatio=r,o.height=i,o.width=a,e.ctx.setTransform(r,0,0,r,0,0),!0):!1}var Uu=function(){let e=!1;try{let t={get passive(){return e=!0,!1}};ku()&&(window.addEventListener(`test`,null,t),window.removeEventListener(`test`,null,t))}catch{}return e}();function Wu(e,t){let n=Nu(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function Gu(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function Ku(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:r===`middle`?n<.5?e.y:t.y:r===`after`?n<1?e.y:t.y:n>0?t.y:e.y}}function qu(e,t,n,r){let i={x:e.cp2x,y:e.cp2y},a={x:t.cp1x,y:t.cp1y},o=Gu(e,i,n),s=Gu(i,a,n),c=Gu(a,t,n);return Gu(Gu(o,s,n),Gu(s,c,n),n)}var Ju=function(e,t){return{x(n){return e+e+t-n},setWidth(e){t=e},textAlign(e){return e===`center`?e:e===`right`?`left`:`right`},xPlus(e,t){return e-t},leftForLtr(e,t){return e-t}}},Yu=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function Xu(e,t,n){return e?Ju(t,n):Yu()}function Zu(e,t){let n,r;(t===`ltr`||t===`rtl`)&&(n=e.canvas.style,r=[n.getPropertyValue(`direction`),n.getPropertyPriority(`direction`)],n.setProperty(`direction`,t,`important`),e.prevTextDirection=r)}function Qu(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty(`direction`,t[0],t[1]))}function $u(e){return e===`angle`?{between:Fc,compare:Nc,normalize:Pc}:{between:Rc,compare:(e,t)=>e-t,normalize:e=>e}}function ed({start:e,end:t,count:n,loop:r,style:i}){return{start:e%n,end:t%n,loop:r&&(t-e+1)%n===0,style:i}}function td(e,t,n){let{property:r,start:i,end:a}=n,{between:o,normalize:s}=$u(r),c=t.length,{start:l,end:u,loop:d}=e,f,p;if(d){for(l+=c,u+=c,f=0,p=c;f<p&&o(s(t[l%c][r]),i,a);++f)l--,u--;l%=c,u%=c}return u<l&&(u+=c),{start:l,end:u,loop:d,style:e.style}}function nd(e,t,n){if(!n)return[e];let{property:r,start:i,end:a}=n,o=t.length,{compare:s,between:c,normalize:l}=$u(r),{start:u,end:d,loop:f,style:p}=td(e,t,n),m=[],h=!1,g=null,_,v,y,b=()=>c(i,y,_)&&s(i,y)!==0,x=()=>s(a,_)===0||c(a,y,_),S=()=>h||b(),C=()=>!h||x();for(let e=u,n=u;e<=d;++e)v=t[e%o],!v.skip&&(_=l(v[r]),_!==y&&(h=c(_,i,a),g===null&&S()&&(g=s(_,i)===0?e:n),g!==null&&C()&&(m.push(ed({start:g,end:e,loop:f,count:o,style:p})),g=null),n=e,y=_));return g!==null&&m.push(ed({start:g,end:d,loop:f,count:o,style:p})),m}function rd(e,t){let n=[],r=e.segments;for(let i=0;i<r.length;i++){let a=nd(r[i],e.points,t);a.length&&n.push(...a)}return n}function id(e,t,n,r){let i=0,a=t-1;if(n&&!r)for(;i<t&&!e[i].skip;)i++;for(;i<t&&e[i].skip;)i++;for(i%=t,n&&(a+=i);a>i&&e[a%t].skip;)a--;return a%=t,{start:i,end:a}}function ad(e,t,n,r){let i=e.length,a=[],o=t,s=e[t],c;for(c=t+1;c<=n;++c){let n=e[c%i];n.skip||n.stop?s.skip||(r=!1,a.push({start:t%i,end:(c-1)%i,loop:r}),t=o=n.stop?c:null):(o=c,s.skip&&(t=c)),s=n}return o!==null&&a.push({start:t%i,end:o%i,loop:r}),a}function od(e,t){let n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];let a=!!e._loop,{start:o,end:s}=id(n,i,a,r);return r===!0?sd(e,[{start:o,end:s,loop:a}],n,t):sd(e,ad(n,o,s<o?s+i:s,!!e._fullLoop&&o===0&&s===i-1),n,t)}function sd(e,t,n,r){return!r||!r.setContext||!n?t:cd(e,t,n,r)}function cd(e,t,n,r){let i=e._chart.getContext(),a=ld(e.options),{_datasetIndex:o,options:{spanGaps:s}}=e,c=n.length,l=[],u=a,d=t[0].start,f=d;function p(e,t,r,i){let a=s?-1:1;if(e!==t){for(e+=c;n[e%c].skip;)e-=a;for(;n[t%c].skip;)t+=a;e%c!==t%c&&(l.push({start:e%c,end:t%c,loop:r,style:i}),u=i,d=t%c)}}for(let e of t){d=s?d:e.start;let t=n[d%c],a;for(f=d+1;f<=e.end;f++){let s=n[f%c];a=ld(r.setContext(Ql(i,{type:`segment`,p0:t,p1:s,p0DataIndex:(f-1)%c,p1DataIndex:f%c,datasetIndex:o}))),ud(a,u)&&p(d,f-1,e.loop,u),t=s,u=a}d<f-1&&p(d,f-1,e.loop,u)}return l}function ld(e){return{backgroundColor:e.backgroundColor,borderCapStyle:e.borderCapStyle,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderJoinStyle:e.borderJoinStyle,borderWidth:e.borderWidth,borderColor:e.borderColor}}function ud(e,t){if(!t)return!1;let n=[],r=function(e,t){return al(t)?(n.includes(t)||n.push(t),n.indexOf(t)):t};return JSON.stringify(e,r)!==JSON.stringify(t,r)}function dd(e,t,n){return e.options.clip?e[n]:t[n]}function fd(e,t){let{xScale:n,yScale:r}=e;return n&&r?{left:dd(n,t,`left`),right:dd(n,t,`right`),top:dd(r,t,`top`),bottom:dd(r,t,`bottom`)}:t}function pd(e,t){let n=t._clip;if(n.disabled)return!1;let r=fd(t,e.chartArea);return{left:n.left===!1?0:r.left-(n.left===!0?0:n.left),right:n.right===!1?e.width:r.right+(n.right===!0?0:n.right),top:n.top===!1?0:r.top-(n.top===!0?0:n.top),bottom:n.bottom===!1?e.height:r.bottom+(n.bottom===!0?0:n.bottom)}}var md=new class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(e,t,n,r){let i=t.listeners[r],a=t.duration;i.forEach(r=>r({chart:e,initial:t.initial,numSteps:a,currentStep:Math.min(n-t.start,a)}))}_refresh(){this._request||=(this._running=!0,qc.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let t=0;this._charts.forEach((n,r)=>{if(!n.running||!n.items.length)return;let i=n.items,a=i.length-1,o=!1,s;for(;a>=0;--a)s=i[a],s._active?(s._total>n.duration&&(n.duration=s._total),s.tick(e),o=!0):(i[a]=i[i.length-1],i.pop());o&&(r.draw(),this._notify(r,n,e,`progress`)),i.length||(n.running=!1,this._notify(r,n,e,`complete`),n.initial=!1),t+=i.length}),this._lastDate=e,t===0&&(this._running=!1)}_getAnims(e){let t=this._charts,n=t.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},t.set(e,n)),n}listen(e,t,n){this._getAnims(e).listeners[t].push(n)}add(e,t){!t||!t.length||this._getAnims(e).items.push(...t)}has(e){return this._getAnims(e).items.length>0}start(e){let t=this._charts.get(e);t&&(t.running=!0,t.start=Date.now(),t.duration=t.items.reduce((e,t)=>Math.max(e,t._duration),0),this._refresh())}running(e){if(!this._running)return!1;let t=this._charts.get(e);return!(!t||!t.running||!t.items.length)}stop(e){let t=this._charts.get(e);if(!t||!t.items.length)return;let n=t.items,r=n.length-1;for(;r>=0;--r)n[r].cancel();t.items=[],this._notify(e,t,Date.now(),`complete`)}remove(e){return this._charts.delete(e)}},hd=`transparent`,gd={boolean(e,t,n){return n>.5?t:e},color(e,t,n){let r=ol(e||hd),i=r.valid&&ol(t||hd);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}},_d=class{constructor(e,t,n,r){let i=t[n];r=Xl([e.to,r,i,e.from]);let a=Xl([e.from,i,r]);this._active=!0,this._fn=e.fn||gd[e.type||typeof a],this._easing=il[e.easing]||il.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=t,this._prop=n,this._from=a,this._to=r,this._promises=void 0}active(){return this._active}update(e,t,n){if(this._active){this._notify(!1);let r=this._target[this._prop],i=n-this._start,a=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(a,e.duration)),this._total+=i,this._loop=!!e.loop,this._to=Xl([e.to,t,r,e.from]),this._from=Xl([e.from,r,t])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){let t=e-this._start,n=this._duration,r=this._prop,i=this._from,a=this._loop,o=this._to,s;if(this._active=i!==o&&(a||t<n),!this._active){this._target[r]=o,this._notify(!0);return}if(t<0){this._target[r]=i;return}s=t/n%2,s=a&&s>1?2-s:s,s=this._easing(Math.min(1,Math.max(0,s))),this._target[r]=this._fn(i,o,s)}wait(){let e=this._promises||=[];return new Promise((t,n)=>{e.push({res:t,rej:n})})}_notify(e){let t=e?`res`:`rej`,n=this._promises||[];for(let e=0;e<n.length;e++)n[e][t]()}},vd=class{constructor(e,t){this._chart=e,this._properties=new Map,this.configure(t)}configure(e){if(!Y(e))return;let t=Object.keys(Cl.animation),n=this._properties;Object.getOwnPropertyNames(e).forEach(r=>{let i=e[r];if(!Y(i))return;let a={};for(let e of t)a[e]=i[e];(Gs(i.properties)&&i.properties||[r]).forEach(e=>{(e===r||!n.has(e))&&n.set(e,a)})})}_animateOptions(e,t){let n=t.options,r=bd(e,n);if(!r)return[];let i=this._createAnimations(r,n);return n.$shared&&yd(e.options.$animations,n).then(()=>{e.options=n},()=>{}),i}_createAnimations(e,t){let n=this._properties,r=[],i=e.$animations||={},a=Object.keys(t),o=Date.now(),s;for(s=a.length-1;s>=0;--s){let c=a[s];if(c.charAt(0)===`$`)continue;if(c===`options`){r.push(...this._animateOptions(e,t));continue}let l=t[c],u=i[c],d=n.get(c);if(u){if(d&&u.active()){u.update(d,l,o);continue}u.cancel()}if(!d||!d.duration){e[c]=l;continue}i[c]=u=new _d(d,e,c,l),r.push(u)}return r}update(e,t){if(this._properties.size===0){Object.assign(e,t);return}let n=this._createAnimations(e,t);if(n.length)return md.add(this._chart,n),!0}};function yd(e,t){let n=[],r=Object.keys(t);for(let t=0;t<r.length;t++){let i=e[r[t]];i&&i.active()&&n.push(i.wait())}return Promise.all(n)}function bd(e,t){if(!t)return;let n=e.options;if(!n){e.options=t;return}return n.$shared&&(e.options=n=Object.assign({},n,{$shared:!1,$animations:{}})),n}function xd(e,t){let n=e&&e.options||{},r=n.reverse,i=n.min===void 0?t:0,a=n.max===void 0?t:0;return{start:r?a:i,end:r?i:a}}function Sd(e,t,n){if(n===!1)return!1;let r=xd(e,n),i=xd(t,n);return{top:i.end,right:r.end,bottom:i.start,left:r.start}}function Cd(e){let t,n,r,i;return Y(e)?(t=e.top,n=e.right,r=e.bottom,i=e.left):t=n=r=i=e,{top:t,right:n,bottom:r,left:i,disabled:e===!1}}function wd(e,t){let n=[],r=e._getSortedDatasetMetas(t),i,a;for(i=0,a=r.length;i<a;++i)n.push(r[i].index);return n}function Td(e,t,n,r={}){let i=e.keys,a=r.mode===`single`,o,s,c,l;if(t===null)return;let u=!1;for(o=0,s=i.length;o<s;++o){if(c=+i[o],c===n){if(u=!0,r.all)continue;break}l=e.values[c],Ks(l)&&(a||t===0||bc(t)===bc(l))&&(t+=l)}return!u&&!r.all?0:t}function Ed(e,t){let{iScale:n,vScale:r}=t,i=n.axis===`x`?`x`:`y`,a=r.axis===`x`?`x`:`y`,o=Object.keys(e),s=Array(o.length),c,l,u;for(c=0,l=o.length;c<l;++c)u=o[c],s[c]={[i]:u,[a]:e[u]};return s}function Dd(e,t){let n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function Od(e,t,n){return`${e.id}.${t.id}.${n.stack||n.type}`}function kd(e){let{min:t,max:n,minDefined:r,maxDefined:i}=e.getUserBounds();return{min:r?t:-1/0,max:i?n:1/0}}function Ad(e,t,n){let r=e[t]||(e[t]={});return r[n]||(r[n]={})}function jd(e,t,n,r){for(let i of t.getMatchingVisibleMetas(r).reverse()){let t=e[i.index];if(n&&t>0||!n&&t<0)return i.index}return null}function Md(e,t){let{chart:n,_cachedMeta:r}=e,i=n._stacks||={},{iScale:a,vScale:o,index:s}=r,c=a.axis,l=o.axis,u=Od(a,o,r),d=t.length,f;for(let e=0;e<d;++e){let n=t[e],{[c]:a,[l]:d}=n,p=n._stacks||={};f=p[l]=Ad(i,u,a),f[s]=d,f._top=jd(f,o,!0,r.type),f._bottom=jd(f,o,!1,r.type);let m=f._visualValues||(f._visualValues={});m[s]=d}}function Nd(e,t){let n=e.scales;return Object.keys(n).filter(e=>n[e].axis===t).shift()}function Pd(e,t){return Ql(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:`default`,type:`dataset`})}function Fd(e,t,n){return Ql(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:`default`,type:`data`})}function Id(e,t){let n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t||=e._parsed;for(let e of t){let t=e._stacks;if(!t||t[r]===void 0||t[r][n]===void 0)return;delete t[r][n],t[r]._visualValues!==void 0&&t[r]._visualValues[n]!==void 0&&delete t[r]._visualValues[n]}}}var Ld=e=>e===`reset`||e===`none`,Rd=(e,t)=>t?e:Object.assign({},e),zd=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:wd(n,!0),values:null},Bd=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(e,t){this.chart=e,this._ctx=e.ctx,this.index=t,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.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=Dd(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled(`filler`)&&console.warn(`Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options`)}updateIndex(e){this.index!==e&&Id(this._cachedMeta),this.index=e}linkScales(){let e=this.chart,t=this._cachedMeta,n=this.getDataset(),r=(e,t,n,r)=>e===`x`?t:e===`r`?r:n,i=t.xAxisID=X(n.xAxisID,Nd(e,`x`)),a=t.yAxisID=X(n.yAxisID,Nd(e,`y`)),o=t.rAxisID=X(n.rAxisID,Nd(e,`r`)),s=t.indexAxis,c=t.iAxisID=r(s,i,a,o),l=t.vAxisID=r(s,a,i,o);t.xScale=this.getScaleForId(i),t.yScale=this.getScaleForId(a),t.rScale=this.getScaleForId(o),t.iScale=this.getScaleForId(c),t.vScale=this.getScaleForId(l)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){let t=this._cachedMeta;return e===t.iScale?t.vScale:t.iScale}reset(){this._update(`reset`)}_destroy(){let e=this._cachedMeta;this._data&&Gc(this._data,this),e._stacked&&Id(e)}_dataCheck(){let e=this.getDataset(),t=e.data||=[],n=this._data;if(Y(t)){let e=this._cachedMeta;this._data=Ed(t,e)}else if(n!==t){if(n){Gc(n,this);let e=this._cachedMeta;Id(e),e._parsed=[]}t&&Object.isExtensible(t)&&Wc(t,this),this._syncList=[],this._data=t}}addElements(){let e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){let t=this._cachedMeta,n=this.getDataset(),r=!1;this._dataCheck();let i=t._stacked;t._stacked=Dd(t.vScale,t),t.stack!==n.stack&&(r=!0,Id(t),t.stack=n.stack),this._resyncElements(e),(r||i!==t._stacked)&&(Md(this,t._parsed),t._stacked=Dd(t.vScale,t))}configure(){let e=this.chart.config,t=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),t,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,t){let{_cachedMeta:n,_data:r}=this,{iScale:i,_stacked:a}=n,o=i.axis,s=e===0&&t===r.length||n._sorted,c=e>0&&n._parsed[e-1],l,u,d;if(this._parsing===!1)n._parsed=r,n._sorted=!0,d=r;else{d=Gs(r[e])?this.parseArrayData(n,r,e,t):Y(r[e])?this.parseObjectData(n,r,e,t):this.parsePrimitiveData(n,r,e,t);let i=()=>u[o]===null||c&&u[o]<c[o];for(l=0;l<t;++l)n._parsed[l+e]=u=d[l],s&&(i()&&(s=!1),c=u);n._sorted=s}a&&Md(this,d)}parsePrimitiveData(e,t,n,r){let{iScale:i,vScale:a}=e,o=i.axis,s=a.axis,c=i.getLabels(),l=i===a,u=Array(r),d,f,p;for(d=0,f=r;d<f;++d)p=d+n,u[d]={[o]:l||i.parse(c[p],p),[s]:a.parse(t[p],p)};return u}parseArrayData(e,t,n,r){let{xScale:i,yScale:a}=e,o=Array(r),s,c,l,u;for(s=0,c=r;s<c;++s)l=s+n,u=t[l],o[s]={x:i.parse(u[0],l),y:a.parse(u[1],l)};return o}parseObjectData(e,t,n,r){let{xScale:i,yScale:a}=e,{xAxisKey:o=`x`,yAxisKey:s=`y`}=this._parsing,c=Array(r),l,u,d,f;for(l=0,u=r;l<u;++l)d=l+n,f=t[d],c[l]={x:i.parse(oc(f,o),d),y:a.parse(oc(f,s),d)};return c}getParsed(e){return this._cachedMeta._parsed[e]}getDataElement(e){return this._cachedMeta.data[e]}applyStack(e,t,n){let r=this.chart,i=this._cachedMeta,a=t[e.axis];return Td({keys:wd(r,!0),values:t._stacks[e.axis]._visualValues},a,i.index,{mode:n})}updateRangeFromParsed(e,t,n,r){let i=n[t.axis],a=i===null?NaN:i,o=r&&n._stacks[t.axis];r&&o&&(r.values=o,a=Td(r,i,this._cachedMeta.index)),e.min=Math.min(e.min,a),e.max=Math.max(e.max,a)}getMinMax(e,t){let n=this._cachedMeta,r=n._parsed,i=n._sorted&&e===n.iScale,a=r.length,o=this._getOtherScale(e),s=zd(t,n,this.chart),c={min:1/0,max:-1/0},{min:l,max:u}=kd(o),d,f;function p(){f=r[d];let t=f[o.axis];return!Ks(f[e.axis])||l>t||u<t}for(d=0;d<a&&!(!p()&&(this.updateRangeFromParsed(c,e,f,s),i));++d);if(i){for(d=a-1;d>=0;--d)if(!p()){this.updateRangeFromParsed(c,e,f,s);break}}return c}getAllParsedValues(e){let t=this._cachedMeta._parsed,n=[],r,i,a;for(r=0,i=t.length;r<i;++r)a=t[r][e.axis],Ks(a)&&n.push(a);return n}getMaxOverflow(){return!1}getLabelAndValue(e){let t=this._cachedMeta,n=t.iScale,r=t.vScale,i=this.getParsed(e);return{label:n?``+n.getLabelForValue(i[n.axis]):``,value:r?``+r.getLabelForValue(i[r.axis]):``}}_update(e){let t=this._cachedMeta;this.update(e||`default`),t._clip=Cd(X(this.options.clip,Sd(t.xScale,t.yScale,this.getMaxOverflow())))}update(e){}draw(){let e=this._ctx,t=this.chart,n=this._cachedMeta,r=n.data||[],i=t.chartArea,a=[],o=this._drawStart||0,s=this._drawCount||r.length-o,c=this.options.drawActiveElementsOnTop,l;for(n.dataset&&n.dataset.draw(e,i,o,s),l=o;l<o+s;++l){let t=r[l];t.hidden||(t.active&&c?a.push(t):t.draw(e,i))}for(l=0;l<a.length;++l)a[l].draw(e,i)}getStyle(e,t){let n=t?`active`:`default`;return e===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(n):this.resolveDataElementOptions(e||0,n)}getContext(e,t,n){let r=this.getDataset(),i;if(e>=0&&e<this._cachedMeta.data.length){let t=this._cachedMeta.data[e];i=t.$context||=Fd(this.getContext(),e,t),i.parsed=this.getParsed(e),i.raw=r.data[e],i.index=i.dataIndex=e}else i=this.$context||=Pd(this.chart.getContext(),this.index),i.dataset=r,i.index=i.datasetIndex=this.index;return i.active=!!t,i.mode=n,i}resolveDatasetElementOptions(e){return this._resolveElementOptions(this.datasetElementType.id,e)}resolveDataElementOptions(e,t){return this._resolveElementOptions(this.dataElementType.id,t,e)}_resolveElementOptions(e,t=`default`,n){let r=t===`active`,i=this._cachedDataOpts,a=e+`-`+t,o=i[a],s=this.enableOptionSharing&&cc(n);if(o)return Rd(o,s);let c=this.chart.config,l=c.datasetElementScopeKeys(this._type,e),u=r?[`${e}Hover`,`hover`,e,``]:[e,``],d=c.getOptionScopes(this.getDataset(),l),f=Object.keys(Cl.elements[e]),p=c.resolveNamedOptions(d,f,()=>this.getContext(n,r,t),u);return p.$shared&&(p.$shared=s,i[a]=Object.freeze(Rd(p,s))),p}_resolveAnimations(e,t,n){let r=this.chart,i=this._cachedDataOpts,a=`animation-${t}`,o=i[a];if(o)return o;let s;if(r.options.animation!==!1){let r=this.chart.config,i=r.datasetAnimationScopeKeys(this._type,t),a=r.getOptionScopes(this.getDataset(),i);s=r.createResolver(a,this.getContext(e,n,t))}let c=new vd(r,s&&s.animations);return s&&s._cacheable&&(i[a]=Object.freeze(c)),c}getSharedOptions(e){if(e.$shared)return this._sharedOptions||=Object.assign({},e)}includeOptions(e,t){return!t||Ld(e)||this.chart._animationsDisabled}_getSharedOptions(e,t){let n=this.resolveDataElementOptions(e,t),r=this._sharedOptions,i=this.getSharedOptions(n),a=this.includeOptions(t,i)||i!==r;return this.updateSharedOptions(i,t,n),{sharedOptions:i,includeOptions:a}}updateElement(e,t,n,r){Ld(r)?Object.assign(e,n):this._resolveAnimations(t,r).update(e,n)}updateSharedOptions(e,t,n){e&&!Ld(t)&&this._resolveAnimations(void 0,t).update(e,n)}_setStyle(e,t,n,r){e.active=r;let i=this.getStyle(t,r);this._resolveAnimations(t,n,r).update(e,{options:!r&&this.getSharedOptions(i)||i})}removeHoverStyle(e,t,n){this._setStyle(e,n,`active`,!1)}setHoverStyle(e,t,n){this._setStyle(e,n,`active`,!0)}_removeDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!1)}_setDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!0)}_resyncElements(e){let t=this._data,n=this._cachedMeta.data;for(let[e,t,n]of this._syncList)this[e](t,n);this._syncList=[];let r=n.length,i=t.length,a=Math.min(i,r);a&&this.parse(0,a),i>r?this._insertElements(r,i-r,e):i<r&&this._removeElements(i,r-i)}_insertElements(e,t,n=!0){let r=this._cachedMeta,i=r.data,a=e+t,o,s=e=>{for(e.length+=t,o=e.length-1;o>=a;o--)e[o]=e[o-t]};for(s(i),o=e;o<a;++o)i[o]=new this.dataElementType;this._parsing&&s(r._parsed),this.parse(e,t),n&&this.updateElements(i,e,t,`reset`)}updateElements(e,t,n,r){}_removeElements(e,t){let n=this._cachedMeta;if(this._parsing){let r=n._parsed.splice(e,t);n._stacked&&Id(n,r)}n.data.splice(e,t)}_sync(e){if(this._parsing)this._syncList.push(e);else{let[t,n,r]=e;this[t](n,r)}this.chart._dataChanges.push([this.index,...e])}_onDataPush(){let e=arguments.length;this._sync([`_insertElements`,this.getDataset().data.length-e,e])}_onDataPop(){this._sync([`_removeElements`,this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync([`_removeElements`,0,1])}_onDataSplice(e,t){t&&this._sync([`_removeElements`,e,t]);let n=arguments.length-2;n&&this._sync([`_insertElements`,e,n])}_onDataUnshift(){this._sync([`_insertElements`,0,arguments.length])}};function Vd(e,t){if(!e._cache.$bar){let n=e.getMatchingVisibleMetas(t),r=[];for(let t=0,i=n.length;t<i;t++)r=r.concat(n[t].controller.getAllParsedValues(e));e._cache.$bar=Kc(r.sort((e,t)=>e-t))}return e._cache.$bar}function Hd(e){let t=e.iScale,n=Vd(t,e.type),r=t._length,i,a,o,s,c=()=>{o!==32767&&o!==-32768&&(cc(s)&&(r=Math.min(r,Math.abs(o-s)||r)),s=o)};for(i=0,a=n.length;i<a;++i)o=t.getPixelForValue(n[i]),c();for(s=void 0,i=0,a=t.ticks.length;i<a;++i)o=t.getPixelForTick(i),c();return r}function Ud(e,t,n,r){let i=n.barThickness,a,o;return J(i)?(a=t.min*n.categoryPercentage,o=n.barPercentage):(a=i*r,o=1),{chunk:a/r,ratio:o,start:t.pixels[e]-a/2}}function Wd(e,t,n,r){let i=t.pixels,a=i[e],o=e>0?i[e-1]:null,s=e<i.length-1?i[e+1]:null,c=n.categoryPercentage;o===null&&(o=a-(s===null?t.end-t.start:s-a)),s===null&&(s=a+a-o);let l=a-(a-Math.min(o,s))/2*c;return{chunk:Math.abs(s-o)/2*c/r,ratio:n.barPercentage,start:l}}function Gd(e,t,n,r){let i=n.parse(e[0],r),a=n.parse(e[1],r),o=Math.min(i,a),s=Math.max(i,a),c=o,l=s;Math.abs(o)>Math.abs(s)&&(c=s,l=o),t[n.axis]=l,t._custom={barStart:c,barEnd:l,start:i,end:a,min:o,max:s}}function Kd(e,t,n,r){return Gs(e)?Gd(e,t,n,r):t[n.axis]=n.parse(e,r),t}function qd(e,t,n,r){let i=e.iScale,a=e.vScale,o=i.getLabels(),s=i===a,c=[],l,u,d,f;for(l=n,u=n+r;l<u;++l)f=t[l],d={},d[i.axis]=s||i.parse(o[l],l),c.push(Kd(f,d,a,l));return c}function Jd(e){return e&&e.barStart!==void 0&&e.barEnd!==void 0}function Yd(e,t,n){return e===0?(t.isHorizontal()?1:-1)*(t.min>=n?1:-1):bc(e)}function Xd(e){let t,n,r,i,a;return e.horizontal?(t=e.base>e.x,n=`left`,r=`right`):(t=e.base<e.y,n=`bottom`,r=`top`),t?(i=`end`,a=`start`):(i=`start`,a=`end`),{start:n,end:r,reverse:t,top:i,bottom:a}}function Zd(e,t,n,r){let i=t.borderSkipped,a={};if(!i){e.borderSkipped=a;return}if(i===!0){e.borderSkipped={top:!0,right:!0,bottom:!0,left:!0};return}let{start:o,end:s,reverse:c,top:l,bottom:u}=Xd(e);i===`middle`&&n&&(e.enableBorderRadius=!0,(n._top||0)===r?i=l:(n._bottom||0)===r?i=u:(a[Qd(u,o,s,c)]=!0,i=l)),a[Qd(i,o,s,c)]=!0,e.borderSkipped=a}function Qd(e,t,n,r){return r?(e=$d(e,t,n),e=ef(e,n,t)):e=ef(e,t,n),e}function $d(e,t,n){return e===t?n:e===n?t:e}function ef(e,t,n){return e===`start`?t:e===`end`?n:e}function tf(e,{inflateAmount:t},n){e.inflateAmount=t===`auto`?n===1?.33:0:t}var nf=class extends Bd{static id=`bar`;static defaults={datasetElementType:!1,dataElementType:`bar`,categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:`number`,properties:[`x`,`y`,`base`,`width`,`height`]}}};static overrides={scales:{_index_:{type:`category`,offset:!0,grid:{offset:!0}},_value_:{type:`linear`,beginAtZero:!0}}};parsePrimitiveData(e,t,n,r){return qd(e,t,n,r)}parseArrayData(e,t,n,r){return qd(e,t,n,r)}parseObjectData(e,t,n,r){let{iScale:i,vScale:a}=e,{xAxisKey:o=`x`,yAxisKey:s=`y`}=this._parsing,c=i.axis===`x`?o:s,l=a.axis===`x`?o:s,u=[],d,f,p,m;for(d=n,f=n+r;d<f;++d)m=t[d],p={},p[i.axis]=i.parse(oc(m,c),d),u.push(Kd(oc(m,l),p,a,d));return u}updateRangeFromParsed(e,t,n,r){super.updateRangeFromParsed(e,t,n,r);let i=n._custom;i&&t===this._cachedMeta.vScale&&(e.min=Math.min(e.min,i.min),e.max=Math.max(e.max,i.max))}getMaxOverflow(){return 0}getLabelAndValue(e){let{iScale:t,vScale:n}=this._cachedMeta,r=this.getParsed(e),i=r._custom,a=Jd(i)?`[`+i.start+`, `+i.end+`]`:``+n.getLabelForValue(r[n.axis]);return{label:``+t.getLabelForValue(r[t.axis]),value:a}}initialize(){this.enableOptionSharing=!0,super.initialize();let e=this._cachedMeta;e.stack=this.getDataset().stack}update(e){let t=this._cachedMeta;this.updateElements(t.data,0,t.data.length,e)}updateElements(e,t,n,r){let i=r===`reset`,{index:a,_cachedMeta:{vScale:o}}=this,s=o.getBasePixel(),c=o.isHorizontal(),l=this._getRuler(),{sharedOptions:u,includeOptions:d}=this._getSharedOptions(t,r);for(let f=t;f<t+n;f++){let t=this.getParsed(f),n=i||J(t[o.axis])?{base:s,head:s}:this._calculateBarValuePixels(f),p=this._calculateBarIndexPixels(f,l),m=(t._stacks||{})[o.axis],h={horizontal:c,base:n.base,enableBorderRadius:!m||Jd(t._custom)||a===m._top||a===m._bottom,x:c?n.head:p.center,y:c?p.center:n.head,height:c?p.size:Math.abs(n.size),width:c?Math.abs(n.size):p.size};d&&(h.options=u||this.resolveDataElementOptions(f,e[f].active?`active`:r));let g=h.options||e[f].options;Zd(h,g,m,a),tf(h,g,l.ratio),this.updateElement(e[f],f,h,r)}}_getStacks(e,t){let{iScale:n}=this._cachedMeta,r=n.getMatchingVisibleMetas(this._type).filter(e=>e.controller.options.grouped),i=n.options.stacked,a=[],o=this._cachedMeta.controller.getParsed(t),s=o&&o[n.axis],c=e=>{let t=e._parsed.find(e=>e[n.axis]===s),r=t&&t[e.vScale.axis];if(J(r)||isNaN(r))return!0};for(let n of r)if(!(t!==void 0&&c(n))&&((i===!1||a.indexOf(n.stack)===-1||i===void 0&&n.stack===void 0)&&a.push(n.stack),n.index===e))break;return a.length||a.push(void 0),a}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let e=this.chart.scales,t=this.chart.options.indexAxis;return Object.keys(e).filter(n=>e[n].axis===t).shift()}_getAxis(){let e={},t=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)e[X(this.chart.options.indexAxis===`x`?n.xAxisID:n.yAxisID,t)]=!0;return Object.keys(e)}_getStackIndex(e,t,n){let r=this._getStacks(e,n),i=t===void 0?-1:r.indexOf(t);return i===-1?r.length-1:i}_getRuler(){let e=this.options,t=this._cachedMeta,n=t.iScale,r=[],i,a;for(i=0,a=t.data.length;i<a;++i)r.push(n.getPixelForValue(this.getParsed(i)[n.axis],i));let o=e.barThickness;return{min:o||Hd(t),pixels:r,start:n._startPixel,end:n._endPixel,stackCount:this._getStackCount(),scale:n,grouped:e.grouped,ratio:o?1:e.categoryPercentage*e.barPercentage}}_calculateBarValuePixels(e){let{_cachedMeta:{vScale:t,_stacked:n,index:r},options:{base:i,minBarLength:a}}=this,o=i||0,s=this.getParsed(e),c=s._custom,l=Jd(c),u=s[t.axis],d=0,f=n?this.applyStack(t,s,n):u,p,m;f!==u&&(d=f-u,f=u),l&&(u=c.barStart,f=c.barEnd-c.barStart,u!==0&&bc(u)!==bc(c.barEnd)&&(d=0),d+=u);let h=!J(i)&&!l?i:d,g=t.getPixelForValue(h);if(p=this.chart.getDataVisibility(e)?t.getPixelForValue(d+f):g,m=p-g,Math.abs(m)<a){m=Yd(m,t,o)*a,u===o&&(g-=m/2);let e=t.getPixelForDecimal(0),i=t.getPixelForDecimal(1);g=Math.max(Math.min(g,Math.max(e,i)),Math.min(e,i)),p=g+m,n&&!l&&(s._stacks[t.axis]._visualValues[r]=t.getValueForPixel(p)-t.getValueForPixel(g))}if(g===t.getPixelForValue(o)){let e=bc(m)*t.getLineWidthForValue(o)/2;g+=e,m-=e}return{size:m,base:g,head:p,center:p+m/2}}_calculateBarIndexPixels(e,t){let n=t.scale,r=this.options,i=r.skipNull,a=X(r.maxBarThickness,1/0),o,s,c=this._getAxisCount();if(t.grouped){let n=i?this._getStackCount(e):t.stackCount,l=r.barThickness===`flex`?Wd(e,t,r,n*c):Ud(e,t,r,n*c),u=this.chart.options.indexAxis===`x`?this.getDataset().xAxisID:this.getDataset().yAxisID,d=this._getAxis().indexOf(X(u,this.getFirstScaleIdForIndexAxis())),f=this._getStackIndex(this.index,this._cachedMeta.stack,i?e:void 0)+d;o=l.start+l.chunk*f+l.chunk/2,s=Math.min(a,l.chunk*l.ratio)}else o=n.getPixelForValue(this.getParsed(e)[n.axis],e),s=Math.min(a,t.min*t.ratio);return{base:o-s/2,head:o+s/2,center:o,size:s}}draw(){let e=this._cachedMeta,t=e.vScale,n=e.data,r=n.length,i=0;for(;i<r;++i)this.getParsed(i)[t.axis]!==null&&!n[i].hidden&&n[i].draw(this._ctx)}},rf=class extends Bd{static id=`bubble`;static defaults={datasetElementType:!1,dataElementType:`point`,animations:{numbers:{type:`number`,properties:[`x`,`y`,`borderWidth`,`radius`]}}};static overrides={scales:{x:{type:`linear`},y:{type:`linear`}}};initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(e,t,n,r){let i=super.parsePrimitiveData(e,t,n,r);for(let e=0;e<i.length;e++)i[e]._custom=this.resolveDataElementOptions(e+n).radius;return i}parseArrayData(e,t,n,r){let i=super.parseArrayData(e,t,n,r);for(let e=0;e<i.length;e++){let r=t[n+e];i[e]._custom=X(r[2],this.resolveDataElementOptions(e+n).radius)}return i}parseObjectData(e,t,n,r){let i=super.parseObjectData(e,t,n,r);for(let e=0;e<i.length;e++){let r=t[n+e];i[e]._custom=X(r&&r.r&&+r.r,this.resolveDataElementOptions(e+n).radius)}return i}getMaxOverflow(){let e=this._cachedMeta.data,t=0;for(let n=e.length-1;n>=0;--n)t=Math.max(t,e[n].size(this.resolveDataElementOptions(n))/2);return t>0&&t}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:r,yScale:i}=t,a=this.getParsed(e),o=r.getLabelForValue(a.x),s=i.getLabelForValue(a.y),c=a._custom;return{label:n[e]||``,value:`(`+o+`, `+s+(c?`, `+c:``)+`)`}}update(e){let t=this._cachedMeta.data;this.updateElements(t,0,t.length,e)}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o}=this._cachedMeta,{sharedOptions:s,includeOptions:c}=this._getSharedOptions(t,r),l=a.axis,u=o.axis;for(let d=t;d<t+n;d++){let t=e[d],n=!i&&this.getParsed(d),f={},p=f[l]=i?a.getPixelForDecimal(.5):a.getPixelForValue(n[l]),m=f[u]=i?o.getBasePixel():o.getPixelForValue(n[u]);f.skip=isNaN(p)||isNaN(m),c&&(f.options=s||this.resolveDataElementOptions(d,t.active?`active`:r),i&&(f.options.radius=0)),this.updateElement(t,d,f,r)}}resolveDataElementOptions(e,t){let n=this.getParsed(e),r=super.resolveDataElementOptions(e,t);r.$shared&&(r=Object.assign({},r,{$shared:!1}));let i=r.radius;return t!==`active`&&(r.radius=0),r.radius+=X(n&&n._custom,i),r}};function af(e,t,n){let r=1,i=1,a=0,o=0;if(t<fc){let s=e,c=s+t,l=Math.cos(s),u=Math.sin(s),d=Math.cos(c),f=Math.sin(c),p=(e,t,r)=>Fc(e,s,c,!0)?1:Math.max(t,t*n,r,r*n),m=(e,t,r)=>Fc(e,s,c,!0)?-1:Math.min(t,t*n,r,r*n),h=p(0,l,d),g=p(gc,u,f),_=m($,l,d),v=m($+gc,u,f);r=(h-_)/2,i=(g-v)/2,a=-(h+_)/2,o=-(g+v)/2}return{ratioX:r,ratioY:i,offsetX:a,offsetY:o}}var of=class extends Bd{static id=`doughnut`;static 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`};static descriptors={_scriptable:e=>e!==`spacing`,_indexable:e=>e!==`spacing`&&!e.startsWith(`borderDash`)&&!e.startsWith(`hoverBorderDash`)};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data,{labels:{pointStyle:n,textAlign:r,color:i,useBorderRadius:a,borderRadius:o}}=e.legend.options;return t.labels.length&&t.datasets.length?t.labels.map((t,s)=>{let c=e.getDatasetMeta(0).controller.getStyle(s);return{text:t,fillStyle:c.backgroundColor,fontColor:i,hidden:!e.getDataVisibility(s),lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:c.borderWidth,strokeStyle:c.borderColor,textAlign:r,pointStyle:n,borderRadius:a&&(o||c.borderRadius),index:s}}):[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}}};constructor(e,t){super(e,t),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,t){let n=this.getDataset().data,r=this._cachedMeta;if(this._parsing===!1)r._parsed=n;else{let i=e=>+n[e];if(Y(n[e])){let{key:e=`value`}=this._parsing;i=t=>+oc(n[t],e)}let a,o;for(a=e,o=e+t;a<o;++a)r._parsed[a]=i(a)}}_getRotation(){return Oc(this.options.rotation-90)}_getCircumference(){return Oc(this.options.circumference)}_getRotationExtents(){let e=fc,t=-fc;for(let n=0;n<this.chart.data.datasets.length;++n)if(this.chart.isDatasetVisible(n)&&this.chart.getDatasetMeta(n).type===this._type){let r=this.chart.getDatasetMeta(n).controller,i=r._getRotation(),a=r._getCircumference();e=Math.min(e,i),t=Math.max(t,i+a)}return{rotation:e,circumference:t-e}}update(e){let{chartArea:t}=this.chart,n=this._cachedMeta,r=n.data,i=this.getMaxBorderWidth()+this.getMaxOffset(r)+this.options.spacing,a=Math.max((Math.min(t.width,t.height)-i)/2,0),o=Math.min(Js(this.options.cutout,a),1),s=this._getRingWeight(this.index),{circumference:c,rotation:l}=this._getRotationExtents(),{ratioX:u,ratioY:d,offsetX:f,offsetY:p}=af(l,c,o),m=(t.width-i)/u,h=(t.height-i)/d,g=Math.max(Math.min(m,h)/2,0),_=Ys(this.options.radius,g),v=(_-Math.max(_*o,0))/this._getVisibleDatasetWeightTotal();this.offsetX=f*_,this.offsetY=p*_,n.total=this.calculateTotal(),this.outerRadius=_-v*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-v*s,0),this.updateElements(r,0,r.length,e)}_circumference(e,t){let n=this.options,r=this._cachedMeta,i=this._getCircumference();return t&&n.animation.animateRotate||!this.chart.getDataVisibility(e)||r._parsed[e]===null||r.data[e].hidden?0:this.calculateCircumference(r._parsed[e]*i/fc)}updateElements(e,t,n,r){let i=r===`reset`,a=this.chart,o=a.chartArea,s=a.options.animation,c=(o.left+o.right)/2,l=(o.top+o.bottom)/2,u=i&&s.animateScale,d=u?0:this.innerRadius,f=u?0:this.outerRadius,{sharedOptions:p,includeOptions:m}=this._getSharedOptions(t,r),h=this._getRotation(),g;for(g=0;g<t;++g)h+=this._circumference(g,i);for(g=t;g<t+n;++g){let t=this._circumference(g,i),n=e[g],a={x:c+this.offsetX,y:l+this.offsetY,startAngle:h,endAngle:h+t,circumference:t,outerRadius:f,innerRadius:d};m&&(a.options=p||this.resolveDataElementOptions(g,n.active?`active`:r)),h+=t,this.updateElement(n,g,a,r)}}calculateTotal(){let e=this._cachedMeta,t=e.data,n=0,r;for(r=0;r<t.length;r++){let i=e._parsed[r];i!==null&&!isNaN(i)&&this.chart.getDataVisibility(r)&&!t[r].hidden&&(n+=Math.abs(i))}return n}calculateCircumference(e){let t=this._cachedMeta.total;return t>0&&!isNaN(e)?Math.abs(e)/t*fc:0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=ml(t._parsed[e],n.options.locale);return{label:r[e]||``,value:i}}getMaxBorderWidth(e){let t=0,n=this.chart,r,i,a,o,s;if(!e){for(r=0,i=n.data.datasets.length;r<i;++r)if(n.isDatasetVisible(r)){a=n.getDatasetMeta(r),e=a.data,o=a.controller;break}}if(!e)return 0;for(r=0,i=e.length;r<i;++r)s=o.resolveDataElementOptions(r),s.borderAlign!==`inner`&&(t=Math.max(t,s.borderWidth||0,s.hoverBorderWidth||0));return t}getMaxOffset(e){let t=0;for(let n=0,r=e.length;n<r;++n){let e=this.resolveDataElementOptions(n);t=Math.max(t,e.offset||0,e.hoverOffset||0)}return t}_getRingWeightOffset(e){let t=0;for(let n=0;n<e;++n)this.chart.isDatasetVisible(n)&&(t+=this._getRingWeight(n));return t}_getRingWeight(e){return Math.max(X(this.chart.data.datasets[e].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}},sf=class extends Bd{static id=`line`;static defaults={datasetElementType:`line`,dataElementType:`point`,showLine:!0,spanGaps:!1};static overrides={scales:{_index_:{type:`category`},_value_:{type:`linear`}}};initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(e){let t=this._cachedMeta,{dataset:n,data:r=[],_dataset:i}=t,a=this.chart._animationsDisabled,{start:o,count:s}=$c(t,r,a);this._drawStart=o,this._drawCount=s,el(t)&&(o=0,s=r.length),n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!i._decimated,n.points=r;let c=this.resolveDatasetElementOptions(e);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(n,void 0,{animated:!a,options:c},e),this.updateElements(r,o,s,e)}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o,_stacked:s,_dataset:c}=this._cachedMeta,{sharedOptions:l,includeOptions:u}=this._getSharedOptions(t,r),d=a.axis,f=o.axis,{spanGaps:p,segment:m}=this.options,h=Tc(p)?p:1/0,g=this.chart._animationsDisabled||i||r===`none`,_=t+n,v=e.length,y=t>0&&this.getParsed(t-1);for(let n=0;n<v;++n){let p=e[n],v=g?p:{};if(n<t||n>=_){v.skip=!0;continue}let b=this.getParsed(n),x=J(b[f]),S=v[d]=a.getPixelForValue(b[d],n),C=v[f]=i||x?o.getBasePixel():o.getPixelForValue(s?this.applyStack(o,b,s):b[f],n);v.skip=isNaN(S)||isNaN(C)||x,v.stop=n>0&&Math.abs(b[d]-y[d])>h,m&&(v.parsed=b,v.raw=c.data[n]),u&&(v.options=l||this.resolveDataElementOptions(n,p.active?`active`:r)),g||this.updateElement(p,n,v,r),y=b}}getMaxOverflow(){let e=this._cachedMeta,t=e.dataset,n=t.options&&t.options.borderWidth||0,r=e.data||[];if(!r.length)return n;let i=r[0].size(this.resolveDataElementOptions(0)),a=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(n,i,a)/2}draw(){let e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}},cf=class extends Bd{static id=`polarArea`;static defaults={dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:`number`,properties:[`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`]}},indexAxis:`r`,startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data;if(t.labels.length&&t.datasets.length){let{labels:{pointStyle:n,color:r}}=e.legend.options;return t.labels.map((t,i)=>{let a=e.getDatasetMeta(0).controller.getStyle(i);return{text:t,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,fontColor:r,lineWidth:a.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(i),index:i}})}return[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}},scales:{r:{type:`radialLinear`,angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(e,t){super(e,t),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=ml(t._parsed[e].r,n.options.locale);return{label:r[e]||``,value:i}}parseObjectData(e,t,n,r){return vu.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta.data;this._updateRadius(),this.updateElements(t,0,t.length,e)}getMinMax(){let e=this._cachedMeta,t={min:1/0,max:-1/0};return e.data.forEach((e,n)=>{let r=this.getParsed(n).r;!isNaN(r)&&this.chart.getDataVisibility(n)&&(r<t.min&&(t.min=r),r>t.max&&(t.max=r))}),t}_updateRadius(){let e=this.chart,t=e.chartArea,n=e.options,r=Math.min(t.right-t.left,t.bottom-t.top),i=Math.max(r/2,0),a=(i-Math.max(n.cutoutPercentage?i/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();this.outerRadius=i-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(e,t,n,r){let i=r===`reset`,a=this.chart,o=a.options.animation,s=this._cachedMeta.rScale,c=s.xCenter,l=s.yCenter,u=s.getIndexAngle(0)-.5*$,d=u,f,p=360/this.countVisibleElements();for(f=0;f<t;++f)d+=this._computeAngle(f,r,p);for(f=t;f<t+n;f++){let t=e[f],n=d,m=d+this._computeAngle(f,r,p),h=a.getDataVisibility(f)?s.getDistanceFromCenterForValue(this.getParsed(f).r):0;d=m,i&&(o.animateScale&&(h=0),o.animateRotate&&(n=m=u));let g={x:c,y:l,innerRadius:0,outerRadius:h,startAngle:n,endAngle:m,options:this.resolveDataElementOptions(f,t.active?`active`:r)};this.updateElement(t,f,g,r)}}countVisibleElements(){let e=this._cachedMeta,t=0;return e.data.forEach((e,n)=>{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&t++}),t}_computeAngle(e,t,n){return this.chart.getDataVisibility(e)?Oc(this.resolveDataElementOptions(e,t).angle||n):0}},lf=Object.freeze({__proto__:null,BarController:nf,BubbleController:rf,DoughnutController:of,LineController:sf,PieController:class extends of{static id=`pie`;static defaults={cutout:0,rotation:0,circumference:360,radius:`100%`}},PolarAreaController:cf,RadarController:class extends Bd{static id=`radar`;static defaults={datasetElementType:`line`,dataElementType:`point`,indexAxis:`r`,showLine:!0,elements:{line:{fill:`start`}}};static overrides={aspectRatio:1,scales:{r:{type:`radialLinear`}}};getLabelAndValue(e){let t=this._cachedMeta.vScale,n=this.getParsed(e);return{label:t.getLabels()[e],value:``+t.getLabelForValue(n[t.axis])}}parseObjectData(e,t,n,r){return vu.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta,n=t.dataset,r=t.data||[],i=t.iScale.getLabels();if(n.points=r,e!==`resize`){let t=this.resolveDatasetElementOptions(e);this.options.showLine||(t.borderWidth=0);let a={_loop:!0,_fullLoop:i.length===r.length,options:t};this.updateElement(n,void 0,a,e)}this.updateElements(r,0,r.length,e)}updateElements(e,t,n,r){let i=this._cachedMeta.rScale,a=r===`reset`;for(let o=t;o<t+n;o++){let t=e[o],n=this.resolveDataElementOptions(o,t.active?`active`:r),s=i.getPointPositionForValue(o,this.getParsed(o).r),c=a?i.xCenter:s.x,l=a?i.yCenter:s.y,u={x:c,y:l,angle:s.angle,skip:isNaN(c)||isNaN(l),options:n};this.updateElement(t,o,u,r)}}},ScatterController:class extends Bd{static id=`scatter`;static defaults={datasetElementType:!1,dataElementType:`point`,showLine:!1,fill:!1};static overrides={interaction:{mode:`point`},scales:{x:{type:`linear`},y:{type:`linear`}}};getLabelAndValue(e){let t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:r,yScale:i}=t,a=this.getParsed(e),o=r.getLabelForValue(a.x),s=i.getLabelForValue(a.y);return{label:n[e]||``,value:`(`+o+`, `+s+`)`}}update(e){let t=this._cachedMeta,{data:n=[]}=t,r=this.chart._animationsDisabled,{start:i,count:a}=$c(t,n,r);if(this._drawStart=i,this._drawCount=a,el(t)&&(i=0,a=n.length),this.options.showLine){this.datasetElementType||this.addElements();let{dataset:i,_dataset:a}=t;i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!a._decimated,i.points=n;let o=this.resolveDatasetElementOptions(e);o.segment=this.options.segment,this.updateElement(i,void 0,{animated:!r,options:o},e)}else this.datasetElementType&&=(delete t.dataset,!1);this.updateElements(n,i,a,e)}addElements(){let{showLine:e}=this.options;!this.datasetElementType&&e&&(this.datasetElementType=this.chart.registry.getElement(`line`)),super.addElements()}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o,_stacked:s,_dataset:c}=this._cachedMeta,l=this.resolveDataElementOptions(t,r),u=this.getSharedOptions(l),d=this.includeOptions(r,u),f=a.axis,p=o.axis,{spanGaps:m,segment:h}=this.options,g=Tc(m)?m:1/0,_=this.chart._animationsDisabled||i||r===`none`,v=t>0&&this.getParsed(t-1);for(let l=t;l<t+n;++l){let t=e[l],n=this.getParsed(l),m=_?t:{},y=J(n[p]),b=m[f]=a.getPixelForValue(n[f],l),x=m[p]=i||y?o.getBasePixel():o.getPixelForValue(s?this.applyStack(o,n,s):n[p],l);m.skip=isNaN(b)||isNaN(x)||y,m.stop=l>0&&Math.abs(n[f]-v[f])>g,h&&(m.parsed=n,m.raw=c.data[l]),d&&(m.options=u||this.resolveDataElementOptions(l,t.active?`active`:r)),_||this.updateElement(t,l,m,r),v=n}this.updateSharedOptions(u,r,l)}getMaxOverflow(){let e=this._cachedMeta,t=e.data||[];if(!this.options.showLine){let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}let n=e.dataset,r=n.options&&n.options.borderWidth||0;if(!t.length)return r;let i=t[0].size(this.resolveDataElementOptions(0)),a=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(r,i,a)/2}}});function uf(){throw Error(`This method is not implemented: Check that a complete date adapter is provided.`)}var df={_date:class e{static override(t){Object.assign(e.prototype,t)}options;constructor(e){this.options=e||{}}init(){}formats(){return uf()}parse(){return uf()}format(){return uf()}add(){return uf()}diff(){return uf()}startOf(){return uf()}endOf(){return uf()}}};function ff(e,t,n,r){let{controller:i,data:a,_sorted:o}=e,s=i._cachedMeta.iScale,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(s&&t===s.axis&&t!==`r`&&o&&a.length){let o=s._reversePixels?Vc:Bc;if(!r){let r=o(a,t,n);if(c){let{vScale:t}=i._cachedMeta,{_parsed:n}=e,a=n.slice(0,r.lo+1).reverse().findIndex(e=>!J(e[t.axis]));r.lo-=Math.max(0,a);let o=n.slice(r.hi).findIndex(e=>!J(e[t.axis]));r.hi+=Math.max(0,o)}return r}if(i._sharedOptions){let e=a[0],r=typeof e.getRange==`function`&&e.getRange(t);if(r){let e=o(a,t,n-r),i=o(a,t,n+r);return{lo:e.lo,hi:i.hi}}}}return{lo:0,hi:a.length-1}}function pf(e,t,n,r,i){let a=e.getSortedVisibleDatasetMetas(),o=n[t];for(let e=0,n=a.length;e<n;++e){let{index:n,data:s}=a[e],{lo:c,hi:l}=ff(a[e],t,o,i);for(let e=c;e<=l;++e){let t=s[e];t.skip||r(t,n,e)}}}function mf(e){let t=e.indexOf(`x`)!==-1,n=e.indexOf(`y`)!==-1;return function(e,r){let i=t?Math.abs(e.x-r.x):0,a=n?Math.abs(e.y-r.y):0;return Math.sqrt(i**2+a**2)}}function hf(e,t,n,r,i){let a=[];return!i&&!e.isPointInArea(t)||pf(e,n,t,function(n,o,s){!i&&!jl(n,e.chartArea,0)||n.inRange(t.x,t.y,r)&&a.push({element:n,datasetIndex:o,index:s})},!0),a}function gf(e,t,n,r){let i=[];function a(e,n,a){let{startAngle:o,endAngle:s}=e.getProps([`startAngle`,`endAngle`],r),{angle:c}=jc(e,{x:t.x,y:t.y});Fc(c,o,s)&&i.push({element:e,datasetIndex:n,index:a})}return pf(e,n,t,a),i}function _f(e,t,n,r,i,a){let o=[],s=mf(n),c=1/0;function l(n,l,u){let d=n.inRange(t.x,t.y,i);if(r&&!d)return;let f=n.getCenterPoint(i);if(!(a||e.isPointInArea(f))&&!d)return;let p=s(t,f);p<c?(o=[{element:n,datasetIndex:l,index:u}],c=p):p===c&&o.push({element:n,datasetIndex:l,index:u})}return pf(e,n,t,l),o}function vf(e,t,n,r,i,a){return!a&&!e.isPointInArea(t)?[]:n===`r`&&!r?gf(e,t,n,i):_f(e,t,n,r,i,a)}function yf(e,t,n,r,i){let a=[],o=n===`x`?`inXRange`:`inYRange`,s=!1;return pf(e,n,t,(e,r,c)=>{e[o]&&e[o](t[n],i)&&(a.push({element:e,datasetIndex:r,index:c}),s||=e.inRange(t.x,t.y,i))}),r&&!s?[]:a}var bf={evaluateInteractionItems:pf,modes:{index(e,t,n,r){let i=Ru(t,e),a=n.axis||`x`,o=n.includeInvisible||!1,s=n.intersect?hf(e,i,a,r,o):vf(e,i,a,!1,r,o),c=[];return s.length?(e.getSortedVisibleDatasetMetas().forEach(e=>{let t=s[0].index,n=e.data[t];n&&!n.skip&&c.push({element:n,datasetIndex:e.index,index:t})}),c):[]},dataset(e,t,n,r){let i=Ru(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1,s=n.intersect?hf(e,i,a,r,o):vf(e,i,a,!1,r,o);if(s.length>0){let t=s[0].datasetIndex,n=e.getDatasetMeta(t).data;s=[];for(let e=0;e<n.length;++e)s.push({element:n[e],datasetIndex:t,index:e})}return s},point(e,t,n,r){return hf(e,Ru(t,e),n.axis||`xy`,r,n.includeInvisible||!1)},nearest(e,t,n,r){let i=Ru(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1;return vf(e,i,a,n.intersect,r,o)},x(e,t,n,r){return yf(e,Ru(t,e),`x`,n.intersect,r)},y(e,t,n,r){return yf(e,Ru(t,e),`y`,n.intersect,r)}}},xf=[`left`,`top`,`right`,`bottom`];function Sf(e,t){return e.filter(e=>e.pos===t)}function Cf(e,t){return e.filter(e=>xf.indexOf(e.pos)===-1&&e.box.axis===t)}function wf(e,t){return e.sort((e,n)=>{let r=t?n:e,i=t?e:n;return r.weight===i.weight?r.index-i.index:r.weight-i.weight})}function Tf(e){let t=[],n,r,i,a,o,s;for(n=0,r=(e||[]).length;n<r;++n)i=e[n],{position:a,options:{stack:o,stackWeight:s=1}}=i,t.push({index:n,box:i,pos:a,horizontal:i.isHorizontal(),weight:i.weight,stack:o&&a+o,stackWeight:s});return t}function Ef(e){let t={};for(let n of e){let{stack:e,pos:r,stackWeight:i}=n;if(!e||!xf.includes(r))continue;let a=t[e]||(t[e]={count:0,placed:0,weight:0,size:0});a.count++,a.weight+=i}return t}function Df(e,t){let n=Ef(e),{vBoxMaxWidth:r,hBoxMaxHeight:i}=t,a,o,s;for(a=0,o=e.length;a<o;++a){s=e[a];let{fullSize:o}=s.box,c=n[s.stack],l=c&&s.stackWeight/c.weight;s.horizontal?(s.width=l?l*r:o&&t.availableWidth,s.height=i):(s.width=r,s.height=l?l*i:o&&t.availableHeight)}return n}function Of(e){let t=Tf(e),n=wf(t.filter(e=>e.box.fullSize),!0),r=wf(Sf(t,`left`),!0),i=wf(Sf(t,`right`)),a=wf(Sf(t,`top`),!0),o=wf(Sf(t,`bottom`)),s=Cf(t,`x`),c=Cf(t,`y`);return{fullSize:n,leftAndTop:r.concat(a),rightAndBottom:i.concat(c).concat(o).concat(s),chartArea:Sf(t,`chartArea`),vertical:r.concat(i).concat(c),horizontal:a.concat(o).concat(s)}}function kf(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function Af(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function jf(e,t,n,r){let{pos:i,box:a}=n,o=e.maxPadding;if(!Y(i)){n.size&&(e[i]-=n.size);let t=r[n.stack]||{size:0,count:1};t.size=Math.max(t.size,n.horizontal?a.height:a.width),n.size=t.size/t.count,e[i]+=n.size}a.getPadding&&Af(o,a.getPadding());let s=Math.max(0,t.outerWidth-kf(o,e,`left`,`right`)),c=Math.max(0,t.outerHeight-kf(o,e,`top`,`bottom`)),l=s!==e.w,u=c!==e.h;return e.w=s,e.h=c,n.horizontal?{same:l,other:u}:{same:u,other:l}}function Mf(e){let t=e.maxPadding;function n(n){let r=Math.max(t[n]-e[n],0);return e[n]+=r,r}e.y+=n(`top`),e.x+=n(`left`),n(`right`),n(`bottom`)}function Nf(e,t){let n=t.maxPadding;function r(e){let r={left:0,top:0,right:0,bottom:0};return e.forEach(e=>{r[e]=Math.max(t[e],n[e])}),r}return r(e?[`left`,`right`]:[`top`,`bottom`])}function Pf(e,t,n,r){let i=[],a,o,s,c,l,u;for(a=0,o=e.length,l=0;a<o;++a){s=e[a],c=s.box,c.update(s.width||t.w,s.height||t.h,Nf(s.horizontal,t));let{same:o,other:d}=jf(t,n,s,r);l|=o&&i.length,u||=d,c.fullSize||i.push(s)}return l&&Pf(i,t,n,r)||u}function Ff(e,t,n,r,i){e.top=n,e.left=t,e.right=t+r,e.bottom=n+i,e.width=r,e.height=i}function If(e,t,n,r){let i=n.padding,{x:a,y:o}=t;for(let s of e){let e=s.box,c=r[s.stack]||{count:1,placed:0,weight:1},l=s.stackWeight/c.weight||1;if(s.horizontal){let r=t.w*l,a=c.size||e.height;cc(c.start)&&(o=c.start),e.fullSize?Ff(e,i.left,o,n.outerWidth-i.right-i.left,a):Ff(e,t.left+c.placed,o,r,a),c.start=o,c.placed+=r,o=e.bottom}else{let r=t.h*l,o=c.size||e.width;cc(c.start)&&(a=c.start),e.fullSize?Ff(e,a,i.top,o,n.outerHeight-i.bottom-i.top):Ff(e,a,t.top+c.placed,o,r),c.start=a,c.placed+=r,a=e.right}}t.x=a,t.y=o}var Lf={addBox(e,t){e.boxes||=[],t.fullSize=t.fullSize||!1,t.position=t.position||`top`,t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(e){t.draw(e)}}]},e.boxes.push(t)},removeBox(e,t){let n=e.boxes?e.boxes.indexOf(t):-1;n!==-1&&e.boxes.splice(n,1)},configure(e,t,n){t.fullSize=n.fullSize,t.position=n.position,t.weight=n.weight},update(e,t,n,r){if(!e)return;let i=Jl(e.options.layout.padding),a=Math.max(t-i.width,0),o=Math.max(n-i.height,0),s=Of(e.boxes),c=s.vertical,l=s.horizontal;Q(e.boxes,e=>{typeof e.beforeLayout==`function`&&e.beforeLayout()});let u=c.reduce((e,t)=>t.box.options&&t.box.options.display===!1?e:e+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:a,availableHeight:o,vBoxMaxWidth:a/2/u,hBoxMaxHeight:o/2}),f=Object.assign({},i);Af(f,Jl(r));let p=Object.assign({maxPadding:f,w:a,h:o,x:i.left,y:i.top},i),m=Df(c.concat(l),d);Pf(s.fullSize,p,d,m),Pf(c,p,d,m),Pf(l,p,d,m)&&Pf(c,p,d,m),Mf(p),If(s.leftAndTop,p,d,m),p.x+=p.w,p.y+=p.h,If(s.rightAndBottom,p,d,m),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},Q(s.chartArea,t=>{let n=t.box;Object.assign(n,e.chartArea),n.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}},Rf=class{acquireContext(e,t){}releaseContext(e){return!1}addEventListener(e,t,n){}removeEventListener(e,t,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,t,n,r){return t=Math.max(0,t||e.width),n||=e.height,{width:t,height:Math.max(0,r?Math.floor(t/r):n)}}isAttached(e){return!0}updateConfig(e){}},zf=class extends Rf{acquireContext(e){return e&&e.getContext&&e.getContext(`2d`)||null}updateConfig(e){e.options.animation=!1}},Bf=`$chartjs`,Vf={touchstart:`mousedown`,touchmove:`mousemove`,touchend:`mouseup`,pointerenter:`mouseenter`,pointerdown:`mousedown`,pointermove:`mousemove`,pointerup:`mouseup`,pointerleave:`mouseout`,pointerout:`mouseout`},Hf=e=>e===null||e===``;function Uf(e,t){let n=e.style,r=e.getAttribute(`height`),i=e.getAttribute(`width`);if(e[Bf]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||`block`,n.boxSizing=n.boxSizing||`border-box`,Hf(i)){let t=Wu(e,`width`);t!==void 0&&(e.width=t)}if(Hf(r)){if(e.style.height===``)e.height=e.width/(t||2);else{let t=Wu(e,`height`);t!==void 0&&(e.height=t)}}return e}var Wf=Uu?{passive:!0}:!1;function Gf(e,t,n){e&&e.addEventListener(t,n,Wf)}function Kf(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,Wf)}function qf(e,t){let n=Vf[e.type]||e.type,{x:r,y:i}=Ru(e,t);return{type:n,chart:t,native:e,x:r===void 0?null:r,y:i===void 0?null:i}}function Jf(e,t){for(let n of e)if(n===t||n.contains(t))return!0}function Yf(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=Jf(n.addedNodes,r),t&&=!Jf(n.removedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function Xf(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=Jf(n.removedNodes,r),t&&=!Jf(n.addedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}var Zf=new Map,Qf=0;function $f(){let e=window.devicePixelRatio;e!==Qf&&(Qf=e,Zf.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function ep(e,t){Zf.size||window.addEventListener(`resize`,$f),Zf.set(e,t)}function tp(e){Zf.delete(e),Zf.size||window.removeEventListener(`resize`,$f)}function np(e,t,n){let r=e.canvas,i=r&&Au(r);if(!i)return;let a=Jc((e,t)=>{let r=i.clientWidth;n(e,t),r<i.clientWidth&&n()},window),o=new ResizeObserver(e=>{let t=e[0],n=t.contentRect.width,r=t.contentRect.height;(n!==0||r!==0)&&a(n,r)});return o.observe(i),ep(e,a),o}function rp(e,t,n){n&&n.disconnect(),t===`resize`&&tp(e)}function ip(e,t,n){let r=e.canvas,i=Jc(t=>{e.ctx!==null&&n(qf(t,e))},e);return Gf(r,t,i),i}var ap=class extends Rf{acquireContext(e,t){let n=e&&e.getContext&&e.getContext(`2d`);return n&&n.canvas===e?(Uf(e,t),n):null}releaseContext(e){let t=e.canvas;if(!t[Bf])return!1;let n=t[Bf].initial;[`height`,`width`].forEach(e=>{let r=n[e];J(r)?t.removeAttribute(e):t.setAttribute(e,r)});let r=n.style||{};return Object.keys(r).forEach(e=>{t.style[e]=r[e]}),t.width=t.width,delete t[Bf],!0}addEventListener(e,t,n){this.removeEventListener(e,t);let r=e.$proxies||={};r[t]=({attach:Yf,detach:Xf,resize:np}[t]||ip)(e,t,n)}removeEventListener(e,t){let n=e.$proxies||={},r=n[t];r&&(({attach:rp,detach:rp,resize:rp}[t]||Kf)(e,t,r),n[t]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,r){return Vu(e,t,n,r)}isAttached(e){let t=e&&Au(e);return!!(t&&t.isConnected)}};function op(e){return!ku()||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?zf:ap}var sp=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}hasValue(){return Tc(this.x)&&Tc(this.y)}getProps(e,t){let n=this.$animations;if(!t||!n)return this;let r={};return e.forEach(e=>{r[e]=n[e]&&n[e].active()?n[e]._to:this[e]}),r}};function cp(e,t){let n=e.options.ticks,r=lp(e),i=Math.min(n.maxTicksLimit||r,r),a=n.major.enabled?dp(t):[],o=a.length,s=a[0],c=a[o-1],l=[];if(o>i)return fp(t,l,a,o/i),l;let u=up(a,t,i);if(o>0){let e,n,r=o>1?Math.round((c-s)/(o-1)):null;for(pp(t,l,u,J(r)?0:s-r,s),e=0,n=o-1;e<n;e++)pp(t,l,u,a[e],a[e+1]);return pp(t,l,u,c,J(r)?t.length:c+r),l}return pp(t,l,u),l}function lp(e){let t=e.options.offset,n=e._tickSize(),r=e._length/n+ +!t,i=e._maxLength/n;return Math.floor(Math.min(r,i))}function up(e,t,n){let r=mp(e),i=t.length/n;if(!r)return Math.max(i,1);let a=Cc(r);for(let e=0,t=a.length-1;e<t;e++){let t=a[e];if(t>i)return t}return Math.max(i,1)}function dp(e){let t=[],n,r;for(n=0,r=e.length;n<r;n++)e[n].major&&t.push(n);return t}function fp(e,t,n,r){let i=0,a=n[0],o;for(r=Math.ceil(r),o=0;o<e.length;o++)o===a&&(t.push(e[o]),i++,a=n[i*r])}function pp(e,t,n,r,i){let a=X(r,0),o=Math.min(X(i,e.length),e.length),s=0,c,l,u;for(n=Math.ceil(n),i&&(c=i-r,n=c/Math.floor(c/n)),u=a;u<0;)s++,u=Math.round(a+s*n);for(l=Math.max(a,0);l<o;l++)l===u&&(t.push(e[l]),s++,u=Math.round(a+s*n))}function mp(e){let t=e.length,n,r;if(t<2)return!1;for(r=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==r)return!1;return r}var hp=e=>e===`left`?`right`:e===`right`?`left`:e,gp=(e,t,n)=>t===`top`||t===`left`?e[t]+n:e[t]-n,_p=(e,t)=>Math.min(t||e,e);function vp(e,t){let n=[],r=e.length/t,i=e.length,a=0;for(;a<i;a+=r)n.push(e[Math.floor(a)]);return n}function yp(e,t,n){let r=e.ticks.length,i=Math.min(t,r-1),a=e._startPixel,o=e._endPixel,s=1e-6,c=e.getPixelForTick(i),l;if(!(n&&(l=r===1?Math.max(c-a,o-c):t===0?(e.getPixelForTick(1)-c)/2:(c-e.getPixelForTick(i-1))/2,c+=i<t?l:-l,c<a-s||c>o+s)))return c}function bp(e,t){Q(e,e=>{let n=e.gc,r=n.length/2,i;if(r>t){for(i=0;i<r;++i)delete e.data[n[i]];n.splice(0,r)}})}function xp(e){return e.drawTicks?e.tickLength:0}function Sp(e,t){if(!e.display)return 0;let n=Yl(e.font,t),r=Jl(e.padding);return(Gs(e.text)?e.text.length:1)*n.lineHeight+r.height}function Cp(e,t){return Ql(e,{scale:t,type:`scale`})}function wp(e,t,n){return Ql(e,{tick:n,index:t,type:`tick`})}function Tp(e,t,n){let r=Xc(e);return(n&&t!==`right`||!n&&t===`right`)&&(r=hp(r)),r}function Ep(e,t,n,r){let{top:i,left:a,bottom:o,right:s,chart:c}=e,{chartArea:l,scales:u}=c,d=0,f,p,m,h=o-i,g=s-a;if(e.isHorizontal()){if(p=Zc(r,a,s),Y(n)){let e=Object.keys(n)[0],r=n[e];m=u[e].getPixelForValue(r)+h-t}else m=n===`center`?(l.bottom+l.top)/2+h-t:gp(e,n,t);f=s-a}else{if(Y(n)){let e=Object.keys(n)[0],r=n[e];p=u[e].getPixelForValue(r)-g+t}else p=n===`center`?(l.left+l.right)/2-g+t:gp(e,n,t);m=Zc(r,o,i),d=n===`left`?-gc:gc}return{titleX:p,titleY:m,maxWidth:f,rotation:d}}var Dp=class e extends sp{constructor(e){super(),this.id=e.id,this.type=e.type,this.options=void 0,this.ctx=e.ctx,this.chart=e.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(e){this.options=e.setContext(this.getContext()),this.axis=e.axis,this._userMin=this.parse(e.min),this._userMax=this.parse(e.max),this._suggestedMin=this.parse(e.suggestedMin),this._suggestedMax=this.parse(e.suggestedMax)}parse(e,t){return e}getUserBounds(){let{_userMin:e,_userMax:t,_suggestedMin:n,_suggestedMax:r}=this;return e=qs(e,1/0),t=qs(t,-1/0),n=qs(n,1/0),r=qs(r,-1/0),{min:qs(e,n),max:qs(t,r),minDefined:Ks(e),maxDefined:Ks(t)}}getMinMax(e){let{min:t,max:n,minDefined:r,maxDefined:i}=this.getUserBounds(),a;if(r&&i)return{min:t,max:n};let o=this.getMatchingVisibleMetas();for(let s=0,c=o.length;s<c;++s)a=o[s].controller.getMinMax(this,e),r||(t=Math.min(t,a.min)),i||(n=Math.max(n,a.max));return t=i&&t>n?n:t,n=r&&t>n?t:n,{min:qs(t,qs(n,t)),max:qs(n,qs(t,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||=this._computeLabelItems(e)}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){Z(this.options.beforeUpdate,[this])}update(e,t,n){let{beginAtZero:r,grace:i,ticks:a}=this.options,o=a.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=t,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||=(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Zl(this,i,r),!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let s=o<this.ticks.length;this._convertTicksToLabels(s?vp(this.ticks,o):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),a.display&&(a.autoSkip||a.source===`auto`)&&(this.ticks=cp(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),s&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let e=this.options.reverse,t,n;this.isHorizontal()?(t=this.left,n=this.right):(t=this.top,n=this.bottom,e=!e),this._startPixel=t,this._endPixel=n,this._reversePixels=e,this._length=n-t,this._alignToPixels=this.options.alignToPixels}afterUpdate(){Z(this.options.afterUpdate,[this])}beforeSetDimensions(){Z(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(){Z(this.options.afterSetDimensions,[this])}_callHooks(e){this.chart.notifyPlugins(e,this.getContext()),Z(this.options[e],[this])}beforeDataLimits(){this._callHooks(`beforeDataLimits`)}determineDataLimits(){}afterDataLimits(){this._callHooks(`afterDataLimits`)}beforeBuildTicks(){this._callHooks(`beforeBuildTicks`)}buildTicks(){return[]}afterBuildTicks(){this._callHooks(`afterBuildTicks`)}beforeTickToLabelConversion(){Z(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(e){let t=this.options.ticks,n,r,i;for(n=0,r=e.length;n<r;n++)i=e[n],i.label=Z(t.callback,[i.value,n,e],this)}afterTickToLabelConversion(){Z(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){Z(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){let e=this.options,t=e.ticks,n=_p(this.ticks.length,e.ticks.maxTicksLimit),r=t.minRotation||0,i=t.maxRotation,a=r,o,s,c;if(!this._isVisible()||!t.display||r>=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}let l=this._getLabelSizes(),u=l.widest.width,d=l.highest.height,f=Ic(this.chart.width-u,0,this.maxWidth);o=e.offset?this.maxWidth/n:f/(n-1),u+6>o&&(o=f/(n-(e.offset?.5:1)),s=this.maxHeight-xp(e.grid)-t.padding-Sp(e.title,this.chart.options.font),c=Math.sqrt(u*u+d*d),a=kc(Math.min(Math.asin(Ic((l.highest.height+6)/o,-1,1)),Math.asin(Ic(s/c,-1,1))-Math.asin(Ic(d/c,-1,1)))),a=Math.max(r,Math.min(i,a))),this.labelRotation=a}afterCalculateLabelRotation(){Z(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){Z(this.options.beforeFit,[this])}fit(){let e={width:0,height:0},{chart:t,options:{ticks:n,title:r,grid:i}}=this,a=this._isVisible(),o=this.isHorizontal();if(a){let a=Sp(r,t.options.font);if(o?(e.width=this.maxWidth,e.height=xp(i)+a):(e.height=this.maxHeight,e.width=xp(i)+a),n.display&&this.ticks.length){let{first:t,last:r,widest:i,highest:a}=this._getLabelSizes(),s=n.padding*2,c=Oc(this.labelRotation),l=Math.cos(c),u=Math.sin(c);if(o){let t=n.mirror?0:u*i.width+l*a.height;e.height=Math.min(this.maxHeight,e.height+t+s)}else{let t=n.mirror?0:l*i.width+u*a.height;e.width=Math.min(this.maxWidth,e.width+t+s)}this._calculatePadding(t,r,u,l)}}this._handleMargins(),o?(this.width=this._length=t.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=t.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,t,n,r){let{ticks:{align:i,padding:a},position:o}=this.options,s=this.labelRotation!==0,c=o!==`top`&&this.axis===`x`;if(this.isHorizontal()){let o=this.getPixelForTick(0)-this.left,l=this.right-this.getPixelForTick(this.ticks.length-1),u=0,d=0;s?c?(u=r*e.width,d=n*t.height):(u=n*e.height,d=r*t.width):i===`start`?d=t.width:i===`end`?u=e.width:i!==`inner`&&(u=e.width/2,d=t.width/2),this.paddingLeft=Math.max((u-o+a)*this.width/(this.width-o),0),this.paddingRight=Math.max((d-l+a)*this.width/(this.width-l),0)}else{let n=t.height/2,r=e.height/2;i===`start`?(n=0,r=e.height):i===`end`&&(n=t.height,r=0),this.paddingTop=n+a,this.paddingBottom=r+a}}_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(){Z(this.options.afterFit,[this])}isHorizontal(){let{axis:e,position:t}=this.options;return t===`top`||t===`bottom`||e===`x`}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let t,n;for(t=0,n=e.length;t<n;t++)J(e[t].label)&&(e.splice(t,1),n--,t--);this.afterTickToLabelConversion()}_getLabelSizes(){let e=this._labelSizes;if(!e){let t=this.options.ticks.sampleSize,n=this.ticks;t<n.length&&(n=vp(n,t)),this._labelSizes=e=this._computeLabelSizes(n,n.length,this.options.ticks.maxTicksLimit)}return e}_computeLabelSizes(e,t,n){let{ctx:r,_longestTextCache:i}=this,a=[],o=[],s=Math.floor(t/_p(t,n)),c=0,l=0,u,d,f,p,m,h,g,_,v,y,b;for(u=0;u<t;u+=s){if(p=e[u].label,m=this._resolveTickFontOptions(u),r.font=h=m.string,g=i[h]=i[h]||{data:{},gc:[]},_=m.lineHeight,v=y=0,!J(p)&&!Gs(p))v=Tl(r,g.data,g.gc,v,p),y=_;else if(Gs(p))for(d=0,f=p.length;d<f;++d)b=p[d],!J(b)&&!Gs(b)&&(v=Tl(r,g.data,g.gc,v,b),y+=_);a.push(v),o.push(y),c=Math.max(v,c),l=Math.max(y,l)}bp(i,t);let x=a.indexOf(c),S=o.indexOf(l),C=e=>({width:a[e]||0,height:o[e]||0});return{first:C(0),last:C(t-1),widest:C(x),highest:C(S),widths:a,heights:o}}getLabelForValue(e){return e}getPixelForValue(e,t){return NaN}getValueForPixel(e){}getPixelForTick(e){let t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);let t=this._startPixel+e*this._length;return Lc(this._alignToPixels?Dl(this.chart,t,0):t)}getDecimalForPixel(e){let t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:e,max:t}=this;return e<0&&t<0?t:e>0&&t>0?e:0}getContext(e){let t=this.ticks||[];if(e>=0&&e<t.length){let n=t[e];return n.$context||=wp(this.getContext(),e,n)}return this.$context||=Cp(this.chart.getContext(),this)}_tickSize(){let e=this.options.ticks,t=Oc(this.labelRotation),n=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t)),i=this._getLabelSizes(),a=e.autoSkipPadding||0,o=i?i.widest.width+a:0,s=i?i.highest.height+a:0;return this.isHorizontal()?s*n>o*r?o/n:s/r:s*r<o*n?s/n:o/r}_isVisible(){let e=this.options.display;return e===`auto`?this.getMatchingVisibleMetas().length>0:!!e}_computeGridLineItems(e){let t=this.axis,n=this.chart,r=this.options,{grid:i,position:a,border:o}=r,s=i.offset,c=this.isHorizontal(),l=this.ticks.length+ +!!s,u=xp(i),d=[],f=o.setContext(this.getContext()),p=f.display?f.width:0,m=p/2,h=function(e){return Dl(n,e,p)},g,_,v,y,b,x,S,C,w,T,E,D;if(a===`top`)g=h(this.bottom),x=this.bottom-u,C=g-m,T=h(e.top)+m,D=e.bottom;else if(a===`bottom`)g=h(this.top),T=e.top,D=h(e.bottom)-m,x=g+m,C=this.top+u;else if(a===`left`)g=h(this.right),b=this.right-u,S=g-m,w=h(e.left)+m,E=e.right;else if(a===`right`)g=h(this.left),w=e.left,E=h(e.right)-m,b=g+m,S=this.left+u;else if(t===`x`){if(a===`center`)g=h((e.top+e.bottom)/2+.5);else if(Y(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}T=e.top,D=e.bottom,x=g+m,C=x+u}else if(t===`y`){if(a===`center`)g=h((e.left+e.right)/2);else if(Y(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}b=g-m,S=b-u,w=e.left,E=e.right}let ee=X(r.ticks.maxTicksLimit,l),te=Math.max(1,Math.ceil(l/ee));for(_=0;_<l;_+=te){let e=this.getContext(_),t=i.setContext(e),r=o.setContext(e),a=t.lineWidth,l=t.color,u=r.dash||[],f=r.dashOffset,p=t.tickWidth,m=t.tickColor,h=t.tickBorderDash||[],g=t.tickBorderDashOffset;v=yp(this,_,s),v!==void 0&&(y=Dl(n,v,a),c?b=S=w=E=y:x=C=T=D=y,d.push({tx1:b,ty1:x,tx2:S,ty2:C,x1:w,y1:T,x2:E,y2:D,width:a,color:l,borderDash:u,borderDashOffset:f,tickWidth:p,tickColor:m,tickBorderDash:h,tickBorderDashOffset:g}))}return this._ticksLength=l,this._borderValue=g,d}_computeLabelItems(e){let t=this.axis,n=this.options,{position:r,ticks:i}=n,a=this.isHorizontal(),o=this.ticks,{align:s,crossAlign:c,padding:l,mirror:u}=i,d=xp(n.grid),f=d+l,p=u?-l:f,m=-Oc(this.labelRotation),h=[],g,_,v,y,b,x,S,C,w,T,E,D,ee=`middle`;if(r===`top`)x=this.bottom-p,S=this._getXAxisLabelAlignment();else if(r===`bottom`)x=this.top+p,S=this._getXAxisLabelAlignment();else if(r===`left`){let e=this._getYAxisLabelAlignment(d);S=e.textAlign,b=e.x}else if(r===`right`){let e=this._getYAxisLabelAlignment(d);S=e.textAlign,b=e.x}else if(t===`x`){if(r===`center`)x=(e.top+e.bottom)/2+f;else if(Y(r)){let e=Object.keys(r)[0],t=r[e];x=this.chart.scales[e].getPixelForValue(t)+f}S=this._getXAxisLabelAlignment()}else if(t===`y`){if(r===`center`)b=(e.left+e.right)/2-f;else if(Y(r)){let e=Object.keys(r)[0],t=r[e];b=this.chart.scales[e].getPixelForValue(t)}S=this._getYAxisLabelAlignment(d).textAlign}t===`y`&&(s===`start`?ee=`top`:s===`end`&&(ee=`bottom`));let te=this._getLabelSizes();for(g=0,_=o.length;g<_;++g){v=o[g],y=v.label;let e=i.setContext(this.getContext(g));C=this.getPixelForTick(g)+i.labelOffset,w=this._resolveTickFontOptions(g),T=w.lineHeight,E=Gs(y)?y.length:1;let t=E/2,n=e.color,s=e.textStrokeColor,l=e.textStrokeWidth,d=S;a?(b=C,S===`inner`&&(d=g===_-1?this.options.reverse?`left`:`right`:g===0?this.options.reverse?`right`:`left`:`center`),D=r===`top`?c===`near`||m!==0?-E*T+T/2:c===`center`?-te.highest.height/2-t*T+T:-te.highest.height+T/2:c===`near`||m!==0?T/2:c===`center`?te.highest.height/2-t*T:te.highest.height-E*T,u&&(D*=-1),m!==0&&!e.showLabelBackdrop&&(b+=T/2*Math.sin(m))):(x=C,D=(1-E)*T/2);let f;if(e.showLabelBackdrop){let t=Jl(e.backdropPadding),n=te.heights[g],r=te.widths[g],i=D-t.top,a=0-t.left;switch(ee){case`middle`:i-=n/2;break;case`bottom`:i-=n}switch(S){case`center`:a-=r/2;break;case`right`:a-=r;break;case`inner`:g===_-1?a-=r:g>0&&(a-=r/2)}f={left:a,top:i,width:r+t.width,height:n+t.height,color:e.backdropColor}}h.push({label:y,font:w,textOffset:D,options:{rotation:m,color:n,strokeColor:s,strokeWidth:l,textAlign:d,textBaseline:ee,translation:[b,x],backdrop:f}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:t}=this.options;if(-Oc(this.labelRotation))return e===`top`?`left`:`right`;let n=`center`;return t.align===`start`?n=`left`:t.align===`end`?n=`right`:t.align===`inner`&&(n=`inner`),n}_getYAxisLabelAlignment(e){let{position:t,ticks:{crossAlign:n,mirror:r,padding:i}}=this.options,a=this._getLabelSizes(),o=e+i,s=a.widest.width,c,l;return t===`left`?r?(l=this.right+i,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l+=s)):(l=this.right-o,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l=this.left)):t===`right`?r?(l=this.left+i,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l-=s)):(l=this.left+o,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l=this.right)):c=`right`,{textAlign:c,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;let e=this.chart,t=this.options.position;if(t===`left`||t===`right`)return{top:0,left:this.left,bottom:e.height,right:this.right};if(t===`top`||t===`bottom`)return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){let{ctx:e,options:{backgroundColor:t},left:n,top:r,width:i,height:a}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,r,i,a),e.restore())}getLineWidthForValue(e){let t=this.options.grid;if(!this._isVisible()||!t.display)return 0;let n=this.ticks.findIndex(t=>t.value===e);return n>=0?t.setContext(this.getContext(n)).lineWidth:0}drawGrid(e){let t=this.options.grid,n=this.ctx,r=this._gridLineItems||=this._computeGridLineItems(e),i,a,o=(e,t,r)=>{!r.width||!r.color||(n.save(),n.lineWidth=r.width,n.strokeStyle=r.color,n.setLineDash(r.borderDash||[]),n.lineDashOffset=r.borderDashOffset,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.stroke(),n.restore())};if(t.display)for(i=0,a=r.length;i<a;++i){let e=r[i];t.drawOnChartArea&&o({x:e.x1,y:e.y1},{x:e.x2,y:e.y2},e),t.drawTicks&&o({x:e.tx1,y:e.ty1},{x:e.tx2,y:e.ty2},{color:e.tickColor,width:e.tickWidth,borderDash:e.tickBorderDash,borderDashOffset:e.tickBorderDashOffset})}}drawBorder(){let{chart:e,ctx:t,options:{border:n,grid:r}}=this,i=n.setContext(this.getContext()),a=n.display?i.width:0;if(!a)return;let o=r.setContext(this.getContext(0)).lineWidth,s=this._borderValue,c,l,u,d;this.isHorizontal()?(c=Dl(e,this.left,a)-a/2,l=Dl(e,this.right,o)+o/2,u=d=s):(u=Dl(e,this.top,a)-a/2,d=Dl(e,this.bottom,o)+o/2,c=l=s),t.save(),t.lineWidth=i.width,t.strokeStyle=i.color,t.beginPath(),t.moveTo(c,u),t.lineTo(l,d),t.stroke(),t.restore()}drawLabels(e){if(!this.options.ticks.display)return;let t=this.ctx,n=this._computeLabelArea();n&&Ml(t,n);let r=this.getLabelItems(e);for(let e of r){let n=e.options,r=e.font,i=e.label,a=e.textOffset;zl(t,i,0,a,r,n)}n&&Nl(t)}drawTitle(){let{ctx:e,options:{position:t,title:n,reverse:r}}=this;if(!n.display)return;let i=Yl(n.font),a=Jl(n.padding),o=n.align,s=i.lineHeight/2;t===`bottom`||t===`center`||Y(t)?(s+=a.bottom,Gs(n.text)&&(s+=i.lineHeight*(n.text.length-1))):s+=a.top;let{titleX:c,titleY:l,maxWidth:u,rotation:d}=Ep(this,s,t,o);zl(e,n.text,0,0,i,{color:n.color,maxWidth:u,rotation:d,textAlign:Tp(o,t,r),textBaseline:`middle`,translation:[c,l]})}draw(e){this._isVisible()&&(this.drawBackground(),this.drawGrid(e),this.drawBorder(),this.drawTitle(),this.drawLabels(e))}_layers(){let t=this.options,n=t.ticks&&t.ticks.z||0,r=X(t.grid&&t.grid.z,-1),i=X(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==e.prototype.draw?[{z:n,draw:e=>{this.draw(e)}}]:[{z:r,draw:e=>{this.drawBackground(),this.drawGrid(e),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:e=>{this.drawLabels(e)}}]}getMatchingVisibleMetas(e){let t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+`AxisID`,r=[],i,a;for(i=0,a=t.length;i<a;++i){let a=t[i];a[n]===this.id&&(!e||a.type===e)&&r.push(a)}return r}_resolveTickFontOptions(e){return Yl(this.options.ticks.setContext(this.getContext(e)).font)}_maxDigits(){let e=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/e}},Op=class{constructor(e,t,n){this.type=e,this.scope=t,this.override=n,this.items=Object.create(null)}isForType(e){return Object.prototype.isPrototypeOf.call(this.type.prototype,e.prototype)}register(e){let t=Object.getPrototypeOf(e),n;jp(t)&&(n=this.register(t));let r=this.items,i=e.id,a=this.scope+`.`+i;if(!i)throw Error(`class does not have id: `+e);return i in r?a:(r[i]=e,kp(e,a,n),this.override&&Cl.override(e.id,e.overrides),a)}get(e){return this.items[e]}unregister(e){let t=this.items,n=e.id,r=this.scope;n in t&&delete t[n],r&&n in Cl[r]&&(delete Cl[r][n],this.override&&delete yl[n])}};function kp(e,t,n){let r=ec(Object.create(null),[n?Cl.get(n):{},Cl.get(t),e.defaults]);Cl.set(t,r),e.defaultRoutes&&Ap(t,e.defaultRoutes),e.descriptors&&Cl.describe(t,e.descriptors)}function Ap(e,t){Object.keys(t).forEach(n=>{let r=n.split(`.`),i=r.pop(),a=[e].concat(r).join(`.`),o=t[n].split(`.`),s=o.pop(),c=o.join(`.`);Cl.route(a,i,c,s)})}function jp(e){return`id`in e&&`defaults`in e}var Mp=new class{constructor(){this.controllers=new Op(Bd,`datasets`,!0),this.elements=new Op(sp,`elements`),this.plugins=new Op(Object,`plugins`),this.scales=new Op(Dp,`scales`),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each(`register`,e)}remove(...e){this._each(`unregister`,e)}addControllers(...e){this._each(`register`,e,this.controllers)}addElements(...e){this._each(`register`,e,this.elements)}addPlugins(...e){this._each(`register`,e,this.plugins)}addScales(...e){this._each(`register`,e,this.scales)}getController(e){return this._get(e,this.controllers,`controller`)}getElement(e){return this._get(e,this.elements,`element`)}getPlugin(e){return this._get(e,this.plugins,`plugin`)}getScale(e){return this._get(e,this.scales,`scale`)}removeControllers(...e){this._each(`unregister`,e,this.controllers)}removeElements(...e){this._each(`unregister`,e,this.elements)}removePlugins(...e){this._each(`unregister`,e,this.plugins)}removeScales(...e){this._each(`unregister`,e,this.scales)}_each(e,t,n){[...t].forEach(t=>{let r=n||this._getRegistryForType(t);n||r.isForType(t)||r===this.plugins&&t.id?this._exec(e,r,t):Q(t,t=>{let r=n||this._getRegistryForType(t);this._exec(e,r,t)})})}_exec(e,t,n){let r=sc(e);Z(n[`before`+r],[],n),t[e](n),Z(n[`after`+r],[],n)}_getRegistryForType(e){for(let t=0;t<this._typedRegistries.length;t++){let n=this._typedRegistries[t];if(n.isForType(e))return n}return this.plugins}_get(e,t,n){let r=t.get(e);if(r===void 0)throw Error(`"`+e+`" is not a registered `+n+`.`);return r}},Np=class{constructor(){this._init=void 0}notify(e,t,n,r){if(t===`beforeInit`&&(this._init=this._createDescriptors(e,!0),this._notify(this._init,e,`install`)),this._init===void 0)return;let i=r?this._descriptors(e).filter(r):this._descriptors(e),a=this._notify(i,e,t,n);return t===`afterDestroy`&&(this._notify(i,e,`stop`),this._notify(this._init,e,`uninstall`),this._init=void 0),a}_notify(e,t,n,r){r||={};for(let i of e){let e=i.plugin,a=e[n];if(Z(a,[t,r,i.options],e)===!1&&r.cancelable)return!1}return!0}invalidate(){J(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(e){if(this._cache)return this._cache;let t=this._cache=this._createDescriptors(e);return this._notifyStateChanges(e),t}_createDescriptors(e,t){let n=e&&e.config,r=X(n.options&&n.options.plugins,{}),i=Pp(n);return r===!1&&!t?[]:Ip(e,i,r,t)}_notifyStateChanges(e){let t=this._oldCache||[],n=this._cache,r=(e,t)=>e.filter(e=>!t.some(t=>e.plugin.id===t.plugin.id));this._notify(r(t,n),e,`stop`),this._notify(r(n,t),e,`start`)}};function Pp(e){let t={},n=[],r=Object.keys(Mp.plugins.items);for(let e=0;e<r.length;e++)n.push(Mp.getPlugin(r[e]));let i=e.plugins||[];for(let e=0;e<i.length;e++){let r=i[e];n.indexOf(r)===-1&&(n.push(r),t[r.id]=!0)}return{plugins:n,localIds:t}}function Fp(e,t){return!t&&e===!1?null:e===!0?{}:e}function Ip(e,{plugins:t,localIds:n},r,i){let a=[],o=e.getContext();for(let s of t){let t=s.id,c=Fp(r[t],i);c!==null&&a.push({plugin:s,options:Lp(e.config,{plugin:s,local:n[t]},c,o)})}return a}function Lp(e,{plugin:t,local:n},r,i){let a=e.pluginScopeKeys(t),o=e.getOptionScopes(r,a);return n&&t.defaults&&o.push(t.defaults),e.createResolver(o,i,[``],{scriptable:!1,indexable:!1,allKeys:!0})}function Rp(e,t){let n=Cl.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||`x`}function zp(e,t){let n=e;return e===`_index_`?n=t:e===`_value_`&&(n=t===`x`?`y`:`x`),n}function Bp(e,t){return e===t?`_index_`:`_value_`}function Vp(e){if(e===`x`||e===`y`||e===`r`)return e}function Hp(e){if(e===`top`||e===`bottom`)return`x`;if(e===`left`||e===`right`)return`y`}function Up(e,...t){if(Vp(e))return e;for(let n of t){let t=n.axis||Hp(n.position)||e.length>1&&Vp(e[0].toLowerCase());if(t)return t}throw Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function Wp(e,t,n){if(n[t+`AxisID`]===e)return{axis:t}}function Gp(e,t){if(t.data&&t.data.datasets){let n=t.data.datasets.filter(t=>t.xAxisID===e||t.yAxisID===e);if(n.length)return Wp(e,`x`,n[0])||Wp(e,`y`,n[0])}return{}}function Kp(e,t){let n=yl[e.type]||{scales:{}},r=t.scales||{},i=Rp(e.type,t),a=Object.create(null);return Object.keys(r).forEach(t=>{let o=r[t];if(!Y(o))return console.error(`Invalid scale configuration for scale: ${t}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);let s=Up(t,o,Gp(t,e),Cl.scales[o.type]),c=Bp(s,i),l=n.scales||{};a[t]=tc(Object.create(null),[{axis:s},o,l[s],l[c]])}),e.data.datasets.forEach(n=>{let i=n.type||e.type,o=n.indexAxis||Rp(i,t),s=(yl[i]||{}).scales||{};Object.keys(s).forEach(e=>{let t=zp(e,o),i=n[t+`AxisID`]||t;a[i]=a[i]||Object.create(null),tc(a[i],[{axis:t},r[i],s[e]])})}),Object.keys(a).forEach(e=>{let t=a[e];tc(t,[Cl.scales[t.type],Cl.scale])}),a}function qp(e){let t=e.options||={};t.plugins=X(t.plugins,{}),t.scales=Kp(e,t)}function Jp(e){return e||={},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function Yp(e){return e||={},e.data=Jp(e.data),qp(e),e}var Xp=new Map,Zp=new Set;function Qp(e,t){let n=Xp.get(e);return n||(n=t(),Xp.set(e,n),Zp.add(n)),n}var $p=(e,t,n)=>{let r=oc(t,n);r!==void 0&&e.add(r)},em=class{constructor(e){this._config=Yp(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=Jp(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){let e=this._config;this.clearCache(),qp(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return Qp(e,()=>[[`datasets.${e}`,``]])}datasetAnimationScopeKeys(e,t){return Qp(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,``]])}datasetElementScopeKeys(e,t){return Qp(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,``]])}pluginScopeKeys(e){let t=e.id,n=this.type;return Qp(`${n}-plugin-${t}`,()=>[[`plugins.${t}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){let n=this._scopeCache,r=n.get(e);return(!r||t)&&(r=new Map,n.set(e,r)),r}getOptionScopes(e,t,n){let{options:r,type:i}=this,a=this._cachedScopes(e,n),o=a.get(t);if(o)return o;let s=new Set;t.forEach(t=>{e&&(s.add(e),t.forEach(t=>$p(s,e,t))),t.forEach(e=>$p(s,r,e)),t.forEach(e=>$p(s,yl[i]||{},e)),t.forEach(e=>$p(s,Cl,e)),t.forEach(e=>$p(s,bl,e))});let c=Array.from(s);return c.length===0&&c.push(Object.create(null)),Zp.has(t)&&a.set(t,c),c}chartOptionScopes(){let{options:e,type:t}=this;return[e,yl[t]||{},Cl.datasets[t]||{},{type:t},Cl,bl]}resolveNamedOptions(e,t,n,r=[``]){let i={$shared:!0},{resolver:a,subPrefixes:o}=tm(this._resolverCache,e,r),s=a;if(rm(a,t)){i.$shared=!1,n=lc(n)?n():n;let t=this.createResolver(e,n,o);s=eu(a,n,t)}for(let e of t)i[e]=s[e];return i}createResolver(e,t,n=[``],r){let{resolver:i}=tm(this._resolverCache,e,n);return Y(t)?eu(i,t,void 0,r):i}};function tm(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));let i=n.join(),a=r.get(i);return a||(a={resolver:$l(t,n),subPrefixes:n.filter(e=>!e.toLowerCase().includes(`hover`))},r.set(i,a)),a}var nm=e=>Y(e)&&Object.getOwnPropertyNames(e).some(t=>lc(e[t]));function rm(e,t){let{isScriptable:n,isIndexable:r}=tu(e);for(let i of t){let t=n(i),a=r(i),o=(a||t)&&e[i];if(t&&(lc(o)||nm(o))||a&&Gs(o))return!0}return!1}var im=`4.5.1`,am=[`top`,`bottom`,`left`,`right`,`chartArea`];function om(e,t){return e===`top`||e===`bottom`||am.indexOf(e)===-1&&t===`x`}function sm(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function cm(e){let t=e.chart,n=t.options.animation;t.notifyPlugins(`afterRender`),Z(n&&n.onComplete,[e],t)}function lm(e){let t=e.chart,n=t.options.animation;Z(n&&n.onProgress,[e],t)}function um(e){return ku()&&typeof e==`string`?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}var dm={},fm=e=>{let t=um(e);return Object.values(dm).filter(e=>e.canvas===t).pop()};function pm(e,t,n){let r=Object.keys(e);for(let i of r){let r=+i;if(r>=t){let a=e[i];delete e[i],(n>0||r>t)&&(e[r+n]=a)}}}function mm(e,t,n,r){return!n||e.type===`mouseout`?null:r?t:e}var hm=class{static defaults=Cl;static instances=dm;static overrides=yl;static registry=Mp;static version=im;static getChart=fm;static register(...e){Mp.add(...e),gm()}static unregister(...e){Mp.remove(...e),gm()}constructor(e,t){let n=this.config=new em(t),r=um(e),i=fm(r);if(i)throw Error(`Canvas is already in use. Chart with ID '`+i.id+`' must be destroyed before the canvas with ID '`+i.canvas.id+`' can be reused.`);let a=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||(op(r))),this.platform.updateConfig(n);let o=this.platform.acquireContext(r,a.aspectRatio),s=o&&o.canvas,c=s&&s.height,l=s&&s.width;if(this.id=Ws(),this.ctx=o,this.canvas=s,this.width=l,this.height=c,this._options=a,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 Np,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=Yc(e=>this.update(e),a.resizeDelay||0),this._dataChanges=[],dm[this.id]=this,!o||!s){console.error(`Failed to create chart: can't acquire context from the given item`);return}md.listen(this,`complete`,cm),md.listen(this,`progress`,lm),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:r,_aspectRatio:i}=this;return J(e)?t&&i?i:r?n/r:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return Mp}_initialize(){return this.notifyPlugins(`beforeInit`),this.options.responsive?this.resize():Hu(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins(`afterInit`),this}clear(){return Ol(this.canvas,this.ctx),this}stop(){return md.stop(this),this}resize(e,t){md.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){let n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(r,e,t,i),o=n.devicePixelRatio||this.platform.getDevicePixelRatio(),s=this.width?`resize`:`attach`;this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,Hu(this,o,!0)&&(this.notifyPlugins(`resize`,{size:a}),Z(n.onResize,[this,a],this),this.attached&&this._doResize(s)&&this.render())}ensureScalesHaveIDs(){Q(this.options.scales||{},(e,t)=>{e.id=t})}buildOrUpdateScales(){let e=this.options,t=e.scales,n=this.scales,r=Object.keys(n).reduce((e,t)=>(e[t]=!1,e),{}),i=[];t&&(i=i.concat(Object.keys(t).map(e=>{let n=t[e],r=Up(e,n),i=r===`r`,a=r===`x`;return{options:n,dposition:i?`chartArea`:a?`bottom`:`left`,dtype:i?`radialLinear`:a?`category`:`linear`}}))),Q(i,t=>{let i=t.options,a=i.id,o=Up(a,i),s=X(i.type,t.dtype);(i.position===void 0||om(i.position,o)!==om(t.dposition))&&(i.position=t.dposition),r[a]=!0;let c=null;a in n&&n[a].type===s?c=n[a]:(c=new(Mp.getScale(s))({id:a,type:s,ctx:this.ctx,chart:this}),n[c.id]=c),c.init(i,e)}),Q(r,(e,t)=>{e||delete n[t]}),Q(n,e=>{Lf.configure(this,e,e.options),Lf.addBox(this,e)})}_updateMetasets(){let e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((e,t)=>e.index-t.index),n>t){for(let e=t;e<n;++e)this._destroyDatasetMeta(e);e.splice(t,n-t)}this._sortedMetasets=e.slice(0).sort(sm(`order`,`index`))}_removeUnreferencedMetasets(){let{_metasets:e,data:{datasets:t}}=this;e.length>t.length&&delete this._stacks,e.forEach((e,n)=>{t.filter(t=>t===e._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let e=[],t=this.data.datasets,n,r;for(this._removeUnreferencedMetasets(),n=0,r=t.length;n<r;n++){let r=t[n],i=this.getDatasetMeta(n),a=r.type||this.config.type;if(i.type&&i.type!==a&&(this._destroyDatasetMeta(n),i=this.getDatasetMeta(n)),i.type=a,i.indexAxis=r.indexAxis||Rp(a,this.options),i.order=r.order||0,i.index=n,i.label=``+r.label,i.visible=this.isDatasetVisible(n),i.controller)i.controller.updateIndex(n),i.controller.linkScales();else{let t=Mp.getController(a),{datasetElementType:r,dataElementType:o}=Cl.datasets[a];Object.assign(t,{dataElementType:Mp.getElement(o),datasetElementType:r&&Mp.getElement(r)}),i.controller=new t(this,n),e.push(i.controller)}}return this._updateMetasets(),e}_resetElements(){Q(this.data.datasets,(e,t)=>{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins(`reset`)}update(e){let t=this.config;t.update();let n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins(`beforeUpdate`,{mode:e,cancelable:!0})===!1)return;let i=this.buildOrUpdateControllers();this.notifyPlugins(`beforeElementsUpdate`);let a=0;for(let e=0,t=this.data.datasets.length;e<t;e++){let{controller:t}=this.getDatasetMeta(e),n=!r&&i.indexOf(t)===-1;t.buildOrUpdateElements(n),a=Math.max(+t.getMaxOverflow(),a)}a=this._minPadding=n.layout.autoPadding?a:0,this._updateLayout(a),r||Q(i,e=>{e.reset()}),this._updateDatasets(e),this.notifyPlugins(`afterUpdate`,{mode:e}),this._layers.sort(sm(`z`,`_idx`));let{_active:o,_lastEvent:s}=this;s?this._eventHandler(s,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){Q(this.scales,e=>{Lf.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options;(!uc(new Set(Object.keys(this._listeners)),new Set(e.events))||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(let{method:n,start:r,count:i}of t)pm(e,r,n===`_removeElements`?-i:i)}_getUniformDataChanges(){let e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];let t=this.data.datasets.length,n=t=>new Set(e.filter(e=>e[0]===t).map((e,t)=>t+`,`+e.splice(1).join(`,`))),r=n(0);for(let e=1;e<t;e++)if(!uc(r,n(e)))return;return Array.from(r).map(e=>e.split(`,`)).map(e=>({method:e[1],start:+e[2],count:+e[3]}))}_updateLayout(e){if(this.notifyPlugins(`beforeLayout`,{cancelable:!0})===!1)return;Lf.update(this,this.width,this.height,e);let t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],Q(this.boxes,e=>{n&&e.position===`chartArea`||(e.configure&&e.configure(),this._layers.push(...e._layers()))},this),this._layers.forEach((e,t)=>{e._idx=t}),this.notifyPlugins(`afterLayout`)}_updateDatasets(e){if(this.notifyPlugins(`beforeDatasetsUpdate`,{mode:e,cancelable:!0})!==!1){for(let e=0,t=this.data.datasets.length;e<t;++e)this.getDatasetMeta(e).controller.configure();for(let t=0,n=this.data.datasets.length;t<n;++t)this._updateDataset(t,lc(e)?e({datasetIndex:t}):e);this.notifyPlugins(`afterDatasetsUpdate`,{mode:e})}}_updateDataset(e,t){let n=this.getDatasetMeta(e),r={meta:n,index:e,mode:t,cancelable:!0};this.notifyPlugins(`beforeDatasetUpdate`,r)!==!1&&(n.controller._update(t),r.cancelable=!1,this.notifyPlugins(`afterDatasetUpdate`,r))}render(){this.notifyPlugins(`beforeRender`,{cancelable:!0})!==!1&&(md.has(this)?this.attached&&!md.running(this)&&md.start(this):(this.draw(),cm({chart:this})))}draw(){let e;if(this._resizeBeforeDraw){let{width:e,height:t}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(e,t)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins(`beforeDraw`,{cancelable:!0})===!1)return;let t=this._layers;for(e=0;e<t.length&&t[e].z<=0;++e)t[e].draw(this.chartArea);for(this._drawDatasets();e<t.length;++e)t[e].draw(this.chartArea);this.notifyPlugins(`afterDraw`)}_getSortedDatasetMetas(e){let t=this._sortedMetasets,n=[],r,i;for(r=0,i=t.length;r<i;++r){let i=t[r];(!e||i.visible)&&n.push(i)}return n}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins(`beforeDatasetsDraw`,{cancelable:!0})===!1)return;let e=this.getSortedVisibleDatasetMetas();for(let t=e.length-1;t>=0;--t)this._drawDataset(e[t]);this.notifyPlugins(`afterDatasetsDraw`)}_drawDataset(e){let t=this.ctx,n={meta:e,index:e.index,cancelable:!0},r=pd(this,e);this.notifyPlugins(`beforeDatasetDraw`,n)!==!1&&(r&&Ml(t,r),e.controller.draw(),r&&Nl(t),n.cancelable=!1,this.notifyPlugins(`afterDatasetDraw`,n))}isPointInArea(e){return jl(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,r){let i=bf.modes[t];return typeof i==`function`?i(this,e,n,r):[]}getDatasetMeta(e){let t=this.data.datasets[e],n=this._metasets,r=n.filter(e=>e&&e._dataset===t).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(r)),r}getContext(){return this.$context||=Ql(null,{chart:this,type:`chart`})}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){let t=this.data.datasets[e];if(!t)return!1;let n=this.getDatasetMeta(e);return typeof n.hidden==`boolean`?!n.hidden:!t.hidden}setDatasetVisibility(e,t){let n=this.getDatasetMeta(e);n.hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){let r=n?`show`:`hide`,i=this.getDatasetMeta(e),a=i.controller._resolveAnimations(void 0,r);cc(t)?(i.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),a.update(i,{visible:n}),this.update(t=>t.datasetIndex===e?r:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){let t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),md.remove(this),e=0,t=this.data.datasets.length;e<t;++e)this._destroyDatasetMeta(e)}destroy(){this.notifyPlugins(`beforeDestroy`);let{canvas:e,ctx:t}=this;this._stop(),this.config.clearCache(),e&&(this.unbindEvents(),Ol(e,t),this.platform.releaseContext(t),this.canvas=null,this.ctx=null),delete dm[this.id],this.notifyPlugins(`afterDestroy`)}toBase64Image(...e){return this.canvas.toDataURL(...e)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){let e=this._listeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(e,t,n)=>{e.offsetX=t,e.offsetY=n,this._eventHandler(e)};Q(this.options.events,e=>n(e,r))}bindResponsiveEvents(){this._responsiveListeners||={};let e=this._responsiveListeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(n,r)=>{e[n]&&(t.removeEventListener(this,n,r),delete e[n])},i=(e,t)=>{this.canvas&&this.resize(e,t)},a,o=()=>{r(`attach`,o),this.attached=!0,this.resize(),n(`resize`,i),n(`detach`,a)};a=()=>{this.attached=!1,r(`resize`,i),this._stop(),this._resize(0,0),n(`attach`,o)},t.isAttached(this.canvas)?o():a()}unbindEvents(){Q(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},Q(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){let r=n?`set`:`remove`,i,a,o,s;for(t===`dataset`&&(i=this.getDatasetMeta(e[0].datasetIndex),i.controller[`_`+r+`DatasetHoverStyle`]()),o=0,s=e.length;o<s;++o){a=e[o];let t=a&&this.getDatasetMeta(a.datasetIndex).controller;t&&t[r+`HoverStyle`](a.element,a.datasetIndex,a.index)}}getActiveElements(){return this._active||[]}setActiveElements(e){let t=this._active||[],n=e.map(({datasetIndex:e,index:t})=>{let n=this.getDatasetMeta(e);if(!n)throw Error(`No dataset found at index `+e);return{datasetIndex:e,element:n.data[t],index:t}});Xs(n,t)||(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return this._plugins._cache.filter(t=>t.plugin.id===e).length===1}_updateHoverStyles(e,t,n){let r=this.options.hover,i=(e,t)=>e.filter(e=>!t.some(t=>e.datasetIndex===t.datasetIndex&&e.index===t.index)),a=i(t,e),o=n?e:i(e,t);a.length&&this.updateHoverStyle(a,r.mode,!1),o.length&&r.mode&&this.updateHoverStyle(o,r.mode,!0)}_eventHandler(e,t){let n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},r=t=>(t.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins(`beforeEvent`,n,r)===!1)return;let i=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins(`afterEvent`,n,r),(i||n.changed)&&this.render(),this}_handleEvent(e,t,n){let{_active:r=[],options:i}=this,a=t,o=this._getActiveElements(e,r,n,a),s=dc(e),c=mm(e,this._lastEvent,n,s);n&&(this._lastEvent=null,Z(i.onHover,[e,o,this],this),s&&Z(i.onClick,[e,o,this],this));let l=!Xs(o,r);return(l||t)&&(this._active=o,this._updateHoverStyles(o,r,t)),this._lastEvent=c,l}_getActiveElements(e,t,n,r){if(e.type===`mouseout`)return[];if(!n)return t;let i=this.options.hover;return this.getElementsAtEventForMode(e,i.mode,i,r)}};function gm(){return Q(hm.instances,e=>e._plugins.invalidate())}function _m(e,t,n){let{startAngle:r,x:i,y:a,outerRadius:o,innerRadius:s,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,d=Math.min(l/o,Pc(r-n));if(e.beginPath(),e.arc(i,a,o-l/2,r+d/2,n-d/2),s>0){let t=Math.min(l/s,Pc(r-n));e.arc(i,a,s+l/2,n-t/2,r+t/2,!0)}else{let t=Math.min(l/2,o*Pc(r-n));if(u===`round`)e.arc(i,a,t,n-$/2,r+$/2,!0);else if(u===`bevel`){let o=2*t*t,s=-o*Math.cos(n+$/2)+i,c=-o*Math.sin(n+$/2)+a,l=o*Math.cos(r+$/2)+i,u=o*Math.sin(r+$/2)+a;e.lineTo(s,c),e.lineTo(l,u)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip(`evenodd`)}function vm(e,t,n){let{startAngle:r,pixelMargin:i,x:a,y:o,outerRadius:s,innerRadius:c}=t,l=i/s;e.beginPath(),e.arc(a,o,s,r-l,n+l),c>i?(l=i/c,e.arc(a,o,c,n+l,r-l,!0)):e.arc(a,o,i,n+gc,r-gc),e.closePath(),e.clip()}function ym(e){return Gl(e,[`outerStart`,`outerEnd`,`innerStart`,`innerEnd`])}function bm(e,t,n,r){let i=ym(e.options.borderRadius),a=(n-t)/2,o=Math.min(a,r*t/2),s=e=>{let t=(n-Math.min(a,e))*r/2;return Ic(e,0,Math.min(a,t))};return{outerStart:s(i.outerStart),outerEnd:s(i.outerEnd),innerStart:Ic(i.innerStart,0,o),innerEnd:Ic(i.innerEnd,0,o)}}function xm(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function Sm(e,t,n,r,i,a){let{x:o,y:s,startAngle:c,pixelMargin:l,innerRadius:u}=t,d=Math.max(t.outerRadius+r+n-l,0),f=u>0?u+r+n+l:0,p=0,m=i-c;if(r){let e=((u>0?u-r:0)+(d>0?d-r:0))/2;p=(m-(e===0?m:m*e/(e+r)))/2}let h=(m-Math.max(.001,m*d-n/$)/d)/2,g=c+h+p,_=i-h-p,{outerStart:v,outerEnd:y,innerStart:b,innerEnd:x}=bm(t,f,d,_-g),S=d-v,C=d-y,w=g+v/S,T=_-y/C,E=f+b,D=f+x,ee=g+b/E,te=_-x/D;if(e.beginPath(),a){let t=(w+T)/2;if(e.arc(o,s,d,w,t),e.arc(o,s,d,t,T),y>0){let t=xm(C,T,o,s);e.arc(t.x,t.y,y,T,_+gc)}let n=xm(D,_,o,s);if(e.lineTo(n.x,n.y),x>0){let t=xm(D,te,o,s);e.arc(t.x,t.y,x,_+gc,te+Math.PI)}let r=(_-x/f+(g+b/f))/2;if(e.arc(o,s,f,_-x/f,r,!0),e.arc(o,s,f,r,g+b/f,!0),b>0){let t=xm(E,ee,o,s);e.arc(t.x,t.y,b,ee+Math.PI,g-gc)}let i=xm(S,g,o,s);if(e.lineTo(i.x,i.y),v>0){let t=xm(S,w,o,s);e.arc(t.x,t.y,v,g-gc,w)}}else{e.moveTo(o,s);let t=Math.cos(w)*d+o,n=Math.sin(w)*d+s;e.lineTo(t,n);let r=Math.cos(T)*d+o,i=Math.sin(T)*d+s;e.lineTo(r,i)}e.closePath()}function Cm(e,t,n,r,i){let{fullCircles:a,startAngle:o,circumference:s}=t,c=t.endAngle;if(a){Sm(e,t,n,r,c,i);for(let t=0;t<a;++t)e.fill();isNaN(s)||(c=o+(s%fc||fc))}return Sm(e,t,n,r,c,i),e.fill(),c}function wm(e,t,n,r,i){let{fullCircles:a,startAngle:o,circumference:s,options:c}=t,{borderWidth:l,borderJoinStyle:u,borderDash:d,borderDashOffset:f,borderRadius:p}=c,m=c.borderAlign===`inner`;if(!l)return;e.setLineDash(d||[]),e.lineDashOffset=f,m?(e.lineWidth=l*2,e.lineJoin=u||`round`):(e.lineWidth=l,e.lineJoin=u||`bevel`);let h=t.endAngle;if(a){Sm(e,t,n,r,h,i);for(let t=0;t<a;++t)e.stroke();isNaN(s)||(h=o+(s%fc||fc))}m&&vm(e,t,h),c.selfJoin&&h-o>=$&&p===0&&u!==`miter`&&_m(e,t,h),a||(Sm(e,t,n,r,h,i),e.stroke())}var Tm=class extends sp{static id=`arc`;static defaults={borderAlign:`center`,borderColor:`#fff`,borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:`backgroundColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(e){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,e&&Object.assign(this,e)}inRange(e,t,n){let{angle:r,distance:i}=jc(this.getProps([`x`,`y`],n),{x:e,y:t}),{startAngle:a,endAngle:o,innerRadius:s,outerRadius:c,circumference:l}=this.getProps([`startAngle`,`endAngle`,`innerRadius`,`outerRadius`,`circumference`],n),u=(this.options.spacing+this.options.borderWidth)/2,d=X(l,o-a),f=Fc(r,a,o)&&a!==o,p=d>=fc||f,m=Rc(i,s+u,c+u);return p&&m}getCenterPoint(e){let{x:t,y:n,startAngle:r,endAngle:i,innerRadius:a,outerRadius:o}=this.getProps([`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`],e),{offset:s,spacing:c}=this.options,l=(r+i)/2,u=(a+o+c+s)/2;return{x:t+Math.cos(l)*u,y:n+Math.sin(l)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:t,circumference:n}=this,r=(t.offset||0)/4,i=(t.spacing||0)/2,a=t.circular;if(this.pixelMargin=t.borderAlign===`inner`?.33:0,this.fullCircles=n>fc?Math.floor(n/fc):0,n===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let o=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(o)*r,Math.sin(o)*r);let s=r*(1-Math.sin(Math.min($,n||0)));e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,Cm(e,this,s,i,a),wm(e,this,s,i,a),e.restore()}};function Em(e,t,n=t){e.lineCap=X(n.borderCapStyle,t.borderCapStyle),e.setLineDash(X(n.borderDash,t.borderDash)),e.lineDashOffset=X(n.borderDashOffset,t.borderDashOffset),e.lineJoin=X(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=X(n.borderWidth,t.borderWidth),e.strokeStyle=X(n.borderColor,t.borderColor)}function Dm(e,t,n){e.lineTo(n.x,n.y)}function Om(e){return e.stepped?Pl:e.tension||e.cubicInterpolationMode===`monotone`?Fl:Dm}function km(e,t,n={}){let r=e.length,{start:i=0,end:a=r-1}=n,{start:o,end:s}=t,c=Math.max(i,o),l=Math.min(a,s),u=i<o&&a<o||i>s&&a>s;return{count:r,start:c,loop:t.loop,ilen:l<c&&!u?r+l-c:l-c}}function Am(e,t,n,r){let{points:i,options:a}=t,{count:o,start:s,loop:c,ilen:l}=km(i,n,r),u=Om(a),{move:d=!0,reverse:f}=r||{},p,m,h;for(p=0;p<=l;++p)m=i[(s+(f?l-p:p))%o],!m.skip&&(d?(e.moveTo(m.x,m.y),d=!1):u(e,h,m,f,a.stepped),h=m);return c&&(m=i[(s+(f?l:0))%o],u(e,h,m,f,a.stepped)),!!c}function jm(e,t,n,r){let i=t.points,{count:a,start:o,ilen:s}=km(i,n,r),{move:c=!0,reverse:l}=r||{},u=0,d=0,f,p,m,h,g,_,v=e=>(o+(l?s-e:e))%a,y=()=>{h!==g&&(e.lineTo(u,g),e.lineTo(u,h),e.lineTo(u,_))};for(c&&(p=i[v(0)],e.moveTo(p.x,p.y)),f=0;f<=s;++f){if(p=i[v(f)],p.skip)continue;let t=p.x,n=p.y,r=t|0;r===m?(n<h?h=n:n>g&&(g=n),u=(d*u+t)/++d):(y(),e.lineTo(t,n),m=r,d=0,h=g=n),_=n}y()}function Mm(e){let t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!==`monotone`&&!t.stepped&&!n?jm:Am}function Nm(e){return e.stepped?Ku:e.tension||e.cubicInterpolationMode===`monotone`?qu:Gu}function Pm(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),Em(e,t.options),e.stroke(i)}function Fm(e,t,n,r){let{segments:i,options:a}=t,o=Mm(t);for(let s of i)Em(e,a,s.style),e.beginPath(),o(e,t,s,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}var Im=typeof Path2D==`function`;function Lm(e,t,n,r){Im&&!t.options.segment?Pm(e,t,n,r):Fm(e,t,n,r)}var Rm=class extends sp{static id=`line`;static defaults={borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:`default`,fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`&&e!==`fill`};constructor(e){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,e&&Object.assign(this,e)}updateControlPoints(e,t){let n=this.options;if((n.tension||n.cubicInterpolationMode===`monotone`)&&!n.stepped&&!this._pointsUpdated){let r=n.spanGaps?this._loop:this._fullLoop;Ou(this._points,n,e,r,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||=od(this,this.options.segment)}first(){let e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){let e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){let n=this.options,r=e[t],i=this.points,a=rd(this,{property:t,start:r,end:r});if(!a.length)return;let o=[],s=Nm(n),c,l;for(c=0,l=a.length;c<l;++c){let{start:l,end:u}=a[c],d=i[l],f=i[u];if(d===f){o.push(d);continue}let p=s(d,f,Math.abs((r-d[t])/(f[t]-d[t])),n.stepped);p[t]=e[t],o.push(p)}return o.length===1?o[0]:o}pathSegment(e,t,n){return Mm(this)(e,this,t,n)}path(e,t,n){let r=this.segments,i=Mm(this),a=this._loop;t||=0,n||=this.points.length-t;for(let o of r)a&=i(e,this,o,{start:t,end:t+n-1});return!!a}draw(e,t,n,r){let i=this.options||{};(this.points||[]).length&&i.borderWidth&&(e.save(),Lm(e,this,n,r),e.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}};function zm(e,t,n,r){let i=e.options,{[n]:a}=e.getProps([n],r);return Math.abs(t-a)<i.radius+i.hitRadius}var Bm=class extends sp{static id=`point`;parsed;skip;stop;static defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:`circle`,radius:3,rotation:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};constructor(e){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,e&&Object.assign(this,e)}inRange(e,t,n){let r=this.options,{x:i,y:a}=this.getProps([`x`,`y`],n);return(e-i)**2+(t-a)**2<(r.hitRadius+r.radius)**2}inXRange(e,t){return zm(this,e,`x`,t)}inYRange(e,t){return zm(this,e,`y`,t)}getCenterPoint(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}size(e){e=e||this.options||{};let t=e.radius||0;t=Math.max(t,t&&e.hoverRadius||0);let n=t&&e.borderWidth||0;return(t+n)*2}draw(e,t){let n=this.options;this.skip||n.radius<.1||!jl(this,t,this.size(n)/2)||(e.strokeStyle=n.borderColor,e.lineWidth=n.borderWidth,e.fillStyle=n.backgroundColor,kl(e,n,this.x,this.y))}getRange(){let e=this.options||{};return e.radius+e.hitRadius}};function Vm(e,t){let{x:n,y:r,base:i,width:a,height:o}=e.getProps([`x`,`y`,`base`,`width`,`height`],t),s,c,l,u,d;return e.horizontal?(d=o/2,s=Math.min(n,i),c=Math.max(n,i),l=r-d,u=r+d):(d=a/2,s=n-d,c=n+d,l=Math.min(r,i),u=Math.max(r,i)),{left:s,top:l,right:c,bottom:u}}function Hm(e,t,n,r){return e?0:Ic(t,n,r)}function Um(e,t,n){let r=e.options.borderWidth,i=e.borderSkipped,a=Kl(r);return{t:Hm(i.top,a.top,0,n),r:Hm(i.right,a.right,0,t),b:Hm(i.bottom,a.bottom,0,n),l:Hm(i.left,a.left,0,t)}}function Wm(e,t,n){let{enableBorderRadius:r}=e.getProps([`enableBorderRadius`]),i=e.options.borderRadius,a=ql(i),o=Math.min(t,n),s=e.borderSkipped,c=r||Y(i);return{topLeft:Hm(!c||s.top||s.left,a.topLeft,0,o),topRight:Hm(!c||s.top||s.right,a.topRight,0,o),bottomLeft:Hm(!c||s.bottom||s.left,a.bottomLeft,0,o),bottomRight:Hm(!c||s.bottom||s.right,a.bottomRight,0,o)}}function Gm(e){let t=Vm(e),n=t.right-t.left,r=t.bottom-t.top,i=Um(e,n/2,r/2),a=Wm(e,n/2,r/2);return{outer:{x:t.left,y:t.top,w:n,h:r,radius:a},inner:{x:t.left+i.l,y:t.top+i.t,w:n-i.l-i.r,h:r-i.t-i.b,radius:{topLeft:Math.max(0,a.topLeft-Math.max(i.t,i.l)),topRight:Math.max(0,a.topRight-Math.max(i.t,i.r)),bottomLeft:Math.max(0,a.bottomLeft-Math.max(i.b,i.l)),bottomRight:Math.max(0,a.bottomRight-Math.max(i.b,i.r))}}}}function Km(e,t,n,r){let i=t===null,a=n===null,o=e&&!(i&&a)&&Vm(e,r);return o&&(i||Rc(t,o.left,o.right))&&(a||Rc(n,o.top,o.bottom))}function qm(e){return e.topLeft||e.topRight||e.bottomLeft||e.bottomRight}function Jm(e,t){e.rect(t.x,t.y,t.w,t.h)}function Ym(e,t,n={}){let r=e.x===n.x?0:-t,i=e.y===n.y?0:-t,a=(e.x+e.w===n.x+n.w?0:t)-r,o=(e.y+e.h===n.y+n.h?0:t)-i;return{x:e.x+r,y:e.y+i,w:e.w+a,h:e.h+o,radius:e.radius}}var Xm=Object.freeze({__proto__:null,ArcElement:Tm,BarElement:class extends sp{static id=`bar`;static defaults={borderSkipped:`start`,borderWidth:0,borderRadius:0,inflateAmount:`auto`,pointStyle:void 0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};constructor(e){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,e&&Object.assign(this,e)}draw(e){let{inflateAmount:t,options:{borderColor:n,backgroundColor:r}}=this,{inner:i,outer:a}=Gm(this),o=qm(a.radius)?Bl:Jm;e.save(),(a.w!==i.w||a.h!==i.h)&&(e.beginPath(),o(e,Ym(a,t,i)),e.clip(),o(e,Ym(i,-t,a)),e.fillStyle=n,e.fill(`evenodd`)),e.beginPath(),o(e,Ym(i,t)),e.fillStyle=r,e.fill(),e.restore()}inRange(e,t,n){return Km(this,e,t,n)}inXRange(e,t){return Km(this,e,null,t)}inYRange(e,t){return Km(this,null,e,t)}getCenterPoint(e){let{x:t,y:n,base:r,horizontal:i}=this.getProps([`x`,`y`,`base`,`horizontal`],e);return{x:i?(t+r)/2:t,y:i?n:(n+r)/2}}getRange(e){return e===`x`?this.width/2:this.height/2}},LineElement:Rm,PointElement:Bm}),Zm=[`rgb(54, 162, 235)`,`rgb(255, 99, 132)`,`rgb(255, 159, 64)`,`rgb(255, 205, 86)`,`rgb(75, 192, 192)`,`rgb(153, 102, 255)`,`rgb(201, 203, 207)`],Qm=Zm.map(e=>e.replace(`rgb(`,`rgba(`).replace(`)`,`, 0.5)`));function $m(e){return Zm[e%Zm.length]}function eh(e){return Qm[e%Qm.length]}function th(e,t){return e.borderColor=$m(t),e.backgroundColor=eh(t),++t}function nh(e,t){return e.backgroundColor=e.data.map(()=>$m(t++)),t}function rh(e,t){return e.backgroundColor=e.data.map(()=>eh(t++)),t}function ih(e){let t=0;return(n,r)=>{let i=e.getDatasetMeta(r).controller;i instanceof of?t=nh(n,t):i instanceof cf?t=rh(n,t):i&&(t=th(n,t))}}function ah(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function oh(e){return e&&(e.borderColor||e.backgroundColor)}function sh(){return Cl.borderColor!==`rgba(0,0,0,0.1)`||Cl.backgroundColor!==`rgba(0,0,0,0.1)`}var ch={id:`colors`,defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;let{data:{datasets:r},options:i}=e.config,{elements:a}=i,o=ah(r)||oh(i)||a&&ah(a)||sh();if(!n.forceOverride&&o)return;let s=ih(e);r.forEach(s)}};function lh(e,t,n,r,i){let a=i.samples||r;if(a>=n)return e.slice(t,t+n);let o=[],s=(n-2)/(a-2),c=0,l=t+n-1,u=t,d,f,p,m,h;for(o[c++]=e[u],d=0;d<a-2;d++){let r=0,i=0,a,l=Math.floor((d+1)*s)+1+t,g=Math.min(Math.floor((d+2)*s)+1,n)+t,_=g-l;for(a=l;a<g;a++)r+=e[a].x,i+=e[a].y;r/=_,i/=_;let v=Math.floor(d*s)+1+t,y=Math.min(Math.floor((d+1)*s)+1,n)+t,{x:b,y:x}=e[u];for(p=m=-1,a=v;a<y;a++)m=.5*Math.abs((b-r)*(e[a].y-x)-(b-e[a].x)*(i-x)),m>p&&(p=m,f=e[a],h=a);o[c++]=f,u=h}return o[c++]=e[l],o}function uh(e,t,n,r){let i=0,a=0,o,s,c,l,u,d,f,p,m,h,g=[],_=t+n-1,v=e[t].x,y=e[_].x-v;for(o=t;o<t+n;++o){s=e[o],c=(s.x-v)/y*r,l=s.y;let t=c|0;if(t===u)l<m?(m=l,d=o):l>h&&(h=l,f=o),i=(a*i+s.x)/++a;else{let n=o-1;if(!J(d)&&!J(f)){let t=Math.min(d,f),r=Math.max(d,f);t!==p&&t!==n&&g.push({...e[t],x:i}),r!==p&&r!==n&&g.push({...e[r],x:i})}o>0&&n!==p&&g.push(e[n]),g.push(s),u=t,a=0,m=h=l,d=f=p=o}}return g}function dh(e){if(e._decimated){let t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function fh(e){e.data.datasets.forEach(e=>{dh(e)})}function ph(e,t){let n=t.length,r=0,i,{iScale:a}=e,{min:o,max:s,minDefined:c,maxDefined:l}=a.getUserBounds();return c&&(r=Ic(Bc(t,a.axis,o).lo,0,n-1)),i=l?Ic(Bc(t,a.axis,s).hi+1,r,n)-r:n-r,{start:r,count:i}}var mh={id:`decimation`,defaults:{algorithm:`min-max`,enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){fh(e);return}let r=e.width;e.data.datasets.forEach((t,i)=>{let{_data:a,indexAxis:o}=t,s=e.getDatasetMeta(i),c=a||t.data;if(Xl([o,e.options.indexAxis])===`y`||!s.controller.supportsDecimation)return;let l=e.scales[s.xAxisID];if(l.type!==`linear`&&l.type!==`time`||e.options.parsing)return;let{start:u,count:d}=ph(s,c);if(d<=(n.threshold||4*r)){dh(t);return}J(a)&&(t._data=c,delete t.data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(e){this._data=e}}));let f;switch(n.algorithm){case`lttb`:f=lh(c,u,d,r,n);break;case`min-max`:f=uh(c,u,d,r);break;default:throw Error(`Unsupported decimation algorithm '${n.algorithm}'`)}t._decimated=f})},destroy(e){fh(e)}};function hh(e,t,n){let r=e.segments,i=e.points,a=t.points,o=[];for(let e of r){let{start:r,end:s}=e;s=vh(r,s,i);let c=gh(n,i[r],i[s],e.loop);if(!t.segments){o.push({source:e,target:c,start:i[r],end:i[s]});continue}let l=rd(t,c);for(let t of l){let r=gh(n,a[t.start],a[t.end],t.loop),s=nd(e,i,r);for(let e of s)o.push({source:e,target:t,start:{[n]:yh(c,r,`start`,Math.max)},end:{[n]:yh(c,r,`end`,Math.min)}})}}return o}function gh(e,t,n,r){if(r)return;let i=t[e],a=n[e];return e===`angle`&&(i=Pc(i),a=Pc(a)),{property:e,start:i,end:a}}function _h(e,t){let{x:n=null,y:r=null}=e||{},i=t.points,a=[];return t.segments.forEach(({start:e,end:t})=>{t=vh(e,t,i);let o=i[e],s=i[t];r===null?n!==null&&(a.push({x:n,y:o.y}),a.push({x:n,y:s.y})):(a.push({x:o.x,y:r}),a.push({x:s.x,y:r}))}),a}function vh(e,t,n){for(;t>e;t--){let e=n[t];if(!isNaN(e.x)&&!isNaN(e.y))break}return t}function yh(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function bh(e,t){let n=[],r=!1;return Gs(e)?(r=!0,n=e):n=_h(e,t),n.length?new Rm({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function xh(e){return e&&e.fill!==!1}function Sh(e,t,n){let r=e[t].fill,i=[t],a;if(!n)return r;for(;r!==!1&&i.indexOf(r)===-1;){if(!Ks(r))return r;if(a=e[r],!a)return!1;if(a.visible)return r;i.push(r),r=a.fill}return!1}function Ch(e,t,n){let r=Dh(e);if(Y(r))return!isNaN(r.value)&&r;let i=parseFloat(r);return Ks(i)&&Math.floor(i)===i?wh(r[0],t,i,n):[`origin`,`start`,`end`,`stack`,`shape`].indexOf(r)>=0&&r}function wh(e,t,n,r){return(e===`-`||e===`+`)&&(n=t+n),n===t||n<0||n>=r?!1:n}function Th(e,t){let n=null;return e===`start`?n=t.bottom:e===`end`?n=t.top:Y(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function Eh(e,t,n){let r;return r=e===`start`?n:e===`end`?t.options.reverse?t.min:t.max:Y(e)?e.value:t.getBaseValue(),r}function Dh(e){let t=e.options,n=t.fill,r=X(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?`origin`:r}function Oh(e){let{scale:t,index:n,line:r}=e,i=[],a=r.segments,o=r.points,s=kh(t,n);s.push(bh({x:null,y:t.bottom},r));for(let e=0;e<a.length;e++){let t=a[e];for(let e=t.start;e<=t.end;e++)Ah(i,o[e],s)}return new Rm({points:i,options:{}})}function kh(e,t){let n=[],r=e.getMatchingVisibleMetas(`line`);for(let e=0;e<r.length;e++){let i=r[e];if(i.index===t)break;i.hidden||n.unshift(i.dataset)}return n}function Ah(e,t,n){let r=[];for(let i=0;i<n.length;i++){let a=n[i],{first:o,last:s,point:c}=jh(a,t,`x`);if(!(!c||o&&s)){if(o)r.unshift(c);else if(e.push(c),!s)break}}e.push(...r)}function jh(e,t,n){let r=e.interpolate(t,n);if(!r)return{};let i=r[n],a=e.segments,o=e.points,s=!1,c=!1;for(let e=0;e<a.length;e++){let t=a[e],r=o[t.start][n],l=o[t.end][n];if(Rc(i,r,l)){s=i===r,c=i===l;break}}return{first:s,last:c,point:r}}var Mh=class{constructor(e){this.x=e.x,this.y=e.y,this.radius=e.radius}pathSegment(e,t,n){let{x:r,y:i,radius:a}=this;return t||={start:0,end:fc},e.arc(r,i,a,t.end,t.start,!0),!n.bounds}interpolate(e){let{x:t,y:n,radius:r}=this,i=e.angle;return{x:t+Math.cos(i)*r,y:n+Math.sin(i)*r,angle:i}}};function Nh(e){let{chart:t,fill:n,line:r}=e;if(Ks(n))return Ph(t,n);if(n===`stack`)return Oh(e);if(n===`shape`)return!0;let i=Fh(e);return i instanceof Mh?i:bh(i,r)}function Ph(e,t){let n=e.getDatasetMeta(t);return n&&e.isDatasetVisible(t)?n.dataset:null}function Fh(e){return(e.scale||{}).getPointPositionForValue?Lh(e):Ih(e)}function Ih(e){let{scale:t={},fill:n}=e,r=Th(n,t);if(Ks(r)){let e=t.isHorizontal();return{x:e?r:null,y:e?null:r}}return null}function Lh(e){let{scale:t,fill:n}=e,r=t.options,i=t.getLabels().length,a=r.reverse?t.max:t.min,o=Eh(n,t,a),s=[];if(r.grid.circular){let e=t.getPointPositionForValue(0,a);return new Mh({x:e.x,y:e.y,radius:t.getDistanceFromCenterForValue(o)})}for(let e=0;e<i;++e)s.push(t.getPointPositionForValue(e,o));return s}function Rh(e,t,n){let r=Nh(t),{chart:i,index:a,line:o,scale:s,axis:c}=t,l=o.options,u=l.fill,d=l.backgroundColor,{above:f=d,below:p=d}=u||{},m=pd(i,i.getDatasetMeta(a));r&&o.points.length&&(Ml(e,n),zh(e,{line:o,target:r,above:f,below:p,area:n,scale:s,axis:c,clip:m}),Nl(e))}function zh(e,t){let{line:n,target:r,above:i,below:a,area:o,scale:s,clip:c}=t,l=n._loop?`angle`:t.axis;e.save();let u=a;a!==i&&(l===`x`?(Bh(e,r,o.top),Hh(e,{line:n,target:r,color:i,scale:s,property:l,clip:c}),e.restore(),e.save(),Bh(e,r,o.bottom)):l===`y`&&(Vh(e,r,o.left),Hh(e,{line:n,target:r,color:a,scale:s,property:l,clip:c}),e.restore(),e.save(),Vh(e,r,o.right),u=i)),Hh(e,{line:n,target:r,color:u,scale:s,property:l,clip:c}),e.restore()}function Bh(e,t,n){let{segments:r,points:i}=t,a=!0,o=!1;e.beginPath();for(let s of r){let{start:r,end:c}=s,l=i[r],u=i[vh(r,c,i)];a?(e.moveTo(l.x,l.y),a=!1):(e.lineTo(l.x,n),e.lineTo(l.x,l.y)),o=!!t.pathSegment(e,s,{move:o}),o?e.closePath():e.lineTo(u.x,n)}e.lineTo(t.first().x,n),e.closePath(),e.clip()}function Vh(e,t,n){let{segments:r,points:i}=t,a=!0,o=!1;e.beginPath();for(let s of r){let{start:r,end:c}=s,l=i[r],u=i[vh(r,c,i)];a?(e.moveTo(l.x,l.y),a=!1):(e.lineTo(n,l.y),e.lineTo(l.x,l.y)),o=!!t.pathSegment(e,s,{move:o}),o?e.closePath():e.lineTo(n,u.y)}e.lineTo(n,t.first().y),e.closePath(),e.clip()}function Hh(e,t){let{line:n,target:r,property:i,color:a,scale:o,clip:s}=t,c=hh(n,r,i);for(let{source:t,target:l,start:u,end:d}of c){let{style:{backgroundColor:c=a}={}}=t,f=r!==!0;e.save(),e.fillStyle=c,Uh(e,o,s,f&&gh(i,u,d)),e.beginPath();let p=!!n.pathSegment(e,t),m;if(f){p?e.closePath():Wh(e,r,d,i);let t=!!r.pathSegment(e,l,{move:p,reverse:!0});m=p&&t,m||Wh(e,r,u,i)}e.closePath(),e.fill(m?`evenodd`:`nonzero`),e.restore()}}function Uh(e,t,n,r){let i=t.chart.chartArea,{property:a,start:o,end:s}=r||{};if(a===`x`||a===`y`){let t,r,c,l;a===`x`?(t=o,r=i.top,c=s,l=i.bottom):(t=i.left,r=o,c=i.right,l=s),e.beginPath(),n&&(t=Math.max(t,n.left),c=Math.min(c,n.right),r=Math.max(r,n.top),l=Math.min(l,n.bottom)),e.rect(t,r,c-t,l-r),e.clip()}}function Wh(e,t,n,r){let i=t.interpolate(n,r);i&&e.lineTo(i.x,i.y)}var Gh={id:`filler`,afterDatasetsUpdate(e,t,n){let r=(e.data.datasets||[]).length,i=[],a,o,s,c;for(o=0;o<r;++o)a=e.getDatasetMeta(o),s=a.dataset,c=null,s&&s.options&&s instanceof Rm&&(c={visible:e.isDatasetVisible(o),index:o,fill:Ch(s,o,r),chart:e,axis:a.controller.options.indexAxis,scale:a.vScale,line:s}),a.$filler=c,i.push(c);for(o=0;o<r;++o)c=i[o],!(!c||c.fill===!1)&&(c.fill=Sh(i,o,n.propagate))},beforeDraw(e,t,n){let r=n.drawTime===`beforeDraw`,i=e.getSortedVisibleDatasetMetas(),a=e.chartArea;for(let t=i.length-1;t>=0;--t){let n=i[t].$filler;n&&(n.line.updateControlPoints(a,n.axis),r&&n.fill&&Rh(e.ctx,n,a))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!==`beforeDatasetsDraw`)return;let r=e.getSortedVisibleDatasetMetas();for(let t=r.length-1;t>=0;--t){let n=r[t].$filler;xh(n)&&Rh(e.ctx,n,e.chartArea)}},beforeDatasetDraw(e,t,n){let r=t.meta.$filler;!xh(r)||n.drawTime!==`beforeDatasetDraw`||Rh(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:`beforeDatasetDraw`}},Kh=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},qh=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index,Jh=class extends sp{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.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(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,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(){let e=this.options.labels||{},t=Z(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(t=>e.filter(t,this.chart.data))),e.sort&&(t=t.sort((t,n)=>e.sort(t,n,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){let{options:e,ctx:t}=this;if(!e.display){this.width=this.height=0;return}let n=e.labels,r=Yl(n.font),i=r.size,a=this._computeTitleHeight(),{boxWidth:o,itemHeight:s}=Kh(n,i),c,l;t.font=r.string,this.isHorizontal()?(c=this.maxWidth,l=this._fitRows(a,i,o,s)+10):(l=this.maxHeight,c=this._fitCols(a,r,o,s)+10),this.width=Math.min(c,e.maxWidth||this.maxWidth),this.height=Math.min(l,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,r){let{ctx:i,maxWidth:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.lineWidths=[0],l=r+o,u=e;i.textAlign=`left`,i.textBaseline=`middle`;let d=-1,f=-l;return this.legendItems.forEach((e,p)=>{let m=n+t/2+i.measureText(e.text).width;(p===0||c[c.length-1]+m+2*o>a)&&(u+=l,c[c.length-(p>0?0:1)]=0,f+=l,d++),s[p]={left:0,top:f,row:d,width:m,height:r},c[c.length-1]+=m+o}),u}_fitCols(e,t,n,r){let{ctx:i,maxHeight:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.columnSizes=[],l=a-e,u=o,d=0,f=0,p=0,m=0;return this.legendItems.forEach((e,a)=>{let{itemWidth:h,itemHeight:g}=Yh(n,t,i,e,r);a>0&&f+g+2*o>l&&(u+=d+o,c.push({width:d,height:f}),p+=d+o,m++,d=f=0),s[a]={left:p,top:f,col:m,width:h,height:g},d=Math.max(d,h),f+=g+o}),u+=d,c.push({width:d,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;let e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:r},rtl:i}}=this,a=Xu(i,this.left,this.width);if(this.isHorizontal()){let i=0,o=Zc(n,this.left+r,this.right-this.lineWidths[i]);for(let s of t)i!==s.row&&(i=s.row,o=Zc(n,this.left+r,this.right-this.lineWidths[i])),s.top+=this.top+e+r,s.left=a.leftForLtr(a.x(o),s.width),o+=s.width+r}else{let i=0,o=Zc(n,this.top+e+r,this.bottom-this.columnSizes[i].height);for(let s of t)s.col!==i&&(i=s.col,o=Zc(n,this.top+e+r,this.bottom-this.columnSizes[i].height)),s.top=o,s.left+=this.left+r,s.left=a.leftForLtr(a.x(s.left),s.width),o+=s.height+r}}isHorizontal(){return this.options.position===`top`||this.options.position===`bottom`}draw(){if(this.options.display){let e=this.ctx;Ml(e,this),this._draw(),Nl(e)}}_draw(){let{options:e,columnSizes:t,lineWidths:n,ctx:r}=this,{align:i,labels:a}=e,o=Cl.color,s=Xu(e.rtl,this.left,this.width),c=Yl(a.font),{padding:l}=a,u=c.size,d=u/2,f;this.drawTitle(),r.textAlign=s.textAlign(`left`),r.textBaseline=`middle`,r.lineWidth=.5,r.font=c.string;let{boxWidth:p,boxHeight:m,itemHeight:h}=Kh(a,u),g=function(e,t,n){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;r.save();let i=X(n.lineWidth,1);if(r.fillStyle=X(n.fillStyle,o),r.lineCap=X(n.lineCap,`butt`),r.lineDashOffset=X(n.lineDashOffset,0),r.lineJoin=X(n.lineJoin,`miter`),r.lineWidth=i,r.strokeStyle=X(n.strokeStyle,o),r.setLineDash(X(n.lineDash,[])),a.usePointStyle){let o={radius:m*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:i},c=s.xPlus(e,p/2),l=t+d;Al(r,o,c,l,a.pointStyleWidth&&p)}else{let a=t+Math.max((u-m)/2,0),o=s.leftForLtr(e,p),c=ql(n.borderRadius);r.beginPath(),Object.values(c).some(e=>e!==0)?Bl(r,{x:o,y:a,w:p,h:m,radius:c}):r.rect(o,a,p,m),r.fill(),i!==0&&r.stroke()}r.restore()},_=function(e,t,n){zl(r,n.text,e,t+h/2,c,{strikethrough:n.hidden,textAlign:s.textAlign(n.textAlign)})},v=this.isHorizontal(),y=this._computeTitleHeight();f=v?{x:Zc(i,this.left+l,this.right-n[0]),y:this.top+l+y,line:0}:{x:this.left+l,y:Zc(i,this.top+y+l,this.bottom-t[0].height),line:0},Zu(this.ctx,e.textDirection);let b=h+l;this.legendItems.forEach((o,u)=>{r.strokeStyle=o.fontColor,r.fillStyle=o.fontColor;let m=r.measureText(o.text).width,h=s.textAlign(o.textAlign||=a.textAlign),x=p+d+m,S=f.x,C=f.y;s.setWidth(this.width),v?u>0&&S+x+l>this.right&&(C=f.y+=b,f.line++,S=f.x=Zc(i,this.left+l,this.right-n[f.line])):u>0&&C+b>this.bottom&&(S=f.x=S+t[f.line].width+l,f.line++,C=f.y=Zc(i,this.top+y+l,this.bottom-t[f.line].height));let w=s.x(S);if(g(w,C,o),S=Qc(h,S+p+d,v?S+x:this.right,e.rtl),_(s.x(S),C,o),v)f.x+=x+l;else if(typeof o.text!=`string`){let e=c.lineHeight;f.y+=Qh(o,e)+l}else f.y+=b}),Qu(this.ctx,e.textDirection)}drawTitle(){let e=this.options,t=e.title,n=Yl(t.font),r=Jl(t.padding);if(!t.display)return;let i=Xu(e.rtl,this.left,this.width),a=this.ctx,o=t.position,s=n.size/2,c=r.top+s,l,u=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),l=this.top+c,u=Zc(e.align,u,this.right-d);else{let t=this.columnSizes.reduce((e,t)=>Math.max(e,t.height),0);l=c+Zc(e.align,this.top,this.bottom-t-e.labels.padding-this._computeTitleHeight())}let f=Zc(o,u,u+d);a.textAlign=i.textAlign(Xc(o)),a.textBaseline=`middle`,a.strokeStyle=t.color,a.fillStyle=t.color,a.font=n.string,zl(a,t.text,f,l,n)}_computeTitleHeight(){let e=this.options.title,t=Yl(e.font),n=Jl(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,r,i;if(Rc(e,this.left,this.right)&&Rc(t,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;n<i.length;++n)if(r=i[n],Rc(e,r.left,r.left+r.width)&&Rc(t,r.top,r.top+r.height))return this.legendItems[n]}return null}handleEvent(e){let t=this.options;if(!$h(e.type,t))return;let n=this._getLegendItemAt(e.x,e.y);if(e.type===`mousemove`||e.type===`mouseout`){let r=this._hoveredItem,i=qh(r,n);r&&!i&&Z(t.onLeave,[e,r,this],this),this._hoveredItem=n,n&&!i&&Z(t.onHover,[e,n,this],this)}else n&&Z(t.onClick,[e,n,this],this)}};function Yh(e,t,n,r,i){return{itemWidth:Xh(r,e,t,n),itemHeight:Zh(i,r,t.lineHeight)}}function Xh(e,t,n,r){let i=e.text;return i&&typeof i!=`string`&&(i=i.reduce((e,t)=>e.length>t.length?e:t)),t+n.size/2+r.measureText(i).width}function Zh(e,t,n){let r=e;return typeof t.text!=`string`&&(r=Qh(t,n)),r}function Qh(e,t){return t*(e.text?e.text.length:0)}function $h(e,t){return!!((e===`mousemove`||e===`mouseout`)&&(t.onHover||t.onLeave)||t.onClick&&(e===`click`||e===`mouseup`))}var eg={id:`legend`,_element:Jh,start(e,t,n){let r=e.legend=new Jh({ctx:e.ctx,options:n,chart:e});Lf.configure(e,r,n),Lf.addBox(e,r)},stop(e){Lf.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){let r=e.legend;Lf.configure(e,r,n),r.options=n},afterUpdate(e){let t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:`top`,align:`center`,fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){let r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){let t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:a,useBorderRadius:o,borderRadius:s}}=e.legend.options;return e._getSortedDatasetMetas().map(e=>{let c=e.controller.getStyle(n?0:void 0),l=Jl(c.borderWidth);return{text:t[e.index].label,fillStyle:c.backgroundColor,fontColor:a,hidden:!e.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(l.width+l.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:o&&(s||c.borderRadius),datasetIndex:e.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:`center`,text:``}},descriptors:{_scriptable:e=>!e.startsWith(`on`),labels:{_scriptable:e=>![`generateLabels`,`filter`,`sort`].includes(e)}}},tg=class extends sp{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.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(e,t){let n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=t;let r=Gs(n.text)?n.text.length:1;this._padding=Jl(n.padding);let i=r*Yl(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=i:this.width=i}isHorizontal(){let e=this.options.position;return e===`top`||e===`bottom`}_drawArgs(e){let{top:t,left:n,bottom:r,right:i,options:a}=this,o=a.align,s=0,c,l,u;return this.isHorizontal()?(l=Zc(o,n,i),u=t+e,c=i-n):(a.position===`left`?(l=n+e,u=Zc(o,r,t),s=$*-.5):(l=i-e,u=Zc(o,t,r),s=$*.5),c=r-t),{titleX:l,titleY:u,maxWidth:c,rotation:s}}draw(){let e=this.ctx,t=this.options;if(!t.display)return;let n=Yl(t.font),r=n.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:o,rotation:s}=this._drawArgs(r);zl(e,t.text,0,0,n,{color:t.color,maxWidth:o,rotation:s,textAlign:Xc(t.align),textBaseline:`middle`,translation:[i,a]})}};function ng(e,t){let n=new tg({ctx:e.ctx,options:t,chart:e});Lf.configure(e,n,t),Lf.addBox(e,n),e.titleBlock=n}var rg={id:`title`,_element:tg,start(e,t,n){ng(e,n)},stop(e){let t=e.titleBlock;Lf.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){let r=e.titleBlock;Lf.configure(e,r,n),r.options=n},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}},ig=new WeakMap,ag={id:`subtitle`,start(e,t,n){let r=new tg({ctx:e.ctx,options:n,chart:e});Lf.configure(e,r,n),Lf.addBox(e,r),ig.set(e,r)},stop(e){Lf.removeBox(e,ig.get(e)),ig.delete(e)},beforeUpdate(e,t,n){let r=ig.get(e);Lf.configure(e,r,n),r.options=n},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}},og={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,a=0;for(t=0,n=e.length;t<n;++t){let n=e[t].element;if(n&&n.hasValue()){let e=n.tooltipPosition();r.add(e.x),i+=e.y,++a}}return a===0||r.size===0?!1:{x:[...r].reduce((e,t)=>e+t)/r.size,y:i/a}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=1/0,a,o,s;for(a=0,o=e.length;a<o;++a){let n=e[a].element;if(n&&n.hasValue()){let e=Mc(t,n.getCenterPoint());e<i&&(i=e,s=n)}}if(s){let e=s.tooltipPosition();n=e.x,r=e.y}return{x:n,y:r}}};function sg(e,t){return t&&(Gs(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function cg(e){return(typeof e==`string`||e instanceof String)&&e.indexOf(`
34
+ FROM skadi_views`)},f=e=>{let t=e.currentTarget.value;if(!Fa(n())||n().count_by===t)return;n().count_by=t;let r=Ga(n().type,t);r&&r!==n().type&&(n().belongs_to??={},n().belongs_to[r]??={}),m()},p=e=>{Fa(n())&&(n().belongs_to?.[e]?.required?(delete n().belongs_to[e].required,m()):(n().belongs_to??={},n().belongs_to[e]??={},n().belongs_to[e].required=!0))},m=()=>{if(!Fa(n()))return;let e=new Set;if(n().count_by){let t=Ga(n().type,n().count_by);t&&t!==n().type&&e.add(t)}if(n().selects){for(let t of n().selects)if(t.includes(`.`)){let[n,r]=t.split(`.`,2);e.add(n)}}if(!(e.size===0&&!n().belongs_to)){n().belongs_to??={};for(let[t,r]of Object.entries(n().belongs_to))V(o)?.belongs_to?.includes(t)&&(e.has(t)||r.required!==void 0||r.split_by?.length||r.filters?.length)||delete n().belongs_to[t];for(let t of e)n().belongs_to[t]??={};Object.keys(n().belongs_to).length===0&&delete n().belongs_to}},h,g=()=>{t.onDuplicate(),h?.close()};Qi(Da(e,{wrapperClass:`border-night-700`,get startOpen(){return r()},title:(e,r=d)=>{var i=ho(),a=F(i),o=e=>{var n=Gr();R(()=>G(n,`Dataset ${t.index+1}`)),W(e,n)},s=e=>{var t=mo(),r=I(t),i=F(r,!0);A(r);var a=L(r);R(()=>{G(i,n().type),G(a,` dataset: ${n().label??``}`)}),W(e,t)};K(a,e=>{r()?e(o):e(s,-1)}),A(i),W(e,i)},children:(e,r)=>{var d=Do(),h=I(d),_=L(F(h));Fi(_),Ie(2),A(h);var v=L(h,2),y=F(v),b=L(F(y));q(b,20,()=>V(a),e=>e,(e,t)=>{var n=go(),r=F(n,!0);A(n);var i={};R(e=>{G(r,e),i!==(i=t)&&(n.value=(n.__value=t)??``)},[()=>ka(t)]),W(e,n)}),A(b);var x;wi(b),A(y);var S=L(y,2),C=e=>{var t=_o(),r=L(F(t));q(r,20,()=>V(c),e=>e,(e,t)=>{var n=go(),r=F(n,!0);A(n);var i={};R(()=>{G(r,t.label),i!==(i=t.value)&&(n.value=(n.__value=t.value)??``)}),W(e,n)}),A(r);var i;wi(r),A(t),R(()=>{i!==(i=n().count_by??n().type)&&(r.value=(r.__value=n().count_by??n().type)??``,Ci(r,n().count_by??n().type))}),H(`change`,r,f),W(e,t)},w=j(()=>Fa(n())&&V(c).length>1&&t.chartConfig.type!==`table`);K(S,e=>{V(w)&&e(C)}),A(v);var T=L(v,2),E=e=>{var t=Kr(),r=I(t),i=e=>{oo(e,{get dataset(){return n()},pruneBelongsTo:m,get selectFields(){return V(s).select}})},a=j(()=>Fa(n())&&V(s).select.length>0);K(r,e=>{V(a)&&e(i)}),W(e,t)},D=e=>{var t=vo(),r=I(t),i=F(r);xa(i,{type:`switch`,leftValue:!1,get model(){return n()},key:`visible`,children:(e,t)=>{Ie(),W(e,Gr(`Show on chart`))},$$slots:{default:!0}});var a=L(i,2),o=e=>{xa(e,{type:`switch`,leftLabel:`Left`,rightLabel:`Right`,rightValue:`right`,get model(){return n()},key:`axis`,children:(e,t)=>{Ie(),W(e,Gr(`Axis`))},$$slots:{default:!0}})};K(a,e=>{n().visible!==!1&&e(o)}),A(r);var c=L(r,2),l=e=>{var t=Kr(),r=I(t),i=e=>{po(e,{get dataset(){return n()},pruneBelongsTo:m,get splitFields(){return V(s).split}})};K(r,e=>{V(s).split.length>0&&e(i)}),W(e,t)},u=j(()=>Fa(n()));K(c,e=>{V(u)&&e(l)}),W(e,t)};K(T,e=>{t.chartConfig.type===`table`?e(E):e(D,-1)});var ee=L(T,2),te=e=>{var t=yo(),r=I(t);xa(r,{type:`select`,get model(){return n()},key:`numerator`,get selectOptions(){return V(i)},description:`The dataset you are using for your target, e.g. a specific page view or event.`,children:(e,t)=>{Ie(),W(e,Gr(`Numerator`))},$$slots:{default:!0}}),xa(L(r,2),{type:`select`,get model(){return n()},key:`denominator`,get selectOptions(){return V(i)},description:`The dataset you are using for comparison, e.g. the number of visits.`,children:(e,t)=>{Ie(),W(e,Gr(`Denominator`))},$$slots:{default:!0}}),W(e,t)},ne=j(()=>Na(n())),re=e=>{{let r=e=>{var n=Kr(),r=I(n),i=e=>{W(e,bo())};K(r,e=>{t.chartConfig.type!==`table`&&e(i)}),W(e,n)},i=j(()=>!t.canDangerouslyUseSql);xa(e,{type:`textarea`,get model(){return n()},key:`sql`,class:`font-mono text-red-800 bg-red-50/50 p-1 border border-red-800`,rows:`10`,get readonly(){return V(i)},description:r,children:(e,t)=>{Ie(),W(e,Gr(`SQL Query`))},$$slots:{description:!0,default:!0}})}},ie=j(()=>Pa(n())),ae=e=>{var t=yo(),r=I(t);to(r,{get dataset(){return n()},pruneBelongsTo:m,get filterFields(){return V(s).filter}});var i=L(r,2),a=e=>{var t=So();q(L(F(t),2),17,()=>V(o).belongs_to,ei,(e,t)=>{let r=j(()=>n().belongs_to?.[V(t)]?.required??!1);var i=xo(),a=F(i),o=F(a,!0);A(a),sa(L(a,4),{get value(){return V(r)},onToggle:()=>p(V(t))}),A(i),R(e=>{bi(i,1,`flex flex-row items-center gap-2 font-normal pill pl-3 pr-1 ${V(r)?`bg-ice-50/50`:`bg-gray-50/50`}`),G(o,e)},[()=>Va(V(t))]),W(e,i)}),A(t),W(e,t)};K(i,e=>{V(o)?.belongs_to&&e(a)}),W(e,t)};K(ee,e=>{V(ne)?e(te):V(ie)?e(re,1):e(ae,-1)});var oe=L(ee,2),se=F(oe),ce=e=>{var t=Co();H(`click`,t,g),W(e,t)};K(se,e=>{(n().type!==`sql`||t.canDangerouslyUseSql)&&t.chartConfig.type!==`table`&&e(ce)});var le=L(se,2),ue=e=>{var n=wo();aa(F(n),{name:`chevron_up`,size:24}),A(n),H(`click`,n,function(...e){t.onMoveUp?.apply(this,e)}),W(e,n)};K(le,e=>{t.onMoveUp!==null&&e(ue)});var de=L(le,2),fe=e=>{var n=wo();aa(F(n),{name:`chevron_down`,size:24}),A(n),H(`click`,n,function(...e){t.onMoveDown?.apply(this,e)}),W(e,n)};K(de,e=>{t.onMoveDown!==null&&e(fe)});var pe=L(de,2),me=e=>{var n=Kr(),r=I(n),i=e=>{var n=To();H(`click`,n,function(...e){t.onDelete?.apply(this,e)}),W(e,n)},a=e=>{var t=Eo();H(`click`,t,()=>P(l,!0)),W(e,t)};K(r,e=>{V(l)?e(i):e(a,-1)}),W(e,n)};K(pe,e=>{t.chartConfig.datasets.length>1&&e(me)}),A(oe),R(()=>{x!==(x=n().type)&&(b.value=(b.__value=n().type)??``,Ci(b,n().type))}),Ji(_,()=>n().label,e=>n().label=e),H(`change`,b,u),W(e,d)},$$slots:{title:!0,default:!0}}),e=>h=e,()=>h),Je()}Ir([`change`,`click`]);var ko=U(`<option>All time</option>`),Ao=U(`<option>Daily</option>`),jo=U(`<!> <!> <option>Weekly</option> <option>Monthly</option>`,1),Mo=U(`<span class="sr-only">Date from</span>`),No=U(`<span class="sr-only">Date to</span>`),Po=U(`<button type="button" class="sm text-sm ghost w-full border-l-4 border-night-100 hover:border-night-700 pl-4 hover:bg-transparent hover:backdrop-filter-none"><!> New dataset</button>`),Fo=U(`<div class="p-1 px-2 bg-red-50/50 border border-red-500"><p class="text-red-800 font-semibold">Unable to preview the chart:</p> <pre class="text-red-800 whitespace-pre-wrap"> </pre></div>`),Io=U(`<button type="button" class="emph bg-ice-600 text-white">Preview</button>`),Lo=U(`<button type="button" class="emph">Save</button>`),Ro=U(`<div class="shrink-0 flex flex-col gap-4 border-l-4 border-ice-400 pl-4"><p class="font-semibold text-ice-700">Editing chart</p> <label>Title <input type="text"/></label> <!> <div class="sm:grid grid-cols-2 gap-x-2 gap-y-4 items-start"><label class="only:col-span-2">Type <select><option>Line chart</option><option>Bar chart</option><option>Table</option></select></label> <!></div> <div class="flex flex-wrap gap-2 items-center"><div class="flex gap-2 items-center sm:contents">Include data from <!></div> <div class="flex gap-2 items-center sm:contents">to <!></div></div> <div class="flex flex-col gap-4 mt-1 max-w-160"><!> <!></div> <!> <div class="flex gap-2 mt-4"><!> <button type="button" class="bg-gray-100">Cancel</button></div></div>`);function zo(e,t){qe(t,!0);let n=on(Ue(br(()=>t.chartConfig))),r=j(()=>JSON.stringify(t.chartConfig)),i=j(()=>JSON.stringify(n)),a=N(on(br(()=>V(r)))),o=j(()=>V(r)!==V(i)),s=j(()=>V(i)!==V(a)),c=N(null),l=N(null),u=()=>{t.onSave(n)},d=()=>{V(a)!==V(r)&&t.reloadChartData(t.chartConfig),t.onClose()},f=()=>{let e=V(i);t.reloadChartData(Ue(n)).then(()=>{P(a,e,!0),P(c,null)}).catch(e=>{P(c,e.message.trim().replace(/Configuration configuration\[\d+\]\.children\[\d+\]\./g,``),!0)})},p=e=>{let t=e.currentTarget.value;t===`line`&&(n.type=`line`,n.time_series??=`daily`),t===`bar`&&(n.type=`bar`,n.time_series===`daily`&&delete n.time_series),t===`table`&&(n.type=`table`,n.datasets=n.datasets.filter(e=>e.type!==`percentage`),n.datasets.length===0?m():n.datasets.splice(1),[`visible`,`axis`,`split_by`].forEach(e=>{delete n.datasets[0][e]}),delete n.time_series)},m=()=>{let e=crypto.randomUUID();P(l,e,!0),n.datasets.push({id:e,label:`Dataset ${n.datasets.length+1}`,type:`visits`})},h=e=>{n.datasets.splice(e,1)},g=e=>{let t=Ue(n.datasets[e]);t.id=crypto.randomUUID(),P(l,t.id,!0),t.label=`Copy of ${t.label}`,n.datasets.splice(e+1,0,t)},_=e=>{if(e===0)return;let t=n.datasets[e];n.datasets[e]=n.datasets[e-1],n.datasets[e-1]=t},v=e=>{if(e>=n.datasets.length-1)return;let t=n.datasets[e];n.datasets[e]=n.datasets[e+1],n.datasets[e+1]=t};var y=Ro(),b=L(F(y),2),x=L(F(b));Fi(x),A(b);var S=L(b,2);xa(S,{type:`contenteditable`,get model(){return n},key:`description`,placeholder:`Enter a description for this chart`,children:(e,t)=>{Ie(),W(e,Gr(`Description`))},$$slots:{default:!0}});var C=L(S,2),w=F(C),T=L(F(w)),E=F(T);E.value=E.__value=`line`;var D=L(E);D.value=D.__value=`bar`;var ee=L(D);ee.value=ee.__value=`table`,A(T);var te;wi(T),A(w);var ne=L(w,2),re=e=>{xa(e,{type:`select`,get model(){return n},key:`time_series`,selectOptions:e=>{var t=jo(),r=I(t),i=e=>{var t=ko();t.value=t.__value=``,W(e,t)};K(r,e=>{n.type!==`line`&&e(i)});var a=L(r,2),o=e=>{var t=Ao();t.value=t.__value=`daily`,W(e,t)};K(a,e=>{n.type!==`bar`&&e(o)});var s=L(a,2);s.value=s.__value=`weekly`;var c=L(s,2);c.value=c.__value=`monthly`,W(e,t)},children:(e,t)=>{Ie(),W(e,Gr(`Time series`))},$$slots:{selectOptions:!0,default:!0}})};K(ne,e=>{n.type!==`table`&&e(re)}),A(C);var ie=L(C,2),ae=F(ie);xa(L(F(ae)),{type:`date`,get model(){return n},key:`date_from`,children:(e,t)=>{W(e,Mo())},$$slots:{default:!0}}),A(ae);var oe=L(ae,2);xa(L(F(oe)),{type:`date`,get model(){return n},key:`date_to`,children:(e,t)=>{W(e,No())},$$slots:{default:!0}}),A(oe),A(ie);var se=L(ie,2),ce=F(se);q(ce,19,()=>n.datasets,e=>e.id,(e,r,i)=>{{let a=j(()=>V(r).id===V(l)),o=j(()=>V(i)===0?null:()=>_(V(i))),s=j(()=>V(i)===n.datasets.length-1?null:()=>v(V(i)));Oo(e,{get canDangerouslyUseSql(){return t.canDangerouslyUseSql},get chartConfig(){return n},get dataset(){return V(r)},get index(){return V(i)},get startOpen(){return V(a)},onDelete:()=>h(V(i)),onDuplicate:()=>g(V(i)),get onMoveUp(){return V(o)},get onMoveDown(){return V(s)}})}});var le=L(ce,2),ue=e=>{var t=Po();aa(F(t),{name:`plus`,size:18,class:`-ml-1 mt-px`}),Ie(),A(t),H(`click`,t,m),W(e,t)};K(le,e=>{n.type!==`table`&&e(ue)}),A(se);var de=L(se,2),fe=e=>{var t=Fo(),n=L(F(t),2),r=F(n,!0);A(n),A(t),R(()=>G(r,V(c))),W(e,t)};K(de,e=>{V(c)&&e(fe)});var pe=L(de,2),me=F(pe),he=e=>{var t=Io();H(`click`,t,f),W(e,t)},ge=e=>{var t=Kr(),n=I(t),r=e=>{var t=Lo();H(`click`,t,u),W(e,t)};K(n,e=>{V(o)&&e(r)}),W(e,t)};K(me,e=>{V(s)?e(he):e(ge,-1)});var _e=L(me,2);A(pe),A(y),R(()=>{te!==(te=n.type)&&(T.value=(T.__value=n.type)??``,Ci(T,n.type))}),Ji(x,()=>n.title,e=>n.title=e),H(`change`,T,p),H(`click`,_e,d),W(e,y),Je()}Ir([`change`,`click`]);var Bo=(e,t)=>{let n={};for(let e of t){let t=e.split?`${e.id} ${e.split}`:e.id;n[t]??=[],n[t].push({x:e.date,y:e.count})}return Ho(e,n),Wo(e,n),qo(e,n),Vo(e,n)},Vo=(e,t)=>e.datasets.filter(e=>e.visible!==!1).flatMap(n=>{let r={},i=Object.keys(t).filter(e=>e.startsWith(n.id));for(let e of i){let t=e.replace(/^[^ ]+ ?/,``);r[t]=e}return Object.entries(r).map(([r,i])=>{let a=n.label,o=r?r.split(`|~|`):[],s=Math.max(o.length,n.split_by?.length??0);for(let e=0;e<s;e++){let t=RegExp(`%${e+1}(?!\\d)(?:\\(([^)]+)\\))?`,`g`);if(a.match(t))a=a.replace(t,(t,n)=>o[e]?o[e]:n??`n/a`);else{let t=o[e]?o[e]:`n/a`;a=`${a}, ${t}`}}return!e.time_series&&t[i]?.[0]&&(t[i][0].x=a),{dataset:i,split:r,label:a,data:t[i],axis:n.axis===`right`?`right`:`left`}})}),Ho=(e,t)=>{for(let n of e.datasets)if(Na(n)){let r=t[n.numerator],i=t[n.denominator];if(!r||!i){console.error(`Could not find numerator or denominator for percentage dataset ${n.id}`),delete t[n.id];continue}if(e.time_series)t[n.id]=Uo(r,i);else{let e=i[0]?.y,a=r[0]?.y;if(e&&typeof a==`number`){let r=a/e;t[n.id]=[{x:n.label,y:Math.round(r*1e3)/10}]}}}},Uo=(e,t)=>{let n=0,r=0,i=[];for(;n<e.length&&r<t.length;){let a=e[n]?.x,o=t[r]?.x;if(a===o){let a=e[n]?.y??null,o=t[r]?.y??null;a!==null&&o!==null&&o!==0&&i.push({x:e[n]?.x??null,y:Math.round(a/o*1e3)/10}),n++,r++}else a<o?n++:r++}return i},Wo=(e,t)=>{if(!e.time_series)return;let n=new Set;for(let e of Object.values(t))for(let t of e)n.add(t.x);let r=Array.from(n).sort();Go(e,r);for(let e of Object.values(t)){e.sort((e,t)=>(e.x??`￿`).localeCompare(t.x??`￿`));for(let t=0;t<r.length;t++){let n=r[t],i=e[t];(!i||(i.x??``)>n)&&e.splice(t,0,{x:n,y:null})}}},Go=(e,t)=>{if(e.time_series)for(let n=0;n<t.length-1;n++){let r=t[n],i=t[t.length-1];if(!r||!i)continue;let a=new Date(r);e.time_series===`daily`?a.setUTCDate(a.getUTCDate()+1):e.time_series===`weekly`?a.setUTCDate(a.getUTCDate()+7):e.time_series===`monthly`&&a.setUTCMonth(a.getUTCMonth()+1);let o=a.toISOString().substring(0,10);o!==t[n+1]&&o<i&&t.splice(n+1,0,o)}},Ko={monthly:`month`,weekly:`week`,daily:`day`},qo=(e,t)=>{for(let n of e.datasets){if(!e.time_series)continue;let r=Ko[e.time_series];for(let[e,i]of Object.entries(t))if(e.startsWith(n.id))for(let e of i)e.x&&=Ma(e.x,r)}},Jo=document.querySelector(`[data-dashboard-config]`),Yo=Jo?.dataset?.fetchDataPath,Xo=Jo?.dataset?.updateDashboardPath,Zo=Jo?.dataset?.deleteDashboardPath,Qo=document.querySelector(`meta[name=csrf-param]`)?.content,$o=document.querySelector(`meta[name=csrf-token]`)?.content,es=class extends Error{status;constructor(e,t){super(e),this.status=t}},ts=e=>e.text().then(t=>{let n=null;if(t)try{n=JSON.parse(t)}catch{}if(!e.ok)throw new es(n?.error??`Request failed with status ${e.status}\n${t}`,e.status);return n}),ns=(e,t,n)=>{let r={[Qo]:$o};return t.date_from&&(r.date_from=t.date_from),t.date_to&&(r.date_to=t.date_to),n.page&&(r.page=n.page),typeof e==`string`?r.chart_id=e:r.configuration=e,fetch(Yo,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}).then(ts)},rs=(e,t,n)=>fetch(Xo,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({[Qo]:$o,name:t.name?.trim()||void 0,description:t.description??``,configuration:e,updated_at:n})}).then(ts),is=()=>fetch(Zo,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({[Qo]:$o})}).then(ts);function as(e){return e+.5|0}var os=(e,t,n)=>Math.max(Math.min(e,n),t);function ss(e){return os(as(e*2.55),0,255)}function cs(e){return os(as(e*255),0,255)}function ls(e){return os(as(e/2.55)/100,0,1)}function us(e){return os(as(e*100),0,100)}var ds={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},fs=[...`0123456789ABCDEF`],ps=e=>fs[e&15],ms=e=>fs[(e&240)>>4]+fs[e&15],hs=e=>(e&240)>>4==(e&15),gs=e=>hs(e.r)&&hs(e.g)&&hs(e.b)&&hs(e.a);function _s(e){var t=e.length,n;return e[0]===`#`&&(t===4||t===5?n={r:255&ds[e[1]]*17,g:255&ds[e[2]]*17,b:255&ds[e[3]]*17,a:t===5?ds[e[4]]*17:255}:(t===7||t===9)&&(n={r:ds[e[1]]<<4|ds[e[2]],g:ds[e[3]]<<4|ds[e[4]],b:ds[e[5]]<<4|ds[e[6]],a:t===9?ds[e[7]]<<4|ds[e[8]]:255})),n}var vs=(e,t)=>e<255?t(e):``;function ys(e){var t=gs(e)?ps:ms;return e?`#`+t(e.r)+t(e.g)+t(e.b)+vs(e.a,t):void 0}var bs=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function xs(e,t,n){let r=t*Math.min(n,1-n),i=(t,i=(t+e/30)%12)=>n-r*Math.max(Math.min(i-3,9-i,1),-1);return[i(0),i(8),i(4)]}function Ss(e,t,n){let r=(r,i=(r+e/60)%6)=>n-n*t*Math.max(Math.min(i,4-i,1),0);return[r(5),r(3),r(1)]}function Cs(e,t,n){let r=xs(e,1,.5),i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)r[i]*=1-t-n,r[i]+=t;return r}function ws(e,t,n,r,i){return e===i?(t-n)/r+(t<n?6:0):t===i?(n-e)/r+2:(e-t)/r+4}function Ts(e){let t=e.r/255,n=e.g/255,r=e.b/255,i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2,s,c,l;return i!==a&&(l=i-a,c=o>.5?l/(2-i-a):l/(i+a),s=ws(t,n,r,l,i),s=s*60+.5),[s|0,c||0,o]}function Es(e,t,n,r){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,r)).map(cs)}function Ds(e,t,n){return Es(xs,e,t,n)}function Os(e,t,n){return Es(Cs,e,t,n)}function ks(e,t,n){return Es(Ss,e,t,n)}function As(e){return(e%360+360)%360}function js(e){let t=bs.exec(e),n=255,r;if(!t)return;t[5]!==r&&(n=t[6]?ss(+t[5]):cs(+t[5]));let i=As(+t[2]),a=t[3]/100,o=t[4]/100;return r=t[1]===`hwb`?Os(i,a,o):t[1]===`hsv`?ks(i,a,o):Ds(i,a,o),{r:r[0],g:r[1],b:r[2],a:n}}function Ms(e,t){var n=Ts(e);n[0]=As(n[0]+t),n=Ds(n),e.r=n[0],e.g=n[1],e.b=n[2]}function Ns(e){if(!e)return;let t=Ts(e),n=t[0],r=us(t[1]),i=us(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${i}%, ${ls(e.a)})`:`hsl(${n}, ${r}%, ${i}%)`}var Ps={x:`dark`,Z:`light`,Y:`re`,X:`blu`,W:`gr`,V:`medium`,U:`slate`,A:`ee`,T:`ol`,S:`or`,B:`ra`,C:`lateg`,D:`ights`,R:`in`,Q:`turquois`,E:`hi`,P:`ro`,O:`al`,N:`le`,M:`de`,L:`yello`,F:`en`,K:`ch`,G:`arks`,H:`ea`,I:`ightg`,J:`wh`},Fs={OiceXe:`f0f8ff`,antiquewEte:`faebd7`,aqua:`ffff`,aquamarRe:`7fffd4`,azuY:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`0`,blanKedOmond:`ffebcd`,Xe:`ff`,XeviTet:`8a2be2`,bPwn:`a52a2a`,burlywood:`deb887`,caMtXe:`5f9ea0`,KartYuse:`7fff00`,KocTate:`d2691e`,cSO:`ff7f50`,cSnflowerXe:`6495ed`,cSnsilk:`fff8dc`,crimson:`dc143c`,cyan:`ffff`,xXe:`8b`,xcyan:`8b8b`,xgTMnPd:`b8860b`,xWay:`a9a9a9`,xgYF:`6400`,xgYy:`a9a9a9`,xkhaki:`bdb76b`,xmagFta:`8b008b`,xTivegYF:`556b2f`,xSange:`ff8c00`,xScEd:`9932cc`,xYd:`8b0000`,xsOmon:`e9967a`,xsHgYF:`8fbc8f`,xUXe:`483d8b`,xUWay:`2f4f4f`,xUgYy:`2f4f4f`,xQe:`ced1`,xviTet:`9400d3`,dAppRk:`ff1493`,dApskyXe:`bfff`,dimWay:`696969`,dimgYy:`696969`,dodgerXe:`1e90ff`,fiYbrick:`b22222`,flSOwEte:`fffaf0`,foYstWAn:`228b22`,fuKsia:`ff00ff`,gaRsbSo:`dcdcdc`,ghostwEte:`f8f8ff`,gTd:`ffd700`,gTMnPd:`daa520`,Way:`808080`,gYF:`8000`,gYFLw:`adff2f`,gYy:`808080`,honeyMw:`f0fff0`,hotpRk:`ff69b4`,RdianYd:`cd5c5c`,Rdigo:`4b0082`,ivSy:`fffff0`,khaki:`f0e68c`,lavFMr:`e6e6fa`,lavFMrXsh:`fff0f5`,lawngYF:`7cfc00`,NmoncEffon:`fffacd`,ZXe:`add8e6`,ZcSO:`f08080`,Zcyan:`e0ffff`,ZgTMnPdLw:`fafad2`,ZWay:`d3d3d3`,ZgYF:`90ee90`,ZgYy:`d3d3d3`,ZpRk:`ffb6c1`,ZsOmon:`ffa07a`,ZsHgYF:`20b2aa`,ZskyXe:`87cefa`,ZUWay:`778899`,ZUgYy:`778899`,ZstAlXe:`b0c4de`,ZLw:`ffffe0`,lime:`ff00`,limegYF:`32cd32`,lRF:`faf0e6`,magFta:`ff00ff`,maPon:`800000`,VaquamarRe:`66cdaa`,VXe:`cd`,VScEd:`ba55d3`,VpurpN:`9370db`,VsHgYF:`3cb371`,VUXe:`7b68ee`,VsprRggYF:`fa9a`,VQe:`48d1cc`,VviTetYd:`c71585`,midnightXe:`191970`,mRtcYam:`f5fffa`,mistyPse:`ffe4e1`,moccasR:`ffe4b5`,navajowEte:`ffdead`,navy:`80`,Tdlace:`fdf5e6`,Tive:`808000`,TivedBb:`6b8e23`,Sange:`ffa500`,SangeYd:`ff4500`,ScEd:`da70d6`,pOegTMnPd:`eee8aa`,pOegYF:`98fb98`,pOeQe:`afeeee`,pOeviTetYd:`db7093`,papayawEp:`ffefd5`,pHKpuff:`ffdab9`,peru:`cd853f`,pRk:`ffc0cb`,plum:`dda0dd`,powMrXe:`b0e0e6`,purpN:`800080`,YbeccapurpN:`663399`,Yd:`ff0000`,Psybrown:`bc8f8f`,PyOXe:`4169e1`,saddNbPwn:`8b4513`,sOmon:`fa8072`,sandybPwn:`f4a460`,sHgYF:`2e8b57`,sHshell:`fff5ee`,siFna:`a0522d`,silver:`c0c0c0`,skyXe:`87ceeb`,UXe:`6a5acd`,UWay:`708090`,UgYy:`708090`,snow:`fffafa`,sprRggYF:`ff7f`,stAlXe:`4682b4`,tan:`d2b48c`,teO:`8080`,tEstN:`d8bfd8`,tomato:`ff6347`,Qe:`40e0d0`,viTet:`ee82ee`,JHt:`f5deb3`,wEte:`ffffff`,wEtesmoke:`f5f5f5`,Lw:`ffff00`,LwgYF:`9acd32`};function Is(){let e={},t=Object.keys(Fs),n=Object.keys(Ps),r,i,a,o,s;for(r=0;r<t.length;r++){for(o=s=t[r],i=0;i<n.length;i++)a=n[i],s=s.replace(a,Ps[a]);a=parseInt(Fs[o],16),e[s]=[a>>16&255,a>>8&255,a&255]}return e}var Ls;function Rs(e){Ls||(Ls=Is(),Ls.transparent=[0,0,0,0]);let t=Ls[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}var zs=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Bs(e){let t=zs.exec(e),n=255,r,i,a;if(t){if(t[7]!==r){let e=+t[7];n=t[8]?ss(e):os(e*255,0,255)}return r=+t[1],i=+t[3],a=+t[5],r=255&(t[2]?ss(r):os(r,0,255)),i=255&(t[4]?ss(i):os(i,0,255)),a=255&(t[6]?ss(a):os(a,0,255)),{r,g:i,b:a,a:n}}}function Vs(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${ls(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}var Hs=e=>e<=.0031308?e*12.92:e**(1/2.4)*1.055-.055,Us=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;function Ws(e,t,n){let r=Us(ls(e.r)),i=Us(ls(e.g)),a=Us(ls(e.b));return{r:cs(Hs(r+n*(Us(ls(t.r))-r))),g:cs(Hs(i+n*(Us(ls(t.g))-i))),b:cs(Hs(a+n*(Us(ls(t.b))-a))),a:e.a+n*(t.a-e.a)}}function Gs(e,t,n){if(e){let r=Ts(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=Ds(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function Ks(e,t){return e&&Object.assign(t||{},e)}function qs(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=cs(e[3]))):(t=Ks(e,{r:0,g:0,b:0,a:1}),t.a=cs(t.a)),t}function Js(e){return e.charAt(0)===`r`?Bs(e):js(e)}var Ys=class e{constructor(t){if(t instanceof e)return t;let n=typeof t,r;n===`object`?r=qs(t):n===`string`&&(r=_s(t)||Rs(t)||Js(t)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var e=Ks(this._rgb);return e&&(e.a=ls(e.a)),e}set rgb(e){this._rgb=qs(e)}rgbString(){return this._valid?Vs(this._rgb):void 0}hexString(){return this._valid?ys(this._rgb):void 0}hslString(){return this._valid?Ns(this._rgb):void 0}mix(e,t){if(e){let n=this.rgb,r=e.rgb,i,a=t===i?.5:t,o=2*a-1,s=n.a-r.a,c=((o*s===-1?o:(o+s)/(1+o*s))+1)/2;i=1-c,n.r=255&c*n.r+i*r.r+.5,n.g=255&c*n.g+i*r.g+.5,n.b=255&c*n.b+i*r.b+.5,n.a=a*n.a+(1-a)*r.a,this.rgb=n}return this}interpolate(e,t){return e&&(this._rgb=Ws(this._rgb,e._rgb,t)),this}clone(){return new e(this.rgb)}alpha(e){return this._rgb.a=cs(e),this}clearer(e){let t=this._rgb;return t.a*=1-e,this}greyscale(){let e=this._rgb;return e.r=e.g=e.b=as(e.r*.3+e.g*.59+e.b*.11),this}opaquer(e){let t=this._rgb;return t.a*=1+e,this}negate(){let e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return Gs(this._rgb,2,e),this}darken(e){return Gs(this._rgb,2,-e),this}saturate(e){return Gs(this._rgb,1,e),this}desaturate(e){return Gs(this._rgb,1,-e),this}rotate(e){return Ms(this._rgb,e),this}};function Xs(){}var Zs=(()=>{let e=0;return()=>e++})();function J(e){return e==null}function Qs(e){if(Array.isArray&&Array.isArray(e))return!0;let t=Object.prototype.toString.call(e);return t.slice(0,7)===`[object`&&t.slice(-6)===`Array]`}function Y(e){return e!==null&&Object.prototype.toString.call(e)===`[object Object]`}function $s(e){return(typeof e==`number`||e instanceof Number)&&isFinite(+e)}function ec(e,t){return $s(e)?e:t}function X(e,t){return e===void 0?t:e}var tc=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100:+e/t,nc=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100*t:+e;function Z(e,t,n){if(e&&typeof e.call==`function`)return e.apply(n,t)}function Q(e,t,n,r){let i,a,o;if(Qs(e)){if(a=e.length,r)for(i=a-1;i>=0;i--)t.call(n,e[i],i);else for(i=0;i<a;i++)t.call(n,e[i],i)}else if(Y(e))for(o=Object.keys(e),a=o.length,i=0;i<a;i++)t.call(n,e[o[i]],o[i])}function rc(e,t){let n,r,i,a;if(!e||!t||e.length!==t.length)return!1;for(n=0,r=e.length;n<r;++n)if(i=e[n],a=t[n],i.datasetIndex!==a.datasetIndex||i.index!==a.index)return!1;return!0}function ic(e){if(Qs(e))return e.map(ic);if(Y(e)){let t=Object.create(null),n=Object.keys(e),r=n.length,i=0;for(;i<r;++i)t[n[i]]=ic(e[n[i]]);return t}return e}function ac(e){return[`__proto__`,`prototype`,`constructor`].indexOf(e)===-1}function oc(e,t,n,r){if(!ac(e))return;let i=t[e],a=n[e];Y(i)&&Y(a)?sc(i,a,r):t[e]=ic(a)}function sc(e,t,n){let r=Qs(t)?t:[t],i=r.length;if(!Y(e))return e;n||={};let a=n.merger||oc,o;for(let t=0;t<i;++t){if(o=r[t],!Y(o))continue;let i=Object.keys(o);for(let t=0,r=i.length;t<r;++t)a(i[t],e,o,n)}return e}function cc(e,t){return sc(e,t,{merger:lc})}function lc(e,t,n){if(!ac(e))return;let r=t[e],i=n[e];Y(r)&&Y(i)?cc(r,i):Object.prototype.hasOwnProperty.call(t,e)||(t[e]=ic(i))}var uc={"":e=>e,x:e=>e.x,y:e=>e.y};function dc(e){let t=e.split(`.`),n=[],r=``;for(let e of t)r+=e,r.endsWith(`\\`)?r=r.slice(0,-1)+`.`:(n.push(r),r=``);return n}function fc(e){let t=dc(e);return e=>{for(let n of t){if(n===``)break;e&&=e[n]}return e}}function pc(e,t){return(uc[t]||(uc[t]=fc(t)))(e)}function mc(e){return e.charAt(0).toUpperCase()+e.slice(1)}var hc=e=>e!==void 0,gc=e=>typeof e==`function`,_c=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};function vc(e){return e.type===`mouseup`||e.type===`click`||e.type===`contextmenu`}var $=Math.PI,yc=2*$,bc=yc+$,xc=1/0,Sc=$/180,Cc=$/2,wc=$/4,Tc=$*2/3,Ec=Math.log10,Dc=Math.sign;function Oc(e,t,n){return Math.abs(e-t)<n}function kc(e){let t=Math.round(e);e=Oc(e,t,e/1e3)?t:e;let n=10**Math.floor(Ec(e)),r=e/n;return(r<=1?1:r<=2?2:r<=5?5:10)*n}function Ac(e){let t=[],n=Math.sqrt(e),r;for(r=1;r<n;r++)e%r===0&&(t.push(r),t.push(e/r));return n===(n|0)&&t.push(n),t.sort((e,t)=>e-t).pop(),t}function jc(e){return typeof e==`symbol`||typeof e==`object`&&!!e&&!(Symbol.toPrimitive in e||`toString`in e||`valueOf`in e)}function Mc(e){return!jc(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function Nc(e,t){let n=Math.round(e);return n-t<=e&&n+t>=e}function Pc(e,t,n){let r,i,a;for(r=0,i=e.length;r<i;r++)a=e[r][n],isNaN(a)||(t.min=Math.min(t.min,a),t.max=Math.max(t.max,a))}function Fc(e){return $/180*e}function Ic(e){return 180/$*e}function Lc(e){if(!$s(e))return;let t=1,n=0;for(;Math.round(e*t)/t!==e;)t*=10,n++;return n}function Rc(e,t){let n=t.x-e.x,r=t.y-e.y,i=Math.sqrt(n*n+r*r),a=Math.atan2(r,n);return a<-.5*$&&(a+=yc),{angle:a,distance:i}}function zc(e,t){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)}function Bc(e,t){return(e-t+bc)%yc-$}function Vc(e){return(e%yc+yc)%yc}function Hc(e,t,n,r){let i=Vc(e),a=Vc(t),o=Vc(n),s=Vc(a-i),c=Vc(o-i),l=Vc(i-a),u=Vc(i-o);return i===a||i===o||r&&a===o||s>c&&l<u}function Uc(e,t,n){return Math.max(t,Math.min(n,e))}function Wc(e){return Uc(e,-32768,32767)}function Gc(e,t,n,r=1e-6){return e>=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function Kc(e,t,n){n||=(n=>e[n]<t);let r=e.length-1,i=0,a;for(;r-i>1;)a=i+r>>1,n(a)?i=a:r=a;return{lo:i,hi:r}}var qc=(e,t,n,r)=>Kc(e,n,r?r=>{let i=e[r][t];return i<n||i===n&&e[r+1][t]===n}:r=>e[r][t]<n),Jc=(e,t,n)=>Kc(e,n,r=>e[r][t]>=n);function Yc(e,t,n){let r=0,i=e.length;for(;r<i&&e[r]<t;)r++;for(;i>r&&e[i-1]>n;)i--;return r>0||i<e.length?e.slice(r,i):e}var Xc=[`push`,`pop`,`shift`,`splice`,`unshift`];function Zc(e,t){if(e._chartjs){e._chartjs.listeners.push(t);return}Object.defineProperty(e,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[t]}}),Xc.forEach(t=>{let n=`_onData`+mc(t),r=e[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value(...t){let i=r.apply(this,t);return e._chartjs.listeners.forEach(e=>{typeof e[n]==`function`&&e[n](...t)}),i}})})}function Qc(e,t){let n=e._chartjs;if(!n)return;let r=n.listeners,i=r.indexOf(t);i!==-1&&r.splice(i,1),!(r.length>0)&&(Xc.forEach(t=>{delete e[t]}),delete e._chartjs)}function $c(e){let t=new Set(e);return t.size===e.length?e:Array.from(t)}var el=function(){return typeof window>`u`?function(e){return e()}:window.requestAnimationFrame}();function tl(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,el.call(window,()=>{r=!1,e.apply(t,n)}))}}function nl(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}var rl=e=>e===`start`?`left`:e===`end`?`right`:`center`,il=(e,t,n)=>e===`start`?t:e===`end`?n:(t+n)/2,al=(e,t,n,r)=>e===(r?`left`:`right`)?n:e===`center`?(t+n)/2:t;function ol(e,t,n){let r=t.length,i=0,a=r;if(e._sorted){let{iScale:o,vScale:s,_parsed:c}=e,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=o.axis,{min:d,max:f,minDefined:p,maxDefined:m}=o.getUserBounds();if(p){if(i=Math.min(qc(c,u,d).lo,n?r:qc(t,u,o.getPixelForValue(d)).lo),l){let e=c.slice(0,i+1).reverse().findIndex(e=>!J(e[s.axis]));i-=Math.max(0,e)}i=Uc(i,0,r-1)}if(m){let e=Math.max(qc(c,o.axis,f,!0).hi+1,n?0:qc(t,u,o.getPixelForValue(f),!0).hi+1);if(l){let t=c.slice(e-1).findIndex(e=>!J(e[s.axis]));e+=Math.max(0,t)}a=Uc(e,i,r)-i}else a=r-i}return{start:i,count:a}}function sl(e){let{xScale:t,yScale:n,_scaleRanges:r}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!r)return e._scaleRanges=i,!0;let a=r.xmin!==t.min||r.xmax!==t.max||r.ymin!==n.min||r.ymax!==n.max;return Object.assign(r,i),a}var cl=e=>e===0||e===1,ll=(e,t,n)=>-(2**(10*--e)*Math.sin((e-t)*yc/n)),ul=(e,t,n)=>2**(-10*e)*Math.sin((e-t)*yc/n)+1,dl={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-(--e*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>--e*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*Cc)+1,easeOutSine:e=>Math.sin(e*Cc),easeInOutSine:e=>-.5*(Math.cos($*e)-1),easeInExpo:e=>e===0?0:2**(10*(e-1)),easeOutExpo:e=>e===1?1:-(2**(-10*e))+1,easeInOutExpo:e=>cl(e)?e:e<.5?.5*2**(10*(e*2-1)):.5*(-(2**(-10*(e*2-1)))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1- --e*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>cl(e)?e:ll(e,.075,.3),easeOutElastic:e=>cl(e)?e:ul(e,.075,.3),easeInOutElastic(e){let t=.1125,n=.45;return cl(e)?e:e<.5?.5*ll(e*2,t,n):.5+.5*ul(e*2-1,t,n)},easeInBack(e){return e*e*(2.70158*e-1.70158)},easeOutBack(e){return--e*e*(2.70158*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-dl.easeOutBounce(1-e),easeOutBounce(e){let t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},easeInOutBounce:e=>e<.5?dl.easeInBounce(e*2)*.5:dl.easeOutBounce(e*2-1)*.5+.5};function fl(e){if(e&&typeof e==`object`){let t=e.toString();return t===`[object CanvasPattern]`||t===`[object CanvasGradient]`}return!1}function pl(e){return fl(e)?e:new Ys(e)}function ml(e){return fl(e)?e:new Ys(e).saturate(.5).darken(.1).hexString()}var hl=[`x`,`y`,`borderWidth`,`radius`,`tension`],gl=[`color`,`borderColor`,`backgroundColor`];function _l(e){e.set(`animation`,{delay:void 0,duration:1e3,easing:`easeOutQuart`,fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe(`animation`,{_fallback:!1,_indexable:!1,_scriptable:e=>e!==`onProgress`&&e!==`onComplete`&&e!==`fn`}),e.set(`animations`,{colors:{type:`color`,properties:gl},numbers:{type:`number`,properties:hl}}),e.describe(`animations`,{_fallback:`animation`}),e.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:e=>e|0}}}})}function vl(e){e.set(`layout`,{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var yl=new Map;function bl(e,t){t||={};let n=e+JSON.stringify(t),r=yl.get(n);return r||(r=new Intl.NumberFormat(e,t),yl.set(n,r)),r}function xl(e,t,n){return bl(t,n).format(e)}var Sl={values(e){return Qs(e)?e:``+e},numeric(e,t,n){if(e===0)return`0`;let r=this.chart.options.locale,i,a=e;if(n.length>1){let t=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(t<1e-4||t>0x38d7ea4c68000)&&(i=`scientific`),a=Cl(e,n)}let o=Ec(Math.abs(a)),s=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),c={notation:i,minimumFractionDigits:s,maximumFractionDigits:s};return Object.assign(c,this.options.ticks.format),xl(e,r,c)},logarithmic(e,t,n){if(e===0)return`0`;let r=n[t].significand||e/10**Math.floor(Ec(e));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?Sl.numeric.call(this,e,t,n):``}};function Cl(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var wl={formatters:Sl};function Tl(e){e.set(`scale`,{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:`ticks`,clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,t)=>t.lineWidth,tickColor:(e,t)=>t.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width: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:wl.formatters.values,minor:{},major:{},align:`center`,crossAlign:`near`,showLabelBackdrop:!1,backdropColor:`rgba(255, 255, 255, 0.75)`,backdropPadding:2}}),e.route(`scale.ticks`,`color`,``,`color`),e.route(`scale.grid`,`color`,``,`borderColor`),e.route(`scale.border`,`color`,``,`borderColor`),e.route(`scale.title`,`color`,``,`color`),e.describe(`scale`,{_fallback:!1,_scriptable:e=>!e.startsWith(`before`)&&!e.startsWith(`after`)&&e!==`callback`&&e!==`parser`,_indexable:e=>e!==`borderDash`&&e!==`tickBorderDash`&&e!==`dash`}),e.describe(`scales`,{_fallback:`scale`}),e.describe(`scale.ticks`,{_scriptable:e=>e!==`backdropPadding`&&e!==`callback`,_indexable:e=>e!==`backdropPadding`})}var El=Object.create(null),Dl=Object.create(null);function Ol(e,t){if(!t)return e;let n=t.split(`.`);for(let t=0,r=n.length;t<r;++t){let r=n[t];e=e[r]||(e[r]=Object.create(null))}return e}function kl(e,t,n){return typeof t==`string`?sc(Ol(e,t),n):sc(Ol(e,``),t)}var Al=new class{constructor(e,t){this.animation=void 0,this.backgroundColor=`rgba(0,0,0,0.1)`,this.borderColor=`rgba(0,0,0,0.1)`,this.color=`#666`,this.datasets={},this.devicePixelRatio=e=>e.chart.platform.getDevicePixelRatio(),this.elements={},this.events=[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`],this.font={family:`'Helvetica Neue', 'Helvetica', 'Arial', sans-serif`,size:12,style:`normal`,lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(e,t)=>ml(t.backgroundColor),this.hoverBorderColor=(e,t)=>ml(t.borderColor),this.hoverColor=(e,t)=>ml(t.color),this.indexAxis=`x`,this.interaction={mode:`nearest`,intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(t)}set(e,t){return kl(this,e,t)}get(e){return Ol(this,e)}describe(e,t){return kl(Dl,e,t)}override(e,t){return kl(El,e,t)}route(e,t,n,r){let i=Ol(this,e),a=Ol(this,n),o=`_`+t;Object.defineProperties(i,{[o]:{value:i[t],writable:!0},[t]:{enumerable:!0,get(){let e=this[o],t=a[r];return Y(e)?Object.assign({},t,e):X(e,t)},set(e){this[o]=e}}})}apply(e){e.forEach(e=>e(this))}}({_scriptable:e=>!e.startsWith(`on`),_indexable:e=>e!==`events`,hover:{_fallback:`interaction`},interaction:{_scriptable:!1,_indexable:!1}},[_l,vl,Tl]);function jl(e){return!e||J(e.size)||J(e.family)?null:(e.style?e.style+` `:``)+(e.weight?e.weight+` `:``)+e.size+`px `+e.family}function Ml(e,t,n,r,i){let a=t[i];return a||(a=t[i]=e.measureText(i).width,n.push(i)),a>r&&(r=a),r}function Nl(e,t,n,r){r||={};let i=r.data=r.data||{},a=r.garbageCollect=r.garbageCollect||[];r.font!==t&&(i=r.data={},a=r.garbageCollect=[],r.font=t),e.save(),e.font=t;let o=0,s=n.length,c,l,u,d,f;for(c=0;c<s;c++)if(d=n[c],d!=null&&!Qs(d))o=Ml(e,i,a,o,d);else if(Qs(d))for(l=0,u=d.length;l<u;l++)f=d[l],f!=null&&!Qs(f)&&(o=Ml(e,i,a,o,f));e.restore();let p=a.length/2;if(p>n.length){for(c=0;c<p;c++)delete i[a[c]];a.splice(0,p)}return o}function Pl(e,t,n){let r=e.currentDevicePixelRatio,i=n===0?0:Math.max(n/2,.5);return Math.round((t-i)*r)/r+i}function Fl(e,t){!t&&!e||(t||=e.getContext(`2d`),t.save(),t.resetTransform(),t.clearRect(0,0,e.width,e.height),t.restore())}function Il(e,t,n,r){Ll(e,t,n,r,null)}function Ll(e,t,n,r,i){let a,o,s,c,l,u,d,f,p=t.pointStyle,m=t.rotation,h=t.radius,g=(m||0)*Sc;if(p&&typeof p==`object`&&(a=p.toString(),a===`[object HTMLImageElement]`||a===`[object HTMLCanvasElement]`)){e.save(),e.translate(n,r),e.rotate(g),e.drawImage(p,-p.width/2,-p.height/2,p.width,p.height),e.restore();return}if(!(isNaN(h)||h<=0)){switch(e.beginPath(),p){default:i?e.ellipse(n,r,i/2,h,0,0,yc):e.arc(n,r,h,0,yc),e.closePath();break;case`triangle`:u=i?i/2:h,e.moveTo(n+Math.sin(g)*u,r-Math.cos(g)*h),g+=Tc,e.lineTo(n+Math.sin(g)*u,r-Math.cos(g)*h),g+=Tc,e.lineTo(n+Math.sin(g)*u,r-Math.cos(g)*h),e.closePath();break;case`rectRounded`:l=h*.516,c=h-l,o=Math.cos(g+wc)*c,d=Math.cos(g+wc)*(i?i/2-l:c),s=Math.sin(g+wc)*c,f=Math.sin(g+wc)*(i?i/2-l:c),e.arc(n-d,r-s,l,g-$,g-Cc),e.arc(n+f,r-o,l,g-Cc,g),e.arc(n+d,r+s,l,g,g+Cc),e.arc(n-f,r+o,l,g+Cc,g+$),e.closePath();break;case`rect`:if(!m){c=Math.SQRT1_2*h,u=i?i/2:c,e.rect(n-u,r-c,2*u,2*c);break}g+=wc;case`rectRot`:d=Math.cos(g)*(i?i/2:h),o=Math.cos(g)*h,s=Math.sin(g)*h,f=Math.sin(g)*(i?i/2:h),e.moveTo(n-d,r-s),e.lineTo(n+f,r-o),e.lineTo(n+d,r+s),e.lineTo(n-f,r+o),e.closePath();break;case`crossRot`:g+=wc;case`cross`:d=Math.cos(g)*(i?i/2:h),o=Math.cos(g)*h,s=Math.sin(g)*h,f=Math.sin(g)*(i?i/2:h),e.moveTo(n-d,r-s),e.lineTo(n+d,r+s),e.moveTo(n+f,r-o),e.lineTo(n-f,r+o);break;case`star`:d=Math.cos(g)*(i?i/2:h),o=Math.cos(g)*h,s=Math.sin(g)*h,f=Math.sin(g)*(i?i/2:h),e.moveTo(n-d,r-s),e.lineTo(n+d,r+s),e.moveTo(n+f,r-o),e.lineTo(n-f,r+o),g+=wc,d=Math.cos(g)*(i?i/2:h),o=Math.cos(g)*h,s=Math.sin(g)*h,f=Math.sin(g)*(i?i/2:h),e.moveTo(n-d,r-s),e.lineTo(n+d,r+s),e.moveTo(n+f,r-o),e.lineTo(n-f,r+o);break;case`line`:o=i?i/2:Math.cos(g)*h,s=Math.sin(g)*h,e.moveTo(n-o,r-s),e.lineTo(n+o,r+s);break;case`dash`:e.moveTo(n,r),e.lineTo(n+Math.cos(g)*(i?i/2:h),r+Math.sin(g)*h);break;case!1:e.closePath()}e.fill(),t.borderWidth>0&&e.stroke()}}function Rl(e,t,n){return n||=.5,!t||e&&e.x>t.left-n&&e.x<t.right+n&&e.y>t.top-n&&e.y<t.bottom+n}function zl(e,t){e.save(),e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.clip()}function Bl(e){e.restore()}function Vl(e,t,n,r,i){if(!t)return e.lineTo(n.x,n.y);if(i===`middle`){let r=(t.x+n.x)/2;e.lineTo(r,t.y),e.lineTo(r,n.y)}else i===`after`==!!r?e.lineTo(n.x,t.y):e.lineTo(t.x,n.y);e.lineTo(n.x,n.y)}function Hl(e,t,n,r){if(!t)return e.lineTo(n.x,n.y);e.bezierCurveTo(r?t.cp1x:t.cp2x,r?t.cp1y:t.cp2y,r?n.cp2x:n.cp1x,r?n.cp2y:n.cp1y,n.x,n.y)}function Ul(e,t){t.translation&&e.translate(t.translation[0],t.translation[1]),J(t.rotation)||e.rotate(t.rotation),t.color&&(e.fillStyle=t.color),t.textAlign&&(e.textAlign=t.textAlign),t.textBaseline&&(e.textBaseline=t.textBaseline)}function Wl(e,t,n,r,i){if(i.strikethrough||i.underline){let a=e.measureText(r),o=t-a.actualBoundingBoxLeft,s=t+a.actualBoundingBoxRight,c=n-a.actualBoundingBoxAscent,l=n+a.actualBoundingBoxDescent,u=i.strikethrough?(c+l)/2:l;e.strokeStyle=e.fillStyle,e.beginPath(),e.lineWidth=i.decorationWidth||2,e.moveTo(o,u),e.lineTo(s,u),e.stroke()}}function Gl(e,t){let n=e.fillStyle;e.fillStyle=t.color,e.fillRect(t.left,t.top,t.width,t.height),e.fillStyle=n}function Kl(e,t,n,r,i,a={}){let o=Qs(t)?t:[t],s=a.strokeWidth>0&&a.strokeColor!==``,c,l;for(e.save(),e.font=i.string,Ul(e,a),c=0;c<o.length;++c)l=o[c],a.backdrop&&Gl(e,a.backdrop),s&&(a.strokeColor&&(e.strokeStyle=a.strokeColor),J(a.strokeWidth)||(e.lineWidth=a.strokeWidth),e.strokeText(l,n,r,a.maxWidth)),e.fillText(l,n,r,a.maxWidth),Wl(e,n,r,l,a),r+=Number(i.lineHeight);e.restore()}function ql(e,t){let{x:n,y:r,w:i,h:a,radius:o}=t;e.arc(n+o.topLeft,r+o.topLeft,o.topLeft,1.5*$,$,!0),e.lineTo(n,r+a-o.bottomLeft),e.arc(n+o.bottomLeft,r+a-o.bottomLeft,o.bottomLeft,$,Cc,!0),e.lineTo(n+i-o.bottomRight,r+a),e.arc(n+i-o.bottomRight,r+a-o.bottomRight,o.bottomRight,Cc,0,!0),e.lineTo(n+i,r+o.topRight),e.arc(n+i-o.topRight,r+o.topRight,o.topRight,0,-Cc,!0),e.lineTo(n+o.topLeft,r)}var Jl=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,Yl=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function Xl(e,t){let n=(``+e).match(Jl);if(!n||n[1]===`normal`)return t*1.2;switch(e=+n[2],n[3]){case`px`:return e;case`%`:e/=100}return t*e}var Zl=e=>+e||0;function Ql(e,t){let n={},r=Y(t),i=r?Object.keys(t):t,a=Y(e)?r?n=>X(e[n],e[t[n]]):t=>e[t]:()=>e;for(let e of i)n[e]=Zl(a(e));return n}function $l(e){return Ql(e,{top:`y`,right:`x`,bottom:`y`,left:`x`})}function eu(e){return Ql(e,[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`])}function tu(e){let t=$l(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function nu(e,t){e||={},t||=Al.font;let n=X(e.size,t.size);typeof n==`string`&&(n=parseInt(n,10));let r=X(e.style,t.style);r&&!(``+r).match(Yl)&&(console.warn(`Invalid font style specified: "`+r+`"`),r=void 0);let i={family:X(e.family,t.family),lineHeight:Xl(X(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:X(e.weight,t.weight),string:``};return i.string=jl(i),i}function ru(e,t,n,r){let i=!0,a,o,s;for(a=0,o=e.length;a<o;++a)if(s=e[a],s!==void 0&&(t!==void 0&&typeof s==`function`&&(s=s(t),i=!1),n!==void 0&&Qs(s)&&(s=s[n%s.length],i=!1),s!==void 0))return r&&!i&&(r.cacheable=!1),s}function iu(e,t,n){let{min:r,max:i}=e,a=nc(t,(i-r)/2),o=(e,t)=>n&&e===0?0:e+t;return{min:o(r,-Math.abs(a)),max:o(i,a)}}function au(e,t){return Object.assign(Object.create(e),t)}function ou(e,t=[``],n,r,i=()=>e[0]){let a=n||e;return r===void 0&&(r=Su(`_fallback`,e)),new Proxy({[Symbol.toStringTag]:`Object`,_cacheable:!0,_scopes:e,_rootScopes:a,_fallback:r,_getTarget:i,override:n=>ou([n,...e],t,a,r)},{deleteProperty(t,n){return delete t[n],delete t._keys,delete e[0][n],!0},get(n,r){return du(n,r,()=>xu(r,t,e,n))},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e._scopes[0],t)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(e,t){return Cu(e).includes(t)},ownKeys(e){return Cu(e)},set(e,t,n){let r=e._storage||=i();return e[t]=r[t]=n,delete e._keys,!0}})}function su(e,t,n,r){let i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:cu(e,r),setContext:t=>su(e,t,n,r),override:i=>su(e.override(i),t,n,r)};return new Proxy(i,{deleteProperty(t,n){return delete t[n],delete e[n],!0},get(e,t,n){return du(e,t,()=>fu(e,t,n))},getOwnPropertyDescriptor(t,n){return t._descriptors.allKeys?Reflect.has(e,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,n)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(t,n){return Reflect.has(e,n)},ownKeys(){return Reflect.ownKeys(e)},set(t,n,r){return e[n]=r,delete t[n],!0}})}function cu(e,t={scriptable:!0,indexable:!0}){let{_scriptable:n=t.scriptable,_indexable:r=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:r,isScriptable:gc(n)?n:()=>n,isIndexable:gc(r)?r:()=>r}}var lu=(e,t)=>e?e+mc(t):t,uu=(e,t)=>Y(t)&&e!==`adapters`&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function du(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t===`constructor`)return e[t];let r=n();return e[t]=r,r}function fu(e,t,n){let{_proxy:r,_context:i,_subProxy:a,_descriptors:o}=e,s=r[t];return gc(s)&&o.isScriptable(t)&&(s=pu(t,s,e,n)),Qs(s)&&s.length&&(s=mu(t,s,e,o.isIndexable)),uu(t,s)&&(s=su(s,i,a&&a[t],o)),s}function pu(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_stack:s}=n;if(s.has(e))throw Error(`Recursion detected: `+Array.from(s).join(`->`)+`->`+e);s.add(e);let c=t(a,o||r);return s.delete(e),uu(e,c)&&(c=vu(i._scopes,i,e,c)),c}function mu(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_descriptors:s}=n;if(a.index!==void 0&&r(e))return t[a.index%t.length];if(Y(t[0])){let n=t,r=i._scopes.filter(e=>e!==n);t=[];for(let c of n){let n=vu(r,i,e,c);t.push(su(n,a,o&&o[e],s))}}return t}function hu(e,t,n){return gc(e)?e(t,n):e}var gu=(e,t)=>e===!0?t:typeof e==`string`?pc(t,e):void 0;function _u(e,t,n,r,i){for(let a of t){let t=gu(n,a);if(t){e.add(t);let a=hu(t._fallback,n,i);if(a!==void 0&&a!==n&&a!==r)return a}else if(t===!1&&r!==void 0&&n!==r)return null}return!1}function vu(e,t,n,r){let i=t._rootScopes,a=hu(t._fallback,n,r),o=[...e,...i],s=new Set;s.add(r);let c=yu(s,o,n,a||n,r);return c===null||a!==void 0&&a!==n&&(c=yu(s,o,a,c,r),c===null)?!1:ou(Array.from(s),[``],i,a,()=>bu(t,n,r))}function yu(e,t,n,r,i){for(;n;)n=_u(e,t,n,r,i);return n}function bu(e,t,n){let r=e._getTarget();t in r||(r[t]={});let i=r[t];return Qs(i)&&Y(n)?n:i||{}}function xu(e,t,n,r){let i;for(let a of t)if(i=Su(lu(a,e),n),i!==void 0)return uu(e,i)?vu(n,r,e,i):i}function Su(e,t){for(let n of t){if(!n)continue;let t=n[e];if(t!==void 0)return t}}function Cu(e){let t=e._keys;return t||=e._keys=wu(e._scopes),t}function wu(e){let t=new Set;for(let n of e)for(let e of Object.keys(n).filter(e=>!e.startsWith(`_`)))t.add(e);return Array.from(t)}function Tu(e,t,n,r){let{iScale:i}=e,{key:a=`r`}=this._parsing,o=Array(r),s,c,l,u;for(s=0,c=r;s<c;++s)l=s+n,u=t[l],o[s]={r:i.parse(pc(u,a),l)};return o}var Eu=2**-52||1e-14,Du=(e,t)=>t<e.length&&!e[t].skip&&e[t],Ou=e=>e===`x`?`y`:`x`;function ku(e,t,n,r){let i=e.skip?t:e,a=t,o=n.skip?t:n,s=zc(a,i),c=zc(o,a),l=s/(s+c),u=c/(s+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;let d=r*l,f=r*u;return{previous:{x:a.x-d*(o.x-i.x),y:a.y-d*(o.y-i.y)},next:{x:a.x+f*(o.x-i.x),y:a.y+f*(o.y-i.y)}}}function Au(e,t,n){let r=e.length,i,a,o,s,c,l=Du(e,0);for(let u=0;u<r-1;++u)if(c=l,l=Du(e,u+1),!(!c||!l)){if(Oc(t[u],0,Eu)){n[u]=n[u+1]=0;continue}i=n[u]/t[u],a=n[u+1]/t[u],s=i**2+a**2,!(s<=9)&&(o=3/Math.sqrt(s),n[u]=i*o*t[u],n[u+1]=a*o*t[u])}}function ju(e,t,n=`x`){let r=Ou(n),i=e.length,a,o,s,c=Du(e,0);for(let l=0;l<i;++l){if(o=s,s=c,c=Du(e,l+1),!s)continue;let i=s[n],u=s[r];o&&(a=(i-o[n])/3,s[`cp1${n}`]=i-a,s[`cp1${r}`]=u-a*t[l]),c&&(a=(c[n]-i)/3,s[`cp2${n}`]=i+a,s[`cp2${r}`]=u+a*t[l])}}function Mu(e,t=`x`){let n=Ou(t),r=e.length,i=Array(r).fill(0),a=Array(r),o,s,c,l=Du(e,0);for(o=0;o<r;++o)if(s=c,c=l,l=Du(e,o+1),c){if(l){let e=l[t]-c[t];i[o]=e===0?0:(l[n]-c[n])/e}a[o]=s?l?Dc(i[o-1])===Dc(i[o])?(i[o-1]+i[o])/2:0:i[o-1]:i[o]}Au(e,i,a),ju(e,a,t)}function Nu(e,t,n){return Math.max(Math.min(e,n),t)}function Pu(e,t){let n,r,i,a,o,s=Rl(e[0],t);for(n=0,r=e.length;n<r;++n)o=a,a=s,s=n<r-1&&Rl(e[n+1],t),a&&(i=e[n],o&&(i.cp1x=Nu(i.cp1x,t.left,t.right),i.cp1y=Nu(i.cp1y,t.top,t.bottom)),s&&(i.cp2x=Nu(i.cp2x,t.left,t.right),i.cp2y=Nu(i.cp2y,t.top,t.bottom)))}function Fu(e,t,n,r,i){let a,o,s,c;if(t.spanGaps&&(e=e.filter(e=>!e.skip)),t.cubicInterpolationMode===`monotone`)Mu(e,i);else{let n=r?e[e.length-1]:e[0];for(a=0,o=e.length;a<o;++a)s=e[a],c=ku(n,s,e[Math.min(a+1,o-+!r)%o],t.tension),s.cp1x=c.previous.x,s.cp1y=c.previous.y,s.cp2x=c.next.x,s.cp2y=c.next.y,n=s}t.capBezierPoints&&Pu(e,n)}function Iu(){return typeof window<`u`&&typeof document<`u`}function Lu(e){let t=e.parentNode;return t&&t.toString()===`[object ShadowRoot]`&&(t=t.host),t}function Ru(e,t,n){let r;return typeof e==`string`?(r=parseInt(e,10),e.indexOf(`%`)!==-1&&(r=r/100*t.parentNode[n])):r=e,r}var zu=e=>e.ownerDocument.defaultView.getComputedStyle(e,null);function Bu(e,t){return zu(e).getPropertyValue(t)}var Vu=[`top`,`right`,`bottom`,`left`];function Hu(e,t,n){let r={};n=n?`-`+n:``;for(let i=0;i<4;i++){let a=Vu[i];r[a]=parseFloat(e[t+`-`+a+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}var Uu=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function Wu(e,t){let n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:a}=r,o=!1,s,c;if(Uu(i,a,e.target))s=i,c=a;else{let e=t.getBoundingClientRect();s=r.clientX-e.left,c=r.clientY-e.top,o=!0}return{x:s,y:c,box:o}}function Gu(e,t){if(`native`in e)return e;let{canvas:n,currentDevicePixelRatio:r}=t,i=zu(n),a=i.boxSizing===`border-box`,o=Hu(i,`padding`),s=Hu(i,`border`,`width`),{x:c,y:l,box:u}=Wu(e,n),d=o.left+(u&&s.left),f=o.top+(u&&s.top),{width:p,height:m}=t;return a&&(p-=o.width+s.width,m-=o.height+s.height),{x:Math.round((c-d)/p*n.width/r),y:Math.round((l-f)/m*n.height/r)}}function Ku(e,t,n){let r,i;if(t===void 0||n===void 0){let a=e&&Lu(e);if(!a)t=e.clientWidth,n=e.clientHeight;else{let e=a.getBoundingClientRect(),o=zu(a),s=Hu(o,`border`,`width`),c=Hu(o,`padding`);t=e.width-c.width-s.width,n=e.height-c.height-s.height,r=Ru(o.maxWidth,a,`clientWidth`),i=Ru(o.maxHeight,a,`clientHeight`)}}return{width:t,height:n,maxWidth:r||xc,maxHeight:i||xc}}var qu=e=>Math.round(e*10)/10;function Ju(e,t,n,r){let i=zu(e),a=Hu(i,`margin`),o=Ru(i.maxWidth,e,`clientWidth`)||xc,s=Ru(i.maxHeight,e,`clientHeight`)||xc,c=Ku(e,t,n),{width:l,height:u}=c;if(i.boxSizing===`content-box`){let e=Hu(i,`border`,`width`),t=Hu(i,`padding`);l-=t.width+e.width,u-=t.height+e.height}return l=Math.max(0,l-a.width),u=Math.max(0,r?l/r:u-a.height),l=qu(Math.min(l,o,c.maxWidth)),u=qu(Math.min(u,s,c.maxHeight)),l&&!u&&(u=qu(l/2)),(t!==void 0||n!==void 0)&&r&&c.height&&u>c.height&&(u=c.height,l=qu(Math.floor(u*r))),{width:l,height:u}}function Yu(e,t,n){let r=t||1,i=qu(e.height*r),a=qu(e.width*r);e.height=qu(e.height),e.width=qu(e.width);let o=e.canvas;return o.style&&(n||!o.style.height&&!o.style.width)&&(o.style.height=`${e.height}px`,o.style.width=`${e.width}px`),e.currentDevicePixelRatio!==r||o.height!==i||o.width!==a?(e.currentDevicePixelRatio=r,o.height=i,o.width=a,e.ctx.setTransform(r,0,0,r,0,0),!0):!1}var Xu=function(){let e=!1;try{let t={get passive(){return e=!0,!1}};Iu()&&(window.addEventListener(`test`,null,t),window.removeEventListener(`test`,null,t))}catch{}return e}();function Zu(e,t){let n=Bu(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function Qu(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function $u(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:r===`middle`?n<.5?e.y:t.y:r===`after`?n<1?e.y:t.y:n>0?t.y:e.y}}function ed(e,t,n,r){let i={x:e.cp2x,y:e.cp2y},a={x:t.cp1x,y:t.cp1y},o=Qu(e,i,n),s=Qu(i,a,n),c=Qu(a,t,n);return Qu(Qu(o,s,n),Qu(s,c,n),n)}var td=function(e,t){return{x(n){return e+e+t-n},setWidth(e){t=e},textAlign(e){return e===`center`?e:e===`right`?`left`:`right`},xPlus(e,t){return e-t},leftForLtr(e,t){return e-t}}},nd=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function rd(e,t,n){return e?td(t,n):nd()}function id(e,t){let n,r;(t===`ltr`||t===`rtl`)&&(n=e.canvas.style,r=[n.getPropertyValue(`direction`),n.getPropertyPriority(`direction`)],n.setProperty(`direction`,t,`important`),e.prevTextDirection=r)}function ad(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty(`direction`,t[0],t[1]))}function od(e){return e===`angle`?{between:Hc,compare:Bc,normalize:Vc}:{between:Gc,compare:(e,t)=>e-t,normalize:e=>e}}function sd({start:e,end:t,count:n,loop:r,style:i}){return{start:e%n,end:t%n,loop:r&&(t-e+1)%n===0,style:i}}function cd(e,t,n){let{property:r,start:i,end:a}=n,{between:o,normalize:s}=od(r),c=t.length,{start:l,end:u,loop:d}=e,f,p;if(d){for(l+=c,u+=c,f=0,p=c;f<p&&o(s(t[l%c][r]),i,a);++f)l--,u--;l%=c,u%=c}return u<l&&(u+=c),{start:l,end:u,loop:d,style:e.style}}function ld(e,t,n){if(!n)return[e];let{property:r,start:i,end:a}=n,o=t.length,{compare:s,between:c,normalize:l}=od(r),{start:u,end:d,loop:f,style:p}=cd(e,t,n),m=[],h=!1,g=null,_,v,y,b=()=>c(i,y,_)&&s(i,y)!==0,x=()=>s(a,_)===0||c(a,y,_),S=()=>h||b(),C=()=>!h||x();for(let e=u,n=u;e<=d;++e)v=t[e%o],!v.skip&&(_=l(v[r]),_!==y&&(h=c(_,i,a),g===null&&S()&&(g=s(_,i)===0?e:n),g!==null&&C()&&(m.push(sd({start:g,end:e,loop:f,count:o,style:p})),g=null),n=e,y=_));return g!==null&&m.push(sd({start:g,end:d,loop:f,count:o,style:p})),m}function ud(e,t){let n=[],r=e.segments;for(let i=0;i<r.length;i++){let a=ld(r[i],e.points,t);a.length&&n.push(...a)}return n}function dd(e,t,n,r){let i=0,a=t-1;if(n&&!r)for(;i<t&&!e[i].skip;)i++;for(;i<t&&e[i].skip;)i++;for(i%=t,n&&(a+=i);a>i&&e[a%t].skip;)a--;return a%=t,{start:i,end:a}}function fd(e,t,n,r){let i=e.length,a=[],o=t,s=e[t],c;for(c=t+1;c<=n;++c){let n=e[c%i];n.skip||n.stop?s.skip||(r=!1,a.push({start:t%i,end:(c-1)%i,loop:r}),t=o=n.stop?c:null):(o=c,s.skip&&(t=c)),s=n}return o!==null&&a.push({start:t%i,end:o%i,loop:r}),a}function pd(e,t){let n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];let a=!!e._loop,{start:o,end:s}=dd(n,i,a,r);return r===!0?md(e,[{start:o,end:s,loop:a}],n,t):md(e,fd(n,o,s<o?s+i:s,!!e._fullLoop&&o===0&&s===i-1),n,t)}function md(e,t,n,r){return!r||!r.setContext||!n?t:hd(e,t,n,r)}function hd(e,t,n,r){let i=e._chart.getContext(),a=gd(e.options),{_datasetIndex:o,options:{spanGaps:s}}=e,c=n.length,l=[],u=a,d=t[0].start,f=d;function p(e,t,r,i){let a=s?-1:1;if(e!==t){for(e+=c;n[e%c].skip;)e-=a;for(;n[t%c].skip;)t+=a;e%c!==t%c&&(l.push({start:e%c,end:t%c,loop:r,style:i}),u=i,d=t%c)}}for(let e of t){d=s?d:e.start;let t=n[d%c],a;for(f=d+1;f<=e.end;f++){let s=n[f%c];a=gd(r.setContext(au(i,{type:`segment`,p0:t,p1:s,p0DataIndex:(f-1)%c,p1DataIndex:f%c,datasetIndex:o}))),_d(a,u)&&p(d,f-1,e.loop,u),t=s,u=a}d<f-1&&p(d,f-1,e.loop,u)}return l}function gd(e){return{backgroundColor:e.backgroundColor,borderCapStyle:e.borderCapStyle,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderJoinStyle:e.borderJoinStyle,borderWidth:e.borderWidth,borderColor:e.borderColor}}function _d(e,t){if(!t)return!1;let n=[],r=function(e,t){return fl(t)?(n.includes(t)||n.push(t),n.indexOf(t)):t};return JSON.stringify(e,r)!==JSON.stringify(t,r)}function vd(e,t,n){return e.options.clip?e[n]:t[n]}function yd(e,t){let{xScale:n,yScale:r}=e;return n&&r?{left:vd(n,t,`left`),right:vd(n,t,`right`),top:vd(r,t,`top`),bottom:vd(r,t,`bottom`)}:t}function bd(e,t){let n=t._clip;if(n.disabled)return!1;let r=yd(t,e.chartArea);return{left:n.left===!1?0:r.left-(n.left===!0?0:n.left),right:n.right===!1?e.width:r.right+(n.right===!0?0:n.right),top:n.top===!1?0:r.top-(n.top===!0?0:n.top),bottom:n.bottom===!1?e.height:r.bottom+(n.bottom===!0?0:n.bottom)}}var xd=new class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(e,t,n,r){let i=t.listeners[r],a=t.duration;i.forEach(r=>r({chart:e,initial:t.initial,numSteps:a,currentStep:Math.min(n-t.start,a)}))}_refresh(){this._request||=(this._running=!0,el.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let t=0;this._charts.forEach((n,r)=>{if(!n.running||!n.items.length)return;let i=n.items,a=i.length-1,o=!1,s;for(;a>=0;--a)s=i[a],s._active?(s._total>n.duration&&(n.duration=s._total),s.tick(e),o=!0):(i[a]=i[i.length-1],i.pop());o&&(r.draw(),this._notify(r,n,e,`progress`)),i.length||(n.running=!1,this._notify(r,n,e,`complete`),n.initial=!1),t+=i.length}),this._lastDate=e,t===0&&(this._running=!1)}_getAnims(e){let t=this._charts,n=t.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},t.set(e,n)),n}listen(e,t,n){this._getAnims(e).listeners[t].push(n)}add(e,t){!t||!t.length||this._getAnims(e).items.push(...t)}has(e){return this._getAnims(e).items.length>0}start(e){let t=this._charts.get(e);t&&(t.running=!0,t.start=Date.now(),t.duration=t.items.reduce((e,t)=>Math.max(e,t._duration),0),this._refresh())}running(e){if(!this._running)return!1;let t=this._charts.get(e);return!(!t||!t.running||!t.items.length)}stop(e){let t=this._charts.get(e);if(!t||!t.items.length)return;let n=t.items,r=n.length-1;for(;r>=0;--r)n[r].cancel();t.items=[],this._notify(e,t,Date.now(),`complete`)}remove(e){return this._charts.delete(e)}},Sd=`transparent`,Cd={boolean(e,t,n){return n>.5?t:e},color(e,t,n){let r=pl(e||Sd),i=r.valid&&pl(t||Sd);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}},wd=class{constructor(e,t,n,r){let i=t[n];r=ru([e.to,r,i,e.from]);let a=ru([e.from,i,r]);this._active=!0,this._fn=e.fn||Cd[e.type||typeof a],this._easing=dl[e.easing]||dl.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=t,this._prop=n,this._from=a,this._to=r,this._promises=void 0}active(){return this._active}update(e,t,n){if(this._active){this._notify(!1);let r=this._target[this._prop],i=n-this._start,a=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(a,e.duration)),this._total+=i,this._loop=!!e.loop,this._to=ru([e.to,t,r,e.from]),this._from=ru([e.from,r,t])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){let t=e-this._start,n=this._duration,r=this._prop,i=this._from,a=this._loop,o=this._to,s;if(this._active=i!==o&&(a||t<n),!this._active){this._target[r]=o,this._notify(!0);return}if(t<0){this._target[r]=i;return}s=t/n%2,s=a&&s>1?2-s:s,s=this._easing(Math.min(1,Math.max(0,s))),this._target[r]=this._fn(i,o,s)}wait(){let e=this._promises||=[];return new Promise((t,n)=>{e.push({res:t,rej:n})})}_notify(e){let t=e?`res`:`rej`,n=this._promises||[];for(let e=0;e<n.length;e++)n[e][t]()}},Td=class{constructor(e,t){this._chart=e,this._properties=new Map,this.configure(t)}configure(e){if(!Y(e))return;let t=Object.keys(Al.animation),n=this._properties;Object.getOwnPropertyNames(e).forEach(r=>{let i=e[r];if(!Y(i))return;let a={};for(let e of t)a[e]=i[e];(Qs(i.properties)&&i.properties||[r]).forEach(e=>{(e===r||!n.has(e))&&n.set(e,a)})})}_animateOptions(e,t){let n=t.options,r=Dd(e,n);if(!r)return[];let i=this._createAnimations(r,n);return n.$shared&&Ed(e.options.$animations,n).then(()=>{e.options=n},()=>{}),i}_createAnimations(e,t){let n=this._properties,r=[],i=e.$animations||={},a=Object.keys(t),o=Date.now(),s;for(s=a.length-1;s>=0;--s){let c=a[s];if(c.charAt(0)===`$`)continue;if(c===`options`){r.push(...this._animateOptions(e,t));continue}let l=t[c],u=i[c],d=n.get(c);if(u){if(d&&u.active()){u.update(d,l,o);continue}u.cancel()}if(!d||!d.duration){e[c]=l;continue}i[c]=u=new wd(d,e,c,l),r.push(u)}return r}update(e,t){if(this._properties.size===0){Object.assign(e,t);return}let n=this._createAnimations(e,t);if(n.length)return xd.add(this._chart,n),!0}};function Ed(e,t){let n=[],r=Object.keys(t);for(let t=0;t<r.length;t++){let i=e[r[t]];i&&i.active()&&n.push(i.wait())}return Promise.all(n)}function Dd(e,t){if(!t)return;let n=e.options;if(!n){e.options=t;return}return n.$shared&&(e.options=n=Object.assign({},n,{$shared:!1,$animations:{}})),n}function Od(e,t){let n=e&&e.options||{},r=n.reverse,i=n.min===void 0?t:0,a=n.max===void 0?t:0;return{start:r?a:i,end:r?i:a}}function kd(e,t,n){if(n===!1)return!1;let r=Od(e,n),i=Od(t,n);return{top:i.end,right:r.end,bottom:i.start,left:r.start}}function Ad(e){let t,n,r,i;return Y(e)?(t=e.top,n=e.right,r=e.bottom,i=e.left):t=n=r=i=e,{top:t,right:n,bottom:r,left:i,disabled:e===!1}}function jd(e,t){let n=[],r=e._getSortedDatasetMetas(t),i,a;for(i=0,a=r.length;i<a;++i)n.push(r[i].index);return n}function Md(e,t,n,r={}){let i=e.keys,a=r.mode===`single`,o,s,c,l;if(t===null)return;let u=!1;for(o=0,s=i.length;o<s;++o){if(c=+i[o],c===n){if(u=!0,r.all)continue;break}l=e.values[c],$s(l)&&(a||t===0||Dc(t)===Dc(l))&&(t+=l)}return!u&&!r.all?0:t}function Nd(e,t){let{iScale:n,vScale:r}=t,i=n.axis===`x`?`x`:`y`,a=r.axis===`x`?`x`:`y`,o=Object.keys(e),s=Array(o.length),c,l,u;for(c=0,l=o.length;c<l;++c)u=o[c],s[c]={[i]:u,[a]:e[u]};return s}function Pd(e,t){let n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function Fd(e,t,n){return`${e.id}.${t.id}.${n.stack||n.type}`}function Id(e){let{min:t,max:n,minDefined:r,maxDefined:i}=e.getUserBounds();return{min:r?t:-1/0,max:i?n:1/0}}function Ld(e,t,n){let r=e[t]||(e[t]={});return r[n]||(r[n]={})}function Rd(e,t,n,r){for(let i of t.getMatchingVisibleMetas(r).reverse()){let t=e[i.index];if(n&&t>0||!n&&t<0)return i.index}return null}function zd(e,t){let{chart:n,_cachedMeta:r}=e,i=n._stacks||={},{iScale:a,vScale:o,index:s}=r,c=a.axis,l=o.axis,u=Fd(a,o,r),d=t.length,f;for(let e=0;e<d;++e){let n=t[e],{[c]:a,[l]:d}=n,p=n._stacks||={};f=p[l]=Ld(i,u,a),f[s]=d,f._top=Rd(f,o,!0,r.type),f._bottom=Rd(f,o,!1,r.type);let m=f._visualValues||(f._visualValues={});m[s]=d}}function Bd(e,t){let n=e.scales;return Object.keys(n).filter(e=>n[e].axis===t).shift()}function Vd(e,t){return au(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:`default`,type:`dataset`})}function Hd(e,t,n){return au(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:`default`,type:`data`})}function Ud(e,t){let n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t||=e._parsed;for(let e of t){let t=e._stacks;if(!t||t[r]===void 0||t[r][n]===void 0)return;delete t[r][n],t[r]._visualValues!==void 0&&t[r]._visualValues[n]!==void 0&&delete t[r]._visualValues[n]}}}var Wd=e=>e===`reset`||e===`none`,Gd=(e,t)=>t?e:Object.assign({},e),Kd=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:jd(n,!0),values:null},qd=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(e,t){this.chart=e,this._ctx=e.ctx,this.index=t,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.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=Pd(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled(`filler`)&&console.warn(`Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options`)}updateIndex(e){this.index!==e&&Ud(this._cachedMeta),this.index=e}linkScales(){let e=this.chart,t=this._cachedMeta,n=this.getDataset(),r=(e,t,n,r)=>e===`x`?t:e===`r`?r:n,i=t.xAxisID=X(n.xAxisID,Bd(e,`x`)),a=t.yAxisID=X(n.yAxisID,Bd(e,`y`)),o=t.rAxisID=X(n.rAxisID,Bd(e,`r`)),s=t.indexAxis,c=t.iAxisID=r(s,i,a,o),l=t.vAxisID=r(s,a,i,o);t.xScale=this.getScaleForId(i),t.yScale=this.getScaleForId(a),t.rScale=this.getScaleForId(o),t.iScale=this.getScaleForId(c),t.vScale=this.getScaleForId(l)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){let t=this._cachedMeta;return e===t.iScale?t.vScale:t.iScale}reset(){this._update(`reset`)}_destroy(){let e=this._cachedMeta;this._data&&Qc(this._data,this),e._stacked&&Ud(e)}_dataCheck(){let e=this.getDataset(),t=e.data||=[],n=this._data;if(Y(t)){let e=this._cachedMeta;this._data=Nd(t,e)}else if(n!==t){if(n){Qc(n,this);let e=this._cachedMeta;Ud(e),e._parsed=[]}t&&Object.isExtensible(t)&&Zc(t,this),this._syncList=[],this._data=t}}addElements(){let e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){let t=this._cachedMeta,n=this.getDataset(),r=!1;this._dataCheck();let i=t._stacked;t._stacked=Pd(t.vScale,t),t.stack!==n.stack&&(r=!0,Ud(t),t.stack=n.stack),this._resyncElements(e),(r||i!==t._stacked)&&(zd(this,t._parsed),t._stacked=Pd(t.vScale,t))}configure(){let e=this.chart.config,t=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),t,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,t){let{_cachedMeta:n,_data:r}=this,{iScale:i,_stacked:a}=n,o=i.axis,s=e===0&&t===r.length||n._sorted,c=e>0&&n._parsed[e-1],l,u,d;if(this._parsing===!1)n._parsed=r,n._sorted=!0,d=r;else{d=Qs(r[e])?this.parseArrayData(n,r,e,t):Y(r[e])?this.parseObjectData(n,r,e,t):this.parsePrimitiveData(n,r,e,t);let i=()=>u[o]===null||c&&u[o]<c[o];for(l=0;l<t;++l)n._parsed[l+e]=u=d[l],s&&(i()&&(s=!1),c=u);n._sorted=s}a&&zd(this,d)}parsePrimitiveData(e,t,n,r){let{iScale:i,vScale:a}=e,o=i.axis,s=a.axis,c=i.getLabels(),l=i===a,u=Array(r),d,f,p;for(d=0,f=r;d<f;++d)p=d+n,u[d]={[o]:l||i.parse(c[p],p),[s]:a.parse(t[p],p)};return u}parseArrayData(e,t,n,r){let{xScale:i,yScale:a}=e,o=Array(r),s,c,l,u;for(s=0,c=r;s<c;++s)l=s+n,u=t[l],o[s]={x:i.parse(u[0],l),y:a.parse(u[1],l)};return o}parseObjectData(e,t,n,r){let{xScale:i,yScale:a}=e,{xAxisKey:o=`x`,yAxisKey:s=`y`}=this._parsing,c=Array(r),l,u,d,f;for(l=0,u=r;l<u;++l)d=l+n,f=t[d],c[l]={x:i.parse(pc(f,o),d),y:a.parse(pc(f,s),d)};return c}getParsed(e){return this._cachedMeta._parsed[e]}getDataElement(e){return this._cachedMeta.data[e]}applyStack(e,t,n){let r=this.chart,i=this._cachedMeta,a=t[e.axis];return Md({keys:jd(r,!0),values:t._stacks[e.axis]._visualValues},a,i.index,{mode:n})}updateRangeFromParsed(e,t,n,r){let i=n[t.axis],a=i===null?NaN:i,o=r&&n._stacks[t.axis];r&&o&&(r.values=o,a=Md(r,i,this._cachedMeta.index)),e.min=Math.min(e.min,a),e.max=Math.max(e.max,a)}getMinMax(e,t){let n=this._cachedMeta,r=n._parsed,i=n._sorted&&e===n.iScale,a=r.length,o=this._getOtherScale(e),s=Kd(t,n,this.chart),c={min:1/0,max:-1/0},{min:l,max:u}=Id(o),d,f;function p(){f=r[d];let t=f[o.axis];return!$s(f[e.axis])||l>t||u<t}for(d=0;d<a&&!(!p()&&(this.updateRangeFromParsed(c,e,f,s),i));++d);if(i){for(d=a-1;d>=0;--d)if(!p()){this.updateRangeFromParsed(c,e,f,s);break}}return c}getAllParsedValues(e){let t=this._cachedMeta._parsed,n=[],r,i,a;for(r=0,i=t.length;r<i;++r)a=t[r][e.axis],$s(a)&&n.push(a);return n}getMaxOverflow(){return!1}getLabelAndValue(e){let t=this._cachedMeta,n=t.iScale,r=t.vScale,i=this.getParsed(e);return{label:n?``+n.getLabelForValue(i[n.axis]):``,value:r?``+r.getLabelForValue(i[r.axis]):``}}_update(e){let t=this._cachedMeta;this.update(e||`default`),t._clip=Ad(X(this.options.clip,kd(t.xScale,t.yScale,this.getMaxOverflow())))}update(e){}draw(){let e=this._ctx,t=this.chart,n=this._cachedMeta,r=n.data||[],i=t.chartArea,a=[],o=this._drawStart||0,s=this._drawCount||r.length-o,c=this.options.drawActiveElementsOnTop,l;for(n.dataset&&n.dataset.draw(e,i,o,s),l=o;l<o+s;++l){let t=r[l];t.hidden||(t.active&&c?a.push(t):t.draw(e,i))}for(l=0;l<a.length;++l)a[l].draw(e,i)}getStyle(e,t){let n=t?`active`:`default`;return e===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(n):this.resolveDataElementOptions(e||0,n)}getContext(e,t,n){let r=this.getDataset(),i;if(e>=0&&e<this._cachedMeta.data.length){let t=this._cachedMeta.data[e];i=t.$context||=Hd(this.getContext(),e,t),i.parsed=this.getParsed(e),i.raw=r.data[e],i.index=i.dataIndex=e}else i=this.$context||=Vd(this.chart.getContext(),this.index),i.dataset=r,i.index=i.datasetIndex=this.index;return i.active=!!t,i.mode=n,i}resolveDatasetElementOptions(e){return this._resolveElementOptions(this.datasetElementType.id,e)}resolveDataElementOptions(e,t){return this._resolveElementOptions(this.dataElementType.id,t,e)}_resolveElementOptions(e,t=`default`,n){let r=t===`active`,i=this._cachedDataOpts,a=e+`-`+t,o=i[a],s=this.enableOptionSharing&&hc(n);if(o)return Gd(o,s);let c=this.chart.config,l=c.datasetElementScopeKeys(this._type,e),u=r?[`${e}Hover`,`hover`,e,``]:[e,``],d=c.getOptionScopes(this.getDataset(),l),f=Object.keys(Al.elements[e]),p=c.resolveNamedOptions(d,f,()=>this.getContext(n,r,t),u);return p.$shared&&(p.$shared=s,i[a]=Object.freeze(Gd(p,s))),p}_resolveAnimations(e,t,n){let r=this.chart,i=this._cachedDataOpts,a=`animation-${t}`,o=i[a];if(o)return o;let s;if(r.options.animation!==!1){let r=this.chart.config,i=r.datasetAnimationScopeKeys(this._type,t),a=r.getOptionScopes(this.getDataset(),i);s=r.createResolver(a,this.getContext(e,n,t))}let c=new Td(r,s&&s.animations);return s&&s._cacheable&&(i[a]=Object.freeze(c)),c}getSharedOptions(e){if(e.$shared)return this._sharedOptions||=Object.assign({},e)}includeOptions(e,t){return!t||Wd(e)||this.chart._animationsDisabled}_getSharedOptions(e,t){let n=this.resolveDataElementOptions(e,t),r=this._sharedOptions,i=this.getSharedOptions(n),a=this.includeOptions(t,i)||i!==r;return this.updateSharedOptions(i,t,n),{sharedOptions:i,includeOptions:a}}updateElement(e,t,n,r){Wd(r)?Object.assign(e,n):this._resolveAnimations(t,r).update(e,n)}updateSharedOptions(e,t,n){e&&!Wd(t)&&this._resolveAnimations(void 0,t).update(e,n)}_setStyle(e,t,n,r){e.active=r;let i=this.getStyle(t,r);this._resolveAnimations(t,n,r).update(e,{options:!r&&this.getSharedOptions(i)||i})}removeHoverStyle(e,t,n){this._setStyle(e,n,`active`,!1)}setHoverStyle(e,t,n){this._setStyle(e,n,`active`,!0)}_removeDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!1)}_setDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!0)}_resyncElements(e){let t=this._data,n=this._cachedMeta.data;for(let[e,t,n]of this._syncList)this[e](t,n);this._syncList=[];let r=n.length,i=t.length,a=Math.min(i,r);a&&this.parse(0,a),i>r?this._insertElements(r,i-r,e):i<r&&this._removeElements(i,r-i)}_insertElements(e,t,n=!0){let r=this._cachedMeta,i=r.data,a=e+t,o,s=e=>{for(e.length+=t,o=e.length-1;o>=a;o--)e[o]=e[o-t]};for(s(i),o=e;o<a;++o)i[o]=new this.dataElementType;this._parsing&&s(r._parsed),this.parse(e,t),n&&this.updateElements(i,e,t,`reset`)}updateElements(e,t,n,r){}_removeElements(e,t){let n=this._cachedMeta;if(this._parsing){let r=n._parsed.splice(e,t);n._stacked&&Ud(n,r)}n.data.splice(e,t)}_sync(e){if(this._parsing)this._syncList.push(e);else{let[t,n,r]=e;this[t](n,r)}this.chart._dataChanges.push([this.index,...e])}_onDataPush(){let e=arguments.length;this._sync([`_insertElements`,this.getDataset().data.length-e,e])}_onDataPop(){this._sync([`_removeElements`,this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync([`_removeElements`,0,1])}_onDataSplice(e,t){t&&this._sync([`_removeElements`,e,t]);let n=arguments.length-2;n&&this._sync([`_insertElements`,e,n])}_onDataUnshift(){this._sync([`_insertElements`,0,arguments.length])}};function Jd(e,t){if(!e._cache.$bar){let n=e.getMatchingVisibleMetas(t),r=[];for(let t=0,i=n.length;t<i;t++)r=r.concat(n[t].controller.getAllParsedValues(e));e._cache.$bar=$c(r.sort((e,t)=>e-t))}return e._cache.$bar}function Yd(e){let t=e.iScale,n=Jd(t,e.type),r=t._length,i,a,o,s,c=()=>{o!==32767&&o!==-32768&&(hc(s)&&(r=Math.min(r,Math.abs(o-s)||r)),s=o)};for(i=0,a=n.length;i<a;++i)o=t.getPixelForValue(n[i]),c();for(s=void 0,i=0,a=t.ticks.length;i<a;++i)o=t.getPixelForTick(i),c();return r}function Xd(e,t,n,r){let i=n.barThickness,a,o;return J(i)?(a=t.min*n.categoryPercentage,o=n.barPercentage):(a=i*r,o=1),{chunk:a/r,ratio:o,start:t.pixels[e]-a/2}}function Zd(e,t,n,r){let i=t.pixels,a=i[e],o=e>0?i[e-1]:null,s=e<i.length-1?i[e+1]:null,c=n.categoryPercentage;o===null&&(o=a-(s===null?t.end-t.start:s-a)),s===null&&(s=a+a-o);let l=a-(a-Math.min(o,s))/2*c;return{chunk:Math.abs(s-o)/2*c/r,ratio:n.barPercentage,start:l}}function Qd(e,t,n,r){let i=n.parse(e[0],r),a=n.parse(e[1],r),o=Math.min(i,a),s=Math.max(i,a),c=o,l=s;Math.abs(o)>Math.abs(s)&&(c=s,l=o),t[n.axis]=l,t._custom={barStart:c,barEnd:l,start:i,end:a,min:o,max:s}}function $d(e,t,n,r){return Qs(e)?Qd(e,t,n,r):t[n.axis]=n.parse(e,r),t}function ef(e,t,n,r){let i=e.iScale,a=e.vScale,o=i.getLabels(),s=i===a,c=[],l,u,d,f;for(l=n,u=n+r;l<u;++l)f=t[l],d={},d[i.axis]=s||i.parse(o[l],l),c.push($d(f,d,a,l));return c}function tf(e){return e&&e.barStart!==void 0&&e.barEnd!==void 0}function nf(e,t,n){return e===0?(t.isHorizontal()?1:-1)*(t.min>=n?1:-1):Dc(e)}function rf(e){let t,n,r,i,a;return e.horizontal?(t=e.base>e.x,n=`left`,r=`right`):(t=e.base<e.y,n=`bottom`,r=`top`),t?(i=`end`,a=`start`):(i=`start`,a=`end`),{start:n,end:r,reverse:t,top:i,bottom:a}}function af(e,t,n,r){let i=t.borderSkipped,a={};if(!i){e.borderSkipped=a;return}if(i===!0){e.borderSkipped={top:!0,right:!0,bottom:!0,left:!0};return}let{start:o,end:s,reverse:c,top:l,bottom:u}=rf(e);i===`middle`&&n&&(e.enableBorderRadius=!0,(n._top||0)===r?i=l:(n._bottom||0)===r?i=u:(a[of(u,o,s,c)]=!0,i=l)),a[of(i,o,s,c)]=!0,e.borderSkipped=a}function of(e,t,n,r){return r?(e=sf(e,t,n),e=cf(e,n,t)):e=cf(e,t,n),e}function sf(e,t,n){return e===t?n:e===n?t:e}function cf(e,t,n){return e===`start`?t:e===`end`?n:e}function lf(e,{inflateAmount:t},n){e.inflateAmount=t===`auto`?n===1?.33:0:t}var uf=class extends qd{static id=`bar`;static defaults={datasetElementType:!1,dataElementType:`bar`,categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:`number`,properties:[`x`,`y`,`base`,`width`,`height`]}}};static overrides={scales:{_index_:{type:`category`,offset:!0,grid:{offset:!0}},_value_:{type:`linear`,beginAtZero:!0}}};parsePrimitiveData(e,t,n,r){return ef(e,t,n,r)}parseArrayData(e,t,n,r){return ef(e,t,n,r)}parseObjectData(e,t,n,r){let{iScale:i,vScale:a}=e,{xAxisKey:o=`x`,yAxisKey:s=`y`}=this._parsing,c=i.axis===`x`?o:s,l=a.axis===`x`?o:s,u=[],d,f,p,m;for(d=n,f=n+r;d<f;++d)m=t[d],p={},p[i.axis]=i.parse(pc(m,c),d),u.push($d(pc(m,l),p,a,d));return u}updateRangeFromParsed(e,t,n,r){super.updateRangeFromParsed(e,t,n,r);let i=n._custom;i&&t===this._cachedMeta.vScale&&(e.min=Math.min(e.min,i.min),e.max=Math.max(e.max,i.max))}getMaxOverflow(){return 0}getLabelAndValue(e){let{iScale:t,vScale:n}=this._cachedMeta,r=this.getParsed(e),i=r._custom,a=tf(i)?`[`+i.start+`, `+i.end+`]`:``+n.getLabelForValue(r[n.axis]);return{label:``+t.getLabelForValue(r[t.axis]),value:a}}initialize(){this.enableOptionSharing=!0,super.initialize();let e=this._cachedMeta;e.stack=this.getDataset().stack}update(e){let t=this._cachedMeta;this.updateElements(t.data,0,t.data.length,e)}updateElements(e,t,n,r){let i=r===`reset`,{index:a,_cachedMeta:{vScale:o}}=this,s=o.getBasePixel(),c=o.isHorizontal(),l=this._getRuler(),{sharedOptions:u,includeOptions:d}=this._getSharedOptions(t,r);for(let f=t;f<t+n;f++){let t=this.getParsed(f),n=i||J(t[o.axis])?{base:s,head:s}:this._calculateBarValuePixels(f),p=this._calculateBarIndexPixels(f,l),m=(t._stacks||{})[o.axis],h={horizontal:c,base:n.base,enableBorderRadius:!m||tf(t._custom)||a===m._top||a===m._bottom,x:c?n.head:p.center,y:c?p.center:n.head,height:c?p.size:Math.abs(n.size),width:c?Math.abs(n.size):p.size};d&&(h.options=u||this.resolveDataElementOptions(f,e[f].active?`active`:r));let g=h.options||e[f].options;af(h,g,m,a),lf(h,g,l.ratio),this.updateElement(e[f],f,h,r)}}_getStacks(e,t){let{iScale:n}=this._cachedMeta,r=n.getMatchingVisibleMetas(this._type).filter(e=>e.controller.options.grouped),i=n.options.stacked,a=[],o=this._cachedMeta.controller.getParsed(t),s=o&&o[n.axis],c=e=>{let t=e._parsed.find(e=>e[n.axis]===s),r=t&&t[e.vScale.axis];if(J(r)||isNaN(r))return!0};for(let n of r)if(!(t!==void 0&&c(n))&&((i===!1||a.indexOf(n.stack)===-1||i===void 0&&n.stack===void 0)&&a.push(n.stack),n.index===e))break;return a.length||a.push(void 0),a}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let e=this.chart.scales,t=this.chart.options.indexAxis;return Object.keys(e).filter(n=>e[n].axis===t).shift()}_getAxis(){let e={},t=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)e[X(this.chart.options.indexAxis===`x`?n.xAxisID:n.yAxisID,t)]=!0;return Object.keys(e)}_getStackIndex(e,t,n){let r=this._getStacks(e,n),i=t===void 0?-1:r.indexOf(t);return i===-1?r.length-1:i}_getRuler(){let e=this.options,t=this._cachedMeta,n=t.iScale,r=[],i,a;for(i=0,a=t.data.length;i<a;++i)r.push(n.getPixelForValue(this.getParsed(i)[n.axis],i));let o=e.barThickness;return{min:o||Yd(t),pixels:r,start:n._startPixel,end:n._endPixel,stackCount:this._getStackCount(),scale:n,grouped:e.grouped,ratio:o?1:e.categoryPercentage*e.barPercentage}}_calculateBarValuePixels(e){let{_cachedMeta:{vScale:t,_stacked:n,index:r},options:{base:i,minBarLength:a}}=this,o=i||0,s=this.getParsed(e),c=s._custom,l=tf(c),u=s[t.axis],d=0,f=n?this.applyStack(t,s,n):u,p,m;f!==u&&(d=f-u,f=u),l&&(u=c.barStart,f=c.barEnd-c.barStart,u!==0&&Dc(u)!==Dc(c.barEnd)&&(d=0),d+=u);let h=!J(i)&&!l?i:d,g=t.getPixelForValue(h);if(p=this.chart.getDataVisibility(e)?t.getPixelForValue(d+f):g,m=p-g,Math.abs(m)<a){m=nf(m,t,o)*a,u===o&&(g-=m/2);let e=t.getPixelForDecimal(0),i=t.getPixelForDecimal(1);g=Math.max(Math.min(g,Math.max(e,i)),Math.min(e,i)),p=g+m,n&&!l&&(s._stacks[t.axis]._visualValues[r]=t.getValueForPixel(p)-t.getValueForPixel(g))}if(g===t.getPixelForValue(o)){let e=Dc(m)*t.getLineWidthForValue(o)/2;g+=e,m-=e}return{size:m,base:g,head:p,center:p+m/2}}_calculateBarIndexPixels(e,t){let n=t.scale,r=this.options,i=r.skipNull,a=X(r.maxBarThickness,1/0),o,s,c=this._getAxisCount();if(t.grouped){let n=i?this._getStackCount(e):t.stackCount,l=r.barThickness===`flex`?Zd(e,t,r,n*c):Xd(e,t,r,n*c),u=this.chart.options.indexAxis===`x`?this.getDataset().xAxisID:this.getDataset().yAxisID,d=this._getAxis().indexOf(X(u,this.getFirstScaleIdForIndexAxis())),f=this._getStackIndex(this.index,this._cachedMeta.stack,i?e:void 0)+d;o=l.start+l.chunk*f+l.chunk/2,s=Math.min(a,l.chunk*l.ratio)}else o=n.getPixelForValue(this.getParsed(e)[n.axis],e),s=Math.min(a,t.min*t.ratio);return{base:o-s/2,head:o+s/2,center:o,size:s}}draw(){let e=this._cachedMeta,t=e.vScale,n=e.data,r=n.length,i=0;for(;i<r;++i)this.getParsed(i)[t.axis]!==null&&!n[i].hidden&&n[i].draw(this._ctx)}},df=class extends qd{static id=`bubble`;static defaults={datasetElementType:!1,dataElementType:`point`,animations:{numbers:{type:`number`,properties:[`x`,`y`,`borderWidth`,`radius`]}}};static overrides={scales:{x:{type:`linear`},y:{type:`linear`}}};initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(e,t,n,r){let i=super.parsePrimitiveData(e,t,n,r);for(let e=0;e<i.length;e++)i[e]._custom=this.resolveDataElementOptions(e+n).radius;return i}parseArrayData(e,t,n,r){let i=super.parseArrayData(e,t,n,r);for(let e=0;e<i.length;e++){let r=t[n+e];i[e]._custom=X(r[2],this.resolveDataElementOptions(e+n).radius)}return i}parseObjectData(e,t,n,r){let i=super.parseObjectData(e,t,n,r);for(let e=0;e<i.length;e++){let r=t[n+e];i[e]._custom=X(r&&r.r&&+r.r,this.resolveDataElementOptions(e+n).radius)}return i}getMaxOverflow(){let e=this._cachedMeta.data,t=0;for(let n=e.length-1;n>=0;--n)t=Math.max(t,e[n].size(this.resolveDataElementOptions(n))/2);return t>0&&t}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:r,yScale:i}=t,a=this.getParsed(e),o=r.getLabelForValue(a.x),s=i.getLabelForValue(a.y),c=a._custom;return{label:n[e]||``,value:`(`+o+`, `+s+(c?`, `+c:``)+`)`}}update(e){let t=this._cachedMeta.data;this.updateElements(t,0,t.length,e)}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o}=this._cachedMeta,{sharedOptions:s,includeOptions:c}=this._getSharedOptions(t,r),l=a.axis,u=o.axis;for(let d=t;d<t+n;d++){let t=e[d],n=!i&&this.getParsed(d),f={},p=f[l]=i?a.getPixelForDecimal(.5):a.getPixelForValue(n[l]),m=f[u]=i?o.getBasePixel():o.getPixelForValue(n[u]);f.skip=isNaN(p)||isNaN(m),c&&(f.options=s||this.resolveDataElementOptions(d,t.active?`active`:r),i&&(f.options.radius=0)),this.updateElement(t,d,f,r)}}resolveDataElementOptions(e,t){let n=this.getParsed(e),r=super.resolveDataElementOptions(e,t);r.$shared&&(r=Object.assign({},r,{$shared:!1}));let i=r.radius;return t!==`active`&&(r.radius=0),r.radius+=X(n&&n._custom,i),r}};function ff(e,t,n){let r=1,i=1,a=0,o=0;if(t<yc){let s=e,c=s+t,l=Math.cos(s),u=Math.sin(s),d=Math.cos(c),f=Math.sin(c),p=(e,t,r)=>Hc(e,s,c,!0)?1:Math.max(t,t*n,r,r*n),m=(e,t,r)=>Hc(e,s,c,!0)?-1:Math.min(t,t*n,r,r*n),h=p(0,l,d),g=p(Cc,u,f),_=m($,l,d),v=m($+Cc,u,f);r=(h-_)/2,i=(g-v)/2,a=-(h+_)/2,o=-(g+v)/2}return{ratioX:r,ratioY:i,offsetX:a,offsetY:o}}var pf=class extends qd{static id=`doughnut`;static 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`};static descriptors={_scriptable:e=>e!==`spacing`,_indexable:e=>e!==`spacing`&&!e.startsWith(`borderDash`)&&!e.startsWith(`hoverBorderDash`)};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data,{labels:{pointStyle:n,textAlign:r,color:i,useBorderRadius:a,borderRadius:o}}=e.legend.options;return t.labels.length&&t.datasets.length?t.labels.map((t,s)=>{let c=e.getDatasetMeta(0).controller.getStyle(s);return{text:t,fillStyle:c.backgroundColor,fontColor:i,hidden:!e.getDataVisibility(s),lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:c.borderWidth,strokeStyle:c.borderColor,textAlign:r,pointStyle:n,borderRadius:a&&(o||c.borderRadius),index:s}}):[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}}};constructor(e,t){super(e,t),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,t){let n=this.getDataset().data,r=this._cachedMeta;if(this._parsing===!1)r._parsed=n;else{let i=e=>+n[e];if(Y(n[e])){let{key:e=`value`}=this._parsing;i=t=>+pc(n[t],e)}let a,o;for(a=e,o=e+t;a<o;++a)r._parsed[a]=i(a)}}_getRotation(){return Fc(this.options.rotation-90)}_getCircumference(){return Fc(this.options.circumference)}_getRotationExtents(){let e=yc,t=-yc;for(let n=0;n<this.chart.data.datasets.length;++n)if(this.chart.isDatasetVisible(n)&&this.chart.getDatasetMeta(n).type===this._type){let r=this.chart.getDatasetMeta(n).controller,i=r._getRotation(),a=r._getCircumference();e=Math.min(e,i),t=Math.max(t,i+a)}return{rotation:e,circumference:t-e}}update(e){let{chartArea:t}=this.chart,n=this._cachedMeta,r=n.data,i=this.getMaxBorderWidth()+this.getMaxOffset(r)+this.options.spacing,a=Math.max((Math.min(t.width,t.height)-i)/2,0),o=Math.min(tc(this.options.cutout,a),1),s=this._getRingWeight(this.index),{circumference:c,rotation:l}=this._getRotationExtents(),{ratioX:u,ratioY:d,offsetX:f,offsetY:p}=ff(l,c,o),m=(t.width-i)/u,h=(t.height-i)/d,g=Math.max(Math.min(m,h)/2,0),_=nc(this.options.radius,g),v=(_-Math.max(_*o,0))/this._getVisibleDatasetWeightTotal();this.offsetX=f*_,this.offsetY=p*_,n.total=this.calculateTotal(),this.outerRadius=_-v*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-v*s,0),this.updateElements(r,0,r.length,e)}_circumference(e,t){let n=this.options,r=this._cachedMeta,i=this._getCircumference();return t&&n.animation.animateRotate||!this.chart.getDataVisibility(e)||r._parsed[e]===null||r.data[e].hidden?0:this.calculateCircumference(r._parsed[e]*i/yc)}updateElements(e,t,n,r){let i=r===`reset`,a=this.chart,o=a.chartArea,s=a.options.animation,c=(o.left+o.right)/2,l=(o.top+o.bottom)/2,u=i&&s.animateScale,d=u?0:this.innerRadius,f=u?0:this.outerRadius,{sharedOptions:p,includeOptions:m}=this._getSharedOptions(t,r),h=this._getRotation(),g;for(g=0;g<t;++g)h+=this._circumference(g,i);for(g=t;g<t+n;++g){let t=this._circumference(g,i),n=e[g],a={x:c+this.offsetX,y:l+this.offsetY,startAngle:h,endAngle:h+t,circumference:t,outerRadius:f,innerRadius:d};m&&(a.options=p||this.resolveDataElementOptions(g,n.active?`active`:r)),h+=t,this.updateElement(n,g,a,r)}}calculateTotal(){let e=this._cachedMeta,t=e.data,n=0,r;for(r=0;r<t.length;r++){let i=e._parsed[r];i!==null&&!isNaN(i)&&this.chart.getDataVisibility(r)&&!t[r].hidden&&(n+=Math.abs(i))}return n}calculateCircumference(e){let t=this._cachedMeta.total;return t>0&&!isNaN(e)?Math.abs(e)/t*yc:0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=xl(t._parsed[e],n.options.locale);return{label:r[e]||``,value:i}}getMaxBorderWidth(e){let t=0,n=this.chart,r,i,a,o,s;if(!e){for(r=0,i=n.data.datasets.length;r<i;++r)if(n.isDatasetVisible(r)){a=n.getDatasetMeta(r),e=a.data,o=a.controller;break}}if(!e)return 0;for(r=0,i=e.length;r<i;++r)s=o.resolveDataElementOptions(r),s.borderAlign!==`inner`&&(t=Math.max(t,s.borderWidth||0,s.hoverBorderWidth||0));return t}getMaxOffset(e){let t=0;for(let n=0,r=e.length;n<r;++n){let e=this.resolveDataElementOptions(n);t=Math.max(t,e.offset||0,e.hoverOffset||0)}return t}_getRingWeightOffset(e){let t=0;for(let n=0;n<e;++n)this.chart.isDatasetVisible(n)&&(t+=this._getRingWeight(n));return t}_getRingWeight(e){return Math.max(X(this.chart.data.datasets[e].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}},mf=class extends qd{static id=`line`;static defaults={datasetElementType:`line`,dataElementType:`point`,showLine:!0,spanGaps:!1};static overrides={scales:{_index_:{type:`category`},_value_:{type:`linear`}}};initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(e){let t=this._cachedMeta,{dataset:n,data:r=[],_dataset:i}=t,a=this.chart._animationsDisabled,{start:o,count:s}=ol(t,r,a);this._drawStart=o,this._drawCount=s,sl(t)&&(o=0,s=r.length),n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!i._decimated,n.points=r;let c=this.resolveDatasetElementOptions(e);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(n,void 0,{animated:!a,options:c},e),this.updateElements(r,o,s,e)}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o,_stacked:s,_dataset:c}=this._cachedMeta,{sharedOptions:l,includeOptions:u}=this._getSharedOptions(t,r),d=a.axis,f=o.axis,{spanGaps:p,segment:m}=this.options,h=Mc(p)?p:1/0,g=this.chart._animationsDisabled||i||r===`none`,_=t+n,v=e.length,y=t>0&&this.getParsed(t-1);for(let n=0;n<v;++n){let p=e[n],v=g?p:{};if(n<t||n>=_){v.skip=!0;continue}let b=this.getParsed(n),x=J(b[f]),S=v[d]=a.getPixelForValue(b[d],n),C=v[f]=i||x?o.getBasePixel():o.getPixelForValue(s?this.applyStack(o,b,s):b[f],n);v.skip=isNaN(S)||isNaN(C)||x,v.stop=n>0&&Math.abs(b[d]-y[d])>h,m&&(v.parsed=b,v.raw=c.data[n]),u&&(v.options=l||this.resolveDataElementOptions(n,p.active?`active`:r)),g||this.updateElement(p,n,v,r),y=b}}getMaxOverflow(){let e=this._cachedMeta,t=e.dataset,n=t.options&&t.options.borderWidth||0,r=e.data||[];if(!r.length)return n;let i=r[0].size(this.resolveDataElementOptions(0)),a=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(n,i,a)/2}draw(){let e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}},hf=class extends qd{static id=`polarArea`;static defaults={dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:`number`,properties:[`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`]}},indexAxis:`r`,startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data;if(t.labels.length&&t.datasets.length){let{labels:{pointStyle:n,color:r}}=e.legend.options;return t.labels.map((t,i)=>{let a=e.getDatasetMeta(0).controller.getStyle(i);return{text:t,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,fontColor:r,lineWidth:a.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(i),index:i}})}return[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}},scales:{r:{type:`radialLinear`,angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(e,t){super(e,t),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=xl(t._parsed[e].r,n.options.locale);return{label:r[e]||``,value:i}}parseObjectData(e,t,n,r){return Tu.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta.data;this._updateRadius(),this.updateElements(t,0,t.length,e)}getMinMax(){let e=this._cachedMeta,t={min:1/0,max:-1/0};return e.data.forEach((e,n)=>{let r=this.getParsed(n).r;!isNaN(r)&&this.chart.getDataVisibility(n)&&(r<t.min&&(t.min=r),r>t.max&&(t.max=r))}),t}_updateRadius(){let e=this.chart,t=e.chartArea,n=e.options,r=Math.min(t.right-t.left,t.bottom-t.top),i=Math.max(r/2,0),a=(i-Math.max(n.cutoutPercentage?i/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();this.outerRadius=i-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(e,t,n,r){let i=r===`reset`,a=this.chart,o=a.options.animation,s=this._cachedMeta.rScale,c=s.xCenter,l=s.yCenter,u=s.getIndexAngle(0)-.5*$,d=u,f,p=360/this.countVisibleElements();for(f=0;f<t;++f)d+=this._computeAngle(f,r,p);for(f=t;f<t+n;f++){let t=e[f],n=d,m=d+this._computeAngle(f,r,p),h=a.getDataVisibility(f)?s.getDistanceFromCenterForValue(this.getParsed(f).r):0;d=m,i&&(o.animateScale&&(h=0),o.animateRotate&&(n=m=u));let g={x:c,y:l,innerRadius:0,outerRadius:h,startAngle:n,endAngle:m,options:this.resolveDataElementOptions(f,t.active?`active`:r)};this.updateElement(t,f,g,r)}}countVisibleElements(){let e=this._cachedMeta,t=0;return e.data.forEach((e,n)=>{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&t++}),t}_computeAngle(e,t,n){return this.chart.getDataVisibility(e)?Fc(this.resolveDataElementOptions(e,t).angle||n):0}},gf=Object.freeze({__proto__:null,BarController:uf,BubbleController:df,DoughnutController:pf,LineController:mf,PieController:class extends pf{static id=`pie`;static defaults={cutout:0,rotation:0,circumference:360,radius:`100%`}},PolarAreaController:hf,RadarController:class extends qd{static id=`radar`;static defaults={datasetElementType:`line`,dataElementType:`point`,indexAxis:`r`,showLine:!0,elements:{line:{fill:`start`}}};static overrides={aspectRatio:1,scales:{r:{type:`radialLinear`}}};getLabelAndValue(e){let t=this._cachedMeta.vScale,n=this.getParsed(e);return{label:t.getLabels()[e],value:``+t.getLabelForValue(n[t.axis])}}parseObjectData(e,t,n,r){return Tu.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta,n=t.dataset,r=t.data||[],i=t.iScale.getLabels();if(n.points=r,e!==`resize`){let t=this.resolveDatasetElementOptions(e);this.options.showLine||(t.borderWidth=0);let a={_loop:!0,_fullLoop:i.length===r.length,options:t};this.updateElement(n,void 0,a,e)}this.updateElements(r,0,r.length,e)}updateElements(e,t,n,r){let i=this._cachedMeta.rScale,a=r===`reset`;for(let o=t;o<t+n;o++){let t=e[o],n=this.resolveDataElementOptions(o,t.active?`active`:r),s=i.getPointPositionForValue(o,this.getParsed(o).r),c=a?i.xCenter:s.x,l=a?i.yCenter:s.y,u={x:c,y:l,angle:s.angle,skip:isNaN(c)||isNaN(l),options:n};this.updateElement(t,o,u,r)}}},ScatterController:class extends qd{static id=`scatter`;static defaults={datasetElementType:!1,dataElementType:`point`,showLine:!1,fill:!1};static overrides={interaction:{mode:`point`},scales:{x:{type:`linear`},y:{type:`linear`}}};getLabelAndValue(e){let t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:r,yScale:i}=t,a=this.getParsed(e),o=r.getLabelForValue(a.x),s=i.getLabelForValue(a.y);return{label:n[e]||``,value:`(`+o+`, `+s+`)`}}update(e){let t=this._cachedMeta,{data:n=[]}=t,r=this.chart._animationsDisabled,{start:i,count:a}=ol(t,n,r);if(this._drawStart=i,this._drawCount=a,sl(t)&&(i=0,a=n.length),this.options.showLine){this.datasetElementType||this.addElements();let{dataset:i,_dataset:a}=t;i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!a._decimated,i.points=n;let o=this.resolveDatasetElementOptions(e);o.segment=this.options.segment,this.updateElement(i,void 0,{animated:!r,options:o},e)}else this.datasetElementType&&=(delete t.dataset,!1);this.updateElements(n,i,a,e)}addElements(){let{showLine:e}=this.options;!this.datasetElementType&&e&&(this.datasetElementType=this.chart.registry.getElement(`line`)),super.addElements()}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o,_stacked:s,_dataset:c}=this._cachedMeta,l=this.resolveDataElementOptions(t,r),u=this.getSharedOptions(l),d=this.includeOptions(r,u),f=a.axis,p=o.axis,{spanGaps:m,segment:h}=this.options,g=Mc(m)?m:1/0,_=this.chart._animationsDisabled||i||r===`none`,v=t>0&&this.getParsed(t-1);for(let l=t;l<t+n;++l){let t=e[l],n=this.getParsed(l),m=_?t:{},y=J(n[p]),b=m[f]=a.getPixelForValue(n[f],l),x=m[p]=i||y?o.getBasePixel():o.getPixelForValue(s?this.applyStack(o,n,s):n[p],l);m.skip=isNaN(b)||isNaN(x)||y,m.stop=l>0&&Math.abs(n[f]-v[f])>g,h&&(m.parsed=n,m.raw=c.data[l]),d&&(m.options=u||this.resolveDataElementOptions(l,t.active?`active`:r)),_||this.updateElement(t,l,m,r),v=n}this.updateSharedOptions(u,r,l)}getMaxOverflow(){let e=this._cachedMeta,t=e.data||[];if(!this.options.showLine){let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}let n=e.dataset,r=n.options&&n.options.borderWidth||0;if(!t.length)return r;let i=t[0].size(this.resolveDataElementOptions(0)),a=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(r,i,a)/2}}});function _f(){throw Error(`This method is not implemented: Check that a complete date adapter is provided.`)}var vf={_date:class e{static override(t){Object.assign(e.prototype,t)}options;constructor(e){this.options=e||{}}init(){}formats(){return _f()}parse(){return _f()}format(){return _f()}add(){return _f()}diff(){return _f()}startOf(){return _f()}endOf(){return _f()}}};function yf(e,t,n,r){let{controller:i,data:a,_sorted:o}=e,s=i._cachedMeta.iScale,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(s&&t===s.axis&&t!==`r`&&o&&a.length){let o=s._reversePixels?Jc:qc;if(!r){let r=o(a,t,n);if(c){let{vScale:t}=i._cachedMeta,{_parsed:n}=e,a=n.slice(0,r.lo+1).reverse().findIndex(e=>!J(e[t.axis]));r.lo-=Math.max(0,a);let o=n.slice(r.hi).findIndex(e=>!J(e[t.axis]));r.hi+=Math.max(0,o)}return r}if(i._sharedOptions){let e=a[0],r=typeof e.getRange==`function`&&e.getRange(t);if(r){let e=o(a,t,n-r),i=o(a,t,n+r);return{lo:e.lo,hi:i.hi}}}}return{lo:0,hi:a.length-1}}function bf(e,t,n,r,i){let a=e.getSortedVisibleDatasetMetas(),o=n[t];for(let e=0,n=a.length;e<n;++e){let{index:n,data:s}=a[e],{lo:c,hi:l}=yf(a[e],t,o,i);for(let e=c;e<=l;++e){let t=s[e];t.skip||r(t,n,e)}}}function xf(e){let t=e.indexOf(`x`)!==-1,n=e.indexOf(`y`)!==-1;return function(e,r){let i=t?Math.abs(e.x-r.x):0,a=n?Math.abs(e.y-r.y):0;return Math.sqrt(i**2+a**2)}}function Sf(e,t,n,r,i){let a=[];return!i&&!e.isPointInArea(t)||bf(e,n,t,function(n,o,s){!i&&!Rl(n,e.chartArea,0)||n.inRange(t.x,t.y,r)&&a.push({element:n,datasetIndex:o,index:s})},!0),a}function Cf(e,t,n,r){let i=[];function a(e,n,a){let{startAngle:o,endAngle:s}=e.getProps([`startAngle`,`endAngle`],r),{angle:c}=Rc(e,{x:t.x,y:t.y});Hc(c,o,s)&&i.push({element:e,datasetIndex:n,index:a})}return bf(e,n,t,a),i}function wf(e,t,n,r,i,a){let o=[],s=xf(n),c=1/0;function l(n,l,u){let d=n.inRange(t.x,t.y,i);if(r&&!d)return;let f=n.getCenterPoint(i);if(!(a||e.isPointInArea(f))&&!d)return;let p=s(t,f);p<c?(o=[{element:n,datasetIndex:l,index:u}],c=p):p===c&&o.push({element:n,datasetIndex:l,index:u})}return bf(e,n,t,l),o}function Tf(e,t,n,r,i,a){return!a&&!e.isPointInArea(t)?[]:n===`r`&&!r?Cf(e,t,n,i):wf(e,t,n,r,i,a)}function Ef(e,t,n,r,i){let a=[],o=n===`x`?`inXRange`:`inYRange`,s=!1;return bf(e,n,t,(e,r,c)=>{e[o]&&e[o](t[n],i)&&(a.push({element:e,datasetIndex:r,index:c}),s||=e.inRange(t.x,t.y,i))}),r&&!s?[]:a}var Df={evaluateInteractionItems:bf,modes:{index(e,t,n,r){let i=Gu(t,e),a=n.axis||`x`,o=n.includeInvisible||!1,s=n.intersect?Sf(e,i,a,r,o):Tf(e,i,a,!1,r,o),c=[];return s.length?(e.getSortedVisibleDatasetMetas().forEach(e=>{let t=s[0].index,n=e.data[t];n&&!n.skip&&c.push({element:n,datasetIndex:e.index,index:t})}),c):[]},dataset(e,t,n,r){let i=Gu(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1,s=n.intersect?Sf(e,i,a,r,o):Tf(e,i,a,!1,r,o);if(s.length>0){let t=s[0].datasetIndex,n=e.getDatasetMeta(t).data;s=[];for(let e=0;e<n.length;++e)s.push({element:n[e],datasetIndex:t,index:e})}return s},point(e,t,n,r){return Sf(e,Gu(t,e),n.axis||`xy`,r,n.includeInvisible||!1)},nearest(e,t,n,r){let i=Gu(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1;return Tf(e,i,a,n.intersect,r,o)},x(e,t,n,r){return Ef(e,Gu(t,e),`x`,n.intersect,r)},y(e,t,n,r){return Ef(e,Gu(t,e),`y`,n.intersect,r)}}},Of=[`left`,`top`,`right`,`bottom`];function kf(e,t){return e.filter(e=>e.pos===t)}function Af(e,t){return e.filter(e=>Of.indexOf(e.pos)===-1&&e.box.axis===t)}function jf(e,t){return e.sort((e,n)=>{let r=t?n:e,i=t?e:n;return r.weight===i.weight?r.index-i.index:r.weight-i.weight})}function Mf(e){let t=[],n,r,i,a,o,s;for(n=0,r=(e||[]).length;n<r;++n)i=e[n],{position:a,options:{stack:o,stackWeight:s=1}}=i,t.push({index:n,box:i,pos:a,horizontal:i.isHorizontal(),weight:i.weight,stack:o&&a+o,stackWeight:s});return t}function Nf(e){let t={};for(let n of e){let{stack:e,pos:r,stackWeight:i}=n;if(!e||!Of.includes(r))continue;let a=t[e]||(t[e]={count:0,placed:0,weight:0,size:0});a.count++,a.weight+=i}return t}function Pf(e,t){let n=Nf(e),{vBoxMaxWidth:r,hBoxMaxHeight:i}=t,a,o,s;for(a=0,o=e.length;a<o;++a){s=e[a];let{fullSize:o}=s.box,c=n[s.stack],l=c&&s.stackWeight/c.weight;s.horizontal?(s.width=l?l*r:o&&t.availableWidth,s.height=i):(s.width=r,s.height=l?l*i:o&&t.availableHeight)}return n}function Ff(e){let t=Mf(e),n=jf(t.filter(e=>e.box.fullSize),!0),r=jf(kf(t,`left`),!0),i=jf(kf(t,`right`)),a=jf(kf(t,`top`),!0),o=jf(kf(t,`bottom`)),s=Af(t,`x`),c=Af(t,`y`);return{fullSize:n,leftAndTop:r.concat(a),rightAndBottom:i.concat(c).concat(o).concat(s),chartArea:kf(t,`chartArea`),vertical:r.concat(i).concat(c),horizontal:a.concat(o).concat(s)}}function If(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function Lf(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function Rf(e,t,n,r){let{pos:i,box:a}=n,o=e.maxPadding;if(!Y(i)){n.size&&(e[i]-=n.size);let t=r[n.stack]||{size:0,count:1};t.size=Math.max(t.size,n.horizontal?a.height:a.width),n.size=t.size/t.count,e[i]+=n.size}a.getPadding&&Lf(o,a.getPadding());let s=Math.max(0,t.outerWidth-If(o,e,`left`,`right`)),c=Math.max(0,t.outerHeight-If(o,e,`top`,`bottom`)),l=s!==e.w,u=c!==e.h;return e.w=s,e.h=c,n.horizontal?{same:l,other:u}:{same:u,other:l}}function zf(e){let t=e.maxPadding;function n(n){let r=Math.max(t[n]-e[n],0);return e[n]+=r,r}e.y+=n(`top`),e.x+=n(`left`),n(`right`),n(`bottom`)}function Bf(e,t){let n=t.maxPadding;function r(e){let r={left:0,top:0,right:0,bottom:0};return e.forEach(e=>{r[e]=Math.max(t[e],n[e])}),r}return r(e?[`left`,`right`]:[`top`,`bottom`])}function Vf(e,t,n,r){let i=[],a,o,s,c,l,u;for(a=0,o=e.length,l=0;a<o;++a){s=e[a],c=s.box,c.update(s.width||t.w,s.height||t.h,Bf(s.horizontal,t));let{same:o,other:d}=Rf(t,n,s,r);l|=o&&i.length,u||=d,c.fullSize||i.push(s)}return l&&Vf(i,t,n,r)||u}function Hf(e,t,n,r,i){e.top=n,e.left=t,e.right=t+r,e.bottom=n+i,e.width=r,e.height=i}function Uf(e,t,n,r){let i=n.padding,{x:a,y:o}=t;for(let s of e){let e=s.box,c=r[s.stack]||{count:1,placed:0,weight:1},l=s.stackWeight/c.weight||1;if(s.horizontal){let r=t.w*l,a=c.size||e.height;hc(c.start)&&(o=c.start),e.fullSize?Hf(e,i.left,o,n.outerWidth-i.right-i.left,a):Hf(e,t.left+c.placed,o,r,a),c.start=o,c.placed+=r,o=e.bottom}else{let r=t.h*l,o=c.size||e.width;hc(c.start)&&(a=c.start),e.fullSize?Hf(e,a,i.top,o,n.outerHeight-i.bottom-i.top):Hf(e,a,t.top+c.placed,o,r),c.start=a,c.placed+=r,a=e.right}}t.x=a,t.y=o}var Wf={addBox(e,t){e.boxes||=[],t.fullSize=t.fullSize||!1,t.position=t.position||`top`,t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(e){t.draw(e)}}]},e.boxes.push(t)},removeBox(e,t){let n=e.boxes?e.boxes.indexOf(t):-1;n!==-1&&e.boxes.splice(n,1)},configure(e,t,n){t.fullSize=n.fullSize,t.position=n.position,t.weight=n.weight},update(e,t,n,r){if(!e)return;let i=tu(e.options.layout.padding),a=Math.max(t-i.width,0),o=Math.max(n-i.height,0),s=Ff(e.boxes),c=s.vertical,l=s.horizontal;Q(e.boxes,e=>{typeof e.beforeLayout==`function`&&e.beforeLayout()});let u=c.reduce((e,t)=>t.box.options&&t.box.options.display===!1?e:e+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:a,availableHeight:o,vBoxMaxWidth:a/2/u,hBoxMaxHeight:o/2}),f=Object.assign({},i);Lf(f,tu(r));let p=Object.assign({maxPadding:f,w:a,h:o,x:i.left,y:i.top},i),m=Pf(c.concat(l),d);Vf(s.fullSize,p,d,m),Vf(c,p,d,m),Vf(l,p,d,m)&&Vf(c,p,d,m),zf(p),Uf(s.leftAndTop,p,d,m),p.x+=p.w,p.y+=p.h,Uf(s.rightAndBottom,p,d,m),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},Q(s.chartArea,t=>{let n=t.box;Object.assign(n,e.chartArea),n.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}},Gf=class{acquireContext(e,t){}releaseContext(e){return!1}addEventListener(e,t,n){}removeEventListener(e,t,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,t,n,r){return t=Math.max(0,t||e.width),n||=e.height,{width:t,height:Math.max(0,r?Math.floor(t/r):n)}}isAttached(e){return!0}updateConfig(e){}},Kf=class extends Gf{acquireContext(e){return e&&e.getContext&&e.getContext(`2d`)||null}updateConfig(e){e.options.animation=!1}},qf=`$chartjs`,Jf={touchstart:`mousedown`,touchmove:`mousemove`,touchend:`mouseup`,pointerenter:`mouseenter`,pointerdown:`mousedown`,pointermove:`mousemove`,pointerup:`mouseup`,pointerleave:`mouseout`,pointerout:`mouseout`},Yf=e=>e===null||e===``;function Xf(e,t){let n=e.style,r=e.getAttribute(`height`),i=e.getAttribute(`width`);if(e[qf]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||`block`,n.boxSizing=n.boxSizing||`border-box`,Yf(i)){let t=Zu(e,`width`);t!==void 0&&(e.width=t)}if(Yf(r)){if(e.style.height===``)e.height=e.width/(t||2);else{let t=Zu(e,`height`);t!==void 0&&(e.height=t)}}return e}var Zf=Xu?{passive:!0}:!1;function Qf(e,t,n){e&&e.addEventListener(t,n,Zf)}function $f(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,Zf)}function ep(e,t){let n=Jf[e.type]||e.type,{x:r,y:i}=Gu(e,t);return{type:n,chart:t,native:e,x:r===void 0?null:r,y:i===void 0?null:i}}function tp(e,t){for(let n of e)if(n===t||n.contains(t))return!0}function np(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=tp(n.addedNodes,r),t&&=!tp(n.removedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function rp(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=tp(n.removedNodes,r),t&&=!tp(n.addedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}var ip=new Map,ap=0;function op(){let e=window.devicePixelRatio;e!==ap&&(ap=e,ip.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function sp(e,t){ip.size||window.addEventListener(`resize`,op),ip.set(e,t)}function cp(e){ip.delete(e),ip.size||window.removeEventListener(`resize`,op)}function lp(e,t,n){let r=e.canvas,i=r&&Lu(r);if(!i)return;let a=tl((e,t)=>{let r=i.clientWidth;n(e,t),r<i.clientWidth&&n()},window),o=new ResizeObserver(e=>{let t=e[0],n=t.contentRect.width,r=t.contentRect.height;(n!==0||r!==0)&&a(n,r)});return o.observe(i),sp(e,a),o}function up(e,t,n){n&&n.disconnect(),t===`resize`&&cp(e)}function dp(e,t,n){let r=e.canvas,i=tl(t=>{e.ctx!==null&&n(ep(t,e))},e);return Qf(r,t,i),i}var fp=class extends Gf{acquireContext(e,t){let n=e&&e.getContext&&e.getContext(`2d`);return n&&n.canvas===e?(Xf(e,t),n):null}releaseContext(e){let t=e.canvas;if(!t[qf])return!1;let n=t[qf].initial;[`height`,`width`].forEach(e=>{let r=n[e];J(r)?t.removeAttribute(e):t.setAttribute(e,r)});let r=n.style||{};return Object.keys(r).forEach(e=>{t.style[e]=r[e]}),t.width=t.width,delete t[qf],!0}addEventListener(e,t,n){this.removeEventListener(e,t);let r=e.$proxies||={};r[t]=({attach:np,detach:rp,resize:lp}[t]||dp)(e,t,n)}removeEventListener(e,t){let n=e.$proxies||={},r=n[t];r&&(({attach:up,detach:up,resize:up}[t]||$f)(e,t,r),n[t]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,r){return Ju(e,t,n,r)}isAttached(e){let t=e&&Lu(e);return!!(t&&t.isConnected)}};function pp(e){return!Iu()||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?Kf:fp}var mp=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}hasValue(){return Mc(this.x)&&Mc(this.y)}getProps(e,t){let n=this.$animations;if(!t||!n)return this;let r={};return e.forEach(e=>{r[e]=n[e]&&n[e].active()?n[e]._to:this[e]}),r}};function hp(e,t){let n=e.options.ticks,r=gp(e),i=Math.min(n.maxTicksLimit||r,r),a=n.major.enabled?vp(t):[],o=a.length,s=a[0],c=a[o-1],l=[];if(o>i)return yp(t,l,a,o/i),l;let u=_p(a,t,i);if(o>0){let e,n,r=o>1?Math.round((c-s)/(o-1)):null;for(bp(t,l,u,J(r)?0:s-r,s),e=0,n=o-1;e<n;e++)bp(t,l,u,a[e],a[e+1]);return bp(t,l,u,c,J(r)?t.length:c+r),l}return bp(t,l,u),l}function gp(e){let t=e.options.offset,n=e._tickSize(),r=e._length/n+ +!t,i=e._maxLength/n;return Math.floor(Math.min(r,i))}function _p(e,t,n){let r=xp(e),i=t.length/n;if(!r)return Math.max(i,1);let a=Ac(r);for(let e=0,t=a.length-1;e<t;e++){let t=a[e];if(t>i)return t}return Math.max(i,1)}function vp(e){let t=[],n,r;for(n=0,r=e.length;n<r;n++)e[n].major&&t.push(n);return t}function yp(e,t,n,r){let i=0,a=n[0],o;for(r=Math.ceil(r),o=0;o<e.length;o++)o===a&&(t.push(e[o]),i++,a=n[i*r])}function bp(e,t,n,r,i){let a=X(r,0),o=Math.min(X(i,e.length),e.length),s=0,c,l,u;for(n=Math.ceil(n),i&&(c=i-r,n=c/Math.floor(c/n)),u=a;u<0;)s++,u=Math.round(a+s*n);for(l=Math.max(a,0);l<o;l++)l===u&&(t.push(e[l]),s++,u=Math.round(a+s*n))}function xp(e){let t=e.length,n,r;if(t<2)return!1;for(r=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==r)return!1;return r}var Sp=e=>e===`left`?`right`:e===`right`?`left`:e,Cp=(e,t,n)=>t===`top`||t===`left`?e[t]+n:e[t]-n,wp=(e,t)=>Math.min(t||e,e);function Tp(e,t){let n=[],r=e.length/t,i=e.length,a=0;for(;a<i;a+=r)n.push(e[Math.floor(a)]);return n}function Ep(e,t,n){let r=e.ticks.length,i=Math.min(t,r-1),a=e._startPixel,o=e._endPixel,s=1e-6,c=e.getPixelForTick(i),l;if(!(n&&(l=r===1?Math.max(c-a,o-c):t===0?(e.getPixelForTick(1)-c)/2:(c-e.getPixelForTick(i-1))/2,c+=i<t?l:-l,c<a-s||c>o+s)))return c}function Dp(e,t){Q(e,e=>{let n=e.gc,r=n.length/2,i;if(r>t){for(i=0;i<r;++i)delete e.data[n[i]];n.splice(0,r)}})}function Op(e){return e.drawTicks?e.tickLength:0}function kp(e,t){if(!e.display)return 0;let n=nu(e.font,t),r=tu(e.padding);return(Qs(e.text)?e.text.length:1)*n.lineHeight+r.height}function Ap(e,t){return au(e,{scale:t,type:`scale`})}function jp(e,t,n){return au(e,{tick:n,index:t,type:`tick`})}function Mp(e,t,n){let r=rl(e);return(n&&t!==`right`||!n&&t===`right`)&&(r=Sp(r)),r}function Np(e,t,n,r){let{top:i,left:a,bottom:o,right:s,chart:c}=e,{chartArea:l,scales:u}=c,d=0,f,p,m,h=o-i,g=s-a;if(e.isHorizontal()){if(p=il(r,a,s),Y(n)){let e=Object.keys(n)[0],r=n[e];m=u[e].getPixelForValue(r)+h-t}else m=n===`center`?(l.bottom+l.top)/2+h-t:Cp(e,n,t);f=s-a}else{if(Y(n)){let e=Object.keys(n)[0],r=n[e];p=u[e].getPixelForValue(r)-g+t}else p=n===`center`?(l.left+l.right)/2-g+t:Cp(e,n,t);m=il(r,o,i),d=n===`left`?-Cc:Cc}return{titleX:p,titleY:m,maxWidth:f,rotation:d}}var Pp=class e extends mp{constructor(e){super(),this.id=e.id,this.type=e.type,this.options=void 0,this.ctx=e.ctx,this.chart=e.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(e){this.options=e.setContext(this.getContext()),this.axis=e.axis,this._userMin=this.parse(e.min),this._userMax=this.parse(e.max),this._suggestedMin=this.parse(e.suggestedMin),this._suggestedMax=this.parse(e.suggestedMax)}parse(e,t){return e}getUserBounds(){let{_userMin:e,_userMax:t,_suggestedMin:n,_suggestedMax:r}=this;return e=ec(e,1/0),t=ec(t,-1/0),n=ec(n,1/0),r=ec(r,-1/0),{min:ec(e,n),max:ec(t,r),minDefined:$s(e),maxDefined:$s(t)}}getMinMax(e){let{min:t,max:n,minDefined:r,maxDefined:i}=this.getUserBounds(),a;if(r&&i)return{min:t,max:n};let o=this.getMatchingVisibleMetas();for(let s=0,c=o.length;s<c;++s)a=o[s].controller.getMinMax(this,e),r||(t=Math.min(t,a.min)),i||(n=Math.max(n,a.max));return t=i&&t>n?n:t,n=r&&t>n?t:n,{min:ec(t,ec(n,t)),max:ec(n,ec(t,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||=this._computeLabelItems(e)}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){Z(this.options.beforeUpdate,[this])}update(e,t,n){let{beginAtZero:r,grace:i,ticks:a}=this.options,o=a.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=t,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||=(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=iu(this,i,r),!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let s=o<this.ticks.length;this._convertTicksToLabels(s?Tp(this.ticks,o):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),a.display&&(a.autoSkip||a.source===`auto`)&&(this.ticks=hp(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),s&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let e=this.options.reverse,t,n;this.isHorizontal()?(t=this.left,n=this.right):(t=this.top,n=this.bottom,e=!e),this._startPixel=t,this._endPixel=n,this._reversePixels=e,this._length=n-t,this._alignToPixels=this.options.alignToPixels}afterUpdate(){Z(this.options.afterUpdate,[this])}beforeSetDimensions(){Z(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(){Z(this.options.afterSetDimensions,[this])}_callHooks(e){this.chart.notifyPlugins(e,this.getContext()),Z(this.options[e],[this])}beforeDataLimits(){this._callHooks(`beforeDataLimits`)}determineDataLimits(){}afterDataLimits(){this._callHooks(`afterDataLimits`)}beforeBuildTicks(){this._callHooks(`beforeBuildTicks`)}buildTicks(){return[]}afterBuildTicks(){this._callHooks(`afterBuildTicks`)}beforeTickToLabelConversion(){Z(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(e){let t=this.options.ticks,n,r,i;for(n=0,r=e.length;n<r;n++)i=e[n],i.label=Z(t.callback,[i.value,n,e],this)}afterTickToLabelConversion(){Z(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){Z(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){let e=this.options,t=e.ticks,n=wp(this.ticks.length,e.ticks.maxTicksLimit),r=t.minRotation||0,i=t.maxRotation,a=r,o,s,c;if(!this._isVisible()||!t.display||r>=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}let l=this._getLabelSizes(),u=l.widest.width,d=l.highest.height,f=Uc(this.chart.width-u,0,this.maxWidth);o=e.offset?this.maxWidth/n:f/(n-1),u+6>o&&(o=f/(n-(e.offset?.5:1)),s=this.maxHeight-Op(e.grid)-t.padding-kp(e.title,this.chart.options.font),c=Math.sqrt(u*u+d*d),a=Ic(Math.min(Math.asin(Uc((l.highest.height+6)/o,-1,1)),Math.asin(Uc(s/c,-1,1))-Math.asin(Uc(d/c,-1,1)))),a=Math.max(r,Math.min(i,a))),this.labelRotation=a}afterCalculateLabelRotation(){Z(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){Z(this.options.beforeFit,[this])}fit(){let e={width:0,height:0},{chart:t,options:{ticks:n,title:r,grid:i}}=this,a=this._isVisible(),o=this.isHorizontal();if(a){let a=kp(r,t.options.font);if(o?(e.width=this.maxWidth,e.height=Op(i)+a):(e.height=this.maxHeight,e.width=Op(i)+a),n.display&&this.ticks.length){let{first:t,last:r,widest:i,highest:a}=this._getLabelSizes(),s=n.padding*2,c=Fc(this.labelRotation),l=Math.cos(c),u=Math.sin(c);if(o){let t=n.mirror?0:u*i.width+l*a.height;e.height=Math.min(this.maxHeight,e.height+t+s)}else{let t=n.mirror?0:l*i.width+u*a.height;e.width=Math.min(this.maxWidth,e.width+t+s)}this._calculatePadding(t,r,u,l)}}this._handleMargins(),o?(this.width=this._length=t.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=t.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,t,n,r){let{ticks:{align:i,padding:a},position:o}=this.options,s=this.labelRotation!==0,c=o!==`top`&&this.axis===`x`;if(this.isHorizontal()){let o=this.getPixelForTick(0)-this.left,l=this.right-this.getPixelForTick(this.ticks.length-1),u=0,d=0;s?c?(u=r*e.width,d=n*t.height):(u=n*e.height,d=r*t.width):i===`start`?d=t.width:i===`end`?u=e.width:i!==`inner`&&(u=e.width/2,d=t.width/2),this.paddingLeft=Math.max((u-o+a)*this.width/(this.width-o),0),this.paddingRight=Math.max((d-l+a)*this.width/(this.width-l),0)}else{let n=t.height/2,r=e.height/2;i===`start`?(n=0,r=e.height):i===`end`&&(n=t.height,r=0),this.paddingTop=n+a,this.paddingBottom=r+a}}_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(){Z(this.options.afterFit,[this])}isHorizontal(){let{axis:e,position:t}=this.options;return t===`top`||t===`bottom`||e===`x`}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let t,n;for(t=0,n=e.length;t<n;t++)J(e[t].label)&&(e.splice(t,1),n--,t--);this.afterTickToLabelConversion()}_getLabelSizes(){let e=this._labelSizes;if(!e){let t=this.options.ticks.sampleSize,n=this.ticks;t<n.length&&(n=Tp(n,t)),this._labelSizes=e=this._computeLabelSizes(n,n.length,this.options.ticks.maxTicksLimit)}return e}_computeLabelSizes(e,t,n){let{ctx:r,_longestTextCache:i}=this,a=[],o=[],s=Math.floor(t/wp(t,n)),c=0,l=0,u,d,f,p,m,h,g,_,v,y,b;for(u=0;u<t;u+=s){if(p=e[u].label,m=this._resolveTickFontOptions(u),r.font=h=m.string,g=i[h]=i[h]||{data:{},gc:[]},_=m.lineHeight,v=y=0,!J(p)&&!Qs(p))v=Ml(r,g.data,g.gc,v,p),y=_;else if(Qs(p))for(d=0,f=p.length;d<f;++d)b=p[d],!J(b)&&!Qs(b)&&(v=Ml(r,g.data,g.gc,v,b),y+=_);a.push(v),o.push(y),c=Math.max(v,c),l=Math.max(y,l)}Dp(i,t);let x=a.indexOf(c),S=o.indexOf(l),C=e=>({width:a[e]||0,height:o[e]||0});return{first:C(0),last:C(t-1),widest:C(x),highest:C(S),widths:a,heights:o}}getLabelForValue(e){return e}getPixelForValue(e,t){return NaN}getValueForPixel(e){}getPixelForTick(e){let t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);let t=this._startPixel+e*this._length;return Wc(this._alignToPixels?Pl(this.chart,t,0):t)}getDecimalForPixel(e){let t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:e,max:t}=this;return e<0&&t<0?t:e>0&&t>0?e:0}getContext(e){let t=this.ticks||[];if(e>=0&&e<t.length){let n=t[e];return n.$context||=jp(this.getContext(),e,n)}return this.$context||=Ap(this.chart.getContext(),this)}_tickSize(){let e=this.options.ticks,t=Fc(this.labelRotation),n=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t)),i=this._getLabelSizes(),a=e.autoSkipPadding||0,o=i?i.widest.width+a:0,s=i?i.highest.height+a:0;return this.isHorizontal()?s*n>o*r?o/n:s/r:s*r<o*n?s/n:o/r}_isVisible(){let e=this.options.display;return e===`auto`?this.getMatchingVisibleMetas().length>0:!!e}_computeGridLineItems(e){let t=this.axis,n=this.chart,r=this.options,{grid:i,position:a,border:o}=r,s=i.offset,c=this.isHorizontal(),l=this.ticks.length+ +!!s,u=Op(i),d=[],f=o.setContext(this.getContext()),p=f.display?f.width:0,m=p/2,h=function(e){return Pl(n,e,p)},g,_,v,y,b,x,S,C,w,T,E,D;if(a===`top`)g=h(this.bottom),x=this.bottom-u,C=g-m,T=h(e.top)+m,D=e.bottom;else if(a===`bottom`)g=h(this.top),T=e.top,D=h(e.bottom)-m,x=g+m,C=this.top+u;else if(a===`left`)g=h(this.right),b=this.right-u,S=g-m,w=h(e.left)+m,E=e.right;else if(a===`right`)g=h(this.left),w=e.left,E=h(e.right)-m,b=g+m,S=this.left+u;else if(t===`x`){if(a===`center`)g=h((e.top+e.bottom)/2+.5);else if(Y(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}T=e.top,D=e.bottom,x=g+m,C=x+u}else if(t===`y`){if(a===`center`)g=h((e.left+e.right)/2);else if(Y(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}b=g-m,S=b-u,w=e.left,E=e.right}let ee=X(r.ticks.maxTicksLimit,l),te=Math.max(1,Math.ceil(l/ee));for(_=0;_<l;_+=te){let e=this.getContext(_),t=i.setContext(e),r=o.setContext(e),a=t.lineWidth,l=t.color,u=r.dash||[],f=r.dashOffset,p=t.tickWidth,m=t.tickColor,h=t.tickBorderDash||[],g=t.tickBorderDashOffset;v=Ep(this,_,s),v!==void 0&&(y=Pl(n,v,a),c?b=S=w=E=y:x=C=T=D=y,d.push({tx1:b,ty1:x,tx2:S,ty2:C,x1:w,y1:T,x2:E,y2:D,width:a,color:l,borderDash:u,borderDashOffset:f,tickWidth:p,tickColor:m,tickBorderDash:h,tickBorderDashOffset:g}))}return this._ticksLength=l,this._borderValue=g,d}_computeLabelItems(e){let t=this.axis,n=this.options,{position:r,ticks:i}=n,a=this.isHorizontal(),o=this.ticks,{align:s,crossAlign:c,padding:l,mirror:u}=i,d=Op(n.grid),f=d+l,p=u?-l:f,m=-Fc(this.labelRotation),h=[],g,_,v,y,b,x,S,C,w,T,E,D,ee=`middle`;if(r===`top`)x=this.bottom-p,S=this._getXAxisLabelAlignment();else if(r===`bottom`)x=this.top+p,S=this._getXAxisLabelAlignment();else if(r===`left`){let e=this._getYAxisLabelAlignment(d);S=e.textAlign,b=e.x}else if(r===`right`){let e=this._getYAxisLabelAlignment(d);S=e.textAlign,b=e.x}else if(t===`x`){if(r===`center`)x=(e.top+e.bottom)/2+f;else if(Y(r)){let e=Object.keys(r)[0],t=r[e];x=this.chart.scales[e].getPixelForValue(t)+f}S=this._getXAxisLabelAlignment()}else if(t===`y`){if(r===`center`)b=(e.left+e.right)/2-f;else if(Y(r)){let e=Object.keys(r)[0],t=r[e];b=this.chart.scales[e].getPixelForValue(t)}S=this._getYAxisLabelAlignment(d).textAlign}t===`y`&&(s===`start`?ee=`top`:s===`end`&&(ee=`bottom`));let te=this._getLabelSizes();for(g=0,_=o.length;g<_;++g){v=o[g],y=v.label;let e=i.setContext(this.getContext(g));C=this.getPixelForTick(g)+i.labelOffset,w=this._resolveTickFontOptions(g),T=w.lineHeight,E=Qs(y)?y.length:1;let t=E/2,n=e.color,s=e.textStrokeColor,l=e.textStrokeWidth,d=S;a?(b=C,S===`inner`&&(d=g===_-1?this.options.reverse?`left`:`right`:g===0?this.options.reverse?`right`:`left`:`center`),D=r===`top`?c===`near`||m!==0?-E*T+T/2:c===`center`?-te.highest.height/2-t*T+T:-te.highest.height+T/2:c===`near`||m!==0?T/2:c===`center`?te.highest.height/2-t*T:te.highest.height-E*T,u&&(D*=-1),m!==0&&!e.showLabelBackdrop&&(b+=T/2*Math.sin(m))):(x=C,D=(1-E)*T/2);let f;if(e.showLabelBackdrop){let t=tu(e.backdropPadding),n=te.heights[g],r=te.widths[g],i=D-t.top,a=0-t.left;switch(ee){case`middle`:i-=n/2;break;case`bottom`:i-=n}switch(S){case`center`:a-=r/2;break;case`right`:a-=r;break;case`inner`:g===_-1?a-=r:g>0&&(a-=r/2)}f={left:a,top:i,width:r+t.width,height:n+t.height,color:e.backdropColor}}h.push({label:y,font:w,textOffset:D,options:{rotation:m,color:n,strokeColor:s,strokeWidth:l,textAlign:d,textBaseline:ee,translation:[b,x],backdrop:f}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:t}=this.options;if(-Fc(this.labelRotation))return e===`top`?`left`:`right`;let n=`center`;return t.align===`start`?n=`left`:t.align===`end`?n=`right`:t.align===`inner`&&(n=`inner`),n}_getYAxisLabelAlignment(e){let{position:t,ticks:{crossAlign:n,mirror:r,padding:i}}=this.options,a=this._getLabelSizes(),o=e+i,s=a.widest.width,c,l;return t===`left`?r?(l=this.right+i,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l+=s)):(l=this.right-o,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l=this.left)):t===`right`?r?(l=this.left+i,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l-=s)):(l=this.left+o,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l=this.right)):c=`right`,{textAlign:c,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;let e=this.chart,t=this.options.position;if(t===`left`||t===`right`)return{top:0,left:this.left,bottom:e.height,right:this.right};if(t===`top`||t===`bottom`)return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){let{ctx:e,options:{backgroundColor:t},left:n,top:r,width:i,height:a}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,r,i,a),e.restore())}getLineWidthForValue(e){let t=this.options.grid;if(!this._isVisible()||!t.display)return 0;let n=this.ticks.findIndex(t=>t.value===e);return n>=0?t.setContext(this.getContext(n)).lineWidth:0}drawGrid(e){let t=this.options.grid,n=this.ctx,r=this._gridLineItems||=this._computeGridLineItems(e),i,a,o=(e,t,r)=>{!r.width||!r.color||(n.save(),n.lineWidth=r.width,n.strokeStyle=r.color,n.setLineDash(r.borderDash||[]),n.lineDashOffset=r.borderDashOffset,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.stroke(),n.restore())};if(t.display)for(i=0,a=r.length;i<a;++i){let e=r[i];t.drawOnChartArea&&o({x:e.x1,y:e.y1},{x:e.x2,y:e.y2},e),t.drawTicks&&o({x:e.tx1,y:e.ty1},{x:e.tx2,y:e.ty2},{color:e.tickColor,width:e.tickWidth,borderDash:e.tickBorderDash,borderDashOffset:e.tickBorderDashOffset})}}drawBorder(){let{chart:e,ctx:t,options:{border:n,grid:r}}=this,i=n.setContext(this.getContext()),a=n.display?i.width:0;if(!a)return;let o=r.setContext(this.getContext(0)).lineWidth,s=this._borderValue,c,l,u,d;this.isHorizontal()?(c=Pl(e,this.left,a)-a/2,l=Pl(e,this.right,o)+o/2,u=d=s):(u=Pl(e,this.top,a)-a/2,d=Pl(e,this.bottom,o)+o/2,c=l=s),t.save(),t.lineWidth=i.width,t.strokeStyle=i.color,t.beginPath(),t.moveTo(c,u),t.lineTo(l,d),t.stroke(),t.restore()}drawLabels(e){if(!this.options.ticks.display)return;let t=this.ctx,n=this._computeLabelArea();n&&zl(t,n);let r=this.getLabelItems(e);for(let e of r){let n=e.options,r=e.font,i=e.label,a=e.textOffset;Kl(t,i,0,a,r,n)}n&&Bl(t)}drawTitle(){let{ctx:e,options:{position:t,title:n,reverse:r}}=this;if(!n.display)return;let i=nu(n.font),a=tu(n.padding),o=n.align,s=i.lineHeight/2;t===`bottom`||t===`center`||Y(t)?(s+=a.bottom,Qs(n.text)&&(s+=i.lineHeight*(n.text.length-1))):s+=a.top;let{titleX:c,titleY:l,maxWidth:u,rotation:d}=Np(this,s,t,o);Kl(e,n.text,0,0,i,{color:n.color,maxWidth:u,rotation:d,textAlign:Mp(o,t,r),textBaseline:`middle`,translation:[c,l]})}draw(e){this._isVisible()&&(this.drawBackground(),this.drawGrid(e),this.drawBorder(),this.drawTitle(),this.drawLabels(e))}_layers(){let t=this.options,n=t.ticks&&t.ticks.z||0,r=X(t.grid&&t.grid.z,-1),i=X(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==e.prototype.draw?[{z:n,draw:e=>{this.draw(e)}}]:[{z:r,draw:e=>{this.drawBackground(),this.drawGrid(e),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:e=>{this.drawLabels(e)}}]}getMatchingVisibleMetas(e){let t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+`AxisID`,r=[],i,a;for(i=0,a=t.length;i<a;++i){let a=t[i];a[n]===this.id&&(!e||a.type===e)&&r.push(a)}return r}_resolveTickFontOptions(e){return nu(this.options.ticks.setContext(this.getContext(e)).font)}_maxDigits(){let e=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/e}},Fp=class{constructor(e,t,n){this.type=e,this.scope=t,this.override=n,this.items=Object.create(null)}isForType(e){return Object.prototype.isPrototypeOf.call(this.type.prototype,e.prototype)}register(e){let t=Object.getPrototypeOf(e),n;Rp(t)&&(n=this.register(t));let r=this.items,i=e.id,a=this.scope+`.`+i;if(!i)throw Error(`class does not have id: `+e);return i in r?a:(r[i]=e,Ip(e,a,n),this.override&&Al.override(e.id,e.overrides),a)}get(e){return this.items[e]}unregister(e){let t=this.items,n=e.id,r=this.scope;n in t&&delete t[n],r&&n in Al[r]&&(delete Al[r][n],this.override&&delete El[n])}};function Ip(e,t,n){let r=sc(Object.create(null),[n?Al.get(n):{},Al.get(t),e.defaults]);Al.set(t,r),e.defaultRoutes&&Lp(t,e.defaultRoutes),e.descriptors&&Al.describe(t,e.descriptors)}function Lp(e,t){Object.keys(t).forEach(n=>{let r=n.split(`.`),i=r.pop(),a=[e].concat(r).join(`.`),o=t[n].split(`.`),s=o.pop(),c=o.join(`.`);Al.route(a,i,c,s)})}function Rp(e){return`id`in e&&`defaults`in e}var zp=new class{constructor(){this.controllers=new Fp(qd,`datasets`,!0),this.elements=new Fp(mp,`elements`),this.plugins=new Fp(Object,`plugins`),this.scales=new Fp(Pp,`scales`),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each(`register`,e)}remove(...e){this._each(`unregister`,e)}addControllers(...e){this._each(`register`,e,this.controllers)}addElements(...e){this._each(`register`,e,this.elements)}addPlugins(...e){this._each(`register`,e,this.plugins)}addScales(...e){this._each(`register`,e,this.scales)}getController(e){return this._get(e,this.controllers,`controller`)}getElement(e){return this._get(e,this.elements,`element`)}getPlugin(e){return this._get(e,this.plugins,`plugin`)}getScale(e){return this._get(e,this.scales,`scale`)}removeControllers(...e){this._each(`unregister`,e,this.controllers)}removeElements(...e){this._each(`unregister`,e,this.elements)}removePlugins(...e){this._each(`unregister`,e,this.plugins)}removeScales(...e){this._each(`unregister`,e,this.scales)}_each(e,t,n){[...t].forEach(t=>{let r=n||this._getRegistryForType(t);n||r.isForType(t)||r===this.plugins&&t.id?this._exec(e,r,t):Q(t,t=>{let r=n||this._getRegistryForType(t);this._exec(e,r,t)})})}_exec(e,t,n){let r=mc(e);Z(n[`before`+r],[],n),t[e](n),Z(n[`after`+r],[],n)}_getRegistryForType(e){for(let t=0;t<this._typedRegistries.length;t++){let n=this._typedRegistries[t];if(n.isForType(e))return n}return this.plugins}_get(e,t,n){let r=t.get(e);if(r===void 0)throw Error(`"`+e+`" is not a registered `+n+`.`);return r}},Bp=class{constructor(){this._init=void 0}notify(e,t,n,r){if(t===`beforeInit`&&(this._init=this._createDescriptors(e,!0),this._notify(this._init,e,`install`)),this._init===void 0)return;let i=r?this._descriptors(e).filter(r):this._descriptors(e),a=this._notify(i,e,t,n);return t===`afterDestroy`&&(this._notify(i,e,`stop`),this._notify(this._init,e,`uninstall`),this._init=void 0),a}_notify(e,t,n,r){r||={};for(let i of e){let e=i.plugin,a=e[n];if(Z(a,[t,r,i.options],e)===!1&&r.cancelable)return!1}return!0}invalidate(){J(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(e){if(this._cache)return this._cache;let t=this._cache=this._createDescriptors(e);return this._notifyStateChanges(e),t}_createDescriptors(e,t){let n=e&&e.config,r=X(n.options&&n.options.plugins,{}),i=Vp(n);return r===!1&&!t?[]:Up(e,i,r,t)}_notifyStateChanges(e){let t=this._oldCache||[],n=this._cache,r=(e,t)=>e.filter(e=>!t.some(t=>e.plugin.id===t.plugin.id));this._notify(r(t,n),e,`stop`),this._notify(r(n,t),e,`start`)}};function Vp(e){let t={},n=[],r=Object.keys(zp.plugins.items);for(let e=0;e<r.length;e++)n.push(zp.getPlugin(r[e]));let i=e.plugins||[];for(let e=0;e<i.length;e++){let r=i[e];n.indexOf(r)===-1&&(n.push(r),t[r.id]=!0)}return{plugins:n,localIds:t}}function Hp(e,t){return!t&&e===!1?null:e===!0?{}:e}function Up(e,{plugins:t,localIds:n},r,i){let a=[],o=e.getContext();for(let s of t){let t=s.id,c=Hp(r[t],i);c!==null&&a.push({plugin:s,options:Wp(e.config,{plugin:s,local:n[t]},c,o)})}return a}function Wp(e,{plugin:t,local:n},r,i){let a=e.pluginScopeKeys(t),o=e.getOptionScopes(r,a);return n&&t.defaults&&o.push(t.defaults),e.createResolver(o,i,[``],{scriptable:!1,indexable:!1,allKeys:!0})}function Gp(e,t){let n=Al.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||`x`}function Kp(e,t){let n=e;return e===`_index_`?n=t:e===`_value_`&&(n=t===`x`?`y`:`x`),n}function qp(e,t){return e===t?`_index_`:`_value_`}function Jp(e){if(e===`x`||e===`y`||e===`r`)return e}function Yp(e){if(e===`top`||e===`bottom`)return`x`;if(e===`left`||e===`right`)return`y`}function Xp(e,...t){if(Jp(e))return e;for(let n of t){let t=n.axis||Yp(n.position)||e.length>1&&Jp(e[0].toLowerCase());if(t)return t}throw Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function Zp(e,t,n){if(n[t+`AxisID`]===e)return{axis:t}}function Qp(e,t){if(t.data&&t.data.datasets){let n=t.data.datasets.filter(t=>t.xAxisID===e||t.yAxisID===e);if(n.length)return Zp(e,`x`,n[0])||Zp(e,`y`,n[0])}return{}}function $p(e,t){let n=El[e.type]||{scales:{}},r=t.scales||{},i=Gp(e.type,t),a=Object.create(null);return Object.keys(r).forEach(t=>{let o=r[t];if(!Y(o))return console.error(`Invalid scale configuration for scale: ${t}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);let s=Xp(t,o,Qp(t,e),Al.scales[o.type]),c=qp(s,i),l=n.scales||{};a[t]=cc(Object.create(null),[{axis:s},o,l[s],l[c]])}),e.data.datasets.forEach(n=>{let i=n.type||e.type,o=n.indexAxis||Gp(i,t),s=(El[i]||{}).scales||{};Object.keys(s).forEach(e=>{let t=Kp(e,o),i=n[t+`AxisID`]||t;a[i]=a[i]||Object.create(null),cc(a[i],[{axis:t},r[i],s[e]])})}),Object.keys(a).forEach(e=>{let t=a[e];cc(t,[Al.scales[t.type],Al.scale])}),a}function em(e){let t=e.options||={};t.plugins=X(t.plugins,{}),t.scales=$p(e,t)}function tm(e){return e||={},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function nm(e){return e||={},e.data=tm(e.data),em(e),e}var rm=new Map,im=new Set;function am(e,t){let n=rm.get(e);return n||(n=t(),rm.set(e,n),im.add(n)),n}var om=(e,t,n)=>{let r=pc(t,n);r!==void 0&&e.add(r)},sm=class{constructor(e){this._config=nm(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=tm(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){let e=this._config;this.clearCache(),em(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return am(e,()=>[[`datasets.${e}`,``]])}datasetAnimationScopeKeys(e,t){return am(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,``]])}datasetElementScopeKeys(e,t){return am(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,``]])}pluginScopeKeys(e){let t=e.id,n=this.type;return am(`${n}-plugin-${t}`,()=>[[`plugins.${t}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){let n=this._scopeCache,r=n.get(e);return(!r||t)&&(r=new Map,n.set(e,r)),r}getOptionScopes(e,t,n){let{options:r,type:i}=this,a=this._cachedScopes(e,n),o=a.get(t);if(o)return o;let s=new Set;t.forEach(t=>{e&&(s.add(e),t.forEach(t=>om(s,e,t))),t.forEach(e=>om(s,r,e)),t.forEach(e=>om(s,El[i]||{},e)),t.forEach(e=>om(s,Al,e)),t.forEach(e=>om(s,Dl,e))});let c=Array.from(s);return c.length===0&&c.push(Object.create(null)),im.has(t)&&a.set(t,c),c}chartOptionScopes(){let{options:e,type:t}=this;return[e,El[t]||{},Al.datasets[t]||{},{type:t},Al,Dl]}resolveNamedOptions(e,t,n,r=[``]){let i={$shared:!0},{resolver:a,subPrefixes:o}=cm(this._resolverCache,e,r),s=a;if(um(a,t)){i.$shared=!1,n=gc(n)?n():n;let t=this.createResolver(e,n,o);s=su(a,n,t)}for(let e of t)i[e]=s[e];return i}createResolver(e,t,n=[``],r){let{resolver:i}=cm(this._resolverCache,e,n);return Y(t)?su(i,t,void 0,r):i}};function cm(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));let i=n.join(),a=r.get(i);return a||(a={resolver:ou(t,n),subPrefixes:n.filter(e=>!e.toLowerCase().includes(`hover`))},r.set(i,a)),a}var lm=e=>Y(e)&&Object.getOwnPropertyNames(e).some(t=>gc(e[t]));function um(e,t){let{isScriptable:n,isIndexable:r}=cu(e);for(let i of t){let t=n(i),a=r(i),o=(a||t)&&e[i];if(t&&(gc(o)||lm(o))||a&&Qs(o))return!0}return!1}var dm=`4.5.1`,fm=[`top`,`bottom`,`left`,`right`,`chartArea`];function pm(e,t){return e===`top`||e===`bottom`||fm.indexOf(e)===-1&&t===`x`}function mm(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function hm(e){let t=e.chart,n=t.options.animation;t.notifyPlugins(`afterRender`),Z(n&&n.onComplete,[e],t)}function gm(e){let t=e.chart,n=t.options.animation;Z(n&&n.onProgress,[e],t)}function _m(e){return Iu()&&typeof e==`string`?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}var vm={},ym=e=>{let t=_m(e);return Object.values(vm).filter(e=>e.canvas===t).pop()};function bm(e,t,n){let r=Object.keys(e);for(let i of r){let r=+i;if(r>=t){let a=e[i];delete e[i],(n>0||r>t)&&(e[r+n]=a)}}}function xm(e,t,n,r){return!n||e.type===`mouseout`?null:r?t:e}var Sm=class{static defaults=Al;static instances=vm;static overrides=El;static registry=zp;static version=dm;static getChart=ym;static register(...e){zp.add(...e),Cm()}static unregister(...e){zp.remove(...e),Cm()}constructor(e,t){let n=this.config=new sm(t),r=_m(e),i=ym(r);if(i)throw Error(`Canvas is already in use. Chart with ID '`+i.id+`' must be destroyed before the canvas with ID '`+i.canvas.id+`' can be reused.`);let a=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||(pp(r))),this.platform.updateConfig(n);let o=this.platform.acquireContext(r,a.aspectRatio),s=o&&o.canvas,c=s&&s.height,l=s&&s.width;if(this.id=Zs(),this.ctx=o,this.canvas=s,this.width=l,this.height=c,this._options=a,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 Bp,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=nl(e=>this.update(e),a.resizeDelay||0),this._dataChanges=[],vm[this.id]=this,!o||!s){console.error(`Failed to create chart: can't acquire context from the given item`);return}xd.listen(this,`complete`,hm),xd.listen(this,`progress`,gm),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:r,_aspectRatio:i}=this;return J(e)?t&&i?i:r?n/r:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return zp}_initialize(){return this.notifyPlugins(`beforeInit`),this.options.responsive?this.resize():Yu(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins(`afterInit`),this}clear(){return Fl(this.canvas,this.ctx),this}stop(){return xd.stop(this),this}resize(e,t){xd.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){let n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(r,e,t,i),o=n.devicePixelRatio||this.platform.getDevicePixelRatio(),s=this.width?`resize`:`attach`;this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,Yu(this,o,!0)&&(this.notifyPlugins(`resize`,{size:a}),Z(n.onResize,[this,a],this),this.attached&&this._doResize(s)&&this.render())}ensureScalesHaveIDs(){Q(this.options.scales||{},(e,t)=>{e.id=t})}buildOrUpdateScales(){let e=this.options,t=e.scales,n=this.scales,r=Object.keys(n).reduce((e,t)=>(e[t]=!1,e),{}),i=[];t&&(i=i.concat(Object.keys(t).map(e=>{let n=t[e],r=Xp(e,n),i=r===`r`,a=r===`x`;return{options:n,dposition:i?`chartArea`:a?`bottom`:`left`,dtype:i?`radialLinear`:a?`category`:`linear`}}))),Q(i,t=>{let i=t.options,a=i.id,o=Xp(a,i),s=X(i.type,t.dtype);(i.position===void 0||pm(i.position,o)!==pm(t.dposition))&&(i.position=t.dposition),r[a]=!0;let c=null;a in n&&n[a].type===s?c=n[a]:(c=new(zp.getScale(s))({id:a,type:s,ctx:this.ctx,chart:this}),n[c.id]=c),c.init(i,e)}),Q(r,(e,t)=>{e||delete n[t]}),Q(n,e=>{Wf.configure(this,e,e.options),Wf.addBox(this,e)})}_updateMetasets(){let e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((e,t)=>e.index-t.index),n>t){for(let e=t;e<n;++e)this._destroyDatasetMeta(e);e.splice(t,n-t)}this._sortedMetasets=e.slice(0).sort(mm(`order`,`index`))}_removeUnreferencedMetasets(){let{_metasets:e,data:{datasets:t}}=this;e.length>t.length&&delete this._stacks,e.forEach((e,n)=>{t.filter(t=>t===e._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let e=[],t=this.data.datasets,n,r;for(this._removeUnreferencedMetasets(),n=0,r=t.length;n<r;n++){let r=t[n],i=this.getDatasetMeta(n),a=r.type||this.config.type;if(i.type&&i.type!==a&&(this._destroyDatasetMeta(n),i=this.getDatasetMeta(n)),i.type=a,i.indexAxis=r.indexAxis||Gp(a,this.options),i.order=r.order||0,i.index=n,i.label=``+r.label,i.visible=this.isDatasetVisible(n),i.controller)i.controller.updateIndex(n),i.controller.linkScales();else{let t=zp.getController(a),{datasetElementType:r,dataElementType:o}=Al.datasets[a];Object.assign(t,{dataElementType:zp.getElement(o),datasetElementType:r&&zp.getElement(r)}),i.controller=new t(this,n),e.push(i.controller)}}return this._updateMetasets(),e}_resetElements(){Q(this.data.datasets,(e,t)=>{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins(`reset`)}update(e){let t=this.config;t.update();let n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins(`beforeUpdate`,{mode:e,cancelable:!0})===!1)return;let i=this.buildOrUpdateControllers();this.notifyPlugins(`beforeElementsUpdate`);let a=0;for(let e=0,t=this.data.datasets.length;e<t;e++){let{controller:t}=this.getDatasetMeta(e),n=!r&&i.indexOf(t)===-1;t.buildOrUpdateElements(n),a=Math.max(+t.getMaxOverflow(),a)}a=this._minPadding=n.layout.autoPadding?a:0,this._updateLayout(a),r||Q(i,e=>{e.reset()}),this._updateDatasets(e),this.notifyPlugins(`afterUpdate`,{mode:e}),this._layers.sort(mm(`z`,`_idx`));let{_active:o,_lastEvent:s}=this;s?this._eventHandler(s,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){Q(this.scales,e=>{Wf.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options;(!_c(new Set(Object.keys(this._listeners)),new Set(e.events))||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(let{method:n,start:r,count:i}of t)bm(e,r,n===`_removeElements`?-i:i)}_getUniformDataChanges(){let e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];let t=this.data.datasets.length,n=t=>new Set(e.filter(e=>e[0]===t).map((e,t)=>t+`,`+e.splice(1).join(`,`))),r=n(0);for(let e=1;e<t;e++)if(!_c(r,n(e)))return;return Array.from(r).map(e=>e.split(`,`)).map(e=>({method:e[1],start:+e[2],count:+e[3]}))}_updateLayout(e){if(this.notifyPlugins(`beforeLayout`,{cancelable:!0})===!1)return;Wf.update(this,this.width,this.height,e);let t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],Q(this.boxes,e=>{n&&e.position===`chartArea`||(e.configure&&e.configure(),this._layers.push(...e._layers()))},this),this._layers.forEach((e,t)=>{e._idx=t}),this.notifyPlugins(`afterLayout`)}_updateDatasets(e){if(this.notifyPlugins(`beforeDatasetsUpdate`,{mode:e,cancelable:!0})!==!1){for(let e=0,t=this.data.datasets.length;e<t;++e)this.getDatasetMeta(e).controller.configure();for(let t=0,n=this.data.datasets.length;t<n;++t)this._updateDataset(t,gc(e)?e({datasetIndex:t}):e);this.notifyPlugins(`afterDatasetsUpdate`,{mode:e})}}_updateDataset(e,t){let n=this.getDatasetMeta(e),r={meta:n,index:e,mode:t,cancelable:!0};this.notifyPlugins(`beforeDatasetUpdate`,r)!==!1&&(n.controller._update(t),r.cancelable=!1,this.notifyPlugins(`afterDatasetUpdate`,r))}render(){this.notifyPlugins(`beforeRender`,{cancelable:!0})!==!1&&(xd.has(this)?this.attached&&!xd.running(this)&&xd.start(this):(this.draw(),hm({chart:this})))}draw(){let e;if(this._resizeBeforeDraw){let{width:e,height:t}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(e,t)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins(`beforeDraw`,{cancelable:!0})===!1)return;let t=this._layers;for(e=0;e<t.length&&t[e].z<=0;++e)t[e].draw(this.chartArea);for(this._drawDatasets();e<t.length;++e)t[e].draw(this.chartArea);this.notifyPlugins(`afterDraw`)}_getSortedDatasetMetas(e){let t=this._sortedMetasets,n=[],r,i;for(r=0,i=t.length;r<i;++r){let i=t[r];(!e||i.visible)&&n.push(i)}return n}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins(`beforeDatasetsDraw`,{cancelable:!0})===!1)return;let e=this.getSortedVisibleDatasetMetas();for(let t=e.length-1;t>=0;--t)this._drawDataset(e[t]);this.notifyPlugins(`afterDatasetsDraw`)}_drawDataset(e){let t=this.ctx,n={meta:e,index:e.index,cancelable:!0},r=bd(this,e);this.notifyPlugins(`beforeDatasetDraw`,n)!==!1&&(r&&zl(t,r),e.controller.draw(),r&&Bl(t),n.cancelable=!1,this.notifyPlugins(`afterDatasetDraw`,n))}isPointInArea(e){return Rl(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,r){let i=Df.modes[t];return typeof i==`function`?i(this,e,n,r):[]}getDatasetMeta(e){let t=this.data.datasets[e],n=this._metasets,r=n.filter(e=>e&&e._dataset===t).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(r)),r}getContext(){return this.$context||=au(null,{chart:this,type:`chart`})}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){let t=this.data.datasets[e];if(!t)return!1;let n=this.getDatasetMeta(e);return typeof n.hidden==`boolean`?!n.hidden:!t.hidden}setDatasetVisibility(e,t){let n=this.getDatasetMeta(e);n.hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){let r=n?`show`:`hide`,i=this.getDatasetMeta(e),a=i.controller._resolveAnimations(void 0,r);hc(t)?(i.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),a.update(i,{visible:n}),this.update(t=>t.datasetIndex===e?r:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){let t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),xd.remove(this),e=0,t=this.data.datasets.length;e<t;++e)this._destroyDatasetMeta(e)}destroy(){this.notifyPlugins(`beforeDestroy`);let{canvas:e,ctx:t}=this;this._stop(),this.config.clearCache(),e&&(this.unbindEvents(),Fl(e,t),this.platform.releaseContext(t),this.canvas=null,this.ctx=null),delete vm[this.id],this.notifyPlugins(`afterDestroy`)}toBase64Image(...e){return this.canvas.toDataURL(...e)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){let e=this._listeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(e,t,n)=>{e.offsetX=t,e.offsetY=n,this._eventHandler(e)};Q(this.options.events,e=>n(e,r))}bindResponsiveEvents(){this._responsiveListeners||={};let e=this._responsiveListeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(n,r)=>{e[n]&&(t.removeEventListener(this,n,r),delete e[n])},i=(e,t)=>{this.canvas&&this.resize(e,t)},a,o=()=>{r(`attach`,o),this.attached=!0,this.resize(),n(`resize`,i),n(`detach`,a)};a=()=>{this.attached=!1,r(`resize`,i),this._stop(),this._resize(0,0),n(`attach`,o)},t.isAttached(this.canvas)?o():a()}unbindEvents(){Q(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},Q(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){let r=n?`set`:`remove`,i,a,o,s;for(t===`dataset`&&(i=this.getDatasetMeta(e[0].datasetIndex),i.controller[`_`+r+`DatasetHoverStyle`]()),o=0,s=e.length;o<s;++o){a=e[o];let t=a&&this.getDatasetMeta(a.datasetIndex).controller;t&&t[r+`HoverStyle`](a.element,a.datasetIndex,a.index)}}getActiveElements(){return this._active||[]}setActiveElements(e){let t=this._active||[],n=e.map(({datasetIndex:e,index:t})=>{let n=this.getDatasetMeta(e);if(!n)throw Error(`No dataset found at index `+e);return{datasetIndex:e,element:n.data[t],index:t}});rc(n,t)||(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return this._plugins._cache.filter(t=>t.plugin.id===e).length===1}_updateHoverStyles(e,t,n){let r=this.options.hover,i=(e,t)=>e.filter(e=>!t.some(t=>e.datasetIndex===t.datasetIndex&&e.index===t.index)),a=i(t,e),o=n?e:i(e,t);a.length&&this.updateHoverStyle(a,r.mode,!1),o.length&&r.mode&&this.updateHoverStyle(o,r.mode,!0)}_eventHandler(e,t){let n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},r=t=>(t.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins(`beforeEvent`,n,r)===!1)return;let i=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins(`afterEvent`,n,r),(i||n.changed)&&this.render(),this}_handleEvent(e,t,n){let{_active:r=[],options:i}=this,a=t,o=this._getActiveElements(e,r,n,a),s=vc(e),c=xm(e,this._lastEvent,n,s);n&&(this._lastEvent=null,Z(i.onHover,[e,o,this],this),s&&Z(i.onClick,[e,o,this],this));let l=!rc(o,r);return(l||t)&&(this._active=o,this._updateHoverStyles(o,r,t)),this._lastEvent=c,l}_getActiveElements(e,t,n,r){if(e.type===`mouseout`)return[];if(!n)return t;let i=this.options.hover;return this.getElementsAtEventForMode(e,i.mode,i,r)}};function Cm(){return Q(Sm.instances,e=>e._plugins.invalidate())}function wm(e,t,n){let{startAngle:r,x:i,y:a,outerRadius:o,innerRadius:s,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,d=Math.min(l/o,Vc(r-n));if(e.beginPath(),e.arc(i,a,o-l/2,r+d/2,n-d/2),s>0){let t=Math.min(l/s,Vc(r-n));e.arc(i,a,s+l/2,n-t/2,r+t/2,!0)}else{let t=Math.min(l/2,o*Vc(r-n));if(u===`round`)e.arc(i,a,t,n-$/2,r+$/2,!0);else if(u===`bevel`){let o=2*t*t,s=-o*Math.cos(n+$/2)+i,c=-o*Math.sin(n+$/2)+a,l=o*Math.cos(r+$/2)+i,u=o*Math.sin(r+$/2)+a;e.lineTo(s,c),e.lineTo(l,u)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip(`evenodd`)}function Tm(e,t,n){let{startAngle:r,pixelMargin:i,x:a,y:o,outerRadius:s,innerRadius:c}=t,l=i/s;e.beginPath(),e.arc(a,o,s,r-l,n+l),c>i?(l=i/c,e.arc(a,o,c,n+l,r-l,!0)):e.arc(a,o,i,n+Cc,r-Cc),e.closePath(),e.clip()}function Em(e){return Ql(e,[`outerStart`,`outerEnd`,`innerStart`,`innerEnd`])}function Dm(e,t,n,r){let i=Em(e.options.borderRadius),a=(n-t)/2,o=Math.min(a,r*t/2),s=e=>{let t=(n-Math.min(a,e))*r/2;return Uc(e,0,Math.min(a,t))};return{outerStart:s(i.outerStart),outerEnd:s(i.outerEnd),innerStart:Uc(i.innerStart,0,o),innerEnd:Uc(i.innerEnd,0,o)}}function Om(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function km(e,t,n,r,i,a){let{x:o,y:s,startAngle:c,pixelMargin:l,innerRadius:u}=t,d=Math.max(t.outerRadius+r+n-l,0),f=u>0?u+r+n+l:0,p=0,m=i-c;if(r){let e=((u>0?u-r:0)+(d>0?d-r:0))/2;p=(m-(e===0?m:m*e/(e+r)))/2}let h=(m-Math.max(.001,m*d-n/$)/d)/2,g=c+h+p,_=i-h-p,{outerStart:v,outerEnd:y,innerStart:b,innerEnd:x}=Dm(t,f,d,_-g),S=d-v,C=d-y,w=g+v/S,T=_-y/C,E=f+b,D=f+x,ee=g+b/E,te=_-x/D;if(e.beginPath(),a){let t=(w+T)/2;if(e.arc(o,s,d,w,t),e.arc(o,s,d,t,T),y>0){let t=Om(C,T,o,s);e.arc(t.x,t.y,y,T,_+Cc)}let n=Om(D,_,o,s);if(e.lineTo(n.x,n.y),x>0){let t=Om(D,te,o,s);e.arc(t.x,t.y,x,_+Cc,te+Math.PI)}let r=(_-x/f+(g+b/f))/2;if(e.arc(o,s,f,_-x/f,r,!0),e.arc(o,s,f,r,g+b/f,!0),b>0){let t=Om(E,ee,o,s);e.arc(t.x,t.y,b,ee+Math.PI,g-Cc)}let i=Om(S,g,o,s);if(e.lineTo(i.x,i.y),v>0){let t=Om(S,w,o,s);e.arc(t.x,t.y,v,g-Cc,w)}}else{e.moveTo(o,s);let t=Math.cos(w)*d+o,n=Math.sin(w)*d+s;e.lineTo(t,n);let r=Math.cos(T)*d+o,i=Math.sin(T)*d+s;e.lineTo(r,i)}e.closePath()}function Am(e,t,n,r,i){let{fullCircles:a,startAngle:o,circumference:s}=t,c=t.endAngle;if(a){km(e,t,n,r,c,i);for(let t=0;t<a;++t)e.fill();isNaN(s)||(c=o+(s%yc||yc))}return km(e,t,n,r,c,i),e.fill(),c}function jm(e,t,n,r,i){let{fullCircles:a,startAngle:o,circumference:s,options:c}=t,{borderWidth:l,borderJoinStyle:u,borderDash:d,borderDashOffset:f,borderRadius:p}=c,m=c.borderAlign===`inner`;if(!l)return;e.setLineDash(d||[]),e.lineDashOffset=f,m?(e.lineWidth=l*2,e.lineJoin=u||`round`):(e.lineWidth=l,e.lineJoin=u||`bevel`);let h=t.endAngle;if(a){km(e,t,n,r,h,i);for(let t=0;t<a;++t)e.stroke();isNaN(s)||(h=o+(s%yc||yc))}m&&Tm(e,t,h),c.selfJoin&&h-o>=$&&p===0&&u!==`miter`&&wm(e,t,h),a||(km(e,t,n,r,h,i),e.stroke())}var Mm=class extends mp{static id=`arc`;static defaults={borderAlign:`center`,borderColor:`#fff`,borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:`backgroundColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(e){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,e&&Object.assign(this,e)}inRange(e,t,n){let{angle:r,distance:i}=Rc(this.getProps([`x`,`y`],n),{x:e,y:t}),{startAngle:a,endAngle:o,innerRadius:s,outerRadius:c,circumference:l}=this.getProps([`startAngle`,`endAngle`,`innerRadius`,`outerRadius`,`circumference`],n),u=(this.options.spacing+this.options.borderWidth)/2,d=X(l,o-a),f=Hc(r,a,o)&&a!==o,p=d>=yc||f,m=Gc(i,s+u,c+u);return p&&m}getCenterPoint(e){let{x:t,y:n,startAngle:r,endAngle:i,innerRadius:a,outerRadius:o}=this.getProps([`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`],e),{offset:s,spacing:c}=this.options,l=(r+i)/2,u=(a+o+c+s)/2;return{x:t+Math.cos(l)*u,y:n+Math.sin(l)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:t,circumference:n}=this,r=(t.offset||0)/4,i=(t.spacing||0)/2,a=t.circular;if(this.pixelMargin=t.borderAlign===`inner`?.33:0,this.fullCircles=n>yc?Math.floor(n/yc):0,n===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let o=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(o)*r,Math.sin(o)*r);let s=r*(1-Math.sin(Math.min($,n||0)));e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,Am(e,this,s,i,a),jm(e,this,s,i,a),e.restore()}};function Nm(e,t,n=t){e.lineCap=X(n.borderCapStyle,t.borderCapStyle),e.setLineDash(X(n.borderDash,t.borderDash)),e.lineDashOffset=X(n.borderDashOffset,t.borderDashOffset),e.lineJoin=X(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=X(n.borderWidth,t.borderWidth),e.strokeStyle=X(n.borderColor,t.borderColor)}function Pm(e,t,n){e.lineTo(n.x,n.y)}function Fm(e){return e.stepped?Vl:e.tension||e.cubicInterpolationMode===`monotone`?Hl:Pm}function Im(e,t,n={}){let r=e.length,{start:i=0,end:a=r-1}=n,{start:o,end:s}=t,c=Math.max(i,o),l=Math.min(a,s),u=i<o&&a<o||i>s&&a>s;return{count:r,start:c,loop:t.loop,ilen:l<c&&!u?r+l-c:l-c}}function Lm(e,t,n,r){let{points:i,options:a}=t,{count:o,start:s,loop:c,ilen:l}=Im(i,n,r),u=Fm(a),{move:d=!0,reverse:f}=r||{},p,m,h;for(p=0;p<=l;++p)m=i[(s+(f?l-p:p))%o],!m.skip&&(d?(e.moveTo(m.x,m.y),d=!1):u(e,h,m,f,a.stepped),h=m);return c&&(m=i[(s+(f?l:0))%o],u(e,h,m,f,a.stepped)),!!c}function Rm(e,t,n,r){let i=t.points,{count:a,start:o,ilen:s}=Im(i,n,r),{move:c=!0,reverse:l}=r||{},u=0,d=0,f,p,m,h,g,_,v=e=>(o+(l?s-e:e))%a,y=()=>{h!==g&&(e.lineTo(u,g),e.lineTo(u,h),e.lineTo(u,_))};for(c&&(p=i[v(0)],e.moveTo(p.x,p.y)),f=0;f<=s;++f){if(p=i[v(f)],p.skip)continue;let t=p.x,n=p.y,r=t|0;r===m?(n<h?h=n:n>g&&(g=n),u=(d*u+t)/++d):(y(),e.lineTo(t,n),m=r,d=0,h=g=n),_=n}y()}function zm(e){let t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!==`monotone`&&!t.stepped&&!n?Rm:Lm}function Bm(e){return e.stepped?$u:e.tension||e.cubicInterpolationMode===`monotone`?ed:Qu}function Vm(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),Nm(e,t.options),e.stroke(i)}function Hm(e,t,n,r){let{segments:i,options:a}=t,o=zm(t);for(let s of i)Nm(e,a,s.style),e.beginPath(),o(e,t,s,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}var Um=typeof Path2D==`function`;function Wm(e,t,n,r){Um&&!t.options.segment?Vm(e,t,n,r):Hm(e,t,n,r)}var Gm=class extends mp{static id=`line`;static defaults={borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:`default`,fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`&&e!==`fill`};constructor(e){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,e&&Object.assign(this,e)}updateControlPoints(e,t){let n=this.options;if((n.tension||n.cubicInterpolationMode===`monotone`)&&!n.stepped&&!this._pointsUpdated){let r=n.spanGaps?this._loop:this._fullLoop;Fu(this._points,n,e,r,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||=pd(this,this.options.segment)}first(){let e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){let e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){let n=this.options,r=e[t],i=this.points,a=ud(this,{property:t,start:r,end:r});if(!a.length)return;let o=[],s=Bm(n),c,l;for(c=0,l=a.length;c<l;++c){let{start:l,end:u}=a[c],d=i[l],f=i[u];if(d===f){o.push(d);continue}let p=s(d,f,Math.abs((r-d[t])/(f[t]-d[t])),n.stepped);p[t]=e[t],o.push(p)}return o.length===1?o[0]:o}pathSegment(e,t,n){return zm(this)(e,this,t,n)}path(e,t,n){let r=this.segments,i=zm(this),a=this._loop;t||=0,n||=this.points.length-t;for(let o of r)a&=i(e,this,o,{start:t,end:t+n-1});return!!a}draw(e,t,n,r){let i=this.options||{};(this.points||[]).length&&i.borderWidth&&(e.save(),Wm(e,this,n,r),e.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}};function Km(e,t,n,r){let i=e.options,{[n]:a}=e.getProps([n],r);return Math.abs(t-a)<i.radius+i.hitRadius}var qm=class extends mp{static id=`point`;parsed;skip;stop;static defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:`circle`,radius:3,rotation:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};constructor(e){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,e&&Object.assign(this,e)}inRange(e,t,n){let r=this.options,{x:i,y:a}=this.getProps([`x`,`y`],n);return(e-i)**2+(t-a)**2<(r.hitRadius+r.radius)**2}inXRange(e,t){return Km(this,e,`x`,t)}inYRange(e,t){return Km(this,e,`y`,t)}getCenterPoint(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}size(e){e=e||this.options||{};let t=e.radius||0;t=Math.max(t,t&&e.hoverRadius||0);let n=t&&e.borderWidth||0;return(t+n)*2}draw(e,t){let n=this.options;this.skip||n.radius<.1||!Rl(this,t,this.size(n)/2)||(e.strokeStyle=n.borderColor,e.lineWidth=n.borderWidth,e.fillStyle=n.backgroundColor,Il(e,n,this.x,this.y))}getRange(){let e=this.options||{};return e.radius+e.hitRadius}};function Jm(e,t){let{x:n,y:r,base:i,width:a,height:o}=e.getProps([`x`,`y`,`base`,`width`,`height`],t),s,c,l,u,d;return e.horizontal?(d=o/2,s=Math.min(n,i),c=Math.max(n,i),l=r-d,u=r+d):(d=a/2,s=n-d,c=n+d,l=Math.min(r,i),u=Math.max(r,i)),{left:s,top:l,right:c,bottom:u}}function Ym(e,t,n,r){return e?0:Uc(t,n,r)}function Xm(e,t,n){let r=e.options.borderWidth,i=e.borderSkipped,a=$l(r);return{t:Ym(i.top,a.top,0,n),r:Ym(i.right,a.right,0,t),b:Ym(i.bottom,a.bottom,0,n),l:Ym(i.left,a.left,0,t)}}function Zm(e,t,n){let{enableBorderRadius:r}=e.getProps([`enableBorderRadius`]),i=e.options.borderRadius,a=eu(i),o=Math.min(t,n),s=e.borderSkipped,c=r||Y(i);return{topLeft:Ym(!c||s.top||s.left,a.topLeft,0,o),topRight:Ym(!c||s.top||s.right,a.topRight,0,o),bottomLeft:Ym(!c||s.bottom||s.left,a.bottomLeft,0,o),bottomRight:Ym(!c||s.bottom||s.right,a.bottomRight,0,o)}}function Qm(e){let t=Jm(e),n=t.right-t.left,r=t.bottom-t.top,i=Xm(e,n/2,r/2),a=Zm(e,n/2,r/2);return{outer:{x:t.left,y:t.top,w:n,h:r,radius:a},inner:{x:t.left+i.l,y:t.top+i.t,w:n-i.l-i.r,h:r-i.t-i.b,radius:{topLeft:Math.max(0,a.topLeft-Math.max(i.t,i.l)),topRight:Math.max(0,a.topRight-Math.max(i.t,i.r)),bottomLeft:Math.max(0,a.bottomLeft-Math.max(i.b,i.l)),bottomRight:Math.max(0,a.bottomRight-Math.max(i.b,i.r))}}}}function $m(e,t,n,r){let i=t===null,a=n===null,o=e&&!(i&&a)&&Jm(e,r);return o&&(i||Gc(t,o.left,o.right))&&(a||Gc(n,o.top,o.bottom))}function eh(e){return e.topLeft||e.topRight||e.bottomLeft||e.bottomRight}function th(e,t){e.rect(t.x,t.y,t.w,t.h)}function nh(e,t,n={}){let r=e.x===n.x?0:-t,i=e.y===n.y?0:-t,a=(e.x+e.w===n.x+n.w?0:t)-r,o=(e.y+e.h===n.y+n.h?0:t)-i;return{x:e.x+r,y:e.y+i,w:e.w+a,h:e.h+o,radius:e.radius}}var rh=Object.freeze({__proto__:null,ArcElement:Mm,BarElement:class extends mp{static id=`bar`;static defaults={borderSkipped:`start`,borderWidth:0,borderRadius:0,inflateAmount:`auto`,pointStyle:void 0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};constructor(e){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,e&&Object.assign(this,e)}draw(e){let{inflateAmount:t,options:{borderColor:n,backgroundColor:r}}=this,{inner:i,outer:a}=Qm(this),o=eh(a.radius)?ql:th;e.save(),(a.w!==i.w||a.h!==i.h)&&(e.beginPath(),o(e,nh(a,t,i)),e.clip(),o(e,nh(i,-t,a)),e.fillStyle=n,e.fill(`evenodd`)),e.beginPath(),o(e,nh(i,t)),e.fillStyle=r,e.fill(),e.restore()}inRange(e,t,n){return $m(this,e,t,n)}inXRange(e,t){return $m(this,e,null,t)}inYRange(e,t){return $m(this,null,e,t)}getCenterPoint(e){let{x:t,y:n,base:r,horizontal:i}=this.getProps([`x`,`y`,`base`,`horizontal`],e);return{x:i?(t+r)/2:t,y:i?n:(n+r)/2}}getRange(e){return e===`x`?this.width/2:this.height/2}},LineElement:Gm,PointElement:qm}),ih=[`rgb(54, 162, 235)`,`rgb(255, 99, 132)`,`rgb(255, 159, 64)`,`rgb(255, 205, 86)`,`rgb(75, 192, 192)`,`rgb(153, 102, 255)`,`rgb(201, 203, 207)`],ah=ih.map(e=>e.replace(`rgb(`,`rgba(`).replace(`)`,`, 0.5)`));function oh(e){return ih[e%ih.length]}function sh(e){return ah[e%ah.length]}function ch(e,t){return e.borderColor=oh(t),e.backgroundColor=sh(t),++t}function lh(e,t){return e.backgroundColor=e.data.map(()=>oh(t++)),t}function uh(e,t){return e.backgroundColor=e.data.map(()=>sh(t++)),t}function dh(e){let t=0;return(n,r)=>{let i=e.getDatasetMeta(r).controller;i instanceof pf?t=lh(n,t):i instanceof hf?t=uh(n,t):i&&(t=ch(n,t))}}function fh(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function ph(e){return e&&(e.borderColor||e.backgroundColor)}function mh(){return Al.borderColor!==`rgba(0,0,0,0.1)`||Al.backgroundColor!==`rgba(0,0,0,0.1)`}var hh={id:`colors`,defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;let{data:{datasets:r},options:i}=e.config,{elements:a}=i,o=fh(r)||ph(i)||a&&fh(a)||mh();if(!n.forceOverride&&o)return;let s=dh(e);r.forEach(s)}};function gh(e,t,n,r,i){let a=i.samples||r;if(a>=n)return e.slice(t,t+n);let o=[],s=(n-2)/(a-2),c=0,l=t+n-1,u=t,d,f,p,m,h;for(o[c++]=e[u],d=0;d<a-2;d++){let r=0,i=0,a,l=Math.floor((d+1)*s)+1+t,g=Math.min(Math.floor((d+2)*s)+1,n)+t,_=g-l;for(a=l;a<g;a++)r+=e[a].x,i+=e[a].y;r/=_,i/=_;let v=Math.floor(d*s)+1+t,y=Math.min(Math.floor((d+1)*s)+1,n)+t,{x:b,y:x}=e[u];for(p=m=-1,a=v;a<y;a++)m=.5*Math.abs((b-r)*(e[a].y-x)-(b-e[a].x)*(i-x)),m>p&&(p=m,f=e[a],h=a);o[c++]=f,u=h}return o[c++]=e[l],o}function _h(e,t,n,r){let i=0,a=0,o,s,c,l,u,d,f,p,m,h,g=[],_=t+n-1,v=e[t].x,y=e[_].x-v;for(o=t;o<t+n;++o){s=e[o],c=(s.x-v)/y*r,l=s.y;let t=c|0;if(t===u)l<m?(m=l,d=o):l>h&&(h=l,f=o),i=(a*i+s.x)/++a;else{let n=o-1;if(!J(d)&&!J(f)){let t=Math.min(d,f),r=Math.max(d,f);t!==p&&t!==n&&g.push({...e[t],x:i}),r!==p&&r!==n&&g.push({...e[r],x:i})}o>0&&n!==p&&g.push(e[n]),g.push(s),u=t,a=0,m=h=l,d=f=p=o}}return g}function vh(e){if(e._decimated){let t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function yh(e){e.data.datasets.forEach(e=>{vh(e)})}function bh(e,t){let n=t.length,r=0,i,{iScale:a}=e,{min:o,max:s,minDefined:c,maxDefined:l}=a.getUserBounds();return c&&(r=Uc(qc(t,a.axis,o).lo,0,n-1)),i=l?Uc(qc(t,a.axis,s).hi+1,r,n)-r:n-r,{start:r,count:i}}var xh={id:`decimation`,defaults:{algorithm:`min-max`,enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){yh(e);return}let r=e.width;e.data.datasets.forEach((t,i)=>{let{_data:a,indexAxis:o}=t,s=e.getDatasetMeta(i),c=a||t.data;if(ru([o,e.options.indexAxis])===`y`||!s.controller.supportsDecimation)return;let l=e.scales[s.xAxisID];if(l.type!==`linear`&&l.type!==`time`||e.options.parsing)return;let{start:u,count:d}=bh(s,c);if(d<=(n.threshold||4*r)){vh(t);return}J(a)&&(t._data=c,delete t.data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(e){this._data=e}}));let f;switch(n.algorithm){case`lttb`:f=gh(c,u,d,r,n);break;case`min-max`:f=_h(c,u,d,r);break;default:throw Error(`Unsupported decimation algorithm '${n.algorithm}'`)}t._decimated=f})},destroy(e){yh(e)}};function Sh(e,t,n){let r=e.segments,i=e.points,a=t.points,o=[];for(let e of r){let{start:r,end:s}=e;s=Th(r,s,i);let c=Ch(n,i[r],i[s],e.loop);if(!t.segments){o.push({source:e,target:c,start:i[r],end:i[s]});continue}let l=ud(t,c);for(let t of l){let r=Ch(n,a[t.start],a[t.end],t.loop),s=ld(e,i,r);for(let e of s)o.push({source:e,target:t,start:{[n]:Eh(c,r,`start`,Math.max)},end:{[n]:Eh(c,r,`end`,Math.min)}})}}return o}function Ch(e,t,n,r){if(r)return;let i=t[e],a=n[e];return e===`angle`&&(i=Vc(i),a=Vc(a)),{property:e,start:i,end:a}}function wh(e,t){let{x:n=null,y:r=null}=e||{},i=t.points,a=[];return t.segments.forEach(({start:e,end:t})=>{t=Th(e,t,i);let o=i[e],s=i[t];r===null?n!==null&&(a.push({x:n,y:o.y}),a.push({x:n,y:s.y})):(a.push({x:o.x,y:r}),a.push({x:s.x,y:r}))}),a}function Th(e,t,n){for(;t>e;t--){let e=n[t];if(!isNaN(e.x)&&!isNaN(e.y))break}return t}function Eh(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function Dh(e,t){let n=[],r=!1;return Qs(e)?(r=!0,n=e):n=wh(e,t),n.length?new Gm({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function Oh(e){return e&&e.fill!==!1}function kh(e,t,n){let r=e[t].fill,i=[t],a;if(!n)return r;for(;r!==!1&&i.indexOf(r)===-1;){if(!$s(r))return r;if(a=e[r],!a)return!1;if(a.visible)return r;i.push(r),r=a.fill}return!1}function Ah(e,t,n){let r=Ph(e);if(Y(r))return!isNaN(r.value)&&r;let i=parseFloat(r);return $s(i)&&Math.floor(i)===i?jh(r[0],t,i,n):[`origin`,`start`,`end`,`stack`,`shape`].indexOf(r)>=0&&r}function jh(e,t,n,r){return(e===`-`||e===`+`)&&(n=t+n),n===t||n<0||n>=r?!1:n}function Mh(e,t){let n=null;return e===`start`?n=t.bottom:e===`end`?n=t.top:Y(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function Nh(e,t,n){let r;return r=e===`start`?n:e===`end`?t.options.reverse?t.min:t.max:Y(e)?e.value:t.getBaseValue(),r}function Ph(e){let t=e.options,n=t.fill,r=X(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?`origin`:r}function Fh(e){let{scale:t,index:n,line:r}=e,i=[],a=r.segments,o=r.points,s=Ih(t,n);s.push(Dh({x:null,y:t.bottom},r));for(let e=0;e<a.length;e++){let t=a[e];for(let e=t.start;e<=t.end;e++)Lh(i,o[e],s)}return new Gm({points:i,options:{}})}function Ih(e,t){let n=[],r=e.getMatchingVisibleMetas(`line`);for(let e=0;e<r.length;e++){let i=r[e];if(i.index===t)break;i.hidden||n.unshift(i.dataset)}return n}function Lh(e,t,n){let r=[];for(let i=0;i<n.length;i++){let a=n[i],{first:o,last:s,point:c}=Rh(a,t,`x`);if(!(!c||o&&s)){if(o)r.unshift(c);else if(e.push(c),!s)break}}e.push(...r)}function Rh(e,t,n){let r=e.interpolate(t,n);if(!r)return{};let i=r[n],a=e.segments,o=e.points,s=!1,c=!1;for(let e=0;e<a.length;e++){let t=a[e],r=o[t.start][n],l=o[t.end][n];if(Gc(i,r,l)){s=i===r,c=i===l;break}}return{first:s,last:c,point:r}}var zh=class{constructor(e){this.x=e.x,this.y=e.y,this.radius=e.radius}pathSegment(e,t,n){let{x:r,y:i,radius:a}=this;return t||={start:0,end:yc},e.arc(r,i,a,t.end,t.start,!0),!n.bounds}interpolate(e){let{x:t,y:n,radius:r}=this,i=e.angle;return{x:t+Math.cos(i)*r,y:n+Math.sin(i)*r,angle:i}}};function Bh(e){let{chart:t,fill:n,line:r}=e;if($s(n))return Vh(t,n);if(n===`stack`)return Fh(e);if(n===`shape`)return!0;let i=Hh(e);return i instanceof zh?i:Dh(i,r)}function Vh(e,t){let n=e.getDatasetMeta(t);return n&&e.isDatasetVisible(t)?n.dataset:null}function Hh(e){return(e.scale||{}).getPointPositionForValue?Wh(e):Uh(e)}function Uh(e){let{scale:t={},fill:n}=e,r=Mh(n,t);if($s(r)){let e=t.isHorizontal();return{x:e?r:null,y:e?null:r}}return null}function Wh(e){let{scale:t,fill:n}=e,r=t.options,i=t.getLabels().length,a=r.reverse?t.max:t.min,o=Nh(n,t,a),s=[];if(r.grid.circular){let e=t.getPointPositionForValue(0,a);return new zh({x:e.x,y:e.y,radius:t.getDistanceFromCenterForValue(o)})}for(let e=0;e<i;++e)s.push(t.getPointPositionForValue(e,o));return s}function Gh(e,t,n){let r=Bh(t),{chart:i,index:a,line:o,scale:s,axis:c}=t,l=o.options,u=l.fill,d=l.backgroundColor,{above:f=d,below:p=d}=u||{},m=bd(i,i.getDatasetMeta(a));r&&o.points.length&&(zl(e,n),Kh(e,{line:o,target:r,above:f,below:p,area:n,scale:s,axis:c,clip:m}),Bl(e))}function Kh(e,t){let{line:n,target:r,above:i,below:a,area:o,scale:s,clip:c}=t,l=n._loop?`angle`:t.axis;e.save();let u=a;a!==i&&(l===`x`?(qh(e,r,o.top),Yh(e,{line:n,target:r,color:i,scale:s,property:l,clip:c}),e.restore(),e.save(),qh(e,r,o.bottom)):l===`y`&&(Jh(e,r,o.left),Yh(e,{line:n,target:r,color:a,scale:s,property:l,clip:c}),e.restore(),e.save(),Jh(e,r,o.right),u=i)),Yh(e,{line:n,target:r,color:u,scale:s,property:l,clip:c}),e.restore()}function qh(e,t,n){let{segments:r,points:i}=t,a=!0,o=!1;e.beginPath();for(let s of r){let{start:r,end:c}=s,l=i[r],u=i[Th(r,c,i)];a?(e.moveTo(l.x,l.y),a=!1):(e.lineTo(l.x,n),e.lineTo(l.x,l.y)),o=!!t.pathSegment(e,s,{move:o}),o?e.closePath():e.lineTo(u.x,n)}e.lineTo(t.first().x,n),e.closePath(),e.clip()}function Jh(e,t,n){let{segments:r,points:i}=t,a=!0,o=!1;e.beginPath();for(let s of r){let{start:r,end:c}=s,l=i[r],u=i[Th(r,c,i)];a?(e.moveTo(l.x,l.y),a=!1):(e.lineTo(n,l.y),e.lineTo(l.x,l.y)),o=!!t.pathSegment(e,s,{move:o}),o?e.closePath():e.lineTo(n,u.y)}e.lineTo(n,t.first().y),e.closePath(),e.clip()}function Yh(e,t){let{line:n,target:r,property:i,color:a,scale:o,clip:s}=t,c=Sh(n,r,i);for(let{source:t,target:l,start:u,end:d}of c){let{style:{backgroundColor:c=a}={}}=t,f=r!==!0;e.save(),e.fillStyle=c,Xh(e,o,s,f&&Ch(i,u,d)),e.beginPath();let p=!!n.pathSegment(e,t),m;if(f){p?e.closePath():Zh(e,r,d,i);let t=!!r.pathSegment(e,l,{move:p,reverse:!0});m=p&&t,m||Zh(e,r,u,i)}e.closePath(),e.fill(m?`evenodd`:`nonzero`),e.restore()}}function Xh(e,t,n,r){let i=t.chart.chartArea,{property:a,start:o,end:s}=r||{};if(a===`x`||a===`y`){let t,r,c,l;a===`x`?(t=o,r=i.top,c=s,l=i.bottom):(t=i.left,r=o,c=i.right,l=s),e.beginPath(),n&&(t=Math.max(t,n.left),c=Math.min(c,n.right),r=Math.max(r,n.top),l=Math.min(l,n.bottom)),e.rect(t,r,c-t,l-r),e.clip()}}function Zh(e,t,n,r){let i=t.interpolate(n,r);i&&e.lineTo(i.x,i.y)}var Qh={id:`filler`,afterDatasetsUpdate(e,t,n){let r=(e.data.datasets||[]).length,i=[],a,o,s,c;for(o=0;o<r;++o)a=e.getDatasetMeta(o),s=a.dataset,c=null,s&&s.options&&s instanceof Gm&&(c={visible:e.isDatasetVisible(o),index:o,fill:Ah(s,o,r),chart:e,axis:a.controller.options.indexAxis,scale:a.vScale,line:s}),a.$filler=c,i.push(c);for(o=0;o<r;++o)c=i[o],!(!c||c.fill===!1)&&(c.fill=kh(i,o,n.propagate))},beforeDraw(e,t,n){let r=n.drawTime===`beforeDraw`,i=e.getSortedVisibleDatasetMetas(),a=e.chartArea;for(let t=i.length-1;t>=0;--t){let n=i[t].$filler;n&&(n.line.updateControlPoints(a,n.axis),r&&n.fill&&Gh(e.ctx,n,a))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!==`beforeDatasetsDraw`)return;let r=e.getSortedVisibleDatasetMetas();for(let t=r.length-1;t>=0;--t){let n=r[t].$filler;Oh(n)&&Gh(e.ctx,n,e.chartArea)}},beforeDatasetDraw(e,t,n){let r=t.meta.$filler;!Oh(r)||n.drawTime!==`beforeDatasetDraw`||Gh(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:`beforeDatasetDraw`}},$h=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},eg=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index,tg=class extends mp{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.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(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,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(){let e=this.options.labels||{},t=Z(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(t=>e.filter(t,this.chart.data))),e.sort&&(t=t.sort((t,n)=>e.sort(t,n,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){let{options:e,ctx:t}=this;if(!e.display){this.width=this.height=0;return}let n=e.labels,r=nu(n.font),i=r.size,a=this._computeTitleHeight(),{boxWidth:o,itemHeight:s}=$h(n,i),c,l;t.font=r.string,this.isHorizontal()?(c=this.maxWidth,l=this._fitRows(a,i,o,s)+10):(l=this.maxHeight,c=this._fitCols(a,r,o,s)+10),this.width=Math.min(c,e.maxWidth||this.maxWidth),this.height=Math.min(l,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,r){let{ctx:i,maxWidth:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.lineWidths=[0],l=r+o,u=e;i.textAlign=`left`,i.textBaseline=`middle`;let d=-1,f=-l;return this.legendItems.forEach((e,p)=>{let m=n+t/2+i.measureText(e.text).width;(p===0||c[c.length-1]+m+2*o>a)&&(u+=l,c[c.length-(p>0?0:1)]=0,f+=l,d++),s[p]={left:0,top:f,row:d,width:m,height:r},c[c.length-1]+=m+o}),u}_fitCols(e,t,n,r){let{ctx:i,maxHeight:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.columnSizes=[],l=a-e,u=o,d=0,f=0,p=0,m=0;return this.legendItems.forEach((e,a)=>{let{itemWidth:h,itemHeight:g}=ng(n,t,i,e,r);a>0&&f+g+2*o>l&&(u+=d+o,c.push({width:d,height:f}),p+=d+o,m++,d=f=0),s[a]={left:p,top:f,col:m,width:h,height:g},d=Math.max(d,h),f+=g+o}),u+=d,c.push({width:d,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;let e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:r},rtl:i}}=this,a=rd(i,this.left,this.width);if(this.isHorizontal()){let i=0,o=il(n,this.left+r,this.right-this.lineWidths[i]);for(let s of t)i!==s.row&&(i=s.row,o=il(n,this.left+r,this.right-this.lineWidths[i])),s.top+=this.top+e+r,s.left=a.leftForLtr(a.x(o),s.width),o+=s.width+r}else{let i=0,o=il(n,this.top+e+r,this.bottom-this.columnSizes[i].height);for(let s of t)s.col!==i&&(i=s.col,o=il(n,this.top+e+r,this.bottom-this.columnSizes[i].height)),s.top=o,s.left+=this.left+r,s.left=a.leftForLtr(a.x(s.left),s.width),o+=s.height+r}}isHorizontal(){return this.options.position===`top`||this.options.position===`bottom`}draw(){if(this.options.display){let e=this.ctx;zl(e,this),this._draw(),Bl(e)}}_draw(){let{options:e,columnSizes:t,lineWidths:n,ctx:r}=this,{align:i,labels:a}=e,o=Al.color,s=rd(e.rtl,this.left,this.width),c=nu(a.font),{padding:l}=a,u=c.size,d=u/2,f;this.drawTitle(),r.textAlign=s.textAlign(`left`),r.textBaseline=`middle`,r.lineWidth=.5,r.font=c.string;let{boxWidth:p,boxHeight:m,itemHeight:h}=$h(a,u),g=function(e,t,n){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;r.save();let i=X(n.lineWidth,1);if(r.fillStyle=X(n.fillStyle,o),r.lineCap=X(n.lineCap,`butt`),r.lineDashOffset=X(n.lineDashOffset,0),r.lineJoin=X(n.lineJoin,`miter`),r.lineWidth=i,r.strokeStyle=X(n.strokeStyle,o),r.setLineDash(X(n.lineDash,[])),a.usePointStyle){let o={radius:m*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:i},c=s.xPlus(e,p/2),l=t+d;Ll(r,o,c,l,a.pointStyleWidth&&p)}else{let a=t+Math.max((u-m)/2,0),o=s.leftForLtr(e,p),c=eu(n.borderRadius);r.beginPath(),Object.values(c).some(e=>e!==0)?ql(r,{x:o,y:a,w:p,h:m,radius:c}):r.rect(o,a,p,m),r.fill(),i!==0&&r.stroke()}r.restore()},_=function(e,t,n){Kl(r,n.text,e,t+h/2,c,{strikethrough:n.hidden,textAlign:s.textAlign(n.textAlign)})},v=this.isHorizontal(),y=this._computeTitleHeight();f=v?{x:il(i,this.left+l,this.right-n[0]),y:this.top+l+y,line:0}:{x:this.left+l,y:il(i,this.top+y+l,this.bottom-t[0].height),line:0},id(this.ctx,e.textDirection);let b=h+l;this.legendItems.forEach((o,u)=>{r.strokeStyle=o.fontColor,r.fillStyle=o.fontColor;let m=r.measureText(o.text).width,h=s.textAlign(o.textAlign||=a.textAlign),x=p+d+m,S=f.x,C=f.y;s.setWidth(this.width),v?u>0&&S+x+l>this.right&&(C=f.y+=b,f.line++,S=f.x=il(i,this.left+l,this.right-n[f.line])):u>0&&C+b>this.bottom&&(S=f.x=S+t[f.line].width+l,f.line++,C=f.y=il(i,this.top+y+l,this.bottom-t[f.line].height));let w=s.x(S);if(g(w,C,o),S=al(h,S+p+d,v?S+x:this.right,e.rtl),_(s.x(S),C,o),v)f.x+=x+l;else if(typeof o.text!=`string`){let e=c.lineHeight;f.y+=ag(o,e)+l}else f.y+=b}),ad(this.ctx,e.textDirection)}drawTitle(){let e=this.options,t=e.title,n=nu(t.font),r=tu(t.padding);if(!t.display)return;let i=rd(e.rtl,this.left,this.width),a=this.ctx,o=t.position,s=n.size/2,c=r.top+s,l,u=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),l=this.top+c,u=il(e.align,u,this.right-d);else{let t=this.columnSizes.reduce((e,t)=>Math.max(e,t.height),0);l=c+il(e.align,this.top,this.bottom-t-e.labels.padding-this._computeTitleHeight())}let f=il(o,u,u+d);a.textAlign=i.textAlign(rl(o)),a.textBaseline=`middle`,a.strokeStyle=t.color,a.fillStyle=t.color,a.font=n.string,Kl(a,t.text,f,l,n)}_computeTitleHeight(){let e=this.options.title,t=nu(e.font),n=tu(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,r,i;if(Gc(e,this.left,this.right)&&Gc(t,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;n<i.length;++n)if(r=i[n],Gc(e,r.left,r.left+r.width)&&Gc(t,r.top,r.top+r.height))return this.legendItems[n]}return null}handleEvent(e){let t=this.options;if(!og(e.type,t))return;let n=this._getLegendItemAt(e.x,e.y);if(e.type===`mousemove`||e.type===`mouseout`){let r=this._hoveredItem,i=eg(r,n);r&&!i&&Z(t.onLeave,[e,r,this],this),this._hoveredItem=n,n&&!i&&Z(t.onHover,[e,n,this],this)}else n&&Z(t.onClick,[e,n,this],this)}};function ng(e,t,n,r,i){return{itemWidth:rg(r,e,t,n),itemHeight:ig(i,r,t.lineHeight)}}function rg(e,t,n,r){let i=e.text;return i&&typeof i!=`string`&&(i=i.reduce((e,t)=>e.length>t.length?e:t)),t+n.size/2+r.measureText(i).width}function ig(e,t,n){let r=e;return typeof t.text!=`string`&&(r=ag(t,n)),r}function ag(e,t){return t*(e.text?e.text.length:0)}function og(e,t){return!!((e===`mousemove`||e===`mouseout`)&&(t.onHover||t.onLeave)||t.onClick&&(e===`click`||e===`mouseup`))}var sg={id:`legend`,_element:tg,start(e,t,n){let r=e.legend=new tg({ctx:e.ctx,options:n,chart:e});Wf.configure(e,r,n),Wf.addBox(e,r)},stop(e){Wf.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){let r=e.legend;Wf.configure(e,r,n),r.options=n},afterUpdate(e){let t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:`top`,align:`center`,fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){let r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){let t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:a,useBorderRadius:o,borderRadius:s}}=e.legend.options;return e._getSortedDatasetMetas().map(e=>{let c=e.controller.getStyle(n?0:void 0),l=tu(c.borderWidth);return{text:t[e.index].label,fillStyle:c.backgroundColor,fontColor:a,hidden:!e.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(l.width+l.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:o&&(s||c.borderRadius),datasetIndex:e.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:`center`,text:``}},descriptors:{_scriptable:e=>!e.startsWith(`on`),labels:{_scriptable:e=>![`generateLabels`,`filter`,`sort`].includes(e)}}},cg=class extends mp{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.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(e,t){let n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=t;let r=Qs(n.text)?n.text.length:1;this._padding=tu(n.padding);let i=r*nu(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=i:this.width=i}isHorizontal(){let e=this.options.position;return e===`top`||e===`bottom`}_drawArgs(e){let{top:t,left:n,bottom:r,right:i,options:a}=this,o=a.align,s=0,c,l,u;return this.isHorizontal()?(l=il(o,n,i),u=t+e,c=i-n):(a.position===`left`?(l=n+e,u=il(o,r,t),s=$*-.5):(l=i-e,u=il(o,t,r),s=$*.5),c=r-t),{titleX:l,titleY:u,maxWidth:c,rotation:s}}draw(){let e=this.ctx,t=this.options;if(!t.display)return;let n=nu(t.font),r=n.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:o,rotation:s}=this._drawArgs(r);Kl(e,t.text,0,0,n,{color:t.color,maxWidth:o,rotation:s,textAlign:rl(t.align),textBaseline:`middle`,translation:[i,a]})}};function lg(e,t){let n=new cg({ctx:e.ctx,options:t,chart:e});Wf.configure(e,n,t),Wf.addBox(e,n),e.titleBlock=n}var ug={id:`title`,_element:cg,start(e,t,n){lg(e,n)},stop(e){let t=e.titleBlock;Wf.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){let r=e.titleBlock;Wf.configure(e,r,n),r.options=n},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}},dg=new WeakMap,fg={id:`subtitle`,start(e,t,n){let r=new cg({ctx:e.ctx,options:n,chart:e});Wf.configure(e,r,n),Wf.addBox(e,r),dg.set(e,r)},stop(e){Wf.removeBox(e,dg.get(e)),dg.delete(e)},beforeUpdate(e,t,n){let r=dg.get(e);Wf.configure(e,r,n),r.options=n},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}},pg={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,a=0;for(t=0,n=e.length;t<n;++t){let n=e[t].element;if(n&&n.hasValue()){let e=n.tooltipPosition();r.add(e.x),i+=e.y,++a}}return a===0||r.size===0?!1:{x:[...r].reduce((e,t)=>e+t)/r.size,y:i/a}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=1/0,a,o,s;for(a=0,o=e.length;a<o;++a){let n=e[a].element;if(n&&n.hasValue()){let e=zc(t,n.getCenterPoint());e<i&&(i=e,s=n)}}if(s){let e=s.tooltipPosition();n=e.x,r=e.y}return{x:n,y:r}}};function mg(e,t){return t&&(Qs(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function hg(e){return(typeof e==`string`||e instanceof String)&&e.indexOf(`
35
35
  `)>-1?e.split(`
36
- `):e}function lg(e,t){let{element:n,datasetIndex:r,index:i}=t,a=e.getDatasetMeta(r).controller,{label:o,value:s}=a.getLabelAndValue(i);return{chart:e,label:o,parsed:a.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:s,dataset:a.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function ug(e,t){let n=e.chart.ctx,{body:r,footer:i,title:a}=e,{boxWidth:o,boxHeight:s}=t,c=Yl(t.bodyFont),l=Yl(t.titleFont),u=Yl(t.footerFont),d=a.length,f=i.length,p=r.length,m=Jl(t.padding),h=m.height,g=0,_=r.reduce((e,t)=>e+t.before.length+t.lines.length+t.after.length,0);if(_+=e.beforeBody.length+e.afterBody.length,d&&(h+=d*l.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),_){let e=t.displayColors?Math.max(s,c.lineHeight):c.lineHeight;h+=p*e+(_-p)*c.lineHeight+(_-1)*t.bodySpacing}f&&(h+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let v=0,y=function(e){g=Math.max(g,n.measureText(e).width+v)};return n.save(),n.font=l.string,Q(e.title,y),n.font=c.string,Q(e.beforeBody.concat(e.afterBody),y),v=t.displayColors?o+2+t.boxPadding:0,Q(r,e=>{Q(e.before,y),Q(e.lines,y),Q(e.after,y)}),v=0,n.font=u.string,Q(e.footer,y),n.restore(),g+=m.width,{width:g,height:h}}function dg(e,t){let{y:n,height:r}=t;return n<r/2?`top`:n>e.height-r/2?`bottom`:`center`}function fg(e,t,n,r){let{x:i,width:a}=r,o=n.caretSize+n.caretPadding;if(e===`left`&&i+a+o>t.width||e===`right`&&i-a-o<0)return!0}function pg(e,t,n,r){let{x:i,width:a}=n,{width:o,chartArea:{left:s,right:c}}=e,l=`center`;return r===`center`?l=i<=(s+c)/2?`left`:`right`:i<=a/2?l=`left`:i>=o-a/2&&(l=`right`),fg(l,e,t,n)&&(l=`center`),l}function mg(e,t,n){let r=n.yAlign||t.yAlign||dg(e,n);return{xAlign:n.xAlign||t.xAlign||pg(e,t,n,r),yAlign:r}}function hg(e,t){let{x:n,width:r}=e;return t===`right`?n-=r:t===`center`&&(n-=r/2),n}function gg(e,t,n){let{y:r,height:i}=e;return t===`top`?r+=n:r-=t===`bottom`?i+n:i/2,r}function _g(e,t,n,r){let{caretSize:i,caretPadding:a,cornerRadius:o}=e,{xAlign:s,yAlign:c}=n,l=i+a,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=ql(o),m=hg(t,s),h=gg(t,c,l);return c===`center`?s===`left`?m+=l:s===`right`&&(m-=l):s===`left`?m-=Math.max(u,f)+i:s===`right`&&(m+=Math.max(d,p)+i),{x:Ic(m,0,r.width-t.width),y:Ic(h,0,r.height-t.height)}}function vg(e,t,n){let r=Jl(n.padding);return t===`center`?e.x+e.width/2:t===`right`?e.x+e.width-r.right:e.x+r.left}function yg(e){return sg([],cg(e))}function bg(e,t,n){return Ql(e,{tooltip:t,tooltipItems:n,type:`tooltip`})}function xg(e,t){let n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}var Sg={beforeTitle:Us,title(e){if(e.length>0){let t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode===`dataset`)return t.dataset.label||``;if(t.label)return t.label;if(r>0&&t.dataIndex<r)return n[t.dataIndex]}return``},afterTitle:Us,beforeBody:Us,beforeLabel:Us,label(e){if(this&&this.options&&this.options.mode===`dataset`)return e.label+`: `+e.formattedValue||e.formattedValue;let t=e.dataset.label||``;t&&(t+=`: `);let n=e.formattedValue;return J(n)||(t+=n),t},labelColor(e){let t=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.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(e){let t=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:t.pointStyle,rotation:t.rotation}},afterLabel:Us,afterBody:Us,beforeFooter:Us,footer:Us,afterFooter:Us};function Cg(e,t,n,r){let i=e[t].call(n,r);return i===void 0?Sg[t].call(n,r):i}var wg=class extends sp{static positioners=og;constructor(e){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=e.chart,this.options=e.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(e){this.options=e,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){let e=this._cachedAnimations;if(e)return e;let t=this.chart,n=this.options.setContext(this.getContext()),r=n.enabled&&t.options.animation&&n.animations,i=new vd(this.chart,r);return r._cacheable&&(this._cachedAnimations=Object.freeze(i)),i}getContext(){return this.$context||=bg(this.chart.getContext(),this,this._tooltipItems)}getTitle(e,t){let{callbacks:n}=t,r=Cg(n,`beforeTitle`,this,e),i=Cg(n,`title`,this,e),a=Cg(n,`afterTitle`,this,e),o=[];return o=sg(o,cg(r)),o=sg(o,cg(i)),o=sg(o,cg(a)),o}getBeforeBody(e,t){return yg(Cg(t.callbacks,`beforeBody`,this,e))}getBody(e,t){let{callbacks:n}=t,r=[];return Q(e,e=>{let t={before:[],lines:[],after:[]},i=xg(n,e);sg(t.before,cg(Cg(i,`beforeLabel`,this,e))),sg(t.lines,Cg(i,`label`,this,e)),sg(t.after,cg(Cg(i,`afterLabel`,this,e))),r.push(t)}),r}getAfterBody(e,t){return yg(Cg(t.callbacks,`afterBody`,this,e))}getFooter(e,t){let{callbacks:n}=t,r=Cg(n,`beforeFooter`,this,e),i=Cg(n,`footer`,this,e),a=Cg(n,`afterFooter`,this,e),o=[];return o=sg(o,cg(r)),o=sg(o,cg(i)),o=sg(o,cg(a)),o}_createItems(e){let t=this._active,n=this.chart.data,r=[],i=[],a=[],o=[],s,c;for(s=0,c=t.length;s<c;++s)o.push(lg(this.chart,t[s]));return e.filter&&(o=o.filter((t,r,i)=>e.filter(t,r,i,n))),e.itemSort&&(o=o.sort((t,r)=>e.itemSort(t,r,n))),Q(o,t=>{let n=xg(e.callbacks,t);r.push(Cg(n,`labelColor`,this,t)),i.push(Cg(n,`labelPointStyle`,this,t)),a.push(Cg(n,`labelTextColor`,this,t))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=a,this.dataPoints=o,o}update(e,t){let n=this.options.setContext(this.getContext()),r=this._active,i,a=[];if(!r.length)this.opacity!==0&&(i={opacity:0});else{let e=og[n.position].call(this,r,this._eventPosition);a=this._createItems(n),this.title=this.getTitle(a,n),this.beforeBody=this.getBeforeBody(a,n),this.body=this.getBody(a,n),this.afterBody=this.getAfterBody(a,n),this.footer=this.getFooter(a,n);let t=this._size=ug(this,n),o=Object.assign({},e,t),s=mg(this.chart,n,o),c=_g(n,o,s,this.chart);this.xAlign=s.xAlign,this.yAlign=s.yAlign,i={opacity:1,x:c.x,y:c.y,width:t.width,height:t.height,caretX:e.x,caretY:e.y}}this._tooltipItems=a,this.$context=void 0,i&&this._resolveAnimations().update(this,i),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:t})}drawCaret(e,t,n,r){let i=this.getCaretPosition(e,n,r);t.lineTo(i.x1,i.y1),t.lineTo(i.x2,i.y2),t.lineTo(i.x3,i.y3)}getCaretPosition(e,t,n){let{xAlign:r,yAlign:i}=this,{caretSize:a,cornerRadius:o}=n,{topLeft:s,topRight:c,bottomLeft:l,bottomRight:u}=ql(o),{x:d,y:f}=e,{width:p,height:m}=t,h,g,_,v,y,b;return i===`center`?(y=f+m/2,r===`left`?(h=d,g=h-a,v=y+a,b=y-a):(h=d+p,g=h+a,v=y-a,b=y+a),_=h):(g=r===`left`?d+Math.max(s,l)+a:r===`right`?d+p-Math.max(c,u)-a:this.caretX,i===`top`?(v=f,y=v-a,h=g-a,_=g+a):(v=f+m,y=v+a,h=g+a,_=g-a),b=v),{x1:h,x2:g,x3:_,y1:v,y2:y,y3:b}}drawTitle(e,t,n){let r=this.title,i=r.length,a,o,s;if(i){let c=Xu(n.rtl,this.x,this.width);for(e.x=vg(this,n.titleAlign,n),t.textAlign=c.textAlign(n.titleAlign),t.textBaseline=`middle`,a=Yl(n.titleFont),o=n.titleSpacing,t.fillStyle=n.titleColor,t.font=a.string,s=0;s<i;++s)t.fillText(r[s],c.x(e.x),e.y+a.lineHeight/2),e.y+=a.lineHeight+o,s+1===i&&(e.y+=n.titleMarginBottom-o)}}_drawColorBox(e,t,n,r,i){let a=this.labelColors[n],o=this.labelPointStyles[n],{boxHeight:s,boxWidth:c}=i,l=Yl(i.bodyFont),u=vg(this,`left`,i),d=r.x(u),f=s<l.lineHeight?(l.lineHeight-s)/2:0,p=t.y+f;if(i.usePointStyle){let t={radius:Math.min(c,s)/2,pointStyle:o.pointStyle,rotation:o.rotation,borderWidth:1},n=r.leftForLtr(d,c)+c/2,l=p+s/2;e.strokeStyle=i.multiKeyBackground,e.fillStyle=i.multiKeyBackground,kl(e,t,n,l),e.strokeStyle=a.borderColor,e.fillStyle=a.backgroundColor,kl(e,t,n,l)}else{e.lineWidth=Y(a.borderWidth)?Math.max(...Object.values(a.borderWidth)):a.borderWidth||1,e.strokeStyle=a.borderColor,e.setLineDash(a.borderDash||[]),e.lineDashOffset=a.borderDashOffset||0;let t=r.leftForLtr(d,c),n=r.leftForLtr(r.xPlus(d,1),c-2),o=ql(a.borderRadius);Object.values(o).some(e=>e!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,Bl(e,{x:t,y:p,w:c,h:s,radius:o}),e.fill(),e.stroke(),e.fillStyle=a.backgroundColor,e.beginPath(),Bl(e,{x:n,y:p+1,w:c-2,h:s-2,radius:o}),e.fill()):(e.fillStyle=i.multiKeyBackground,e.fillRect(t,p,c,s),e.strokeRect(t,p,c,s),e.fillStyle=a.backgroundColor,e.fillRect(n,p+1,c-2,s-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,t,n){let{body:r}=this,{bodySpacing:i,bodyAlign:a,displayColors:o,boxHeight:s,boxWidth:c,boxPadding:l}=n,u=Yl(n.bodyFont),d=u.lineHeight,f=0,p=Xu(n.rtl,this.x,this.width),m=function(n){t.fillText(n,p.x(e.x+f),e.y+d/2),e.y+=d+i},h=p.textAlign(a),g,_,v,y,b,x,S;for(t.textAlign=a,t.textBaseline=`middle`,t.font=u.string,e.x=vg(this,h,n),t.fillStyle=n.bodyColor,Q(this.beforeBody,m),f=o&&h!==`right`?a===`center`?c/2+l:c+2+l:0,y=0,x=r.length;y<x;++y){for(g=r[y],_=this.labelTextColors[y],t.fillStyle=_,Q(g.before,m),v=g.lines,o&&v.length&&(this._drawColorBox(t,e,y,p,n),d=Math.max(u.lineHeight,s)),b=0,S=v.length;b<S;++b)m(v[b]),d=u.lineHeight;Q(g.after,m)}f=0,d=u.lineHeight,Q(this.afterBody,m),e.y-=i}drawFooter(e,t,n){let r=this.footer,i=r.length,a,o;if(i){let s=Xu(n.rtl,this.x,this.width);for(e.x=vg(this,n.footerAlign,n),e.y+=n.footerMarginTop,t.textAlign=s.textAlign(n.footerAlign),t.textBaseline=`middle`,a=Yl(n.footerFont),t.fillStyle=n.footerColor,t.font=a.string,o=0;o<i;++o)t.fillText(r[o],s.x(e.x),e.y+a.lineHeight/2),e.y+=a.lineHeight+n.footerSpacing}}drawBackground(e,t,n,r){let{xAlign:i,yAlign:a}=this,{x:o,y:s}=e,{width:c,height:l}=n,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=ql(r.cornerRadius);t.fillStyle=r.backgroundColor,t.strokeStyle=r.borderColor,t.lineWidth=r.borderWidth,t.beginPath(),t.moveTo(o+u,s),a===`top`&&this.drawCaret(e,t,n,r),t.lineTo(o+c-d,s),t.quadraticCurveTo(o+c,s,o+c,s+d),a===`center`&&i===`right`&&this.drawCaret(e,t,n,r),t.lineTo(o+c,s+l-p),t.quadraticCurveTo(o+c,s+l,o+c-p,s+l),a===`bottom`&&this.drawCaret(e,t,n,r),t.lineTo(o+f,s+l),t.quadraticCurveTo(o,s+l,o,s+l-f),a===`center`&&i===`left`&&this.drawCaret(e,t,n,r),t.lineTo(o,s+u),t.quadraticCurveTo(o,s,o+u,s),t.closePath(),t.fill(),r.borderWidth>0&&t.stroke()}_updateAnimationTarget(e){let t=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){let n=og[e.position].call(this,this._active,this._eventPosition);if(!n)return;let a=this._size=ug(this,e),o=Object.assign({},n,this._size),s=mg(t,e,o),c=_g(e,o,s,t);(r._to!==c.x||i._to!==c.y)&&(this.xAlign=s.xAlign,this.yAlign=s.yAlign,this.width=a.width,this.height=a.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(e){let t=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(t);let r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let a=Jl(t.padding),o=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;t.enabled&&o&&(e.save(),e.globalAlpha=n,this.drawBackground(i,e,r,t),Zu(e,t.textDirection),i.y+=a.top,this.drawTitle(i,e,t),this.drawBody(i,e,t),this.drawFooter(i,e,t),Qu(e,t.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,t){let n=this._active,r=e.map(({datasetIndex:e,index:t})=>{let n=this.chart.getDatasetMeta(e);if(!n)throw Error(`Cannot find a dataset at index `+e);return{datasetIndex:e,element:n.data[t],index:t}}),i=!Xs(n,r),a=this._positionChanged(r,t);(i||a)&&(this._active=r,this._eventPosition=t,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,t,n=!0){if(t&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let r=this.options,i=this._active||[],a=this._getActiveElements(e,i,t,n),o=this._positionChanged(a,e),s=t||!Xs(a,i)||o;return s&&(this._active=a,(r.enabled||r.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,t))),s}_getActiveElements(e,t,n,r){let i=this.options;if(e.type===`mouseout`)return[];if(!r)return t.filter(e=>this.chart.data.datasets[e.datasetIndex]&&this.chart.getDatasetMeta(e.datasetIndex).controller.getParsed(e.index)!==void 0);let a=this.chart.getElementsAtEventForMode(e,i.mode,i,n);return i.reverse&&a.reverse(),a}_positionChanged(e,t){let{caretX:n,caretY:r,options:i}=this,a=og[i.position].call(this,e,t);return a!==!1&&(n!==a.x||r!==a.y)}},Tg=Object.freeze({__proto__:null,Colors:ch,Decimation:mh,Filler:Gh,Legend:eg,SubTitle:ag,Title:rg,Tooltip:{id:`tooltip`,_element:wg,positioners:og,afterInit(e,t,n){n&&(e.tooltip=new wg({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){let t=e.tooltip;if(t&&t._willRender()){let n={tooltip:t};if(e.notifyPlugins(`beforeTooltipDraw`,{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins(`afterTooltipDraw`,n)}},afterEvent(e,t){if(e.tooltip){let n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.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:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.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:Sg},defaultRoutes:{bodyFont:`font`,footerFont:`font`,titleFont:`font`},descriptors:{_scriptable:e=>e!==`filter`&&e!==`itemSort`&&e!==`external`,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:`animation`}},additionalOptionScopes:[`interaction`]}}),Eg=(e,t,n,r)=>(typeof t==`string`?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Dg(e,t,n,r){let i=e.indexOf(t);return i===-1?Eg(e,t,n,r):i===e.lastIndexOf(t)?i:n}var Og=(e,t)=>e===null?null:Ic(Math.round(e),0,t);function kg(e){let t=this.getLabels();return e>=0&&e<t.length?t[e]:e}var Ag=class extends Dp{static id=`category`;static defaults={ticks:{callback:kg}};constructor(e){super(e),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(e){let t=this._addedLabels;if(t.length){let e=this.getLabels();for(let{index:n,label:r}of t)e[n]===r&&e.splice(n,1);this._addedLabels=[]}super.init(e)}parse(e,t){if(J(e))return null;let n=this.getLabels();return t=isFinite(t)&&n[t]===e?t:Dg(n,e,X(t,e),this._addedLabels),Og(t,n.length-1)}determineDataLimits(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),{min:n,max:r}=this.getMinMax(!0);this.options.bounds===`ticks`&&(e||(n=0),t||(r=this.getLabels().length-1)),this.min=n,this.max=r}buildTicks(){let e=this.min,t=this.max,n=this.options.offset,r=[],i=this.getLabels();i=e===0&&t===i.length-1?i:i.slice(e,t+1),this._valueRange=Math.max(i.length-+!n,1),this._startValue=this.min-(n?.5:0);for(let n=e;n<=t;n++)r.push({value:n});return r}getLabelForValue(e){return kg.call(this,e)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(e){return typeof e!=`number`&&(e=this.parse(e)),e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getPixelForTick(e){let t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}};function jg(e,t){let n=[],{bounds:r,step:i,min:a,max:o,precision:s,count:c,maxTicks:l,maxDigits:u,includeBounds:d}=e,f=i||1,p=l-1,{min:m,max:h}=t,g=!J(a),_=!J(o),v=!J(c),y=(h-m)/(u+1),b=Sc((h-m)/p/f)*f,x,S,C,w;if(b<1e-14&&!g&&!_)return[{value:m},{value:h}];w=Math.ceil(h/b)-Math.floor(m/b),w>p&&(b=Sc(w*b/p/f)*f),J(s)||(x=10**s,b=Math.ceil(b*x)/x),r===`ticks`?(S=Math.floor(m/b)*b,C=Math.ceil(h/b)*b):(S=m,C=h),g&&_&&i&&Ec((o-a)/i,b/1e3)?(w=Math.round(Math.min((o-a)/b,l)),b=(o-a)/w,S=a,C=o):v?(S=g?a:S,C=_?o:C,w=c-1,b=(C-S)/w):(w=(C-S)/b,w=xc(w,Math.round(w),b/1e3)?Math.round(w):Math.ceil(w));let T=Math.max(Ac(b),Ac(S));x=10**(J(s)?T:s),S=Math.round(S*x)/x,C=Math.round(C*x)/x;let E=0;for(g&&(d&&S!==a?(n.push({value:a}),S<a&&E++,xc(Math.round((S+E*b)*x)/x,a,Mg(a,y,e))&&E++):S<a&&E++);E<w;++E){let e=Math.round((S+E*b)*x)/x;if(_&&e>o)break;n.push({value:e})}return _&&d&&C!==o?n.length&&xc(n[n.length-1].value,o,Mg(o,y,e))?n[n.length-1].value=o:n.push({value:o}):(!_||C===o)&&n.push({value:C}),n}function Mg(e,t,{horizontal:n,minRotation:r}){let i=Oc(r),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(``+e).length;return Math.min(t/a,o)}var Ng=class extends Dp{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,t){return J(e)||(typeof e==`number`||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){let{beginAtZero:e}=this.options,{minDefined:t,maxDefined:n}=this.getUserBounds(),{min:r,max:i}=this,a=e=>r=t?r:e,o=e=>i=n?i:e;if(e){let e=bc(r),t=bc(i);e<0&&t<0?o(0):e>0&&t>0&&a(0)}if(r===i){let t=i===0?1:Math.abs(i*.05);o(i+t),e||a(r-t)}this.min=r,this.max=i}getTickLimit(){let{maxTicksLimit:e,stepSize:t}=this.options.ticks,n;return t?(n=Math.ceil(this.max/t)-Math.floor(this.min/t)+1,n>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${t} would result generating up to ${n} ticks. Limiting to 1000.`),n=1e3)):(n=this.computeTickLimit(),e||=11),e&&(n=Math.min(e,n)),n}computeTickLimit(){return 1/0}buildTicks(){let e=this.options,t=e.ticks,n=this.getTickLimit();n=Math.max(2,n);let r=jg({maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:t.precision,step:t.stepSize,count:t.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:t.minRotation||0,includeBounds:t.includeBounds!==!1},this._range||this);return e.bounds===`ticks`&&Dc(r,this,`value`),e.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){let e=this.ticks,t=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){let r=(n-t)/Math.max(e.length-1,1)/2;t-=r,n+=r}this._startValue=t,this._endValue=n,this._valueRange=n-t}getLabelForValue(e){return ml(e,this.chart.options.locale,this.options.ticks.format)}},Pg=class extends Ng{static id=`linear`;static defaults={ticks:{callback:_l.formatters.numeric}};determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=Ks(e)?e:0,this.max=Ks(t)?t:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),t=e?this.width:this.height,n=Oc(this.options.ticks.minRotation),r=(e?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(t/Math.min(40,i.lineHeight/r))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}},Fg=e=>Math.floor(yc(e)),Ig=(e,t)=>10**(Fg(e)+t);function Lg(e){return e/10**Fg(e)==1}function Rg(e,t,n){let r=10**n,i=Math.floor(e/r);return Math.ceil(t/r)-i}function zg(e,t){let n=Fg(t-e);for(;Rg(e,t,n)>10;)n++;for(;Rg(e,t,n)<10;)n--;return Math.min(n,Fg(e))}function Bg(e,{min:t,max:n}){t=qs(e.min,t);let r=[],i=Fg(t),a=zg(t,n),o=a<0?10**Math.abs(a):1,s=10**a,c=i>a?10**i:0,l=Math.round((t-c)*o)/o,u=Math.floor((t-c)/s/10)*s*10,d=Math.floor((l-u)/10**a),f=qs(e.min,Math.round((c+u+d*10**a)*o)/o);for(;f<n;)r.push({value:f,major:Lg(f),significand:d}),d>=10?d=d<15?15:20:d++,d>=20&&(a++,d=2,o=a>=0?1:o),f=Math.round((c+u+d*10**a)*o)/o;let p=qs(e.max,f);return r.push({value:p,major:Lg(p),significand:d}),r}var Vg=class extends Dp{static id=`logarithmic`;static defaults={ticks:{callback:_l.formatters.logarithmic,major:{enabled:!0}}};constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,t){let n=Ng.prototype.parse.apply(this,[e,t]);if(n===0){this._zero=!0;return}return Ks(n)&&n>0?n:null}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=Ks(e)?Math.max(0,e):null,this.max=Ks(t)?Math.max(0,t):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!Ks(this._userMin)&&(this.min=e===Ig(this.min,0)?Ig(this.min,-1):Ig(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),n=this.min,r=this.max,i=t=>n=e?n:t,a=e=>r=t?r:e;n===r&&(n<=0?(i(1),a(10)):(i(Ig(n,-1)),a(Ig(r,1)))),n<=0&&i(Ig(r,-1)),r<=0&&a(Ig(n,1)),this.min=n,this.max=r}buildTicks(){let e=this.options,t=Bg({min:this._userMin,max:this._userMax},this);return e.bounds===`ticks`&&Dc(t,this,`value`),e.reverse?(t.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),t}getLabelForValue(e){return e===void 0?`0`:ml(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=yc(e),this._valueRange=yc(this.max)-yc(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(yc(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let t=this.getDecimalForPixel(e);return 10**(this._startValue+t*this._valueRange)}};function Hg(e){let t=e.ticks;if(t.display&&e.display){let e=Jl(t.backdropPadding);return X(t.font&&t.font.size,Cl.font.size)+e.height}return 0}function Ug(e,t,n){return n=Gs(n)?n:[n],{w:El(e,t.string,n),h:n.length*t.lineHeight}}function Wg(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:e<r||e>i?{start:t-n,end:t}:{start:t,end:t+n}}function Gg(e){let t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],a=e._pointLabels.length,o=e.options.pointLabels,s=o.centerPointLabels?$/a:0;for(let c=0;c<a;c++){let a=o.setContext(e.getPointLabelContext(c));i[c]=a.padding;let l=e.getPointPosition(c,e.drawingArea+i[c],s),u=Yl(a.font),d=Ug(e.ctx,u,e._pointLabels[c]);r[c]=d;let f=Pc(e.getIndexAngle(c)+s),p=Math.round(kc(f));Kg(n,t,f,Wg(p,l.x,d.w,0,180),Wg(p,l.y,d.h,90,270))}e.setCenterPoint(t.l-n.l,n.r-t.r,t.t-n.t,n.b-t.b),e._pointLabelItems=Yg(e,r,i)}function Kg(e,t,n,r,i){let a=Math.abs(Math.sin(n)),o=Math.abs(Math.cos(n)),s=0,c=0;r.start<t.l?(s=(t.l-r.start)/a,e.l=Math.min(e.l,t.l-s)):r.end>t.r&&(s=(r.end-t.r)/a,e.r=Math.max(e.r,t.r+s)),i.start<t.t?(c=(t.t-i.start)/o,e.t=Math.min(e.t,t.t-c)):i.end>t.b&&(c=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+c))}function qg(e,t,n){let r=e.drawingArea,{extra:i,additionalAngle:a,padding:o,size:s}=n,c=e.getPointPosition(t,r+i+o,a),l=Math.round(kc(Pc(c.angle+gc))),u=Qg(c.y,s.h,l),d=Xg(l),f=Zg(c.x,s.w,d);return{visible:!0,x:c.x,y:u,textAlign:d,left:f,top:u,right:f+s.w,bottom:u+s.h}}function Jg(e,t){if(!t)return!0;let{left:n,top:r,right:i,bottom:a}=e;return!(jl({x:n,y:r},t)||jl({x:n,y:a},t)||jl({x:i,y:r},t)||jl({x:i,y:a},t))}function Yg(e,t,n){let r=[],i=e._pointLabels.length,a=e.options,{centerPointLabels:o,display:s}=a.pointLabels,c={extra:Hg(a)/2,additionalAngle:o?$/i:0},l;for(let a=0;a<i;a++){c.padding=n[a],c.size=t[a];let i=qg(e,a,c);r.push(i),s===`auto`&&(i.visible=Jg(i,l),i.visible&&(l=i))}return r}function Xg(e){return e===0||e===180?`center`:e<180?`left`:`right`}function Zg(e,t,n){return n===`right`?e-=t:n===`center`&&(e-=t/2),e}function Qg(e,t,n){return n===90||n===270?e-=t/2:(n>270||n<90)&&(e-=t),e}function $g(e,t,n){let{left:r,top:i,right:a,bottom:o}=n,{backdropColor:s}=t;if(!J(s)){let n=ql(t.borderRadius),c=Jl(t.backdropPadding);e.fillStyle=s;let l=r-c.left,u=i-c.top,d=a-r+c.width,f=o-i+c.height;Object.values(n).some(e=>e!==0)?(e.beginPath(),Bl(e,{x:l,y:u,w:d,h:f,radius:n}),e.fill()):e.fillRect(l,u,d,f)}}function e_(e,t){let{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){let t=e._pointLabelItems[i];if(!t.visible)continue;let a=r.setContext(e.getPointLabelContext(i));$g(n,a,t);let o=Yl(a.font),{x:s,y:c,textAlign:l}=t;zl(n,e._pointLabels[i],s,c+o.lineHeight/2,o,{color:a.color,textAlign:l,textBaseline:`middle`})}}function t_(e,t,n,r){let{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,fc);else{let n=e.getPointPosition(0,t);i.moveTo(n.x,n.y);for(let a=1;a<r;a++)n=e.getPointPosition(a,t),i.lineTo(n.x,n.y)}}function n_(e,t,n,r,i){let a=e.ctx,o=t.circular,{color:s,lineWidth:c}=t;!o&&!r||!s||!c||n<0||(a.save(),a.strokeStyle=s,a.lineWidth=c,a.setLineDash(i.dash||[]),a.lineDashOffset=i.dashOffset,a.beginPath(),t_(e,n,o,r),a.closePath(),a.stroke(),a.restore())}function r_(e,t,n){return Ql(e,{label:n,index:t,type:`pointLabel`})}var i_=class extends Ng{static id=`radialLinear`;static defaults={display:!0,animate:!0,position:`chartArea`,angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:_l.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(e){return e},padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":`borderColor`,"pointLabels.color":`color`,"ticks.color":`color`};static descriptors={angleLines:{_fallback:`grid`}};constructor(e){super(e),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){let e=this._padding=Jl(Hg(this.options)/2),t=this.width=this.maxWidth-e.width,n=this.height=this.maxHeight-e.height;this.xCenter=Math.floor(this.left+t/2+e.left),this.yCenter=Math.floor(this.top+n/2+e.top),this.drawingArea=Math.floor(Math.min(t,n)/2)}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!1);this.min=Ks(e)&&!isNaN(e)?e:0,this.max=Ks(t)&&!isNaN(t)?t:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/Hg(this.options))}generateTickLabels(e){Ng.prototype.generateTickLabels.call(this,e),this._pointLabels=this.getLabels().map((e,t)=>{let n=Z(this.options.pointLabels.callback,[e,t],this);return n||n===0?n:``}).filter((e,t)=>this.chart.getDataVisibility(t))}fit(){let e=this.options;e.display&&e.pointLabels.display?Gg(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,t,n,r){this.xCenter+=Math.floor((e-t)/2),this.yCenter+=Math.floor((n-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,t,n,r))}getIndexAngle(e){let t=fc/(this._pointLabels.length||1),n=this.options.startAngle||0;return Pc(e*t+Oc(n))}getDistanceFromCenterForValue(e){if(J(e))return NaN;let t=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*t:(e-this.min)*t}getValueForDistanceFromCenter(e){if(J(e))return NaN;let t=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-t:this.min+t}getPointLabelContext(e){let t=this._pointLabels||[];if(e>=0&&e<t.length){let n=t[e];return r_(this.getContext(),e,n)}}getPointPosition(e,t,n=0){let r=this.getIndexAngle(e)-gc+n;return{x:Math.cos(r)*t+this.xCenter,y:Math.sin(r)*t+this.yCenter,angle:r}}getPointPositionForValue(e,t){return this.getPointPosition(e,this.getDistanceFromCenterForValue(t))}getBasePosition(e){return this.getPointPositionForValue(e||0,this.getBaseValue())}getPointLabelPosition(e){let{left:t,top:n,right:r,bottom:i}=this._pointLabelItems[e];return{left:t,top:n,right:r,bottom:i}}drawBackground(){let{backgroundColor:e,grid:{circular:t}}=this.options;if(e){let n=this.ctx;n.save(),n.beginPath(),t_(this,this.getDistanceFromCenterForValue(this._endValue),t,this._pointLabels.length),n.closePath(),n.fillStyle=e,n.fill(),n.restore()}}drawGrid(){let e=this.ctx,t=this.options,{angleLines:n,grid:r,border:i}=t,a=this._pointLabels.length,o,s,c;if(t.pointLabels.display&&e_(this,a),r.display&&this.ticks.forEach((e,t)=>{if(t!==0||t===0&&this.min<0){s=this.getDistanceFromCenterForValue(e.value);let n=this.getContext(t),o=r.setContext(n),c=i.setContext(n);n_(this,o,s,a,c)}}),n.display){for(e.save(),o=a-1;o>=0;o--){let r=n.setContext(this.getPointLabelContext(o)),{color:i,lineWidth:a}=r;!a||!i||(e.lineWidth=a,e.strokeStyle=i,e.setLineDash(r.borderDash),e.lineDashOffset=r.borderDashOffset,s=this.getDistanceFromCenterForValue(t.reverse?this.min:this.max),c=this.getPointPosition(o,s),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){let e=this.ctx,t=this.options,n=t.ticks;if(!n.display)return;let r=this.getIndexAngle(0),i,a;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(r),e.textAlign=`center`,e.textBaseline=`middle`,this.ticks.forEach((r,o)=>{if(o===0&&this.min>=0&&!t.reverse)return;let s=n.setContext(this.getContext(o)),c=Yl(s.font);if(i=this.getDistanceFromCenterForValue(this.ticks[o].value),s.showLabelBackdrop){e.font=c.string,a=e.measureText(r.label).width,e.fillStyle=s.backdropColor;let t=Jl(s.backdropPadding);e.fillRect(-a/2-t.left,-i-c.size/2-t.top,a+t.width,c.size+t.height)}zl(e,r.label,0,-i,c,{color:s.color,strokeColor:s.textStrokeColor,strokeWidth:s.textStrokeWidth})}),e.restore()}drawTitle(){}},a_={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},o_=Object.keys(a_);function s_(e,t){return e-t}function c_(e,t){if(J(t))return null;let n=e._adapter,{parser:r,round:i,isoWeekday:a}=e._parseOpts,o=t;return typeof r==`function`&&(o=r(o)),Ks(o)||(o=typeof r==`string`?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i===`week`&&(Tc(a)||a===!0)?n.startOf(o,`isoWeek`,a):n.startOf(o,i)),+o)}function l_(e,t,n,r){let i=o_.length;for(let a=o_.indexOf(e);a<i-1;++a){let e=a_[o_[a]],i=e.steps?e.steps:2**53-1;if(e.common&&Math.ceil((n-t)/(i*e.size))<=r)return o_[a]}return o_[i-1]}function u_(e,t,n,r,i){for(let a=o_.length-1;a>=o_.indexOf(n);a--){let n=o_[a];if(a_[n].common&&e._adapter.diff(i,r,n)>=t-1)return n}return o_[n?o_.indexOf(n):0]}function d_(e){for(let t=o_.indexOf(e)+1,n=o_.length;t<n;++t)if(a_[o_[t]].common)return o_[t]}function f_(e,t,n){if(!n)e[t]=!0;else if(n.length){let{lo:r,hi:i}=zc(n,t),a=n[r]>=t?n[r]:n[i];e[a]=!0}}function p_(e,t,n,r){let i=e._adapter,a=+i.startOf(t[0].value,r),o=t[t.length-1].value,s,c;for(s=a;s<=o;s=+i.add(s,1,r))c=n[s],c>=0&&(t[c].major=!0);return t}function m_(e,t,n){let r=[],i={},a=t.length,o,s;for(o=0;o<a;++o)s=t[o],i[s]=o,r.push({value:s,major:!1});return a===0||!n?r:p_(e,r,i,n)}var h_=class extends Dp{static id=`time`;static defaults={bounds:`data`,adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:`millisecond`,displayFormats:{}},ticks:{source:`auto`,callback:!1,major:{enabled:!1}}};constructor(e){super(e),this._cache={data:[],labels:[],all:[]},this._unit=`day`,this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(e,t={}){let n=e.time||={},r=this._adapter=new df._date(e.adapters.date);r.init(t),tc(n.displayFormats,r.formats()),this._parseOpts={parser:n.parser,round:n.round,isoWeekday:n.isoWeekday},super.init(e),this._normalized=t.normalized}parse(e,t){return e===void 0?null:c_(this,e)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){let e=this.options,t=this._adapter,n=e.time.unit||`day`,{min:r,max:i,minDefined:a,maxDefined:o}=this.getUserBounds();function s(e){!a&&!isNaN(e.min)&&(r=Math.min(r,e.min)),!o&&!isNaN(e.max)&&(i=Math.max(i,e.max))}(!a||!o)&&(s(this._getLabelBounds()),(e.bounds!==`ticks`||e.ticks.source!==`labels`)&&s(this.getMinMax(!1))),r=Ks(r)&&!isNaN(r)?r:+t.startOf(Date.now(),n),i=Ks(i)&&!isNaN(i)?i:+t.endOf(Date.now(),n)+1,this.min=Math.min(r,i-1),this.max=Math.max(r+1,i)}_getLabelBounds(){let e=this.getLabelTimestamps(),t=1/0,n=-1/0;return e.length&&(t=e[0],n=e[e.length-1]),{min:t,max:n}}buildTicks(){let e=this.options,t=e.time,n=e.ticks,r=n.source===`labels`?this.getLabelTimestamps():this._generate();e.bounds===`ticks`&&r.length&&(this.min=this._userMin||r[0],this.max=this._userMax||r[r.length-1]);let i=this.min,a=this.max,o=Hc(r,i,a);return this._unit=t.unit||(n.autoSkip?l_(t.minUnit,this.min,this.max,this._getLabelCapacity(i)):u_(this,o.length,t.minUnit,this.min,this.max)),this._majorUnit=!n.major.enabled||this._unit===`year`?void 0:d_(this._unit),this.initOffsets(r),e.reverse&&o.reverse(),m_(this,o,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(e=>+e.value))}initOffsets(e=[]){let t=0,n=0,r,i;this.options.offset&&e.length&&(r=this.getDecimalForValue(e[0]),t=e.length===1?1-r:(this.getDecimalForValue(e[1])-r)/2,i=this.getDecimalForValue(e[e.length-1]),n=e.length===1?i:(i-this.getDecimalForValue(e[e.length-2]))/2);let a=e.length<3?.5:.25;t=Ic(t,0,a),n=Ic(n,0,a),this._offsets={start:t,end:n,factor:1/(t+1+n)}}_generate(){let e=this._adapter,t=this.min,n=this.max,r=this.options,i=r.time,a=i.unit||l_(i.minUnit,t,n,this._getLabelCapacity(t)),o=X(r.ticks.stepSize,1),s=a===`week`&&i.isoWeekday,c=Tc(s)||s===!0,l={},u=t,d,f;if(c&&(u=+e.startOf(u,`isoWeek`,s)),u=+e.startOf(u,c?`day`:a),e.diff(n,t,a)>1e5*o)throw Error(t+` and `+n+` are too far apart with stepSize of `+o+` `+a);let p=r.ticks.source===`data`&&this.getDataTimestamps();for(d=u,f=0;d<n;d=+e.add(d,o,a),f++)f_(l,d,p);return(d===n||r.bounds===`ticks`||f===1)&&f_(l,d,p),Object.keys(l).sort(s_).map(e=>+e)}getLabelForValue(e){let t=this._adapter,n=this.options.time;return n.tooltipFormat?t.format(e,n.tooltipFormat):t.format(e,n.displayFormats.datetime)}format(e,t){let n=this.options.time.displayFormats,r=this._unit,i=t||n[r];return this._adapter.format(e,i)}_tickFormatFunction(e,t,n,r){let i=this.options,a=i.ticks.callback;if(a)return Z(a,[e,t,n],this);let o=i.time.displayFormats,s=this._unit,c=this._majorUnit,l=s&&o[s],u=c&&o[c],d=n[t],f=c&&u&&d&&d.major;return this._adapter.format(e,r||(f?u:l))}generateTickLabels(e){let t,n,r;for(t=0,n=e.length;t<n;++t)r=e[t],r.label=this._tickFormatFunction(r.value,t,e)}getDecimalForValue(e){return e===null?NaN:(e-this.min)/(this.max-this.min)}getPixelForValue(e){let t=this._offsets,n=this.getDecimalForValue(e);return this.getPixelForDecimal((t.start+n)*t.factor)}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return this.min+n*(this.max-this.min)}_getLabelSize(e){let t=this.options.ticks,n=this.ctx.measureText(e).width,r=Oc(this.isHorizontal()?t.maxRotation:t.minRotation),i=Math.cos(r),a=Math.sin(r),o=this._resolveTickFontOptions(0).size;return{w:n*i+o*a,h:n*a+o*i}}_getLabelCapacity(e){let t=this.options.time,n=t.displayFormats,r=n[t.unit]||n.millisecond,i=this._tickFormatFunction(e,0,m_(this,[e],this._majorUnit),r),a=this._getLabelSize(i),o=Math.floor(this.isHorizontal()?this.width/a.w:this.height/a.h)-1;return o>0?o:1}getDataTimestamps(){let e=this._cache.data||[],t,n;if(e.length)return e;let r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(t=0,n=r.length;t<n;++t)e=e.concat(r[t].controller.getAllParsedValues(this));return this._cache.data=this.normalize(e)}getLabelTimestamps(){let e=this._cache.labels||[],t,n;if(e.length)return e;let r=this.getLabels();for(t=0,n=r.length;t<n;++t)e.push(c_(this,r[t]));return this._cache.labels=this._normalized?e:this.normalize(e)}normalize(e){return Kc(e.sort(s_))}};function g_(e,t,n){let r=0,i=e.length-1,a,o,s,c;n?(t>=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=Bc(e,`pos`,t)),{pos:a,time:s}=e[r],{pos:o,time:c}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=Bc(e,`time`,t)),{time:a,pos:s}=e[r],{time:o,pos:c}=e[i]);let l=o-a;return l?s+(c-s)*(t-a)/l:s}var __=class extends h_{static id=`timeseries`;static defaults=h_.defaults;constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let e=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(e);this._minPos=g_(t,this.min),this._tableRange=g_(t,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){let{min:t,max:n}=this,r=[],i=[],a,o,s,c,l;for(a=0,o=e.length;a<o;++a)c=e[a],c>=t&&c<=n&&r.push(c);if(r.length<2)return[{time:t,pos:0},{time:n,pos:1}];for(a=0,o=r.length;a<o;++a)l=r[a+1],s=r[a-1],c=r[a],Math.round((l+s)/2)!==c&&i.push({time:c,pos:a/(o-1)});return i}_generate(){let e=this.min,t=this.max,n=super.getDataTimestamps();return(!n.includes(e)||!n.length)&&n.splice(0,0,e),(!n.includes(t)||n.length===1)&&n.push(t),n.sort((e,t)=>e-t)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;let t=this.getDataTimestamps(),n=this.getLabelTimestamps();return e=t.length&&n.length?this.normalize(t.concat(n)):t.length?t:n,e=this._cache.all=e,e}getDecimalForValue(e){return(g_(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return g_(this._table,n*this._tableRange+this._minPos,!0)}},v_=[lf,Xm,Tg,Object.freeze({__proto__:null,CategoryScale:Ag,LinearScale:Pg,LogarithmicScale:Vg,RadialLinearScale:i_,TimeScale:h_,TimeSeriesScale:__})];hm.register(...v_);var y_=e=>new hm(e,{type:`bar`,data:{datasets:[]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1},tooltip:{position:`average`,intersect:!1,mode:`index`,caretPadding:10,caretSize:8}},scales:{y:{beginAtZero:!0},y1:{beginAtZero:!0,position:`right`,grid:{drawOnChartArea:!1}}},hover:{mode:`index`,intersect:!1},onHover:(e,t,n)=>{let r;r=t.length?(t[0].element.x+t[t.length-1].element.x)/2:null,r!==n.hoveredPosition&&(n.hoveredPosition=r,n.update(`none`))}},plugins:[{id:`highlightXAxisBand`,beforeDatasetsDraw(e,t,n){let{ctx:r,hoveredPosition:i,scales:{x:a,y:o}}=e;if(!i||!a||!o)return;let s=a.ticks.length>0?a.chart.chartArea.width/a.ticks.length:0,c=i-s/2;r.save(),r.fillStyle=`#3366CC11`,r.fillRect(c,o.top,s,o.height),r.restore()}}]}),b_=U(`<div class="relative w-full aspect-video pr-4"><canvas></canvas></div>`);function x_(e,t){qe(t,!0);let n=N(void 0),r;na(()=>(hm.defaults.font.size=18,r=y_(V(n)),a(),i(),r.update(),()=>r?.destroy()));let i=()=>{r.options.plugins?.tooltip&&(r.options.plugins.tooltip.mode=t.chartConfig.time_series?`index`:`x`,r.options.plugins.tooltip.yAlign=t.chartConfig.time_series?void 0:`bottom`),r.options.hover&&(r.options.hover.mode=t.chartConfig.time_series?`index`:`x`)};Dn(()=>{r&&(i(),r.update())});let a=()=>{if(!r||!t.data)return;let e=!1,n=!1;r.data.datasets=t.data.map(r=>(r.axis===`right`?n=!0:e=!0,{label:r.label,data:r.data,yAxisID:r.axis===`right`?`y1`:`y`,fill:!1,skipNull:!t.chartConfig.time_series})),r.options.plugins?.legend&&(r.options.plugins.legend.display=!!t.chartConfig.time_series),r.options.scales?.y&&(r.options.scales.y.display=e),r.options.scales?.y1&&(r.options.scales.y1.display=n),r.hoveredPosition=null};Dn(()=>{r&&(a(),r.update())});var o=b_();Qi(F(o),e=>P(n,e),()=>V(n)),A(o),W(e,o),Je()}var S_=U(`<p class="text-gray-500 leading-none">&hellip;</p>`),C_=U(`<button type="button" class="ghost bg-night-700 text-white" disabled=""> </button>`),w_=U(`<button type="button" class="ghost"> </button>`),T_=U(`<div></div>`);function E_(e,t){qe(t,!0);let n=ta(t,`class`,3,``),r=j(()=>Math.ceil(t.totalItems/t.perPage)),i=j(()=>{let e=[];t.page>3&&e.push(1),t.page>4&&e.push(`...`);let n=Math.min(t.page+2,V(r));for(let r=Math.max(1,t.page-2);r<=n;r++)e.push(r);return t.page<V(r)-3&&e.push(`...`),t.page<V(r)-2&&e.push(V(r)),e});var a=Kr(),o=I(a),s=e=>{var r=T_();q(r,21,()=>V(i),ei,(e,n)=>{var r=Kr(),i=I(r),a=e=>{W(e,S_())},o=e=>{var t=C_(),r=F(t,!0);A(t),R(()=>G(r,V(n))),W(e,t)},s=e=>{var r=w_(),i=F(r,!0);A(r),R(()=>G(i,V(n))),H(`click`,r,()=>t.setPage(V(n))),W(e,r)};K(i,e=>{V(n)===`...`?e(a):V(n)===t.page?e(o,1):e(s,-1)}),W(e,r)}),A(r),R(()=>bi(r,1,`grid grid-flow-col grid-cols-fr gap-2 items-baseline w-max mx-auto ${n()??``}`)),W(e,r)};K(o,e=>{V(r)>1&&e(s)}),W(e,a),Je()}Ir([`click`]);var D_=U(`<th> </th>`),O_=U(`<td><!></td>`),k_=U(`<tr></tr>`),A_=U(`<div><table><thead><tr></tr></thead><tbody></tbody></table> <!></div>`);function j_(e,t){qe(t,!0);let n=ta(t,`chartFilters`,7),r=N(1),i=N(1),a=j(()=>typeof t.chartMetadata.resultOffset==`number`?t.chartMetadata.resultOffset/10:null),o=e=>V(a)!==null&&e>V(a)&&e<=V(a)+10,s=j(()=>t.loading||!o(V(r))),c=j(()=>t.chartMetadata.resultCount),l=j(()=>Math.ceil(V(c)/10)),u=j(()=>Math.max(1,Math.min(V(r),V(l)??1))),d=j(()=>((V(s)?V(i):V(u))-1)%10*10),f=j(()=>t.chartConfig.datasets[0]),p=j(()=>{let e;return V(f)&&ja(V(f))&&(V(f).selects?.length?e=V(f).selects:wa[V(f).type]&&(e=Object.entries(wa[V(f).type]?.fields??{}).flatMap(([e,t])=>t.select?[e]:[]))),e??=Object.keys(t.data[0]),e.flatMap(e=>{if(!V(f))return[];let{datasetType:t,field:n,fieldSchema:r}=Fa(V(f),e);return[{label:Ra(n,t),value:e,type:r?.type??`string`}]})}),m=e=>{o(e)||(P(i,V(r),!0),n().page=e-(e-1)%10),P(r,e,!0)};var h=A_(),g=F(h),_=F(g),v=F(_);q(v,21,()=>V(p),ei,(e,t)=>{var n=D_(),r=F(n,!0);A(n),R(()=>G(r,V(t).label)),W(e,n)}),A(v),A(_);var y=L(_);q(y,21,()=>Array(10),ei,(e,n,r)=>{let i=j(()=>t.data[V(d)+r]);var a=Kr(),o=I(a),s=e=>{var t=k_();q(t,21,()=>V(p),ei,(e,t)=>{var n=O_(),r=F(n),a=e=>{var n=Gr();R(e=>G(n,e),[()=>Oa(V(i)[V(t).value],`day`)]),W(e,n)},o=e=>{var n=Gr();R(()=>G(n,V(i)[V(t).value]?`Yes`:`No`)),W(e,n)},s=e=>{var n=Gr();R(()=>G(n,V(i)[V(t).value])),W(e,n)};K(r,e=>{V(t).type===`date`?e(a):V(t).type===`boolean`?e(o,1):e(s,-1)}),A(n),W(e,n)}),A(t),W(e,t)};K(o,e=>{V(i)&&e(s)}),W(e,a)}),A(y),A(g),E_(L(g,2),{class:`mt-4`,get page(){return V(u)},perPage:10,get totalItems(){return V(c)},setPage:m}),A(h),R(()=>bi(h,1,`w-full overflow-x-auto ${V(s)?`opacity-25`:``}`)),W(e,h),Je()}var M_=e=>new hm(e,{type:`line`,data:{datasets:[]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:`top`},tooltip:{intersect:!1,mode:`index`,position:`nearest`,caretPadding:10,caretSize:8}},scales:{x:{ticks:{sampleSize:1}},y:{beginAtZero:!0},y1:{beginAtZero:!0,position:`right`,grid:{drawOnChartArea:!1}}}},plugins:[{id:`verticalLineOnHover`,afterDraw:e=>{let t=e.tooltip?.getActiveElements();if(t?.length){let n=t[0];if(!n||!e.scales.y)return;let r=e.ctx,i=n.element.x,a=e.scales.y.top,o=e.scales.y.bottom;r.save(),r.beginPath(),r.moveTo(i,a),r.lineTo(i,o),r.lineWidth=1,r.strokeStyle=`rgb(0, 0, 0, 0.4)`,r.setLineDash([4,6]),r.stroke(),r.restore()}}}]}),N_=U(`<div class="relative w-full aspect-video pr-4"><canvas></canvas></div>`);function P_(e,t){qe(t,!0);let n=N(void 0),r;na(()=>(hm.defaults.font.size=18,r=M_(V(n)),i(),r.update(),()=>r?.destroy()));let i=()=>{if(!r||!t.data)return;let e=!1,n=!1;r.data.datasets=t.data.map(t=>(t.axis===`right`?n=!0:e=!0,{label:t.label,data:t.data,yAxisID:t.axis===`right`?`y1`:`y`,fill:!1})),r.options.scales?.y&&(r.options.scales.y.display=e),r.options.scales?.y1&&(r.options.scales.y1.display=n)};Dn(()=>{r&&(i(),r.update())});var a=N_();Qi(F(a),e=>P(n,e),()=>V(n)),A(a),W(e,a),Je()}var F_=U(`<th>Date</th>`),I_=U(`<th> </th>`),L_=U(`<td> </td>`),R_=U(`<tr><!><!></tr>`),z_=U(`<div class="w-full overflow-x-auto"><table><thead><tr><!><!></tr></thead><tbody></tbody></table> <!></div>`);function B_(e,t){qe(t,!0);let n=j(()=>t.data[0]?.data?.length??0),r=N(1),i=j(()=>Math.ceil(V(n)/10)),a=j(()=>Math.max(1,Math.min(V(r),V(i))));var o=z_(),s=F(o),c=F(s),l=F(c),u=F(l),d=e=>{W(e,F_())};K(u,e=>{t.chartConfig.time_series&&e(d)}),q(L(u),17,()=>t.data,ei,(e,t)=>{var n=I_(),r=F(n,!0);A(n),R(()=>G(r,V(t).label)),W(e,n)}),A(l),A(c);var f=L(c);q(f,21,()=>Array(10),ei,(e,r,i)=>{let o=j(()=>i+(V(a)-1)*10);var s=Kr(),c=I(s),l=e=>{var n=R_(),r=F(n),i=e=>{var n=L_(),r=F(n,!0);A(n),R(()=>G(r,t.data[0]?.data[V(o)]?.x)),W(e,n)};K(r,e=>{t.chartConfig.time_series&&e(i)}),q(L(r),17,()=>t.data,ei,(e,t)=>{var n=L_(),r=F(n,!0);A(n),R(()=>G(r,V(t).data[V(o)]?.y)),W(e,n)}),A(n),W(e,n)};K(c,e=>{V(o)<V(n)&&e(l)}),W(e,s)}),A(f),A(s),E_(L(s,2),{class:`mt-4`,get page(){return V(a)},perPage:10,get totalItems(){return V(n)},setPage:e=>P(r,e,!0)}),A(o),W(e,o),Je()}var V_=U(`<div class="mt-12"><!></div>`),H_=U(`<p class="whitespace-pre-wrap w-max max-w-full mx-auto px-2 lg:px-12"> </p>`),U_=U(`<div class="aspect-video border border-ice-100"><p class="absolute top-1/2 left-1/2 -translate-1/2 text-gray-600">No data to display</p></div>`),W_=U(`<div class="p-2 bg-dawn-50 border border-dawn-200 text-dawn-700"><p>Something went wrong when trying to load the chart data.</p></div>`),G_=U(`<button type="button" class="sm px-1"><!></button>`),K_=U(`<button type="button" class="bg-dawn-100">Yes, delete this chart</button> <button type="button" class="ghost text-gray-600">Cancel</button>`,1),q_=U(`<button type="button" class="bg-dawn-100">Delete</button>`),J_=U(`<button type="button">Edit</button> <button type="button">Duplicate</button> <!> <!> <!>`,1),Y_=U(`<button type="button"> </button>`),X_=U(`<div><div><!> <div class="sticky top-18 grow min-w-0 flex flex-col gap-4"><div><div class="mb-4"><h2 class="text-night-950 text-xl font-semibold text-center"> </h2> <!></div> <div class="relative"><!></div></div> <!> <div class="flex flex-wrap gap-2 items-center"><!> <div class="ml-auto"></div> <button type="button">Refresh</button> <!></div></div></div></div>`);function Z_(e,t){qe(t,!0);let n=N(on(br(()=>t.startOpen))),r=N(!1),i=N(!1),a=N(!1),o=N(!1),s=N(on(br(()=>t.chartConfig))),c=on({}),l=on({}),u=N([]),d=e=>(P(o,!0),Xo(V(n)?e:t.chartConfig.id,t.tabFilters,c).then(t=>{P(s,e,!0),V(s).type===`table`?(l.resultOffset=t.resultOffset,l.resultCount=t.resultCount,P(u,t.data)):P(u,Io(V(s),t.data)),P(a,!1)}).catch(e=>{throw console.error(e),P(a,!0),e}).finally(()=>{P(o,!1)})),f=e=>d(e),p=e=>{t.onSave(e),P(s,e,!0),P(n,!1)};Dn(()=>{JSON.stringify(t.tabFilters),JSON.stringify(c),br(()=>{d(V(s))})});var m=X_(),h=F(m),g=F(h),_=e=>{var r=V_();Fo(F(r),{get canDangerouslyUseSql(){return t.canDangerouslyUseSql},get chartConfig(){return t.chartConfig},reloadChartData:f,onClose:()=>P(n,!1),onSave:p}),A(r),W(e,r)};K(g,e=>{V(n)&&e(_)});var v=L(g,2),y=F(v),b=F(y),x=F(b),S=F(x,!0);A(x);var C=L(x,2),w=e=>{var t=H_(),n=F(t,!0);A(t),R(()=>G(n,V(s).description)),W(e,t)};K(C,e=>{V(s).description&&e(w)}),A(b);var T=L(b,2),E=F(T),D=e=>{W(e,U_())},ee=e=>{j_(e,{get chartConfig(){return V(s)},get chartFilters(){return c},get chartMetadata(){return l},get data(){return V(u)},get loading(){return V(o)}})},te=e=>{B_(e,{get chartConfig(){return V(s)},get data(){return V(u)}})},ne=e=>{P_(e,{get data(){return V(u)}})},re=e=>{x_(e,{get chartConfig(){return V(s)},get data(){return V(u)}})};K(E,e=>{V(u).length===0?e(D):V(s).type===`table`?e(ee,1):V(r)&&V(u).length!==0?e(te,2):V(s).type===`line`?e(ne,3):V(s).type===`bar`&&e(re,4)}),A(T),A(y);var ie=L(y,2),ae=e=>{W(e,W_())};K(ie,e=>{V(a)&&e(ae)});var oe=L(ie,2),se=F(oe),ce=e=>{var r=J_(),a=I(r),o=L(a,2),s=L(o,2),c=e=>{var n=G_();aa(F(n),{name:`chevron_up`,size:24}),A(n),H(`click`,n,function(...e){t.onMoveUp?.apply(this,e)}),W(e,n)};K(s,e=>{t.onMoveUp!==null&&e(c)});var l=L(s,2),u=e=>{var n=G_();aa(F(n),{name:`chevron_down`,size:24}),A(n),H(`click`,n,function(...e){t.onMoveDown?.apply(this,e)}),W(e,n)};K(l,e=>{t.onMoveDown!==null&&e(u)});var d=L(l,2),f=e=>{var n=K_(),r=I(n),a=L(r,2);H(`click`,r,function(...e){t.onDelete?.apply(this,e)}),H(`click`,a,()=>P(i,!1)),W(e,n)},p=e=>{var t=q_();H(`click`,t,()=>P(i,!0)),W(e,t)};K(d,e=>{V(i)?e(f):e(p,-1)}),H(`click`,a,()=>P(n,!0)),H(`click`,o,function(...e){t.onDuplicate?.apply(this,e)}),W(e,r)};K(se,e=>{t.editingEnabled&&!V(n)&&e(ce)});var le=L(se,4),ue=L(le,2),de=e=>{var t=Y_(),n=F(t,!0);A(t),R(()=>G(n,V(r)?`Show chart`:`Show data`)),H(`click`,t,()=>P(r,!V(r))),W(e,t)};K(ue,e=>{V(u).length!==0&&t.chartConfig.type!==`table`&&e(de)}),A(oe),A(v),A(h),A(m),R(()=>{bi(m,1,V(n)?`xl:full-width`:``),bi(h,1,`flex flex-col px-6 p-4 bg-white border border-night-50 ${V(n)?`mx-auto xl:max-w-384 xl:flex-row xl:justify-center xl:items-start`:``} gap-4`),bi(y,1,mi(V(n)?`flex-1 min-w-0 max-w-256`:``)),G(S,V(s).title)}),H(`click`,le,()=>d(V(s))),W(e,m),Je()}Ir([`click`]);var Q_=U(`<button type="button" class="bg-dawn-100">Yes, delete this dashboard and all its charts</button> <button type="button" class="ghost text-gray-600">Cancel</button>`,1),$_=U(`<button type="button" class="bg-dawn-100">Delete this tab</button>`),ev=U(`<!> <!> <!> <!> <div class="flex gap-2 mt-4"><!></div>`,1);function tv(e,t){let n=N(!1);var r=ev(),i=I(r);xa(i,{get model(){return t.tabConfig},key:`title`,allowEmpty:!0,trimOnBlur:!0,children:(e,t)=>{Ie(),W(e,Gr(`Tab name`))},$$slots:{default:!0}});var a=L(i,2);xa(a,{type:`contenteditable`,get model(){return t.tabConfig},key:`description`,placeholder:`Enter a description for this tab`,trimOnBlur:!0,children:(e,t)=>{Ie(),W(e,Gr(`Tab description`))},$$slots:{default:!0}});var o=L(a,2);xa(o,{type:`date`,get model(){return t.tabConfig},key:`date_from`,children:(e,t)=>{Ie(),W(e,Gr(`Default date from`))},$$slots:{default:!0}});var s=L(o,2);xa(s,{type:`date`,get model(){return t.tabConfig},key:`date_to`,children:(e,t)=>{Ie(),W(e,Gr(`Default date to`))},$$slots:{default:!0}});var c=L(s,2),l=F(c),u=e=>{var r=Q_(),i=I(r),a=L(i,2);H(`click`,i,function(...e){t.onDelete?.apply(this,e)}),H(`click`,a,()=>P(n,!1)),W(e,r)},d=e=>{var t=$_();H(`click`,t,()=>P(n,!0)),W(e,t)};K(l,e=>{V(n)?e(u):e(d,-1)}),A(c),W(e,r)}Ir([`click`]);var nv=U(`<button type="button"> </button>`),rv=U(`<header class="mt-4"><nav><!> <button type="button" class="shrink-0 font-bold px-3">+</button></nav></header>`);function iv(e,t){qe(t,!0);var n=rv(),r=F(n),i=F(r);q(i,17,()=>t.dashboards,ei,(e,n,r)=>{var i=nv(),a=F(i,!0);A(i),R(()=>{bi(i,1,V(n).id===t.selectedTab?`selected`:``),G(a,V(n).title?V(n).title:`Tab ${r+1}`)}),H(`click`,i,()=>t.selectTab(V(n).id)),W(e,i)});var a=L(i,2);A(r),A(n),H(`click`,a,()=>t.newTab()),W(e,n),Je()}Ir([`click`]);var av=U(`<div class="fixed bottom-2 right-2 z-10 p-2 bg-ice-50 border border-ice-200 text-ice-700"><p>Saving your changes...</p></div>`),ov=U(`<div class="fixed bottom-2 right-2 z-10 p-2 bg-dawn-50 border border-dawn-200 text-dawn-700"><p>Something went wrong when trying to save the dashboard. Retrying in 10 seconds...</p></div>`),sv=U(`<div class="sm:sticky z-10 sm:h-0 top-0 sm:-mb-4"><div class="ml-auto w-max p-4 bg-white"><button type="button">Finish editing</button></div></div> <div class="flex flex-col gap-4 bg-white p-4"><!></div>`,1),cv=U(`<p class="whitespace-pre-wrap"> </p>`),lv=U(`<span class="sr-only">Date from</span>`),uv=U(`<span class="sr-only">Date to</span>`),dv=U(`<!> <div class="flex flex-wrap gap-2 justify-center sm:justify-start items-center"><div class="flex gap-2 items-center sm:contents">Showing data from <!></div> <div class="flex gap-2 items-center sm:contents">to <!></div></div>`,1),fv=U(`<button type="button">Enable editing</button>`),pv=U(`<div class="z-10 border border-night-50 gap-4 flex flex-col md:flex-row justify-between items-center md:items-start bg-white p-4 sm:sticky top-0"><div class="grow flex flex-col gap-4"><!></div> <!></div>`),mv=U(`<div class="flex justify-center items-center py-8 mt-8 border border-dashed border-black/20"><button type="button">Add chart</button></div>`),hv=U(`<!> <main class="w-full mx-auto flex flex-col gap-4 pt-4"><!> <!> <!> <!></main>`,1);function gv(e,t){qe(t,!0);let n=document.querySelector(`[data-dashboard-config]`),r=on(JSON.parse(n.dataset.dashboardConfig)),i=n.dataset.canEdit===`true`,a=n.dataset.canDangerouslyUseSql===`true`,o=N(on(r[0].id)),s=j(()=>r.find(e=>e.id===V(o))),c=N(on(br(()=>({date_from:V(s).date_from,date_to:V(s).date_to})))),l=N(null),u=N(!1),d=N(!1),f=N(!1),p=e=>{P(l,null),P(o,e,!0),P(c,{date_from:V(s).date_from,date_to:V(s).date_to},!0)},m=(e=null)=>{let t=crypto.randomUUID();r.push({id:t,title:e??`Tab ${r.length+1}`,description:``,children:[]}),P(o,t,!0)},h=()=>{let e=crypto.randomUUID();P(l,e,!0),V(s).children.push({id:e,type:`line`,title:`New chart`,time_series:`weekly`,datasets:[{id:crypto.randomUUID(),type:`visits`,label:`Dataset 1`}]})},g=e=>{V(s).children.splice(e,1)},_=e=>{let t=Ue(V(s).children[e]);t.id=crypto.randomUUID(),P(l,t.id,!0),t.title=`Copy of ${t.title}`,V(s).children.splice(e+1,0,t)},v=e=>{if(e===0)return;let t=V(s).children[e];V(s).children[e]=V(s).children[e-1],V(s).children[e-1]=t},y=e=>{if(e>=V(s).children.length-1)return;let t=V(s).children[e];V(s).children[e]=V(s).children[e+1],V(s).children[e+1]=t},b=()=>{let e=r.indexOf(V(s));if(r.length<=1)m(`Tab 1`);else{let t=e===0?1:e-1;P(o,r[t].id,!0)}r.splice(e,1)},x=null,S=()=>{P(d,!0),x!==null&&(clearTimeout(x),x=null),Zo(r).then(()=>{P(d,!1),P(f,!1)}).catch(e=>{P(d,!1),P(f,!0),console.error(`Failed to save dashboard`,e),x=setTimeout(()=>{S(),x=null},1e4)})},C=!1;Dn(()=>{if(!C){JSON.stringify(r),C=!0;return}S()});var w=hv(),T=I(w);iv(T,{get dashboards(){return r},get selectedTab(){return V(o)},selectTab:p,newTab:m});var E=L(T,2),D=F(E),ee=e=>{W(e,av())},te=e=>{W(e,ov())};K(D,e=>{V(d)?e(ee):V(f)&&e(te,1)});var ne=L(D,2),re=e=>{var t=sv(),n=I(t),r=F(n),i=F(r);A(r),A(n);var a=L(n,2);$r(F(a),()=>V(o),e=>{tv(e,{get tabConfig(){return V(s)},onDelete:b})}),A(a),H(`click`,i,()=>P(u,!1)),W(e,t)},ie=e=>{var t=pv(),n=F(t),r=F(n),a=e=>{var t=dv(),n=I(t),r=e=>{var t=cv(),n=F(t,!0);A(t),R(()=>G(n,V(s).description)),W(e,t)};K(n,e=>{V(s).description&&e(r)});var i=L(n,2),a=F(i);xa(L(F(a)),{type:`date`,get model(){return V(c)},key:`date_from`,children:(e,t)=>{W(e,lv())},$$slots:{default:!0}}),A(a);var o=L(a,2);xa(L(F(o)),{type:`date`,get model(){return V(c)},key:`date_to`,children:(e,t)=>{W(e,uv())},$$slots:{default:!0}}),A(o),A(i),W(e,t)};K(r,e=>{V(u)||e(a)}),A(n);var o=L(n,2),l=e=>{var t=fv();H(`click`,t,()=>P(u,!0)),W(e,t)};K(o,e=>{i&&e(l)}),A(t),W(e,t)};K(ne,e=>{V(u)?e(re):e(ie,-1)});var ae=L(ne,2);q(ae,19,()=>V(s)?.children,e=>e.id,(e,t,n)=>{{let r=j(()=>V(l)===V(t).id),i=j(()=>V(n)===0?null:()=>v(V(n))),o=j(()=>V(n)===V(s).children.length-1?null:()=>y(V(n)));Z_(e,{get canDangerouslyUseSql(){return a},get chartConfig(){return V(t)},get editingEnabled(){return V(u)},get tabFilters(){return V(c)},get startOpen(){return V(r)},onDelete:()=>g(V(n)),onDuplicate:()=>_(V(n)),get onMoveUp(){return V(i)},get onMoveDown(){return V(o)},onSave:e=>V(s).children[V(n)]=e})}});var oe=L(ae,2),se=e=>{var t=mv(),n=F(t);A(t),H(`click`,n,h),W(e,t)};K(oe,e=>{V(u)&&e(se)}),A(E),W(e,w),Je()}Ir([`click`]),window.addEventListener(`load`,()=>{qr(gv,{target:document.getElementById(`skadi-dashboard`)})});
36
+ `):e}function gg(e,t){let{element:n,datasetIndex:r,index:i}=t,a=e.getDatasetMeta(r).controller,{label:o,value:s}=a.getLabelAndValue(i);return{chart:e,label:o,parsed:a.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:s,dataset:a.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function _g(e,t){let n=e.chart.ctx,{body:r,footer:i,title:a}=e,{boxWidth:o,boxHeight:s}=t,c=nu(t.bodyFont),l=nu(t.titleFont),u=nu(t.footerFont),d=a.length,f=i.length,p=r.length,m=tu(t.padding),h=m.height,g=0,_=r.reduce((e,t)=>e+t.before.length+t.lines.length+t.after.length,0);if(_+=e.beforeBody.length+e.afterBody.length,d&&(h+=d*l.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),_){let e=t.displayColors?Math.max(s,c.lineHeight):c.lineHeight;h+=p*e+(_-p)*c.lineHeight+(_-1)*t.bodySpacing}f&&(h+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let v=0,y=function(e){g=Math.max(g,n.measureText(e).width+v)};return n.save(),n.font=l.string,Q(e.title,y),n.font=c.string,Q(e.beforeBody.concat(e.afterBody),y),v=t.displayColors?o+2+t.boxPadding:0,Q(r,e=>{Q(e.before,y),Q(e.lines,y),Q(e.after,y)}),v=0,n.font=u.string,Q(e.footer,y),n.restore(),g+=m.width,{width:g,height:h}}function vg(e,t){let{y:n,height:r}=t;return n<r/2?`top`:n>e.height-r/2?`bottom`:`center`}function yg(e,t,n,r){let{x:i,width:a}=r,o=n.caretSize+n.caretPadding;if(e===`left`&&i+a+o>t.width||e===`right`&&i-a-o<0)return!0}function bg(e,t,n,r){let{x:i,width:a}=n,{width:o,chartArea:{left:s,right:c}}=e,l=`center`;return r===`center`?l=i<=(s+c)/2?`left`:`right`:i<=a/2?l=`left`:i>=o-a/2&&(l=`right`),yg(l,e,t,n)&&(l=`center`),l}function xg(e,t,n){let r=n.yAlign||t.yAlign||vg(e,n);return{xAlign:n.xAlign||t.xAlign||bg(e,t,n,r),yAlign:r}}function Sg(e,t){let{x:n,width:r}=e;return t===`right`?n-=r:t===`center`&&(n-=r/2),n}function Cg(e,t,n){let{y:r,height:i}=e;return t===`top`?r+=n:r-=t===`bottom`?i+n:i/2,r}function wg(e,t,n,r){let{caretSize:i,caretPadding:a,cornerRadius:o}=e,{xAlign:s,yAlign:c}=n,l=i+a,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=eu(o),m=Sg(t,s),h=Cg(t,c,l);return c===`center`?s===`left`?m+=l:s===`right`&&(m-=l):s===`left`?m-=Math.max(u,f)+i:s===`right`&&(m+=Math.max(d,p)+i),{x:Uc(m,0,r.width-t.width),y:Uc(h,0,r.height-t.height)}}function Tg(e,t,n){let r=tu(n.padding);return t===`center`?e.x+e.width/2:t===`right`?e.x+e.width-r.right:e.x+r.left}function Eg(e){return mg([],hg(e))}function Dg(e,t,n){return au(e,{tooltip:t,tooltipItems:n,type:`tooltip`})}function Og(e,t){let n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}var kg={beforeTitle:Xs,title(e){if(e.length>0){let t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode===`dataset`)return t.dataset.label||``;if(t.label)return t.label;if(r>0&&t.dataIndex<r)return n[t.dataIndex]}return``},afterTitle:Xs,beforeBody:Xs,beforeLabel:Xs,label(e){if(this&&this.options&&this.options.mode===`dataset`)return e.label+`: `+e.formattedValue||e.formattedValue;let t=e.dataset.label||``;t&&(t+=`: `);let n=e.formattedValue;return J(n)||(t+=n),t},labelColor(e){let t=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.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(e){let t=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:t.pointStyle,rotation:t.rotation}},afterLabel:Xs,afterBody:Xs,beforeFooter:Xs,footer:Xs,afterFooter:Xs};function Ag(e,t,n,r){let i=e[t].call(n,r);return i===void 0?kg[t].call(n,r):i}var jg=class extends mp{static positioners=pg;constructor(e){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=e.chart,this.options=e.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(e){this.options=e,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){let e=this._cachedAnimations;if(e)return e;let t=this.chart,n=this.options.setContext(this.getContext()),r=n.enabled&&t.options.animation&&n.animations,i=new Td(this.chart,r);return r._cacheable&&(this._cachedAnimations=Object.freeze(i)),i}getContext(){return this.$context||=Dg(this.chart.getContext(),this,this._tooltipItems)}getTitle(e,t){let{callbacks:n}=t,r=Ag(n,`beforeTitle`,this,e),i=Ag(n,`title`,this,e),a=Ag(n,`afterTitle`,this,e),o=[];return o=mg(o,hg(r)),o=mg(o,hg(i)),o=mg(o,hg(a)),o}getBeforeBody(e,t){return Eg(Ag(t.callbacks,`beforeBody`,this,e))}getBody(e,t){let{callbacks:n}=t,r=[];return Q(e,e=>{let t={before:[],lines:[],after:[]},i=Og(n,e);mg(t.before,hg(Ag(i,`beforeLabel`,this,e))),mg(t.lines,Ag(i,`label`,this,e)),mg(t.after,hg(Ag(i,`afterLabel`,this,e))),r.push(t)}),r}getAfterBody(e,t){return Eg(Ag(t.callbacks,`afterBody`,this,e))}getFooter(e,t){let{callbacks:n}=t,r=Ag(n,`beforeFooter`,this,e),i=Ag(n,`footer`,this,e),a=Ag(n,`afterFooter`,this,e),o=[];return o=mg(o,hg(r)),o=mg(o,hg(i)),o=mg(o,hg(a)),o}_createItems(e){let t=this._active,n=this.chart.data,r=[],i=[],a=[],o=[],s,c;for(s=0,c=t.length;s<c;++s)o.push(gg(this.chart,t[s]));return e.filter&&(o=o.filter((t,r,i)=>e.filter(t,r,i,n))),e.itemSort&&(o=o.sort((t,r)=>e.itemSort(t,r,n))),Q(o,t=>{let n=Og(e.callbacks,t);r.push(Ag(n,`labelColor`,this,t)),i.push(Ag(n,`labelPointStyle`,this,t)),a.push(Ag(n,`labelTextColor`,this,t))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=a,this.dataPoints=o,o}update(e,t){let n=this.options.setContext(this.getContext()),r=this._active,i,a=[];if(!r.length)this.opacity!==0&&(i={opacity:0});else{let e=pg[n.position].call(this,r,this._eventPosition);a=this._createItems(n),this.title=this.getTitle(a,n),this.beforeBody=this.getBeforeBody(a,n),this.body=this.getBody(a,n),this.afterBody=this.getAfterBody(a,n),this.footer=this.getFooter(a,n);let t=this._size=_g(this,n),o=Object.assign({},e,t),s=xg(this.chart,n,o),c=wg(n,o,s,this.chart);this.xAlign=s.xAlign,this.yAlign=s.yAlign,i={opacity:1,x:c.x,y:c.y,width:t.width,height:t.height,caretX:e.x,caretY:e.y}}this._tooltipItems=a,this.$context=void 0,i&&this._resolveAnimations().update(this,i),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:t})}drawCaret(e,t,n,r){let i=this.getCaretPosition(e,n,r);t.lineTo(i.x1,i.y1),t.lineTo(i.x2,i.y2),t.lineTo(i.x3,i.y3)}getCaretPosition(e,t,n){let{xAlign:r,yAlign:i}=this,{caretSize:a,cornerRadius:o}=n,{topLeft:s,topRight:c,bottomLeft:l,bottomRight:u}=eu(o),{x:d,y:f}=e,{width:p,height:m}=t,h,g,_,v,y,b;return i===`center`?(y=f+m/2,r===`left`?(h=d,g=h-a,v=y+a,b=y-a):(h=d+p,g=h+a,v=y-a,b=y+a),_=h):(g=r===`left`?d+Math.max(s,l)+a:r===`right`?d+p-Math.max(c,u)-a:this.caretX,i===`top`?(v=f,y=v-a,h=g-a,_=g+a):(v=f+m,y=v+a,h=g+a,_=g-a),b=v),{x1:h,x2:g,x3:_,y1:v,y2:y,y3:b}}drawTitle(e,t,n){let r=this.title,i=r.length,a,o,s;if(i){let c=rd(n.rtl,this.x,this.width);for(e.x=Tg(this,n.titleAlign,n),t.textAlign=c.textAlign(n.titleAlign),t.textBaseline=`middle`,a=nu(n.titleFont),o=n.titleSpacing,t.fillStyle=n.titleColor,t.font=a.string,s=0;s<i;++s)t.fillText(r[s],c.x(e.x),e.y+a.lineHeight/2),e.y+=a.lineHeight+o,s+1===i&&(e.y+=n.titleMarginBottom-o)}}_drawColorBox(e,t,n,r,i){let a=this.labelColors[n],o=this.labelPointStyles[n],{boxHeight:s,boxWidth:c}=i,l=nu(i.bodyFont),u=Tg(this,`left`,i),d=r.x(u),f=s<l.lineHeight?(l.lineHeight-s)/2:0,p=t.y+f;if(i.usePointStyle){let t={radius:Math.min(c,s)/2,pointStyle:o.pointStyle,rotation:o.rotation,borderWidth:1},n=r.leftForLtr(d,c)+c/2,l=p+s/2;e.strokeStyle=i.multiKeyBackground,e.fillStyle=i.multiKeyBackground,Il(e,t,n,l),e.strokeStyle=a.borderColor,e.fillStyle=a.backgroundColor,Il(e,t,n,l)}else{e.lineWidth=Y(a.borderWidth)?Math.max(...Object.values(a.borderWidth)):a.borderWidth||1,e.strokeStyle=a.borderColor,e.setLineDash(a.borderDash||[]),e.lineDashOffset=a.borderDashOffset||0;let t=r.leftForLtr(d,c),n=r.leftForLtr(r.xPlus(d,1),c-2),o=eu(a.borderRadius);Object.values(o).some(e=>e!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,ql(e,{x:t,y:p,w:c,h:s,radius:o}),e.fill(),e.stroke(),e.fillStyle=a.backgroundColor,e.beginPath(),ql(e,{x:n,y:p+1,w:c-2,h:s-2,radius:o}),e.fill()):(e.fillStyle=i.multiKeyBackground,e.fillRect(t,p,c,s),e.strokeRect(t,p,c,s),e.fillStyle=a.backgroundColor,e.fillRect(n,p+1,c-2,s-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,t,n){let{body:r}=this,{bodySpacing:i,bodyAlign:a,displayColors:o,boxHeight:s,boxWidth:c,boxPadding:l}=n,u=nu(n.bodyFont),d=u.lineHeight,f=0,p=rd(n.rtl,this.x,this.width),m=function(n){t.fillText(n,p.x(e.x+f),e.y+d/2),e.y+=d+i},h=p.textAlign(a),g,_,v,y,b,x,S;for(t.textAlign=a,t.textBaseline=`middle`,t.font=u.string,e.x=Tg(this,h,n),t.fillStyle=n.bodyColor,Q(this.beforeBody,m),f=o&&h!==`right`?a===`center`?c/2+l:c+2+l:0,y=0,x=r.length;y<x;++y){for(g=r[y],_=this.labelTextColors[y],t.fillStyle=_,Q(g.before,m),v=g.lines,o&&v.length&&(this._drawColorBox(t,e,y,p,n),d=Math.max(u.lineHeight,s)),b=0,S=v.length;b<S;++b)m(v[b]),d=u.lineHeight;Q(g.after,m)}f=0,d=u.lineHeight,Q(this.afterBody,m),e.y-=i}drawFooter(e,t,n){let r=this.footer,i=r.length,a,o;if(i){let s=rd(n.rtl,this.x,this.width);for(e.x=Tg(this,n.footerAlign,n),e.y+=n.footerMarginTop,t.textAlign=s.textAlign(n.footerAlign),t.textBaseline=`middle`,a=nu(n.footerFont),t.fillStyle=n.footerColor,t.font=a.string,o=0;o<i;++o)t.fillText(r[o],s.x(e.x),e.y+a.lineHeight/2),e.y+=a.lineHeight+n.footerSpacing}}drawBackground(e,t,n,r){let{xAlign:i,yAlign:a}=this,{x:o,y:s}=e,{width:c,height:l}=n,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=eu(r.cornerRadius);t.fillStyle=r.backgroundColor,t.strokeStyle=r.borderColor,t.lineWidth=r.borderWidth,t.beginPath(),t.moveTo(o+u,s),a===`top`&&this.drawCaret(e,t,n,r),t.lineTo(o+c-d,s),t.quadraticCurveTo(o+c,s,o+c,s+d),a===`center`&&i===`right`&&this.drawCaret(e,t,n,r),t.lineTo(o+c,s+l-p),t.quadraticCurveTo(o+c,s+l,o+c-p,s+l),a===`bottom`&&this.drawCaret(e,t,n,r),t.lineTo(o+f,s+l),t.quadraticCurveTo(o,s+l,o,s+l-f),a===`center`&&i===`left`&&this.drawCaret(e,t,n,r),t.lineTo(o,s+u),t.quadraticCurveTo(o,s,o+u,s),t.closePath(),t.fill(),r.borderWidth>0&&t.stroke()}_updateAnimationTarget(e){let t=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){let n=pg[e.position].call(this,this._active,this._eventPosition);if(!n)return;let a=this._size=_g(this,e),o=Object.assign({},n,this._size),s=xg(t,e,o),c=wg(e,o,s,t);(r._to!==c.x||i._to!==c.y)&&(this.xAlign=s.xAlign,this.yAlign=s.yAlign,this.width=a.width,this.height=a.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(e){let t=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(t);let r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let a=tu(t.padding),o=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;t.enabled&&o&&(e.save(),e.globalAlpha=n,this.drawBackground(i,e,r,t),id(e,t.textDirection),i.y+=a.top,this.drawTitle(i,e,t),this.drawBody(i,e,t),this.drawFooter(i,e,t),ad(e,t.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,t){let n=this._active,r=e.map(({datasetIndex:e,index:t})=>{let n=this.chart.getDatasetMeta(e);if(!n)throw Error(`Cannot find a dataset at index `+e);return{datasetIndex:e,element:n.data[t],index:t}}),i=!rc(n,r),a=this._positionChanged(r,t);(i||a)&&(this._active=r,this._eventPosition=t,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,t,n=!0){if(t&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let r=this.options,i=this._active||[],a=this._getActiveElements(e,i,t,n),o=this._positionChanged(a,e),s=t||!rc(a,i)||o;return s&&(this._active=a,(r.enabled||r.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,t))),s}_getActiveElements(e,t,n,r){let i=this.options;if(e.type===`mouseout`)return[];if(!r)return t.filter(e=>this.chart.data.datasets[e.datasetIndex]&&this.chart.getDatasetMeta(e.datasetIndex).controller.getParsed(e.index)!==void 0);let a=this.chart.getElementsAtEventForMode(e,i.mode,i,n);return i.reverse&&a.reverse(),a}_positionChanged(e,t){let{caretX:n,caretY:r,options:i}=this,a=pg[i.position].call(this,e,t);return a!==!1&&(n!==a.x||r!==a.y)}},Mg=Object.freeze({__proto__:null,Colors:hh,Decimation:xh,Filler:Qh,Legend:sg,SubTitle:fg,Title:ug,Tooltip:{id:`tooltip`,_element:jg,positioners:pg,afterInit(e,t,n){n&&(e.tooltip=new jg({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){let t=e.tooltip;if(t&&t._willRender()){let n={tooltip:t};if(e.notifyPlugins(`beforeTooltipDraw`,{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins(`afterTooltipDraw`,n)}},afterEvent(e,t){if(e.tooltip){let n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.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:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.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:kg},defaultRoutes:{bodyFont:`font`,footerFont:`font`,titleFont:`font`},descriptors:{_scriptable:e=>e!==`filter`&&e!==`itemSort`&&e!==`external`,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:`animation`}},additionalOptionScopes:[`interaction`]}}),Ng=(e,t,n,r)=>(typeof t==`string`?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Pg(e,t,n,r){let i=e.indexOf(t);return i===-1?Ng(e,t,n,r):i===e.lastIndexOf(t)?i:n}var Fg=(e,t)=>e===null?null:Uc(Math.round(e),0,t);function Ig(e){let t=this.getLabels();return e>=0&&e<t.length?t[e]:e}var Lg=class extends Pp{static id=`category`;static defaults={ticks:{callback:Ig}};constructor(e){super(e),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(e){let t=this._addedLabels;if(t.length){let e=this.getLabels();for(let{index:n,label:r}of t)e[n]===r&&e.splice(n,1);this._addedLabels=[]}super.init(e)}parse(e,t){if(J(e))return null;let n=this.getLabels();return t=isFinite(t)&&n[t]===e?t:Pg(n,e,X(t,e),this._addedLabels),Fg(t,n.length-1)}determineDataLimits(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),{min:n,max:r}=this.getMinMax(!0);this.options.bounds===`ticks`&&(e||(n=0),t||(r=this.getLabels().length-1)),this.min=n,this.max=r}buildTicks(){let e=this.min,t=this.max,n=this.options.offset,r=[],i=this.getLabels();i=e===0&&t===i.length-1?i:i.slice(e,t+1),this._valueRange=Math.max(i.length-+!n,1),this._startValue=this.min-(n?.5:0);for(let n=e;n<=t;n++)r.push({value:n});return r}getLabelForValue(e){return Ig.call(this,e)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(e){return typeof e!=`number`&&(e=this.parse(e)),e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getPixelForTick(e){let t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}};function Rg(e,t){let n=[],{bounds:r,step:i,min:a,max:o,precision:s,count:c,maxTicks:l,maxDigits:u,includeBounds:d}=e,f=i||1,p=l-1,{min:m,max:h}=t,g=!J(a),_=!J(o),v=!J(c),y=(h-m)/(u+1),b=kc((h-m)/p/f)*f,x,S,C,w;if(b<1e-14&&!g&&!_)return[{value:m},{value:h}];w=Math.ceil(h/b)-Math.floor(m/b),w>p&&(b=kc(w*b/p/f)*f),J(s)||(x=10**s,b=Math.ceil(b*x)/x),r===`ticks`?(S=Math.floor(m/b)*b,C=Math.ceil(h/b)*b):(S=m,C=h),g&&_&&i&&Nc((o-a)/i,b/1e3)?(w=Math.round(Math.min((o-a)/b,l)),b=(o-a)/w,S=a,C=o):v?(S=g?a:S,C=_?o:C,w=c-1,b=(C-S)/w):(w=(C-S)/b,w=Oc(w,Math.round(w),b/1e3)?Math.round(w):Math.ceil(w));let T=Math.max(Lc(b),Lc(S));x=10**(J(s)?T:s),S=Math.round(S*x)/x,C=Math.round(C*x)/x;let E=0;for(g&&(d&&S!==a?(n.push({value:a}),S<a&&E++,Oc(Math.round((S+E*b)*x)/x,a,zg(a,y,e))&&E++):S<a&&E++);E<w;++E){let e=Math.round((S+E*b)*x)/x;if(_&&e>o)break;n.push({value:e})}return _&&d&&C!==o?n.length&&Oc(n[n.length-1].value,o,zg(o,y,e))?n[n.length-1].value=o:n.push({value:o}):(!_||C===o)&&n.push({value:C}),n}function zg(e,t,{horizontal:n,minRotation:r}){let i=Fc(r),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(``+e).length;return Math.min(t/a,o)}var Bg=class extends Pp{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,t){return J(e)||(typeof e==`number`||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){let{beginAtZero:e}=this.options,{minDefined:t,maxDefined:n}=this.getUserBounds(),{min:r,max:i}=this,a=e=>r=t?r:e,o=e=>i=n?i:e;if(e){let e=Dc(r),t=Dc(i);e<0&&t<0?o(0):e>0&&t>0&&a(0)}if(r===i){let t=i===0?1:Math.abs(i*.05);o(i+t),e||a(r-t)}this.min=r,this.max=i}getTickLimit(){let{maxTicksLimit:e,stepSize:t}=this.options.ticks,n;return t?(n=Math.ceil(this.max/t)-Math.floor(this.min/t)+1,n>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${t} would result generating up to ${n} ticks. Limiting to 1000.`),n=1e3)):(n=this.computeTickLimit(),e||=11),e&&(n=Math.min(e,n)),n}computeTickLimit(){return 1/0}buildTicks(){let e=this.options,t=e.ticks,n=this.getTickLimit();n=Math.max(2,n);let r=Rg({maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:t.precision,step:t.stepSize,count:t.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:t.minRotation||0,includeBounds:t.includeBounds!==!1},this._range||this);return e.bounds===`ticks`&&Pc(r,this,`value`),e.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){let e=this.ticks,t=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){let r=(n-t)/Math.max(e.length-1,1)/2;t-=r,n+=r}this._startValue=t,this._endValue=n,this._valueRange=n-t}getLabelForValue(e){return xl(e,this.chart.options.locale,this.options.ticks.format)}},Vg=class extends Bg{static id=`linear`;static defaults={ticks:{callback:wl.formatters.numeric}};determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=$s(e)?e:0,this.max=$s(t)?t:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),t=e?this.width:this.height,n=Fc(this.options.ticks.minRotation),r=(e?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(t/Math.min(40,i.lineHeight/r))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}},Hg=e=>Math.floor(Ec(e)),Ug=(e,t)=>10**(Hg(e)+t);function Wg(e){return e/10**Hg(e)==1}function Gg(e,t,n){let r=10**n,i=Math.floor(e/r);return Math.ceil(t/r)-i}function Kg(e,t){let n=Hg(t-e);for(;Gg(e,t,n)>10;)n++;for(;Gg(e,t,n)<10;)n--;return Math.min(n,Hg(e))}function qg(e,{min:t,max:n}){t=ec(e.min,t);let r=[],i=Hg(t),a=Kg(t,n),o=a<0?10**Math.abs(a):1,s=10**a,c=i>a?10**i:0,l=Math.round((t-c)*o)/o,u=Math.floor((t-c)/s/10)*s*10,d=Math.floor((l-u)/10**a),f=ec(e.min,Math.round((c+u+d*10**a)*o)/o);for(;f<n;)r.push({value:f,major:Wg(f),significand:d}),d>=10?d=d<15?15:20:d++,d>=20&&(a++,d=2,o=a>=0?1:o),f=Math.round((c+u+d*10**a)*o)/o;let p=ec(e.max,f);return r.push({value:p,major:Wg(p),significand:d}),r}var Jg=class extends Pp{static id=`logarithmic`;static defaults={ticks:{callback:wl.formatters.logarithmic,major:{enabled:!0}}};constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,t){let n=Bg.prototype.parse.apply(this,[e,t]);if(n===0){this._zero=!0;return}return $s(n)&&n>0?n:null}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=$s(e)?Math.max(0,e):null,this.max=$s(t)?Math.max(0,t):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!$s(this._userMin)&&(this.min=e===Ug(this.min,0)?Ug(this.min,-1):Ug(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),n=this.min,r=this.max,i=t=>n=e?n:t,a=e=>r=t?r:e;n===r&&(n<=0?(i(1),a(10)):(i(Ug(n,-1)),a(Ug(r,1)))),n<=0&&i(Ug(r,-1)),r<=0&&a(Ug(n,1)),this.min=n,this.max=r}buildTicks(){let e=this.options,t=qg({min:this._userMin,max:this._userMax},this);return e.bounds===`ticks`&&Pc(t,this,`value`),e.reverse?(t.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),t}getLabelForValue(e){return e===void 0?`0`:xl(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=Ec(e),this._valueRange=Ec(this.max)-Ec(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(Ec(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let t=this.getDecimalForPixel(e);return 10**(this._startValue+t*this._valueRange)}};function Yg(e){let t=e.ticks;if(t.display&&e.display){let e=tu(t.backdropPadding);return X(t.font&&t.font.size,Al.font.size)+e.height}return 0}function Xg(e,t,n){return n=Qs(n)?n:[n],{w:Nl(e,t.string,n),h:n.length*t.lineHeight}}function Zg(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:e<r||e>i?{start:t-n,end:t}:{start:t,end:t+n}}function Qg(e){let t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],a=e._pointLabels.length,o=e.options.pointLabels,s=o.centerPointLabels?$/a:0;for(let c=0;c<a;c++){let a=o.setContext(e.getPointLabelContext(c));i[c]=a.padding;let l=e.getPointPosition(c,e.drawingArea+i[c],s),u=nu(a.font),d=Xg(e.ctx,u,e._pointLabels[c]);r[c]=d;let f=Vc(e.getIndexAngle(c)+s),p=Math.round(Ic(f));$g(n,t,f,Zg(p,l.x,d.w,0,180),Zg(p,l.y,d.h,90,270))}e.setCenterPoint(t.l-n.l,n.r-t.r,t.t-n.t,n.b-t.b),e._pointLabelItems=n_(e,r,i)}function $g(e,t,n,r,i){let a=Math.abs(Math.sin(n)),o=Math.abs(Math.cos(n)),s=0,c=0;r.start<t.l?(s=(t.l-r.start)/a,e.l=Math.min(e.l,t.l-s)):r.end>t.r&&(s=(r.end-t.r)/a,e.r=Math.max(e.r,t.r+s)),i.start<t.t?(c=(t.t-i.start)/o,e.t=Math.min(e.t,t.t-c)):i.end>t.b&&(c=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+c))}function e_(e,t,n){let r=e.drawingArea,{extra:i,additionalAngle:a,padding:o,size:s}=n,c=e.getPointPosition(t,r+i+o,a),l=Math.round(Ic(Vc(c.angle+Cc))),u=a_(c.y,s.h,l),d=r_(l),f=i_(c.x,s.w,d);return{visible:!0,x:c.x,y:u,textAlign:d,left:f,top:u,right:f+s.w,bottom:u+s.h}}function t_(e,t){if(!t)return!0;let{left:n,top:r,right:i,bottom:a}=e;return!(Rl({x:n,y:r},t)||Rl({x:n,y:a},t)||Rl({x:i,y:r},t)||Rl({x:i,y:a},t))}function n_(e,t,n){let r=[],i=e._pointLabels.length,a=e.options,{centerPointLabels:o,display:s}=a.pointLabels,c={extra:Yg(a)/2,additionalAngle:o?$/i:0},l;for(let a=0;a<i;a++){c.padding=n[a],c.size=t[a];let i=e_(e,a,c);r.push(i),s===`auto`&&(i.visible=t_(i,l),i.visible&&(l=i))}return r}function r_(e){return e===0||e===180?`center`:e<180?`left`:`right`}function i_(e,t,n){return n===`right`?e-=t:n===`center`&&(e-=t/2),e}function a_(e,t,n){return n===90||n===270?e-=t/2:(n>270||n<90)&&(e-=t),e}function o_(e,t,n){let{left:r,top:i,right:a,bottom:o}=n,{backdropColor:s}=t;if(!J(s)){let n=eu(t.borderRadius),c=tu(t.backdropPadding);e.fillStyle=s;let l=r-c.left,u=i-c.top,d=a-r+c.width,f=o-i+c.height;Object.values(n).some(e=>e!==0)?(e.beginPath(),ql(e,{x:l,y:u,w:d,h:f,radius:n}),e.fill()):e.fillRect(l,u,d,f)}}function s_(e,t){let{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){let t=e._pointLabelItems[i];if(!t.visible)continue;let a=r.setContext(e.getPointLabelContext(i));o_(n,a,t);let o=nu(a.font),{x:s,y:c,textAlign:l}=t;Kl(n,e._pointLabels[i],s,c+o.lineHeight/2,o,{color:a.color,textAlign:l,textBaseline:`middle`})}}function c_(e,t,n,r){let{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,yc);else{let n=e.getPointPosition(0,t);i.moveTo(n.x,n.y);for(let a=1;a<r;a++)n=e.getPointPosition(a,t),i.lineTo(n.x,n.y)}}function l_(e,t,n,r,i){let a=e.ctx,o=t.circular,{color:s,lineWidth:c}=t;!o&&!r||!s||!c||n<0||(a.save(),a.strokeStyle=s,a.lineWidth=c,a.setLineDash(i.dash||[]),a.lineDashOffset=i.dashOffset,a.beginPath(),c_(e,n,o,r),a.closePath(),a.stroke(),a.restore())}function u_(e,t,n){return au(e,{label:n,index:t,type:`pointLabel`})}var d_=class extends Bg{static id=`radialLinear`;static defaults={display:!0,animate:!0,position:`chartArea`,angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:wl.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(e){return e},padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":`borderColor`,"pointLabels.color":`color`,"ticks.color":`color`};static descriptors={angleLines:{_fallback:`grid`}};constructor(e){super(e),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){let e=this._padding=tu(Yg(this.options)/2),t=this.width=this.maxWidth-e.width,n=this.height=this.maxHeight-e.height;this.xCenter=Math.floor(this.left+t/2+e.left),this.yCenter=Math.floor(this.top+n/2+e.top),this.drawingArea=Math.floor(Math.min(t,n)/2)}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!1);this.min=$s(e)&&!isNaN(e)?e:0,this.max=$s(t)&&!isNaN(t)?t:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/Yg(this.options))}generateTickLabels(e){Bg.prototype.generateTickLabels.call(this,e),this._pointLabels=this.getLabels().map((e,t)=>{let n=Z(this.options.pointLabels.callback,[e,t],this);return n||n===0?n:``}).filter((e,t)=>this.chart.getDataVisibility(t))}fit(){let e=this.options;e.display&&e.pointLabels.display?Qg(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,t,n,r){this.xCenter+=Math.floor((e-t)/2),this.yCenter+=Math.floor((n-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,t,n,r))}getIndexAngle(e){let t=yc/(this._pointLabels.length||1),n=this.options.startAngle||0;return Vc(e*t+Fc(n))}getDistanceFromCenterForValue(e){if(J(e))return NaN;let t=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*t:(e-this.min)*t}getValueForDistanceFromCenter(e){if(J(e))return NaN;let t=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-t:this.min+t}getPointLabelContext(e){let t=this._pointLabels||[];if(e>=0&&e<t.length){let n=t[e];return u_(this.getContext(),e,n)}}getPointPosition(e,t,n=0){let r=this.getIndexAngle(e)-Cc+n;return{x:Math.cos(r)*t+this.xCenter,y:Math.sin(r)*t+this.yCenter,angle:r}}getPointPositionForValue(e,t){return this.getPointPosition(e,this.getDistanceFromCenterForValue(t))}getBasePosition(e){return this.getPointPositionForValue(e||0,this.getBaseValue())}getPointLabelPosition(e){let{left:t,top:n,right:r,bottom:i}=this._pointLabelItems[e];return{left:t,top:n,right:r,bottom:i}}drawBackground(){let{backgroundColor:e,grid:{circular:t}}=this.options;if(e){let n=this.ctx;n.save(),n.beginPath(),c_(this,this.getDistanceFromCenterForValue(this._endValue),t,this._pointLabels.length),n.closePath(),n.fillStyle=e,n.fill(),n.restore()}}drawGrid(){let e=this.ctx,t=this.options,{angleLines:n,grid:r,border:i}=t,a=this._pointLabels.length,o,s,c;if(t.pointLabels.display&&s_(this,a),r.display&&this.ticks.forEach((e,t)=>{if(t!==0||t===0&&this.min<0){s=this.getDistanceFromCenterForValue(e.value);let n=this.getContext(t),o=r.setContext(n),c=i.setContext(n);l_(this,o,s,a,c)}}),n.display){for(e.save(),o=a-1;o>=0;o--){let r=n.setContext(this.getPointLabelContext(o)),{color:i,lineWidth:a}=r;!a||!i||(e.lineWidth=a,e.strokeStyle=i,e.setLineDash(r.borderDash),e.lineDashOffset=r.borderDashOffset,s=this.getDistanceFromCenterForValue(t.reverse?this.min:this.max),c=this.getPointPosition(o,s),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){let e=this.ctx,t=this.options,n=t.ticks;if(!n.display)return;let r=this.getIndexAngle(0),i,a;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(r),e.textAlign=`center`,e.textBaseline=`middle`,this.ticks.forEach((r,o)=>{if(o===0&&this.min>=0&&!t.reverse)return;let s=n.setContext(this.getContext(o)),c=nu(s.font);if(i=this.getDistanceFromCenterForValue(this.ticks[o].value),s.showLabelBackdrop){e.font=c.string,a=e.measureText(r.label).width,e.fillStyle=s.backdropColor;let t=tu(s.backdropPadding);e.fillRect(-a/2-t.left,-i-c.size/2-t.top,a+t.width,c.size+t.height)}Kl(e,r.label,0,-i,c,{color:s.color,strokeColor:s.textStrokeColor,strokeWidth:s.textStrokeWidth})}),e.restore()}drawTitle(){}},f_={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},p_=Object.keys(f_);function m_(e,t){return e-t}function h_(e,t){if(J(t))return null;let n=e._adapter,{parser:r,round:i,isoWeekday:a}=e._parseOpts,o=t;return typeof r==`function`&&(o=r(o)),$s(o)||(o=typeof r==`string`?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i===`week`&&(Mc(a)||a===!0)?n.startOf(o,`isoWeek`,a):n.startOf(o,i)),+o)}function g_(e,t,n,r){let i=p_.length;for(let a=p_.indexOf(e);a<i-1;++a){let e=f_[p_[a]],i=e.steps?e.steps:2**53-1;if(e.common&&Math.ceil((n-t)/(i*e.size))<=r)return p_[a]}return p_[i-1]}function __(e,t,n,r,i){for(let a=p_.length-1;a>=p_.indexOf(n);a--){let n=p_[a];if(f_[n].common&&e._adapter.diff(i,r,n)>=t-1)return n}return p_[n?p_.indexOf(n):0]}function v_(e){for(let t=p_.indexOf(e)+1,n=p_.length;t<n;++t)if(f_[p_[t]].common)return p_[t]}function y_(e,t,n){if(!n)e[t]=!0;else if(n.length){let{lo:r,hi:i}=Kc(n,t),a=n[r]>=t?n[r]:n[i];e[a]=!0}}function b_(e,t,n,r){let i=e._adapter,a=+i.startOf(t[0].value,r),o=t[t.length-1].value,s,c;for(s=a;s<=o;s=+i.add(s,1,r))c=n[s],c>=0&&(t[c].major=!0);return t}function x_(e,t,n){let r=[],i={},a=t.length,o,s;for(o=0;o<a;++o)s=t[o],i[s]=o,r.push({value:s,major:!1});return a===0||!n?r:b_(e,r,i,n)}var S_=class extends Pp{static id=`time`;static defaults={bounds:`data`,adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:`millisecond`,displayFormats:{}},ticks:{source:`auto`,callback:!1,major:{enabled:!1}}};constructor(e){super(e),this._cache={data:[],labels:[],all:[]},this._unit=`day`,this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(e,t={}){let n=e.time||={},r=this._adapter=new vf._date(e.adapters.date);r.init(t),cc(n.displayFormats,r.formats()),this._parseOpts={parser:n.parser,round:n.round,isoWeekday:n.isoWeekday},super.init(e),this._normalized=t.normalized}parse(e,t){return e===void 0?null:h_(this,e)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){let e=this.options,t=this._adapter,n=e.time.unit||`day`,{min:r,max:i,minDefined:a,maxDefined:o}=this.getUserBounds();function s(e){!a&&!isNaN(e.min)&&(r=Math.min(r,e.min)),!o&&!isNaN(e.max)&&(i=Math.max(i,e.max))}(!a||!o)&&(s(this._getLabelBounds()),(e.bounds!==`ticks`||e.ticks.source!==`labels`)&&s(this.getMinMax(!1))),r=$s(r)&&!isNaN(r)?r:+t.startOf(Date.now(),n),i=$s(i)&&!isNaN(i)?i:+t.endOf(Date.now(),n)+1,this.min=Math.min(r,i-1),this.max=Math.max(r+1,i)}_getLabelBounds(){let e=this.getLabelTimestamps(),t=1/0,n=-1/0;return e.length&&(t=e[0],n=e[e.length-1]),{min:t,max:n}}buildTicks(){let e=this.options,t=e.time,n=e.ticks,r=n.source===`labels`?this.getLabelTimestamps():this._generate();e.bounds===`ticks`&&r.length&&(this.min=this._userMin||r[0],this.max=this._userMax||r[r.length-1]);let i=this.min,a=this.max,o=Yc(r,i,a);return this._unit=t.unit||(n.autoSkip?g_(t.minUnit,this.min,this.max,this._getLabelCapacity(i)):__(this,o.length,t.minUnit,this.min,this.max)),this._majorUnit=!n.major.enabled||this._unit===`year`?void 0:v_(this._unit),this.initOffsets(r),e.reverse&&o.reverse(),x_(this,o,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(e=>+e.value))}initOffsets(e=[]){let t=0,n=0,r,i;this.options.offset&&e.length&&(r=this.getDecimalForValue(e[0]),t=e.length===1?1-r:(this.getDecimalForValue(e[1])-r)/2,i=this.getDecimalForValue(e[e.length-1]),n=e.length===1?i:(i-this.getDecimalForValue(e[e.length-2]))/2);let a=e.length<3?.5:.25;t=Uc(t,0,a),n=Uc(n,0,a),this._offsets={start:t,end:n,factor:1/(t+1+n)}}_generate(){let e=this._adapter,t=this.min,n=this.max,r=this.options,i=r.time,a=i.unit||g_(i.minUnit,t,n,this._getLabelCapacity(t)),o=X(r.ticks.stepSize,1),s=a===`week`&&i.isoWeekday,c=Mc(s)||s===!0,l={},u=t,d,f;if(c&&(u=+e.startOf(u,`isoWeek`,s)),u=+e.startOf(u,c?`day`:a),e.diff(n,t,a)>1e5*o)throw Error(t+` and `+n+` are too far apart with stepSize of `+o+` `+a);let p=r.ticks.source===`data`&&this.getDataTimestamps();for(d=u,f=0;d<n;d=+e.add(d,o,a),f++)y_(l,d,p);return(d===n||r.bounds===`ticks`||f===1)&&y_(l,d,p),Object.keys(l).sort(m_).map(e=>+e)}getLabelForValue(e){let t=this._adapter,n=this.options.time;return n.tooltipFormat?t.format(e,n.tooltipFormat):t.format(e,n.displayFormats.datetime)}format(e,t){let n=this.options.time.displayFormats,r=this._unit,i=t||n[r];return this._adapter.format(e,i)}_tickFormatFunction(e,t,n,r){let i=this.options,a=i.ticks.callback;if(a)return Z(a,[e,t,n],this);let o=i.time.displayFormats,s=this._unit,c=this._majorUnit,l=s&&o[s],u=c&&o[c],d=n[t],f=c&&u&&d&&d.major;return this._adapter.format(e,r||(f?u:l))}generateTickLabels(e){let t,n,r;for(t=0,n=e.length;t<n;++t)r=e[t],r.label=this._tickFormatFunction(r.value,t,e)}getDecimalForValue(e){return e===null?NaN:(e-this.min)/(this.max-this.min)}getPixelForValue(e){let t=this._offsets,n=this.getDecimalForValue(e);return this.getPixelForDecimal((t.start+n)*t.factor)}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return this.min+n*(this.max-this.min)}_getLabelSize(e){let t=this.options.ticks,n=this.ctx.measureText(e).width,r=Fc(this.isHorizontal()?t.maxRotation:t.minRotation),i=Math.cos(r),a=Math.sin(r),o=this._resolveTickFontOptions(0).size;return{w:n*i+o*a,h:n*a+o*i}}_getLabelCapacity(e){let t=this.options.time,n=t.displayFormats,r=n[t.unit]||n.millisecond,i=this._tickFormatFunction(e,0,x_(this,[e],this._majorUnit),r),a=this._getLabelSize(i),o=Math.floor(this.isHorizontal()?this.width/a.w:this.height/a.h)-1;return o>0?o:1}getDataTimestamps(){let e=this._cache.data||[],t,n;if(e.length)return e;let r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(t=0,n=r.length;t<n;++t)e=e.concat(r[t].controller.getAllParsedValues(this));return this._cache.data=this.normalize(e)}getLabelTimestamps(){let e=this._cache.labels||[],t,n;if(e.length)return e;let r=this.getLabels();for(t=0,n=r.length;t<n;++t)e.push(h_(this,r[t]));return this._cache.labels=this._normalized?e:this.normalize(e)}normalize(e){return $c(e.sort(m_))}};function C_(e,t,n){let r=0,i=e.length-1,a,o,s,c;n?(t>=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=qc(e,`pos`,t)),{pos:a,time:s}=e[r],{pos:o,time:c}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=qc(e,`time`,t)),{time:a,pos:s}=e[r],{time:o,pos:c}=e[i]);let l=o-a;return l?s+(c-s)*(t-a)/l:s}var w_=class extends S_{static id=`timeseries`;static defaults=S_.defaults;constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let e=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(e);this._minPos=C_(t,this.min),this._tableRange=C_(t,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){let{min:t,max:n}=this,r=[],i=[],a,o,s,c,l;for(a=0,o=e.length;a<o;++a)c=e[a],c>=t&&c<=n&&r.push(c);if(r.length<2)return[{time:t,pos:0},{time:n,pos:1}];for(a=0,o=r.length;a<o;++a)l=r[a+1],s=r[a-1],c=r[a],Math.round((l+s)/2)!==c&&i.push({time:c,pos:a/(o-1)});return i}_generate(){let e=this.min,t=this.max,n=super.getDataTimestamps();return(!n.includes(e)||!n.length)&&n.splice(0,0,e),(!n.includes(t)||n.length===1)&&n.push(t),n.sort((e,t)=>e-t)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;let t=this.getDataTimestamps(),n=this.getLabelTimestamps();return e=t.length&&n.length?this.normalize(t.concat(n)):t.length?t:n,e=this._cache.all=e,e}getDecimalForValue(e){return(C_(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return C_(this._table,n*this._tableRange+this._minPos,!0)}},T_=[gf,rh,Mg,Object.freeze({__proto__:null,CategoryScale:Lg,LinearScale:Vg,LogarithmicScale:Jg,RadialLinearScale:d_,TimeScale:S_,TimeSeriesScale:w_})];Sm.register(...T_);var E_=e=>new Sm(e,{type:`bar`,data:{datasets:[]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1},tooltip:{position:`average`,intersect:!1,mode:`index`,caretPadding:10,caretSize:8}},scales:{y:{beginAtZero:!0},y1:{beginAtZero:!0,position:`right`,grid:{drawOnChartArea:!1}}},hover:{mode:`index`,intersect:!1},onHover:(e,t,n)=>{let r;r=t.length?(t[0].element.x+t[t.length-1].element.x)/2:null,r!==n.hoveredPosition&&(n.hoveredPosition=r,n.update(`none`))}},plugins:[{id:`highlightXAxisBand`,beforeDatasetsDraw(e,t,n){let{ctx:r,hoveredPosition:i,scales:{x:a,y:o}}=e;if(!i||!a||!o)return;let s=a.ticks.length>0?a.chart.chartArea.width/a.ticks.length:0,c=i-s/2;r.save(),r.fillStyle=`#3366CC11`,r.fillRect(c,o.top,s,o.height),r.restore()}}]}),D_=U(`<div class="relative w-full aspect-video pr-4"><canvas></canvas></div>`);function O_(e,t){qe(t,!0);let n=N(void 0),r;na(()=>(Sm.defaults.font.size=18,r=E_(V(n)),a(),i(),r.update(),()=>r?.destroy()));let i=()=>{r.options.plugins?.tooltip&&(r.options.plugins.tooltip.mode=t.chartConfig.time_series?`index`:`x`,r.options.plugins.tooltip.yAlign=t.chartConfig.time_series?void 0:`bottom`),r.options.hover&&(r.options.hover.mode=t.chartConfig.time_series?`index`:`x`)};Dn(()=>{r&&(i(),r.update())});let a=()=>{if(!r||!t.data)return;let e=!1,n=!1;r.data.datasets=t.data.map(r=>(r.axis===`right`?n=!0:e=!0,{label:r.label,data:r.data,yAxisID:r.axis===`right`?`y1`:`y`,fill:!1,skipNull:!t.chartConfig.time_series})),r.options.plugins?.legend&&(r.options.plugins.legend.display=!!t.chartConfig.time_series),r.options.scales?.y&&(r.options.scales.y.display=e),r.options.scales?.y1&&(r.options.scales.y1.display=n),r.hoveredPosition=null};Dn(()=>{r&&(a(),r.update())});var o=D_();Qi(F(o),e=>P(n,e),()=>V(n)),A(o),W(e,o),Je()}var k_=U(`<p class="text-gray-500 leading-none">&hellip;</p>`),A_=U(`<button type="button" class="ghost bg-night-700 text-white" disabled=""> </button>`),j_=U(`<button type="button" class="ghost"> </button>`),M_=U(`<div></div>`);function N_(e,t){qe(t,!0);let n=ta(t,`class`,3,``),r=j(()=>Math.ceil(t.totalItems/t.perPage)),i=j(()=>{let e=[];t.page>3&&e.push(1),t.page>4&&e.push(`...`);let n=Math.min(t.page+2,V(r));for(let r=Math.max(1,t.page-2);r<=n;r++)e.push(r);return t.page<V(r)-3&&e.push(`...`),t.page<V(r)-2&&e.push(V(r)),e});var a=Kr(),o=I(a),s=e=>{var r=M_();q(r,21,()=>V(i),ei,(e,n)=>{var r=Kr(),i=I(r),a=e=>{W(e,k_())},o=e=>{var t=A_(),r=F(t,!0);A(t),R(()=>G(r,V(n))),W(e,t)},s=e=>{var r=j_(),i=F(r,!0);A(r),R(()=>G(i,V(n))),H(`click`,r,()=>t.setPage(V(n))),W(e,r)};K(i,e=>{V(n)===`...`?e(a):V(n)===t.page?e(o,1):e(s,-1)}),W(e,r)}),A(r),R(()=>bi(r,1,`grid grid-flow-col grid-cols-fr gap-2 items-baseline w-max mx-auto ${n()??``}`)),W(e,r)};K(o,e=>{V(r)>1&&e(s)}),W(e,a),Je()}Ir([`click`]);var P_=U(`<th> </th>`),F_=U(`<td><!></td>`),I_=U(`<tr></tr>`),L_=U(`<div><table><thead><tr></tr></thead><tbody></tbody></table> <!></div>`);function R_(e,t){qe(t,!0);let n=ta(t,`chartFilters`,7),r=N(1),i=N(1),a=j(()=>typeof t.chartMetadata.resultOffset==`number`?t.chartMetadata.resultOffset/10:null),o=e=>V(a)!==null&&e>V(a)&&e<=V(a)+10,s=j(()=>t.loading||!o(V(r))),c=j(()=>t.chartMetadata.resultCount),l=j(()=>Math.ceil(V(c)/10)),u=j(()=>Math.max(1,Math.min(V(r),V(l)??1))),d=j(()=>((V(s)?V(i):V(u))-1)%10*10),f=j(()=>t.chartConfig.datasets[0]),p=j(()=>{let e;return V(f)&&Fa(V(f))&&(V(f).selects?.length?e=V(f).selects:Oa[V(f).type]&&(e=Object.entries(Oa[V(f).type]?.fields??{}).flatMap(([e,t])=>t.select?[e]:[]))),e??=Object.keys(t.data[0]),e.flatMap(e=>{if(!V(f))return[];let{datasetType:t,field:n,fieldSchema:r}=za(V(f),e);return[{label:Ha(n,t),value:e,type:r?.type??`string`}]})}),m=e=>{o(e)||(P(i,V(r),!0),n().page=e-(e-1)%10),P(r,e,!0)};var h=L_(),g=F(h),_=F(g),v=F(_);q(v,21,()=>V(p),ei,(e,t)=>{var n=P_(),r=F(n,!0);A(n),R(()=>G(r,V(t).label)),W(e,n)}),A(v),A(_);var y=L(_);q(y,21,()=>Array(10),ei,(e,n,r)=>{let i=j(()=>t.data[V(d)+r]);var a=Kr(),o=I(a),s=e=>{var t=I_();q(t,21,()=>V(p),ei,(e,t)=>{var n=F_(),r=F(n),a=e=>{var n=Gr();R(e=>G(n,e),[()=>Ma(V(i)[V(t).value],`day`)]),W(e,n)},o=e=>{var n=Gr();R(()=>G(n,V(i)[V(t).value]?`Yes`:`No`)),W(e,n)},s=e=>{var n=Gr();R(()=>G(n,V(i)[V(t).value])),W(e,n)};K(r,e=>{V(t).type===`date`?e(a):V(t).type===`boolean`?e(o,1):e(s,-1)}),A(n),W(e,n)}),A(t),W(e,t)};K(o,e=>{V(i)&&e(s)}),W(e,a)}),A(y),A(g),N_(L(g,2),{class:`mt-4`,get page(){return V(u)},perPage:10,get totalItems(){return V(c)},setPage:m}),A(h),R(()=>bi(h,1,`w-full overflow-x-auto ${V(s)?`opacity-25`:``}`)),W(e,h),Je()}var z_=e=>new Sm(e,{type:`line`,data:{datasets:[]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:`top`},tooltip:{intersect:!1,mode:`index`,position:`nearest`,caretPadding:10,caretSize:8}},scales:{x:{ticks:{sampleSize:1}},y:{beginAtZero:!0},y1:{beginAtZero:!0,position:`right`,grid:{drawOnChartArea:!1}}}},plugins:[{id:`verticalLineOnHover`,afterDraw:e=>{let t=e.tooltip?.getActiveElements();if(t?.length){let n=t[0];if(!n||!e.scales.y)return;let r=e.ctx,i=n.element.x,a=e.scales.y.top,o=e.scales.y.bottom;r.save(),r.beginPath(),r.moveTo(i,a),r.lineTo(i,o),r.lineWidth=1,r.strokeStyle=`rgb(0, 0, 0, 0.4)`,r.setLineDash([4,6]),r.stroke(),r.restore()}}}]}),B_=U(`<div class="relative w-full aspect-video pr-4"><canvas></canvas></div>`);function V_(e,t){qe(t,!0);let n=N(void 0),r;na(()=>(Sm.defaults.font.size=18,r=z_(V(n)),i(),r.update(),()=>r?.destroy()));let i=()=>{if(!r||!t.data)return;let e=!1,n=!1;r.data.datasets=t.data.map(t=>(t.axis===`right`?n=!0:e=!0,{label:t.label,data:t.data,yAxisID:t.axis===`right`?`y1`:`y`,fill:!1})),r.options.scales?.y&&(r.options.scales.y.display=e),r.options.scales?.y1&&(r.options.scales.y1.display=n)};Dn(()=>{r&&(i(),r.update())});var a=B_();Qi(F(a),e=>P(n,e),()=>V(n)),A(a),W(e,a),Je()}var H_=U(`<th>Date</th>`),U_=U(`<th> </th>`),W_=U(`<td> </td>`),G_=U(`<tr><!><!></tr>`),K_=U(`<div class="w-full overflow-x-auto"><table><thead><tr><!><!></tr></thead><tbody></tbody></table> <!></div>`);function q_(e,t){qe(t,!0);let n=j(()=>t.data[0]?.data?.length??0),r=N(1),i=j(()=>Math.ceil(V(n)/10)),a=j(()=>Math.max(1,Math.min(V(r),V(i))));var o=K_(),s=F(o),c=F(s),l=F(c),u=F(l),d=e=>{W(e,H_())};K(u,e=>{t.chartConfig.time_series&&e(d)}),q(L(u),17,()=>t.data,ei,(e,t)=>{var n=U_(),r=F(n,!0);A(n),R(()=>G(r,V(t).label)),W(e,n)}),A(l),A(c);var f=L(c);q(f,21,()=>Array(10),ei,(e,r,i)=>{let o=j(()=>i+(V(a)-1)*10);var s=Kr(),c=I(s),l=e=>{var n=G_(),r=F(n),i=e=>{var n=W_(),r=F(n,!0);A(n),R(()=>G(r,t.data[0]?.data[V(o)]?.x)),W(e,n)};K(r,e=>{t.chartConfig.time_series&&e(i)}),q(L(r),17,()=>t.data,ei,(e,t)=>{var n=W_(),r=F(n,!0);A(n),R(()=>G(r,V(t).data[V(o)]?.y)),W(e,n)}),A(n),W(e,n)};K(c,e=>{V(o)<V(n)&&e(l)}),W(e,s)}),A(f),A(s),N_(L(s,2),{class:`mt-4`,get page(){return V(a)},perPage:10,get totalItems(){return V(n)},setPage:e=>P(r,e,!0)}),A(o),W(e,o),Je()}var J_=U(`<div class="mt-12"><!></div>`),Y_=U(`<p class="whitespace-pre-wrap w-max max-w-full mx-auto px-2 lg:px-12"> </p>`),X_=U(`<div class="aspect-video border border-ice-100"><p class="absolute top-1/2 left-1/2 -translate-1/2 text-gray-600">No data to display</p></div>`),Z_=U(`<div class="p-2 bg-dawn-50 border border-dawn-200 text-dawn-700"><p>Something went wrong when trying to load the chart data.</p></div>`),Q_=U(`<button type="button" class="sm px-1"><!></button>`),$_=U(`<button type="button" class="bg-dawn-100">Yes, delete this chart</button> <button type="button" class="ghost text-gray-600">Cancel</button>`,1),ev=U(`<button type="button" class="bg-dawn-100">Delete</button>`),tv=U(`<button type="button">Edit</button> <button type="button">Duplicate</button> <!> <!> <!>`,1),nv=U(`<button type="button"> </button>`),rv=U(`<div><div><!> <div class="sticky top-18 grow min-w-0 flex flex-col gap-4"><div><div class="mb-4"><h2 class="text-night-950 text-xl font-semibold text-center"> </h2> <!></div> <div class="relative"><!></div></div> <!> <div class="flex flex-wrap gap-2 items-center"><!> <div class="ml-auto"></div> <button type="button">Refresh</button> <!></div></div></div></div>`);function iv(e,t){qe(t,!0);let n=N(on(br(()=>t.startOpen))),r=N(!1),i=N(!1),a=N(!1),o=N(!1),s=N(on(br(()=>t.chartConfig))),c=on({}),l=on({}),u=N([]),d=e=>(P(o,!0),ns(V(n)?e:t.chartConfig.id,t.tabFilters,c).then(t=>{P(s,e,!0),V(s).type===`table`?(l.resultOffset=t.resultOffset,l.resultCount=t.resultCount,P(u,t.data)):P(u,Bo(V(s),t.data)),P(a,!1)}).catch(e=>{throw console.error(e),P(a,!0),e}).finally(()=>{P(o,!1)})),f=e=>d(e),p=e=>{t.onSave(e),P(s,e,!0),P(n,!1)};Dn(()=>{JSON.stringify(t.tabFilters),JSON.stringify(c),br(()=>{d(V(s))})});var m=rv(),h=F(m),g=F(h),_=e=>{var r=J_();zo(F(r),{get canDangerouslyUseSql(){return t.canDangerouslyUseSql},get chartConfig(){return t.chartConfig},reloadChartData:f,onClose:()=>P(n,!1),onSave:p}),A(r),W(e,r)};K(g,e=>{V(n)&&e(_)});var v=L(g,2),y=F(v),b=F(y),x=F(b),S=F(x,!0);A(x);var C=L(x,2),w=e=>{var t=Y_(),n=F(t,!0);A(t),R(()=>G(n,V(s).description)),W(e,t)};K(C,e=>{V(s).description&&e(w)}),A(b);var T=L(b,2),E=F(T),D=e=>{W(e,X_())},ee=e=>{R_(e,{get chartConfig(){return V(s)},get chartFilters(){return c},get chartMetadata(){return l},get data(){return V(u)},get loading(){return V(o)}})},te=e=>{q_(e,{get chartConfig(){return V(s)},get data(){return V(u)}})},ne=e=>{V_(e,{get data(){return V(u)}})},re=e=>{O_(e,{get chartConfig(){return V(s)},get data(){return V(u)}})};K(E,e=>{V(u).length===0?e(D):V(s).type===`table`?e(ee,1):V(r)&&V(u).length!==0?e(te,2):V(s).type===`line`?e(ne,3):V(s).type===`bar`&&e(re,4)}),A(T),A(y);var ie=L(y,2),ae=e=>{W(e,Z_())};K(ie,e=>{V(a)&&e(ae)});var oe=L(ie,2),se=F(oe),ce=e=>{var r=tv(),a=I(r),o=L(a,2),s=L(o,2),c=e=>{var n=Q_();aa(F(n),{name:`chevron_up`,size:24}),A(n),H(`click`,n,function(...e){t.onMoveUp?.apply(this,e)}),W(e,n)};K(s,e=>{t.onMoveUp!==null&&e(c)});var l=L(s,2),u=e=>{var n=Q_();aa(F(n),{name:`chevron_down`,size:24}),A(n),H(`click`,n,function(...e){t.onMoveDown?.apply(this,e)}),W(e,n)};K(l,e=>{t.onMoveDown!==null&&e(u)});var d=L(l,2),f=e=>{var n=$_(),r=I(n),a=L(r,2);H(`click`,r,function(...e){t.onDelete?.apply(this,e)}),H(`click`,a,()=>P(i,!1)),W(e,n)},p=e=>{var t=ev();H(`click`,t,()=>P(i,!0)),W(e,t)};K(d,e=>{V(i)?e(f):e(p,-1)}),H(`click`,a,()=>P(n,!0)),H(`click`,o,function(...e){t.onDuplicate?.apply(this,e)}),W(e,r)};K(se,e=>{t.editingEnabled&&!V(n)&&e(ce)});var le=L(se,4),ue=L(le,2),de=e=>{var t=nv(),n=F(t,!0);A(t),R(()=>G(n,V(r)?`Show chart`:`Show data`)),H(`click`,t,()=>P(r,!V(r))),W(e,t)};K(ue,e=>{V(u).length!==0&&t.chartConfig.type!==`table`&&e(de)}),A(oe),A(v),A(h),A(m),R(()=>{bi(m,1,V(n)?`xl:full-width`:``),bi(h,1,`flex flex-col px-6 p-4 bg-white border border-night-50 ${V(n)?`mx-auto xl:max-w-384 xl:flex-row xl:justify-center xl:items-start`:``} gap-4`),bi(y,1,mi(V(n)?`flex-1 min-w-0 max-w-256`:``)),G(S,V(s).title)}),H(`click`,le,()=>d(V(s))),W(e,m),Je()}Ir([`click`]);var av=U(`<button type="button" class="bg-dawn-100">Yes, delete this tab and all its charts</button> <button type="button" class="ghost text-gray-600">Cancel</button>`,1),ov=U(`<button type="button" class="bg-dawn-100">Delete this tab</button>`),sv=U(`<!> <!> <!> <!> <div class="flex gap-2 mt-4"><!></div>`,1);function cv(e,t){let n=N(!1);var r=sv(),i=I(r);xa(i,{get model(){return t.tabConfig},key:`title`,allowEmpty:!0,trimOnBlur:!0,showClear:!1,children:(e,t)=>{Ie(),W(e,Gr(`Tab name`))},$$slots:{default:!0}});var a=L(i,2);xa(a,{type:`contenteditable`,get model(){return t.tabConfig},key:`description`,placeholder:`Enter a description for this tab`,trimOnBlur:!0,children:(e,t)=>{Ie(),W(e,Gr(`Tab description`))},$$slots:{default:!0}});var o=L(a,2);xa(o,{type:`date`,get model(){return t.tabConfig},key:`date_from`,children:(e,t)=>{Ie(),W(e,Gr(`Default date from`))},$$slots:{default:!0}});var s=L(o,2);xa(s,{type:`date`,get model(){return t.tabConfig},key:`date_to`,children:(e,t)=>{Ie(),W(e,Gr(`Default date to`))},$$slots:{default:!0}});var c=L(s,2),l=F(c),u=e=>{var r=av(),i=I(r),a=L(i,2);H(`click`,i,function(...e){t.onDelete?.apply(this,e)}),H(`click`,a,()=>P(n,!1)),W(e,r)},d=e=>{var t=ov();H(`click`,t,()=>P(n,!0)),W(e,t)};K(l,e=>{V(n)?e(u):e(d,-1)}),A(c),W(e,r)}Ir([`click`]);var lv=3e3,uv=1e4,dv=class{#e=N(`idle`);get status(){return V(this.#e)}set status(e){P(this.#e,e,!0)}#t;#n;#r=null;#i=!1;#a=!1;#o=!1;#s=!1;constructor(e,t){this.#t=e,this.#n=t}get hasUnsavedChanges(){return this.status===`pending`||this.status===`saving`||this.status===`error`}schedule(){this.#s||(this.#a=!0,!(this.#i||this.status===`error`)&&(this.status=`pending`,this.#l(lv)))}flush(){if(!(this.#s||!this.#a)){if(this.#i){this.#o=!0;return}this.#c()}}cancel(){this.#s=!0,this.#u(),this.status=`idle`}#c(){this.#u(),this.#a=!1,this.#o=!1,this.#i=!0,this.status=`saving`;let[e,t]=this.#n();rs(e,t,this.#t).then(e=>{this.#t=e.updated_at,this.#i=!1,!this.#s&&(this.#a&&this.#o?this.#c():this.#a?(this.status=`pending`,this.#l(lv)):this.status=`idle`)}).catch(e=>{if(console.error(`Failed to save dashboard`,e),this.#i=!1,!this.#s){if(e instanceof es&&e.status===409){this.#s=!0,this.status=`conflict`;return}this.#a=!0,this.status=`error`,this.#l(uv)}})}#l(e){this.#u(),this.#r=setTimeout(()=>{this.#r=null,this.#c()},e)}#u(){this.#r!==null&&(clearTimeout(this.#r),this.#r=null)}},fv=U(`<button type="button"> </button>`),pv=U(`<header class="mt-4"><nav><!> <button type="button" class="shrink-0 font-bold px-3">+</button></nav></header>`);function mv(e,t){qe(t,!0);var n=pv(),r=F(n),i=F(r);q(i,17,()=>t.dashboards,ei,(e,n,r)=>{var i=fv(),a=F(i,!0);A(i),R(()=>{bi(i,1,V(n).id===t.selectedTab?`selected`:``),G(a,V(n).title?V(n).title:`Tab ${r+1}`)}),H(`click`,i,()=>t.selectTab(V(n).id)),W(e,i)});var a=L(i,2);A(r),A(n),H(`click`,a,()=>t.newTab()),W(e,n),Je()}Ir([`click`]);var hv=U(`<button type="button" class="mt-4 sm:mt-0">Finish editing</button>`),gv=U(`<button type="button" class="mt-4 sm:mt-0">Enable editing</button>`),_v=U(`<p class="-mt-2 help-text text-dawn-700">A dashboard needs a name. Changes to the name are not saved while it is empty.</p>`),vv=U(`<button type="button" class="bg-dawn-100">Yes, delete this dashboard and all its tabs</button> <button type="button" class="ghost text-gray-600">Cancel</button>`,1),yv=U(`<button type="button" class="bg-dawn-100">Delete this dashboard</button>`),bv=U(`<p class="-mt-2 help-text text-dawn-700">Something went wrong when trying to delete the dashboard. Please try again.</p>`),xv=U(`<!> <!> <!> <div class="flex gap-2 mt-2"><!></div> <!>`,1),Sv=U(`<p class="-mt-3 whitespace-pre-wrap text-gray-600"> </p>`),Cv=U(`<h1 class="text-night-950 text-2xl font-semibold"> </h1> <!>`,1),wv=U(`<div class="flex flex-col gap-4 bg-white p-4"><!></div>`),Tv=U(`<p class="whitespace-pre-wrap"> </p>`),Ev=U(`<span class="sr-only">Date from</span>`),Dv=U(`<span class="sr-only">Date to</span>`),Ov=U(`<!> <div class="flex flex-wrap gap-2 justify-center sm:justify-start items-center"><div class="flex gap-2 items-center sm:contents">Showing data from <!></div> <div class="flex gap-2 items-center sm:contents">to <!></div></div>`,1),kv=U(`<div class="z-10 border border-night-50 gap-4 flex flex-col md:flex-row justify-between items-center md:items-start bg-white p-4 sm:sticky top-0"><div class="grow flex flex-col gap-4"><!></div></div>`),Av=U(`<div class="flex justify-center items-center py-8 mt-8 border border-dashed border-black/20"><button type="button">Add chart</button></div>`),jv=U(`<div class="sm:sticky z-20 h-0 top-4 w-max ml-auto -mb-4 sm:mb-0"><!></div> <section class="flex flex-col gap-4 pt-4 pb-2"><a class="text-sm text-night-700 w-max">← All dashboards</a> <!></section> <!> <main class="w-full mx-auto flex flex-col gap-4 pt-4"><!> <!> <!> <!></main>`,1);function Mv(e,t){qe(t,!0);let n=document.querySelector(`[data-dashboard-config]`),r=on(JSON.parse(n.dataset.dashboardConfig)),i=on({name:n.dataset.dashboardName??``,description:n.dataset.dashboardDescription??``}),a=i.name,o=n.dataset.dashboardsIndexPath,s=n.dataset.canEdit===`true`,c=n.dataset.canDangerouslyUseSql===`true`,l=N(on(r[0].id)),u=j(()=>r.find(e=>e.id===V(l))),d=N(on(br(()=>({date_from:V(u).date_from,date_to:V(u).date_to})))),f=N(null),p=N(!1),m=new dv(n.dataset.dashboardUpdatedAt,()=>(i.name?.trim()&&(a=i.name.trim()),[r,i])),h=async()=>{i.name?.trim()||(i.name=a),P(p,!1),await _r(),m.flush()},g=e=>{m.hasUnsavedChanges&&e.preventDefault()},_=N(!1),v=N(!1),y=N(!1),b=()=>{P(v,!0),is().then(()=>{m.cancel(),window.location.href=o}).catch(e=>{P(v,!1),P(y,!0),console.error(`Failed to delete dashboard`,e)})},x=e=>{P(f,null),P(l,e,!0),P(d,{date_from:V(u).date_from,date_to:V(u).date_to},!0)},S=(e=null)=>{let t=crypto.randomUUID();r.push({id:t,title:e??`Tab ${r.length+1}`,description:``,children:[]}),P(l,t,!0)},C=()=>{let e=crypto.randomUUID();P(f,e,!0),V(u).children.push({id:e,type:`line`,title:`New chart`,time_series:`weekly`,datasets:[{id:crypto.randomUUID(),type:`visits`,label:`Dataset 1`}]})},w=e=>{V(u).children.splice(e,1)},T=e=>{let t=Ue(V(u).children[e]);t.id=crypto.randomUUID(),P(f,t.id,!0),t.title=`Copy of ${t.title}`,V(u).children.splice(e+1,0,t)},E=e=>{if(e===0)return;let t=V(u).children[e];V(u).children[e]=V(u).children[e-1],V(u).children[e-1]=t},D=e=>{if(e>=V(u).children.length-1)return;let t=V(u).children[e];V(u).children[e]=V(u).children[e+1],V(u).children[e+1]=t},ee=()=>{let e=r.indexOf(V(u));if(r.length<=1)S(`Tab 1`);else{let t=e===0?1:e-1;P(l,r[t].id,!0)}r.splice(e,1)},te=!1;Dn(()=>{if(JSON.stringify([r,i]),!te){te=!0;return}br(()=>m.schedule())});var ne=jv();Fr(`beforeunload`,ln,g);var re=I(ne),ie=F(re),ae=e=>{var t=hv();H(`click`,t,h),W(e,t)},oe=e=>{var t=gv();H(`click`,t,()=>P(p,!0)),W(e,t)};K(ie,e=>{V(p)?e(ae):s&&e(oe,1)}),A(re);var se=L(re,2),ce=F(se),le=L(ce,2),ue=e=>{var t=xv(),n=I(t);xa(n,{get model(){return i},key:`name`,trimOnBlur:!0,showClear:!1,children:(e,t)=>{Ie(),W(e,Gr(`Dashboard name`))},$$slots:{default:!0}});var r=L(n,2),a=e=>{W(e,_v())},o=j(()=>!i.name?.trim());K(r,e=>{V(o)&&e(a)});var s=L(r,2);xa(s,{type:`contenteditable`,get model(){return i},key:`description`,placeholder:`Enter a description for this dashboard`,trimOnBlur:!0,children:(e,t)=>{Ie(),W(e,Gr(`Dashboard description`))},$$slots:{default:!0}});var c=L(s,2),l=F(c),u=e=>{var t=vv(),n=I(t),r=L(n,2);R(()=>{n.disabled=V(v),r.disabled=V(v)}),H(`click`,n,b),H(`click`,r,()=>P(_,!1)),W(e,t)},d=e=>{var t=yv();H(`click`,t,()=>P(_,!0)),W(e,t)};K(l,e=>{V(_)?e(u):e(d,-1)}),A(c);var f=L(c,2),p=e=>{W(e,bv())};K(f,e=>{V(y)&&e(p)}),W(e,t)},de=e=>{var t=Cv(),n=I(t),r=F(n,!0);A(n);var a=L(n,2),o=e=>{var t=Sv(),n=F(t,!0);A(t),R(()=>G(n,i.description)),W(e,t)};K(a,e=>{i.description&&e(o)}),R(()=>G(r,i.name)),W(e,t)};K(le,e=>{V(p)?e(ue):e(de,-1)}),A(se);var fe=L(se,2);mv(fe,{get dashboards(){return r},get selectedTab(){return V(l)},selectTab:x,newTab:S});var pe=L(fe,2),me=F(pe);Ta(me,{get status(){return m.status}});var he=L(me,2),ge=e=>{var t=wv();$r(F(t),()=>V(l),e=>{cv(e,{get tabConfig(){return V(u)},onDelete:ee})}),A(t),W(e,t)},_e=e=>{var t=kv(),n=F(t),r=F(n),i=e=>{var t=Ov(),n=I(t),r=e=>{var t=Tv(),n=F(t,!0);A(t),R(()=>G(n,V(u).description)),W(e,t)};K(n,e=>{V(u).description&&e(r)});var i=L(n,2),a=F(i);xa(L(F(a)),{type:`date`,get model(){return V(d)},key:`date_from`,children:(e,t)=>{W(e,Ev())},$$slots:{default:!0}}),A(a);var o=L(a,2);xa(L(F(o)),{type:`date`,get model(){return V(d)},key:`date_to`,children:(e,t)=>{W(e,Dv())},$$slots:{default:!0}}),A(o),A(i),W(e,t)};K(r,e=>{V(p)||e(i)}),A(n),A(t),W(e,t)};K(he,e=>{V(p)?e(ge):e(_e,-1)});var ve=L(he,2);q(ve,19,()=>V(u)?.children,e=>e.id,(e,t,n)=>{{let r=j(()=>V(f)===V(t).id),i=j(()=>V(n)===0?null:()=>E(V(n))),a=j(()=>V(n)===V(u).children.length-1?null:()=>D(V(n)));iv(e,{get canDangerouslyUseSql(){return c},get chartConfig(){return V(t)},get editingEnabled(){return V(p)},get tabFilters(){return V(d)},get startOpen(){return V(r)},onDelete:()=>w(V(n)),onDuplicate:()=>T(V(n)),get onMoveUp(){return V(i)},get onMoveDown(){return V(a)},onSave:e=>V(u).children[V(n)]=e})}});var ye=L(ve,2),be=e=>{var t=Av(),n=F(t);A(t),H(`click`,n,C),W(e,t)};K(ye,e=>{V(p)&&e(be)}),A(pe),R(()=>zi(ce,`href`,o)),W(e,ne),Je()}Ir([`click`]),window.addEventListener(`load`,()=>{qr(Mv,{target:document.getElementById(`skadi-dashboard`)})});