var ia=Object.defineProperty;var sa=(n,t,e)=>t in n?ia(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var _=(n,t,e)=>(sa(n,typeof t!="symbol"?t+"":t,e),e);import{t as R,c as rt,m as rn,a as an,b as $i,d as Gn,e as oa,f as qo,g as Uo,h as Xo,i as ra,j as aa,s as Ke,k as Ko,l as la,n as ca,o as Go,p as ha,q as us,r as ua,u as ds,v as da,w as dt,x as j,y as I,z as lt,P as fa,I as Qn,A as Zn,B as ga,C as pa,D as ma,E as ba,F as ya,G as _a,H as xa,J as wa}from"./load-translations-36a0ce82.js";function Jn(n,t){const e=+R(n);return rt(n,e+t)}function va(n,t){return Jn(n,t*rn)}function Ma(n,t){return Jn(n,t*an)}function ka(n,t){const e=t*3;return $i(n,e)}function Pa(n,t){return Jn(n,t*1e3)}function Da(n,t){const e=t*7;return Gn(n,e)}function Ca(n,t){return $i(n,t*12)}function Ye(n,t){const e=R(n),i=R(t),s=e.getTime()-i.getTime();return s<0?-1:s>0?1:s}function Sa(n,t){const e=R(n),i=R(t),s=e.getFullYear()-i.getFullYear(),o=e.getMonth()-i.getMonth();return s*12+o}function Oa(n,t){const e=R(n),i=R(t);return e.getFullYear()-i.getFullYear()}function Qo(n,t){const e=R(n),i=R(t),s=fs(e,i),o=Math.abs(oa(e,i));e.setDate(e.getDate()-s*o);const r=+(fs(e,i)===-s),a=s*(o-r);return a===0?0:a}function fs(n,t){const e=n.getFullYear()-t.getFullYear()||n.getMonth()-t.getMonth()||n.getDate()-t.getDate()||n.getHours()-t.getHours()||n.getMinutes()-t.getMinutes()||n.getSeconds()-t.getSeconds()||n.getMilliseconds()-t.getMilliseconds();return e<0?-1:e>0?1:e}function ti(n,t){return R(n).getTime()-R(t).getTime()}function ln(n){return n?Math[n]:Math.trunc}function Ta(n,t,e){const i=ti(n,t)/rn;return ln(e==null?void 0:e.roundingMethod)(i)}function Aa(n,t,e){const i=ti(n,t)/an;return ln(e==null?void 0:e.roundingMethod)(i)}function La(n){const t=R(n);return+qo(t)==+Uo(t)}function Zo(n,t){const e=R(n),i=R(t),s=Ye(e,i),o=Math.abs(Sa(e,i));let r;if(o<1)r=0;else{e.getMonth()===1&&e.getDate()>27&&e.setDate(30),e.setMonth(e.getMonth()-s*o);let a=Ye(e,i)===-s;La(R(n))&&o===1&&Ye(n,i)===1&&(a=!1),r=s*(o-Number(a))}return r===0?0:r}function Fa(n,t,e){const i=Zo(n,t)/3;return ln(e==null?void 0:e.roundingMethod)(i)}function Ra(n,t,e){const i=ti(n,t)/1e3;return ln(e==null?void 0:e.roundingMethod)(i)}function Ia(n,t,e){const i=Qo(n,t)/7;return ln(e==null?void 0:e.roundingMethod)(i)}function Ea(n,t){const e=R(n),i=R(t),s=Ye(e,i),o=Math.abs(Oa(e,i));e.setFullYear(1584),i.setFullYear(1584);const r=Ye(e,i)===-s,a=s*(o-+r);return a===0?0:a}function za(n){const t=R(n);return t.setSeconds(0,0),t}function Ba(n){const t=R(n),e=t.getFullYear();return t.setFullYear(e+1,0,0),t.setHours(23,59,59,999),t}function Na(n){const t=R(n);return t.setMinutes(59,59,999),t}function Wa(n){const t=R(n);return t.setSeconds(59,999),t}function Ha(n){const t=R(n);return t.setMilliseconds(999),t}function Va(){return Object.assign({},Xo())}function Ya(n){let e=R(n).getDay();return e===0&&(e=7),e}function ja(n,t){const e=t instanceof Date?rt(t,0):new t(0);return e.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),e.setHours(n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()),e}const $a=10;class Jo{constructor(){_(this,"subPriority",0)}validate(t,e){return!0}}class qa extends Jo{constructor(t,e,i,s,o){super(),this.value=t,this.validateValue=e,this.setValue=i,this.priority=s,o&&(this.subPriority=o)}validate(t,e){return this.validateValue(t,this.value,e)}set(t,e,i){return this.setValue(t,e,this.value,i)}}class Ua extends Jo{constructor(){super(...arguments);_(this,"priority",$a);_(this,"subPriority",-1)}set(e,i){return i.timestampIsSet?e:rt(e,ja(e,Date))}}class E{run(t,e,i,s){const o=this.parse(t,e,i,s);return o?{setter:new qa(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(t,e,i){return!0}}class Xa extends E{constructor(){super(...arguments);_(this,"priority",140);_(this,"incompatibleTokens",["R","u","t","T"])}parse(e,i,s){switch(i){case"G":case"GG":case"GGG":return s.era(e,{width:"abbreviated"})||s.era(e,{width:"narrow"});case"GGGGG":return s.era(e,{width:"narrow"});case"GGGG":default:return s.era(e,{width:"wide"})||s.era(e,{width:"abbreviated"})||s.era(e,{width:"narrow"})}}set(e,i,s){return i.era=s,e.setFullYear(s,0,1),e.setHours(0,0,0,0),e}}const G={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},kt={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function Q(n,t){return n&&{value:t(n.value),rest:n.rest}}function Y(n,t){const e=t.match(n);return e?{value:parseInt(e[0],10),rest:t.slice(e[0].length)}:null}function Pt(n,t){const e=t.match(n);if(!e)return null;if(e[0]==="Z")return{value:0,rest:t.slice(1)};const i=e[1]==="+"?1:-1,s=e[2]?parseInt(e[2],10):0,o=e[3]?parseInt(e[3],10):0,r=e[5]?parseInt(e[5],10):0;return{value:i*(s*rn+o*an+r*ra),rest:t.slice(e[0].length)}}function tr(n){return Y(G.anyDigitsSigned,n)}function X(n,t){switch(n){case 1:return Y(G.singleDigit,t);case 2:return Y(G.twoDigits,t);case 3:return Y(G.threeDigits,t);case 4:return Y(G.fourDigits,t);default:return Y(new RegExp("^\\d{1,"+n+"}"),t)}}function Wn(n,t){switch(n){case 1:return Y(G.singleDigitSigned,t);case 2:return Y(G.twoDigitsSigned,t);case 3:return Y(G.threeDigitsSigned,t);case 4:return Y(G.fourDigitsSigned,t);default:return Y(new RegExp("^-?\\d{1,"+n+"}"),t)}}function qi(n){switch(n){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;case"am":case"midnight":case"night":default:return 0}}function er(n,t){const e=t>0,i=e?t:1-t;let s;if(i<=50)s=n||100;else{const o=i+50,r=Math.floor(o/100)*100,a=n>=o%100;s=n+r-(a?100:0)}return e?s:1-s}function nr(n){return n%400===0||n%4===0&&n%100!==0}class Ka extends E{constructor(){super(...arguments);_(this,"priority",130);_(this,"incompatibleTokens",["Y","R","u","w","I","i","e","c","t","T"])}parse(e,i,s){const o=r=>({year:r,isTwoDigitYear:i==="yy"});switch(i){case"y":return Q(X(4,e),o);case"yo":return Q(s.ordinalNumber(e,{unit:"year"}),o);default:return Q(X(i.length,e),o)}}validate(e,i){return i.isTwoDigitYear||i.year>0}set(e,i,s){const o=e.getFullYear();if(s.isTwoDigitYear){const a=er(s.year,o);return e.setFullYear(a,0,1),e.setHours(0,0,0,0),e}const r=!("era"in i)||i.era===1?s.year:1-s.year;return e.setFullYear(r,0,1),e.setHours(0,0,0,0),e}}class Ga extends E{constructor(){super(...arguments);_(this,"priority",130);_(this,"incompatibleTokens",["y","R","u","Q","q","M","L","I","d","D","i","t","T"])}parse(e,i,s){const o=r=>({year:r,isTwoDigitYear:i==="YY"});switch(i){case"Y":return Q(X(4,e),o);case"Yo":return Q(s.ordinalNumber(e,{unit:"year"}),o);default:return Q(X(i.length,e),o)}}validate(e,i){return i.isTwoDigitYear||i.year>0}set(e,i,s,o){const r=aa(e,o);if(s.isTwoDigitYear){const l=er(s.year,r);return e.setFullYear(l,0,o.firstWeekContainsDate),e.setHours(0,0,0,0),Ke(e,o)}const a=!("era"in i)||i.era===1?s.year:1-s.year;return e.setFullYear(a,0,o.firstWeekContainsDate),e.setHours(0,0,0,0),Ke(e,o)}}class Qa extends E{constructor(){super(...arguments);_(this,"priority",130);_(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(e,i){return Wn(i==="R"?4:i.length,e)}set(e,i,s){const o=rt(e,0);return o.setFullYear(s,0,4),o.setHours(0,0,0,0),Ko(o)}}class Za extends E{constructor(){super(...arguments);_(this,"priority",130);_(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(e,i){return Wn(i==="u"?4:i.length,e)}set(e,i,s){return e.setFullYear(s,0,1),e.setHours(0,0,0,0),e}}class Ja extends E{constructor(){super(...arguments);_(this,"priority",120);_(this,"incompatibleTokens",["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"])}parse(e,i,s){switch(i){case"Q":case"QQ":return X(i.length,e);case"Qo":return s.ordinalNumber(e,{unit:"quarter"});case"QQQ":return s.quarter(e,{width:"abbreviated",context:"formatting"})||s.quarter(e,{width:"narrow",context:"formatting"});case"QQQQQ":return s.quarter(e,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(e,{width:"wide",context:"formatting"})||s.quarter(e,{width:"abbreviated",context:"formatting"})||s.quarter(e,{width:"narrow",context:"formatting"})}}validate(e,i){return i>=1&&i<=4}set(e,i,s){return e.setMonth((s-1)*3,1),e.setHours(0,0,0,0),e}}class tl extends E{constructor(){super(...arguments);_(this,"priority",120);_(this,"incompatibleTokens",["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"])}parse(e,i,s){switch(i){case"q":case"qq":return X(i.length,e);case"qo":return s.ordinalNumber(e,{unit:"quarter"});case"qqq":return s.quarter(e,{width:"abbreviated",context:"standalone"})||s.quarter(e,{width:"narrow",context:"standalone"});case"qqqqq":return s.quarter(e,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(e,{width:"wide",context:"standalone"})||s.quarter(e,{width:"abbreviated",context:"standalone"})||s.quarter(e,{width:"narrow",context:"standalone"})}}validate(e,i){return i>=1&&i<=4}set(e,i,s){return e.setMonth((s-1)*3,1),e.setHours(0,0,0,0),e}}class el extends E{constructor(){super(...arguments);_(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);_(this,"priority",110)}parse(e,i,s){const o=r=>r-1;switch(i){case"M":return Q(Y(G.month,e),o);case"MM":return Q(X(2,e),o);case"Mo":return Q(s.ordinalNumber(e,{unit:"month"}),o);case"MMM":return s.month(e,{width:"abbreviated",context:"formatting"})||s.month(e,{width:"narrow",context:"formatting"});case"MMMMM":return s.month(e,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(e,{width:"wide",context:"formatting"})||s.month(e,{width:"abbreviated",context:"formatting"})||s.month(e,{width:"narrow",context:"formatting"})}}validate(e,i){return i>=0&&i<=11}set(e,i,s){return e.setMonth(s,1),e.setHours(0,0,0,0),e}}class nl extends E{constructor(){super(...arguments);_(this,"priority",110);_(this,"incompatibleTokens",["Y","R","q","Q","M","w","I","D","i","e","c","t","T"])}parse(e,i,s){const o=r=>r-1;switch(i){case"L":return Q(Y(G.month,e),o);case"LL":return Q(X(2,e),o);case"Lo":return Q(s.ordinalNumber(e,{unit:"month"}),o);case"LLL":return s.month(e,{width:"abbreviated",context:"standalone"})||s.month(e,{width:"narrow",context:"standalone"});case"LLLLL":return s.month(e,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(e,{width:"wide",context:"standalone"})||s.month(e,{width:"abbreviated",context:"standalone"})||s.month(e,{width:"narrow",context:"standalone"})}}validate(e,i){return i>=0&&i<=11}set(e,i,s){return e.setMonth(s,1),e.setHours(0,0,0,0),e}}function il(n,t,e){const i=R(n),s=la(i,e)-t;return i.setDate(i.getDate()-s*7),i}class sl extends E{constructor(){super(...arguments);_(this,"priority",100);_(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(e,i,s){switch(i){case"w":return Y(G.week,e);case"wo":return s.ordinalNumber(e,{unit:"week"});default:return X(i.length,e)}}validate(e,i){return i>=1&&i<=53}set(e,i,s,o){return Ke(il(e,s,o),o)}}function ol(n,t){const e=R(n),i=ca(e)-t;return e.setDate(e.getDate()-i*7),e}class rl extends E{constructor(){super(...arguments);_(this,"priority",100);_(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"])}parse(e,i,s){switch(i){case"I":return Y(G.week,e);case"Io":return s.ordinalNumber(e,{unit:"week"});default:return X(i.length,e)}}validate(e,i){return i>=1&&i<=53}set(e,i,s){return Ko(ol(e,s))}}const al=[31,28,31,30,31,30,31,31,30,31,30,31],ll=[31,29,31,30,31,30,31,31,30,31,30,31];class cl extends E{constructor(){super(...arguments);_(this,"priority",90);_(this,"subPriority",1);_(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(e,i,s){switch(i){case"d":return Y(G.date,e);case"do":return s.ordinalNumber(e,{unit:"date"});default:return X(i.length,e)}}validate(e,i){const s=e.getFullYear(),o=nr(s),r=e.getMonth();return o?i>=1&&i<=ll[r]:i>=1&&i<=al[r]}set(e,i,s){return e.setDate(s),e.setHours(0,0,0,0),e}}class hl extends E{constructor(){super(...arguments);_(this,"priority",90);_(this,"subpriority",1);_(this,"incompatibleTokens",["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"])}parse(e,i,s){switch(i){case"D":case"DD":return Y(G.dayOfYear,e);case"Do":return s.ordinalNumber(e,{unit:"date"});default:return X(i.length,e)}}validate(e,i){const s=e.getFullYear();return nr(s)?i>=1&&i<=366:i>=1&&i<=365}set(e,i,s){return e.setMonth(0,s),e.setHours(0,0,0,0),e}}function Ui(n,t,e){var u,d,f,g;const i=Xo(),s=(e==null?void 0:e.weekStartsOn)??((d=(u=e==null?void 0:e.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??i.weekStartsOn??((g=(f=i.locale)==null?void 0:f.options)==null?void 0:g.weekStartsOn)??0,o=R(n),r=o.getDay(),l=(t%7+7)%7,c=7-s,h=t<0||t>6?t-(r+c)%7:(l+c)%7-(r+c)%7;return Gn(o,h)}class ul extends E{constructor(){super(...arguments);_(this,"priority",90);_(this,"incompatibleTokens",["D","i","e","c","t","T"])}parse(e,i,s){switch(i){case"E":case"EE":case"EEE":return s.day(e,{width:"abbreviated",context:"formatting"})||s.day(e,{width:"short",context:"formatting"})||s.day(e,{width:"narrow",context:"formatting"});case"EEEEE":return s.day(e,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(e,{width:"short",context:"formatting"})||s.day(e,{width:"narrow",context:"formatting"});case"EEEE":default:return s.day(e,{width:"wide",context:"formatting"})||s.day(e,{width:"abbreviated",context:"formatting"})||s.day(e,{width:"short",context:"formatting"})||s.day(e,{width:"narrow",context:"formatting"})}}validate(e,i){return i>=0&&i<=6}set(e,i,s,o){return e=Ui(e,s,o),e.setHours(0,0,0,0),e}}class dl extends E{constructor(){super(...arguments);_(this,"priority",90);_(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"])}parse(e,i,s,o){const r=a=>{const l=Math.floor((a-1)/7)*7;return(a+o.weekStartsOn+6)%7+l};switch(i){case"e":case"ee":return Q(X(i.length,e),r);case"eo":return Q(s.ordinalNumber(e,{unit:"day"}),r);case"eee":return s.day(e,{width:"abbreviated",context:"formatting"})||s.day(e,{width:"short",context:"formatting"})||s.day(e,{width:"narrow",context:"formatting"});case"eeeee":return s.day(e,{width:"narrow",context:"formatting"});case"eeeeee":return s.day(e,{width:"short",context:"formatting"})||s.day(e,{width:"narrow",context:"formatting"});case"eeee":default:return s.day(e,{width:"wide",context:"formatting"})||s.day(e,{width:"abbreviated",context:"formatting"})||s.day(e,{width:"short",context:"formatting"})||s.day(e,{width:"narrow",context:"formatting"})}}validate(e,i){return i>=0&&i<=6}set(e,i,s,o){return e=Ui(e,s,o),e.setHours(0,0,0,0),e}}class fl extends E{constructor(){super(...arguments);_(this,"priority",90);_(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"])}parse(e,i,s,o){const r=a=>{const l=Math.floor((a-1)/7)*7;return(a+o.weekStartsOn+6)%7+l};switch(i){case"c":case"cc":return Q(X(i.length,e),r);case"co":return Q(s.ordinalNumber(e,{unit:"day"}),r);case"ccc":return s.day(e,{width:"abbreviated",context:"standalone"})||s.day(e,{width:"short",context:"standalone"})||s.day(e,{width:"narrow",context:"standalone"});case"ccccc":return s.day(e,{width:"narrow",context:"standalone"});case"cccccc":return s.day(e,{width:"short",context:"standalone"})||s.day(e,{width:"narrow",context:"standalone"});case"cccc":default:return s.day(e,{width:"wide",context:"standalone"})||s.day(e,{width:"abbreviated",context:"standalone"})||s.day(e,{width:"short",context:"standalone"})||s.day(e,{width:"narrow",context:"standalone"})}}validate(e,i){return i>=0&&i<=6}set(e,i,s,o){return e=Ui(e,s,o),e.setHours(0,0,0,0),e}}function gl(n,t){const e=R(n),i=Ya(e),s=t-i;return Gn(e,s)}class pl extends E{constructor(){super(...arguments);_(this,"priority",90);_(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"])}parse(e,i,s){const o=r=>r===0?7:r;switch(i){case"i":case"ii":return X(i.length,e);case"io":return s.ordinalNumber(e,{unit:"day"});case"iii":return Q(s.day(e,{width:"abbreviated",context:"formatting"})||s.day(e,{width:"short",context:"formatting"})||s.day(e,{width:"narrow",context:"formatting"}),o);case"iiiii":return Q(s.day(e,{width:"narrow",context:"formatting"}),o);case"iiiiii":return Q(s.day(e,{width:"short",context:"formatting"})||s.day(e,{width:"narrow",context:"formatting"}),o);case"iiii":default:return Q(s.day(e,{width:"wide",context:"formatting"})||s.day(e,{width:"abbreviated",context:"formatting"})||s.day(e,{width:"short",context:"formatting"})||s.day(e,{width:"narrow",context:"formatting"}),o)}}validate(e,i){return i>=1&&i<=7}set(e,i,s){return e=gl(e,s),e.setHours(0,0,0,0),e}}class ml extends E{constructor(){super(...arguments);_(this,"priority",80);_(this,"incompatibleTokens",["b","B","H","k","t","T"])}parse(e,i,s){switch(i){case"a":case"aa":case"aaa":return s.dayPeriod(e,{width:"abbreviated",context:"formatting"})||s.dayPeriod(e,{width:"narrow",context:"formatting"});case"aaaaa":return s.dayPeriod(e,{width:"narrow",context:"formatting"});case"aaaa":default:return s.dayPeriod(e,{width:"wide",context:"formatting"})||s.dayPeriod(e,{width:"abbreviated",context:"formatting"})||s.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,i,s){return e.setHours(qi(s),0,0,0),e}}class bl extends E{constructor(){super(...arguments);_(this,"priority",80);_(this,"incompatibleTokens",["a","B","H","k","t","T"])}parse(e,i,s){switch(i){case"b":case"bb":case"bbb":return s.dayPeriod(e,{width:"abbreviated",context:"formatting"})||s.dayPeriod(e,{width:"narrow",context:"formatting"});case"bbbbb":return s.dayPeriod(e,{width:"narrow",context:"formatting"});case"bbbb":default:return s.dayPeriod(e,{width:"wide",context:"formatting"})||s.dayPeriod(e,{width:"abbreviated",context:"formatting"})||s.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,i,s){return e.setHours(qi(s),0,0,0),e}}class yl extends E{constructor(){super(...arguments);_(this,"priority",80);_(this,"incompatibleTokens",["a","b","t","T"])}parse(e,i,s){switch(i){case"B":case"BB":case"BBB":return s.dayPeriod(e,{width:"abbreviated",context:"formatting"})||s.dayPeriod(e,{width:"narrow",context:"formatting"});case"BBBBB":return s.dayPeriod(e,{width:"narrow",context:"formatting"});case"BBBB":default:return s.dayPeriod(e,{width:"wide",context:"formatting"})||s.dayPeriod(e,{width:"abbreviated",context:"formatting"})||s.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,i,s){return e.setHours(qi(s),0,0,0),e}}class _l extends E{constructor(){super(...arguments);_(this,"priority",70);_(this,"incompatibleTokens",["H","K","k","t","T"])}parse(e,i,s){switch(i){case"h":return Y(G.hour12h,e);case"ho":return s.ordinalNumber(e,{unit:"hour"});default:return X(i.length,e)}}validate(e,i){return i>=1&&i<=12}set(e,i,s){const o=e.getHours()>=12;return o&&s<12?e.setHours(s+12,0,0,0):!o&&s===12?e.setHours(0,0,0,0):e.setHours(s,0,0,0),e}}class xl extends E{constructor(){super(...arguments);_(this,"priority",70);_(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(e,i,s){switch(i){case"H":return Y(G.hour23h,e);case"Ho":return s.ordinalNumber(e,{unit:"hour"});default:return X(i.length,e)}}validate(e,i){return i>=0&&i<=23}set(e,i,s){return e.setHours(s,0,0,0),e}}class wl extends E{constructor(){super(...arguments);_(this,"priority",70);_(this,"incompatibleTokens",["h","H","k","t","T"])}parse(e,i,s){switch(i){case"K":return Y(G.hour11h,e);case"Ko":return s.ordinalNumber(e,{unit:"hour"});default:return X(i.length,e)}}validate(e,i){return i>=0&&i<=11}set(e,i,s){return e.getHours()>=12&&s<12?e.setHours(s+12,0,0,0):e.setHours(s,0,0,0),e}}class vl extends E{constructor(){super(...arguments);_(this,"priority",70);_(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(e,i,s){switch(i){case"k":return Y(G.hour24h,e);case"ko":return s.ordinalNumber(e,{unit:"hour"});default:return X(i.length,e)}}validate(e,i){return i>=1&&i<=24}set(e,i,s){const o=s<=24?s%24:s;return e.setHours(o,0,0,0),e}}class Ml extends E{constructor(){super(...arguments);_(this,"priority",60);_(this,"incompatibleTokens",["t","T"])}parse(e,i,s){switch(i){case"m":return Y(G.minute,e);case"mo":return s.ordinalNumber(e,{unit:"minute"});default:return X(i.length,e)}}validate(e,i){return i>=0&&i<=59}set(e,i,s){return e.setMinutes(s,0,0),e}}class kl extends E{constructor(){super(...arguments);_(this,"priority",50);_(this,"incompatibleTokens",["t","T"])}parse(e,i,s){switch(i){case"s":return Y(G.second,e);case"so":return s.ordinalNumber(e,{unit:"second"});default:return X(i.length,e)}}validate(e,i){return i>=0&&i<=59}set(e,i,s){return e.setSeconds(s,0),e}}class Pl extends E{constructor(){super(...arguments);_(this,"priority",30);_(this,"incompatibleTokens",["t","T"])}parse(e,i){const s=o=>Math.floor(o*Math.pow(10,-i.length+3));return Q(X(i.length,e),s)}set(e,i,s){return e.setMilliseconds(s),e}}class Dl extends E{constructor(){super(...arguments);_(this,"priority",10);_(this,"incompatibleTokens",["t","T","x"])}parse(e,i){switch(i){case"X":return Pt(kt.basicOptionalMinutes,e);case"XX":return Pt(kt.basic,e);case"XXXX":return Pt(kt.basicOptionalSeconds,e);case"XXXXX":return Pt(kt.extendedOptionalSeconds,e);case"XXX":default:return Pt(kt.extended,e)}}set(e,i,s){return i.timestampIsSet?e:rt(e,e.getTime()-Go(e)-s)}}class Cl extends E{constructor(){super(...arguments);_(this,"priority",10);_(this,"incompatibleTokens",["t","T","X"])}parse(e,i){switch(i){case"x":return Pt(kt.basicOptionalMinutes,e);case"xx":return Pt(kt.basic,e);case"xxxx":return Pt(kt.basicOptionalSeconds,e);case"xxxxx":return Pt(kt.extendedOptionalSeconds,e);case"xxx":default:return Pt(kt.extended,e)}}set(e,i,s){return i.timestampIsSet?e:rt(e,e.getTime()-Go(e)-s)}}class Sl extends E{constructor(){super(...arguments);_(this,"priority",40);_(this,"incompatibleTokens","*")}parse(e){return tr(e)}set(e,i,s){return[rt(e,s*1e3),{timestampIsSet:!0}]}}class Ol extends E{constructor(){super(...arguments);_(this,"priority",20);_(this,"incompatibleTokens","*")}parse(e){return tr(e)}set(e,i,s){return[rt(e,s),{timestampIsSet:!0}]}}const Tl={G:new Xa,y:new Ka,Y:new Ga,R:new Qa,u:new Za,Q:new Ja,q:new tl,M:new el,L:new nl,w:new sl,I:new rl,d:new cl,D:new hl,E:new ul,e:new dl,c:new fl,i:new pl,a:new ml,b:new bl,B:new yl,h:new _l,H:new xl,K:new wl,k:new vl,m:new Ml,s:new kl,S:new Pl,X:new Dl,x:new Cl,t:new Sl,T:new Ol},Al=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ll=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Fl=/^'([^]*?)'?$/,Rl=/''/g,Il=/\S/,El=/[a-zA-Z]/;function zl(n,t,e,i){var p,m,b,y,w,M,x,P;const s=Va(),o=(i==null?void 0:i.locale)??s.locale??ha,r=(i==null?void 0:i.firstWeekContainsDate)??((m=(p=i==null?void 0:i.locale)==null?void 0:p.options)==null?void 0:m.firstWeekContainsDate)??s.firstWeekContainsDate??((y=(b=s.locale)==null?void 0:b.options)==null?void 0:y.firstWeekContainsDate)??1,a=(i==null?void 0:i.weekStartsOn)??((M=(w=i==null?void 0:i.locale)==null?void 0:w.options)==null?void 0:M.weekStartsOn)??s.weekStartsOn??((P=(x=s.locale)==null?void 0:x.options)==null?void 0:P.weekStartsOn)??0;if(t==="")return n===""?R(e):rt(e,NaN);const l={firstWeekContainsDate:r,weekStartsOn:a,locale:o},c=[new Ua],h=t.match(Ll).map(v=>{const k=v[0];if(k in us){const D=us[k];return D(v,o.formatLong)}return v}).join("").match(Al),u=[];for(let v of h){!(i!=null&&i.useAdditionalWeekYearTokens)&&ua(v)&&ds(v,t,n),!(i!=null&&i.useAdditionalDayOfYearTokens)&&da(v)&&ds(v,t,n);const k=v[0],D=Tl[k];if(D){const{incompatibleTokens:T}=D;if(Array.isArray(T)){const A=u.find(J=>T.includes(J.token)||J.token===k);if(A)throw new RangeError(`The format string mustn't contain \`${A.fullToken}\` and \`${v}\` at the same time`)}else if(D.incompatibleTokens==="*"&&u.length>0)throw new RangeError(`The format string mustn't contain \`${v}\` and any other token at the same time`);u.push({token:k,fullToken:v});const S=D.run(n,v,o.match,l);if(!S)return rt(e,NaN);c.push(S.setter),n=S.rest}else{if(k.match(El))throw new RangeError("Format string contains an unescaped latin alphabet character `"+k+"`");if(v==="''"?v="'":k==="'"&&(v=Bl(v)),n.indexOf(v)===0)n=n.slice(v.length);else return rt(e,NaN)}}if(n.length>0&&Il.test(n))return rt(e,NaN);const d=c.map(v=>v.priority).sort((v,k)=>k-v).filter((v,k,D)=>D.indexOf(v)===k).map(v=>c.filter(k=>k.priority===v).sort((k,D)=>D.subPriority-k.subPriority)).map(v=>v[0]);let f=R(e);if(isNaN(f.getTime()))return rt(e,NaN);const g={};for(const v of d){if(!v.validate(f,l))return rt(e,NaN);const k=v.set(f,g,l);Array.isArray(k)?(f=k[0],Object.assign(g,k[1])):f=k}return rt(e,f)}function Bl(n){return n.match(Fl)[1].replace(Rl,"'")}function Nl(n){const t=R(n);return t.setMinutes(0,0,0),t}function Wl(n){const t=R(n);return t.setMilliseconds(0),t}function Hl(n,t){const e=(t==null?void 0:t.additionalDigits)??2,i=$l(n);let s;if(i.date){const l=ql(i.date,e);s=Ul(l.restDateString,l.year)}if(!s||isNaN(s.getTime()))return new Date(NaN);const o=s.getTime();let r=0,a;if(i.time&&(r=Xl(i.time),isNaN(r)))return new Date(NaN);if(i.timezone){if(a=Kl(i.timezone),isNaN(a))return new Date(NaN)}else{const l=new Date(o+r),c=new Date(0);return c.setFullYear(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()),c.setHours(l.getUTCHours(),l.getUTCMinutes(),l.getUTCSeconds(),l.getUTCMilliseconds()),c}return new Date(o+r+a)}const fn={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Vl=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Yl=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,jl=/^([+-])(\d{2})(?::?(\d{2}))?$/;function $l(n){const t={},e=n.split(fn.dateTimeDelimiter);let i;if(e.length>2)return t;if(/:/.test(e[0])?i=e[0]:(t.date=e[0],i=e[1],fn.timeZoneDelimiter.test(t.date)&&(t.date=n.split(fn.timeZoneDelimiter)[0],i=n.substr(t.date.length,n.length))),i){const s=fn.timezone.exec(i);s?(t.time=i.replace(s[1],""),t.timezone=s[1]):t.time=i}return t}function ql(n,t){const e=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),i=n.match(e);if(!i)return{year:NaN,restDateString:""};const s=i[1]?parseInt(i[1]):null,o=i[2]?parseInt(i[2]):null;return{year:o===null?s:o*100,restDateString:n.slice((i[1]||i[2]).length)}}function Ul(n,t){if(t===null)return new Date(NaN);const e=n.match(Vl);if(!e)return new Date(NaN);const i=!!e[4],s=Ce(e[1]),o=Ce(e[2])-1,r=Ce(e[3]),a=Ce(e[4]),l=Ce(e[5])-1;if(i)return tc(t,a,l)?Gl(t,a,l):new Date(NaN);{const c=new Date(0);return!Zl(t,o,r)||!Jl(t,s)?new Date(NaN):(c.setUTCFullYear(t,o,Math.max(s,r)),c)}}function Ce(n){return n?parseInt(n):1}function Xl(n){const t=n.match(Yl);if(!t)return NaN;const e=li(t[1]),i=li(t[2]),s=li(t[3]);return ec(e,i,s)?e*rn+i*an+s*1e3:NaN}function li(n){return n&&parseFloat(n.replace(",","."))||0}function Kl(n){if(n==="Z")return 0;const t=n.match(jl);if(!t)return 0;const e=t[1]==="+"?-1:1,i=parseInt(t[2]),s=t[3]&&parseInt(t[3])||0;return nc(i,s)?e*(i*rn+s*an):NaN}function Gl(n,t,e){const i=new Date(0);i.setUTCFullYear(n,0,4);const s=i.getUTCDay()||7,o=(t-1)*7+e+1-s;return i.setUTCDate(i.getUTCDate()+o),i}const Ql=[31,null,31,30,31,30,31,31,30,31,30,31];function ir(n){return n%400===0||n%4===0&&n%100!==0}function Zl(n,t,e){return t>=0&&t<=11&&e>=1&&e<=(Ql[t]||(ir(n)?29:28))}function Jl(n,t){return t>=1&&t<=(ir(n)?366:365)}function tc(n,t,e){return t>=1&&t<=53&&e>=0&&e<=6}function ec(n,t,e){return n===24?t===0&&e===0:e>=0&&e<60&&t>=0&&t<60&&n>=0&&n<25}function nc(n,t){return t>=0&&t<=59}class ic{get(t,e,i){return dt.get("/api/v2/summary/basic",{params:{start:t,end:e,code:i}})}}function Ct(n,t,e){const i=j(t,"y-MM-dd")+"_"+j(e,"y-MM-dd")+"_"+n;return console.log("getCacheKey: "+i),String(i)}let ci=!1;const sc=()=>({balanceBox:{amounts:[],subtitles:[]},billBox:{paid:[],unpaid:[]},leftBox:{left:[],perDay:[]},netBox:{net:[]},autoConversion:!1,loading:!1,boxData:null,boxOptions:null,getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Ct("dashboard-boxes-data",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){this.boxData=s,this.generateOptions(this.boxData);return}new ic().get(j(n,"yyyy-MM-dd"),j(t,"yyyy-MM-dd"),null).then(r=>{this.boxData=r.data,window.store.set(e,r.data),this.generateOptions(this.boxData)})},generateOptions(n){this.balanceBox={amounts:[],subtitles:[]},this.billBox={paid:[],unpaid:[]},this.leftBox={left:[],perDay:[]},this.netBox={net:[]};let t={};for(const e in n)if(n.hasOwnProperty(e)){const i=n[e];if(!i.hasOwnProperty("key"))continue;let s=i.key;if(this.autoConversion){if(s.startsWith("balance-in-native")){this.balanceBox.amounts.push(I(i.value,i.currency_code)),t.hasOwnProperty(i.currency_code)||(t[i.currency_code]="");continue}if(s.startsWith("spent-in-native")){t.hasOwnProperty(i.currency_code)||(t[i.currency_code]=""),t[i.currency_code]=t[i.currency_code]+I(i.value,i.currency_code);continue}if(s.startsWith("earned-in-native")){t.hasOwnProperty(i.currency_code)||(t[i.currency_code]=""),t[i.currency_code]=I(i.value,i.currency_code)+" + "+t[i.currency_code];continue}if(s.startsWith("bills-unpaid-in-native")){this.billBox.unpaid.push(I(i.value,i.currency_code));continue}if(s.startsWith("bills-paid-in-native")){this.billBox.paid.push(I(i.value,i.currency_code));continue}if(s.startsWith("left-to-spend-in-native")){this.leftBox.left.push(I(i.value,i.currency_code));continue}if(s.startsWith("left-per-day-to-spend-in-native")){this.leftBox.perDay.push(I(i.value,i.currency_code));continue}if(s.startsWith("net-worth-in-native")){this.netBox.net.push(I(i.value,i.currency_code));continue}}if(!this.autoConversion&&!s.endsWith("native")){if(s.startsWith("balance-in-")){this.balanceBox.amounts.push(I(i.value,i.currency_code));continue}if(s.startsWith("spent-in-")){t.hasOwnProperty(i.currency_code)||(t[i.currency_code]=""),t[i.currency_code]=t[i.currency_code]+I(i.value,i.currency_code);continue}if(s.startsWith("earned-in-")){t.hasOwnProperty(i.currency_code)||(t[i.currency_code]=""),t[i.currency_code]=I(i.value,i.currency_code)+" + "+t[i.currency_code];continue}if(s.startsWith("bills-unpaid-in-")){this.billBox.unpaid.push(I(i.value,i.currency_code));continue}if(s.startsWith("bills-paid-in-")){this.billBox.paid.push(I(i.value,i.currency_code));continue}if(s.startsWith("left-to-spend-in-")){this.leftBox.left.push(I(i.value,i.currency_code));continue}if(s.startsWith("left-per-day-to-spend-in-")){this.leftBox.perDay.push(I(i.value,i.currency_code));continue}s.startsWith("net-worth-in-")&&this.netBox.net.push(I(i.value,i.currency_code))}}for(let e in t)t.hasOwnProperty(e)&&this.balanceBox.subtitles.push(t[e]);this.loading=!1},loadBoxes(){if(this.loading!==!0){if(this.loading=!0,this.boxData===null){this.getFreshData();return}this.generateOptions(this.boxData),this.loading=!1}},init(){Promise.all([lt("viewRange"),lt("autoConversion",!1)]).then(n=>{ci=!0,this.autoConversion=n[1],this.loadBoxes()}),window.store.observe("end",()=>{ci&&(this.boxData=null,this.loadBoxes())}),window.store.observe("autoConversion",n=>{ci&&(this.autoConversion=n,this.loadBoxes())})}});class oc{put(t,e){let i="/api/v1/preferences/"+t;return dt.put(i,{data:e})}}function rc(n,t=null){window.store.set(n,t),new oc().put(n,t).then(i=>{}).catch(()=>{new fa().post(n,t).then(s=>{})})}let ac=class{dashboard(t,e){let i=j(t,"y-MM-dd"),s=j(e,"y-MM-dd");return dt.get("/api/v2/chart/account/dashboard",{params:{start:i,end:s}})}expense(t,e){let i=j(t,"y-MM-dd"),s=j(e,"y-MM-dd");return dt.get("/api/v2/chart/account/expense-dashboard",{params:{start:i,end:s}})}},gs=class{get(t,e){let i={date:j(e,"y-MM-dd").slice(0,10)};return e?dt.get("/api/v2/accounts/"+t,{params:i}):dt.get("/api/v2/accounts/"+t)}transactions(t,e){const i={page:e.page??1};return e.hasOwnProperty("start")&&(i.start=j(e.start,"y-MM-dd")),e.hasOwnProperty("end")&&(i.end=j(e.end,"y-MM-dd")),dt.get("/api/v2/accounts/"+t+"/transactions",{params:i})}};/*! * @kurkle/color v0.3.2 * https://github.com/kurkle/color#readme * (c) 2023 Jukka Kurkela * Released under the MIT License */function cn(n){return n+.5|0}const Nt=(n,t,e)=>Math.max(Math.min(n,e),t);function Ne(n){return Nt(cn(n*2.55),0,255)}function $t(n){return Nt(cn(n*255),0,255)}function Ft(n){return Nt(cn(n/2.55)/100,0,1)}function ps(n){return Nt(cn(n*100),0,100)}const yt={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},Ti=[..."0123456789ABCDEF"],lc=n=>Ti[n&15],cc=n=>Ti[(n&240)>>4]+Ti[n&15],gn=n=>(n&240)>>4===(n&15),hc=n=>gn(n.r)&&gn(n.g)&&gn(n.b)&&gn(n.a);function uc(n){var t=n.length,e;return n[0]==="#"&&(t===4||t===5?e={r:255&yt[n[1]]*17,g:255&yt[n[2]]*17,b:255&yt[n[3]]*17,a:t===5?yt[n[4]]*17:255}:(t===7||t===9)&&(e={r:yt[n[1]]<<4|yt[n[2]],g:yt[n[3]]<<4|yt[n[4]],b:yt[n[5]]<<4|yt[n[6]],a:t===9?yt[n[7]]<<4|yt[n[8]]:255})),e}const dc=(n,t)=>n<255?t(n):"";function fc(n){var t=hc(n)?lc:cc;return n?"#"+t(n.r)+t(n.g)+t(n.b)+dc(n.a,t):void 0}const gc=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function sr(n,t,e){const i=t*Math.min(e,1-e),s=(o,r=(o+n/30)%12)=>e-i*Math.max(Math.min(r-3,9-r,1),-1);return[s(0),s(8),s(4)]}function pc(n,t,e){const i=(s,o=(s+n/60)%6)=>e-e*t*Math.max(Math.min(o,4-o,1),0);return[i(5),i(3),i(1)]}function mc(n,t,e){const i=sr(n,1,.5);let s;for(t+e>1&&(s=1/(t+e),t*=s,e*=s),s=0;s<3;s++)i[s]*=1-t-e,i[s]+=t;return i}function bc(n,t,e,i,s){return n===s?(t-e)/i+(t.5?h/(2-o-r):h/(o+r),l=bc(e,i,s,h,o),l=l*60+.5),[l|0,c||0,a]}function Ki(n,t,e,i){return(Array.isArray(t)?n(t[0],t[1],t[2]):n(t,e,i)).map($t)}function Gi(n,t,e){return Ki(sr,n,t,e)}function yc(n,t,e){return Ki(mc,n,t,e)}function _c(n,t,e){return Ki(pc,n,t,e)}function or(n){return(n%360+360)%360}function xc(n){const t=gc.exec(n);let e=255,i;if(!t)return;t[5]!==i&&(e=t[6]?Ne(+t[5]):$t(+t[5]));const s=or(+t[2]),o=+t[3]/100,r=+t[4]/100;return t[1]==="hwb"?i=yc(s,o,r):t[1]==="hsv"?i=_c(s,o,r):i=Gi(s,o,r),{r:i[0],g:i[1],b:i[2],a:e}}function wc(n,t){var e=Xi(n);e[0]=or(e[0]+t),e=Gi(e),n.r=e[0],n.g=e[1],n.b=e[2]}function vc(n){if(!n)return;const t=Xi(n),e=t[0],i=ps(t[1]),s=ps(t[2]);return n.a<255?`hsla(${e}, ${i}%, ${s}%, ${Ft(n.a)})`:`hsl(${e}, ${i}%, ${s}%)`}const ms={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"},bs={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 Mc(){const n={},t=Object.keys(bs),e=Object.keys(ms);let i,s,o,r,a;for(i=0;i>16&255,o>>8&255,o&255]}return n}let pn;function kc(n){pn||(pn=Mc(),pn.transparent=[0,0,0,0]);const t=pn[n.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}const Pc=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Dc(n){const t=Pc.exec(n);let e=255,i,s,o;if(t){if(t[7]!==i){const r=+t[7];e=t[8]?Ne(r):Nt(r*255,0,255)}return i=+t[1],s=+t[3],o=+t[5],i=255&(t[2]?Ne(i):Nt(i,0,255)),s=255&(t[4]?Ne(s):Nt(s,0,255)),o=255&(t[6]?Ne(o):Nt(o,0,255)),{r:i,g:s,b:o,a:e}}}function Cc(n){return n&&(n.a<255?`rgba(${n.r}, ${n.g}, ${n.b}, ${Ft(n.a)})`:`rgb(${n.r}, ${n.g}, ${n.b})`)}const hi=n=>n<=.0031308?n*12.92:Math.pow(n,1/2.4)*1.055-.055,de=n=>n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4);function Sc(n,t,e){const i=de(Ft(n.r)),s=de(Ft(n.g)),o=de(Ft(n.b));return{r:$t(hi(i+e*(de(Ft(t.r))-i))),g:$t(hi(s+e*(de(Ft(t.g))-s))),b:$t(hi(o+e*(de(Ft(t.b))-o))),a:n.a+e*(t.a-n.a)}}function mn(n,t,e){if(n){let i=Xi(n);i[t]=Math.max(0,Math.min(i[t]+i[t]*e,t===0?360:1)),i=Gi(i),n.r=i[0],n.g=i[1],n.b=i[2]}}function rr(n,t){return n&&Object.assign(t||{},n)}function ys(n){var t={r:0,g:0,b:0,a:255};return Array.isArray(n)?n.length>=3&&(t={r:n[0],g:n[1],b:n[2],a:255},n.length>3&&(t.a=$t(n[3]))):(t=rr(n,{r:0,g:0,b:0,a:1}),t.a=$t(t.a)),t}function Oc(n){return n.charAt(0)==="r"?Dc(n):xc(n)}class it{constructor(t){if(t instanceof it)return t;const e=typeof t;let i;e==="object"?i=ys(t):e==="string"&&(i=uc(t)||kc(t)||Oc(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=rr(this._rgb);return t&&(t.a=Ft(t.a)),t}set rgb(t){this._rgb=ys(t)}rgbString(){return this._valid?Cc(this._rgb):void 0}hexString(){return this._valid?fc(this._rgb):void 0}hslString(){return this._valid?vc(this._rgb):void 0}mix(t,e){if(t){const i=this.rgb,s=t.rgb;let o;const r=e===o?.5:e,a=2*r-1,l=i.a-s.a,c=((a*l===-1?a:(a+l)/(1+a*l))+1)/2;o=1-c,i.r=255&c*i.r+o*s.r+.5,i.g=255&c*i.g+o*s.g+.5,i.b=255&c*i.b+o*s.b+.5,i.a=r*i.a+(1-r)*s.a,this.rgb=i}return this}interpolate(t,e){return t&&(this._rgb=Sc(this._rgb,t._rgb,e)),this}clone(){return new it(this.rgb)}alpha(t){return this._rgb.a=$t(t),this}clearer(t){const e=this._rgb;return e.a*=1-t,this}greyscale(){const t=this._rgb,e=cn(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=e,this}opaquer(t){const e=this._rgb;return e.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return mn(this._rgb,2,t),this}darken(t){return mn(this._rgb,2,-t),this}saturate(t){return mn(this._rgb,1,t),this}desaturate(t){return mn(this._rgb,1,-t),this}rotate(t){return wc(this._rgb,t),this}}/*! * Chart.js v4.4.1 * https://www.chartjs.org * (c) 2023 Chart.js Contributors * Released under the MIT License */function St(){}const Tc=(()=>{let n=0;return()=>n++})();function F(n){return n===null||typeof n>"u"}function W(n){if(Array.isArray&&Array.isArray(n))return!0;const t=Object.prototype.toString.call(n);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function L(n){return n!==null&&Object.prototype.toString.call(n)==="[object Object]"}function q(n){return(typeof n=="number"||n instanceof Number)&&isFinite(+n)}function mt(n,t){return q(n)?n:t}function C(n,t){return typeof n>"u"?t:n}const Ac=(n,t)=>typeof n=="string"&&n.endsWith("%")?parseFloat(n)/100:+n/t,ar=(n,t)=>typeof n=="string"&&n.endsWith("%")?parseFloat(n)/100*t:+n;function N(n,t,e){if(n&&typeof n.call=="function")return n.apply(e,t)}function z(n,t,e,i){let s,o,r;if(W(n))if(o=n.length,i)for(s=o-1;s>=0;s--)t.call(e,n[s],s);else for(s=0;sn,x:n=>n.x,y:n=>n.y};function Rc(n){const t=n.split("."),e=[];let i="";for(const s of t)i+=s,i.endsWith("\\")?i=i.slice(0,-1)+".":(e.push(i),i="");return e}function Ic(n){const t=Rc(n);return e=>{for(const i of t){if(i==="")break;e=e&&e[i]}return e}}function qt(n,t){return(_s[t]||(_s[t]=Ic(t)))(n)}function Qi(n){return n.charAt(0).toUpperCase()+n.slice(1)}const Qe=n=>typeof n<"u",Ut=n=>typeof n=="function",xs=(n,t)=>{if(n.size!==t.size)return!1;for(const e of n)if(!t.has(e))return!1;return!0};function Ec(n){return n.type==="mouseup"||n.type==="click"||n.type==="contextmenu"}const $=Math.PI,H=2*$,zc=H+$,Yn=Number.POSITIVE_INFINITY,Bc=$/180,Z=$/2,Qt=$/4,ws=$*2/3,Wt=Math.log10,Dt=Math.sign;function $e(n,t,e){return Math.abs(n-t)s-o).pop(),t}function Ze(n){return!isNaN(parseFloat(n))&&isFinite(n)}function Wc(n,t){const e=Math.round(n);return e-t<=n&&e+t>=n}function cr(n,t,e){let i,s,o;for(i=0,s=n.length;il&&c=Math.min(t,e)-i&&n<=Math.max(t,e)+i}function Ji(n,t,e){e=e||(r=>n[r]1;)o=s+i>>1,e(o)?s=o:i=o;return{lo:s,hi:i}}const oe=(n,t,e,i)=>Ji(n,e,i?s=>{const o=n[s][t];return on[s][t]Ji(n,e,i=>n[i][t]>=e);function jc(n,t,e){let i=0,s=n.length;for(;ii&&n[s-1]>e;)s--;return i>0||s{const i="_onData"+Qi(e),s=n[e];Object.defineProperty(n,e,{configurable:!0,enumerable:!1,value(...o){const r=s.apply(this,o);return n._chartjs.listeners.forEach(a=>{typeof a[i]=="function"&&a[i](...o)}),r}})})}function ks(n,t){const e=n._chartjs;if(!e)return;const i=e.listeners,s=i.indexOf(t);s!==-1&&i.splice(s,1),!(i.length>0)&&(ur.forEach(o=>{delete n[o]}),delete n._chartjs)}function dr(n){const t=new Set(n);return t.size===n.length?n:Array.from(t)}const fr=function(){return typeof window>"u"?function(n){return n()}:window.requestAnimationFrame}();function gr(n,t){let e=[],i=!1;return function(...s){e=s,i||(i=!0,fr.call(window,()=>{i=!1,n.apply(t,e)}))}}function qc(n,t){let e;return function(...i){return t?(clearTimeout(e),e=setTimeout(n,t,i)):n.apply(this,i),t}}const pr=n=>n==="start"?"left":n==="end"?"right":"center",gt=(n,t,e)=>n==="start"?t:n==="end"?e:(t+e)/2,Uc=(n,t,e,i)=>n===(i?"left":"right")?e:n==="center"?(t+e)/2:t;function Xc(n,t,e){const i=t.length;let s=0,o=i;if(n._sorted){const{iScale:r,_parsed:a}=n,l=r.axis,{min:c,max:h,minDefined:u,maxDefined:d}=r.getUserBounds();u&&(s=st(Math.min(oe(a,l,c).lo,e?i:oe(t,l,r.getPixelForValue(c)).lo),0,i-1)),d?o=st(Math.max(oe(a,r.axis,h,!0).hi+1,e?0:oe(t,l,r.getPixelForValue(h),!0).hi+1),s,i)-s:o=i-s}return{start:s,count:o}}function Kc(n){const{xScale:t,yScale:e,_scaleRanges:i}=n,s={xmin:t.min,xmax:t.max,ymin:e.min,ymax:e.max};if(!i)return n._scaleRanges=s,!0;const o=i.xmin!==t.min||i.xmax!==t.max||i.ymin!==e.min||i.ymax!==e.max;return Object.assign(i,s),o}const bn=n=>n===0||n===1,Ps=(n,t,e)=>-(Math.pow(2,10*(n-=1))*Math.sin((n-t)*H/e)),Ds=(n,t,e)=>Math.pow(2,-10*n)*Math.sin((n-t)*H/e)+1,qe={linear:n=>n,easeInQuad:n=>n*n,easeOutQuad:n=>-n*(n-2),easeInOutQuad:n=>(n/=.5)<1?.5*n*n:-.5*(--n*(n-2)-1),easeInCubic:n=>n*n*n,easeOutCubic:n=>(n-=1)*n*n+1,easeInOutCubic:n=>(n/=.5)<1?.5*n*n*n:.5*((n-=2)*n*n+2),easeInQuart:n=>n*n*n*n,easeOutQuart:n=>-((n-=1)*n*n*n-1),easeInOutQuart:n=>(n/=.5)<1?.5*n*n*n*n:-.5*((n-=2)*n*n*n-2),easeInQuint:n=>n*n*n*n*n,easeOutQuint:n=>(n-=1)*n*n*n*n+1,easeInOutQuint:n=>(n/=.5)<1?.5*n*n*n*n*n:.5*((n-=2)*n*n*n*n+2),easeInSine:n=>-Math.cos(n*Z)+1,easeOutSine:n=>Math.sin(n*Z),easeInOutSine:n=>-.5*(Math.cos($*n)-1),easeInExpo:n=>n===0?0:Math.pow(2,10*(n-1)),easeOutExpo:n=>n===1?1:-Math.pow(2,-10*n)+1,easeInOutExpo:n=>bn(n)?n:n<.5?.5*Math.pow(2,10*(n*2-1)):.5*(-Math.pow(2,-10*(n*2-1))+2),easeInCirc:n=>n>=1?n:-(Math.sqrt(1-n*n)-1),easeOutCirc:n=>Math.sqrt(1-(n-=1)*n),easeInOutCirc:n=>(n/=.5)<1?-.5*(Math.sqrt(1-n*n)-1):.5*(Math.sqrt(1-(n-=2)*n)+1),easeInElastic:n=>bn(n)?n:Ps(n,.075,.3),easeOutElastic:n=>bn(n)?n:Ds(n,.075,.3),easeInOutElastic(n){return bn(n)?n:n<.5?.5*Ps(n*2,.1125,.45):.5+.5*Ds(n*2-1,.1125,.45)},easeInBack(n){return n*n*((1.70158+1)*n-1.70158)},easeOutBack(n){return(n-=1)*n*((1.70158+1)*n+1.70158)+1},easeInOutBack(n){let t=1.70158;return(n/=.5)<1?.5*(n*n*(((t*=1.525)+1)*n-t)):.5*((n-=2)*n*(((t*=1.525)+1)*n+t)+2)},easeInBounce:n=>1-qe.easeOutBounce(1-n),easeOutBounce(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375},easeInOutBounce:n=>n<.5?qe.easeInBounce(n*2)*.5:qe.easeOutBounce(n*2-1)*.5+.5};function ts(n){if(n&&typeof n=="object"){const t=n.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function ye(n){return ts(n)?n:new it(n)}function Ue(n){return ts(n)?n:new it(n).saturate(.5).darken(.1).hexString()}const Gc=["x","y","borderWidth","radius","tension"],Qc=["color","borderColor","backgroundColor"];function Zc(n){n.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),n.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),n.set("animations",{colors:{type:"color",properties:Qc},numbers:{type:"number",properties:Gc}}),n.describe("animations",{_fallback:"animation"}),n.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>t|0}}}})}function Jc(n){n.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const Cs=new Map;function th(n,t){t=t||{};const e=n+JSON.stringify(t);let i=Cs.get(e);return i||(i=new Intl.NumberFormat(n,t),Cs.set(e,i)),i}function hn(n,t,e){return th(t,e).format(n)}const mr={values(n){return W(n)?n:""+n},numeric(n,t,e){if(n===0)return"0";const i=this.chart.options.locale;let s,o=n;if(e.length>1){const c=Math.max(Math.abs(e[0].value),Math.abs(e[e.length-1].value));(c<1e-4||c>1e15)&&(s="scientific"),o=eh(n,e)}const r=Wt(Math.abs(o)),a=isNaN(r)?1:Math.max(Math.min(-1*Math.floor(r),20),0),l={notation:s,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),hn(n,i,l)},logarithmic(n,t,e){if(n===0)return"0";const i=e[t].significand||n/Math.pow(10,Math.floor(Wt(n)));return[1,2,3,5,10,15].includes(i)||t>.8*e.length?mr.numeric.call(this,n,t,e):""}};function eh(n,t){let e=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(e)>=1&&n!==Math.floor(n)&&(e=n-Math.floor(n)),e}var ei={formatters:mr};function nh(n){n.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:(t,e)=>e.lineWidth,tickColor:(t,e)=>e.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:ei.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),n.route("scale.ticks","color","","color"),n.route("scale.grid","color","","borderColor"),n.route("scale.border","color","","borderColor"),n.route("scale.title","color","","color"),n.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),n.describe("scales",{_fallback:"scale"}),n.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}const le=Object.create(null),Li=Object.create(null);function Xe(n,t){if(!t)return n;const e=t.split(".");for(let i=0,s=e.length;ii.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=(i,s)=>Ue(s.backgroundColor),this.hoverBorderColor=(i,s)=>Ue(s.borderColor),this.hoverColor=(i,s)=>Ue(s.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(t),this.apply(e)}set(t,e){return ui(this,t,e)}get(t){return Xe(this,t)}describe(t,e){return ui(Li,t,e)}override(t,e){return ui(le,t,e)}route(t,e,i,s){const o=Xe(this,t),r=Xe(this,i),a="_"+e;Object.defineProperties(o,{[a]:{value:o[e],writable:!0},[e]:{enumerable:!0,get(){const l=this[a],c=r[s];return L(l)?Object.assign({},c,l):C(l,c)},set(l){this[a]=l}}})}apply(t){t.forEach(e=>e(this))}}var U=new ih({_scriptable:n=>!n.startsWith("on"),_indexable:n=>n!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[Zc,Jc,nh]);function sh(n){return!n||F(n.size)||F(n.family)?null:(n.style?n.style+" ":"")+(n.weight?n.weight+" ":"")+n.size+"px "+n.family}function jn(n,t,e,i,s){let o=t[s];return o||(o=t[s]=n.measureText(s).width,e.push(s)),o>i&&(i=o),i}function oh(n,t,e,i){i=i||{};let s=i.data=i.data||{},o=i.garbageCollect=i.garbageCollect||[];i.font!==t&&(s=i.data={},o=i.garbageCollect=[],i.font=t),n.save(),n.font=t;let r=0;const a=e.length;let l,c,h,u,d;for(l=0;le.length){for(l=0;l0&&n.stroke()}}function It(n,t,e){return e=e||.5,!t||n&&n.x>t.left-e&&n.xt.top-e&&n.y0&&o.strokeColor!=="";let l,c;for(n.save(),n.font=s.string,lh(n,o),l=0;l+n||0;function es(n,t){const e={},i=L(t),s=i?Object.keys(t):t,o=L(n)?i?r=>C(n[r],n[t[r]]):r=>n[r]:()=>n;for(const r of s)e[r]=gh(o(r));return e}function yr(n){return es(n,{top:"y",right:"x",bottom:"y",left:"x"})}function re(n){return es(n,["topLeft","topRight","bottomLeft","bottomRight"])}function ct(n){const t=yr(n);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function tt(n,t){n=n||{},t=t||U.font;let e=C(n.size,t.size);typeof e=="string"&&(e=parseInt(e,10));let i=C(n.style,t.style);i&&!(""+i).match(dh)&&(console.warn('Invalid font style specified: "'+i+'"'),i=void 0);const s={family:C(n.family,t.family),lineHeight:fh(C(n.lineHeight,t.lineHeight),e),size:e,style:i,weight:C(n.weight,t.weight),string:""};return s.string=sh(s),s}function yn(n,t,e,i){let s=!0,o,r,a;for(o=0,r=n.length;oe&&a===0?0:a+l;return{min:r(i,-Math.abs(o)),max:r(s,o)}}function Xt(n,t){return Object.assign(Object.create(n),t)}function ns(n,t=[""],e,i,s=()=>n[0]){const o=e||n;typeof i>"u"&&(i=vr("_fallback",n));const r={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:n,_rootScopes:o,_fallback:i,_getTarget:s,override:a=>ns([a,...n],t,o,i)};return new Proxy(r,{deleteProperty(a,l){return delete a[l],delete a._keys,delete n[0][l],!0},get(a,l){return xr(a,l,()=>Mh(l,t,n,a))},getOwnPropertyDescriptor(a,l){return Reflect.getOwnPropertyDescriptor(a._scopes[0],l)},getPrototypeOf(){return Reflect.getPrototypeOf(n[0])},has(a,l){return Ts(a).includes(l)},ownKeys(a){return Ts(a)},set(a,l,c){const h=a._storage||(a._storage=s());return a[l]=h[l]=c,delete a._keys,!0}})}function Me(n,t,e,i){const s={_cacheable:!1,_proxy:n,_context:t,_subProxy:e,_stack:new Set,_descriptors:_r(n,i),setContext:o=>Me(n,o,e,i),override:o=>Me(n.override(o),t,e,i)};return new Proxy(s,{deleteProperty(o,r){return delete o[r],delete n[r],!0},get(o,r,a){return xr(o,r,()=>bh(o,r,a))},getOwnPropertyDescriptor(o,r){return o._descriptors.allKeys?Reflect.has(n,r)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(n,r)},getPrototypeOf(){return Reflect.getPrototypeOf(n)},has(o,r){return Reflect.has(n,r)},ownKeys(){return Reflect.ownKeys(n)},set(o,r,a){return n[r]=a,delete o[r],!0}})}function _r(n,t={scriptable:!0,indexable:!0}){const{_scriptable:e=t.scriptable,_indexable:i=t.indexable,_allKeys:s=t.allKeys}=n;return{allKeys:s,scriptable:e,indexable:i,isScriptable:Ut(e)?e:()=>e,isIndexable:Ut(i)?i:()=>i}}const mh=(n,t)=>n?n+Qi(t):t,is=(n,t)=>L(t)&&n!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function xr(n,t,e){if(Object.prototype.hasOwnProperty.call(n,t))return n[t];const i=e();return n[t]=i,i}function bh(n,t,e){const{_proxy:i,_context:s,_subProxy:o,_descriptors:r}=n;let a=i[t];return Ut(a)&&r.isScriptable(t)&&(a=yh(t,a,n,e)),W(a)&&a.length&&(a=_h(t,a,n,r.isIndexable)),is(t,a)&&(a=Me(a,s,o&&o[t],r)),a}function yh(n,t,e,i){const{_proxy:s,_context:o,_subProxy:r,_stack:a}=e;if(a.has(n))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+n);a.add(n);let l=t(o,r||i);return a.delete(n),is(n,l)&&(l=ss(s._scopes,s,n,l)),l}function _h(n,t,e,i){const{_proxy:s,_context:o,_subProxy:r,_descriptors:a}=e;if(typeof o.index<"u"&&i(n))return t[o.index%t.length];if(L(t[0])){const l=t,c=s._scopes.filter(h=>h!==l);t=[];for(const h of l){const u=ss(c,s,n,h);t.push(Me(u,o,r&&r[n],a))}}return t}function wr(n,t,e){return Ut(n)?n(t,e):n}const xh=(n,t)=>n===!0?t:typeof n=="string"?qt(t,n):void 0;function wh(n,t,e,i,s){for(const o of t){const r=xh(e,o);if(r){n.add(r);const a=wr(r._fallback,e,s);if(typeof a<"u"&&a!==e&&a!==i)return a}else if(r===!1&&typeof i<"u"&&e!==i)return null}return!1}function ss(n,t,e,i){const s=t._rootScopes,o=wr(t._fallback,e,i),r=[...n,...s],a=new Set;a.add(i);let l=Os(a,r,e,o||e,i);return l===null||typeof o<"u"&&o!==e&&(l=Os(a,r,o,l,i),l===null)?!1:ns(Array.from(a),[""],s,o,()=>vh(t,e,i))}function Os(n,t,e,i,s){for(;e;)e=wh(n,t,e,i,s);return e}function vh(n,t,e){const i=n._getTarget();t in i||(i[t]={});const s=i[t];return W(s)&&L(e)?e:s||{}}function Mh(n,t,e,i){let s;for(const o of t)if(s=vr(mh(o,n),e),typeof s<"u")return is(n,s)?ss(e,i,n,s):s}function vr(n,t){for(const e of t){if(!e)continue;const i=e[n];if(typeof i<"u")return i}}function Ts(n){let t=n._keys;return t||(t=n._keys=kh(n._scopes)),t}function kh(n){const t=new Set;for(const e of n)for(const i of Object.keys(e).filter(s=>!s.startsWith("_")))t.add(i);return Array.from(t)}function Ph(n,t,e,i){const{iScale:s}=n,{key:o="r"}=this._parsing,r=new Array(i);let a,l,c,h;for(a=0,l=i;atn==="x"?"y":"x";function Ch(n,t,e,i){const s=n.skip?t:n,o=t,r=e.skip?t:e,a=Ai(o,s),l=Ai(r,o);let c=a/(a+l),h=l/(a+l);c=isNaN(c)?0:c,h=isNaN(h)?0:h;const u=i*c,d=i*h;return{previous:{x:o.x-u*(r.x-s.x),y:o.y-u*(r.y-s.y)},next:{x:o.x+d*(r.x-s.x),y:o.y+d*(r.y-s.y)}}}function Sh(n,t,e){const i=n.length;let s,o,r,a,l,c=ke(n,0);for(let h=0;h!c.skip)),t.cubicInterpolationMode==="monotone")Th(n,s);else{let c=i?n[n.length-1]:n[0];for(o=0,r=n.length;on.ownerDocument.defaultView.getComputedStyle(n,null);function Fh(n,t){return si(n).getPropertyValue(t)}const Rh=["top","right","bottom","left"];function ae(n,t,e){const i={};e=e?"-"+e:"";for(let s=0;s<4;s++){const o=Rh[s];i[o]=parseFloat(n[t+"-"+o+e])||0}return i.width=i.left+i.right,i.height=i.top+i.bottom,i}const Ih=(n,t,e)=>(n>0||t>0)&&(!e||!e.shadowRoot);function Eh(n,t){const e=n.touches,i=e&&e.length?e[0]:n,{offsetX:s,offsetY:o}=i;let r=!1,a,l;if(Ih(s,o,n.target))a=s,l=o;else{const c=t.getBoundingClientRect();a=i.clientX-c.left,l=i.clientY-c.top,r=!0}return{x:a,y:l,box:r}}function ne(n,t){if("native"in n)return n;const{canvas:e,currentDevicePixelRatio:i}=t,s=si(e),o=s.boxSizing==="border-box",r=ae(s,"padding"),a=ae(s,"border","width"),{x:l,y:c,box:h}=Eh(n,e),u=r.left+(h&&a.left),d=r.top+(h&&a.top);let{width:f,height:g}=t;return o&&(f-=r.width+a.width,g-=r.height+a.height),{x:Math.round((l-u)/f*e.width/i),y:Math.round((c-d)/g*e.height/i)}}function zh(n,t,e){let i,s;if(t===void 0||e===void 0){const o=rs(n);if(!o)t=n.clientWidth,e=n.clientHeight;else{const r=o.getBoundingClientRect(),a=si(o),l=ae(a,"border","width"),c=ae(a,"padding");t=r.width-c.width-l.width,e=r.height-c.height-l.height,i=$n(a.maxWidth,o,"clientWidth"),s=$n(a.maxHeight,o,"clientHeight")}}return{width:t,height:e,maxWidth:i||Yn,maxHeight:s||Yn}}const xn=n=>Math.round(n*10)/10;function Bh(n,t,e,i){const s=si(n),o=ae(s,"margin"),r=$n(s.maxWidth,n,"clientWidth")||Yn,a=$n(s.maxHeight,n,"clientHeight")||Yn,l=zh(n,t,e);let{width:c,height:h}=l;if(s.boxSizing==="content-box"){const d=ae(s,"border","width"),f=ae(s,"padding");c-=f.width+d.width,h-=f.height+d.height}return c=Math.max(0,c-o.width),h=Math.max(0,i?c/i:h-o.height),c=xn(Math.min(c,r,l.maxWidth)),h=xn(Math.min(h,a,l.maxHeight)),c&&!h&&(h=xn(c/2)),(t!==void 0||e!==void 0)&&i&&l.height&&h>l.height&&(h=l.height,c=xn(Math.floor(h*i))),{width:c,height:h}}function As(n,t,e){const i=t||1,s=Math.floor(n.height*i),o=Math.floor(n.width*i);n.height=Math.floor(n.height),n.width=Math.floor(n.width);const r=n.canvas;return r.style&&(e||!r.style.height&&!r.style.width)&&(r.style.height=`${n.height}px`,r.style.width=`${n.width}px`),n.currentDevicePixelRatio!==i||r.height!==s||r.width!==o?(n.currentDevicePixelRatio=i,r.height=s,r.width=o,n.ctx.setTransform(i,0,0,i,0,0),!0):!1}const Nh=function(){let n=!1;try{const t={get passive(){return n=!0,!1}};os()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return n}();function Ls(n,t){const e=Fh(n,t),i=e&&e.match(/^(\d+)(\.\d+)?px$/);return i?+i[1]:void 0}function ie(n,t,e,i){return{x:n.x+e*(t.x-n.x),y:n.y+e*(t.y-n.y)}}function Wh(n,t,e,i){return{x:n.x+e*(t.x-n.x),y:i==="middle"?e<.5?n.y:t.y:i==="after"?e<1?n.y:t.y:e>0?t.y:n.y}}function Hh(n,t,e,i){const s={x:n.cp2x,y:n.cp2y},o={x:t.cp1x,y:t.cp1y},r=ie(n,s,e),a=ie(s,o,e),l=ie(o,t,e),c=ie(r,a,e),h=ie(a,l,e);return ie(c,h,e)}const Vh=function(n,t){return{x(e){return n+n+t-e},setWidth(e){t=e},textAlign(e){return e==="center"?e:e==="right"?"left":"right"},xPlus(e,i){return e-i},leftForLtr(e,i){return e-i}}},Yh=function(){return{x(n){return n},setWidth(n){},textAlign(n){return n},xPlus(n,t){return n+t},leftForLtr(n,t){return n}}};function we(n,t,e){return n?Vh(t,e):Yh()}function kr(n,t){let e,i;(t==="ltr"||t==="rtl")&&(e=n.canvas.style,i=[e.getPropertyValue("direction"),e.getPropertyPriority("direction")],e.setProperty("direction",t,"important"),n.prevTextDirection=i)}function Pr(n,t){t!==void 0&&(delete n.prevTextDirection,n.canvas.style.setProperty("direction",t[0],t[1]))}function Dr(n){return n==="angle"?{between:Je,compare:Hc,normalize:bt}:{between:Rt,compare:(t,e)=>t-e,normalize:t=>t}}function Fs({start:n,end:t,count:e,loop:i,style:s}){return{start:n%e,end:t%e,loop:i&&(t-n+1)%e===0,style:s}}function jh(n,t,e){const{property:i,start:s,end:o}=e,{between:r,normalize:a}=Dr(i),l=t.length;let{start:c,end:h,loop:u}=n,d,f;if(u){for(c+=l,h+=l,d=0,f=l;dl(s,w,b)&&a(s,w)!==0,x=()=>a(o,b)===0||l(o,w,b),P=()=>p||M(),v=()=>!p||x();for(let k=h,D=h;k<=u;++k)y=t[k%r],!y.skip&&(b=c(y[i]),b!==w&&(p=l(b,s,o),m===null&&P()&&(m=a(b,s)===0?k:D),m!==null&&v()&&(g.push(Fs({start:m,end:k,loop:d,count:r,style:f})),m=null),D=k,w=b));return m!==null&&g.push(Fs({start:m,end:u,loop:d,count:r,style:f})),g}function Sr(n,t){const e=[],i=n.segments;for(let s=0;ss&&n[o%t].skip;)o--;return o%=t,{start:s,end:o}}function qh(n,t,e,i){const s=n.length,o=[];let r=t,a=n[t],l;for(l=t+1;l<=e;++l){const c=n[l%s];c.skip||c.stop?a.skip||(i=!1,o.push({start:t%s,end:(l-1)%s,loop:i}),t=r=c.stop?l:null):(r=l,a.skip&&(t=l)),a=c}return r!==null&&o.push({start:t%s,end:r%s,loop:i}),o}function Uh(n,t){const e=n.points,i=n.options.spanGaps,s=e.length;if(!s)return[];const o=!!n._loop,{start:r,end:a}=$h(e,s,o,i);if(i===!0)return Rs(n,[{start:r,end:a,loop:o}],e,t);const l=aa({chart:t,initial:e.initial,numSteps:r,currentStep:Math.min(i-e.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=fr.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((i,s)=>{if(!i.running||!i.items.length)return;const o=i.items;let r=o.length-1,a=!1,l;for(;r>=0;--r)l=o[r],l._active?(l._total>i.duration&&(i.duration=l._total),l.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(s.draw(),this._notify(s,i,t,"progress")),o.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),e+=o.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){!e||!e.length||this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((i,s)=>Math.max(i,s._duration),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!(!e||!e.running||!e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var At=new Gh;const Es="transparent",Qh={boolean(n,t,e){return e>.5?t:n},color(n,t,e){const i=ye(n||Es),s=i.valid&&ye(t||Es);return s&&s.valid?s.mix(i,e).hexString():t},number(n,t,e){return n+(t-n)*e}};class Zh{constructor(t,e,i,s){const o=e[i];s=yn([t.to,s,o,t.from]);const r=yn([t.from,o,s]);this._active=!0,this._fn=t.fn||Qh[t.type||typeof r],this._easing=qe[t.easing]||qe.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=r,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const s=this._target[this._prop],o=i-this._start,r=this._duration-o;this._start=i,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=yn([t.to,e,s,t.from]),this._from=yn([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,s=this._prop,o=this._from,r=this._loop,a=this._to;let l;if(this._active=o!==a&&(r||e1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[s]=this._fn(o,a,l)}wait(){const t=this._promises||(this._promises=[]);return new Promise((e,i)=>{t.push({res:e,rej:i})})}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let s=0;s{const o=t[s];if(!L(o))return;const r={};for(const a of e)r[a]=o[a];(W(o.properties)&&o.properties||[s]).forEach(a=>{(a===s||!i.has(a))&&i.set(a,r)})})}_animateOptions(t,e){const i=e.options,s=tu(t,i);if(!s)return[];const o=this._createAnimations(s,i);return i.$shared&&Jh(t.options.$animations,i).then(()=>{t.options=i},()=>{}),o}_createAnimations(t,e){const i=this._properties,s=[],o=t.$animations||(t.$animations={}),r=Object.keys(e),a=Date.now();let l;for(l=r.length-1;l>=0;--l){const c=r[l];if(c.charAt(0)==="$")continue;if(c==="options"){s.push(...this._animateOptions(t,e));continue}const h=e[c];let u=o[c];const d=i.get(c);if(u)if(d&&u.active()){u.update(d,h,a);continue}else u.cancel();if(!d||!d.duration){t[c]=h;continue}o[c]=u=new Zh(d,t,c,h),s.push(u)}return s}update(t,e){if(this._properties.size===0){Object.assign(t,e);return}const i=this._createAnimations(t,e);if(i.length)return At.add(this._chart,i),!0}}function Jh(n,t){const e=[],i=Object.keys(t);for(let s=0;s0||!e&&o<0)return s.index}return null}function Hs(n,t){const{chart:e,_cachedMeta:i}=n,s=e._stacks||(e._stacks={}),{iScale:o,vScale:r,index:a}=i,l=o.axis,c=r.axis,h=su(o,r,i),u=t.length;let d;for(let f=0;fe[i].axis===t).shift()}function au(n,t){return Xt(n,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function lu(n,t,e){return Xt(n,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:e,index:t,mode:"default",type:"data"})}function Se(n,t){const e=n.controller.index,i=n.vScale&&n.vScale.axis;if(i){t=t||n._parsed;for(const s of t){const o=s._stacks;if(!o||o[i]===void 0||o[i][e]===void 0)return;delete o[i][e],o[i]._visualValues!==void 0&&o[i]._visualValues[e]!==void 0&&delete o[i]._visualValues[e]}}}const fi=n=>n==="reset"||n==="none",Vs=(n,t)=>t?n:Object.assign({},n),cu=(n,t,e)=>n&&!t.hidden&&t._stacked&&{keys:Tr(e,!0),values:null};class Et{constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=Ns(t.vScale,t),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(t){this.index!==t&&Se(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(u,d,f,g)=>u==="x"?d:u==="r"?g:f,o=e.xAxisID=C(i.xAxisID,di(t,"x")),r=e.yAxisID=C(i.yAxisID,di(t,"y")),a=e.rAxisID=C(i.rAxisID,di(t,"r")),l=e.indexAxis,c=e.iAxisID=s(l,o,r,a),h=e.vAxisID=s(l,r,o,a);e.xScale=this.getScaleForId(o),e.yScale=this.getScaleForId(r),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(c),e.vScale=this.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&ks(this._data,this),t._stacked&&Se(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(L(e))this._data=iu(e);else if(i!==e){if(i){ks(i,this);const s=this._cachedMeta;Se(s),s._parsed=[]}e&&Object.isExtensible(e)&&$c(e,this),this._syncList=[],this._data=e}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta,i=this.getDataset();let s=!1;this._dataCheck();const o=e._stacked;e._stacked=Ns(e.vScale,e),e.stack!==i.stack&&(s=!0,Se(e),e.stack=i.stack),this._resyncElements(t),(s||o!==e._stacked)&&Hs(this,e._parsed)}configure(){const t=this.chart.config,e=t.datasetScopeKeys(this._type),i=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(i,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:i,_data:s}=this,{iScale:o,_stacked:r}=i,a=o.axis;let l=t===0&&e===s.length?!0:i._sorted,c=t>0&&i._parsed[t-1],h,u,d;if(this._parsing===!1)i._parsed=s,i._sorted=!0,d=s;else{W(s[t])?d=this.parseArrayData(i,s,t,e):L(s[t])?d=this.parseObjectData(i,s,t,e):d=this.parsePrimitiveData(i,s,t,e);const f=()=>u[a]===null||c&&u[a]p||u=0;--d)if(!g()){this.updateRangeFromParsed(c,t,f,l);break}}return c}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,o,r;for(s=0,o=e.length;s=0&&tthis.getContext(i,s,e),p=c.resolveNamedOptions(d,f,g,u);return p.$shared&&(p.$shared=l,o[r]=Object.freeze(Vs(p,l))),p}_resolveAnimations(t,e,i){const s=this.chart,o=this._cachedDataOpts,r=`animation-${e}`,a=o[r];if(a)return a;let l;if(s.options.animation!==!1){const h=this.chart.config,u=h.datasetAnimationScopeKeys(this._type,e),d=h.getOptionScopes(this.getDataset(),u);l=h.createResolver(d,this.getContext(t,i,e))}const c=new Or(s,l&&l.animations);return l&&l._cacheable&&(o[r]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||fi(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const i=this.resolveDataElementOptions(t,e),s=this._sharedOptions,o=this.getSharedOptions(i),r=this.includeOptions(e,o)||o!==s;return this.updateSharedOptions(o,e,i),{sharedOptions:o,includeOptions:r}}updateElement(t,e,i,s){fi(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!fi(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,s){t.active=s;const o=this.getStyle(e,s);this._resolveAnimations(e,i,s).update(t,{options:!s&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,i=this._cachedMeta.data;for(const[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];const s=i.length,o=e.length,r=Math.min(o,s);r&&this.parse(0,r),o>s?this._insertElements(s,o-s,t):o{for(c.length+=e,a=c.length-1;a>=r;a--)c[a]=c[a-e]};for(l(o),a=t;as-o))}return n._cache.$bar}function uu(n){const t=n.iScale,e=hu(t,n.type);let i=t._length,s,o,r,a;const l=()=>{r===32767||r===-32768||(Qe(a)&&(i=Math.min(i,Math.abs(r-a)||i)),a=r)};for(s=0,o=e.length;s0?s[n-1]:null,a=nMath.abs(a)&&(l=a,c=r),t[e.axis]=c,t._custom={barStart:l,barEnd:c,start:s,end:o,min:r,max:a}}function Ar(n,t,e,i){return W(n)?gu(n,t,e,i):t[e.axis]=e.parse(n,i),t}function Ys(n,t,e,i){const s=n.iScale,o=n.vScale,r=s.getLabels(),a=s===o,l=[];let c,h,u,d;for(c=e,h=e+i;c=e?1:-1)}function mu(n){let t,e,i,s,o;return n.horizontal?(t=n.base>n.x,e="left",i="right"):(t=n.basel.controller.options.grouped),o=i.options.stacked,r=[],a=l=>{const c=l.controller.getParsed(e),h=c&&c[l.vScale.axis];if(F(h)||isNaN(h))return!0};for(const l of s)if(!(e!==void 0&&a(l))&&((o===!1||r.indexOf(l.stack)===-1||o===void 0&&l.stack===void 0)&&r.push(l.stack),l.index===t))break;return r.length||r.push(void 0),r}_getStackCount(t){return this._getStacks(void 0,t).length}_getStackIndex(t,e,i){const s=this._getStacks(t,i),o=e!==void 0?s.indexOf(e):-1;return o===-1?s.length-1:o}_getRuler(){const t=this.options,e=this._cachedMeta,i=e.iScale,s=[];let o,r;for(o=0,r=e.data.length;oJe(w,a,l,!0)?1:Math.max(M,M*e,x,x*e),g=(w,M,x)=>Je(w,a,l,!0)?-1:Math.min(M,M*e,x,x*e),p=f(0,c,u),m=f(Z,h,d),b=g($,c,u),y=g($+Z,h,d);i=(p-b)/2,s=(m-y)/2,o=-(p+b)/2,r=-(m+y)/2}return{ratioX:i,ratioY:s,offsetX:o,offsetY:r}}class _e extends Et{constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const i=this.getDataset().data,s=this._cachedMeta;if(this._parsing===!1)s._parsed=i;else{let o=l=>+i[l];if(L(i[t])){const{key:l="value"}=this._parsing;o=c=>+qt(i[c],l)}let r,a;for(r=t,a=t+e;r0&&!isNaN(t)?H*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],o=hn(e._parsed[t],i.options.locale);return{label:s[t]||"",value:o}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,o,r,a,l;if(!t){for(s=0,o=i.data.datasets.length;st!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")}),_(_e,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i,color:s}}=t.legend.options;return e.labels.map((o,r)=>{const l=t.getDatasetMeta(0).controller.getStyle(r);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:s,lineWidth:l.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}}}});class Rn extends Et{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const e=this._cachedMeta,{dataset:i,data:s=[],_dataset:o}=e,r=this.chart._animationsDisabled;let{start:a,count:l}=Xc(e,s,r);this._drawStart=a,this._drawCount=l,Kc(e)&&(a=0,l=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!o._decimated,i.points=s;const c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(i,void 0,{animated:!r,options:c},t),this.updateElements(s,a,l,t)}updateElements(t,e,i,s){const o=s==="reset",{iScale:r,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:h,includeOptions:u}=this._getSharedOptions(e,s),d=r.axis,f=a.axis,{spanGaps:g,segment:p}=this.options,m=Ze(g)?g:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||o||s==="none",y=e+i,w=t.length;let M=e>0&&this.getParsed(e-1);for(let x=0;x=y){v.skip=!0;continue}const k=this.getParsed(x),D=F(k[f]),T=v[d]=r.getPixelForValue(k[d],x),S=v[f]=o||D?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,k,l):k[f],x);v.skip=isNaN(T)||isNaN(S)||D,v.stop=x>0&&Math.abs(k[d]-M[d])>m,p&&(v.parsed=k,v.raw=c.data[x]),u&&(v.options=h||this.resolveDataElementOptions(x,P.active?"active":s)),b||this.updateElement(P,x,v,s),M=k}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const o=s[0].size(this.resolveDataElementOptions(0)),r=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,o,r)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}_(Rn,"id","line"),_(Rn,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),_(Rn,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});class In extends Et{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],o=hn(e._parsed[t].r,i.options.locale);return{label:s[t]||"",value:o}}parseObjectData(t,e,i,s){return Ph.bind(this)(t,e,i,s)}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){const t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((i,s)=>{const o=this.getParsed(s).r;!isNaN(o)&&this.chart.getDataVisibility(s)&&(oe.max&&(e.max=o))}),e}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),o=Math.max(s/2,0),r=Math.max(i.cutoutPercentage?o/100*i.cutoutPercentage:1,0),a=(o-r)/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,e,i,s){const o=s==="reset",r=this.chart,l=r.options.animation,c=this._cachedMeta.rScale,h=c.xCenter,u=c.yCenter,d=c.getIndexAngle(0)-.5*$;let f=d,g;const p=360/this.countVisibleElements();for(g=0;g{!isNaN(this.getParsed(s).r)&&this.chart.getDataVisibility(s)&&e++}),e}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?xt(this.resolveDataElementOptions(t,e).angle||i):0}}_(In,"id","polarArea"),_(In,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),_(In,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i,color:s}}=t.legend.options;return e.labels.map((o,r)=>{const l=t.getDatasetMeta(0).controller.getStyle(r);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:s,lineWidth:l.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});class Ri extends _e{}_(Ri,"id","pie"),_(Ri,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});function Jt(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class as{constructor(t){_(this,"options");this.options=t||{}}static override(t){Object.assign(as.prototype,t)}init(){}formats(){return Jt()}parse(){return Jt()}format(){return Jt()}add(){return Jt()}diff(){return Jt()}startOf(){return Jt()}endOf(){return Jt()}}var Lr={_date:as};function wu(n,t,e,i){const{controller:s,data:o,_sorted:r}=n,a=s._cachedMeta.iScale;if(a&&t===a.axis&&t!=="r"&&r&&o.length){const l=a._reversePixels?Yc:oe;if(i){if(s._sharedOptions){const c=o[0],h=typeof c.getRange=="function"&&c.getRange(t);if(h){const u=l(o,t,e-h),d=l(o,t,e+h);return{lo:u.lo,hi:d.hi}}}}else return l(o,t,e)}return{lo:0,hi:o.length-1}}function un(n,t,e,i,s){const o=n.getSortedVisibleDatasetMetas(),r=e[t];for(let a=0,l=o.length;a{l[r](t[e],s)&&(o.push({element:l,datasetIndex:c,index:h}),a=a||l.inRange(t.x,t.y,s))}),i&&!a?[]:o}var Pu={evaluateInteractionItems:un,modes:{index(n,t,e,i){const s=ne(t,n),o=e.axis||"x",r=e.includeInvisible||!1,a=e.intersect?pi(n,s,o,i,r):mi(n,s,o,!1,i,r),l=[];return a.length?(n.getSortedVisibleDatasetMetas().forEach(c=>{const h=a[0].index,u=c.data[h];u&&!u.skip&&l.push({element:u,datasetIndex:c.index,index:h})}),l):[]},dataset(n,t,e,i){const s=ne(t,n),o=e.axis||"xy",r=e.includeInvisible||!1;let a=e.intersect?pi(n,s,o,i,r):mi(n,s,o,!1,i,r);if(a.length>0){const l=a[0].datasetIndex,c=n.getDatasetMeta(l).data;a=[];for(let h=0;he.pos===t)}function Us(n,t){return n.filter(e=>Fr.indexOf(e.pos)===-1&&e.box.axis===t)}function Te(n,t){return n.sort((e,i)=>{const s=t?i:e,o=t?e:i;return s.weight===o.weight?s.index-o.index:s.weight-o.weight})}function Du(n){const t=[];let e,i,s,o,r,a;for(e=0,i=(n||[]).length;ec.box.fullSize),!0),i=Te(Oe(t,"left"),!0),s=Te(Oe(t,"right")),o=Te(Oe(t,"top"),!0),r=Te(Oe(t,"bottom")),a=Us(t,"x"),l=Us(t,"y");return{fullSize:e,leftAndTop:i.concat(o),rightAndBottom:s.concat(l).concat(r).concat(a),chartArea:Oe(t,"chartArea"),vertical:i.concat(s).concat(l),horizontal:o.concat(r).concat(a)}}function Xs(n,t,e,i){return Math.max(n[e],t[e])+Math.max(n[i],t[i])}function Rr(n,t){n.top=Math.max(n.top,t.top),n.left=Math.max(n.left,t.left),n.bottom=Math.max(n.bottom,t.bottom),n.right=Math.max(n.right,t.right)}function Tu(n,t,e,i){const{pos:s,box:o}=e,r=n.maxPadding;if(!L(s)){e.size&&(n[s]-=e.size);const u=i[e.stack]||{size:0,count:1};u.size=Math.max(u.size,e.horizontal?o.height:o.width),e.size=u.size/u.count,n[s]+=e.size}o.getPadding&&Rr(r,o.getPadding());const a=Math.max(0,t.outerWidth-Xs(r,n,"left","right")),l=Math.max(0,t.outerHeight-Xs(r,n,"top","bottom")),c=a!==n.w,h=l!==n.h;return n.w=a,n.h=l,e.horizontal?{same:c,other:h}:{same:h,other:c}}function Au(n){const t=n.maxPadding;function e(i){const s=Math.max(t[i]-n[i],0);return n[i]+=s,s}n.y+=e("top"),n.x+=e("left"),e("right"),e("bottom")}function Lu(n,t){const e=t.maxPadding;function i(s){const o={left:0,top:0,right:0,bottom:0};return s.forEach(r=>{o[r]=Math.max(t[r],e[r])}),o}return i(n?["left","right"]:["top","bottom"])}function We(n,t,e,i){const s=[];let o,r,a,l,c,h;for(o=0,r=n.length,c=0;o{typeof p.beforeLayout=="function"&&p.beforeLayout()});const h=l.reduce((p,m)=>m.box.options&&m.box.options.display===!1?p:p+1,0)||1,u=Object.freeze({outerWidth:t,outerHeight:e,padding:s,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/h,hBoxMaxHeight:r/2}),d=Object.assign({},s);Rr(d,ct(i));const f=Object.assign({maxPadding:d,w:o,h:r,x:s.left,y:s.top},s),g=Su(l.concat(c),u);We(a.fullSize,f,u,g),We(l,f,u,g),We(c,f,u,g)&&We(l,f,u,g),Au(f),Ks(a.leftAndTop,f,u,g),f.x+=f.w,f.y+=f.h,Ks(a.rightAndBottom,f,u,g),n.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},z(a.chartArea,p=>{const m=p.box;Object.assign(m,n.chartArea),m.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}};class Ir{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,i,s){return e=Math.max(0,e||t.width),i=i||t.height,{width:e,height:Math.max(0,s?Math.floor(e/s):i)}}isAttached(t){return!0}updateConfig(t){}}class Fu extends Ir{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const En="$chartjs",Ru={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},Gs=n=>n===null||n==="";function Iu(n,t){const e=n.style,i=n.getAttribute("height"),s=n.getAttribute("width");if(n[En]={initial:{height:i,width:s,style:{display:e.display,height:e.height,width:e.width}}},e.display=e.display||"block",e.boxSizing=e.boxSizing||"border-box",Gs(s)){const o=Ls(n,"width");o!==void 0&&(n.width=o)}if(Gs(i))if(n.style.height==="")n.height=n.width/(t||2);else{const o=Ls(n,"height");o!==void 0&&(n.height=o)}return n}const Er=Nh?{passive:!0}:!1;function Eu(n,t,e){n.addEventListener(t,e,Er)}function zu(n,t,e){n.canvas.removeEventListener(t,e,Er)}function Bu(n,t){const e=Ru[n.type]||n.type,{x:i,y:s}=ne(n,t);return{type:e,chart:t,native:n,x:i!==void 0?i:null,y:s!==void 0?s:null}}function qn(n,t){for(const e of n)if(e===t||e.contains(t))return!0}function Nu(n,t,e){const i=n.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||qn(a.addedNodes,i),r=r&&!qn(a.removedNodes,i);r&&e()});return s.observe(document,{childList:!0,subtree:!0}),s}function Wu(n,t,e){const i=n.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||qn(a.removedNodes,i),r=r&&!qn(a.addedNodes,i);r&&e()});return s.observe(document,{childList:!0,subtree:!0}),s}const en=new Map;let Qs=0;function zr(){const n=window.devicePixelRatio;n!==Qs&&(Qs=n,en.forEach((t,e)=>{e.currentDevicePixelRatio!==n&&t()}))}function Hu(n,t){en.size||window.addEventListener("resize",zr),en.set(n,t)}function Vu(n){en.delete(n),en.size||window.removeEventListener("resize",zr)}function Yu(n,t,e){const i=n.canvas,s=i&&rs(i);if(!s)return;const o=gr((a,l)=>{const c=s.clientWidth;e(a,l),c{const l=a[0],c=l.contentRect.width,h=l.contentRect.height;c===0&&h===0||o(c,h)});return r.observe(s),Hu(n,o),r}function bi(n,t,e){e&&e.disconnect(),t==="resize"&&Vu(n)}function ju(n,t,e){const i=n.canvas,s=gr(o=>{n.ctx!==null&&e(Bu(o,n))},n);return Eu(i,t,s),s}class $u extends Ir{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(Iu(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e[En])return!1;const i=e[En].initial;["height","width"].forEach(o=>{const r=i[o];F(r)?e.removeAttribute(o):e.setAttribute(o,r)});const s=i.style||{};return Object.keys(s).forEach(o=>{e.style[o]=s[o]}),e.width=e.width,delete e[En],!0}addEventListener(t,e,i){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),r={attach:Nu,detach:Wu,resize:Yu}[e]||ju;s[e]=r(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];if(!s)return;({attach:bi,detach:bi,resize:bi}[e]||zu)(t,e,s),i[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return Bh(t,e,i,s)}isAttached(t){const e=rs(t);return!!(e&&e.isConnected)}}function qu(n){return!os()||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas?Fu:$u}class wt{constructor(){_(this,"x");_(this,"y");_(this,"active",!1);_(this,"options");_(this,"$animations")}tooltipPosition(t){const{x:e,y:i}=this.getProps(["x","y"],t);return{x:e,y:i}}hasValue(){return Ze(this.x)&&Ze(this.y)}getProps(t,e){const i=this.$animations;if(!e||!i)return this;const s={};return t.forEach(o=>{s[o]=i[o]&&i[o].active()?i[o]._to:this[o]}),s}}_(wt,"defaults",{}),_(wt,"defaultRoutes");function Uu(n,t){const e=n.options.ticks,i=Xu(n),s=Math.min(e.maxTicksLimit||i,i),o=e.major.enabled?Gu(t):[],r=o.length,a=o[0],l=o[r-1],c=[];if(r>s)return Qu(t,c,o,r/s),c;const h=Ku(o,t,s);if(r>0){let u,d;const f=r>1?Math.round((l-a)/(r-1)):null;for(vn(t,c,h,F(f)?0:a-f,a),u=0,d=r-1;us)return l}return Math.max(s,1)}function Gu(n){const t=[];let e,i;for(e=0,i=n.length;en==="left"?"right":n==="right"?"left":n,Zs=(n,t,e)=>t==="top"||t==="left"?n[t]+e:n[t]-e,Js=(n,t)=>Math.min(t||n,n);function to(n,t){const e=[],i=n.length/t,s=n.length;let o=0;for(;or+a)))return l}function ed(n,t){z(n,e=>{const i=e.gc,s=i.length/2;let o;if(s>t){for(o=0;oi?i:e,i=s&&e>i?e:i,{min:mt(e,mt(i,e)),max:mt(i,mt(e,i))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){N(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=ph(this,o,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=a=o||i<=1||!this.isHorizontal()){this.labelRotation=s;return}const h=this._getLabelSizes(),u=h.widest.width,d=h.highest.height,f=st(this.chart.width-u,0,this.maxWidth);a=t.offset?this.maxWidth/i:f/(i-1),u+6>a&&(a=f/(i-(t.offset?.5:1)),l=this.maxHeight-Ae(t.grid)-e.padding-eo(t.title,this.chart.options.font),c=Math.sqrt(u*u+d*d),r=Zi(Math.min(Math.asin(st((h.highest.height+6)/a,-1,1)),Math.asin(st(l/c,-1,1))-Math.asin(st(d/c,-1,1)))),r=Math.max(s,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){N(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){N(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){const l=eo(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=Ae(o)+l):(t.height=this.maxHeight,t.width=Ae(o)+l),i.display&&this.ticks.length){const{first:c,last:h,widest:u,highest:d}=this._getLabelSizes(),f=i.padding*2,g=xt(this.labelRotation),p=Math.cos(g),m=Math.sin(g);if(a){const b=i.mirror?0:m*u.width+p*d.height;t.height=Math.min(this.maxHeight,t.height+b+f)}else{const b=i.mirror?0:p*u.width+m*d.height;t.width=Math.min(this.maxWidth,t.width+b+f)}this._calculatePadding(c,h,m,p)}}this._handleMargins(),a?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,i,s){const{ticks:{align:o,padding:r},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const h=this.getPixelForTick(0)-this.left,u=this.right-this.getPixelForTick(this.ticks.length-1);let d=0,f=0;l?c?(d=s*t.width,f=i*e.height):(d=i*t.height,f=s*e.width):o==="start"?f=e.width:o==="end"?d=t.width:o!=="inner"&&(d=t.width/2,f=e.width/2),this.paddingLeft=Math.max((d-h+r)*this.width/(this.width-h),0),this.paddingRight=Math.max((f-u+r)*this.width/(this.width-u),0)}else{let h=e.height/2,u=t.height/2;o==="start"?(h=0,u=t.height):o==="end"&&(h=e.height,u=0),this.paddingTop=h+r,this.paddingBottom=u+r}}_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(){N(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return e==="top"||e==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let e,i;for(e=0,i=t.length;e({width:r[D]||0,height:a[D]||0});return{first:k(0),last:k(e-1),widest:k(P),highest:k(v),widths:r,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return Vc(this._alignToPixels?Zt(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&ta*s?a/i:l/s:l*s0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:o,position:r,border:a}=s,l=o.offset,c=this.isHorizontal(),u=this.ticks.length+(l?1:0),d=Ae(o),f=[],g=a.setContext(this.getContext()),p=g.display?g.width:0,m=p/2,b=function(V){return Zt(i,V,p)};let y,w,M,x,P,v,k,D,T,S,A,J;if(r==="top")y=b(this.bottom),v=this.bottom-d,D=y-m,S=b(t.top)+m,J=t.bottom;else if(r==="bottom")y=b(this.top),S=t.top,J=b(t.bottom)-m,v=y+m,D=this.top+d;else if(r==="left")y=b(this.right),P=this.right-d,k=y-m,T=b(t.left)+m,A=t.right;else if(r==="right")y=b(this.left),T=t.left,A=b(t.right)-m,P=y+m,k=this.left+d;else if(e==="x"){if(r==="center")y=b((t.top+t.bottom)/2+.5);else if(L(r)){const V=Object.keys(r)[0],K=r[V];y=b(this.chart.scales[V].getPixelForValue(K))}S=t.top,J=t.bottom,v=y+m,D=v+d}else if(e==="y"){if(r==="center")y=b((t.left+t.right)/2);else if(L(r)){const V=Object.keys(r)[0],K=r[V];y=b(this.chart.scales[V].getPixelForValue(K))}P=y-m,k=P-d,T=t.left,A=t.right}const ft=C(s.ticks.maxTicksLimit,u),B=Math.max(1,Math.ceil(u/ft));for(w=0;w0&&(Gt-=Kt/2);break}dn={left:Gt,top:De,width:Kt+ue.width,height:Pe+ue.height,color:B.backdropColor}}m.push({label:M,font:D,textOffset:A,options:{rotation:p,color:K,strokeColor:_t,strokeWidth:nt,textAlign:he,textBaseline:J,translation:[x,P],backdrop:dn}})}return m}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;if(-xt(this.labelRotation))return t==="top"?"left":"right";let s="center";return e.align==="start"?s="left":e.align==="end"?s="right":e.align==="inner"&&(s="inner"),s}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:i,mirror:s,padding:o}}=this.options,r=this._getLabelSizes(),a=t+o,l=r.widest.width;let c,h;return e==="left"?s?(h=this.right+o,i==="near"?c="left":i==="center"?(c="center",h+=l/2):(c="right",h+=l)):(h=this.right-a,i==="near"?c="right":i==="center"?(c="center",h-=l/2):(c="left",h=this.left)):e==="right"?s?(h=this.left+o,i==="near"?c="right":i==="center"?(c="center",h-=l/2):(c="left",h-=l)):(h=this.left+a,i==="near"?c="left":i==="center"?(c="center",h+=l/2):(c="right",h=this.right)):c="right",{textAlign:c,x:h}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,e=this.options.position;if(e==="left"||e==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(e==="top"||e==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){const{ctx:t,options:{backgroundColor:e},left:i,top:s,width:o,height:r}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(i,s,o,r),t.restore())}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const s=this.ticks.findIndex(o=>o.value===t);return s>=0?e.setContext(this.getContext(s)).lineWidth:0}drawGrid(t){const e=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let o,r;const a=(l,c,h)=>{!h.width||!h.color||(i.save(),i.lineWidth=h.width,i.strokeStyle=h.color,i.setLineDash(h.borderDash||[]),i.lineDashOffset=h.borderDashOffset,i.beginPath(),i.moveTo(l.x,l.y),i.lineTo(c.x,c.y),i.stroke(),i.restore())};if(e.display)for(o=0,r=s.length;o{this.draw(o)}}]:[{z:i,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let o,r;for(o=0,r=e.length;o{const i=e.split("."),s=i.pop(),o=[n].concat(i).join("."),r=t[e].split("."),a=r.pop(),l=r.join(".");U.route(o,s,l,a)})}function ld(n){return"id"in n&&"defaults"in n}class cd{constructor(){this.controllers=new Mn(Et,"datasets",!0),this.elements=new Mn(wt,"elements"),this.plugins=new Mn(Object,"plugins"),this.scales=new Mn(ce,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,i){[...e].forEach(s=>{const o=i||this._getRegistryForType(s);i||o.isForType(s)||o===this.plugins&&s.id?this._exec(t,o,s):z(s,r=>{const a=i||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,e,i){const s=Qi(t);N(i["before"+s],[],i),e[t](i),N(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;eo.filter(a=>!r.some(l=>a.plugin.id===l.plugin.id));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function ud(n){const t={},e=[],i=Object.keys(Mt.plugins.items);for(let o=0;o1&&no(n[0].toLowerCase());if(i)return i}throw new Error(`Cannot determine type of '${n}' axis. Please provide 'axis' or 'position' option.`)}function io(n,t,e){if(e[t+"AxisID"]===n)return{axis:t}}function yd(n,t){if(t.data&&t.data.datasets){const e=t.data.datasets.filter(i=>i.xAxisID===n||i.yAxisID===n);if(e.length)return io(n,"x",e[0])||io(n,"y",e[0])}return{}}function _d(n,t){const e=le[n.type]||{scales:{}},i=t.scales||{},s=Ii(n.type,t),o=Object.create(null);return Object.keys(i).forEach(r=>{const a=i[r];if(!L(a))return console.error(`Invalid scale configuration for scale: ${r}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${r}`);const l=Ei(r,a,yd(r,n),U.scales[a.type]),c=md(l,s),h=e.scales||{};o[r]=je(Object.create(null),[{axis:l},a,h[l],h[c]])}),n.data.datasets.forEach(r=>{const a=r.type||n.type,l=r.indexAxis||Ii(a,t),h=(le[a]||{}).scales||{};Object.keys(h).forEach(u=>{const d=pd(u,l),f=r[d+"AxisID"]||d;o[f]=o[f]||Object.create(null),je(o[f],[{axis:d},i[f],h[u]])})}),Object.keys(o).forEach(r=>{const a=o[r];je(a,[U.scales[a.type],U.scale])}),o}function Br(n){const t=n.options||(n.options={});t.plugins=C(t.plugins,{}),t.scales=_d(n,t)}function Nr(n){return n=n||{},n.datasets=n.datasets||[],n.labels=n.labels||[],n}function xd(n){return n=n||{},n.data=Nr(n.data),Br(n),n}const so=new Map,Wr=new Set;function kn(n,t){let e=so.get(n);return e||(e=t(),so.set(n,e),Wr.add(e)),e}const Le=(n,t,e)=>{const i=qt(t,e);i!==void 0&&n.add(i)};class wd{constructor(t){this._config=xd(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Nr(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Br(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return kn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return kn(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return kn(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id,i=this.type;return kn(`${i}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){const i=this._scopeCache;let s=i.get(t);return(!s||e)&&(s=new Map,i.set(t,s)),s}getOptionScopes(t,e,i){const{options:s,type:o}=this,r=this._cachedScopes(t,i),a=r.get(e);if(a)return a;const l=new Set;e.forEach(h=>{t&&(l.add(t),h.forEach(u=>Le(l,t,u))),h.forEach(u=>Le(l,s,u)),h.forEach(u=>Le(l,le[o]||{},u)),h.forEach(u=>Le(l,U,u)),h.forEach(u=>Le(l,Li,u))});const c=Array.from(l);return c.length===0&&c.push(Object.create(null)),Wr.has(e)&&r.set(e,c),c}chartOptionScopes(){const{options:t,type:e}=this;return[t,le[e]||{},U.datasets[e]||{},{type:e},U,Li]}resolveNamedOptions(t,e,i,s=[""]){const o={$shared:!0},{resolver:r,subPrefixes:a}=oo(this._resolverCache,t,s);let l=r;if(Md(r,e)){o.$shared=!1,i=Ut(i)?i():i;const c=this.createResolver(t,i,a);l=Me(r,i,c)}for(const c of e)o[c]=l[c];return o}createResolver(t,e,i=[""],s){const{resolver:o}=oo(this._resolverCache,t,i);return L(e)?Me(o,e,void 0,s):o}}function oo(n,t,e){let i=n.get(t);i||(i=new Map,n.set(t,i));const s=e.join();let o=i.get(s);return o||(o={resolver:ns(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},i.set(s,o)),o}const vd=n=>L(n)&&Object.getOwnPropertyNames(n).some(t=>Ut(n[t]));function Md(n,t){const{isScriptable:e,isIndexable:i}=_r(n);for(const s of t){const o=e(s),r=i(s),a=(r||o)&&n[s];if(o&&(Ut(a)||vd(a))||r&&W(a))return!0}return!1}var kd="4.4.1";const Pd=["top","bottom","left","right","chartArea"];function ro(n,t){return n==="top"||n==="bottom"||Pd.indexOf(n)===-1&&t==="x"}function ao(n,t){return function(e,i){return e[n]===i[n]?e[t]-i[t]:e[n]-i[n]}}function lo(n){const t=n.chart,e=t.options.animation;t.notifyPlugins("afterRender"),N(e&&e.onComplete,[n],t)}function Dd(n){const t=n.chart,e=t.options.animation;N(e&&e.onProgress,[n],t)}function Hr(n){return os()&&typeof n=="string"?n=document.getElementById(n):n&&n.length&&(n=n[0]),n&&n.canvas&&(n=n.canvas),n}const zn={},co=n=>{const t=Hr(n);return Object.values(zn).filter(e=>e.canvas===t).pop()};function Cd(n,t,e){const i=Object.keys(n);for(const s of i){const o=+s;if(o>=t){const r=n[s];delete n[s],(e>0||o>t)&&(n[o+e]=r)}}}function Sd(n,t,e,i){return!e||n.type==="mouseout"?null:i?t:n}function Pn(n,t,e){return n.options.clip?n[e]:t[e]}function Od(n,t){const{xScale:e,yScale:i}=n;return e&&i?{left:Pn(e,t,"left"),right:Pn(e,t,"right"),top:Pn(i,t,"top"),bottom:Pn(i,t,"bottom")}:t}class at{static register(...t){Mt.add(...t),ho()}static unregister(...t){Mt.remove(...t),ho()}constructor(t,e){const i=this.config=new wd(e),s=Hr(t),o=co(s);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const r=i.createResolver(i.chartOptionScopes(),this.getContext());this.platform=new(i.platform||qu(s)),this.platform.updateConfig(i);const a=this.platform.acquireContext(s,r.aspectRatio),l=a&&a.canvas,c=l&&l.height,h=l&&l.width;if(this.id=Tc(),this.ctx=a,this.canvas=l,this.width=h,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new hd,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=qc(u=>this.update(u),r.resizeDelay||0),this._dataChanges=[],zn[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}At.listen(this,"complete",lo),At.listen(this,"progress",Dd),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:s,_aspectRatio:o}=this;return F(t)?e&&o?o:s?i/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return Mt}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():As(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Ss(this.canvas,this.ctx),this}stop(){return At.stop(this),this}resize(t,e){At.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,s=this.canvas,o=i.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(s,t,e,o),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,As(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),N(i.onResize,[this,r],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const e=this.options.scales||{};z(e,(i,s)=>{i.id=s})}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce((r,a)=>(r[a]=!1,r),{});let o=[];e&&(o=o.concat(Object.keys(e).map(r=>{const a=e[r],l=Ei(r,a),c=l==="r",h=l==="x";return{options:a,dposition:c?"chartArea":h?"bottom":"left",dtype:c?"radialLinear":h?"category":"linear"}}))),z(o,r=>{const a=r.options,l=a.id,c=Ei(l,a),h=C(a.type,r.dtype);(a.position===void 0||ro(a.position,c)!==ro(r.dposition))&&(a.position=r.dposition),s[l]=!0;let u=null;if(l in i&&i[l].type===h)u=i[l];else{const d=Mt.getScale(h);u=new d({id:l,type:h,ctx:this.ctx,chart:this}),i[u.id]=u}u.init(a,t)}),z(s,(r,a)=>{r||delete i[a]}),z(i,r=>{Ht.configure(this,r,r.options),Ht.addBox(this,r)})}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort((s,o)=>s.index-o.index),i>e){for(let s=e;se.length&&delete this._stacks,t.forEach((i,s)=>{e.filter(o=>o===i._dataset).length===0&&this._destroyDatasetMeta(s)})}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=e.length;i{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let c=0,h=this.data.datasets.length;c{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(ao("z","_idx"));const{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){z(this.scales,t=>{Ht.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);(!xs(e,i)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:o}of e){const r=i==="_removeElements"?-o:o;Cd(t,s,r)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,i=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),s=i(0);for(let o=1;oo.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;Ht.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],z(this.boxes,s=>{i&&s.position==="chartArea"||(s.configure&&s.configure(),this._layers.push(...s._layers()))},this),this._layers.forEach((s,o)=>{s._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,i=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,s=!i.disabled,o=Od(t,this.chartArea),r={meta:t,index:t.index,cancelable:!0};this.notifyPlugins("beforeDatasetDraw",r)!==!1&&(s&&ni(e,{left:i.left===!1?0:o.left-i.left,right:i.right===!1?this.width:o.right+i.right,top:i.top===!1?0:o.top-i.top,bottom:i.bottom===!1?this.height:o.bottom+i.bottom}),t.controller.draw(),s&&ii(e),r.cancelable=!1,this.notifyPlugins("afterDatasetDraw",r))}isPointInArea(t){return It(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,i,s){const o=Pu.modes[e];return typeof o=="function"?o(this,t,i,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let s=i.filter(o=>o&&o._dataset===e).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=Xt(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return typeof i.hidden=="boolean"?!i.hidden:!e.hidden}setDatasetVisibility(t,e){const i=this.getDatasetMeta(t);i.hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,s);Qe(e)?(o.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),r.update(o,{visible:i}),this.update(a=>a.datasetIndex===t?s:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),At.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,o,r),t[o]=r},s=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};z(this.options.events,o=>i(o,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(l,c)=>{e.addEventListener(this,l,c),t[l]=c},s=(l,c)=>{t[l]&&(e.removeEventListener(this,l,c),delete t[l])},o=(l,c)=>{this.canvas&&this.resize(l,c)};let r;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",o),i("detach",r)};r=()=>{this.attached=!1,s("resize",o),this._stop(),this._resize(0,0),i("attach",a)},e.isAttached(this.canvas)?a():r()}unbindEvents(){z(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},z(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const s=i?"set":"remove";let o,r,a,l;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+s+"DatasetHoverStyle"]()),a=0,l=t.length;a{const a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[r],index:r}});!Hn(i,e)&&(this._active=i,this._lastEvent=null,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}isPluginEnabled(t){return this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,i){const s=this.options.hover,o=(l,c)=>l.filter(h=>!c.some(u=>h.datasetIndex===u.datasetIndex&&h.index===u.index)),r=o(e,t),a=i?t:o(t,e);r.length&&this.updateHoverStyle(r,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},s=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",i,s)===!1)return;const o=this._handleEvent(t,e,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(o||i.changed)&&this.render(),this}_handleEvent(t,e,i){const{_active:s=[],options:o}=this,r=e,a=this._getActiveElements(t,s,i,r),l=Ec(t),c=Sd(t,this._lastEvent,i,l);i&&(this._lastEvent=null,N(o.onHover,[t,a,this],this),l&&N(o.onClick,[t,a,this],this));const h=!Hn(a,s);return(h||e)&&(this._active=a,this._updateHoverStyles(a,s,e)),this._lastEvent=c,h}_getActiveElements(t,e,i,s){if(t.type==="mouseout")return[];if(!i)return e;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,s)}}_(at,"defaults",U),_(at,"instances",zn),_(at,"overrides",le),_(at,"registry",Mt),_(at,"version",kd),_(at,"getChart",co);function ho(){return z(at.instances,n=>n._plugins.invalidate())}function Td(n,t,e){const{startAngle:i,pixelMargin:s,x:o,y:r,outerRadius:a,innerRadius:l}=t;let c=s/a;n.beginPath(),n.arc(o,r,a,i-c,e+c),l>s?(c=s/l,n.arc(o,r,l,e+c,i-c,!0)):n.arc(o,r,s,e+Z,i-Z),n.closePath(),n.clip()}function Ad(n){return es(n,["outerStart","outerEnd","innerStart","innerEnd"])}function Ld(n,t,e,i){const s=Ad(n.options.borderRadius),o=(e-t)/2,r=Math.min(o,i*t/2),a=l=>{const c=(e-Math.min(o,l))*i/2;return st(l,0,Math.min(o,c))};return{outerStart:a(s.outerStart),outerEnd:a(s.outerEnd),innerStart:st(s.innerStart,0,r),innerEnd:st(s.innerEnd,0,r)}}function fe(n,t,e,i){return{x:e+n*Math.cos(t),y:i+n*Math.sin(t)}}function Un(n,t,e,i,s,o){const{x:r,y:a,startAngle:l,pixelMargin:c,innerRadius:h}=t,u=Math.max(t.outerRadius+i+e-c,0),d=h>0?h+i+e+c:0;let f=0;const g=s-l;if(i){const B=h>0?h-i:0,V=u>0?u-i:0,K=(B+V)/2,_t=K!==0?g*K/(K+i):g;f=(g-_t)/2}const p=Math.max(.001,g*u-e/$)/u,m=(g-p)/2,b=l+m+f,y=s-m-f,{outerStart:w,outerEnd:M,innerStart:x,innerEnd:P}=Ld(t,d,u,y-b),v=u-w,k=u-M,D=b+w/v,T=y-M/k,S=d+x,A=d+P,J=b+x/S,ft=y-P/A;if(n.beginPath(),o){const B=(D+T)/2;if(n.arc(r,a,u,D,B),n.arc(r,a,u,B,T),M>0){const nt=fe(k,T,r,a);n.arc(nt.x,nt.y,M,T,y+Z)}const V=fe(A,y,r,a);if(n.lineTo(V.x,V.y),P>0){const nt=fe(A,ft,r,a);n.arc(nt.x,nt.y,P,y+Z,ft+Math.PI)}const K=(y-P/d+(b+x/d))/2;if(n.arc(r,a,d,y-P/d,K,!0),n.arc(r,a,d,K,b+x/d,!0),x>0){const nt=fe(S,J,r,a);n.arc(nt.x,nt.y,x,J+Math.PI,b-Z)}const _t=fe(v,b,r,a);if(n.lineTo(_t.x,_t.y),w>0){const nt=fe(v,D,r,a);n.arc(nt.x,nt.y,w,b-Z,D)}}else{n.moveTo(r,a);const B=Math.cos(D)*u+r,V=Math.sin(D)*u+a;n.lineTo(B,V);const K=Math.cos(T)*u+r,_t=Math.sin(T)*u+a;n.lineTo(K,_t)}n.closePath()}function Fd(n,t,e,i,s){const{fullCircles:o,startAngle:r,circumference:a}=t;let l=t.endAngle;if(o){Un(n,t,e,i,l,s);for(let c=0;c=H||Je(r,l,c),m=Rt(a,h+f,u+f);return p&&m}getCenterPoint(e){const{x:i,y:s,startAngle:o,endAngle:r,innerRadius:a,outerRadius:l}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],e),{offset:c,spacing:h}=this.options,u=(o+r)/2,d=(a+l+h+c)/2;return{x:i+Math.cos(u)*d,y:s+Math.sin(u)*d}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){const{options:i,circumference:s}=this,o=(i.offset||0)/4,r=(i.spacing||0)/2,a=i.circular;if(this.pixelMargin=i.borderAlign==="inner"?.33:0,this.fullCircles=s>H?Math.floor(s/H):0,s===0||this.innerRadius<0||this.outerRadius<0)return;e.save();const l=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(l)*o,Math.sin(l)*o);const c=1-Math.sin(Math.min($,s||0)),h=o*c;e.fillStyle=i.backgroundColor,e.strokeStyle=i.borderColor,Fd(e,this,h,r,a),Rd(e,this,h,r,a),e.restore()}}_(He,"id","arc"),_(He,"defaults",{borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0}),_(He,"defaultRoutes",{backgroundColor:"backgroundColor"}),_(He,"descriptors",{_scriptable:!0,_indexable:e=>e!=="borderDash"});function Vr(n,t,e=t){n.lineCap=C(e.borderCapStyle,t.borderCapStyle),n.setLineDash(C(e.borderDash,t.borderDash)),n.lineDashOffset=C(e.borderDashOffset,t.borderDashOffset),n.lineJoin=C(e.borderJoinStyle,t.borderJoinStyle),n.lineWidth=C(e.borderWidth,t.borderWidth),n.strokeStyle=C(e.borderColor,t.borderColor)}function Id(n,t,e){n.lineTo(e.x,e.y)}function Ed(n){return n.stepped?rh:n.tension||n.cubicInterpolationMode==="monotone"?ah:Id}function Yr(n,t,e={}){const i=n.length,{start:s=0,end:o=i-1}=e,{start:r,end:a}=t,l=Math.max(s,r),c=Math.min(o,a),h=sa&&o>a;return{count:i,start:l,loop:t.loop,ilen:c(r+(c?a-M:M))%o,w=()=>{p!==m&&(n.lineTo(h,m),n.lineTo(h,p),n.lineTo(h,b))};for(l&&(f=s[y(0)],n.moveTo(f.x,f.y)),d=0;d<=a;++d){if(f=s[y(d)],f.skip)continue;const M=f.x,x=f.y,P=M|0;P===g?(xm&&(m=x),h=(u*h+M)/++u):(w(),n.lineTo(M,x),g=P,u=0,p=m=x),b=x}w()}function zi(n){const t=n.options,e=t.borderDash&&t.borderDash.length;return!n._decimated&&!n._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!e?Bd:zd}function Nd(n){return n.stepped?Wh:n.tension||n.cubicInterpolationMode==="monotone"?Hh:ie}function Wd(n,t,e,i){let s=t._path;s||(s=t._path=new Path2D,t.path(s,e,i)&&s.closePath()),Vr(n,t.options),n.stroke(s)}function Hd(n,t,e,i){const{segments:s,options:o}=t,r=zi(t);for(const a of s)Vr(n,o,a.style),n.beginPath(),r(n,t,a,{start:e,end:e+i-1})&&n.closePath(),n.stroke()}const Vd=typeof Path2D=="function";function Yd(n,t,e,i){Vd&&!t.options.segment?Wd(n,t,e,i):Hd(n,t,e,i)}class Vt extends wt{constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const i=this.options;if((i.tension||i.cubicInterpolationMode==="monotone")&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;Lh(this._points,i,t,s,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Uh(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],o=this.points,r=Sr(this,{property:e,start:s,end:s});if(!r.length)return;const a=[],l=Nd(i);let c,h;for(c=0,h=r.length;ct!=="borderDash"&&t!=="fill"});function uo(n,t,e,i){const s=n.options,{[e]:o}=n.getProps([e],i);return Math.abs(t-o)n.replace("rgb(","rgba(").replace(")",", 0.5)"));function $r(n){return Bi[n%Bi.length]}function qr(n){return fo[n%fo.length]}function Kd(n,t){return n.borderColor=$r(t),n.backgroundColor=qr(t),++t}function Gd(n,t){return n.backgroundColor=n.data.map(()=>$r(t++)),t}function Qd(n,t){return n.backgroundColor=n.data.map(()=>qr(t++)),t}function Zd(n){let t=0;return(e,i)=>{const s=n.getDatasetMeta(i).controller;s instanceof _e?t=Gd(e,t):s instanceof In?t=Qd(e,t):s&&(t=Kd(e,t))}}function go(n){let t;for(t in n)if(n[t].borderColor||n[t].backgroundColor)return!0;return!1}function Jd(n){return n&&(n.borderColor||n.backgroundColor)}var tf={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(n,t,e){if(!e.enabled)return;const{data:{datasets:i},options:s}=n.config,{elements:o}=s;if(!e.forceOverride&&(go(i)||Jd(s)||o&&go(o)))return;const r=Zd(n);i.forEach(r)}};function ef(n,t,e){const i=n.segments,s=n.points,o=t.points,r=[];for(const a of i){let{start:l,end:c}=a;c=ls(l,c,s);const h=Ni(e,s[l],s[c],a.loop);if(!t.segments){r.push({source:a,target:h,start:s[l],end:s[c]});continue}const u=Sr(t,h);for(const d of u){const f=Ni(e,o[d.start],o[d.end],d.loop),g=Cr(a,s,f);for(const p of g)r.push({source:p,target:d,start:{[e]:po(h,f,"start",Math.max)},end:{[e]:po(h,f,"end",Math.min)}})}}return r}function Ni(n,t,e,i){if(i)return;let s=t[n],o=e[n];return n==="angle"&&(s=bt(s),o=bt(o)),{property:n,start:s,end:o}}function nf(n,t){const{x:e=null,y:i=null}=n||{},s=t.points,o=[];return t.segments.forEach(({start:r,end:a})=>{a=ls(r,a,s);const l=s[r],c=s[a];i!==null?(o.push({x:l.x,y:i}),o.push({x:c.x,y:i})):e!==null&&(o.push({x:e,y:l.y}),o.push({x:e,y:c.y}))}),o}function ls(n,t,e){for(;t>n;t--){const i=e[t];if(!isNaN(i.x)&&!isNaN(i.y))break}return t}function po(n,t,e,i){return n&&t?i(n[e],t[e]):n?n[e]:t?t[e]:0}function Ur(n,t){let e=[],i=!1;return W(n)?(i=!0,e=n):e=nf(n,t),e.length?new Vt({points:e,options:{tension:0},_loop:i,_fullLoop:i}):null}function mo(n){return n&&n.fill!==!1}function sf(n,t,e){let s=n[t].fill;const o=[t];let r;if(!e)return s;for(;s!==!1&&o.indexOf(s)===-1;){if(!q(s))return s;if(r=n[s],!r)return!1;if(r.visible)return s;o.push(s),s=r.fill}return!1}function of(n,t,e){const i=cf(n);if(L(i))return isNaN(i.value)?!1:i;let s=parseFloat(i);return q(s)&&Math.floor(s)===s?rf(i[0],t,s,e):["origin","start","end","stack","shape"].indexOf(i)>=0&&i}function rf(n,t,e,i){return(n==="-"||n==="+")&&(e=t+e),e===t||e<0||e>=i?!1:e}function af(n,t){let e=null;return n==="start"?e=t.bottom:n==="end"?e=t.top:L(n)?e=t.getPixelForValue(n.value):t.getBasePixel&&(e=t.getBasePixel()),e}function lf(n,t,e){let i;return n==="start"?i=e:n==="end"?i=t.options.reverse?t.min:t.max:L(n)?i=n.value:i=t.getBaseValue(),i}function cf(n){const t=n.options,e=t.fill;let i=C(e&&e.target,e);return i===void 0&&(i=!!t.backgroundColor),i===!1||i===null?!1:i===!0?"origin":i}function hf(n){const{scale:t,index:e,line:i}=n,s=[],o=i.segments,r=i.points,a=uf(t,e);a.push(Ur({x:null,y:t.bottom},i));for(let l=0;l=0;--r){const a=s[r].$filler;a&&(a.line.updateControlPoints(o,a.axis),i&&a.fill&&xi(n.ctx,a,o))}},beforeDatasetsDraw(n,t,e){if(e.drawTime!=="beforeDatasetsDraw")return;const i=n.getSortedVisibleDatasetMetas();for(let s=i.length-1;s>=0;--s){const o=i[s].$filler;mo(o)&&xi(n.ctx,o,n.chartArea)}},beforeDatasetDraw(n,t,e){const i=t.meta.$filler;!mo(i)||e.drawTime!=="beforeDatasetDraw"||xi(n.ctx,i,n.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const xo=(n,t)=>{let{boxHeight:e=t,boxWidth:i=t}=n;return n.usePointStyle&&(e=Math.min(e,t),i=n.pointStyleWidth||Math.min(i,t)),{boxWidth:i,boxHeight:e,itemHeight:Math.max(t,e)}},vf=(n,t)=>n!==null&&t!==null&&n.datasetIndex===t.datasetIndex&&n.index===t.index;class wo extends wt{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=N(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(i=>t.filter(i,this.chart.data))),t.sort&&(e=e.sort((i,s)=>t.sort(i,s,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display){this.width=this.height=0;return}const i=t.labels,s=tt(i.font),o=s.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=xo(i,o);let c,h;e.font=s.string,this.isHorizontal()?(c=this.maxWidth,h=this._fitRows(r,o,a,l)+10):(h=this.maxHeight,c=this._fitCols(r,s,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],h=s+a;let u=t;o.textAlign="left",o.textBaseline="middle";let d=-1,f=-h;return this.legendItems.forEach((g,p)=>{const m=i+e/2+o.measureText(g.text).width;(p===0||c[c.length-1]+m+2*a>r)&&(u+=h,c[c.length-(p>0?0:1)]=0,f+=h,d++),l[p]={left:0,top:f,row:d,width:m,height:s},c[c.length-1]+=m+a}),u}_fitCols(t,e,i,s){const{ctx:o,maxHeight:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],h=r-t;let u=a,d=0,f=0,g=0,p=0;return this.legendItems.forEach((m,b)=>{const{itemWidth:y,itemHeight:w}=Mf(i,e,o,m,s);b>0&&f+w+2*a>h&&(u+=d+a,c.push({width:d,height:f}),g+=d+a,p++,d=f=0),l[b]={left:g,top:f,col:p,width:y,height:w},d=Math.max(d,y),f+=w+a}),u+=d,c.push({width:d,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:o}}=this,r=we(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=gt(i,this.left+s,this.right-this.lineWidths[a]);for(const c of e)a!==c.row&&(a=c.row,l=gt(i,this.left+s,this.right-this.lineWidths[a])),c.top+=this.top+t+s,c.left=r.leftForLtr(r.x(l),c.width),l+=c.width+s}else{let a=0,l=gt(i,this.top+t+s,this.bottom-this.columnSizes[a].height);for(const c of e)c.col!==a&&(a=c.col,l=gt(i,this.top+t+s,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+s,c.left=r.leftForLtr(r.x(c.left),c.width),l+=c.height+s}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;ni(t,this),this._draw(),ii(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:o,labels:r}=t,a=U.color,l=we(t.rtl,this.left,this.width),c=tt(r.font),{padding:h}=r,u=c.size,d=u/2;let f;this.drawTitle(),s.textAlign=l.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:g,boxHeight:p,itemHeight:m}=xo(r,u),b=function(P,v,k){if(isNaN(g)||g<=0||isNaN(p)||p<0)return;s.save();const D=C(k.lineWidth,1);if(s.fillStyle=C(k.fillStyle,a),s.lineCap=C(k.lineCap,"butt"),s.lineDashOffset=C(k.lineDashOffset,0),s.lineJoin=C(k.lineJoin,"miter"),s.lineWidth=D,s.strokeStyle=C(k.strokeStyle,a),s.setLineDash(C(k.lineDash,[])),r.usePointStyle){const T={radius:p*Math.SQRT2/2,pointStyle:k.pointStyle,rotation:k.rotation,borderWidth:D},S=l.xPlus(P,g/2),A=v+d;br(s,T,S,A,r.pointStyleWidth&&g)}else{const T=v+Math.max((u-p)/2,0),S=l.leftForLtr(P,g),A=re(k.borderRadius);s.beginPath(),Object.values(A).some(J=>J!==0)?tn(s,{x:S,y:T,w:g,h:p,radius:A}):s.rect(S,T,g,p),s.fill(),D!==0&&s.stroke()}s.restore()},y=function(P,v,k){ve(s,k.text,P,v+m/2,c,{strikethrough:k.hidden,textAlign:l.textAlign(k.textAlign)})},w=this.isHorizontal(),M=this._computeTitleHeight();w?f={x:gt(o,this.left+h,this.right-i[0]),y:this.top+h+M,line:0}:f={x:this.left+h,y:gt(o,this.top+M+h,this.bottom-e[0].height),line:0},kr(this.ctx,t.textDirection);const x=m+h;this.legendItems.forEach((P,v)=>{s.strokeStyle=P.fontColor,s.fillStyle=P.fontColor;const k=s.measureText(P.text).width,D=l.textAlign(P.textAlign||(P.textAlign=r.textAlign)),T=g+d+k;let S=f.x,A=f.y;l.setWidth(this.width),w?v>0&&S+T+h>this.right&&(A=f.y+=x,f.line++,S=f.x=gt(o,this.left+h,this.right-i[f.line])):v>0&&A+x>this.bottom&&(S=f.x=S+e[f.line].width+h,f.line++,A=f.y=gt(o,this.top+M+h,this.bottom-e[f.line].height));const J=l.x(S);if(b(J,A,P),S=Uc(D,S+g+d,w?S+T:this.right,t.rtl),y(l.x(S),A,P),w)f.x+=T+h;else if(typeof P.text!="string"){const ft=c.lineHeight;f.y+=Kr(P,ft)+h}else f.y+=x}),Pr(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=tt(e.font),s=ct(e.padding);if(!e.display)return;const o=we(t.rtl,this.left,this.width),r=this.ctx,a=e.position,l=i.size/2,c=s.top+l;let h,u=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),h=this.top+c,u=gt(t.align,u,this.right-d);else{const g=this.columnSizes.reduce((p,m)=>Math.max(p,m.height),0);h=c+gt(t.align,this.top,this.bottom-g-t.labels.padding-this._computeTitleHeight())}const f=gt(a,u,u+d);r.textAlign=o.textAlign(pr(a)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=i.string,ve(r,e.text,f,h,i)}_computeTitleHeight(){const t=this.options.title,e=tt(t.font),i=ct(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,o;if(Rt(t,this.left,this.right)&&Rt(e,this.top,this.bottom)){for(o=this.legendHitBoxes,i=0;io.length>r.length?o:r)),t+e.size/2+i.measureText(s).width}function Pf(n,t,e){let i=n;return typeof t.text!="string"&&(i=Kr(t,e)),i}function Kr(n,t){const e=n.text?n.text.length:0;return t*e}function Df(n,t){return!!((n==="mousemove"||n==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(n==="click"||n==="mouseup"))}var Cf={id:"legend",_element:wo,start(n,t,e){const i=n.legend=new wo({ctx:n.ctx,options:e,chart:n});Ht.configure(n,i,e),Ht.addBox(n,i)},stop(n){Ht.removeBox(n,n.legend),delete n.legend},beforeUpdate(n,t,e){const i=n.legend;Ht.configure(n,i,e),i.options=e},afterUpdate(n){const t=n.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(n,t){t.replay||n.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(n,t,e){const i=t.datasetIndex,s=e.chart;s.isDatasetVisible(i)?(s.hide(i),t.hidden=!0):(s.show(i),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:n=>n.chart.options.color,boxWidth:40,padding:10,generateLabels(n){const t=n.data.datasets,{labels:{usePointStyle:e,pointStyle:i,textAlign:s,color:o,useBorderRadius:r,borderRadius:a}}=n.legend.options;return n._getSortedDatasetMetas().map(l=>{const c=l.controller.getStyle(e?0:void 0),h=ct(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(h.width+h.height)/4,strokeStyle:c.borderColor,pointStyle:i||c.pointStyle,rotation:c.rotation,textAlign:s||c.textAlign,borderRadius:r&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:n=>n.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:n=>!n.startsWith("on"),labels:{_scriptable:n=>!["generateLabels","filter","sort"].includes(n)}}};const Ve={average(n){if(!n.length)return!1;let t,e,i=0,s=0,o=0;for(t=0,e=n.length;t-1?n.split(` `):n}function Sf(n,t){const{element:e,datasetIndex:i,index:s}=t,o=n.getDatasetMeta(i).controller,{label:r,value:a}=o.getLabelAndValue(s);return{chart:n,label:r,parsed:o.getParsed(s),raw:n.data.datasets[i].data[s],formattedValue:a,dataset:o.getDataset(),dataIndex:s,datasetIndex:i,element:e}}function vo(n,t){const e=n.chart.ctx,{body:i,footer:s,title:o}=n,{boxWidth:r,boxHeight:a}=t,l=tt(t.bodyFont),c=tt(t.titleFont),h=tt(t.footerFont),u=o.length,d=s.length,f=i.length,g=ct(t.padding);let p=g.height,m=0,b=i.reduce((M,x)=>M+x.before.length+x.lines.length+x.after.length,0);if(b+=n.beforeBody.length+n.afterBody.length,u&&(p+=u*c.lineHeight+(u-1)*t.titleSpacing+t.titleMarginBottom),b){const M=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;p+=f*M+(b-f)*l.lineHeight+(b-1)*t.bodySpacing}d&&(p+=t.footerMarginTop+d*h.lineHeight+(d-1)*t.footerSpacing);let y=0;const w=function(M){m=Math.max(m,e.measureText(M).width+y)};return e.save(),e.font=c.string,z(n.title,w),e.font=l.string,z(n.beforeBody.concat(n.afterBody),w),y=t.displayColors?r+2+t.boxPadding:0,z(i,M=>{z(M.before,w),z(M.lines,w),z(M.after,w)}),y=0,e.font=h.string,z(n.footer,w),e.restore(),m+=g.width,{width:m,height:p}}function Of(n,t){const{y:e,height:i}=t;return en.height-i/2?"bottom":"center"}function Tf(n,t,e,i){const{x:s,width:o}=i,r=e.caretSize+e.caretPadding;if(n==="left"&&s+o+r>t.width||n==="right"&&s-o-r<0)return!0}function Af(n,t,e,i){const{x:s,width:o}=e,{width:r,chartArea:{left:a,right:l}}=n;let c="center";return i==="center"?c=s<=(a+l)/2?"left":"right":s<=o/2?c="left":s>=r-o/2&&(c="right"),Tf(c,n,t,e)&&(c="center"),c}function Mo(n,t,e){const i=e.yAlign||t.yAlign||Of(n,e);return{xAlign:e.xAlign||t.xAlign||Af(n,t,e,i),yAlign:i}}function Lf(n,t){let{x:e,width:i}=n;return t==="right"?e-=i:t==="center"&&(e-=i/2),e}function Ff(n,t,e){let{y:i,height:s}=n;return t==="top"?i+=e:t==="bottom"?i-=s+e:i-=s/2,i}function ko(n,t,e,i){const{caretSize:s,caretPadding:o,cornerRadius:r}=n,{xAlign:a,yAlign:l}=e,c=s+o,{topLeft:h,topRight:u,bottomLeft:d,bottomRight:f}=re(r);let g=Lf(t,a);const p=Ff(t,l,c);return l==="center"?a==="left"?g+=c:a==="right"&&(g-=c):a==="left"?g-=Math.max(h,d)+s:a==="right"&&(g+=Math.max(u,f)+s),{x:st(g,0,i.width-t.width),y:st(p,0,i.height-t.height)}}function Dn(n,t,e){const i=ct(e.padding);return t==="center"?n.x+n.width/2:t==="right"?n.x+n.width-i.right:n.x+i.left}function Po(n){return vt([],Lt(n))}function Rf(n,t,e){return Xt(n,{tooltip:t,tooltipItems:e,type:"tooltip"})}function Do(n,t){const e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?n.override(e):n}const Gr={beforeTitle:St,title(n){if(n.length>0){const t=n[0],e=t.chart.data.labels,i=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(i>0&&t.dataIndex"u"?Gr[t].call(e,i):s}class Wi extends wt{constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this.chart,i=this.options.setContext(this.getContext()),s=i.enabled&&e.options.animation&&i.animations,o=new Or(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=Rf(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const{callbacks:i}=e,s=ht(i,"beforeTitle",this,t),o=ht(i,"title",this,t),r=ht(i,"afterTitle",this,t);let a=[];return a=vt(a,Lt(s)),a=vt(a,Lt(o)),a=vt(a,Lt(r)),a}getBeforeBody(t,e){return Po(ht(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:i}=e,s=[];return z(t,o=>{const r={before:[],lines:[],after:[]},a=Do(i,o);vt(r.before,Lt(ht(a,"beforeLabel",this,o))),vt(r.lines,ht(a,"label",this,o)),vt(r.after,Lt(ht(a,"afterLabel",this,o))),s.push(r)}),s}getAfterBody(t,e){return Po(ht(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:i}=e,s=ht(i,"beforeFooter",this,t),o=ht(i,"footer",this,t),r=ht(i,"afterFooter",this,t);let a=[];return a=vt(a,Lt(s)),a=vt(a,Lt(o)),a=vt(a,Lt(r)),a}_createItems(t){const e=this._active,i=this.chart.data,s=[],o=[],r=[];let a=[],l,c;for(l=0,c=e.length;lt.filter(h,u,d,i))),t.itemSort&&(a=a.sort((h,u)=>t.itemSort(h,u,i))),z(a,h=>{const u=Do(t.callbacks,h);s.push(ht(u,"labelColor",this,h)),o.push(ht(u,"labelPointStyle",this,h)),r.push(ht(u,"labelTextColor",this,h))}),this.labelColors=s,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let o,r=[];if(!s.length)this.opacity!==0&&(o={opacity:0});else{const a=Ve[i.position].call(this,s,this._eventPosition);r=this._createItems(i),this.title=this.getTitle(r,i),this.beforeBody=this.getBeforeBody(r,i),this.body=this.getBody(r,i),this.afterBody=this.getAfterBody(r,i),this.footer=this.getFooter(r,i);const l=this._size=vo(this,i),c=Object.assign({},a,l),h=Mo(this.chart,i,c),u=ko(i,c,h,this.chart);this.xAlign=h.xAlign,this.yAlign=h.yAlign,o={opacity:1,x:u.x,y:u.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const o=this.getCaretPosition(t,i,s);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:o}=this,{caretSize:r,cornerRadius:a}=i,{topLeft:l,topRight:c,bottomLeft:h,bottomRight:u}=re(a),{x:d,y:f}=t,{width:g,height:p}=e;let m,b,y,w,M,x;return o==="center"?(M=f+p/2,s==="left"?(m=d,b=m-r,w=M+r,x=M-r):(m=d+g,b=m+r,w=M-r,x=M+r),y=m):(s==="left"?b=d+Math.max(l,h)+r:s==="right"?b=d+g-Math.max(c,u)-r:b=this.caretX,o==="top"?(w=f,M=w-r,m=b-r,y=b+r):(w=f+p,M=w+r,m=b+r,y=b-r),x=w),{x1:m,x2:b,x3:y,y1:w,y2:M,y3:x}}drawTitle(t,e,i){const s=this.title,o=s.length;let r,a,l;if(o){const c=we(i.rtl,this.x,this.width);for(t.x=Dn(this,i.titleAlign,i),e.textAlign=c.textAlign(i.titleAlign),e.textBaseline="middle",r=tt(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=r.string,l=0;ly!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,tn(t,{x:p,y:g,w:c,h:l,radius:b}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),tn(t,{x:m,y:g+1,w:c-2,h:l-2,radius:b}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(p,g,c,l),t.strokeRect(p,g,c,l),t.fillStyle=r.backgroundColor,t.fillRect(m,g+1,c-2,l-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:h}=i,u=tt(i.bodyFont);let d=u.lineHeight,f=0;const g=we(i.rtl,this.x,this.width),p=function(k){e.fillText(k,g.x(t.x+f),t.y+d/2),t.y+=d+o},m=g.textAlign(r);let b,y,w,M,x,P,v;for(e.textAlign=r,e.textBaseline="middle",e.font=u.string,t.x=Dn(this,m,i),e.fillStyle=i.bodyColor,z(this.beforeBody,p),f=a&&m!=="right"?r==="center"?c/2+h:c+2+h:0,M=0,P=s.length;M0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,i=this.$animations,s=i&&i.x,o=i&&i.y;if(s||o){const r=Ve[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=vo(this,t),l=Object.assign({},r,this._size),c=Mo(e,t,l),h=ko(t,l,c,e);(s._to!==h.x||o._to!==h.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,h))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},o={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const r=ct(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(o,t,s,e),kr(t,e.textDirection),o.y+=r.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),Pr(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!Hn(i,s),r=this._positionChanged(s,e);(o||r)&&(this._active=s,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,i=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,o=this._active||[],r=this._getActiveElements(t,o,e,i),a=this._positionChanged(r,t),l=e||!Hn(r,o)||a;return l&&(this._active=r,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,i,s){const o=this.options;if(t.type==="mouseout")return[];if(!s)return e.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const r=this.chart.getElementsAtEventForMode(t,o.mode,o,i);return o.reverse&&r.reverse(),r}_positionChanged(t,e){const{caretX:i,caretY:s,options:o}=this,r=Ve[o.position].call(this,t,e);return r!==!1&&(i!==r.x||s!==r.y)}}_(Wi,"positioners",Ve);var If={id:"tooltip",_element:Wi,positioners:Ve,afterInit(n,t,e){e&&(n.tooltip=new Wi({chart:n,options:e}))},beforeUpdate(n,t,e){n.tooltip&&n.tooltip.initialize(e)},reset(n,t,e){n.tooltip&&n.tooltip.initialize(e)},afterDraw(n){const t=n.tooltip;if(t&&t._willRender()){const e={tooltip:t};if(n.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(n.ctx),n.notifyPlugins("afterTooltipDraw",e)}},afterEvent(n,t){if(n.tooltip){const e=t.replay;n.tooltip.handleEvent(t.event,e,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:(n,t)=>t.bodyFont.size,boxWidth:(n,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:Gr},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:n=>n!=="filter"&&n!=="itemSort"&&n!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};const Ef=(n,t,e,i)=>(typeof t=="string"?(e=n.push(t)-1,i.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);function zf(n,t,e,i){const s=n.indexOf(t);if(s===-1)return Ef(n,t,e,i);const o=n.lastIndexOf(t);return s!==o?e:s}const Bf=(n,t)=>n===null?null:st(Math.round(n),0,t);function Co(n){const t=this.getLabels();return n>=0&&ne.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}_(Hi,"id","category"),_(Hi,"defaults",{ticks:{callback:Co}});function Nf(n,t){const e=[],{bounds:s,step:o,min:r,max:a,precision:l,count:c,maxTicks:h,maxDigits:u,includeBounds:d}=n,f=o||1,g=h-1,{min:p,max:m}=t,b=!F(r),y=!F(a),w=!F(c),M=(m-p)/(u+1);let x=vs((m-p)/g/f)*f,P,v,k,D;if(x<1e-14&&!b&&!y)return[{value:p},{value:m}];D=Math.ceil(m/x)-Math.floor(p/x),D>g&&(x=vs(D*x/g/f)*f),F(l)||(P=Math.pow(10,l),x=Math.ceil(x*P)/P),s==="ticks"?(v=Math.floor(p/x)*x,k=Math.ceil(m/x)*x):(v=p,k=m),b&&y&&o&&Wc((a-r)/o,x/1e3)?(D=Math.round(Math.min((a-r)/x,h)),x=(a-r)/D,v=r,k=a):w?(v=b?r:v,k=y?a:k,D=c-1,x=(k-v)/D):(D=(k-v)/x,$e(D,Math.round(D),x/1e3)?D=Math.round(D):D=Math.ceil(D));const T=Math.max(Ms(x),Ms(v));P=Math.pow(10,F(l)?T:l),v=Math.round(v*P)/P,k=Math.round(k*P)/P;let S=0;for(b&&(d&&v!==r?(e.push({value:r}),va)break;e.push({value:A})}return y&&d&&k!==a?e.length&&$e(e[e.length-1].value,a,So(a,M,n))?e[e.length-1].value=a:e.push({value:a}):(!y||k===a)&&e.push({value:k}),e}function So(n,t,{horizontal:e,minRotation:i}){const s=xt(i),o=(e?Math.sin(s):Math.cos(s))||.001,r=.75*t*(""+n).length;return Math.min(t/o,r)}class Xn extends ce{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return F(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:i}=this.getUserBounds();let{min:s,max:o}=this;const r=l=>s=e?s:l,a=l=>o=i?o:l;if(t){const l=Dt(s),c=Dt(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(s===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(s-l)}this.min=s,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:e,stepSize:i}=t,s;return i?(s=Math.ceil(this.max/i)-Math.floor(this.min/i)+1,s>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${i} would result generating up to ${s} ticks. Limiting to 1000.`),s=1e3)):(s=this.computeTickLimit(),e=e||11),e&&(s=Math.min(e,s)),s}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const s={maxTicks:i,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:e.includeBounds!==!1},o=this._range||this,r=Nf(s,o);return t.bounds==="ticks"&&cr(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){const t=this.ticks;let e=this.min,i=this.max;if(super.configure(),this.options.offset&&t.length){const s=(i-e)/Math.max(t.length-1,1)/2;e-=s,i+=s}this._startValue=e,this._endValue=i,this._valueRange=i-e}getLabelForValue(t){return hn(t,this.chart.options.locale,this.options.ticks.format)}}class Vi extends Xn{determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=q(t)?t:0,this.max=q(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,i=xt(this.options.ticks.minRotation),s=(t?Math.sin(i):Math.cos(i))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/s))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}_(Vi,"id","linear"),_(Vi,"defaults",{ticks:{callback:ei.formatters.numeric}});const nn=n=>Math.floor(Wt(n)),te=(n,t)=>Math.pow(10,nn(n)+t);function Oo(n){return n/Math.pow(10,nn(n))===1}function To(n,t,e){const i=Math.pow(10,e),s=Math.floor(n/i);return Math.ceil(t/i)-s}function Wf(n,t){const e=t-n;let i=nn(e);for(;To(n,t,i)>10;)i++;for(;To(n,t,i)<10;)i--;return Math.min(i,nn(n))}function Hf(n,{min:t,max:e}){t=mt(n.min,t);const i=[],s=nn(t);let o=Wf(t,e),r=o<0?Math.pow(10,Math.abs(o)):1;const a=Math.pow(10,o),l=s>o?Math.pow(10,s):0,c=Math.round((t-l)*r)/r,h=Math.floor((t-l)/a/10)*a*10;let u=Math.floor((c-h)/Math.pow(10,o)),d=mt(n.min,Math.round((l+h+u*Math.pow(10,o))*r)/r);for(;d=10?u=u<15?15:20:u++,u>=20&&(o++,u=2,r=o>=0?1:r),d=Math.round((l+h+u*Math.pow(10,o))*r)/r;const f=mt(n.max,d);return i.push({value:f,major:Oo(f),significand:u}),i}class Ao extends ce{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const i=Xn.prototype.parse.apply(this,[t,e]);if(i===0){this._zero=!0;return}return q(i)&&i>0?i:null}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=q(t)?Math.max(0,t):null,this.max=q(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!q(this._userMin)&&(this.min=t===te(this.min,0)?te(this.min,-1):te(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const o=a=>i=t?i:a,r=a=>s=e?s:a;i===s&&(i<=0?(o(1),r(10)):(o(te(i,-1)),r(te(s,1)))),i<=0&&o(te(s,-1)),s<=0&&r(te(i,1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e={min:this._userMin,max:this._userMax},i=Hf(e,this);return t.bounds==="ticks"&&cr(i,this,"value"),t.reverse?(i.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),i}getLabelForValue(t){return t===void 0?"0":hn(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Wt(t),this._valueRange=Wt(this.max)-Wt(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Wt(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}_(Ao,"id","logarithmic"),_(Ao,"defaults",{ticks:{callback:ei.formatters.logarithmic,major:{enabled:!0}}});function Yi(n){const t=n.ticks;if(t.display&&n.display){const e=ct(t.backdropPadding);return C(t.font&&t.font.size,U.font.size)+e.height}return 0}function Vf(n,t,e){return e=W(e)?e:[e],{w:oh(n,t.string,e),h:e.length*t.lineHeight}}function Lo(n,t,e,i,s){return n===i||n===s?{start:t-e/2,end:t+e/2}:ns?{start:t-e,end:t}:{start:t,end:t+e}}function Yf(n){const t={l:n.left+n._padding.left,r:n.right-n._padding.right,t:n.top+n._padding.top,b:n.bottom-n._padding.bottom},e=Object.assign({},t),i=[],s=[],o=n._pointLabels.length,r=n.options.pointLabels,a=r.centerPointLabels?$/o:0;for(let l=0;lt.r&&(a=(i.end-t.r)/o,n.r=Math.max(n.r,t.r+a)),s.startt.b&&(l=(s.end-t.b)/r,n.b=Math.max(n.b,t.b+l))}function $f(n,t,e){const i=n.drawingArea,{extra:s,additionalAngle:o,padding:r,size:a}=e,l=n.getPointPosition(t,i+s+r,o),c=Math.round(Zi(bt(l.angle+Z))),h=Gf(l.y,a.h,c),u=Xf(c),d=Kf(l.x,a.w,u);return{visible:!0,x:l.x,y:h,textAlign:u,left:d,top:h,right:d+a.w,bottom:h+a.h}}function qf(n,t){if(!t)return!0;const{left:e,top:i,right:s,bottom:o}=n;return!(It({x:e,y:i},t)||It({x:e,y:o},t)||It({x:s,y:i},t)||It({x:s,y:o},t))}function Uf(n,t,e){const i=[],s=n._pointLabels.length,o=n.options,{centerPointLabels:r,display:a}=o.pointLabels,l={extra:Yi(o)/2,additionalAngle:r?$/s:0};let c;for(let h=0;h270||e<90)&&(n-=t),n}function Qf(n,t,e){const{left:i,top:s,right:o,bottom:r}=e,{backdropColor:a}=t;if(!F(a)){const l=re(t.borderRadius),c=ct(t.backdropPadding);n.fillStyle=a;const h=i-c.left,u=s-c.top,d=o-i+c.width,f=r-s+c.height;Object.values(l).some(g=>g!==0)?(n.beginPath(),tn(n,{x:h,y:u,w:d,h:f,radius:l}),n.fill()):n.fillRect(h,u,d,f)}}function Zf(n,t){const{ctx:e,options:{pointLabels:i}}=n;for(let s=t-1;s>=0;s--){const o=n._pointLabelItems[s];if(!o.visible)continue;const r=i.setContext(n.getPointLabelContext(s));Qf(e,r,o);const a=tt(r.font),{x:l,y:c,textAlign:h}=o;ve(e,n._pointLabels[s],l,c+a.lineHeight/2,a,{color:r.color,textAlign:h,textBaseline:"middle"})}}function Qr(n,t,e,i){const{ctx:s}=n;if(e)s.arc(n.xCenter,n.yCenter,t,0,H);else{let o=n.getPointPosition(0,t);s.moveTo(o.x,o.y);for(let r=1;r{const s=N(this.options.pointLabels.callback,[e,i],this);return s||s===0?s:""}).filter((e,i)=>this.chart.getDataVisibility(i))}fit(){const t=this.options;t.display&&t.pointLabels.display?Yf(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,i,s){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((i-s)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,i,s))}getIndexAngle(t){const e=H/(this._pointLabels.length||1),i=this.options.startAngle||0;return bt(t*e+xt(i))}getDistanceFromCenterForValue(t){if(F(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(F(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t{if(u!==0){l=this.getDistanceFromCenterForValue(h.value);const d=this.getContext(u),f=s.setContext(d),g=o.setContext(d);Jf(this,f,l,r,g)}}),i.display){for(t.save(),a=r-1;a>=0;a--){const h=i.setContext(this.getPointLabelContext(a)),{color:u,lineWidth:d}=h;!d||!u||(t.lineWidth=d,t.strokeStyle=u,t.setLineDash(h.borderDash),t.lineDashOffset=h.borderDashOffset,l=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&!e.reverse)return;const c=i.setContext(this.getContext(l)),h=tt(c.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=h.string,r=t.measureText(a.label).width,t.fillStyle=c.backdropColor;const u=ct(c.backdropPadding);t.fillRect(-r/2-u.left,-o-h.size/2-u.top,r+u.width,h.size+u.height)}ve(t,a.label,0,-o,h,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}}_(Cn,"id","radialLinear"),_(Cn,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:ei.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),_(Cn,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),_(Cn,"descriptors",{angleLines:{_fallback:"grid"}});const oi={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}},ut=Object.keys(oi);function Fo(n,t){return n-t}function Ro(n,t){if(F(t))return null;const e=n._adapter,{parser:i,round:s,isoWeekday:o}=n._parseOpts;let r=t;return typeof i=="function"&&(r=i(r)),q(r)||(r=typeof i=="string"?e.parse(r,i):e.parse(r)),r===null?null:(s&&(r=s==="week"&&(Ze(o)||o===!0)?e.startOf(r,"isoWeek",o):e.startOf(r,s)),+r)}function Io(n,t,e,i){const s=ut.length;for(let o=ut.indexOf(n);o=ut.indexOf(e);o--){const r=ut[o];if(oi[r].common&&n._adapter.diff(s,i,r)>=t-1)return r}return ut[e?ut.indexOf(e):0]}function ng(n){for(let t=ut.indexOf(n)+1,e=ut.length;t=t?e[i]:e[s];n[o]=!0}}function ig(n,t,e,i){const s=n._adapter,o=+s.startOf(t[0].value,i),r=t[t.length-1].value;let a,l;for(a=o;a<=r;a=+s.add(a,1,i))l=e[a],l>=0&&(t[l].major=!0);return t}function zo(n,t,e){const i=[],s={},o=t.length;let r,a;for(r=0;r+t.value))}initOffsets(t=[]){let e=0,i=0,s,o;this.options.offset&&t.length&&(s=this.getDecimalForValue(t[0]),t.length===1?e=1-s:e=(this.getDecimalForValue(t[1])-s)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?i=o:i=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;e=st(e,0,r),i=st(i,0,r),this._offsets={start:e,end:i,factor:1/(e+1+i)}}_generate(){const t=this._adapter,e=this.min,i=this.max,s=this.options,o=s.time,r=o.unit||Io(o.minUnit,e,i,this._getLabelCapacity(e)),a=C(s.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=Ze(l)||l===!0,h={};let u=e,d,f;if(c&&(u=+t.startOf(u,"isoWeek",l)),u=+t.startOf(u,c?"day":r),t.diff(i,e,r)>1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+r);const g=s.ticks.source==="data"&&this.getDataTimestamps();for(d=u,f=0;d+p)}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}format(t,e){const s=this.options.time.displayFormats,o=this._unit,r=e||s[o];return this._adapter.format(t,r)}_tickFormatFunction(t,e,i,s){const o=this.options,r=o.ticks.callback;if(r)return N(r,[t,e,i],this);const a=o.time.displayFormats,l=this._unit,c=this._majorUnit,h=l&&a[l],u=c&&a[c],d=i[e],f=c&&u&&d&&d.major;return this._adapter.format(t,s||(f?u:h))}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t=this._cache.data||[],e,i;if(t.length)return t;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(e=0,i=s.length;e=n[i].pos&&t<=n[s].pos&&({lo:i,hi:s}=oe(n,"pos",t)),{pos:o,time:a}=n[i],{pos:r,time:l}=n[s]):(t>=n[i].time&&t<=n[s].time&&({lo:i,hi:s}=oe(n,"time",t)),{time:o,pos:a}=n[i],{time:r,pos:l}=n[s]);const c=r-o;return c?a+(l-a)*(t-o)/c:a}class Bo extends sn{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=Sn(e,this.min),this._tableRange=Sn(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],o=[];let r,a,l,c,h;for(r=0,a=t.length;r=e&&c<=i&&s.push(c);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(r=0,a=s.length;rs-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),i=this.getLabelTimestamps();return e.length&&i.length?t=this.normalize(e.concat(i)):t=e.length?e:i,t=this._cache.all=t,t}getDecimalForValue(t){return(Sn(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return Sn(this._table,i*this._tableRange+this._minPos,!0)}}_(Bo,"id","timeseries"),_(Bo,"defaults",sn.defaults);function ri(n){return n==="sankey"?{type:"sankey",data:{datasets:[]},options:{animations:!1}}:n==="pie"?{type:"pie",data:{datasets:[]}}:n==="column"?{type:"bar",data:{labels:[],datasets:[]},options:{plugins:{tooltip:{callbacks:{label:function(t){let e=t.dataset.currency_code;return I(t.raw,e)}}}},maintainAspectRatio:!1,scales:{}}}:n==="line"?{options:{plugins:{tooltip:{callbacks:{label:function(t){let e=t.dataset.currency_code;return I(t.raw,e)}}}},maintainAspectRatio:!1,scales:{x:{type:"time",time:{tooltipFormat:"PP"}}}},type:"line",data:{labels:[],datasets:[]}}:{}}let Kn=new it("#36a2eb"),xe=new it("#ff6384"),on=new it("#4bc0c0"),Zr=new it("#ff9f40"),sg=new it("#9966ff"),og=new it("#ffcd56"),rg=new it("#c9cbcf"),No=0;window.theme==="dark"&&(xe.darken(.3).desaturate(.3),on.darken(.3).desaturate(.3),Kn.darken(.3).desaturate(.3),Zr.darken(.3).desaturate(.3));let wi=[xe,Zr,Kn,on,sg,og,rg,on];function ge(n,t){let e={borderColor:xe.rgbString(),backgroundColor:xe.rgbString()},i;switch(n){default:let o=Math.floor(No/2)%wi.length;i=new it(wi[o].rgbString()),i.lighten(.38),e={borderColor:wi[o].hexString(),backgroundColor:i.hexString()};break;case"spent":i=new it(Kn.rgbString()),i.lighten(.38),e={borderColor:Kn.rgbString(),backgroundColor:i.rgbString()};break;case"left":i=new it(on.rgbString()),i.lighten(.38),e={borderColor:on.rgbString(),backgroundColor:i.rgbString()};break;case"overspent":i=new it(xe.rgbString()),i.lighten(.22),e={borderColor:xe.rgbString(),backgroundColor:i.rgbString()};break}return No++,t==="border"?e.borderColor:t==="background"?e.backgroundColor:"#FF0000"}let ee=[],Fe=null,vi=null,Mi=!1;const ag=()=>({loading:!1,loadingAccounts:!1,accountList:[],autoConversion:!1,chartOptions:null,switchAutoConversion(){this.autoConversion=!this.autoConversion,rc("autoConversion",this.autoConversion)},getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Ct("dashboard-accounts-chart",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){console.log(s),this.drawChart(this.generateOptions(s)),this.loading=!1;return}new ac().dashboard(n,t,null).then(r=>{this.chartData=r.data,window.store.set(e,r.data),console.log(r.data),this.drawChart(this.generateOptions(this.chartData)),this.loading=!1})},generateOptions(n){ee=[];let t=ri("line");for(let e=0;e0){this.loadingAccounts=!1;return}const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Ct("dashboard-accounts-data",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){this.accountList=s,this.loadingAccounts=!1;return}const o=10;let r=0,a=0,l=[];Promise.all([lt("frontpageAccounts")]).then(c=>{r=c[0].length;for(let h in c[0]){let u=c[0];if(u.hasOwnProperty(h)){let d=u[h];new gs().get(d,new Date(window.store.get("end"))).then(f=>{let g=f.data.data;const p={page:1,start:new Date(window.store.get("start")),end:new Date(window.store.get("end"))};new gs().transactions(g.id,p).then(m=>{let b=[];for(let y=0;y=o);y++){let w=m.data.data[y],M={title:w.attributes.group_title===null?"":w.attributes.group_title,id:w.id,transactions:[]};for(let x=0;xy.order-w.order),this.accountList=l,this.loadingAccounts=!1,window.store.set(e,l))})})}}})},init(){Promise.all([lt("viewRange","1M"),lt("autoConversion",!1),lt("language","en_US")]).then(n=>{this.autoConversion=n[1],Mi=!0,this.loadChart(),this.loadAccounts()}),window.store.observe("end",()=>{Mi&&(vi=null,this.accountList=[],this.loadChart(),this.loadAccounts())}),window.store.observe("autoConversion",()=>{Mi&&(this.loadChart(),this.loadAccounts())})}});let lg=class{dashboard(t,e){let i=j(t,"y-MM-dd"),s=j(e,"y-MM-dd");return dt.get("/api/v2/chart/budget/dashboard",{params:{start:i,end:s}})}},Re=[],On=null,zt=null,ki=!1,pe;const cg=()=>({loading:!1,autoConversion:!1,loadChart(){if(this.loading!==!0){if(this.loading=!0,zt!==null){this.drawChart(this.generateOptions(zt)),this.loading=!1;return}this.getFreshData()}},drawChart(n){if(On!==null){On.data.datasets=n.data.datasets,On.update();return}On=new at(document.querySelector("#budget-chart"),n)},getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Ct("dashboard-budgets-chart",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){zt=s,this.drawChart(this.generateOptions(zt)),this.loading=!1;return}new lg().dashboard(n,t,null).then(r=>{zt=r.data,this.drawChart(this.generateOptions(zt)),window.store.set(e,zt),this.loading=!1})},generateOptions(n){Re=[];let t=ri("column");t.options.locale=window.store.get("locale").replace("_","-"),t.options.plugins={tooltip:{callbacks:{title:function(e){return e.label},label:function(e){let i=e.dataset.label||"";return i&&(i+=": "),i+" "+I(e.parsed.y,Re[e.parsed.x]??"EUR")}}}},t.data={labels:[],datasets:[{label:pe.t("firefly.spent"),data:[],borderWidth:1,stack:1,backgroundColor:ge("spent","background"),borderColor:ge("spent","border")},{label:pe.t("firefly.left"),data:[],borderWidth:1,stack:1,backgroundColor:ge("left","background"),borderColor:ge("left","border")},{label:pe.t("firefly.overspent"),data:[],borderWidth:1,stack:1,backgroundColor:ge("overspent","background"),borderColor:ge("overspent","border")}]};for(const e in n)if(n.hasOwnProperty(e)){let i=n[e],s=i.label+" ("+i.currency_code+")";t.data.labels.push(s),this.autoConversion&&(Re.push(i.native_currency_code),t.data.datasets[0].data.push(parseFloat(i.native_entries.spent)*-1),t.data.datasets[1].data.push(parseFloat(i.native_entries.left)),t.data.datasets[2].data.push(parseFloat(i.native_entries.overspent))),this.autoConversion||(Re.push(i.currency_code),t.data.datasets[0].data.push(parseFloat(i.entries.spent)*-1),t.data.datasets[1].data.push(parseFloat(i.entries.left)),t.data.datasets[2].data.push(parseFloat(i.entries.overspent)))}return t.options.scales={y:{ticks:{callback:function(e){return I(e,Re[0]??"EUR")}}}},t},init(){Promise.all([lt("autoConversion",!1),lt("language","en_US")]).then(n=>{pe=new Qn;const t=n[1].replace("-","_");pe.locale=t,Zn(pe,t).then(()=>{this.autoConversion=n[0],ki=!0,this.loading===!1&&this.loadChart()})}),window.store.observe("end",()=>{ki&&this.loading===!1&&(zt=null,this.loadChart())}),window.store.observe("autoConversion",n=>{ki&&(this.autoConversion=n,this.loading===!1&&this.loadChart())})}});class hg{dashboard(t,e){let i=j(t,"y-MM-dd"),s=j(e,"y-MM-dd");return dt.get("/api/v2/chart/category/dashboard",{params:{start:i,end:s}})}}let Wo=[],Ie=null,me=null,Pi=!1;const ug=()=>({loading:!1,autoConversion:!1,generateOptions(n){Wo=[];let t=ri("column"),e={};for(const s in n)if(n.hasOwnProperty(s)){let o=n[s],r=o.currency_code;this.autoConversion&&(r=o.native_currency_code),e.hasOwnProperty(r)||(e[r]={name:r,yAxisID:"",data:{}},Wo.push(r))}for(const s in n)if(n.hasOwnProperty(s)){let o=n[s],r=o.currency_code;this.autoConversion&&(r=o.native_currency_code);for(const a in e)if(e.hasOwnProperty(a)){let l=0;r===a&&(l=parseFloat(o.amount),""+o.currency_code,this.autoConversion&&(l=parseFloat(o.native_amount),""+o.native_currency_code)),e[a].data.hasOwnProperty(o.label)&&(e[a].data[o.label]=e[a].data[o.label]+l),e[a].data.hasOwnProperty(o.label)||(e[a].data[o.label]=l)}t.data.labels.includes(o.label)||t.data.labels.push(o.label)}let i=0;for(const s in e){let o="y"+s,r={label:s,currency_code:s,yAxisID:o,data:[]};for(const a in e[s].data)r.data.push(e[s].data[a]);t.data.datasets.push(r),t.options.scales.hasOwnProperty(o)||(t.options.scales[o]={beginAtZero:!0,type:"linear",position:i===1?"right":"left",ticks:{callback:function(a,l,c){return I(a,s)}}},i++)}return t},drawChart(n){if(Ie!==null){Ie.options=n.options,Ie.data=n.data,Ie.update();return}Ie=new at(document.querySelector("#category-chart"),n)},getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Ct("dashboard-categories-chart",n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){me=s,this.drawChart(this.generateOptions(me)),this.loading=!1;return}new hg().dashboard(n,t,null).then(r=>{me=r.data,this.drawChart(this.generateOptions(r.data)),window.store.set(e,me),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,me!==null){this.drawChart(this.generateOptions(me)),this.loading=!1;return}this.getFreshData()}},init(){Promise.all([lt("autoConversion",!1)]).then(n=>{this.autoConversion=n[0],Pi=!0,this.loadChart()}),window.store.observe("end",()=>{Pi&&(this.chartData=null,this.loadChart())}),window.store.observe("autoConversion",n=>{Pi&&(this.autoConversion=n,this.loadChart())})}});let dg=class{list(t){return dt.get("/api/v2/transactions",{params:t})}};/*! * chartjs-chart-sankey v0.12.0 * https://github.com/kurkle/chartjs-chart-sankey#readme * (c) 2022 Jukka Kurkela * Released under the MIT license */function fg(n){const t=[],e=W(n)?n:F(n)?[]:[n];for(;e.length;){const i=e.pop();typeof i=="string"?t.unshift.apply(t,i.split(` `)):Array.isArray(i)?e.push.apply(e,i):F(e)||t.unshift(""+i)}return t}function Di(n){return!n||["min","max"].indexOf(n)===-1?"max":n}const jt=n=>n!==void 0;function gg(n,t){const e=new Set(t.map(r=>r.to)),i=new Set(t.map(r=>r.from)),s=new Set([...n.keys()]);let o=0;for(;s.size;){const r=pg([...s],e);for(const a of r){const l=n.get(a);jt(l.x)||(l.x=o),s.delete(a)}s.size&&(e.clear(),t.filter(a=>s.has(a.from)).forEach(a=>e.add(a.to)),o++)}return[...n.keys()].filter(r=>!i.has(r)).forEach(r=>{const a=n.get(r);a.column||(a.x=o)}),o}function pg(n,t){const e=n.filter(i=>!t.has(i));return e.length?e:n.slice(0,1)}const mg=(n,t)=>n.x!==t.x?n.x-t.x:n.y-t.y;let Tn=-1;function bg(){return Tn=Tn<100?Tn+1:0,Tn}function ji(n,t,e=bg()){let i=0;for(const s of n)s.node._visited!==e&&(s.node._visited=e,i+=s.node[t].length+ji(s.node[t],t,e));return i}const Jr=n=>(t,e)=>ji(t.node[n],n)-ji(e.node[n],n)||t.node[n].length-e.node[n].length;function cs(n,t){n.from.sort(Jr("from"));for(const e of n.from){const i=e.node;jt(i.y)||(i.y=t,cs(i,t)),t=Math.max(i.y+i.out,t)}return t}function se(n,t){n.to.sort(Jr("to"));for(const e of n.to){const i=e.node;jt(i.y)||(i.y=t,se(i,t)),t=Math.max(i.y+i.in,t)}return t}function Ee(n,t){return jt(n.y)?n.y:(n.y=t,t)}function yg(n,t){const e=n.filter(h=>h.x===0),i=n.filter(h=>h.x===t),s=e.filter(h=>!jt(h.y)),o=i.filter(h=>!jt(h.y)),r=n.filter(h=>h.x>0&&h.xMath.max(h,u.y+u.out||0),0),l=i.reduce((h,u)=>Math.max(h,u.y+u.in||0),0),c=0;return a>=l?(s.forEach(h=>{a=Ee(h,a),a=Math.max(a+h.out,se(h,a))}),o.forEach(h=>{l=Ee(h,l),l=Math.max(l+h.in,se(h,l))})):(o.forEach(h=>{l=Ee(h,l),l=Math.max(l+h.in,se(h,l))}),s.forEach(h=>{a=Ee(h,a),a=Math.max(a+h.out,se(h,a))})),r.forEach(h=>{let u=n.filter(d=>d.x===h.x&&jt(d.y)).reduce((d,f)=>Math.max(d,f.y+Math.max(f.in,f.out)),0);u=Ee(h,u),u=Math.max(u+h.in,cs(h,u)),u=Math.max(u+h.out,se(h,u)),c=Math.max(c,u)}),Math.max(a,l,c)}function _g(n,t){n.sort((r,a)=>Math.max(a.in,a.out)-Math.max(r.in,r.out));const e=n[0];e.y=0;const i=cs(e,0),s=se(e,0),o=yg(n,t);return Math.max(i,s,o)}function xg(n,t){let e=0,i=0;for(let s=0;s<=t;s++){let o=i;const r=n.filter(a=>a.x===s).sort((a,l)=>a.priority-l.priority);i=r[0].to.filter(a=>a.node.x>s+1).reduce((a,l)=>a+l.flow,0)||0;for(const a of r)a.y=o,o+=Math.max(a.out,a.in);e=Math.max(o,e)}return e}function wg(n,t){let e=1,i=0,s=0,o=0;const r=[];n.sort(mg);for(const a of n){if(a.y){if(a.x===0)r.push(a.y);else{for(i!==a.x&&(i=a.x,s=0),e=s+1;ea.y);e++);s=e}a.y+=e*t,e++}o=Math.max(o,a.y+Math.max(a.in,a.out))}return o}function vg(n,t){n.forEach(e=>{const i=Math[t](e.in||e.out,e.out||e.in),s=il.node.y+l.node.out/2-(c.node.y+c.node.out/2)).forEach((l,c)=>{s?l.addY=c*(i-l.flow)/(a-1):(l.addY=r,r+=l.flow)}),r=0,a=e.to.length,e.to.sort((l,c)=>l.node.y+l.node.in/2-(c.node.y+c.node.in/2)).forEach((l,c)=>{o?l.addY=c*(i-l.flow)/(a-1):(l.addY=r,r+=l.flow)})})}function Mg(n,t,e,i){const s=[...n.values()],o=gg(n,t),a=(e?xg(s,o):_g(s,o))*.03,l=wg(s,a);return vg(s,i),{maxX:o,maxY:l}}function kg(n){const t=new Map;for(let i=0;is.flow-i.flow;return[...t.values()].forEach(i=>{i.from=i.from.sort(e),i.from.forEach(s=>{s.node=t.get(s.key)}),i.to=i.to.sort(e),i.to.forEach(s=>{s.node=t.get(s.key)})}),t}function Ho(n,t,e){for(const i of n)if(i.key===t&&i.index===e)return i.addY;return 0}class ai extends Et{parseObjectData(t,e,i,s){const{from:o="from",to:r="to",flow:a="flow"}=this.options.parsing,l=e.map(({[o]:y,[r]:w,[a]:M})=>({from:y,to:w,flow:M})),{xScale:c,yScale:h}=t,u=[],d=this._nodes=kg(l),{column:f,priority:g,size:p}=this.getDataset();if(g)for(const y of d.values())y.key in g&&(y.priority=g[y.key]);if(f)for(const y of d.values())y.key in f&&(y.column=!0,y.x=f[y.key]);const{maxX:m,maxY:b}=Mg(d,l,!!g,Di(p));this._maxX=m,this._maxY=b;for(let y=0,w=l.length;y1){const d=c-h*l/2+u;for(let f=0;fn.type==="data"?(n.parsed._custom.x-n.parsed.x)*200:void 0,delay:n=>n.type==="data"?n.parsed.x*500+n.dataIndex*20:void 0},colors:{type:"color",properties:["colorFrom","colorTo"]}},transitions:{hide:{animations:{colors:{type:"color",properties:["colorFrom","colorTo"],to:"transparent"}}},show:{animations:{colors:{type:"color",properties:["colorFrom","colorTo"],from:"transparent"}}}}};ai.overrides={interaction:{mode:"nearest",intersect:!0},datasets:{clip:!1,parsing:!0},plugins:{tooltip:{callbacks:{title(){return""},label(n){const t=n.dataset.data[n.dataIndex];return t.from+" -> "+t.to+": "+t.flow}}},legend:{display:!1}},scales:{x:{type:"linear",bounds:"data",display:!1,min:0,offset:!1},y:{type:"linear",bounds:"data",display:!1,min:0,reverse:!0,offset:!1}},layout:{padding:{top:3,left:3,right:13,bottom:3}}};const Vo=(n,t,e,i)=>n({x:n.x+e*(t.x-n.x),y:n.y+e*(t.y-n.y)});function Pg(n,{x:t,x2:e,options:i}){let s;i.colorMode==="from"?s=ye(i.colorFrom).alpha(.5).rgbString():i.colorMode==="to"?s=ye(i.colorTo).alpha(.5).rgbString():(s=n.createLinearGradient(t,0,e,0),s.addColorStop(0,ye(i.colorFrom).alpha(.5).rgbString()),s.addColorStop(1,ye(i.colorTo).alpha(.5).rgbString())),n.fillStyle=s,n.strokeStyle=s,n.lineWidth=.5}class hs extends wt{constructor(t){super(),this.options=void 0,this.x=void 0,this.y=void 0,this.x2=void 0,this.y2=void 0,this.height=void 0,t&&Object.assign(this,t)}draw(t){const e=this,{x:i,x2:s,y:o,y2:r,height:a,progress:l}=e,{cp1:c,cp2:h}=Vo(i,o,s,r);l!==0&&(t.save(),l<1&&(t.beginPath(),t.rect(i,Math.min(o,r),(s-i)*l+1,Math.abs(r-o)+a+1),t.clip()),Pg(t,e),t.beginPath(),t.moveTo(i,o),t.bezierCurveTo(c.x,c.y,h.x,h.y,s,r),t.lineTo(s,r+a),t.bezierCurveTo(h.x,h.y+a,c.x,c.y+a,i,o+a),t.lineTo(i,o),t.stroke(),t.closePath(),t.fill(),t.restore())}inRange(t,e,i){const{x:s,y:o,x2:r,y2:a,height:l}=this.getProps(["x","y","x2","y2","height"],i);if(tr)return!1;const{cp1:c,cp2:h}=Vo(s,o,r,a),u=(t-s)/(r-s),d={x:s,y:o},f={x:r,y:a},g=be(d,c,u),p=be(c,h,u),m=be(h,f,u),b=be(g,p,u),y=be(p,m,u),w=be(b,y,u).y;return e>=w&&e<=w+l}inXRange(t,e){const{x:i,x2:s}=this.getProps(["x","x2"],e);return t>=i&&t<=s}inYRange(t,e){const{y:i,y2:s,height:o}=this.getProps(["y","y2","height"],e),r=Math.min(i,s),a=Math.max(i,s)+o;return t>=r&&t<=a}getCenterPoint(t){const{x:e,y:i,x2:s,y2:o,height:r}=this.getProps(["x","y","x2","y2","height"],t);return{x:(e+s)/2,y:(i+o+r)/2}}tooltipPosition(t){return this.getCenterPoint(t)}getRange(t){return t==="x"?this.width/2:this.height/2}}hs.id="flow";hs.defaults={colorFrom:"red",colorTo:"green",colorMode:"gradient",hoverColorFrom:(n,t)=>Ue(t.colorFrom),hoverColorTo:(n,t)=>Ue(t.colorTo)};at.register({SankeyController:ai,Flow:hs});const Yo="dashboard-sankey-data";let ot,Ci=!1,An=null,Ot=[],et=!1,O={category:null,unknown_category:null,in:null,out:null,unknown_source:null,unknown_dest:null,unknown_account:null,expense_account:null,revenue_account:null,budget:null,unknown_budget:null,all_money:null};const jo=function(n){return n.includes(O.revenue_account)?"forestgreen":n.includes("("+O.in+",")?"green":n.includes(O.budget)||n.includes(O.unknown_budget)?"Orchid":n.includes("("+O.out+",")?"MediumOrchid":n.includes(O.all_money)?"blue":"red"};function ze(n,t,e,i){if(n==="category"&&t!==null&&e==="in")return O.category+' "'+t+'" ('+O.in+(et?", "+i+")":")");if(n==="category"&&t===null&&e==="in")return O.unknown_category+" ("+O.in+(et?", "+i+")":")");if(n==="category"&&t!==null&&e==="out")return O.category+' "'+t+'" ('+O.out+(et?", "+i+")":")");if(n==="category"&&t===null&&e==="out")return O.unknown_category+" ("+O.out+(et?", "+i+")":")");if(n==="account"&&t===null&&e==="in")return O.unknown_source+(et?" ("+i+")":"");if(n==="account"&&t!==null&&e==="in")return O.revenue_account+'"'+t+'"'+(et?" ("+i+")":"");if(n==="account"&&t===null&&e==="out")return O.unknown_dest+(et?" ("+i+")":"");if(n==="account"&&t!==null&&e==="out")return O.expense_account+' "'+t+'"'+(et?" ("+i+")":"");if(n==="budget"&&t!==null)return O.budget+' "'+t+'"'+(et?" ("+i+")":"");if(n==="budget"&&t===null)return O.unknown_budget+(et?" ("+i+")":"");console.error('Cannot handle: type:"'+n+'", dir: "'+e+'"')}function Be(n,t,e){if(n==="category"&&t!==null)return O.category+' "'+t+'"'+(et?" ("+e+")":"");if(n==="category"&&t===null)return O.unknown_category+(et?" ("+e+")":"");if(n==="account"&&t===null)return O.unknown_account+(et?" ("+e+")":"");if(n==="account"&&t!==null)return t+(et?" ("+e+")":"");if(n==="budget"&&t!==null)return O.budget+' "'+t+'"'+(et?" ("+e+")":"");if(n==="budget"&&t===null)return O.unknown_budget+(et?" ("+e+")":"");console.error('Cannot handle: type:"'+n+'"')}const Dg=()=>({loading:!1,autoConversion:!1,generateOptions(){let n=ri("sankey"),t={},e={};for(let s in Ot)if(Ot.hasOwnProperty(s)){let o=Ot[s];for(let r in o.attributes.transactions)if(o.attributes.transactions.hasOwnProperty(r)){let a=o.attributes.transactions[r],l=this.autoConversion?a.native_currency_code:a.currency_code,c=this.autoConversion?parseFloat(a.native_amount):parseFloat(a.amount),h;if(a.type==="deposit"){let u=ze("category",a.category_name,"in",l),d=ze("account",a.source_name,"in",l);e[u]=Be("category",a.category_name,l),e[d]=Be("account",a.source_name,l),h=d+"-"+u+"-"+l,t.hasOwnProperty(h)||(t[h]={from:d,to:u,amount:0}),t[h].amount+=c,h=u+"-"+O.all_money+"-"+l,t.hasOwnProperty(h)||(t[h]={from:u,to:O.all_money+(this.autoConversion?" ("+l+")":""),amount:0}),t[h].amount+=c}if(a.type==="withdrawal"){let u=ze("budget",a.budget_name,"out",l);e[u]=Be("budget",a.budget_name,l),h=O.all_money+"-"+u+"-"+l,t.hasOwnProperty(h)||(t[h]={from:O.all_money+(this.autoConversion?" ("+l+")":""),to:u,amount:0}),t[h].amount+=c;let d=ze("category",a.category_name,"out",l);e[d]=Be("category",a.category_name,l),h=u+"-"+d+"-"+l,t.hasOwnProperty(h)||(t[h]={from:u,to:d,amount:0}),t[h].amount+=c;let f=ze("account",a.destination_name,"out",l);e[f]=Be("account",a.destination_name,l),h=d+"-"+f+"-"+l,t.hasOwnProperty(h)||(t[h]={from:d,to:f,amount:0}),t[h].amount+=c}}}let i={label:"Firefly III dashboard sankey chart",data:[],colorFrom:s=>jo(s.dataset.data[s.dataIndex]?s.dataset.data[s.dataIndex].from:""),colorTo:s=>jo(s.dataset.data[s.dataIndex]?s.dataset.data[s.dataIndex].to:""),colorMode:"gradient",labels:e,size:"min"};for(let s in t)if(t.hasOwnProperty(s)){let o=t[s];i.data.push({from:o.from,to:o.to,flow:o.amount})}return n.data.datasets.push(i),n},drawChart(n){if(An!==null){An.data.datasets=n.data.datasets,An.update();return}An=new at(document.querySelector("#sankey-chart"),n)},getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Ct(Yo,n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){Ot=s,this.drawChart(this.generateOptions()),this.loading=!1;return}let o={start:j(n,"y-MM-dd"),end:j(t,"y-MM-dd"),type:"withdrawal,deposit",page:1};this.downloadTransactions(o)},downloadTransactions(n){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),i=Ct(Yo,t,e);new dg().list(n).then(o=>{if(Ot=[...Ot,...o.data.data],parseInt(o.data.meta.pagination.total_pages)>n.page){n.page++,this.downloadTransactions(n);return}window.store.set(i,Ot),this.drawChart(this.generateOptions()),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,Ot.length!==0){this.drawChart(this.generateOptions()),this.loading=!1;return}this.getFreshData()}},init(){Ot=[],Promise.all([lt("autoConversion",!1),lt("language","en_US")]).then(n=>{this.autoConversion=n[0],et=n[0],ot=new Qn;const t=n[1].replace("-","_");ot.locale=t,Zn(ot,t).then(()=>{O.all_money=ot.t("firefly.all_money"),O.category=ot.t("firefly.category"),O.in=ot.t("firefly.money_flowing_in"),O.out=ot.t("firefly.money_flowing_out"),O.unknown_category=ot.t("firefly.unknown_category_plain"),O.unknown_source=ot.t("firefly.unknown_source_plain"),O.unknown_dest=ot.t("firefly.unknown_dest_plain"),O.unknown_account=ot.t("firefly.unknown_any_plain"),O.unknown_budget=ot.t("firefly.unknown_budget_plain"),O.expense_account=ot.t("firefly.expense_account"),O.revenue_account=ot.t("firefly.revenue_account"),O.budget=ot.t("firefly.budget"),Ci=!0,this.loadChart()})}),window.store.observe("end",()=>{Ci&&(this.transactions=[],this.loadChart())}),window.store.observe("autoConversion",n=>{Ci&&(this.autoConversion=n,this.loadChart())})}});let Cg=class{list(t){return dt.get("/api/v2/subscriptions",{params:t})}paid(t){return dt.get("/api/v2/subscriptions/sum/paid",{params:t})}unpaid(t){return dt.get("/api/v2/subscriptions/sum/unpaid",{params:t})}},Si=!1,Bt,pt={};function ta(n){return new Cg().list(n).then(e=>{let i=e.data.data;for(let s in i)if(i.hasOwnProperty(s)){let o=i[s];if(o.attributes.active&&o.attributes.pay_dates.length>0){let r=o.attributes.object_group_id===null?0:o.attributes.object_group_id,a=o.attributes.object_group_title===null?Bt.t("firefly.default_group_title_name_plain"):o.attributes.object_group_title,l=o.attributes.object_group_order===null?0:o.attributes.object_group_order;pt.hasOwnProperty(r)||(pt[r]={id:r,title:a,order:l,payment_info:{},bills:[]});let c={id:o.id,name:o.attributes.name,amount_min:o.attributes.amount_min,amount_max:o.attributes.amount_max,amount:(parseFloat(o.attributes.amount_max)+parseFloat(o.attributes.amount_min))/2,currency_code:o.attributes.currency_code,native_amount_min:o.attributes.native_amount_min,native_amount_max:o.attributes.native_amount_max,native_amount:(parseFloat(o.attributes.native_amount_max)+parseFloat(o.attributes.native_amount_min))/2,native_currency_code:o.attributes.native_currency_code,transactions:[],pay_dates:o.attributes.pay_dates,paid:o.attributes.paid_dates.length>0};c.expected_amount=n.autoConversion?I(c.native_amount,c.native_currency_code):I(c.amount,c.currency_code),c.expected_times=Bt.t("firefly.subscr_expected_x_times",{times:o.attributes.pay_dates.length,amount:c.expected_amount});for(let h in o.attributes.paid_dates)if(o.attributes.paid_dates.hasOwnProperty(h)){const u=o.attributes.paid_dates[h];let d=100;n.autoConversion&&(d=Math.round(-100+parseFloat(u.native_amount)*-1/parseFloat(c.native_amount)*100)),n.autoConversion||(d=Math.round(-100+parseFloat(u.amount)*-1/parseFloat(c.amount)*100));let f={amount:n.autoConversion?I(u.native_amount,u.native_currency_code):I(u.amount,u.currency_code),percentage:d,date:j(new Date(u.date),"PP"),foreign_amount:null};u.foreign_currency_code!==null&&(f.foreign_amount=n.autoConversion?u.foreign_native_amount:u.foreign_amount,f.foreign_currency_code=n.autoConversion?u.native_currency_code:u.foreign_currency_code),c.transactions.push(f)}if(pt[r].bills.push(c),o.attributes.paid_dates.length===0){const h=o.attributes.pay_dates.length*c.amount,u=o.attributes.pay_dates.length*c.native_amount;pt[r].payment_info.hasOwnProperty(c.currency_code)||(pt[r].payment_info[c.currency_code]={currency_code:c.currency_code,paid:0,unpaid:0,native_currency_code:c.native_currency_code,native_paid:0,native_unpaid:0}),pt[r].payment_info[c.currency_code].unpaid+=h,pt[r].payment_info[c.currency_code].native_unpaid+=u}if(o.attributes.paid_dates.length>0){for(let h in o.attributes.paid_dates)if(o.attributes.paid_dates.hasOwnProperty(h)){let u=o.attributes.paid_dates[h];pt[r].payment_info.hasOwnProperty(u.currency_code)||(pt[r].payment_info[u.currency_code]={currency_code:c.currency_code,paid:0,unpaid:0,native_currency_code:c.native_currency_code,native_paid:0,native_unpaid:0});const d=parseFloat(u.amount)*-1,f=parseFloat(u.native_amount)*-1;pt[r].payment_info[u.currency_code].paid+=d,pt[r].payment_info[u.currency_code].native_paid+=f}}}}return parseInt(e.data.meta.pagination.total_pages)>n.page?(n.page++,ta(n)):Promise.resolve()})}const Sg=()=>({loading:!1,autoConversion:!1,subscriptions:[],startSubscriptions(){this.loading=!0;let n=new Date(window.store.get("start")),t=new Date(window.store.get("end"));console.log("here we are");const e=window.store.get("cacheValid");let i=window.store.get(Ct("subscriptions-data-dashboard",n,t));e&&typeof i<"u",pt={},this.subscriptions=[],console.log("cache is invalid, must download");let s={start:j(n,"y-MM-dd"),end:j(t,"y-MM-dd"),autoConversion:this.autoConversion,page:1};ta(s).then(()=>{console.log("Done with download!");let o=Object.values(pt);for(let r in o)if(o.hasOwnProperty(r)){let a=o[r];const l=Object.keys(a.payment_info);a.col_size=l.length===1?"col-6 offset-3":"col-6",a.chart_width=l.length===1?"50%":"100%",a.payment_length=l.length,this.subscriptions.push(a)}this.loading=!1})},drawPieChart(n,t,e){let i="#pie_"+n+"_"+e.currency_code;const s=this.autoConversion?e.native_unpaid:e.unpaid,o=this.autoConversion?e.native_paid:e.paid,r=this.autoConversion?e.native_currency_code:e.currency_code,l={type:"doughnut",data:{labels:[Bt.t("firefly.paid"),Bt.t("firefly.unpaid")],datasets:[{label:Bt.t("firefly.subscriptions_in_group",{title:t}),data:[o,s],backgroundColor:["rgb(54, 162, 235)","rgb(255, 99, 132)"],hoverOffset:4}]},options:{plugins:{tooltip:{callbacks:{label:function(h){return h.dataset.label+": "+I(h.raw,r)}}}}}};var c=at.getChart(document.querySelector(i));typeof c<"u"&&c.destroy(),new at(document.querySelector(i),l)},init(){console.log("subscriptions init"),Promise.all([lt("autoConversion",!1),lt("language","en_US")]).then(n=>{console.log("subscriptions after promises"),this.autoConversion=n[0],Si=!0,Bt=new Qn;const t=n[1].replace("-","_");Bt.locale=t,Zn(Bt,t).then(()=>{this.loading===!1&&this.startSubscriptions()})}),window.store.observe("end",()=>{Si&&(console.log("subscriptions observe end"),this.loading===!1&&this.startSubscriptions())}),window.store.observe("autoConversion",n=>{Si&&(console.log("subscriptions observe autoConversion"),this.autoConversion=n,this.loading===!1&&this.startSubscriptions())})}});class Og{list(t){return dt.get("/api/v2/piggy-banks",{params:t})}}let Tt={},Oi=!1,Ln;const $o="dashboard-piggies-data",Tg=()=>({loading:!1,autoConversion:!1,sankeyGrouping:"account",piggies:[],getFreshData(){const n=new Date(window.store.get("start")),t=new Date(window.store.get("end")),e=Ct($o,n,t),i=window.store.get("cacheValid");let s=window.store.get(e);if(i&&typeof s<"u"){Tt=s,this.parsePiggies(),this.loading=!1;return}let o={start:j(n,"y-MM-dd"),end:j(t,"y-MM-dd"),page:1};this.downloadPiggyBanks(o)},downloadPiggyBanks(n){const t=new Date(window.store.get("start")),e=new Date(window.store.get("end")),i=Ct($o,t,e);new Og().list(n).then(o=>{if(Tt=[...Tt,...o.data.data],parseInt(o.data.meta.pagination.total_pages)>n.page){n.page++,this.downloadPiggyBanks(n);return}window.store.set(i,Tt),this.parsePiggies(),this.loading=!1})},parsePiggies(){let n=[];for(let t in Tt)if(Tt.hasOwnProperty(t)){let e=Tt[t];if(e.attributes.percentage>=100||e.attributes.percentage===0)continue;let i=e.object_group_title??Ln.t("firefly.default_group_title_name_plain");n.hasOwnProperty(i)||(n[i]={id:e.object_group_id??0,title:i,order:e.object_group_order??0,piggies:[]});let s={id:e.id,name:e.attributes.name,percentage:parseInt(e.attributes.percentage),amount:this.autoConversion?e.attributes.native_current_amount:e.attributes.current_amount,left_to_save:this.autoConversion?e.attributes.native_left_to_save:e.attributes.left_to_save,target_amount:this.autoConversion?e.attributes.native_target_amount:e.attributes.target_amount,save_per_month:this.autoConversion?e.attributes.native_save_per_month:e.attributes.save_per_month,currency_code:this.autoConversion?e.attributes.native_currency_code:e.attributes.currency_code};n[i].piggies.push(s)}this.piggies=Object.values(n)},loadPiggyBanks(){if(this.loading!==!0){if(this.loading=!0,this.piggies.length!==0){this.parsePiggies(),this.loading=!1;return}this.getFreshData()}},init(){Tt=[],Promise.all([lt("autoConversion",!1),lt("language","en_US")]).then(n=>{Ln=new Qn;const t=n[1].replace("-","_");Ln.locale=t,Zn(Ln,t).then(()=>{Oi=!0,this.autoConversion=n[0],this.loadPiggyBanks()})}),window.store.observe("end",()=>{Oi&&(Tt=[],this.loadPiggyBanks())}),window.store.observe("autoConversion",n=>{Oi&&(this.autoConversion=n,this.loadPiggyBanks())})}});/*! * chartjs-adapter-date-fns v3.0.0 * https://www.chartjs.org * (c) 2022 chartjs-adapter-date-fns Contributors * Released under the MIT license */const Ag={datetime:"MMM d, yyyy, h:mm:ss aaaa",millisecond:"h:mm:ss.SSS aaaa",second:"h:mm:ss aaaa",minute:"h:mm aaaa",hour:"ha",day:"MMM d",week:"PP",month:"MMM yyyy",quarter:"qqq - yyyy",year:"yyyy"};Lr._date.override({_id:"date-fns",formats:function(){return Ag},parse:function(n,t){if(n===null||typeof n>"u")return null;const e=typeof n;return e==="number"||n instanceof Date?n=R(n):e==="string"&&(typeof t=="string"?n=zl(n,t,new Date,this.options):n=Hl(n,this.options)),ga(n)?n.getTime():null},format:function(n,t){return j(n,t,this.options)},add:function(n,t,e){switch(e){case"millisecond":return Jn(n,t);case"second":return Pa(n,t);case"minute":return Ma(n,t);case"hour":return va(n,t);case"day":return Gn(n,t);case"week":return Da(n,t);case"month":return $i(n,t);case"quarter":return ka(n,t);case"year":return Ca(n,t);default:return n}},diff:function(n,t,e){switch(e){case"millisecond":return ti(n,t);case"second":return Ra(n,t);case"minute":return Aa(n,t);case"hour":return Ta(n,t);case"day":return Qo(n,t);case"week":return Ia(n,t);case"month":return Zo(n,t);case"quarter":return Fa(n,t);case"year":return Ea(n,t);default:return 0}},startOf:function(n,t,e){switch(t){case"second":return Wl(n);case"minute":return za(n);case"hour":return Nl(n);case"day":return ya(n);case"week":return Ke(n);case"isoWeek":return Ke(n,{weekStartsOn:+e});case"month":return ba(n);case"quarter":return ma(n);case"year":return pa(n);default:return n}},endOf:function(n,t){switch(t){case"second":return Ha(n);case"minute":return Wa(n);case"hour":return Na(n);case"day":return qo(n);case"week":return xa(n);case"month":return Uo(n);case"quarter":return _a(n);case"year":return Ba(n);default:return n}}});at.register({LineController:Rn,LineElement:Vt,ArcElement:He,BarController:Fn,TimeScale:sn,PieController:Ri,BarElement:Nn,Filler:wf,Colors:tf,LinearScale:Vi,CategoryScale:Hi,PointElement:Bn,Tooltip:If,Legend:Cf});const ea={dates:wa,boxes:sc,accounts:ag,budgets:cg,categories:ug,sankey:Dg,subscriptions:Sg,piggies:Tg};function na(n){Object.keys(n).forEach(t=>{console.log(`Loading page component "${t}"`);let e=n[t]();Alpine.data(t,()=>e)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{na(ea)});window.bootstrapped&&na(ea);