mirror of
https://github.com/svm0n/datadeck.git
synced 2026-07-22 08:31:46 +00:00
Inline view (src/inline-view.ts): a csv-view code block renders an editable table/cards/kanban view of a CSV inside any note. InlineCardHost satisfies the renderers' duck-typed surface so renderTable/renderLibrary/renderKanbanGenre are reused unchanged; edits write back via vault.modify and re-sync off the modify event. Block directives: file/mode/height/collapse. - Cards/Kanban thumbnails: getImageCol() auto-detects Image/Cover/Poster/… columns; resolveImageSrc() handles vault paths, wikilinks, md-images, URLs. - Card title + context-menu "Open entry" now open the expander even without a notes column (NoteExpanderModal hides its notes section when absent), so notes-less files (e.g. applications trackers) are editable from cards. - collapse: directive + fileCfg.collapsedGroups: Cards groups collapse by default and remember manual toggles (full-page too). - Habit add-form toggles for 0/1 columns; pseudo-categorical columns (few distinct values) get option dropdowns in the add + edit forms via shared looksCategorical() helper. - Kanban: empty group value → "—" column (was dropped in default grouping); rows with blank/unknown status render ungrouped instead of vanishing while the column header still counted them. - Dark-mode table row hover: explicit text-tint overlay (was near-invisible). - Docs: csv-view syntax in README; architecture + open follow-ups in handoff. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
407 lines
365 KiB
JavaScript
407 lines
365 KiB
JavaScript
"use strict";var Ul=Object.create;var ms=Object.defineProperty;var Kl=Object.getOwnPropertyDescriptor;var Yl=Object.getOwnPropertyNames;var Gl=Object.getPrototypeOf,ql=Object.prototype.hasOwnProperty;var Xl=(s,t,e)=>t in s?ms(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var ti=(s,t)=>()=>(s&&(t=s(s=0)),t);var Ql=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports),So=(s,t)=>{for(var e in t)ms(s,e,{get:t[e],enumerable:!0})},wo=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Yl(t))!ql.call(s,i)&&i!==e&&ms(s,i,{get:()=>t[i],enumerable:!(n=Kl(t,i))||n.enumerable});return s};var qs=(s,t,e)=>(e=s!=null?Ul(Gl(s)):{},wo(t||!s||!s.__esModule?ms(e,"default",{value:s,enumerable:!0}):e,s)),Zl=s=>wo(ms({},"__esModule",{value:!0}),s);var H=(s,t,e)=>(Xl(s,typeof t!="symbol"?t+"":t,e),e);var bs=Ql((ei,si)=>{((s,t)=>{typeof define=="function"&&define.amd?define([],t):typeof si=="object"&&typeof ei!="undefined"?si.exports=t():s.Papa=t()})(ei,function s(){var t=typeof self!="undefined"?self:typeof window!="undefined"?window:t!==void 0?t:{},e,n=!t.document&&!!t.postMessage,i=t.IS_PAPA_WORKER||!1,o={},r=0,a={};function l(v){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},function(y){var S=_(y);S.chunkSize=parseInt(S.chunkSize),y.step||y.chunk||(S.chunkSize=null),this._handle=new f(S),(this._handle.streamer=this)._config=S}.call(this,v),this.parseChunk=function(y,S){var D=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<D){let C=this._config.newline;C||(M=this._config.quoteChar||'"',C=this._handle.guessLineEndings(y,M)),y=[...y.split(C).slice(D)].join(C)}this.isFirstChunk&&w(this._config.beforeFirstChunk)&&(M=this._config.beforeFirstChunk(y))!==void 0&&(y=M),this.isFirstChunk=!1,this._halted=!1;var D=this._partialLine+y,M=(this._partialLine="",this._handle.parse(D,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(y=M.meta.cursor,D=(this._finished||(this._partialLine=D.substring(y-this._baseIndex),this._baseIndex=y),M&&M.data&&(this._rowCount+=M.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),i)t.postMessage({results:M,workerId:a.WORKER_ID,finished:D});else if(w(this._config.chunk)&&!S){if(this._config.chunk(M,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=M=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(M.data),this._completeResults.errors=this._completeResults.errors.concat(M.errors),this._completeResults.meta=M.meta),this._completed||!D||!w(this._config.complete)||M&&M.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),D||M&&M.meta.paused||this._nextChunk(),M}this._halted=!0},this._sendError=function(y){w(this._config.error)?this._config.error(y):i&&this._config.error&&t.postMessage({workerId:a.WORKER_ID,error:y,finished:!1})}}function c(v){var y;(v=v||{}).chunkSize||(v.chunkSize=a.RemoteChunkSize),l.call(this,v),this._nextChunk=n?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(S){this._input=S,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(y=new XMLHttpRequest,this._config.withCredentials&&(y.withCredentials=this._config.withCredentials),n||(y.onload=E(this._chunkLoaded,this),y.onerror=E(this._chunkError,this)),y.open(this._config.downloadRequestBody?"POST":"GET",this._input,!n),this._config.downloadRequestHeaders){var S,D=this._config.downloadRequestHeaders;for(S in D)y.setRequestHeader(S,D[S])}var M;this._config.chunkSize&&(M=this._start+this._config.chunkSize-1,y.setRequestHeader("Range","bytes="+this._start+"-"+M));try{y.send(this._config.downloadRequestBody)}catch(C){this._chunkError(C.message)}n&&y.status===0&&this._chunkError()}},this._chunkLoaded=function(){y.readyState===4&&(y.status<200||400<=y.status?this._chunkError():(this._start+=this._config.chunkSize||y.responseText.length,this._finished=!this._config.chunkSize||this._start>=(S=>(S=S.getResponseHeader("Content-Range"))!==null?parseInt(S.substring(S.lastIndexOf("/")+1)):-1)(y),this.parseChunk(y.responseText)))},this._chunkError=function(S){S=y.statusText||S,this._sendError(new Error(S))}}function d(v){(v=v||{}).chunkSize||(v.chunkSize=a.LocalChunkSize),l.call(this,v);var y,S,D=typeof FileReader!="undefined";this.stream=function(M){this._input=M,S=M.slice||M.webkitSlice||M.mozSlice,D?((y=new FileReader).onload=E(this._chunkLoaded,this),y.onerror=E(this._chunkError,this)):y=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var M=this._input,C=(this._config.chunkSize&&(C=Math.min(this._start+this._config.chunkSize,this._input.size),M=S.call(M,this._start,C)),y.readAsText(M,this._config.encoding));D||this._chunkLoaded({target:{result:C}})},this._chunkLoaded=function(M){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(M.target.result)},this._chunkError=function(){this._sendError(y.error)}}function h(v){var y;l.call(this,v=v||{}),this.stream=function(S){return y=S,this._nextChunk()},this._nextChunk=function(){var S,D;if(!this._finished)return S=this._config.chunkSize,y=S?(D=y.substring(0,S),y.substring(S)):(D=y,""),this._finished=!y,this.parseChunk(D)}}function u(v){l.call(this,v=v||{});var y=[],S=!0,D=!1;this.pause=function(){l.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){l.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(M){this._input=M,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){D&&y.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),y.length?this.parseChunk(y.shift()):S=!0},this._streamData=E(function(M){try{y.push(typeof M=="string"?M:M.toString(this._config.encoding)),S&&(S=!1,this._checkIsFinished(),this.parseChunk(y.shift()))}catch(C){this._streamError(C)}},this),this._streamError=E(function(M){this._streamCleanUp(),this._sendError(M)},this),this._streamEnd=E(function(){this._streamCleanUp(),D=!0,this._streamData("")},this),this._streamCleanUp=E(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function f(v){var y,S,D,M,C=Math.pow(2,53),T=-C,k=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,A=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,P=this,O=0,z=0,G=!1,$=!1,L=[],V={data:[],errors:[],meta:{}};function W(F){return v.skipEmptyLines==="greedy"?F.join("").trim()==="":F.length===1&&F[0].length===0}function j(){if(V&&D&&(B("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),D=!1),v.skipEmptyLines&&(V.data=V.data.filter(function(Y){return!W(Y)})),U()){let Y=function(K,Z){w(v.transformHeader)&&(K=v.transformHeader(K,Z)),L.push(K)};var R=Y;if(V)if(Array.isArray(V.data[0])){for(var F=0;U()&&F<V.data.length;F++)V.data[F].forEach(Y);V.data.splice(0,1)}else V.data.forEach(Y)}function I(Y,K){for(var Z=v.header?{}:[],X=0;X<Y.length;X++){var q=X,ut=Y[X],ut=((J,st)=>(at=>(v.dynamicTypingFunction&&v.dynamicTyping[at]===void 0&&(v.dynamicTyping[at]=v.dynamicTypingFunction(at)),(v.dynamicTyping[at]||v.dynamicTyping)===!0))(J)?st==="true"||st==="TRUE"||st!=="false"&&st!=="FALSE"&&((at=>{if(k.test(at)&&(at=parseFloat(at),T<at&&at<C))return 1})(st)?parseFloat(st):A.test(st)?new Date(st):st===""?null:st):st)(q=v.header?X>=L.length?"__parsed_extra":L[X]:q,ut=v.transform?v.transform(ut,q):ut);q==="__parsed_extra"?(Z[q]=Z[q]||[],Z[q].push(ut)):Z[q]=ut}return v.header&&(X>L.length?B("FieldMismatch","TooManyFields","Too many fields: expected "+L.length+" fields but parsed "+X,z+K):X<L.length&&B("FieldMismatch","TooFewFields","Too few fields: expected "+L.length+" fields but parsed "+X,z+K)),Z}var N;V&&(v.header||v.dynamicTyping||v.transform)&&(N=1,!V.data.length||Array.isArray(V.data[0])?(V.data=V.data.map(I),N=V.data.length):V.data=I(V.data,0),v.header&&V.meta&&(V.meta.fields=L),z+=N)}function U(){return v.header&&L.length===0}function B(F,I,N,R){F={type:F,code:I,message:N},R!==void 0&&(F.row=R),V.errors.push(F)}w(v.step)&&(M=v.step,v.step=function(F){V=F,U()?j():(j(),V.data.length!==0&&(O+=F.data.length,v.preview&&O>v.preview?S.abort():(V.data=V.data[0],M(V,P))))}),this.parse=function(F,I,N){var R=v.quoteChar||'"',R=(v.newline||(v.newline=this.guessLineEndings(F,R)),D=!1,v.delimiter?w(v.delimiter)&&(v.delimiter=v.delimiter(F),V.meta.delimiter=v.delimiter):((R=((Y,K,Z,X,q)=>{var ut,J,st,at;q=q||[","," ","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var Rt=0;Rt<q.length;Rt++){for(var it,gt=q[Rt],ft=0,Kt=0,yt=0,Et=(st=void 0,new m({comments:X,delimiter:gt,newline:K,preview:10}).parse(Y)),ne=0;ne<Et.data.length;ne++)Z&&W(Et.data[ne])?yt++:(it=Et.data[ne].length,Kt+=it,st===void 0?st=it:0<it&&(ft+=Math.abs(it-st),st=it));0<Et.data.length&&(Kt/=Et.data.length-yt),(J===void 0||ft<=J)&&(at===void 0||at<Kt)&&1.99<Kt&&(J=ft,ut=gt,at=Kt)}return{successful:!!(v.delimiter=ut),bestDelimiter:ut}})(F,v.newline,v.skipEmptyLines,v.comments,v.delimitersToGuess)).successful?v.delimiter=R.bestDelimiter:(D=!0,v.delimiter=a.DefaultDelimiter),V.meta.delimiter=v.delimiter),_(v));return v.preview&&v.header&&R.preview++,y=F,S=new m(R),V=S.parse(y,I,N),j(),G?{meta:{paused:!0}}:V||{meta:{paused:!1}}},this.paused=function(){return G},this.pause=function(){G=!0,S.abort(),y=w(v.chunk)?"":y.substring(S.getCharIndex())},this.resume=function(){P.streamer._halted?(G=!1,P.streamer.parseChunk(y,!0)):setTimeout(P.resume,3)},this.aborted=function(){return $},this.abort=function(){$=!0,S.abort(),V.meta.aborted=!0,w(v.complete)&&v.complete(V),y=""},this.guessLineEndings=function(Y,R){Y=Y.substring(0,1048576);var R=new RegExp(p(R)+"([^]*?)"+p(R),"gm"),N=(Y=Y.replace(R,"")).split("\r"),R=Y.split(`
|
||
`),Y=1<R.length&&R[0].length<N[0].length;if(N.length===1||Y)return`
|
||
`;for(var K=0,Z=0;Z<N.length;Z++)N[Z][0]===`
|
||
`&&K++;return K>=N.length/2?`\r
|
||
`:"\r"}}function p(v){return v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function m(v){var y=(v=v||{}).delimiter,S=v.newline,D=v.comments,M=v.step,C=v.preview,T=v.fastMode,k=null,A=!1,P=v.quoteChar==null?'"':v.quoteChar,O=P;if(v.escapeChar!==void 0&&(O=v.escapeChar),(typeof y!="string"||-1<a.BAD_DELIMITERS.indexOf(y))&&(y=","),D===y)throw new Error("Comment character same as delimiter");D===!0?D="#":(typeof D!="string"||-1<a.BAD_DELIMITERS.indexOf(D))&&(D=!1),S!==`
|
||
`&&S!=="\r"&&S!==`\r
|
||
`&&(S=`
|
||
`);var z=0,G=!1;this.parse=function($,L,V){if(typeof $!="string")throw new Error("Input must be a string");var W=$.length,j=y.length,U=S.length,B=D.length,F=w(M),I=[],N=[],R=[],Y=z=0;if(!$)return ft();if(T||T!==!1&&$.indexOf(P)===-1){for(var K=$.split(S),Z=0;Z<K.length;Z++){if(R=K[Z],z+=R.length,Z!==K.length-1)z+=S.length;else if(V)return ft();if(!D||R.substring(0,B)!==D){if(F){if(I=[],at(R.split(y)),Kt(),G)return ft()}else at(R.split(y));if(C&&C<=Z)return I=I.slice(0,C),ft(!0)}}return ft()}for(var X=$.indexOf(y,z),q=$.indexOf(S,z),ut=new RegExp(p(O)+p(P),"g"),J=$.indexOf(P,z);;)if($[z]===P)for(J=z,z++;;){if((J=$.indexOf(P,J+1))===-1)return V||N.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:I.length,index:z}),it();if(J===W-1)return it($.substring(z,J).replace(ut,P));if(P===O&&$[J+1]===O)J++;else if(P===O||J===0||$[J-1]!==O){X!==-1&&X<J+1&&(X=$.indexOf(y,J+1));var st=Rt((q=q!==-1&&q<J+1?$.indexOf(S,J+1):q)===-1?X:Math.min(X,q));if($.substr(J+1+st,j)===y){R.push($.substring(z,J).replace(ut,P)),$[z=J+1+st+j]!==P&&(J=$.indexOf(P,z)),X=$.indexOf(y,z),q=$.indexOf(S,z);break}if(st=Rt(q),$.substring(J+1+st,J+1+st+U)===S){if(R.push($.substring(z,J).replace(ut,P)),gt(J+1+st+U),X=$.indexOf(y,z),J=$.indexOf(P,z),F&&(Kt(),G))return ft();if(C&&I.length>=C)return ft(!0);break}N.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:I.length,index:z}),J++}}else if(D&&R.length===0&&$.substring(z,z+B)===D){if(q===-1)return ft();z=q+U,q=$.indexOf(S,z),X=$.indexOf(y,z)}else if(X!==-1&&(X<q||q===-1))R.push($.substring(z,X)),z=X+j,X=$.indexOf(y,z);else{if(q===-1)break;if(R.push($.substring(z,q)),gt(q+U),F&&(Kt(),G))return ft();if(C&&I.length>=C)return ft(!0)}return it();function at(yt){I.push(yt),Y=z}function Rt(yt){var Et=0;return Et=yt!==-1&&(yt=$.substring(J+1,yt))&&yt.trim()===""?yt.length:Et}function it(yt){return V||(yt===void 0&&(yt=$.substring(z)),R.push(yt),z=W,at(R),F&&Kt()),ft()}function gt(yt){z=yt,at(R),R=[],q=$.indexOf(S,z)}function ft(yt){if(v.header&&!L&&I.length&&!A){var Et=I[0],ne=Object.create(null),Jn=new Set(Et);let _o=!1;for(let $e=0;$e<Et.length;$e++){let Yt=Et[$e];if(ne[Yt=w(v.transformHeader)?v.transformHeader(Yt,$e):Yt]){let gs,Co=ne[Yt];for(;gs=Yt+"_"+Co,Co++,Jn.has(gs););Jn.add(gs),Et[$e]=gs,ne[Yt]++,_o=!0,(k=k===null?{}:k)[gs]=Yt}else ne[Yt]=1,Et[$e]=Yt;Jn.add(Yt)}_o&&console.warn("Duplicate headers found and renamed."),A=!0}return{data:I,errors:N,meta:{delimiter:y,linebreak:S,aborted:G,truncated:!!yt,cursor:Y+(L||0),renamedHeaders:k}}}function Kt(){M(ft()),I=[],N=[]}},this.abort=function(){G=!0},this.getCharIndex=function(){return z}}function g(v){var y=v.data,S=o[y.workerId],D=!1;if(y.error)S.userError(y.error,y.file);else if(y.results&&y.results.data){var M={abort:function(){D=!0,b(y.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:x,resume:x};if(w(S.userStep)){for(var C=0;C<y.results.data.length&&(S.userStep({data:y.results.data[C],errors:y.results.errors,meta:y.results.meta},M),!D);C++);delete y.results}else w(S.userChunk)&&(S.userChunk(y.results,M,y.file),delete y.results)}y.finished&&!D&&b(y.workerId,y.results)}function b(v,y){var S=o[v];w(S.userComplete)&&S.userComplete(y),S.terminate(),delete o[v]}function x(){throw new Error("Not implemented.")}function _(v){if(typeof v!="object"||v===null)return v;var y,S=Array.isArray(v)?[]:{};for(y in v)S[y]=_(v[y]);return S}function E(v,y){return function(){v.apply(y,arguments)}}function w(v){return typeof v=="function"}return a.parse=function(v,y){var S=(y=y||{}).dynamicTyping||!1;if(w(S)&&(y.dynamicTypingFunction=S,S={}),y.dynamicTyping=S,y.transform=!!w(y.transform)&&y.transform,!y.worker||!a.WORKERS_SUPPORTED)return S=null,a.NODE_STREAM_INPUT,typeof v=="string"?(v=(D=>D.charCodeAt(0)!==65279?D:D.slice(1))(v),S=new(y.download?c:h)(y)):v.readable===!0&&w(v.read)&&w(v.on)?S=new u(y):(t.File&&v instanceof File||v instanceof Object)&&(S=new d(y)),S.stream(v);(S=(()=>{var D;return!!a.WORKERS_SUPPORTED&&(D=(()=>{var M=t.URL||t.webkitURL||null,C=s.toString();return a.BLOB_URL||(a.BLOB_URL=M.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",C,")();"],{type:"text/javascript"})))})(),(D=new t.Worker(D)).onmessage=g,D.id=r++,o[D.id]=D)})()).userStep=y.step,S.userChunk=y.chunk,S.userComplete=y.complete,S.userError=y.error,y.step=w(y.step),y.chunk=w(y.chunk),y.complete=w(y.complete),y.error=w(y.error),delete y.worker,S.postMessage({input:v,config:y,workerId:S.id})},a.unparse=function(v,y){var S=!1,D=!0,M=",",C=`\r
|
||
`,T='"',k=T+T,A=!1,P=null,O=!1,z=((()=>{if(typeof y=="object"){if(typeof y.delimiter!="string"||a.BAD_DELIMITERS.filter(function(L){return y.delimiter.indexOf(L)!==-1}).length||(M=y.delimiter),typeof y.quotes!="boolean"&&typeof y.quotes!="function"&&!Array.isArray(y.quotes)||(S=y.quotes),typeof y.skipEmptyLines!="boolean"&&typeof y.skipEmptyLines!="string"||(A=y.skipEmptyLines),typeof y.newline=="string"&&(C=y.newline),typeof y.quoteChar=="string"&&(T=y.quoteChar),typeof y.header=="boolean"&&(D=y.header),Array.isArray(y.columns)){if(y.columns.length===0)throw new Error("Option columns is empty");P=y.columns}y.escapeChar!==void 0&&(k=y.escapeChar+T),y.escapeFormulae instanceof RegExp?O=y.escapeFormulae:typeof y.escapeFormulae=="boolean"&&y.escapeFormulae&&(O=/^[=+\-@\t\r].*$/)}})(),new RegExp(p(T),"g"));if(typeof v=="string"&&(v=JSON.parse(v)),Array.isArray(v)){if(!v.length||Array.isArray(v[0]))return G(null,v,A);if(typeof v[0]=="object")return G(P||Object.keys(v[0]),v,A)}else if(typeof v=="object")return typeof v.data=="string"&&(v.data=JSON.parse(v.data)),Array.isArray(v.data)&&(v.fields||(v.fields=v.meta&&v.meta.fields||P),v.fields||(v.fields=Array.isArray(v.data[0])?v.fields:typeof v.data[0]=="object"?Object.keys(v.data[0]):[]),Array.isArray(v.data[0])||typeof v.data[0]=="object"||(v.data=[v.data])),G(v.fields||[],v.data||[],A);throw new Error("Unable to serialize unrecognized input");function G(L,V,W){var j="",U=(typeof L=="string"&&(L=JSON.parse(L)),typeof V=="string"&&(V=JSON.parse(V)),Array.isArray(L)&&0<L.length),B=!Array.isArray(V[0]);if(U&&D){for(var F=0;F<L.length;F++)0<F&&(j+=M),j+=$(L[F],F);0<V.length&&(j+=C)}for(var I=0;I<V.length;I++){var N=(U?L:V[I]).length,R=!1,Y=U?Object.keys(V[I]).length===0:V[I].length===0;if(W&&!U&&(R=W==="greedy"?V[I].join("").trim()==="":V[I].length===1&&V[I][0].length===0),W==="greedy"&&U){for(var K=[],Z=0;Z<N;Z++){var X=B?L[Z]:Z;K.push(V[I][X])}R=K.join("").trim()===""}if(!R){for(var q=0;q<N;q++){0<q&&!Y&&(j+=M);var ut=U&&B?L[q]:q;j+=$(V[I][ut],q)}I<V.length-1&&(!W||0<N&&!Y)&&(j+=C)}}return j}function $(L,V){var W,j;return L==null?"":L.constructor===Date?JSON.stringify(L).slice(1,25):(j=!1,O&&typeof L=="string"&&O.test(L)&&(L="'"+L,j=!0),W=L.toString().replace(z,k),(j=j||S===!0||typeof S=="function"&&S(L,V)||Array.isArray(S)&&S[V]||((U,B)=>{for(var F=0;F<B.length;F++)if(-1<U.indexOf(B[F]))return!0;return!1})(W,a.BAD_DELIMITERS)||-1<W.indexOf(M)||W.charAt(0)===" "||W.charAt(W.length-1)===" ")?T+W+T:W)}},a.RECORD_SEP="",a.UNIT_SEP="",a.BYTE_ORDER_MARK="\uFEFF",a.BAD_DELIMITERS=["\r",`
|
||
`,'"',a.BYTE_ORDER_MARK],a.WORKERS_SUPPORTED=!n&&!!t.Worker,a.NODE_STREAM_INPUT=1,a.LocalChunkSize=10485760,a.RemoteChunkSize=5242880,a.DefaultDelimiter=",",a.Parser=m,a.ParserHandle=f,a.NetworkStreamer=c,a.FileStreamer=d,a.StringStreamer=h,a.ReadableStreamStreamer=u,t.jQuery&&((e=t.jQuery).fn.parse=function(v){var y=v.config||{},S=[];return this.each(function(C){if(!(e(this).prop("tagName").toUpperCase()==="INPUT"&&e(this).attr("type").toLowerCase()==="file"&&t.FileReader)||!this.files||this.files.length===0)return!0;for(var T=0;T<this.files.length;T++)S.push({file:this.files[T],inputElem:this,instanceConfig:e.extend({},y)})}),D(),this;function D(){if(S.length===0)w(v.complete)&&v.complete();else{var C,T,k,A,P=S[0];if(w(v.before)){var O=v.before(P.file,P.inputElem);if(typeof O=="object"){if(O.action==="abort")return C="AbortError",T=P.file,k=P.inputElem,A=O.reason,void(w(v.error)&&v.error({name:C},T,k,A));if(O.action==="skip")return void M();typeof O.config=="object"&&(P.instanceConfig=e.extend(P.instanceConfig,O.config))}else if(O==="skip")return void M()}var z=P.instanceConfig.complete;P.instanceConfig.complete=function(G){w(z)&&z(G,P.file,P.inputElem),M()},a.parse(P.file,P.instanceConfig)}}function M(){S.splice(0,1),D()}}),i&&(t.onmessage=function(v){v=v.data,a.WORKER_ID===void 0&&v&&(a.WORKER_ID=v.workerId),typeof v.input=="string"?t.postMessage({workerId:a.WORKER_ID,results:a.parse(v.input,v.config),finished:!0}):(t.File&&v.input instanceof File||v.input instanceof Object)&&(v=a.parse(v.input,v.config))&&t.postMessage({workerId:a.WORKER_ID,results:v,finished:!0})}),(c.prototype=Object.create(l.prototype)).constructor=c,(d.prototype=Object.create(l.prototype)).constructor=d,(h.prototype=Object.create(h.prototype)).constructor=h,(u.prototype=Object.create(l.prototype)).constructor=u,a})});function Ds(s){return s+.5|0}function ks(s){return ue(Ds(s*2.55),0,255)}function fe(s){return ue(Ds(s*255),0,255)}function ie(s){return ue(Ds(s/2.55)/100,0,1)}function dr(s){return ue(Ds(s*100),0,100)}function Vc(s){var t=s.length,e;return s[0]==="#"&&(t===4||t===5?e={r:255&Bt[s[1]]*17,g:255&Bt[s[2]]*17,b:255&Bt[s[3]]*17,a:t===5?Bt[s[4]]*17:255}:(t===7||t===9)&&(e={r:Bt[s[1]]<<4|Bt[s[2]],g:Bt[s[3]]<<4|Bt[s[4]],b:Bt[s[5]]<<4|Bt[s[6]],a:t===9?Bt[s[7]]<<4|Bt[s[8]]:255})),e}function Bc(s){var t=Ic(s)?Oc:Fc;return s?"#"+t(s.r)+t(s.g)+t(s.b)+Nc(s.a,t):void 0}function pr(s,t,e){let n=t*Math.min(e,1-e),i=(o,r=(o+s/30)%12)=>e-n*Math.max(Math.min(r-3,9-r,1),-1);return[i(0),i(8),i(4)]}function Hc(s,t,e){let n=(i,o=(i+s/60)%6)=>e-e*t*Math.max(Math.min(o,4-o,1),0);return[n(5),n(3),n(1)]}function $c(s,t,e){let n=pr(s,1,.5),i;for(t+e>1&&(i=1/(t+e),t*=i,e*=i),i=0;i<3;i++)n[i]*=1-t-e,n[i]+=t;return n}function Wc(s,t,e,n,i){return s===i?(t-e)/n+(t<e?6:0):t===i?(e-s)/n+2:(s-t)/n+4}function mi(s){let e=s.r/255,n=s.g/255,i=s.b/255,o=Math.max(e,n,i),r=Math.min(e,n,i),a=(o+r)/2,l,c,d;return o!==r&&(d=o-r,c=a>.5?d/(2-o-r):d/(o+r),l=Wc(e,n,i,d,o),l=l*60+.5),[l|0,c||0,a]}function bi(s,t,e,n){return(Array.isArray(t)?s(t[0],t[1],t[2]):s(t,e,n)).map(fe)}function vi(s,t,e){return bi(pr,s,t,e)}function jc(s,t,e){return bi($c,s,t,e)}function Uc(s,t,e){return bi(Hc,s,t,e)}function gr(s){return(s%360+360)%360}function Kc(s){let t=zc.exec(s),e=255,n;if(!t)return;t[5]!==n&&(e=t[6]?ks(+t[5]):fe(+t[5]));let i=gr(+t[2]),o=+t[3]/100,r=+t[4]/100;return t[1]==="hwb"?n=jc(i,o,r):t[1]==="hsv"?n=Uc(i,o,r):n=vi(i,o,r),{r:n[0],g:n[1],b:n[2],a:e}}function Yc(s,t){var e=mi(s);e[0]=gr(e[0]+t),e=vi(e),s.r=e[0],s.g=e[1],s.b=e[2]}function Gc(s){if(!s)return;let t=mi(s),e=t[0],n=dr(t[1]),i=dr(t[2]);return s.a<255?`hsla(${e}, ${n}%, ${i}%, ${ie(s.a)})`:`hsl(${e}, ${n}%, ${i}%)`}function qc(){let s={},t=Object.keys(ur),e=Object.keys(hr),n,i,o,r,a;for(n=0;n<t.length;n++){for(r=a=t[n],i=0;i<e.length;i++)o=e[i],a=a.replace(o,hr[o]);o=parseInt(ur[r],16),s[a]=[o>>16&255,o>>8&255,o&255]}return s}function Xc(s){gn||(gn=qc(),gn.transparent=[0,0,0,0]);let t=gn[s.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}function Zc(s){let t=Qc.exec(s),e=255,n,i,o;if(t){if(t[7]!==n){let r=+t[7];e=t[8]?ks(r):ue(r*255,0,255)}return n=+t[1],i=+t[3],o=+t[5],n=255&(t[2]?ks(n):ue(n,0,255)),i=255&(t[4]?ks(i):ue(i,0,255)),o=255&(t[6]?ks(o):ue(o,0,255)),{r:n,g:i,b:o,a:e}}}function Jc(s){return s&&(s.a<255?`rgba(${s.r}, ${s.g}, ${s.b}, ${ie(s.a)})`:`rgb(${s.r}, ${s.g}, ${s.b})`)}function td(s,t,e){let n=Ge(ie(s.r)),i=Ge(ie(s.g)),o=Ge(ie(s.b));return{r:fe(pi(n+e*(Ge(ie(t.r))-n))),g:fe(pi(i+e*(Ge(ie(t.g))-i))),b:fe(pi(o+e*(Ge(ie(t.b))-o))),a:s.a+e*(t.a-s.a)}}function mn(s,t,e){if(s){let n=mi(s);n[t]=Math.max(0,Math.min(n[t]+n[t]*e,t===0?360:1)),n=vi(n),s.r=n[0],s.g=n[1],s.b=n[2]}}function mr(s,t){return s&&Object.assign(t||{},s)}function fr(s){var t={r:0,g:0,b:0,a:255};return Array.isArray(s)?s.length>=3&&(t={r:s[0],g:s[1],b:s[2],a:255},s.length>3&&(t.a=fe(s[3]))):(t=mr(s,{r:0,g:0,b:0,a:1}),t.a=fe(t.a)),t}function ed(s){return s.charAt(0)==="r"?Zc(s):Kc(s)}var ue,Bt,gi,Oc,Fc,pn,Ic,Nc,zc,hr,ur,gn,Qc,pi,Ge,Ms,br=ti(()=>{ue=(s,t,e)=>Math.max(Math.min(s,e),t);Bt={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},gi=[..."0123456789ABCDEF"],Oc=s=>gi[s&15],Fc=s=>gi[(s&240)>>4]+gi[s&15],pn=s=>(s&240)>>4===(s&15),Ic=s=>pn(s.r)&&pn(s.g)&&pn(s.b)&&pn(s.a);Nc=(s,t)=>s<255?t(s):"";zc=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;hr={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"},ur={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"};Qc=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;pi=s=>s<=.0031308?s*12.92:Math.pow(s,1/2.4)*1.055-.055,Ge=s=>s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4);Ms=class s{constructor(t){if(t instanceof s)return t;let e=typeof t,n;e==="object"?n=fr(t):e==="string"&&(n=Vc(t)||Xc(t)||ed(t)),this._rgb=n,this._valid=!!n}get valid(){return this._valid}get rgb(){var t=mr(this._rgb);return t&&(t.a=ie(t.a)),t}set rgb(t){this._rgb=fr(t)}rgbString(){return this._valid?Jc(this._rgb):void 0}hexString(){return this._valid?Bc(this._rgb):void 0}hslString(){return this._valid?Gc(this._rgb):void 0}mix(t,e){if(t){let n=this.rgb,i=t.rgb,o,r=e===o?.5:e,a=2*r-1,l=n.a-i.a,c=((a*l===-1?a:(a+l)/(1+a*l))+1)/2;o=1-c,n.r=255&c*n.r+o*i.r+.5,n.g=255&c*n.g+o*i.g+.5,n.b=255&c*n.b+o*i.b+.5,n.a=r*n.a+(1-r)*i.a,this.rgb=n}return this}interpolate(t,e){return t&&(this._rgb=td(this._rgb,t._rgb,e)),this}clone(){return new s(this.rgb)}alpha(t){return this._rgb.a=fe(t),this}clearer(t){let e=this._rgb;return e.a*=1-t,this}greyscale(){let t=this._rgb,e=Ds(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=e,this}opaquer(t){let e=this._rgb;return e.a*=1+t,this}negate(){let 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 Yc(this._rgb,t),this}}});function Qt(){}function tt(s){return s==null}function ct(s){if(Array.isArray&&Array.isArray(s))return!0;let t=Object.prototype.toString.call(s);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function et(s){return s!==null&&Object.prototype.toString.call(s)==="[object Object]"}function pt(s){return(typeof s=="number"||s instanceof Number)&&isFinite(+s)}function Mt(s,t){return pt(s)?s:t}function Q(s,t){return typeof s=="undefined"?t:s}function lt(s,t,e){if(s&&typeof s.call=="function")return s.apply(e,t)}function ot(s,t,e,n){let i,o,r;if(ct(s))if(o=s.length,n)for(i=o-1;i>=0;i--)t.call(e,s[i],i);else for(i=0;i<o;i++)t.call(e,s[i],i);else if(et(s))for(r=Object.keys(s),o=r.length,i=0;i<o;i++)t.call(e,s[r[i]],r[i])}function As(s,t){let e,n,i,o;if(!s||!t||s.length!==t.length)return!1;for(e=0,n=s.length;e<n;++e)if(i=s[e],o=t[e],i.datasetIndex!==o.datasetIndex||i.index!==o.index)return!1;return!0}function xn(s){if(ct(s))return s.map(xn);if(et(s)){let t=Object.create(null),e=Object.keys(s),n=e.length,i=0;for(;i<n;++i)t[e[i]]=xn(s[e[i]]);return t}return s}function Lr(s){return["__proto__","prototype","constructor"].indexOf(s)===-1}function sd(s,t,e,n){if(!Lr(s))return;let i=t[s],o=e[s];et(i)&&et(o)?Xe(i,o,n):t[s]=xn(o)}function Xe(s,t,e){let n=ct(t)?t:[t],i=n.length;if(!et(s))return s;e=e||{};let o=e.merger||sd,r;for(let a=0;a<i;++a){if(r=n[a],!et(r))continue;let l=Object.keys(r);for(let c=0,d=l.length;c<d;++c)o(l[c],s,r,e)}return s}function Ze(s,t){return Xe(s,t,{merger:nd})}function nd(s,t,e){if(!Lr(s))return;let n=t[s],i=e[s];et(n)&&et(i)?Ze(n,i):Object.prototype.hasOwnProperty.call(t,s)||(t[s]=xn(i))}function id(s){let t=s.split("."),e=[],n="";for(let i of t)n+=i,n.endsWith("\\")?n=n.slice(0,-1)+".":(e.push(n),n="");return e}function od(s){let t=id(s);return e=>{for(let n of t){if(n==="")break;e=e&&e[n]}return e}}function ae(s,t){return(vr[t]||(vr[t]=od(t)))(s)}function wn(s){return s.charAt(0).toUpperCase()+s.slice(1)}function Ar(s){return s.type==="mouseup"||s.type==="click"||s.type==="contextmenu"}function ts(s,t,e){return Math.abs(s-t)<e}function wi(s){let t=Math.round(s);s=ts(s,t,s/1e3)?t:s;let e=Math.pow(10,Math.floor(re(s))),n=s/e;return(n<=1?1:n<=2?2:n<=5?5:10)*e}function Pr(s){let t=[],e=Math.sqrt(s),n;for(n=1;n<e;n++)s%n===0&&(t.push(n),t.push(s/n));return e===(e|0)&&t.push(e),t.sort((i,o)=>i-o).pop(),t}function ld(s){return typeof s=="symbol"||typeof s=="object"&&s!==null&&!(Symbol.toPrimitive in s||"toString"in s||"valueOf"in s)}function Ae(s){return!ld(s)&&!isNaN(parseFloat(s))&&isFinite(s)}function Rr(s,t){let e=Math.round(s);return e-t<=s&&e+t>=s}function Ei(s,t,e){let n,i,o;for(n=0,i=s.length;n<i;n++)o=s[n][e],isNaN(o)||(t.min=Math.min(t.min,o),t.max=Math.max(t.max,o))}function zt(s){return s*(nt/180)}function En(s){return s*(180/nt)}function ki(s){if(!pt(s))return;let t=1,e=0;for(;Math.round(s*t)/t!==s;)t*=10,e++;return e}function Mi(s,t){let e=t.x-s.x,n=t.y-s.y,i=Math.sqrt(e*e+n*n),o=Math.atan2(n,e);return o<-.5*nt&&(o+=dt),{angle:o,distance:i}}function Cn(s,t){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function cd(s,t){return(s-t+rd)%dt-nt}function xt(s){return(s%dt+dt)%dt}function es(s,t,e,n){let i=xt(s),o=xt(t),r=xt(e),a=xt(o-i),l=xt(r-i),c=xt(i-o),d=xt(i-r);return i===o||i===r||n&&o===r||a>l&&c<d}function vt(s,t,e){return Math.max(t,Math.min(e,s))}function Or(s){return vt(s,-32768,32767)}function Zt(s,t,e,n=1e-6){return s>=Math.min(t,e)-n&&s<=Math.max(t,e)+n}function kn(s,t,e){e=e||(r=>s[r]<t);let n=s.length-1,i=0,o;for(;n-i>1;)o=i+n>>1,e(o)?i=o:n=o;return{lo:i,hi:n}}function Ir(s,t,e){let n=0,i=s.length;for(;n<i&&s[n]<t;)n++;for(;i>n&&s[i-1]>e;)i--;return n>0||i<s.length?s.slice(n,i):s}function Nr(s,t){if(s._chartjs){s._chartjs.listeners.push(t);return}Object.defineProperty(s,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[t]}}),Vr.forEach(e=>{let n="_onData"+wn(e),i=s[e];Object.defineProperty(s,e,{configurable:!0,enumerable:!1,value(...o){let r=i.apply(this,o);return s._chartjs.listeners.forEach(a=>{typeof a[n]=="function"&&a[n](...o)}),r}})})}function Di(s,t){let e=s._chartjs;if(!e)return;let n=e.listeners,i=n.indexOf(t);i!==-1&&n.splice(i,1),!(n.length>0)&&(Vr.forEach(o=>{delete s[o]}),delete s._chartjs)}function Ti(s){let t=new Set(s);return t.size===s.length?s:Array.from(t)}function Ai(s,t){let e=[],n=!1;return function(...i){e=i,n||(n=!0,Li.call(window,()=>{n=!1,s.apply(t,e)}))}}function Br(s,t){let e;return function(...n){return t?(clearTimeout(e),e=setTimeout(s,t,n)):s.apply(this,n),t}}function Pi(s,t,e){let n=t.length,i=0,o=n;if(s._sorted){let{iScale:r,vScale:a,_parsed:l}=s,c=s.dataset&&s.dataset.options?s.dataset.options.spanGaps:null,d=r.axis,{min:h,max:u,minDefined:f,maxDefined:p}=r.getUserBounds();if(f){if(i=Math.min(qt(l,d,h).lo,e?n:qt(t,d,r.getPixelForValue(h)).lo),c){let m=l.slice(0,i+1).reverse().findIndex(g=>!tt(g[a.axis]));i-=Math.max(0,m)}i=vt(i,0,n-1)}if(p){let m=Math.max(qt(l,r.axis,u,!0).hi+1,e?0:qt(t,d,r.getPixelForValue(u),!0).hi+1);if(c){let g=l.slice(m-1).findIndex(b=>!tt(b[a.axis]));m+=Math.max(0,g)}o=vt(m,i,n)-i}else o=n-i}return{start:i,count:o}}function Ri(s){let{xScale:t,yScale:e,_scaleRanges:n}=s,i={xmin:t.min,xmax:t.max,ymin:e.min,ymax:e.max};if(!n)return s._scaleRanges=i,!0;let o=n.xmin!==t.min||n.xmax!==t.max||n.ymin!==e.min||n.ymax!==e.max;return Object.assign(n,i),o}function Oi(s){if(s&&typeof s=="object"){let t=s.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function Fi(s){return Oi(s)?s:new Ms(s)}function yi(s){return Oi(s)?s:new Ms(s).saturate(.5).darken(.1).hexString()}function ud(s){s.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),s.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),s.set("animations",{colors:{type:"color",properties:hd},numbers:{type:"number",properties:dd}}),s.describe("animations",{_fallback:"animation"}),s.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 fd(s){s.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}function pd(s,t){t=t||{};let e=s+JSON.stringify(t),n=Cr.get(e);return n||(n=new Intl.NumberFormat(s,t),Cr.set(e,n)),n}function ss(s,t,e){return pd(t,e).format(s)}function gd(s,t){let e=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(e)>=1&&s!==Math.floor(s)&&(e=s-Math.floor(s)),e}function md(s){s.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:ns.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),s.route("scale.ticks","color","","color"),s.route("scale.grid","color","","borderColor"),s.route("scale.border","color","","borderColor"),s.route("scale.title","color","","color"),s.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),s.describe("scales",{_fallback:"scale"}),s.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}function Ts(s,t){if(!t)return s;let e=t.split(".");for(let n=0,i=e.length;n<i;++n){let o=e[n];s=s[o]||(s[o]=Object.create(null))}return s}function xi(s,t,e){return typeof t=="string"?Xe(Ts(s,t),e):Xe(Ts(s,""),t)}function bd(s){return!s||tt(s.size)||tt(s.family)?null:(s.style?s.style+" ":"")+(s.weight?s.weight+" ":"")+s.size+"px "+s.family}function Ls(s,t,e,n,i){let o=t[i];return o||(o=t[i]=s.measureText(i).width,e.push(i)),o>n&&(n=o),n}function $r(s,t,e,n){n=n||{};let i=n.data=n.data||{},o=n.garbageCollect=n.garbageCollect||[];n.font!==t&&(i=n.data={},o=n.garbageCollect=[],n.font=t),s.save(),s.font=t;let r=0,a=e.length,l,c,d,h,u;for(l=0;l<a;l++)if(h=e[l],h!=null&&!ct(h))r=Ls(s,i,o,r,h);else if(ct(h))for(c=0,d=h.length;c<d;c++)u=h[c],u!=null&&!ct(u)&&(r=Ls(s,i,o,r,u));s.restore();let f=o.length/2;if(f>e.length){for(l=0;l<f;l++)delete i[o[l]];o.splice(0,f)}return r}function be(s,t,e){let n=s.currentDevicePixelRatio,i=e!==0?Math.max(e/2,.5):0;return Math.round((t-i)*n)/n+i}function Ii(s,t){!t&&!s||(t=t||s.getContext("2d"),t.save(),t.resetTransform(),t.clearRect(0,0,s.width,s.height),t.restore())}function Tn(s,t,e,n){Vi(s,t,e,n,null)}function Vi(s,t,e,n,i){let o,r,a,l,c,d,h,u,f=t.pointStyle,p=t.rotation,m=t.radius,g=(p||0)*ad;if(f&&typeof f=="object"&&(o=f.toString(),o==="[object HTMLImageElement]"||o==="[object HTMLCanvasElement]")){s.save(),s.translate(e,n),s.rotate(g),s.drawImage(f,-f.width/2,-f.height/2,f.width,f.height),s.restore();return}if(!(isNaN(m)||m<=0)){switch(s.beginPath(),f){default:i?s.ellipse(e,n,i/2,m,0,0,dt):s.arc(e,n,m,0,dt),s.closePath();break;case"triangle":d=i?i/2:m,s.moveTo(e+Math.sin(g)*d,n-Math.cos(g)*m),g+=yr,s.lineTo(e+Math.sin(g)*d,n-Math.cos(g)*m),g+=yr,s.lineTo(e+Math.sin(g)*d,n-Math.cos(g)*m),s.closePath();break;case"rectRounded":c=m*.516,l=m-c,r=Math.cos(g+De)*l,h=Math.cos(g+De)*(i?i/2-c:l),a=Math.sin(g+De)*l,u=Math.sin(g+De)*(i?i/2-c:l),s.arc(e-h,n-a,c,g-nt,g-mt),s.arc(e+u,n-r,c,g-mt,g),s.arc(e+h,n+a,c,g,g+mt),s.arc(e-u,n+r,c,g+mt,g+nt),s.closePath();break;case"rect":if(!p){l=Math.SQRT1_2*m,d=i?i/2:l,s.rect(e-d,n-l,2*d,2*l);break}g+=De;case"rectRot":h=Math.cos(g)*(i?i/2:m),r=Math.cos(g)*m,a=Math.sin(g)*m,u=Math.sin(g)*(i?i/2:m),s.moveTo(e-h,n-a),s.lineTo(e+u,n-r),s.lineTo(e+h,n+a),s.lineTo(e-u,n+r),s.closePath();break;case"crossRot":g+=De;case"cross":h=Math.cos(g)*(i?i/2:m),r=Math.cos(g)*m,a=Math.sin(g)*m,u=Math.sin(g)*(i?i/2:m),s.moveTo(e-h,n-a),s.lineTo(e+h,n+a),s.moveTo(e+u,n-r),s.lineTo(e-u,n+r);break;case"star":h=Math.cos(g)*(i?i/2:m),r=Math.cos(g)*m,a=Math.sin(g)*m,u=Math.sin(g)*(i?i/2:m),s.moveTo(e-h,n-a),s.lineTo(e+h,n+a),s.moveTo(e+u,n-r),s.lineTo(e-u,n+r),g+=De,h=Math.cos(g)*(i?i/2:m),r=Math.cos(g)*m,a=Math.sin(g)*m,u=Math.sin(g)*(i?i/2:m),s.moveTo(e-h,n-a),s.lineTo(e+h,n+a),s.moveTo(e+u,n-r),s.lineTo(e-u,n+r);break;case"line":r=i?i/2:Math.cos(g)*m,a=Math.sin(g)*m,s.moveTo(e-r,n-a),s.lineTo(e+r,n+a);break;case"dash":s.moveTo(e,n),s.lineTo(e+Math.cos(g)*(i?i/2:m),n+Math.sin(g)*m);break;case!1:s.closePath();break}s.fill(),t.borderWidth>0&&s.stroke()}}function Xt(s,t,e){return e=e||.5,!t||s&&s.x>t.left-e&&s.x<t.right+e&&s.y>t.top-e&&s.y<t.bottom+e}function Ps(s,t){s.save(),s.beginPath(),s.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),s.clip()}function Rs(s){s.restore()}function Wr(s,t,e,n,i){if(!t)return s.lineTo(e.x,e.y);if(i==="middle"){let o=(t.x+e.x)/2;s.lineTo(o,t.y),s.lineTo(o,e.y)}else i==="after"!=!!n?s.lineTo(t.x,e.y):s.lineTo(e.x,t.y);s.lineTo(e.x,e.y)}function jr(s,t,e,n){if(!t)return s.lineTo(e.x,e.y);s.bezierCurveTo(n?t.cp1x:t.cp2x,n?t.cp1y:t.cp2y,n?e.cp2x:e.cp1x,n?e.cp2y:e.cp1y,e.x,e.y)}function vd(s,t){t.translation&&s.translate(t.translation[0],t.translation[1]),tt(t.rotation)||s.rotate(t.rotation),t.color&&(s.fillStyle=t.color),t.textAlign&&(s.textAlign=t.textAlign),t.textBaseline&&(s.textBaseline=t.textBaseline)}function yd(s,t,e,n,i){if(i.strikethrough||i.underline){let o=s.measureText(n),r=t-o.actualBoundingBoxLeft,a=t+o.actualBoundingBoxRight,l=e-o.actualBoundingBoxAscent,c=e+o.actualBoundingBoxDescent,d=i.strikethrough?(l+c)/2:c;s.strokeStyle=s.fillStyle,s.beginPath(),s.lineWidth=i.decorationWidth||2,s.moveTo(r,d),s.lineTo(a,d),s.stroke()}}function xd(s,t){let e=s.fillStyle;s.fillStyle=t.color,s.fillRect(t.left,t.top,t.width,t.height),s.fillStyle=e}function ve(s,t,e,n,i,o={}){let r=ct(t)?t:[t],a=o.strokeWidth>0&&o.strokeColor!=="",l,c;for(s.save(),s.font=i.string,vd(s,o),l=0;l<r.length;++l)c=r[l],o.backdrop&&xd(s,o.backdrop),a&&(o.strokeColor&&(s.strokeStyle=o.strokeColor),tt(o.strokeWidth)||(s.lineWidth=o.strokeWidth),s.strokeText(c,e,n,o.maxWidth)),s.fillText(c,e,n,o.maxWidth),yd(s,e,n,c,o),n+=Number(i.lineHeight);s.restore()}function is(s,t){let{x:e,y:n,w:i,h:o,radius:r}=t;s.arc(e+r.topLeft,n+r.topLeft,r.topLeft,1.5*nt,nt,!0),s.lineTo(e,n+o-r.bottomLeft),s.arc(e+r.bottomLeft,n+o-r.bottomLeft,r.bottomLeft,nt,mt,!0),s.lineTo(e+i-r.bottomRight,n+o),s.arc(e+i-r.bottomRight,n+o-r.bottomRight,r.bottomRight,mt,0,!0),s.lineTo(e+i,n+r.topRight),s.arc(e+i-r.topRight,n+r.topRight,r.topRight,0,-mt,!0),s.lineTo(e+r.topLeft,n)}function Sd(s,t){let e=(""+s).match(_d);if(!e||e[1]==="normal")return t*1.2;switch(s=+e[2],e[3]){case"px":return s;case"%":s/=100;break}return t*s}function Ln(s,t){let e={},n=et(t),i=n?Object.keys(t):t,o=et(s)?n?r=>Q(s[r],s[t[r]]):r=>s[r]:()=>s;for(let r of i)e[r]=wd(o(r));return e}function Ni(s){return Ln(s,{top:"y",right:"x",bottom:"y",left:"x"})}function ye(s){return Ln(s,["topLeft","topRight","bottomLeft","bottomRight"])}function Ct(s){let t=Ni(s);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function bt(s,t){s=s||{},t=t||ht.font;let e=Q(s.size,t.size);typeof e=="string"&&(e=parseInt(e,10));let n=Q(s.style,t.style);n&&!(""+n).match(Cd)&&(console.warn('Invalid font style specified: "'+n+'"'),n=void 0);let i={family:Q(s.family,t.family),lineHeight:Sd(Q(s.lineHeight,t.lineHeight),e),size:e,style:n,weight:Q(s.weight,t.weight),string:""};return i.string=bd(i),i}function os(s,t,e,n){let i=!0,o,r,a;for(o=0,r=s.length;o<r;++o)if(a=s[o],a!==void 0&&(t!==void 0&&typeof a=="function"&&(a=a(t),i=!1),e!==void 0&&ct(a)&&(a=a[e%a.length],i=!1),a!==void 0))return n&&!i&&(n.cacheable=!1),a}function Ur(s,t,e){let{min:n,max:i}=s,o=Ci(t,(i-n)/2),r=(a,l)=>e&&a===0?0:a+l;return{min:r(n,-Math.abs(o)),max:r(i,o)}}function le(s,t){return Object.assign(Object.create(s),t)}function An(s,t=[""],e,n,i=()=>s[0]){let o=e||s;typeof n=="undefined"&&(n=Gr("_fallback",s));let r={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:s,_rootScopes:o,_fallback:n,_getTarget:i,override:a=>An([a,...s],t,o,n)};return new Proxy(r,{deleteProperty(a,l){return delete a[l],delete a._keys,delete s[0][l],!0},get(a,l){return Kr(a,l,()=>Pd(l,t,s,a))},getOwnPropertyDescriptor(a,l){return Reflect.getOwnPropertyDescriptor(a._scopes[0],l)},getPrototypeOf(){return Reflect.getPrototypeOf(s[0])},has(a,l){return wr(a).includes(l)},ownKeys(a){return wr(a)},set(a,l,c){let d=a._storage||(a._storage=i());return a[l]=d[l]=c,delete a._keys,!0}})}function Le(s,t,e,n){let i={_cacheable:!1,_proxy:s,_context:t,_subProxy:e,_stack:new Set,_descriptors:Bi(s,n),setContext:o=>Le(s,o,e,n),override:o=>Le(s.override(o),t,e,n)};return new Proxy(i,{deleteProperty(o,r){return delete o[r],delete s[r],!0},get(o,r,a){return Kr(o,r,()=>kd(o,r,a))},getOwnPropertyDescriptor(o,r){return o._descriptors.allKeys?Reflect.has(s,r)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(s,r)},getPrototypeOf(){return Reflect.getPrototypeOf(s)},has(o,r){return Reflect.has(s,r)},ownKeys(){return Reflect.ownKeys(s)},set(o,r,a){return s[r]=a,delete o[r],!0}})}function Bi(s,t={scriptable:!0,indexable:!0}){let{_scriptable:e=t.scriptable,_indexable:n=t.indexable,_allKeys:i=t.allKeys}=s;return{allKeys:i,scriptable:e,indexable:n,isScriptable:oe(e)?e:()=>e,isIndexable:oe(n)?n:()=>n}}function Kr(s,t,e){if(Object.prototype.hasOwnProperty.call(s,t)||t==="constructor")return s[t];let n=e();return s[t]=n,n}function kd(s,t,e){let{_proxy:n,_context:i,_subProxy:o,_descriptors:r}=s,a=n[t];return oe(a)&&r.isScriptable(t)&&(a=Md(t,a,s,e)),ct(a)&&a.length&&(a=Dd(t,a,s,r.isIndexable)),zi(t,a)&&(a=Le(a,i,o&&o[t],r)),a}function Md(s,t,e,n){let{_proxy:i,_context:o,_subProxy:r,_stack:a}=e;if(a.has(s))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+s);a.add(s);let l=t(o,r||n);return a.delete(s),zi(s,l)&&(l=Hi(i._scopes,i,s,l)),l}function Dd(s,t,e,n){let{_proxy:i,_context:o,_subProxy:r,_descriptors:a}=e;if(typeof o.index!="undefined"&&n(s))return t[o.index%t.length];if(et(t[0])){let l=t,c=i._scopes.filter(d=>d!==l);t=[];for(let d of l){let h=Hi(c,i,s,d);t.push(Le(h,o,r&&r[s],a))}}return t}function Yr(s,t,e){return oe(s)?s(t,e):s}function Ld(s,t,e,n,i){for(let o of t){let r=Td(e,o);if(r){s.add(r);let a=Yr(r._fallback,e,i);if(typeof a!="undefined"&&a!==e&&a!==n)return a}else if(r===!1&&typeof n!="undefined"&&e!==n)return null}return!1}function Hi(s,t,e,n){let i=t._rootScopes,o=Yr(t._fallback,e,n),r=[...s,...i],a=new Set;a.add(n);let l=Sr(a,r,e,o||e,n);return l===null||typeof o!="undefined"&&o!==e&&(l=Sr(a,r,o,l,n),l===null)?!1:An(Array.from(a),[""],i,o,()=>Ad(t,e,n))}function Sr(s,t,e,n,i){for(;e;)e=Ld(s,t,e,n,i);return e}function Ad(s,t,e){let n=s._getTarget();t in n||(n[t]={});let i=n[t];return ct(i)&&et(e)?e:i||{}}function Pd(s,t,e,n){let i;for(let o of t)if(i=Gr(Ed(o,s),e),typeof i!="undefined")return zi(s,i)?Hi(e,n,s,i):i}function Gr(s,t){for(let e of t){if(!e)continue;let n=e[s];if(typeof n!="undefined")return n}}function wr(s){let t=s._keys;return t||(t=s._keys=Rd(s._scopes)),t}function Rd(s){let t=new Set;for(let e of s)for(let n of Object.keys(e).filter(i=>!i.startsWith("_")))t.add(n);return Array.from(t)}function $i(s,t,e,n){let{iScale:i}=s,{key:o="r"}=this._parsing,r=new Array(n),a,l,c,d;for(a=0,l=n;a<l;++a)c=a+e,d=t[c],r[a]={r:i.parse(ae(d,o),c)};return r}function Fd(s,t,e,n){let i=s.skip?t:s,o=t,r=e.skip?t:e,a=Cn(o,i),l=Cn(r,o),c=a/(a+l),d=l/(a+l);c=isNaN(c)?0:c,d=isNaN(d)?0:d;let h=n*c,u=n*d;return{previous:{x:o.x-h*(r.x-i.x),y:o.y-h*(r.y-i.y)},next:{x:o.x+u*(r.x-i.x),y:o.y+u*(r.y-i.y)}}}function Id(s,t,e){let n=s.length,i,o,r,a,l,c=Qe(s,0);for(let d=0;d<n-1;++d)if(l=c,c=Qe(s,d+1),!(!l||!c)){if(ts(t[d],0,Od)){e[d]=e[d+1]=0;continue}i=e[d]/t[d],o=e[d+1]/t[d],a=Math.pow(i,2)+Math.pow(o,2),!(a<=9)&&(r=3/Math.sqrt(a),e[d]=i*r*t[d],e[d+1]=o*r*t[d])}}function Vd(s,t,e="x"){let n=qr(e),i=s.length,o,r,a,l=Qe(s,0);for(let c=0;c<i;++c){if(r=a,a=l,l=Qe(s,c+1),!a)continue;let d=a[e],h=a[n];r&&(o=(d-r[e])/3,a[`cp1${e}`]=d-o,a[`cp1${n}`]=h-o*t[c]),l&&(o=(l[e]-d)/3,a[`cp2${e}`]=d+o,a[`cp2${n}`]=h+o*t[c])}}function Nd(s,t="x"){let e=qr(t),n=s.length,i=Array(n).fill(0),o=Array(n),r,a,l,c=Qe(s,0);for(r=0;r<n;++r)if(a=l,l=c,c=Qe(s,r+1),!!l){if(c){let d=c[t]-l[t];i[r]=d!==0?(c[e]-l[e])/d:0}o[r]=a?c?Wt(i[r-1])!==Wt(i[r])?0:(i[r-1]+i[r])/2:i[r-1]:i[r]}Id(s,i,o),Vd(s,o,t)}function vn(s,t,e){return Math.max(Math.min(s,e),t)}function Bd(s,t){let e,n,i,o,r,a=Xt(s[0],t);for(e=0,n=s.length;e<n;++e)r=o,o=a,a=e<n-1&&Xt(s[e+1],t),o&&(i=s[e],r&&(i.cp1x=vn(i.cp1x,t.left,t.right),i.cp1y=vn(i.cp1y,t.top,t.bottom)),a&&(i.cp2x=vn(i.cp2x,t.left,t.right),i.cp2y=vn(i.cp2y,t.top,t.bottom)))}function Xr(s,t,e,n,i){let o,r,a,l;if(t.spanGaps&&(s=s.filter(c=>!c.skip)),t.cubicInterpolationMode==="monotone")Nd(s,i);else{let c=n?s[s.length-1]:s[0];for(o=0,r=s.length;o<r;++o)a=s[o],l=Fd(c,a,s[Math.min(o+1,r-(n?0:1))%r],t.tension),a.cp1x=l.previous.x,a.cp1y=l.previous.y,a.cp2x=l.next.x,a.cp2y=l.next.y,c=a}t.capBezierPoints&&Bd(s,e)}function Pn(){return typeof window!="undefined"&&typeof document!="undefined"}function Rn(s){let t=s.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function Sn(s,t,e){let n;return typeof s=="string"?(n=parseInt(s,10),s.indexOf("%")!==-1&&(n=n/100*t.parentNode[e])):n=s,n}function zd(s,t){return On(s).getPropertyValue(t)}function Te(s,t,e){let n={};e=e?"-"+e:"";for(let i=0;i<4;i++){let o=Hd[i];n[o]=parseFloat(s[t+"-"+o+e])||0}return n.width=n.left+n.right,n.height=n.top+n.bottom,n}function Wd(s,t){let e=s.touches,n=e&&e.length?e[0]:s,{offsetX:i,offsetY:o}=n,r=!1,a,l;if($d(i,o,s.target))a=i,l=o;else{let c=t.getBoundingClientRect();a=n.clientX-c.left,l=n.clientY-c.top,r=!0}return{x:a,y:l,box:r}}function xe(s,t){if("native"in s)return s;let{canvas:e,currentDevicePixelRatio:n}=t,i=On(e),o=i.boxSizing==="border-box",r=Te(i,"padding"),a=Te(i,"border","width"),{x:l,y:c,box:d}=Wd(s,e),h=r.left+(d&&a.left),u=r.top+(d&&a.top),{width:f,height:p}=t;return o&&(f-=r.width+a.width,p-=r.height+a.height),{x:Math.round((l-h)/f*e.width/n),y:Math.round((c-u)/p*e.height/n)}}function jd(s,t,e){let n,i;if(t===void 0||e===void 0){let o=s&&Rn(s);if(!o)t=s.clientWidth,e=s.clientHeight;else{let r=o.getBoundingClientRect(),a=On(o),l=Te(a,"border","width"),c=Te(a,"padding");t=r.width-c.width-l.width,e=r.height-c.height-l.height,n=Sn(a.maxWidth,o,"clientWidth"),i=Sn(a.maxHeight,o,"clientHeight")}}return{width:t,height:e,maxWidth:n||_n,maxHeight:i||_n}}function Qr(s,t,e,n){let i=On(s),o=Te(i,"margin"),r=Sn(i.maxWidth,s,"clientWidth")||_n,a=Sn(i.maxHeight,s,"clientHeight")||_n,l=jd(s,t,e),{width:c,height:d}=l;if(i.boxSizing==="content-box"){let u=Te(i,"border","width"),f=Te(i,"padding");c-=f.width+u.width,d-=f.height+u.height}return c=Math.max(0,c-o.width),d=Math.max(0,n?c/n:d-o.height),c=ge(Math.min(c,r,l.maxWidth)),d=ge(Math.min(d,a,l.maxHeight)),c&&!d&&(d=ge(c/2)),(t!==void 0||e!==void 0)&&n&&l.height&&d>l.height&&(d=l.height,c=ge(Math.floor(d*n))),{width:c,height:d}}function Wi(s,t,e){let n=t||1,i=ge(s.height*n),o=ge(s.width*n);s.height=ge(s.height),s.width=ge(s.width);let r=s.canvas;return r.style&&(e||!r.style.height&&!r.style.width)&&(r.style.height=`${s.height}px`,r.style.width=`${s.width}px`),s.currentDevicePixelRatio!==n||r.height!==i||r.width!==o?(s.currentDevicePixelRatio=n,r.height=i,r.width=o,s.ctx.setTransform(n,0,0,n,0,0),!0):!1}function ji(s,t){let e=zd(s,t),n=e&&e.match(/^(\d+)(\.\d+)?px$/);return n?+n[1]:void 0}function pe(s,t,e,n){return{x:s.x+e*(t.x-s.x),y:s.y+e*(t.y-s.y)}}function Jr(s,t,e,n){return{x:s.x+e*(t.x-s.x),y:n==="middle"?e<.5?s.y:t.y:n==="after"?e<1?s.y:t.y:e>0?t.y:s.y}}function ta(s,t,e,n){let i={x:s.cp2x,y:s.cp2y},o={x:t.cp1x,y:t.cp1y},r=pe(s,i,e),a=pe(i,o,e),l=pe(o,t,e),c=pe(r,a,e),d=pe(a,l,e);return pe(c,d,e)}function Pe(s,t,e){return s?Ud(t,e):Kd()}function Ui(s,t){let e,n;(t==="ltr"||t==="rtl")&&(e=s.canvas.style,n=[e.getPropertyValue("direction"),e.getPropertyPriority("direction")],e.setProperty("direction",t,"important"),s.prevTextDirection=n)}function Ki(s,t){t!==void 0&&(delete s.prevTextDirection,s.canvas.style.setProperty("direction",t[0],t[1]))}function ea(s){return s==="angle"?{between:es,compare:cd,normalize:xt}:{between:Zt,compare:(t,e)=>t-e,normalize:t=>t}}function Er({start:s,end:t,count:e,loop:n,style:i}){return{start:s%e,end:t%e,loop:n&&(t-s+1)%e===0,style:i}}function Yd(s,t,e){let{property:n,start:i,end:o}=e,{between:r,normalize:a}=ea(n),l=t.length,{start:c,end:d,loop:h}=s,u,f;if(h){for(c+=l,d+=l,u=0,f=l;u<f&&r(a(t[c%l][n]),i,o);++u)c--,d--;c%=l,d%=l}return d<c&&(d+=l),{start:c,end:d,loop:h,style:s.style}}function Yi(s,t,e){if(!e)return[s];let{property:n,start:i,end:o}=e,r=t.length,{compare:a,between:l,normalize:c}=ea(n),{start:d,end:h,loop:u,style:f}=Yd(s,t,e),p=[],m=!1,g=null,b,x,_,E=()=>l(i,_,b)&&a(i,_)!==0,w=()=>a(o,b)===0||l(o,_,b),v=()=>m||E(),y=()=>!m||w();for(let S=d,D=d;S<=h;++S)x=t[S%r],!x.skip&&(b=c(x[n]),b!==_&&(m=l(b,i,o),g===null&&v()&&(g=a(b,i)===0?S:D),g!==null&&y()&&(p.push(Er({start:g,end:S,loop:u,count:r,style:f})),g=null),D=S,_=b));return g!==null&&p.push(Er({start:g,end:h,loop:u,count:r,style:f})),p}function Gi(s,t){let e=[],n=s.segments;for(let i=0;i<n.length;i++){let o=Yi(n[i],s.points,t);o.length&&e.push(...o)}return e}function Gd(s,t,e,n){let i=0,o=t-1;if(e&&!n)for(;i<t&&!s[i].skip;)i++;for(;i<t&&s[i].skip;)i++;for(i%=t,e&&(o+=i);o>i&&s[o%t].skip;)o--;return o%=t,{start:i,end:o}}function qd(s,t,e,n){let i=s.length,o=[],r=t,a=s[t],l;for(l=t+1;l<=e;++l){let c=s[l%i];c.skip||c.stop?a.skip||(n=!1,o.push({start:t%i,end:(l-1)%i,loop:n}),t=r=c.stop?l:null):(r=l,a.skip&&(t=l)),a=c}return r!==null&&o.push({start:t%i,end:r%i,loop:n}),o}function sa(s,t){let e=s.points,n=s.options.spanGaps,i=e.length;if(!i)return[];let o=!!s._loop,{start:r,end:a}=Gd(e,i,o,n);if(n===!0)return kr(s,[{start:r,end:a,loop:o}],e,t);let l=a<r?a+i:a,c=!!s._fullLoop&&r===0&&a===i-1;return kr(s,qd(e,r,l,c),e,t)}function kr(s,t,e,n){return!n||!n.setContext||!e?t:Xd(s,t,e,n)}function Xd(s,t,e,n){let i=s._chart.getContext(),o=Mr(s.options),{_datasetIndex:r,options:{spanGaps:a}}=s,l=e.length,c=[],d=o,h=t[0].start,u=h;function f(p,m,g,b){let x=a?-1:1;if(p!==m){for(p+=l;e[p%l].skip;)p-=x;for(;e[m%l].skip;)m+=x;p%l!==m%l&&(c.push({start:p%l,end:m%l,loop:g,style:b}),d=b,h=m%l)}}for(let p of t){h=a?h:p.start;let m=e[h%l],g;for(u=h+1;u<=p.end;u++){let b=e[u%l];g=Mr(n.setContext(le(i,{type:"segment",p0:m,p1:b,p0DataIndex:(u-1)%l,p1DataIndex:u%l,datasetIndex:r}))),Qd(g,d)&&f(h,u-1,p.loop,d),m=b,d=g}h<u-1&&f(h,u-1,p.loop,d)}return c}function Mr(s){return{backgroundColor:s.backgroundColor,borderCapStyle:s.borderCapStyle,borderDash:s.borderDash,borderDashOffset:s.borderDashOffset,borderJoinStyle:s.borderJoinStyle,borderWidth:s.borderWidth,borderColor:s.borderColor}}function Qd(s,t){if(!t)return!1;let e=[],n=function(i,o){return Oi(o)?(e.includes(o)||e.push(o),e.indexOf(o)):o};return JSON.stringify(s,n)!==JSON.stringify(t,n)}function yn(s,t,e){return s.options.clip?s[e]:t[e]}function Zd(s,t){let{xScale:e,yScale:n}=s;return e&&n?{left:yn(e,t,"left"),right:yn(e,t,"right"),top:yn(n,t,"top"),bottom:yn(n,t,"bottom")}:t}function qi(s,t){let e=t._clip;if(e.disabled)return!1;let n=Zd(t,s.chartArea);return{left:e.left===!1?0:n.left-(e.left===!0?0:e.left),right:e.right===!1?s.width:n.right+(e.right===!0?0:e.right),top:e.top===!1?0:n.top-(e.top===!0?0:e.top),bottom:e.bottom===!1?s.height:n.bottom+(e.bottom===!0?0:e.bottom)}}var Dr,Tr,Ci,vr,Je,oe,Si,nt,dt,rd,_n,ad,mt,De,yr,re,Wt,qt,Fr,Vr,Li,Mn,_t,zr,bn,xr,_r,qe,dd,hd,Cr,Hr,ns,me,Dn,_i,ht,_d,Cd,wd,Ed,zi,Td,Od,Qe,qr,On,Hd,$d,ge,Zr,Ud,Kd,na=ti(()=>{br();Dr=(()=>{let s=0;return()=>s++})();Tr=(s,t)=>typeof s=="string"&&s.endsWith("%")?parseFloat(s)/100:+s/t,Ci=(s,t)=>typeof s=="string"&&s.endsWith("%")?parseFloat(s)/100*t:+s;vr={"":s=>s,x:s=>s.x,y:s=>s.y};Je=s=>typeof s!="undefined",oe=s=>typeof s=="function",Si=(s,t)=>{if(s.size!==t.size)return!1;for(let e of s)if(!t.has(e))return!1;return!0};nt=Math.PI,dt=2*nt,rd=dt+nt,_n=Number.POSITIVE_INFINITY,ad=nt/180,mt=nt/2,De=nt/4,yr=nt*2/3,re=Math.log10,Wt=Math.sign;qt=(s,t,e,n)=>kn(s,e,n?i=>{let o=s[i][t];return o<e||o===e&&s[i+1][t]===e}:i=>s[i][t]<e),Fr=(s,t,e)=>kn(s,e,n=>s[n][t]>=e);Vr=["push","pop","shift","splice","unshift"];Li=function(){return typeof window=="undefined"?function(s){return s()}:window.requestAnimationFrame}();Mn=s=>s==="start"?"left":s==="end"?"right":"center",_t=(s,t,e)=>s==="start"?t:s==="end"?e:(t+e)/2,zr=(s,t,e,n)=>s===(n?"left":"right")?e:s==="center"?(t+e)/2:t;bn=s=>s===0||s===1,xr=(s,t,e)=>-(Math.pow(2,10*(s-=1))*Math.sin((s-t)*dt/e)),_r=(s,t,e)=>Math.pow(2,-10*s)*Math.sin((s-t)*dt/e)+1,qe={linear:s=>s,easeInQuad:s=>s*s,easeOutQuad:s=>-s*(s-2),easeInOutQuad:s=>(s/=.5)<1?.5*s*s:-.5*(--s*(s-2)-1),easeInCubic:s=>s*s*s,easeOutCubic:s=>(s-=1)*s*s+1,easeInOutCubic:s=>(s/=.5)<1?.5*s*s*s:.5*((s-=2)*s*s+2),easeInQuart:s=>s*s*s*s,easeOutQuart:s=>-((s-=1)*s*s*s-1),easeInOutQuart:s=>(s/=.5)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2),easeInQuint:s=>s*s*s*s*s,easeOutQuint:s=>(s-=1)*s*s*s*s+1,easeInOutQuint:s=>(s/=.5)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2),easeInSine:s=>-Math.cos(s*mt)+1,easeOutSine:s=>Math.sin(s*mt),easeInOutSine:s=>-.5*(Math.cos(nt*s)-1),easeInExpo:s=>s===0?0:Math.pow(2,10*(s-1)),easeOutExpo:s=>s===1?1:-Math.pow(2,-10*s)+1,easeInOutExpo:s=>bn(s)?s:s<.5?.5*Math.pow(2,10*(s*2-1)):.5*(-Math.pow(2,-10*(s*2-1))+2),easeInCirc:s=>s>=1?s:-(Math.sqrt(1-s*s)-1),easeOutCirc:s=>Math.sqrt(1-(s-=1)*s),easeInOutCirc:s=>(s/=.5)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1),easeInElastic:s=>bn(s)?s:xr(s,.075,.3),easeOutElastic:s=>bn(s)?s:_r(s,.075,.3),easeInOutElastic(s){return bn(s)?s:s<.5?.5*xr(s*2,.1125,.45):.5+.5*_r(s*2-1,.1125,.45)},easeInBack(s){return s*s*((1.70158+1)*s-1.70158)},easeOutBack(s){return(s-=1)*s*((1.70158+1)*s+1.70158)+1},easeInOutBack(s){let t=1.70158;return(s/=.5)<1?.5*(s*s*(((t*=1.525)+1)*s-t)):.5*((s-=2)*s*(((t*=1.525)+1)*s+t)+2)},easeInBounce:s=>1-qe.easeOutBounce(1-s),easeOutBounce(s){return s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375},easeInOutBounce:s=>s<.5?qe.easeInBounce(s*2)*.5:qe.easeOutBounce(s*2-1)*.5+.5};dd=["x","y","borderWidth","radius","tension"],hd=["color","borderColor","backgroundColor"];Cr=new Map;Hr={values(s){return ct(s)?s:""+s},numeric(s,t,e){if(s===0)return"0";let n=this.chart.options.locale,i,o=s;if(e.length>1){let c=Math.max(Math.abs(e[0].value),Math.abs(e[e.length-1].value));(c<1e-4||c>1e15)&&(i="scientific"),o=gd(s,e)}let r=re(Math.abs(o)),a=isNaN(r)?1:Math.max(Math.min(-1*Math.floor(r),20),0),l={notation:i,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),ss(s,n,l)},logarithmic(s,t,e){if(s===0)return"0";let n=e[t].significand||s/Math.pow(10,Math.floor(re(s)));return[1,2,3,5,10,15].includes(n)||t>.8*e.length?Hr.numeric.call(this,s,t,e):""}};ns={formatters:Hr};me=Object.create(null),Dn=Object.create(null);_i=class{constructor(t,e){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=n=>n.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=(n,i)=>yi(i.backgroundColor),this.hoverBorderColor=(n,i)=>yi(i.borderColor),this.hoverColor=(n,i)=>yi(i.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 xi(this,t,e)}get(t){return Ts(this,t)}describe(t,e){return xi(Dn,t,e)}override(t,e){return xi(me,t,e)}route(t,e,n,i){let o=Ts(this,t),r=Ts(this,n),a="_"+e;Object.defineProperties(o,{[a]:{value:o[e],writable:!0},[e]:{enumerable:!0,get(){let l=this[a],c=r[i];return et(l)?Object.assign({},c,l):Q(l,c)},set(l){this[a]=l}}})}apply(t){t.forEach(e=>e(this))}},ht=new _i({_scriptable:s=>!s.startsWith("on"),_indexable:s=>s!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[ud,fd,md]);_d=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,Cd=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;wd=s=>+s||0;Ed=(s,t)=>s?s+wn(t):t,zi=(s,t)=>et(t)&&s!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);Td=(s,t)=>s===!0?t:typeof s=="string"?ae(t,s):void 0;Od=Number.EPSILON||1e-14,Qe=(s,t)=>t<s.length&&!s[t].skip&&s[t],qr=s=>s==="x"?"y":"x";On=s=>s.ownerDocument.defaultView.getComputedStyle(s,null);Hd=["top","right","bottom","left"];$d=(s,t,e)=>(s>0||t>0)&&(!e||!e.shadowRoot);ge=s=>Math.round(s*10)/10;Zr=function(){let s=!1;try{let t={get passive(){return s=!0,!1}};Pn()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch(t){}return s}();Ud=function(s,t){return{x(e){return s+s+t-e},setWidth(e){t=e},textAlign(e){return e==="center"?e:e==="right"?"left":"right"},xPlus(e,n){return e-n},leftForLtr(e,n){return e-n}}},Kd=function(){return{x(s){return s},setWidth(s){},textAlign(s){return s},xPlus(s,t){return s+t},leftForLtr(s,t){return s}}}});var Vl={};So(Vl,{Animation:()=>Wn,Animations:()=>$s,ArcElement:()=>_e,BarController:()=>Fe,BarElement:()=>He,BasePlatform:()=>Ws,BasicPlatform:()=>jn,BubbleController:()=>Ie,CategoryScale:()=>cs,Chart:()=>ee,Colors:()=>Sl,DatasetController:()=>Tt,Decimation:()=>El,DomPlatform:()=>Kn,DoughnutController:()=>se,Element:()=>At,Filler:()=>Ml,Interaction:()=>al,Legend:()=>Tl,LineController:()=>Ve,LineElement:()=>Ut,LinearScale:()=>ds,LogarithmicScale:()=>hs,PieController:()=>as,PointElement:()=>ze,PolarAreaController:()=>Se,RadarController:()=>Ne,RadialLinearScale:()=>Ce,Scale:()=>ke,ScatterController:()=>Be,SubTitle:()=>Al,Ticks:()=>ns,TimeScale:()=>Ee,TimeSeriesScale:()=>us,Title:()=>Ll,Tooltip:()=>Rl,_adapters:()=>rl,_detectPlatform:()=>ul,animator:()=>te,controllers:()=>ol,defaults:()=>ht,elements:()=>xl,layouts:()=>St,plugins:()=>Ol,registerables:()=>Jf,registry:()=>jt,scales:()=>Il});function th(s,t){let e=[],n=Object.keys(t);for(let i=0;i<n.length;i++){let o=s[n[i]];o&&o.active()&&e.push(o.wait())}return Promise.all(e)}function eh(s,t){if(!t)return;let e=s.options;if(!e){s.options=t;return}return e.$shared&&(s.options=e=Object.assign({},e,{$shared:!1,$animations:{}})),e}function oa(s,t){let e=s&&s.options||{},n=e.reverse,i=e.min===void 0?t:0,o=e.max===void 0?t:0;return{start:n?o:i,end:n?i:o}}function sh(s,t,e){if(e===!1)return!1;let n=oa(s,e),i=oa(t,e);return{top:i.end,right:n.end,bottom:i.start,left:n.start}}function nh(s){let t,e,n,i;return et(s)?(t=s.top,e=s.right,n=s.bottom,i=s.left):t=e=n=i=s,{top:t,right:e,bottom:n,left:i,disabled:s===!1}}function nl(s,t){let e=[],n=s._getSortedDatasetMetas(t),i,o;for(i=0,o=n.length;i<o;++i)e.push(n[i].index);return e}function ra(s,t,e,n={}){let i=s.keys,o=n.mode==="single",r,a,l,c;if(t===null)return;let d=!1;for(r=0,a=i.length;r<a;++r){if(l=+i[r],l===e){if(d=!0,n.all)continue;break}c=s.values[l],pt(c)&&(o||t===0||Wt(t)===Wt(c))&&(t+=c)}return!d&&!n.all?0:t}function ih(s,t){let{iScale:e,vScale:n}=t,i=e.axis==="x"?"x":"y",o=n.axis==="x"?"x":"y",r=Object.keys(s),a=new Array(r.length),l,c,d;for(l=0,c=r.length;l<c;++l)d=r[l],a[l]={[i]:d,[o]:s[d]};return a}function Xi(s,t){let e=s&&s.options.stacked;return e||e===void 0&&t.stack!==void 0}function oh(s,t,e){return`${s.id}.${t.id}.${e.stack||e.type}`}function rh(s){let{min:t,max:e,minDefined:n,maxDefined:i}=s.getUserBounds();return{min:n?t:Number.NEGATIVE_INFINITY,max:i?e:Number.POSITIVE_INFINITY}}function ah(s,t,e){let n=s[t]||(s[t]={});return n[e]||(n[e]={})}function aa(s,t,e,n){for(let i of t.getMatchingVisibleMetas(n).reverse()){let o=s[i.index];if(e&&o>0||!e&&o<0)return i.index}return null}function la(s,t){let{chart:e,_cachedMeta:n}=s,i=e._stacks||(e._stacks={}),{iScale:o,vScale:r,index:a}=n,l=o.axis,c=r.axis,d=oh(o,r,n),h=t.length,u;for(let f=0;f<h;++f){let p=t[f],{[l]:m,[c]:g}=p,b=p._stacks||(p._stacks={});u=b[c]=ah(i,d,m),u[a]=g,u._top=aa(u,r,!0,n.type),u._bottom=aa(u,r,!1,n.type);let x=u._visualValues||(u._visualValues={});x[a]=g}}function Qi(s,t){let e=s.scales;return Object.keys(e).filter(n=>e[n].axis===t).shift()}function lh(s,t){return le(s,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function ch(s,t,e){return le(s,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:e,index:t,mode:"default",type:"data"})}function Os(s,t){let e=s.controller.index,n=s.vScale&&s.vScale.axis;if(n){t=t||s._parsed;for(let i of t){let o=i._stacks;if(!o||o[n]===void 0||o[n][e]===void 0)return;delete o[n][e],o[n]._visualValues!==void 0&&o[n]._visualValues[e]!==void 0&&delete o[n]._visualValues[e]}}}function hh(s,t){if(!s._cache.$bar){let e=s.getMatchingVisibleMetas(t),n=[];for(let i=0,o=e.length;i<o;i++)n=n.concat(e[i].controller.getAllParsedValues(s));s._cache.$bar=Ti(n.sort((i,o)=>i-o))}return s._cache.$bar}function uh(s){let t=s.iScale,e=hh(t,s.type),n=t._length,i,o,r,a,l=()=>{r===32767||r===-32768||(Je(a)&&(n=Math.min(n,Math.abs(r-a)||n)),a=r)};for(i=0,o=e.length;i<o;++i)r=t.getPixelForValue(e[i]),l();for(a=void 0,i=0,o=t.ticks.length;i<o;++i)r=t.getPixelForTick(i),l();return n}function fh(s,t,e,n){let i=e.barThickness,o,r;return tt(i)?(o=t.min*e.categoryPercentage,r=e.barPercentage):(o=i*n,r=1),{chunk:o/n,ratio:r,start:t.pixels[s]-o/2}}function ph(s,t,e,n){let i=t.pixels,o=i[s],r=s>0?i[s-1]:null,a=s<i.length-1?i[s+1]:null,l=e.categoryPercentage;r===null&&(r=o-(a===null?t.end-t.start:a-o)),a===null&&(a=o+o-r);let c=o-(o-Math.min(r,a))/2*l;return{chunk:Math.abs(a-r)/2*l/n,ratio:e.barPercentage,start:c}}function gh(s,t,e,n){let i=e.parse(s[0],n),o=e.parse(s[1],n),r=Math.min(i,o),a=Math.max(i,o),l=r,c=a;Math.abs(r)>Math.abs(a)&&(l=a,c=r),t[e.axis]=c,t._custom={barStart:l,barEnd:c,start:i,end:o,min:r,max:a}}function il(s,t,e,n){return ct(s)?gh(s,t,e,n):t[e.axis]=e.parse(s,n),t}function da(s,t,e,n){let i=s.iScale,o=s.vScale,r=i.getLabels(),a=i===o,l=[],c,d,h,u;for(c=e,d=e+n;c<d;++c)u=t[c],h={},h[i.axis]=a||i.parse(r[c],c),l.push(il(u,h,o,c));return l}function Ji(s){return s&&s.barStart!==void 0&&s.barEnd!==void 0}function mh(s,t,e){return s!==0?Wt(s):(t.isHorizontal()?1:-1)*(t.min>=e?1:-1)}function bh(s){let t,e,n,i,o;return s.horizontal?(t=s.base>s.x,e="left",n="right"):(t=s.base<s.y,e="bottom",n="top"),t?(i="end",o="start"):(i="start",o="end"),{start:e,end:n,reverse:t,top:i,bottom:o}}function vh(s,t,e,n){let i=t.borderSkipped,o={};if(!i){s.borderSkipped=o;return}if(i===!0){s.borderSkipped={top:!0,right:!0,bottom:!0,left:!0};return}let{start:r,end:a,reverse:l,top:c,bottom:d}=bh(s);i==="middle"&&e&&(s.enableBorderRadius=!0,(e._top||0)===n?i=c:(e._bottom||0)===n?i=d:(o[ha(d,r,a,l)]=!0,i=c)),o[ha(i,r,a,l)]=!0,s.borderSkipped=o}function ha(s,t,e,n){return n?(s=yh(s,t,e),s=ua(s,e,t)):s=ua(s,t,e),s}function yh(s,t,e){return s===t?e:s===e?t:s}function ua(s,t,e){return s==="start"?t:s==="end"?e:s}function xh(s,{inflateAmount:t},e){s.inflateAmount=t==="auto"?e===1?.33:0:t}function _h(s,t,e){let n=1,i=1,o=0,r=0;if(t<dt){let a=s,l=a+t,c=Math.cos(a),d=Math.sin(a),h=Math.cos(l),u=Math.sin(l),f=(_,E,w)=>es(_,a,l,!0)?1:Math.max(E,E*e,w,w*e),p=(_,E,w)=>es(_,a,l,!0)?-1:Math.min(E,E*e,w,w*e),m=f(0,c,h),g=f(mt,d,u),b=p(nt,c,h),x=p(nt+mt,d,u);n=(m-b)/2,i=(g-x)/2,o=-(m+b)/2,r=-(g+x)/2}return{ratioX:n,ratioY:i,offsetX:o,offsetY:r}}function Re(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}function Ch(s,t,e,n){let{controller:i,data:o,_sorted:r}=s,a=i._cachedMeta.iScale,l=s.dataset&&s.dataset.options?s.dataset.options.spanGaps:null;if(a&&t===a.axis&&t!=="r"&&r&&o.length){let c=a._reversePixels?Fr:qt;if(n){if(i._sharedOptions){let d=o[0],h=typeof d.getRange=="function"&&d.getRange(t);if(h){let u=c(o,t,e-h),f=c(o,t,e+h);return{lo:u.lo,hi:f.hi}}}}else{let d=c(o,t,e);if(l){let{vScale:h}=i._cachedMeta,{_parsed:u}=s,f=u.slice(0,d.lo+1).reverse().findIndex(m=>!tt(m[h.axis]));d.lo-=Math.max(0,f);let p=u.slice(d.hi).findIndex(m=>!tt(m[h.axis]));d.hi+=Math.max(0,p)}return d}}return{lo:0,hi:o.length-1}}function Ys(s,t,e,n,i){let o=s.getSortedVisibleDatasetMetas(),r=e[t];for(let a=0,l=o.length;a<l;++a){let{index:c,data:d}=o[a],{lo:h,hi:u}=Ch(o[a],t,r,i);for(let f=h;f<=u;++f){let p=d[f];p.skip||n(p,c,f)}}}function Sh(s){let t=s.indexOf("x")!==-1,e=s.indexOf("y")!==-1;return function(n,i){let o=t?Math.abs(n.x-i.x):0,r=e?Math.abs(n.y-i.y):0;return Math.sqrt(Math.pow(o,2)+Math.pow(r,2))}}function to(s,t,e,n,i){let o=[];return!i&&!s.isPointInArea(t)||Ys(s,e,t,function(a,l,c){!i&&!Xt(a,s.chartArea,0)||a.inRange(t.x,t.y,n)&&o.push({element:a,datasetIndex:l,index:c})},!0),o}function wh(s,t,e,n){let i=[];function o(r,a,l){let{startAngle:c,endAngle:d}=r.getProps(["startAngle","endAngle"],n),{angle:h}=Mi(r,{x:t.x,y:t.y});es(h,c,d)&&i.push({element:r,datasetIndex:a,index:l})}return Ys(s,e,t,o),i}function Eh(s,t,e,n,i,o){let r=[],a=Sh(e),l=Number.POSITIVE_INFINITY;function c(d,h,u){let f=d.inRange(t.x,t.y,i);if(n&&!f)return;let p=d.getCenterPoint(i);if(!(!!o||s.isPointInArea(p))&&!f)return;let g=a(t,p);g<l?(r=[{element:d,datasetIndex:h,index:u}],l=g):g===l&&r.push({element:d,datasetIndex:h,index:u})}return Ys(s,e,t,c),r}function eo(s,t,e,n,i,o){return!o&&!s.isPointInArea(t)?[]:e==="r"&&!n?wh(s,t,e,i):Eh(s,t,e,n,i,o)}function fa(s,t,e,n,i){let o=[],r=e==="x"?"inXRange":"inYRange",a=!1;return Ys(s,e,t,(l,c,d)=>{l[r]&&l[r](t[e],i)&&(o.push({element:l,datasetIndex:c,index:d}),a=a||l.inRange(t.x,t.y,i))}),n&&!a?[]:o}function Fs(s,t){return s.filter(e=>e.pos===t)}function pa(s,t){return s.filter(e=>ll.indexOf(e.pos)===-1&&e.box.axis===t)}function Is(s,t){return s.sort((e,n)=>{let i=t?n:e,o=t?e:n;return i.weight===o.weight?i.index-o.index:i.weight-o.weight})}function kh(s){let t=[],e,n,i,o,r,a;for(e=0,n=(s||[]).length;e<n;++e)i=s[e],{position:o,options:{stack:r,stackWeight:a=1}}=i,t.push({index:e,box:i,pos:o,horizontal:i.isHorizontal(),weight:i.weight,stack:r&&o+r,stackWeight:a});return t}function Mh(s){let t={};for(let e of s){let{stack:n,pos:i,stackWeight:o}=e;if(!n||!ll.includes(i))continue;let r=t[n]||(t[n]={count:0,placed:0,weight:0,size:0});r.count++,r.weight+=o}return t}function Dh(s,t){let e=Mh(s),{vBoxMaxWidth:n,hBoxMaxHeight:i}=t,o,r,a;for(o=0,r=s.length;o<r;++o){a=s[o];let{fullSize:l}=a.box,c=e[a.stack],d=c&&a.stackWeight/c.weight;a.horizontal?(a.width=d?d*n:l&&t.availableWidth,a.height=i):(a.width=n,a.height=d?d*i:l&&t.availableHeight)}return e}function Th(s){let t=kh(s),e=Is(t.filter(c=>c.box.fullSize),!0),n=Is(Fs(t,"left"),!0),i=Is(Fs(t,"right")),o=Is(Fs(t,"top"),!0),r=Is(Fs(t,"bottom")),a=pa(t,"x"),l=pa(t,"y");return{fullSize:e,leftAndTop:n.concat(o),rightAndBottom:i.concat(l).concat(r).concat(a),chartArea:Fs(t,"chartArea"),vertical:n.concat(i).concat(l),horizontal:o.concat(r).concat(a)}}function ga(s,t,e,n){return Math.max(s[e],t[e])+Math.max(s[n],t[n])}function cl(s,t){s.top=Math.max(s.top,t.top),s.left=Math.max(s.left,t.left),s.bottom=Math.max(s.bottom,t.bottom),s.right=Math.max(s.right,t.right)}function Lh(s,t,e,n){let{pos:i,box:o}=e,r=s.maxPadding;if(!et(i)){e.size&&(s[i]-=e.size);let h=n[e.stack]||{size:0,count:1};h.size=Math.max(h.size,e.horizontal?o.height:o.width),e.size=h.size/h.count,s[i]+=e.size}o.getPadding&&cl(r,o.getPadding());let a=Math.max(0,t.outerWidth-ga(r,s,"left","right")),l=Math.max(0,t.outerHeight-ga(r,s,"top","bottom")),c=a!==s.w,d=l!==s.h;return s.w=a,s.h=l,e.horizontal?{same:c,other:d}:{same:d,other:c}}function Ah(s){let t=s.maxPadding;function e(n){let i=Math.max(t[n]-s[n],0);return s[n]+=i,i}s.y+=e("top"),s.x+=e("left"),e("right"),e("bottom")}function Ph(s,t){let e=t.maxPadding;function n(i){let o={left:0,top:0,right:0,bottom:0};return i.forEach(r=>{o[r]=Math.max(t[r],e[r])}),o}return n(s?["left","right"]:["top","bottom"])}function Bs(s,t,e,n){let i=[],o,r,a,l,c,d;for(o=0,r=s.length,c=0;o<r;++o){a=s[o],l=a.box,l.update(a.width||t.w,a.height||t.h,Ph(a.horizontal,t));let{same:h,other:u}=Lh(t,e,a,n);c|=h&&i.length,d=d||u,l.fullSize||i.push(a)}return c&&Bs(i,t,e,n)||d}function Fn(s,t,e,n,i){s.top=e,s.left=t,s.right=t+n,s.bottom=e+i,s.width=n,s.height=i}function ma(s,t,e,n){let i=e.padding,{x:o,y:r}=t;for(let a of s){let l=a.box,c=n[a.stack]||{count:1,placed:0,weight:1},d=a.stackWeight/c.weight||1;if(a.horizontal){let h=t.w*d,u=c.size||l.height;Je(c.start)&&(r=c.start),l.fullSize?Fn(l,i.left,r,e.outerWidth-i.right-i.left,u):Fn(l,t.left+c.placed,r,h,u),c.start=r,c.placed+=h,r=l.bottom}else{let h=t.h*d,u=c.size||l.width;Je(c.start)&&(o=c.start),l.fullSize?Fn(l,o,i.top,u,e.outerHeight-i.bottom-i.top):Fn(l,o,t.top+c.placed,u,h),c.start=o,c.placed+=h,o=l.right}}t.x=o,t.y=r}function Oh(s,t){let e=s.style,n=s.getAttribute("height"),i=s.getAttribute("width");if(s[Hn]={initial:{height:n,width:i,style:{display:e.display,height:e.height,width:e.width}}},e.display=e.display||"block",e.boxSizing=e.boxSizing||"border-box",ba(i)){let o=ji(s,"width");o!==void 0&&(s.width=o)}if(ba(n))if(s.style.height==="")s.height=s.width/(t||2);else{let o=ji(s,"height");o!==void 0&&(s.height=o)}return s}function Fh(s,t,e){s&&s.addEventListener(t,e,dl)}function Ih(s,t,e){s&&s.canvas&&s.canvas.removeEventListener(t,e,dl)}function Vh(s,t){let e=Rh[s.type]||s.type,{x:n,y:i}=xe(s,t);return{type:e,chart:t,native:s,x:n!==void 0?n:null,y:i!==void 0?i:null}}function Un(s,t){for(let e of s)if(e===t||e.contains(t))return!0}function Nh(s,t,e){let n=s.canvas,i=new MutationObserver(o=>{let r=!1;for(let a of o)r=r||Un(a.addedNodes,n),r=r&&!Un(a.removedNodes,n);r&&e()});return i.observe(document,{childList:!0,subtree:!0}),i}function Bh(s,t,e){let n=s.canvas,i=new MutationObserver(o=>{let r=!1;for(let a of o)r=r||Un(a.removedNodes,n),r=r&&!Un(a.addedNodes,n);r&&e()});return i.observe(document,{childList:!0,subtree:!0}),i}function hl(){let s=window.devicePixelRatio;s!==va&&(va=s,js.forEach((t,e)=>{e.currentDevicePixelRatio!==s&&t()}))}function zh(s,t){js.size||window.addEventListener("resize",hl),js.set(s,t)}function Hh(s){js.delete(s),js.size||window.removeEventListener("resize",hl)}function $h(s,t,e){let n=s.canvas,i=n&&Rn(n);if(!i)return;let o=Ai((a,l)=>{let c=i.clientWidth;e(a,l),c<i.clientWidth&&e()},window),r=new ResizeObserver(a=>{let l=a[0],c=l.contentRect.width,d=l.contentRect.height;c===0&&d===0||o(c,d)});return r.observe(i),zh(s,o),r}function so(s,t,e){e&&e.disconnect(),t==="resize"&&Hh(s)}function Wh(s,t,e){let n=s.canvas,i=Ai(o=>{s.ctx!==null&&e(Vh(o,s))},s);return Fh(n,t,i),i}function ul(s){return!Pn()||typeof OffscreenCanvas!="undefined"&&s instanceof OffscreenCanvas?jn:Kn}function jh(s,t){let e=s.options.ticks,n=Uh(s),i=Math.min(e.maxTicksLimit||n,n),o=e.major.enabled?Yh(t):[],r=o.length,a=o[0],l=o[r-1],c=[];if(r>i)return Gh(t,c,o,r/i),c;let d=Kh(o,t,i);if(r>0){let h,u,f=r>1?Math.round((l-a)/(r-1)):null;for(In(t,c,d,tt(f)?0:a-f,a),h=0,u=r-1;h<u;h++)In(t,c,d,o[h],o[h+1]);return In(t,c,d,l,tt(f)?t.length:l+f),c}return In(t,c,d),c}function Uh(s){let t=s.options.offset,e=s._tickSize(),n=s._length/e+(t?0:1),i=s._maxLength/e;return Math.floor(Math.min(n,i))}function Kh(s,t,e){let n=qh(s),i=t.length/e;if(!n)return Math.max(i,1);let o=Pr(n);for(let r=0,a=o.length-1;r<a;r++){let l=o[r];if(l>i)return l}return Math.max(i,1)}function Yh(s){let t=[],e,n;for(e=0,n=s.length;e<n;e++)s[e].major&&t.push(e);return t}function Gh(s,t,e,n){let i=0,o=e[0],r;for(n=Math.ceil(n),r=0;r<s.length;r++)r===o&&(t.push(s[r]),i++,o=e[i*n])}function In(s,t,e,n,i){let o=Q(n,0),r=Math.min(Q(i,s.length),s.length),a=0,l,c,d;for(e=Math.ceil(e),i&&(l=i-n,e=l/Math.floor(l/e)),d=o;d<0;)a++,d=Math.round(o+a*e);for(c=Math.max(o,0);c<r;c++)c===d&&(t.push(s[c]),a++,d=Math.round(o+a*e))}function qh(s){let t=s.length,e,n;if(t<2)return!1;for(n=s[0],e=1;e<t;++e)if(s[e]-s[e-1]!==n)return!1;return n}function _a(s,t){let e=[],n=s.length/t,i=s.length,o=0;for(;o<i;o+=n)e.push(s[Math.floor(o)]);return e}function Qh(s,t,e){let n=s.ticks.length,i=Math.min(t,n-1),o=s._startPixel,r=s._endPixel,a=1e-6,l=s.getPixelForTick(i),c;if(!(e&&(n===1?c=Math.max(l-o,r-l):t===0?c=(s.getPixelForTick(1)-l)/2:c=(l-s.getPixelForTick(i-1))/2,l+=i<t?c:-c,l<o-a||l>r+a)))return l}function Zh(s,t){ot(s,e=>{let n=e.gc,i=n.length/2,o;if(i>t){for(o=0;o<i;++o)delete e.data[n[o]];n.splice(0,i)}})}function Vs(s){return s.drawTicks?s.tickLength:0}function Ca(s,t){if(!s.display)return 0;let e=bt(s.font,t),n=Ct(s.padding);return(ct(s.text)?s.text.length:1)*e.lineHeight+n.height}function Jh(s,t){return le(s,{scale:t,type:"scale"})}function tu(s,t,e){return le(s,{tick:e,index:t,type:"tick"})}function eu(s,t,e){let n=Mn(s);return(e&&t!=="right"||!e&&t==="right")&&(n=Xh(n)),n}function su(s,t,e,n){let{top:i,left:o,bottom:r,right:a,chart:l}=s,{chartArea:c,scales:d}=l,h=0,u,f,p,m=r-i,g=a-o;if(s.isHorizontal()){if(f=_t(n,o,a),et(e)){let b=Object.keys(e)[0],x=e[b];p=d[b].getPixelForValue(x)+m-t}else e==="center"?p=(c.bottom+c.top)/2+m-t:p=ya(s,e,t);u=a-o}else{if(et(e)){let b=Object.keys(e)[0],x=e[b];f=d[b].getPixelForValue(x)-g+t}else e==="center"?f=(c.left+c.right)/2-g+t:f=ya(s,e,t);p=_t(n,r,i),h=e==="left"?-mt:mt}return{titleX:f,titleY:p,maxWidth:u,rotation:h}}function nu(s,t,e){let n=Xe(Object.create(null),[e?ht.get(e):{},ht.get(t),s.defaults]);ht.set(t,n),s.defaultRoutes&&iu(t,s.defaultRoutes),s.descriptors&&ht.describe(t,s.descriptors)}function iu(s,t){Object.keys(t).forEach(e=>{let n=e.split("."),i=n.pop(),o=[s].concat(n).join("."),r=t[e].split("."),a=r.pop(),l=r.join(".");ht.route(o,i,l,a)})}function ou(s){return"id"in s&&"defaults"in s}function ru(s){let t={},e=[],n=Object.keys(jt.plugins.items);for(let o=0;o<n.length;o++)e.push(jt.getPlugin(n[o]));let i=s.plugins||[];for(let o=0;o<i.length;o++){let r=i[o];e.indexOf(r)===-1&&(e.push(r),t[r.id]=!0)}return{plugins:e,localIds:t}}function au(s,t){return!t&&s===!1?null:s===!0?{}:s}function lu(s,{plugins:t,localIds:e},n,i){let o=[],r=s.getContext();for(let a of t){let l=a.id,c=au(n[l],i);c!==null&&o.push({plugin:a,options:cu(s.config,{plugin:a,local:e[l]},c,r)})}return o}function cu(s,{plugin:t,local:e},n,i){let o=s.pluginScopeKeys(t),r=s.getOptionScopes(n,o);return e&&t.defaults&&r.push(t.defaults),s.createResolver(r,i,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function uo(s,t){let e=ht.datasets[s]||{};return((t.datasets||{})[s]||{}).indexAxis||t.indexAxis||e.indexAxis||"x"}function du(s,t){let e=s;return s==="_index_"?e=t:s==="_value_"&&(e=t==="x"?"y":"x"),e}function hu(s,t){return s===t?"_index_":"_value_"}function Sa(s){if(s==="x"||s==="y"||s==="r")return s}function uu(s){if(s==="top"||s==="bottom")return"x";if(s==="left"||s==="right")return"y"}function fo(s,...t){if(Sa(s))return s;for(let e of t){let n=e.axis||uu(e.position)||s.length>1&&Sa(s[0].toLowerCase());if(n)return n}throw new Error(`Cannot determine type of '${s}' axis. Please provide 'axis' or 'position' option.`)}function wa(s,t,e){if(e[t+"AxisID"]===s)return{axis:t}}function fu(s,t){if(t.data&&t.data.datasets){let e=t.data.datasets.filter(n=>n.xAxisID===s||n.yAxisID===s);if(e.length)return wa(s,"x",e[0])||wa(s,"y",e[0])}return{}}function pu(s,t){let e=me[s.type]||{scales:{}},n=t.scales||{},i=uo(s.type,t),o=Object.create(null);return Object.keys(n).forEach(r=>{let a=n[r];if(!et(a))return console.error(`Invalid scale configuration for scale: ${r}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${r}`);let l=fo(r,a,fu(r,s),ht.scales[a.type]),c=hu(l,i),d=e.scales||{};o[r]=Ze(Object.create(null),[{axis:l},a,d[l],d[c]])}),s.data.datasets.forEach(r=>{let a=r.type||s.type,l=r.indexAxis||uo(a,t),d=(me[a]||{}).scales||{};Object.keys(d).forEach(h=>{let u=du(h,l),f=r[u+"AxisID"]||u;o[f]=o[f]||Object.create(null),Ze(o[f],[{axis:u},n[f],d[h]])})}),Object.keys(o).forEach(r=>{let a=o[r];Ze(a,[ht.scales[a.type],ht.scale])}),o}function fl(s){let t=s.options||(s.options={});t.plugins=Q(t.plugins,{}),t.scales=pu(s,t)}function pl(s){return s=s||{},s.datasets=s.datasets||[],s.labels=s.labels||[],s}function gu(s){return s=s||{},s.data=pl(s.data),fl(s),s}function Vn(s,t){let e=Ea.get(s);return e||(e=t(),Ea.set(s,e),gl.add(e)),e}function ka(s,t,e){let n=s.get(t);n||(n=new Map,s.set(t,n));let i=e.join(),o=n.get(i);return o||(o={resolver:An(t,e),subPrefixes:e.filter(a=>!a.toLowerCase().includes("hover"))},n.set(i,o)),o}function bu(s,t){let{isScriptable:e,isIndexable:n}=Bi(s);for(let i of t){let o=e(i),r=n(i),a=(r||o)&&s[i];if(o&&(oe(a)||mu(a))||r&&ct(a))return!0}return!1}function Ma(s,t){return s==="top"||s==="bottom"||yu.indexOf(s)===-1&&t==="x"}function Da(s,t){return function(e,n){return e[s]===n[s]?e[t]-n[t]:e[s]-n[s]}}function Ta(s){let t=s.chart,e=t.options.animation;t.notifyPlugins("afterRender"),lt(e&&e.onComplete,[s],t)}function xu(s){let t=s.chart,e=t.options.animation;lt(e&&e.onProgress,[s],t)}function ml(s){return Pn()&&typeof s=="string"?s=document.getElementById(s):s&&s.length&&(s=s[0]),s&&s.canvas&&(s=s.canvas),s}function _u(s,t,e){let n=Object.keys(s);for(let i of n){let o=+i;if(o>=t){let r=s[i];delete s[i],(e>0||o>t)&&(s[o+e]=r)}}}function Cu(s,t,e,n){return!e||s.type==="mouseout"?null:n?t:s}function Aa(){return ot(ee.instances,s=>s._plugins.invalidate())}function Su(s,t,e){let{startAngle:n,x:i,y:o,outerRadius:r,innerRadius:a,options:l}=t,{borderWidth:c,borderJoinStyle:d}=l,h=Math.min(c/r,xt(n-e));if(s.beginPath(),s.arc(i,o,r-c/2,n+h/2,e-h/2),a>0){let u=Math.min(c/a,xt(n-e));s.arc(i,o,a+c/2,e-u/2,n+u/2,!0)}else{let u=Math.min(c/2,r*xt(n-e));if(d==="round")s.arc(i,o,u,e-nt/2,n+nt/2,!0);else if(d==="bevel"){let f=2*u*u,p=-f*Math.cos(e+nt/2)+i,m=-f*Math.sin(e+nt/2)+o,g=f*Math.cos(n+nt/2)+i,b=f*Math.sin(n+nt/2)+o;s.lineTo(p,m),s.lineTo(g,b)}}s.closePath(),s.moveTo(0,0),s.rect(0,0,s.canvas.width,s.canvas.height),s.clip("evenodd")}function wu(s,t,e){let{startAngle:n,pixelMargin:i,x:o,y:r,outerRadius:a,innerRadius:l}=t,c=i/a;s.beginPath(),s.arc(o,r,a,n-c,e+c),l>i?(c=i/l,s.arc(o,r,l,e+c,n-c,!0)):s.arc(o,r,i,e+mt,n-mt),s.closePath(),s.clip()}function Eu(s){return Ln(s,["outerStart","outerEnd","innerStart","innerEnd"])}function ku(s,t,e,n){let i=Eu(s.options.borderRadius),o=(e-t)/2,r=Math.min(o,n*t/2),a=l=>{let c=(e-Math.min(o,l))*n/2;return vt(l,0,Math.min(o,c))};return{outerStart:a(i.outerStart),outerEnd:a(i.outerEnd),innerStart:vt(i.innerStart,0,r),innerEnd:vt(i.innerEnd,0,r)}}function rs(s,t,e,n){return{x:e+s*Math.cos(t),y:n+s*Math.sin(t)}}function Yn(s,t,e,n,i,o){let{x:r,y:a,startAngle:l,pixelMargin:c,innerRadius:d}=t,h=Math.max(t.outerRadius+n+e-c,0),u=d>0?d+n+e+c:0,f=0,p=i-l;if(n){let P=d>0?d-n:0,O=h>0?h-n:0,z=(P+O)/2,G=z!==0?p*z/(z+n):p;f=(p-G)/2}let m=Math.max(.001,p*h-e/nt)/h,g=(p-m)/2,b=l+g+f,x=i-g-f,{outerStart:_,outerEnd:E,innerStart:w,innerEnd:v}=ku(t,u,h,x-b),y=h-_,S=h-E,D=b+_/y,M=x-E/S,C=u+w,T=u+v,k=b+w/C,A=x-v/T;if(s.beginPath(),o){let P=(D+M)/2;if(s.arc(r,a,h,D,P),s.arc(r,a,h,P,M),E>0){let $=rs(S,M,r,a);s.arc($.x,$.y,E,M,x+mt)}let O=rs(T,x,r,a);if(s.lineTo(O.x,O.y),v>0){let $=rs(T,A,r,a);s.arc($.x,$.y,v,x+mt,A+Math.PI)}let z=(x-v/u+(b+w/u))/2;if(s.arc(r,a,u,x-v/u,z,!0),s.arc(r,a,u,z,b+w/u,!0),w>0){let $=rs(C,k,r,a);s.arc($.x,$.y,w,k+Math.PI,b-mt)}let G=rs(y,b,r,a);if(s.lineTo(G.x,G.y),_>0){let $=rs(y,D,r,a);s.arc($.x,$.y,_,b-mt,D)}}else{s.moveTo(r,a);let P=Math.cos(D)*h+r,O=Math.sin(D)*h+a;s.lineTo(P,O);let z=Math.cos(M)*h+r,G=Math.sin(M)*h+a;s.lineTo(z,G)}s.closePath()}function Mu(s,t,e,n,i){let{fullCircles:o,startAngle:r,circumference:a}=t,l=t.endAngle;if(o){Yn(s,t,e,n,l,i);for(let c=0;c<o;++c)s.fill();isNaN(a)||(l=r+(a%dt||dt))}return Yn(s,t,e,n,l,i),s.fill(),l}function Du(s,t,e,n,i){let{fullCircles:o,startAngle:r,circumference:a,options:l}=t,{borderWidth:c,borderJoinStyle:d,borderDash:h,borderDashOffset:u,borderRadius:f}=l,p=l.borderAlign==="inner";if(!c)return;s.setLineDash(h||[]),s.lineDashOffset=u,p?(s.lineWidth=c*2,s.lineJoin=d||"round"):(s.lineWidth=c,s.lineJoin=d||"bevel");let m=t.endAngle;if(o){Yn(s,t,e,n,m,i);for(let g=0;g<o;++g)s.stroke();isNaN(a)||(m=r+(a%dt||dt))}p&&wu(s,t,m),l.selfJoin&&m-r>=nt&&f===0&&d!=="miter"&&Su(s,t,m),o||(Yn(s,t,e,n,m,i),s.stroke())}function bl(s,t,e=t){s.lineCap=Q(e.borderCapStyle,t.borderCapStyle),s.setLineDash(Q(e.borderDash,t.borderDash)),s.lineDashOffset=Q(e.borderDashOffset,t.borderDashOffset),s.lineJoin=Q(e.borderJoinStyle,t.borderJoinStyle),s.lineWidth=Q(e.borderWidth,t.borderWidth),s.strokeStyle=Q(e.borderColor,t.borderColor)}function Tu(s,t,e){s.lineTo(e.x,e.y)}function Lu(s){return s.stepped?Wr:s.tension||s.cubicInterpolationMode==="monotone"?jr:Tu}function vl(s,t,e={}){let n=s.length,{start:i=0,end:o=n-1}=e,{start:r,end:a}=t,l=Math.max(i,r),c=Math.min(o,a),d=i<r&&o<r||i>a&&o>a;return{count:n,start:l,loop:t.loop,ilen:c<l&&!d?n+c-l:c-l}}function Au(s,t,e,n){let{points:i,options:o}=t,{count:r,start:a,loop:l,ilen:c}=vl(i,e,n),d=Lu(o),{move:h=!0,reverse:u}=n||{},f,p,m;for(f=0;f<=c;++f)p=i[(a+(u?c-f:f))%r],!p.skip&&(h?(s.moveTo(p.x,p.y),h=!1):d(s,m,p,u,o.stepped),m=p);return l&&(p=i[(a+(u?c:0))%r],d(s,m,p,u,o.stepped)),!!l}function Pu(s,t,e,n){let i=t.points,{count:o,start:r,ilen:a}=vl(i,e,n),{move:l=!0,reverse:c}=n||{},d=0,h=0,u,f,p,m,g,b,x=E=>(r+(c?a-E:E))%o,_=()=>{m!==g&&(s.lineTo(d,g),s.lineTo(d,m),s.lineTo(d,b))};for(l&&(f=i[x(0)],s.moveTo(f.x,f.y)),u=0;u<=a;++u){if(f=i[x(u)],f.skip)continue;let E=f.x,w=f.y,v=E|0;v===p?(w<m?m=w:w>g&&(g=w),d=(h*d+E)/++h):(_(),s.lineTo(E,w),p=v,h=0,m=g=w),b=w}_()}function go(s){let t=s.options,e=t.borderDash&&t.borderDash.length;return!s._decimated&&!s._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!e?Pu:Au}function Ru(s){return s.stepped?Jr:s.tension||s.cubicInterpolationMode==="monotone"?ta:pe}function Ou(s,t,e,n){let i=t._path;i||(i=t._path=new Path2D,t.path(i,e,n)&&i.closePath()),bl(s,t.options),s.stroke(i)}function Fu(s,t,e,n){let{segments:i,options:o}=t,r=go(t);for(let a of i)bl(s,o,a.style),s.beginPath(),r(s,t,a,{start:e,end:e+n-1})&&s.closePath(),s.stroke()}function Vu(s,t,e,n){Iu&&!t.options.segment?Ou(s,t,e,n):Fu(s,t,e,n)}function Pa(s,t,e,n){let i=s.options,{[e]:o}=s.getProps([e],n);return Math.abs(t-o)<i.radius+i.hitRadius}function yl(s,t){let{x:e,y:n,base:i,width:o,height:r}=s.getProps(["x","y","base","width","height"],t),a,l,c,d,h;return s.horizontal?(h=r/2,a=Math.min(e,i),l=Math.max(e,i),c=n-h,d=n+h):(h=o/2,a=e-h,l=e+h,c=Math.min(n,i),d=Math.max(n,i)),{left:a,top:c,right:l,bottom:d}}function we(s,t,e,n){return s?0:vt(t,e,n)}function Nu(s,t,e){let n=s.options.borderWidth,i=s.borderSkipped,o=Ni(n);return{t:we(i.top,o.top,0,e),r:we(i.right,o.right,0,t),b:we(i.bottom,o.bottom,0,e),l:we(i.left,o.left,0,t)}}function Bu(s,t,e){let{enableBorderRadius:n}=s.getProps(["enableBorderRadius"]),i=s.options.borderRadius,o=ye(i),r=Math.min(t,e),a=s.borderSkipped,l=n||et(i);return{topLeft:we(!l||a.top||a.left,o.topLeft,0,r),topRight:we(!l||a.top||a.right,o.topRight,0,r),bottomLeft:we(!l||a.bottom||a.left,o.bottomLeft,0,r),bottomRight:we(!l||a.bottom||a.right,o.bottomRight,0,r)}}function zu(s){let t=yl(s),e=t.right-t.left,n=t.bottom-t.top,i=Nu(s,e/2,n/2),o=Bu(s,e/2,n/2);return{outer:{x:t.left,y:t.top,w:e,h:n,radius:o},inner:{x:t.left+i.l,y:t.top+i.t,w:e-i.l-i.r,h:n-i.t-i.b,radius:{topLeft:Math.max(0,o.topLeft-Math.max(i.t,i.l)),topRight:Math.max(0,o.topRight-Math.max(i.t,i.r)),bottomLeft:Math.max(0,o.bottomLeft-Math.max(i.b,i.l)),bottomRight:Math.max(0,o.bottomRight-Math.max(i.b,i.r))}}}}function no(s,t,e,n){let i=t===null,o=e===null,a=s&&!(i&&o)&&yl(s,n);return a&&(i||Zt(t,a.left,a.right))&&(o||Zt(e,a.top,a.bottom))}function Hu(s){return s.topLeft||s.topRight||s.bottomLeft||s.bottomRight}function $u(s,t){s.rect(t.x,t.y,t.w,t.h)}function io(s,t,e={}){let n=s.x!==e.x?-t:0,i=s.y!==e.y?-t:0,o=(s.x+s.w!==e.x+e.w?t:0)-n,r=(s.y+s.h!==e.y+e.h?t:0)-i;return{x:s.x+n,y:s.y+i,w:s.w+o,h:s.h+r,radius:s.radius}}function _l(s){return mo[s%mo.length]}function Cl(s){return Ra[s%Ra.length]}function Wu(s,t){return s.borderColor=_l(t),s.backgroundColor=Cl(t),++t}function ju(s,t){return s.backgroundColor=s.data.map(()=>_l(t++)),t}function Uu(s,t){return s.backgroundColor=s.data.map(()=>Cl(t++)),t}function Ku(s){let t=0;return(e,n)=>{let i=s.getDatasetMeta(n).controller;i instanceof se?t=ju(e,t):i instanceof Se?t=Uu(e,t):i&&(t=Wu(e,t))}}function Oa(s){let t;for(t in s)if(s[t].borderColor||s[t].backgroundColor)return!0;return!1}function Yu(s){return s&&(s.borderColor||s.backgroundColor)}function Gu(){return ht.borderColor!=="rgba(0,0,0,0.1)"||ht.backgroundColor!=="rgba(0,0,0,0.1)"}function qu(s,t,e,n,i){let o=i.samples||n;if(o>=e)return s.slice(t,t+e);let r=[],a=(e-2)/(o-2),l=0,c=t+e-1,d=t,h,u,f,p,m;for(r[l++]=s[d],h=0;h<o-2;h++){let g=0,b=0,x,_=Math.floor((h+1)*a)+1+t,E=Math.min(Math.floor((h+2)*a)+1,e)+t,w=E-_;for(x=_;x<E;x++)g+=s[x].x,b+=s[x].y;g/=w,b/=w;let v=Math.floor(h*a)+1+t,y=Math.min(Math.floor((h+1)*a)+1,e)+t,{x:S,y:D}=s[d];for(f=p=-1,x=v;x<y;x++)p=.5*Math.abs((S-g)*(s[x].y-D)-(S-s[x].x)*(b-D)),p>f&&(f=p,u=s[x],m=x);r[l++]=u,d=m}return r[l++]=s[c],r}function Xu(s,t,e,n){let i=0,o=0,r,a,l,c,d,h,u,f,p,m,g=[],b=t+e-1,x=s[t].x,E=s[b].x-x;for(r=t;r<t+e;++r){a=s[r],l=(a.x-x)/E*n,c=a.y;let w=l|0;if(w===d)c<p?(p=c,h=r):c>m&&(m=c,u=r),i=(o*i+a.x)/++o;else{let v=r-1;if(!tt(h)&&!tt(u)){let y=Math.min(h,u),S=Math.max(h,u);y!==f&&y!==v&&g.push({...s[y],x:i}),S!==f&&S!==v&&g.push({...s[S],x:i})}r>0&&v!==f&&g.push(s[v]),g.push(a),d=w,o=0,p=m=c,h=u=f=r}}return g}function wl(s){if(s._decimated){let t=s._data;delete s._decimated,delete s._data,Object.defineProperty(s,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function Fa(s){s.data.datasets.forEach(t=>{wl(t)})}function Qu(s,t){let e=t.length,n=0,i,{iScale:o}=s,{min:r,max:a,minDefined:l,maxDefined:c}=o.getUserBounds();return l&&(n=vt(qt(t,o.axis,r).lo,0,e-1)),c?i=vt(qt(t,o.axis,a).hi+1,n,e)-n:i=e-n,{start:n,count:i}}function Zu(s,t,e){let n=s.segments,i=s.points,o=t.points,r=[];for(let a of n){let{start:l,end:c}=a;c=Xn(l,c,i);let d=bo(e,i[l],i[c],a.loop);if(!t.segments){r.push({source:a,target:d,start:i[l],end:i[c]});continue}let h=Gi(t,d);for(let u of h){let f=bo(e,o[u.start],o[u.end],u.loop),p=Yi(a,i,f);for(let m of p)r.push({source:m,target:u,start:{[e]:Ia(d,f,"start",Math.max)},end:{[e]:Ia(d,f,"end",Math.min)}})}}return r}function bo(s,t,e,n){if(n)return;let i=t[s],o=e[s];return s==="angle"&&(i=xt(i),o=xt(o)),{property:s,start:i,end:o}}function Ju(s,t){let{x:e=null,y:n=null}=s||{},i=t.points,o=[];return t.segments.forEach(({start:r,end:a})=>{a=Xn(r,a,i);let l=i[r],c=i[a];n!==null?(o.push({x:l.x,y:n}),o.push({x:c.x,y:n})):e!==null&&(o.push({x:e,y:l.y}),o.push({x:e,y:c.y}))}),o}function Xn(s,t,e){for(;t>s;t--){let n=e[t];if(!isNaN(n.x)&&!isNaN(n.y))break}return t}function Ia(s,t,e,n){return s&&t?n(s[e],t[e]):s?s[e]:t?t[e]:0}function kl(s,t){let e=[],n=!1;return ct(s)?(n=!0,e=s):e=Ju(s,t),e.length?new Ut({points:e,options:{tension:0},_loop:n,_fullLoop:n}):null}function Va(s){return s&&s.fill!==!1}function tf(s,t,e){let i=s[t].fill,o=[t],r;if(!e)return i;for(;i!==!1&&o.indexOf(i)===-1;){if(!pt(i))return i;if(r=s[i],!r)return!1;if(r.visible)return i;o.push(i),i=r.fill}return!1}function ef(s,t,e){let n=rf(s);if(et(n))return isNaN(n.value)?!1:n;let i=parseFloat(n);return pt(i)&&Math.floor(i)===i?sf(n[0],t,i,e):["origin","start","end","stack","shape"].indexOf(n)>=0&&n}function sf(s,t,e,n){return(s==="-"||s==="+")&&(e=t+e),e===t||e<0||e>=n?!1:e}function nf(s,t){let e=null;return s==="start"?e=t.bottom:s==="end"?e=t.top:et(s)?e=t.getPixelForValue(s.value):t.getBasePixel&&(e=t.getBasePixel()),e}function of(s,t,e){let n;return s==="start"?n=e:s==="end"?n=t.options.reverse?t.min:t.max:et(s)?n=s.value:n=t.getBaseValue(),n}function rf(s){let t=s.options,e=t.fill,n=Q(e&&e.target,e);return n===void 0&&(n=!!t.backgroundColor),n===!1||n===null?!1:n===!0?"origin":n}function af(s){let{scale:t,index:e,line:n}=s,i=[],o=n.segments,r=n.points,a=lf(t,e);a.push(kl({x:null,y:t.bottom},n));for(let l=0;l<o.length;l++){let c=o[l];for(let d=c.start;d<=c.end;d++)cf(i,r[d],a)}return new Ut({points:i,options:{}})}function lf(s,t){let e=[],n=s.getMatchingVisibleMetas("line");for(let i=0;i<n.length;i++){let o=n[i];if(o.index===t)break;o.hidden||e.unshift(o.dataset)}return e}function cf(s,t,e){let n=[];for(let i=0;i<e.length;i++){let o=e[i],{first:r,last:a,point:l}=df(o,t,"x");if(!(!l||r&&a)){if(r)n.unshift(l);else if(s.push(l),!a)break}}s.push(...n)}function df(s,t,e){let n=s.interpolate(t,e);if(!n)return{};let i=n[e],o=s.segments,r=s.points,a=!1,l=!1;for(let c=0;c<o.length;c++){let d=o[c],h=r[d.start][e],u=r[d.end][e];if(Zt(i,h,u)){a=i===h,l=i===u;break}}return{first:a,last:l,point:n}}function hf(s){let{chart:t,fill:e,line:n}=s;if(pt(e))return uf(t,e);if(e==="stack")return af(s);if(e==="shape")return!0;let i=ff(s);return i instanceof Gn?i:kl(i,n)}function uf(s,t){let e=s.getDatasetMeta(t);return e&&s.isDatasetVisible(t)?e.dataset:null}function ff(s){return(s.scale||{}).getPointPositionForValue?gf(s):pf(s)}function pf(s){let{scale:t={},fill:e}=s,n=nf(e,t);if(pt(n)){let i=t.isHorizontal();return{x:i?n:null,y:i?null:n}}return null}function gf(s){let{scale:t,fill:e}=s,n=t.options,i=t.getLabels().length,o=n.reverse?t.max:t.min,r=of(e,t,o),a=[];if(n.grid.circular){let l=t.getPointPositionForValue(0,o);return new Gn({x:l.x,y:l.y,radius:t.getDistanceFromCenterForValue(r)})}for(let l=0;l<i;++l)a.push(t.getPointPositionForValue(l,r));return a}function oo(s,t,e){let n=hf(t),{chart:i,index:o,line:r,scale:a,axis:l}=t,c=r.options,d=c.fill,h=c.backgroundColor,{above:u=h,below:f=h}=d||{},p=i.getDatasetMeta(o),m=qi(i,p);n&&r.points.length&&(Ps(s,e),mf(s,{line:r,target:n,above:u,below:f,area:e,scale:a,axis:l,clip:m}),Rs(s))}function mf(s,t){let{line:e,target:n,above:i,below:o,area:r,scale:a,clip:l}=t,c=e._loop?"angle":t.axis;s.save();let d=o;o!==i&&(c==="x"?(Na(s,n,r.top),ro(s,{line:e,target:n,color:i,scale:a,property:c,clip:l}),s.restore(),s.save(),Na(s,n,r.bottom)):c==="y"&&(Ba(s,n,r.left),ro(s,{line:e,target:n,color:o,scale:a,property:c,clip:l}),s.restore(),s.save(),Ba(s,n,r.right),d=i)),ro(s,{line:e,target:n,color:d,scale:a,property:c,clip:l}),s.restore()}function Na(s,t,e){let{segments:n,points:i}=t,o=!0,r=!1;s.beginPath();for(let a of n){let{start:l,end:c}=a,d=i[l],h=i[Xn(l,c,i)];o?(s.moveTo(d.x,d.y),o=!1):(s.lineTo(d.x,e),s.lineTo(d.x,d.y)),r=!!t.pathSegment(s,a,{move:r}),r?s.closePath():s.lineTo(h.x,e)}s.lineTo(t.first().x,e),s.closePath(),s.clip()}function Ba(s,t,e){let{segments:n,points:i}=t,o=!0,r=!1;s.beginPath();for(let a of n){let{start:l,end:c}=a,d=i[l],h=i[Xn(l,c,i)];o?(s.moveTo(d.x,d.y),o=!1):(s.lineTo(e,d.y),s.lineTo(d.x,d.y)),r=!!t.pathSegment(s,a,{move:r}),r?s.closePath():s.lineTo(e,h.y)}s.lineTo(e,t.first().y),s.closePath(),s.clip()}function ro(s,t){let{line:e,target:n,property:i,color:o,scale:r,clip:a}=t,l=Zu(e,n,i);for(let{source:c,target:d,start:h,end:u}of l){let{style:{backgroundColor:f=o}={}}=c,p=n!==!0;s.save(),s.fillStyle=f,bf(s,r,a,p&&bo(i,h,u)),s.beginPath();let m=!!e.pathSegment(s,c),g;if(p){m?s.closePath():za(s,n,u,i);let b=!!n.pathSegment(s,d,{move:m,reverse:!0});g=m&&b,g||za(s,n,h,i)}s.closePath(),s.fill(g?"evenodd":"nonzero"),s.restore()}}function bf(s,t,e,n){let i=t.chart.chartArea,{property:o,start:r,end:a}=n||{};if(o==="x"||o==="y"){let l,c,d,h;o==="x"?(l=r,c=i.top,d=a,h=i.bottom):(l=i.left,c=r,d=i.right,h=a),s.beginPath(),e&&(l=Math.max(l,e.left),d=Math.min(d,e.right),c=Math.max(c,e.top),h=Math.min(h,e.bottom)),s.rect(l,c,d-l,h-c),s.clip()}}function za(s,t,e,n){let i=t.interpolate(e,n);i&&s.lineTo(i.x,i.y)}function yf(s,t,e,n,i){let o=xf(n,s,t,e),r=_f(i,n,t.lineHeight);return{itemWidth:o,itemHeight:r}}function xf(s,t,e,n){let i=s.text;return i&&typeof i!="string"&&(i=i.reduce((o,r)=>o.length>r.length?o:r)),t+e.size/2+n.measureText(i).width}function _f(s,t,e){let n=s;return typeof t.text!="string"&&(n=Dl(t,e)),n}function Dl(s,t){let e=s.text?s.text.length:0;return t*e}function Cf(s,t){return!!((s==="mousemove"||s==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(s==="click"||s==="mouseup"))}function Sf(s,t){let e=new Us({ctx:s.ctx,options:t,chart:s});St.configure(s,e,t),St.addBox(s,e),s.titleBlock=e}function Jt(s,t){return t&&(ct(t)?Array.prototype.push.apply(s,t):s.push(t)),s}function ce(s){return(typeof s=="string"||s instanceof String)&&s.indexOf(`
|
||
`)>-1?s.split(`
|
||
`):s}function wf(s,t){let{element:e,datasetIndex:n,index:i}=t,o=s.getDatasetMeta(n).controller,{label:r,value:a}=o.getLabelAndValue(i);return{chart:s,label:r,parsed:o.getParsed(i),raw:s.data.datasets[n].data[i],formattedValue:a,dataset:o.getDataset(),dataIndex:i,datasetIndex:n,element:e}}function $a(s,t){let e=s.chart.ctx,{body:n,footer:i,title:o}=s,{boxWidth:r,boxHeight:a}=t,l=bt(t.bodyFont),c=bt(t.titleFont),d=bt(t.footerFont),h=o.length,u=i.length,f=n.length,p=Ct(t.padding),m=p.height,g=0,b=n.reduce((E,w)=>E+w.before.length+w.lines.length+w.after.length,0);if(b+=s.beforeBody.length+s.afterBody.length,h&&(m+=h*c.lineHeight+(h-1)*t.titleSpacing+t.titleMarginBottom),b){let E=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;m+=f*E+(b-f)*l.lineHeight+(b-1)*t.bodySpacing}u&&(m+=t.footerMarginTop+u*d.lineHeight+(u-1)*t.footerSpacing);let x=0,_=function(E){g=Math.max(g,e.measureText(E).width+x)};return e.save(),e.font=c.string,ot(s.title,_),e.font=l.string,ot(s.beforeBody.concat(s.afterBody),_),x=t.displayColors?r+2+t.boxPadding:0,ot(n,E=>{ot(E.before,_),ot(E.lines,_),ot(E.after,_)}),x=0,e.font=d.string,ot(s.footer,_),e.restore(),g+=p.width,{width:g,height:m}}function Ef(s,t){let{y:e,height:n}=t;return e<n/2?"top":e>s.height-n/2?"bottom":"center"}function kf(s,t,e,n){let{x:i,width:o}=n,r=e.caretSize+e.caretPadding;if(s==="left"&&i+o+r>t.width||s==="right"&&i-o-r<0)return!0}function Mf(s,t,e,n){let{x:i,width:o}=e,{width:r,chartArea:{left:a,right:l}}=s,c="center";return n==="center"?c=i<=(a+l)/2?"left":"right":i<=o/2?c="left":i>=r-o/2&&(c="right"),kf(c,s,t,e)&&(c="center"),c}function Wa(s,t,e){let n=e.yAlign||t.yAlign||Ef(s,e);return{xAlign:e.xAlign||t.xAlign||Mf(s,t,e,n),yAlign:n}}function Df(s,t){let{x:e,width:n}=s;return t==="right"?e-=n:t==="center"&&(e-=n/2),e}function Tf(s,t,e){let{y:n,height:i}=s;return t==="top"?n+=e:t==="bottom"?n-=i+e:n-=i/2,n}function ja(s,t,e,n){let{caretSize:i,caretPadding:o,cornerRadius:r}=s,{xAlign:a,yAlign:l}=e,c=i+o,{topLeft:d,topRight:h,bottomLeft:u,bottomRight:f}=ye(r),p=Df(t,a),m=Tf(t,l,c);return l==="center"?a==="left"?p+=c:a==="right"&&(p-=c):a==="left"?p-=Math.max(d,u)+i:a==="right"&&(p+=Math.max(h,f)+i),{x:vt(p,0,n.width-t.width),y:vt(m,0,n.height-t.height)}}function Bn(s,t,e){let n=Ct(e.padding);return t==="center"?s.x+s.width/2:t==="right"?s.x+s.width-n.right:s.x+n.left}function Ua(s){return Jt([],ce(s))}function Lf(s,t,e){return le(s,{tooltip:t,tooltipItems:e,type:"tooltip"})}function Ka(s,t){let e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?s.override(e):s}function Dt(s,t,e,n){let i=s[t].call(e,n);return typeof i=="undefined"?Pl[t].call(e,n):i}function Pf(s,t,e,n){let i=s.indexOf(t);if(i===-1)return Af(s,t,e,n);let o=s.lastIndexOf(t);return i!==o?e:i}function Ya(s){let t=this.getLabels();return s>=0&&s<t.length?t[s]:s}function Of(s,t){let e=[],{bounds:i,step:o,min:r,max:a,precision:l,count:c,maxTicks:d,maxDigits:h,includeBounds:u}=s,f=o||1,p=d-1,{min:m,max:g}=t,b=!tt(r),x=!tt(a),_=!tt(c),E=(g-m)/(h+1),w=wi((g-m)/p/f)*f,v,y,S,D;if(w<1e-14&&!b&&!x)return[{value:m},{value:g}];D=Math.ceil(g/w)-Math.floor(m/w),D>p&&(w=wi(D*w/p/f)*f),tt(l)||(v=Math.pow(10,l),w=Math.ceil(w*v)/v),i==="ticks"?(y=Math.floor(m/w)*w,S=Math.ceil(g/w)*w):(y=m,S=g),b&&x&&o&&Rr((a-r)/o,w/1e3)?(D=Math.round(Math.min((a-r)/w,d)),w=(a-r)/D,y=r,S=a):_?(y=b?r:y,S=x?a:S,D=c-1,w=(S-y)/D):(D=(S-y)/w,ts(D,Math.round(D),w/1e3)?D=Math.round(D):D=Math.ceil(D));let M=Math.max(ki(w),ki(y));v=Math.pow(10,tt(l)?M:l),y=Math.round(y*v)/v,S=Math.round(S*v)/v;let C=0;for(b&&(u&&y!==r?(e.push({value:r}),y<r&&C++,ts(Math.round((y+C*w)*v)/v,r,Ga(r,E,s))&&C++):y<r&&C++);C<D;++C){let T=Math.round((y+C*w)*v)/v;if(x&&T>a)break;e.push({value:T})}return x&&u&&S!==a?e.length&&ts(e[e.length-1].value,a,Ga(a,E,s))?e[e.length-1].value=a:e.push({value:a}):(!x||S===a)&&e.push({value:S}),e}function Ga(s,t,{horizontal:e,minRotation:n}){let i=zt(n),o=(e?Math.sin(i):Math.cos(i))||.001,r=.75*t*(""+s).length;return Math.min(t/o,r)}function qa(s){return s/Math.pow(10,Ks(s))===1}function Xa(s,t,e){let n=Math.pow(10,e),i=Math.floor(s/n);return Math.ceil(t/n)-i}function Ff(s,t){let e=t-s,n=Ks(e);for(;Xa(s,t,n)>10;)n++;for(;Xa(s,t,n)<10;)n--;return Math.min(n,Ks(s))}function If(s,{min:t,max:e}){t=Mt(s.min,t);let n=[],i=Ks(t),o=Ff(t,e),r=o<0?Math.pow(10,Math.abs(o)):1,a=Math.pow(10,o),l=i>o?Math.pow(10,i):0,c=Math.round((t-l)*r)/r,d=Math.floor((t-l)/a/10)*a*10,h=Math.floor((c-d)/Math.pow(10,o)),u=Mt(s.min,Math.round((l+d+h*Math.pow(10,o))*r)/r);for(;u<e;)n.push({value:u,major:qa(u),significand:h}),h>=10?h=h<15?15:20:h++,h>=20&&(o++,h=2,r=o>=0?1:r),u=Math.round((l+d+h*Math.pow(10,o))*r)/r;let f=Mt(s.max,u);return n.push({value:f,major:qa(f),significand:h}),n}function vo(s){let t=s.ticks;if(t.display&&s.display){let e=Ct(t.backdropPadding);return Q(t.font&&t.font.size,ht.font.size)+e.height}return 0}function Vf(s,t,e){return e=ct(e)?e:[e],{w:$r(s,t.string,e),h:e.length*t.lineHeight}}function Qa(s,t,e,n,i){return s===n||s===i?{start:t-e/2,end:t+e/2}:s<n||s>i?{start:t-e,end:t}:{start:t,end:t+e}}function Nf(s){let t={l:s.left+s._padding.left,r:s.right-s._padding.right,t:s.top+s._padding.top,b:s.bottom-s._padding.bottom},e=Object.assign({},t),n=[],i=[],o=s._pointLabels.length,r=s.options.pointLabels,a=r.centerPointLabels?nt/o:0;for(let l=0;l<o;l++){let c=r.setContext(s.getPointLabelContext(l));i[l]=c.padding;let d=s.getPointPosition(l,s.drawingArea+i[l],a),h=bt(c.font),u=Vf(s.ctx,h,s._pointLabels[l]);n[l]=u;let f=xt(s.getIndexAngle(l)+a),p=Math.round(En(f)),m=Qa(p,d.x,u.w,0,180),g=Qa(p,d.y,u.h,90,270);Bf(e,t,f,m,g)}s.setCenterPoint(t.l-e.l,e.r-t.r,t.t-e.t,e.b-t.b),s._pointLabelItems=$f(s,n,i)}function Bf(s,t,e,n,i){let o=Math.abs(Math.sin(e)),r=Math.abs(Math.cos(e)),a=0,l=0;n.start<t.l?(a=(t.l-n.start)/o,s.l=Math.min(s.l,t.l-a)):n.end>t.r&&(a=(n.end-t.r)/o,s.r=Math.max(s.r,t.r+a)),i.start<t.t?(l=(t.t-i.start)/r,s.t=Math.min(s.t,t.t-l)):i.end>t.b&&(l=(i.end-t.b)/r,s.b=Math.max(s.b,t.b+l))}function zf(s,t,e){let n=s.drawingArea,{extra:i,additionalAngle:o,padding:r,size:a}=e,l=s.getPointPosition(t,n+i+r,o),c=Math.round(En(xt(l.angle+mt))),d=Uf(l.y,a.h,c),h=Wf(c),u=jf(l.x,a.w,h);return{visible:!0,x:l.x,y:d,textAlign:h,left:u,top:d,right:u+a.w,bottom:d+a.h}}function Hf(s,t){if(!t)return!0;let{left:e,top:n,right:i,bottom:o}=s;return!(Xt({x:e,y:n},t)||Xt({x:e,y:o},t)||Xt({x:i,y:n},t)||Xt({x:i,y:o},t))}function $f(s,t,e){let n=[],i=s._pointLabels.length,o=s.options,{centerPointLabels:r,display:a}=o.pointLabels,l={extra:vo(o)/2,additionalAngle:r?nt/i:0},c;for(let d=0;d<i;d++){l.padding=e[d],l.size=t[d];let h=zf(s,d,l);n.push(h),a==="auto"&&(h.visible=Hf(h,c),h.visible&&(c=h))}return n}function Wf(s){return s===0||s===180?"center":s<180?"left":"right"}function jf(s,t,e){return e==="right"?s-=t:e==="center"&&(s-=t/2),s}function Uf(s,t,e){return e===90||e===270?s-=t/2:(e>270||e<90)&&(s-=t),s}function Kf(s,t,e){let{left:n,top:i,right:o,bottom:r}=e,{backdropColor:a}=t;if(!tt(a)){let l=ye(t.borderRadius),c=Ct(t.backdropPadding);s.fillStyle=a;let d=n-c.left,h=i-c.top,u=o-n+c.width,f=r-i+c.height;Object.values(l).some(p=>p!==0)?(s.beginPath(),is(s,{x:d,y:h,w:u,h:f,radius:l}),s.fill()):s.fillRect(d,h,u,f)}}function Yf(s,t){let{ctx:e,options:{pointLabels:n}}=s;for(let i=t-1;i>=0;i--){let o=s._pointLabelItems[i];if(!o.visible)continue;let r=n.setContext(s.getPointLabelContext(i));Kf(e,r,o);let a=bt(r.font),{x:l,y:c,textAlign:d}=o;ve(e,s._pointLabels[i],l,c+a.lineHeight/2,a,{color:r.color,textAlign:d,textBaseline:"middle"})}}function Fl(s,t,e,n){let{ctx:i}=s;if(e)i.arc(s.xCenter,s.yCenter,t,0,dt);else{let o=s.getPointPosition(0,t);i.moveTo(o.x,o.y);for(let r=1;r<n;r++)o=s.getPointPosition(r,t),i.lineTo(o.x,o.y)}}function Gf(s,t,e,n,i){let o=s.ctx,r=t.circular,{color:a,lineWidth:l}=t;!r&&!n||!a||!l||e<0||(o.save(),o.strokeStyle=a,o.lineWidth=l,o.setLineDash(i.dash||[]),o.lineDashOffset=i.dashOffset,o.beginPath(),Fl(s,e,r,n),o.closePath(),o.stroke(),o.restore())}function qf(s,t,e){return le(s,{label:e,index:t,type:"pointLabel"})}function Za(s,t){return s-t}function Ja(s,t){if(tt(t))return null;let e=s._adapter,{parser:n,round:i,isoWeekday:o}=s._parseOpts,r=t;return typeof n=="function"&&(r=n(r)),pt(r)||(r=typeof n=="string"?e.parse(r,n):e.parse(r)),r===null?null:(i&&(r=i==="week"&&(Ae(o)||o===!0)?e.startOf(r,"isoWeek",o):e.startOf(r,i)),+r)}function tl(s,t,e,n){let i=Lt.length;for(let o=Lt.indexOf(s);o<i-1;++o){let r=Qn[Lt[o]],a=r.steps?r.steps:Number.MAX_SAFE_INTEGER;if(r.common&&Math.ceil((e-t)/(a*r.size))<=n)return Lt[o]}return Lt[i-1]}function Xf(s,t,e,n,i){for(let o=Lt.length-1;o>=Lt.indexOf(e);o--){let r=Lt[o];if(Qn[r].common&&s._adapter.diff(i,n,r)>=t-1)return r}return Lt[e?Lt.indexOf(e):0]}function Qf(s){for(let t=Lt.indexOf(s)+1,e=Lt.length;t<e;++t)if(Qn[Lt[t]].common)return Lt[t]}function el(s,t,e){if(!e)s[t]=!0;else if(e.length){let{lo:n,hi:i}=kn(e,t),o=e[n]>=t?e[n]:e[i];s[o]=!0}}function Zf(s,t,e,n){let i=s._adapter,o=+i.startOf(t[0].value,n),r=t[t.length-1].value,a,l;for(a=o;a<=r;a=+i.add(a,1,n))l=e[a],l>=0&&(t[l].major=!0);return t}function sl(s,t,e){let n=[],i={},o=t.length,r,a;for(r=0;r<o;++r)a=t[r],i[a]=r,n.push({value:a,major:!1});return o===0||!e?n:Zf(s,n,i,e)}function zn(s,t,e){let n=0,i=s.length-1,o,r,a,l;e?(t>=s[n].pos&&t<=s[i].pos&&({lo:n,hi:i}=qt(s,"pos",t)),{pos:o,time:a}=s[n],{pos:r,time:l}=s[i]):(t>=s[n].time&&t<=s[i].time&&({lo:n,hi:i}=qt(s,"time",t)),{time:o,pos:a}=s[n],{time:r,pos:l}=s[i]);let c=r-o;return c?a+(l-a)*(t-o)/c:a}var ao,te,ia,Jd,Wn,$s,Zi,ca,dh,Tt,Fe,Ie,se,Ve,Se,as,Ne,Be,ol,lo,rl,al,ll,St,Ws,jn,Hn,Rh,ba,dl,js,va,Kn,At,Xh,ya,xa,ke,ls,co,jt,ho,Ea,gl,Ns,po,mu,vu,yu,$n,La,ee,_e,Iu,Ut,ze,He,xl,mo,Ra,Sl,El,Gn,Ml,Ha,vf,qn,Tl,Us,Ll,Nn,Al,zs,Pl,Hs,Rl,Ol,Af,Rf,cs,fs,ds,Ks,Oe,hs,Ce,Qn,Lt,Ee,us,Il,Jf,Nl=ti(()=>{na();ao=class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,n,i){let o=e.listeners[i],r=e.duration;o.forEach(a=>a({chart:t,initial:e.initial,numSteps:r,currentStep:Math.min(n-e.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=Li.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((n,i)=>{if(!n.running||!n.items.length)return;let o=n.items,r=o.length-1,a=!1,l;for(;r>=0;--r)l=o[r],l._active?(l._total>n.duration&&(n.duration=l._total),l.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(i.draw(),this._notify(i,n,t,"progress")),o.length||(n.running=!1,this._notify(i,n,t,"complete"),n.initial=!1),e+=o.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){let e=this._charts,n=e.get(t);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,n)),n}listen(t,e,n){this._getAnims(t).listeners[e].push(n)}add(t,e){!e||!e.length||this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){let e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((n,i)=>Math.max(n,i._duration),0),this._refresh())}running(t){if(!this._running)return!1;let e=this._charts.get(t);return!(!e||!e.running||!e.items.length)}stop(t){let e=this._charts.get(t);if(!e||!e.items.length)return;let n=e.items,i=n.length-1;for(;i>=0;--i)n[i].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}},te=new ao,ia="transparent",Jd={boolean(s,t,e){return e>.5?t:s},color(s,t,e){let n=Fi(s||ia),i=n.valid&&Fi(t||ia);return i&&i.valid?i.mix(n,e).hexString():t},number(s,t,e){return s+(t-s)*e}},Wn=class{constructor(t,e,n,i){let o=e[n];i=os([t.to,i,o,t.from]);let r=os([t.from,o,i]);this._active=!0,this._fn=t.fn||Jd[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=n,this._from=r,this._to=i,this._promises=void 0}active(){return this._active}update(t,e,n){if(this._active){this._notify(!1);let i=this._target[this._prop],o=n-this._start,r=this._duration-o;this._start=n,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=os([t.to,e,i,t.from]),this._from=os([t.from,i,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){let e=t-this._start,n=this._duration,i=this._prop,o=this._from,r=this._loop,a=this._to,l;if(this._active=o!==a&&(r||e<n),!this._active){this._target[i]=a,this._notify(!0);return}if(e<0){this._target[i]=o;return}l=e/n%2,l=r&&l>1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[i]=this._fn(o,a,l)}wait(){let t=this._promises||(this._promises=[]);return new Promise((e,n)=>{t.push({res:e,rej:n})})}_notify(t){let e=t?"res":"rej",n=this._promises||[];for(let i=0;i<n.length;i++)n[i][e]()}},$s=class{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(!et(t))return;let e=Object.keys(ht.animation),n=this._properties;Object.getOwnPropertyNames(t).forEach(i=>{let o=t[i];if(!et(o))return;let r={};for(let a of e)r[a]=o[a];(ct(o.properties)&&o.properties||[i]).forEach(a=>{(a===i||!n.has(a))&&n.set(a,r)})})}_animateOptions(t,e){let n=e.options,i=eh(t,n);if(!i)return[];let o=this._createAnimations(i,n);return n.$shared&&th(t.options.$animations,n).then(()=>{t.options=n},()=>{}),o}_createAnimations(t,e){let n=this._properties,i=[],o=t.$animations||(t.$animations={}),r=Object.keys(e),a=Date.now(),l;for(l=r.length-1;l>=0;--l){let c=r[l];if(c.charAt(0)==="$")continue;if(c==="options"){i.push(...this._animateOptions(t,e));continue}let d=e[c],h=o[c],u=n.get(c);if(h)if(u&&h.active()){h.update(u,d,a);continue}else h.cancel();if(!u||!u.duration){t[c]=d;continue}o[c]=h=new Wn(u,t,c,d),i.push(h)}return i}update(t,e){if(this._properties.size===0){Object.assign(t,e);return}let n=this._createAnimations(t,e);if(n.length)return te.add(this._chart,n),!0}};Zi=s=>s==="reset"||s==="none",ca=(s,t)=>t?s:Object.assign({},s),dh=(s,t,e)=>s&&!t.hidden&&t._stacked&&{keys:nl(e,!0),values:null},Tt=class{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(){let t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=Xi(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&&Os(this._cachedMeta),this.index=t}linkScales(){let t=this.chart,e=this._cachedMeta,n=this.getDataset(),i=(h,u,f,p)=>h==="x"?u:h==="r"?p:f,o=e.xAxisID=Q(n.xAxisID,Qi(t,"x")),r=e.yAxisID=Q(n.yAxisID,Qi(t,"y")),a=e.rAxisID=Q(n.rAxisID,Qi(t,"r")),l=e.indexAxis,c=e.iAxisID=i(l,o,r,a),d=e.vAxisID=i(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(d)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){let e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){let t=this._cachedMeta;this._data&&Di(this._data,this),t._stacked&&Os(t)}_dataCheck(){let t=this.getDataset(),e=t.data||(t.data=[]),n=this._data;if(et(e)){let i=this._cachedMeta;this._data=ih(e,i)}else if(n!==e){if(n){Di(n,this);let i=this._cachedMeta;Os(i),i._parsed=[]}e&&Object.isExtensible(e)&&Nr(e,this),this._syncList=[],this._data=e}}addElements(){let t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){let e=this._cachedMeta,n=this.getDataset(),i=!1;this._dataCheck();let o=e._stacked;e._stacked=Xi(e.vScale,e),e.stack!==n.stack&&(i=!0,Os(e),e.stack=n.stack),this._resyncElements(t),(i||o!==e._stacked)&&(la(this,e._parsed),e._stacked=Xi(e.vScale,e))}configure(){let t=this.chart.config,e=t.datasetScopeKeys(this._type),n=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){let{_cachedMeta:n,_data:i}=this,{iScale:o,_stacked:r}=n,a=o.axis,l=t===0&&e===i.length?!0:n._sorted,c=t>0&&n._parsed[t-1],d,h,u;if(this._parsing===!1)n._parsed=i,n._sorted=!0,u=i;else{ct(i[t])?u=this.parseArrayData(n,i,t,e):et(i[t])?u=this.parseObjectData(n,i,t,e):u=this.parsePrimitiveData(n,i,t,e);let f=()=>h[a]===null||c&&h[a]<c[a];for(d=0;d<e;++d)n._parsed[d+t]=h=u[d],l&&(f()&&(l=!1),c=h);n._sorted=l}r&&la(this,u)}parsePrimitiveData(t,e,n,i){let{iScale:o,vScale:r}=t,a=o.axis,l=r.axis,c=o.getLabels(),d=o===r,h=new Array(i),u,f,p;for(u=0,f=i;u<f;++u)p=u+n,h[u]={[a]:d||o.parse(c[p],p),[l]:r.parse(e[p],p)};return h}parseArrayData(t,e,n,i){let{xScale:o,yScale:r}=t,a=new Array(i),l,c,d,h;for(l=0,c=i;l<c;++l)d=l+n,h=e[d],a[l]={x:o.parse(h[0],d),y:r.parse(h[1],d)};return a}parseObjectData(t,e,n,i){let{xScale:o,yScale:r}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,c=new Array(i),d,h,u,f;for(d=0,h=i;d<h;++d)u=d+n,f=e[u],c[d]={x:o.parse(ae(f,a),u),y:r.parse(ae(f,l),u)};return c}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,e,n){let i=this.chart,o=this._cachedMeta,r=e[t.axis],a={keys:nl(i,!0),values:e._stacks[t.axis]._visualValues};return ra(a,r,o.index,{mode:n})}updateRangeFromParsed(t,e,n,i){let o=n[e.axis],r=o===null?NaN:o,a=i&&n._stacks[e.axis];i&&a&&(i.values=a,r=ra(i,o,this._cachedMeta.index)),t.min=Math.min(t.min,r),t.max=Math.max(t.max,r)}getMinMax(t,e){let n=this._cachedMeta,i=n._parsed,o=n._sorted&&t===n.iScale,r=i.length,a=this._getOtherScale(t),l=dh(e,n,this.chart),c={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:d,max:h}=rh(a),u,f;function p(){f=i[u];let m=f[a.axis];return!pt(f[t.axis])||d>m||h<m}for(u=0;u<r&&!(!p()&&(this.updateRangeFromParsed(c,t,f,l),o));++u);if(o){for(u=r-1;u>=0;--u)if(!p()){this.updateRangeFromParsed(c,t,f,l);break}}return c}getAllParsedValues(t){let e=this._cachedMeta._parsed,n=[],i,o,r;for(i=0,o=e.length;i<o;++i)r=e[i][t.axis],pt(r)&&n.push(r);return n}getMaxOverflow(){return!1}getLabelAndValue(t){let e=this._cachedMeta,n=e.iScale,i=e.vScale,o=this.getParsed(t);return{label:n?""+n.getLabelForValue(o[n.axis]):"",value:i?""+i.getLabelForValue(o[i.axis]):""}}_update(t){let e=this._cachedMeta;this.update(t||"default"),e._clip=nh(Q(this.options.clip,sh(e.xScale,e.yScale,this.getMaxOverflow())))}update(t){}draw(){let t=this._ctx,e=this.chart,n=this._cachedMeta,i=n.data||[],o=e.chartArea,r=[],a=this._drawStart||0,l=this._drawCount||i.length-a,c=this.options.drawActiveElementsOnTop,d;for(n.dataset&&n.dataset.draw(t,o,a,l),d=a;d<a+l;++d){let h=i[d];h.hidden||(h.active&&c?r.push(h):h.draw(t,o))}for(d=0;d<r.length;++d)r[d].draw(t,o)}getStyle(t,e){let n=e?"active":"default";return t===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(n):this.resolveDataElementOptions(t||0,n)}getContext(t,e,n){let i=this.getDataset(),o;if(t>=0&&t<this._cachedMeta.data.length){let r=this._cachedMeta.data[t];o=r.$context||(r.$context=ch(this.getContext(),t,r)),o.parsed=this.getParsed(t),o.raw=i.data[t],o.index=o.dataIndex=t}else o=this.$context||(this.$context=lh(this.chart.getContext(),this.index)),o.dataset=i,o.index=o.datasetIndex=this.index;return o.active=!!e,o.mode=n,o}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,e){return this._resolveElementOptions(this.dataElementType.id,e,t)}_resolveElementOptions(t,e="default",n){let i=e==="active",o=this._cachedDataOpts,r=t+"-"+e,a=o[r],l=this.enableOptionSharing&&Je(n);if(a)return ca(a,l);let c=this.chart.config,d=c.datasetElementScopeKeys(this._type,t),h=i?[`${t}Hover`,"hover",t,""]:[t,""],u=c.getOptionScopes(this.getDataset(),d),f=Object.keys(ht.elements[t]),p=()=>this.getContext(n,i,e),m=c.resolveNamedOptions(u,f,p,h);return m.$shared&&(m.$shared=l,o[r]=Object.freeze(ca(m,l))),m}_resolveAnimations(t,e,n){let i=this.chart,o=this._cachedDataOpts,r=`animation-${e}`,a=o[r];if(a)return a;let l;if(i.options.animation!==!1){let d=this.chart.config,h=d.datasetAnimationScopeKeys(this._type,e),u=d.getOptionScopes(this.getDataset(),h);l=d.createResolver(u,this.getContext(t,n,e))}let c=new $s(i,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||Zi(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){let n=this.resolveDataElementOptions(t,e),i=this._sharedOptions,o=this.getSharedOptions(n),r=this.includeOptions(e,o)||o!==i;return this.updateSharedOptions(o,e,n),{sharedOptions:o,includeOptions:r}}updateElement(t,e,n,i){Zi(i)?Object.assign(t,n):this._resolveAnimations(e,i).update(t,n)}updateSharedOptions(t,e,n){t&&!Zi(e)&&this._resolveAnimations(void 0,e).update(t,n)}_setStyle(t,e,n,i){t.active=i;let o=this.getStyle(e,i);this._resolveAnimations(e,n,i).update(t,{options:!i&&this.getSharedOptions(o)||o})}removeHoverStyle(t,e,n){this._setStyle(t,n,"active",!1)}setHoverStyle(t,e,n){this._setStyle(t,n,"active",!0)}_removeDatasetHoverStyle(){let t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){let t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){let e=this._data,n=this._cachedMeta.data;for(let[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];let i=n.length,o=e.length,r=Math.min(o,i);r&&this.parse(0,r),o>i?this._insertElements(i,o-i,t):o<i&&this._removeElements(o,i-o)}_insertElements(t,e,n=!0){let i=this._cachedMeta,o=i.data,r=t+e,a,l=c=>{for(c.length+=e,a=c.length-1;a>=r;a--)c[a]=c[a-e]};for(l(o),a=t;a<r;++a)o[a]=new this.dataElementType;this._parsing&&l(i._parsed),this.parse(t,e),n&&this.updateElements(o,t,e,"reset")}updateElements(t,e,n,i){}_removeElements(t,e){let n=this._cachedMeta;if(this._parsing){let i=n._parsed.splice(t,e);n._stacked&&Os(n,i)}n.data.splice(t,e)}_sync(t){if(this._parsing)this._syncList.push(t);else{let[e,n,i]=t;this[e](n,i)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){let t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,e){e&&this._sync(["_removeElements",t,e]);let n=arguments.length-2;n&&this._sync(["_insertElements",t,n])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}};H(Tt,"defaults",{}),H(Tt,"datasetElementType",null),H(Tt,"dataElementType",null);Fe=class extends Tt{parsePrimitiveData(t,e,n,i){return da(t,e,n,i)}parseArrayData(t,e,n,i){return da(t,e,n,i)}parseObjectData(t,e,n,i){let{iScale:o,vScale:r}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,c=o.axis==="x"?a:l,d=r.axis==="x"?a:l,h=[],u,f,p,m;for(u=n,f=n+i;u<f;++u)m=e[u],p={},p[o.axis]=o.parse(ae(m,c),u),h.push(il(ae(m,d),p,r,u));return h}updateRangeFromParsed(t,e,n,i){super.updateRangeFromParsed(t,e,n,i);let o=n._custom;o&&e===this._cachedMeta.vScale&&(t.min=Math.min(t.min,o.min),t.max=Math.max(t.max,o.max))}getMaxOverflow(){return 0}getLabelAndValue(t){let e=this._cachedMeta,{iScale:n,vScale:i}=e,o=this.getParsed(t),r=o._custom,a=Ji(r)?"["+r.start+", "+r.end+"]":""+i.getLabelForValue(o[i.axis]);return{label:""+n.getLabelForValue(o[n.axis]),value:a}}initialize(){this.enableOptionSharing=!0,super.initialize();let t=this._cachedMeta;t.stack=this.getDataset().stack}update(t){let e=this._cachedMeta;this.updateElements(e.data,0,e.data.length,t)}updateElements(t,e,n,i){let o=i==="reset",{index:r,_cachedMeta:{vScale:a}}=this,l=a.getBasePixel(),c=a.isHorizontal(),d=this._getRuler(),{sharedOptions:h,includeOptions:u}=this._getSharedOptions(e,i);for(let f=e;f<e+n;f++){let p=this.getParsed(f),m=o||tt(p[a.axis])?{base:l,head:l}:this._calculateBarValuePixels(f),g=this._calculateBarIndexPixels(f,d),b=(p._stacks||{})[a.axis],x={horizontal:c,base:m.base,enableBorderRadius:!b||Ji(p._custom)||r===b._top||r===b._bottom,x:c?m.head:g.center,y:c?g.center:m.head,height:c?g.size:Math.abs(m.size),width:c?Math.abs(m.size):g.size};u&&(x.options=h||this.resolveDataElementOptions(f,t[f].active?"active":i));let _=x.options||t[f].options;vh(x,_,b,r),xh(x,_,d.ratio),this.updateElement(t[f],f,x,i)}}_getStacks(t,e){let{iScale:n}=this._cachedMeta,i=n.getMatchingVisibleMetas(this._type).filter(d=>d.controller.options.grouped),o=n.options.stacked,r=[],a=this._cachedMeta.controller.getParsed(e),l=a&&a[n.axis],c=d=>{let h=d._parsed.find(f=>f[n.axis]===l),u=h&&h[d.vScale.axis];if(tt(u)||isNaN(u))return!0};for(let d of i)if(!(e!==void 0&&c(d))&&((o===!1||r.indexOf(d.stack)===-1||o===void 0&&d.stack===void 0)&&r.push(d.stack),d.index===t))break;return r.length||r.push(void 0),r}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let t=this.chart.scales,e=this.chart.options.indexAxis;return Object.keys(t).filter(n=>t[n].axis===e).shift()}_getAxis(){let t={},e=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)t[Q(this.chart.options.indexAxis==="x"?n.xAxisID:n.yAxisID,e)]=!0;return Object.keys(t)}_getStackIndex(t,e,n){let i=this._getStacks(t,n),o=e!==void 0?i.indexOf(e):-1;return o===-1?i.length-1:o}_getRuler(){let t=this.options,e=this._cachedMeta,n=e.iScale,i=[],o,r;for(o=0,r=e.data.length;o<r;++o)i.push(n.getPixelForValue(this.getParsed(o)[n.axis],o));let a=t.barThickness;return{min:a||uh(e),pixels:i,start:n._startPixel,end:n._endPixel,stackCount:this._getStackCount(),scale:n,grouped:t.grouped,ratio:a?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){let{_cachedMeta:{vScale:e,_stacked:n,index:i},options:{base:o,minBarLength:r}}=this,a=o||0,l=this.getParsed(t),c=l._custom,d=Ji(c),h=l[e.axis],u=0,f=n?this.applyStack(e,l,n):h,p,m;f!==h&&(u=f-h,f=h),d&&(h=c.barStart,f=c.barEnd-c.barStart,h!==0&&Wt(h)!==Wt(c.barEnd)&&(u=0),u+=h);let g=!tt(o)&&!d?o:u,b=e.getPixelForValue(g);if(this.chart.getDataVisibility(t)?p=e.getPixelForValue(u+f):p=b,m=p-b,Math.abs(m)<r){m=mh(m,e,a)*r,h===a&&(b-=m/2);let x=e.getPixelForDecimal(0),_=e.getPixelForDecimal(1),E=Math.min(x,_),w=Math.max(x,_);b=Math.max(Math.min(b,w),E),p=b+m,n&&!d&&(l._stacks[e.axis]._visualValues[i]=e.getValueForPixel(p)-e.getValueForPixel(b))}if(b===e.getPixelForValue(a)){let x=Wt(m)*e.getLineWidthForValue(a)/2;b+=x,m-=x}return{size:m,base:b,head:p,center:p+m/2}}_calculateBarIndexPixels(t,e){let n=e.scale,i=this.options,o=i.skipNull,r=Q(i.maxBarThickness,1/0),a,l,c=this._getAxisCount();if(e.grouped){let d=o?this._getStackCount(t):e.stackCount,h=i.barThickness==="flex"?ph(t,e,i,d*c):fh(t,e,i,d*c),u=this.chart.options.indexAxis==="x"?this.getDataset().xAxisID:this.getDataset().yAxisID,f=this._getAxis().indexOf(Q(u,this.getFirstScaleIdForIndexAxis())),p=this._getStackIndex(this.index,this._cachedMeta.stack,o?t:void 0)+f;a=h.start+h.chunk*p+h.chunk/2,l=Math.min(r,h.chunk*h.ratio)}else a=n.getPixelForValue(this.getParsed(t)[n.axis],t),l=Math.min(r,e.min*e.ratio);return{base:a-l/2,head:a+l/2,center:a,size:l}}draw(){let t=this._cachedMeta,e=t.vScale,n=t.data,i=n.length,o=0;for(;o<i;++o)this.getParsed(o)[e.axis]!==null&&!n[o].hidden&&n[o].draw(this._ctx)}};H(Fe,"id","bar"),H(Fe,"defaults",{datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}}),H(Fe,"overrides",{scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}});Ie=class extends Tt{initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(t,e,n,i){let o=super.parsePrimitiveData(t,e,n,i);for(let r=0;r<o.length;r++)o[r]._custom=this.resolveDataElementOptions(r+n).radius;return o}parseArrayData(t,e,n,i){let o=super.parseArrayData(t,e,n,i);for(let r=0;r<o.length;r++){let a=e[n+r];o[r]._custom=Q(a[2],this.resolveDataElementOptions(r+n).radius)}return o}parseObjectData(t,e,n,i){let o=super.parseObjectData(t,e,n,i);for(let r=0;r<o.length;r++){let a=e[n+r];o[r]._custom=Q(a&&a.r&&+a.r,this.resolveDataElementOptions(r+n).radius)}return o}getMaxOverflow(){let t=this._cachedMeta.data,e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}getLabelAndValue(t){let e=this._cachedMeta,n=this.chart.data.labels||[],{xScale:i,yScale:o}=e,r=this.getParsed(t),a=i.getLabelForValue(r.x),l=o.getLabelForValue(r.y),c=r._custom;return{label:n[t]||"",value:"("+a+", "+l+(c?", "+c:"")+")"}}update(t){let e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,n,i){let o=i==="reset",{iScale:r,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:c}=this._getSharedOptions(e,i),d=r.axis,h=a.axis;for(let u=e;u<e+n;u++){let f=t[u],p=!o&&this.getParsed(u),m={},g=m[d]=o?r.getPixelForDecimal(.5):r.getPixelForValue(p[d]),b=m[h]=o?a.getBasePixel():a.getPixelForValue(p[h]);m.skip=isNaN(g)||isNaN(b),c&&(m.options=l||this.resolveDataElementOptions(u,f.active?"active":i),o&&(m.options.radius=0)),this.updateElement(f,u,m,i)}}resolveDataElementOptions(t,e){let n=this.getParsed(t),i=super.resolveDataElementOptions(t,e);i.$shared&&(i=Object.assign({},i,{$shared:!1}));let o=i.radius;return e!=="active"&&(i.radius=0),i.radius+=Q(n&&n._custom,o),i}};H(Ie,"id","bubble"),H(Ie,"defaults",{datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}}),H(Ie,"overrides",{scales:{x:{type:"linear"},y:{type:"linear"}}});se=class extends Tt{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){let n=this.getDataset().data,i=this._cachedMeta;if(this._parsing===!1)i._parsed=n;else{let o=l=>+n[l];if(et(n[t])){let{key:l="value"}=this._parsing;o=c=>+ae(n[c],l)}let r,a;for(r=t,a=t+e;r<a;++r)i._parsed[r]=o(r)}}_getRotation(){return zt(this.options.rotation-90)}_getCircumference(){return zt(this.options.circumference)}_getRotationExtents(){let t=dt,e=-dt;for(let n=0;n<this.chart.data.datasets.length;++n)if(this.chart.isDatasetVisible(n)&&this.chart.getDatasetMeta(n).type===this._type){let i=this.chart.getDatasetMeta(n).controller,o=i._getRotation(),r=i._getCircumference();t=Math.min(t,o),e=Math.max(e,o+r)}return{rotation:t,circumference:e-t}}update(t){let e=this.chart,{chartArea:n}=e,i=this._cachedMeta,o=i.data,r=this.getMaxBorderWidth()+this.getMaxOffset(o)+this.options.spacing,a=Math.max((Math.min(n.width,n.height)-r)/2,0),l=Math.min(Tr(this.options.cutout,a),1),c=this._getRingWeight(this.index),{circumference:d,rotation:h}=this._getRotationExtents(),{ratioX:u,ratioY:f,offsetX:p,offsetY:m}=_h(h,d,l),g=(n.width-r)/u,b=(n.height-r)/f,x=Math.max(Math.min(g,b)/2,0),_=Ci(this.options.radius,x),E=Math.max(_*l,0),w=(_-E)/this._getVisibleDatasetWeightTotal();this.offsetX=p*_,this.offsetY=m*_,i.total=this.calculateTotal(),this.outerRadius=_-w*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-w*c,0),this.updateElements(o,0,o.length,t)}_circumference(t,e){let n=this.options,i=this._cachedMeta,o=this._getCircumference();return e&&n.animation.animateRotate||!this.chart.getDataVisibility(t)||i._parsed[t]===null||i.data[t].hidden?0:this.calculateCircumference(i._parsed[t]*o/dt)}updateElements(t,e,n,i){let o=i==="reset",r=this.chart,a=r.chartArea,c=r.options.animation,d=(a.left+a.right)/2,h=(a.top+a.bottom)/2,u=o&&c.animateScale,f=u?0:this.innerRadius,p=u?0:this.outerRadius,{sharedOptions:m,includeOptions:g}=this._getSharedOptions(e,i),b=this._getRotation(),x;for(x=0;x<e;++x)b+=this._circumference(x,o);for(x=e;x<e+n;++x){let _=this._circumference(x,o),E=t[x],w={x:d+this.offsetX,y:h+this.offsetY,startAngle:b,endAngle:b+_,circumference:_,outerRadius:p,innerRadius:f};g&&(w.options=m||this.resolveDataElementOptions(x,E.active?"active":i)),b+=_,this.updateElement(E,x,w,i)}}calculateTotal(){let t=this._cachedMeta,e=t.data,n=0,i;for(i=0;i<e.length;i++){let o=t._parsed[i];o!==null&&!isNaN(o)&&this.chart.getDataVisibility(i)&&!e[i].hidden&&(n+=Math.abs(o))}return n}calculateCircumference(t){let e=this._cachedMeta.total;return e>0&&!isNaN(t)?dt*(Math.abs(t)/e):0}getLabelAndValue(t){let e=this._cachedMeta,n=this.chart,i=n.data.labels||[],o=ss(e._parsed[t],n.options.locale);return{label:i[t]||"",value:o}}getMaxBorderWidth(t){let e=0,n=this.chart,i,o,r,a,l;if(!t){for(i=0,o=n.data.datasets.length;i<o;++i)if(n.isDatasetVisible(i)){r=n.getDatasetMeta(i),t=r.data,a=r.controller;break}}if(!t)return 0;for(i=0,o=t.length;i<o;++i)l=a.resolveDataElementOptions(i),l.borderAlign!=="inner"&&(e=Math.max(e,l.borderWidth||0,l.hoverBorderWidth||0));return e}getMaxOffset(t){let e=0;for(let n=0,i=t.length;n<i;++n){let o=this.resolveDataElementOptions(n);e=Math.max(e,o.offset||0,o.hoverOffset||0)}return e}_getRingWeightOffset(t){let e=0;for(let n=0;n<t;++n)this.chart.isDatasetVisible(n)&&(e+=this._getRingWeight(n));return e}_getRingWeight(t){return Math.max(Q(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}};H(se,"id","doughnut"),H(se,"defaults",{datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"}),H(se,"descriptors",{_scriptable:t=>t!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")}),H(se,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){let e=t.data,{labels:{pointStyle:n,textAlign:i,color:o,useBorderRadius:r,borderRadius:a}}=t.legend.options;return e.labels.length&&e.datasets.length?e.labels.map((l,c)=>{let h=t.getDatasetMeta(0).controller.getStyle(c);return{text:l,fillStyle:h.backgroundColor,fontColor:o,hidden:!t.getDataVisibility(c),lineDash:h.borderDash,lineDashOffset:h.borderDashOffset,lineJoin:h.borderJoinStyle,lineWidth:h.borderWidth,strokeStyle:h.borderColor,textAlign:i,pointStyle:n,borderRadius:r&&(a||h.borderRadius),index:c}}):[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.chart.update()}}}});Ve=class extends Tt{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){let e=this._cachedMeta,{dataset:n,data:i=[],_dataset:o}=e,r=this.chart._animationsDisabled,{start:a,count:l}=Pi(e,i,r);this._drawStart=a,this._drawCount=l,Ri(e)&&(a=0,l=i.length),n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!o._decimated,n.points=i;let c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(n,void 0,{animated:!r,options:c},t),this.updateElements(i,a,l,t)}updateElements(t,e,n,i){let o=i==="reset",{iScale:r,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:d,includeOptions:h}=this._getSharedOptions(e,i),u=r.axis,f=a.axis,{spanGaps:p,segment:m}=this.options,g=Ae(p)?p:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||o||i==="none",x=e+n,_=t.length,E=e>0&&this.getParsed(e-1);for(let w=0;w<_;++w){let v=t[w],y=b?v:{};if(w<e||w>=x){y.skip=!0;continue}let S=this.getParsed(w),D=tt(S[f]),M=y[u]=r.getPixelForValue(S[u],w),C=y[f]=o||D?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,S,l):S[f],w);y.skip=isNaN(M)||isNaN(C)||D,y.stop=w>0&&Math.abs(S[u]-E[u])>g,m&&(y.parsed=S,y.raw=c.data[w]),h&&(y.options=d||this.resolveDataElementOptions(w,v.active?"active":i)),b||this.updateElement(v,w,y,i),E=S}}getMaxOverflow(){let t=this._cachedMeta,e=t.dataset,n=e.options&&e.options.borderWidth||0,i=t.data||[];if(!i.length)return n;let o=i[0].size(this.resolveDataElementOptions(0)),r=i[i.length-1].size(this.resolveDataElementOptions(i.length-1));return Math.max(n,o,r)/2}draw(){let t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}};H(Ve,"id","line"),H(Ve,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),H(Ve,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});Se=class extends Tt{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){let e=this._cachedMeta,n=this.chart,i=n.data.labels||[],o=ss(e._parsed[t].r,n.options.locale);return{label:i[t]||"",value:o}}parseObjectData(t,e,n,i){return $i.bind(this)(t,e,n,i)}update(t){let e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){let t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((n,i)=>{let o=this.getParsed(i).r;!isNaN(o)&&this.chart.getDataVisibility(i)&&(o<e.min&&(e.min=o),o>e.max&&(e.max=o))}),e}_updateRadius(){let t=this.chart,e=t.chartArea,n=t.options,i=Math.min(e.right-e.left,e.bottom-e.top),o=Math.max(i/2,0),r=Math.max(n.cutoutPercentage?o/100*n.cutoutPercentage:1,0),a=(o-r)/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,e,n,i){let o=i==="reset",r=this.chart,l=r.options.animation,c=this._cachedMeta.rScale,d=c.xCenter,h=c.yCenter,u=c.getIndexAngle(0)-.5*nt,f=u,p,m=360/this.countVisibleElements();for(p=0;p<e;++p)f+=this._computeAngle(p,i,m);for(p=e;p<e+n;p++){let g=t[p],b=f,x=f+this._computeAngle(p,i,m),_=r.getDataVisibility(p)?c.getDistanceFromCenterForValue(this.getParsed(p).r):0;f=x,o&&(l.animateScale&&(_=0),l.animateRotate&&(b=x=u));let E={x:d,y:h,innerRadius:0,outerRadius:_,startAngle:b,endAngle:x,options:this.resolveDataElementOptions(p,g.active?"active":i)};this.updateElement(g,p,E,i)}}countVisibleElements(){let t=this._cachedMeta,e=0;return t.data.forEach((n,i)=>{!isNaN(this.getParsed(i).r)&&this.chart.getDataVisibility(i)&&e++}),e}_computeAngle(t,e,n){return this.chart.getDataVisibility(t)?zt(this.resolveDataElementOptions(t,e).angle||n):0}};H(Se,"id","polarArea"),H(Se,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),H(Se,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){let e=t.data;if(e.labels.length&&e.datasets.length){let{labels:{pointStyle:n,color:i}}=t.legend.options;return e.labels.map((o,r)=>{let l=t.getDatasetMeta(0).controller.getStyle(r);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:i,lineWidth:l.borderWidth,pointStyle:n,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,e,n){n.chart.toggleDataVisibility(e.index),n.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});as=class extends se{};H(as,"id","pie"),H(as,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});Ne=class extends Tt{getLabelAndValue(t){let e=this._cachedMeta.vScale,n=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(n[e.axis])}}parseObjectData(t,e,n,i){return $i.bind(this)(t,e,n,i)}update(t){let e=this._cachedMeta,n=e.dataset,i=e.data||[],o=e.iScale.getLabels();if(n.points=i,t!=="resize"){let r=this.resolveDatasetElementOptions(t);this.options.showLine||(r.borderWidth=0);let a={_loop:!0,_fullLoop:o.length===i.length,options:r};this.updateElement(n,void 0,a,t)}this.updateElements(i,0,i.length,t)}updateElements(t,e,n,i){let o=this._cachedMeta.rScale,r=i==="reset";for(let a=e;a<e+n;a++){let l=t[a],c=this.resolveDataElementOptions(a,l.active?"active":i),d=o.getPointPositionForValue(a,this.getParsed(a).r),h=r?o.xCenter:d.x,u=r?o.yCenter:d.y,f={x:h,y:u,angle:d.angle,skip:isNaN(h)||isNaN(u),options:c};this.updateElement(l,a,f,i)}}};H(Ne,"id","radar"),H(Ne,"defaults",{datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}}),H(Ne,"overrides",{aspectRatio:1,scales:{r:{type:"radialLinear"}}});Be=class extends Tt{getLabelAndValue(t){let e=this._cachedMeta,n=this.chart.data.labels||[],{xScale:i,yScale:o}=e,r=this.getParsed(t),a=i.getLabelForValue(r.x),l=o.getLabelForValue(r.y);return{label:n[t]||"",value:"("+a+", "+l+")"}}update(t){let e=this._cachedMeta,{data:n=[]}=e,i=this.chart._animationsDisabled,{start:o,count:r}=Pi(e,n,i);if(this._drawStart=o,this._drawCount=r,Ri(e)&&(o=0,r=n.length),this.options.showLine){this.datasetElementType||this.addElements();let{dataset:a,_dataset:l}=e;a._chart=this.chart,a._datasetIndex=this.index,a._decimated=!!l._decimated,a.points=n;let c=this.resolveDatasetElementOptions(t);c.segment=this.options.segment,this.updateElement(a,void 0,{animated:!i,options:c},t)}else this.datasetElementType&&(delete e.dataset,this.datasetElementType=!1);this.updateElements(n,o,r,t)}addElements(){let{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,e,n,i){let o=i==="reset",{iScale:r,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,d=this.resolveDataElementOptions(e,i),h=this.getSharedOptions(d),u=this.includeOptions(i,h),f=r.axis,p=a.axis,{spanGaps:m,segment:g}=this.options,b=Ae(m)?m:Number.POSITIVE_INFINITY,x=this.chart._animationsDisabled||o||i==="none",_=e>0&&this.getParsed(e-1);for(let E=e;E<e+n;++E){let w=t[E],v=this.getParsed(E),y=x?w:{},S=tt(v[p]),D=y[f]=r.getPixelForValue(v[f],E),M=y[p]=o||S?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,v,l):v[p],E);y.skip=isNaN(D)||isNaN(M)||S,y.stop=E>0&&Math.abs(v[f]-_[f])>b,g&&(y.parsed=v,y.raw=c.data[E]),u&&(y.options=h||this.resolveDataElementOptions(E,w.active?"active":i)),x||this.updateElement(w,E,y,i),_=v}this.updateSharedOptions(h,i,d)}getMaxOverflow(){let t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let a=0;for(let l=e.length-1;l>=0;--l)a=Math.max(a,e[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}let n=t.dataset,i=n.options&&n.options.borderWidth||0;if(!e.length)return i;let o=e[0].size(this.resolveDataElementOptions(0)),r=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(i,o,r)/2}};H(Be,"id","scatter"),H(Be,"defaults",{datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1}),H(Be,"overrides",{interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}});ol=Object.freeze({__proto__:null,BarController:Fe,BubbleController:Ie,DoughnutController:se,LineController:Ve,PieController:as,PolarAreaController:Se,RadarController:Ne,ScatterController:Be});lo=class s{constructor(t){H(this,"options");this.options=t||{}}static override(t){Object.assign(s.prototype,t)}init(){}formats(){return Re()}parse(){return Re()}format(){return Re()}add(){return Re()}diff(){return Re()}startOf(){return Re()}endOf(){return Re()}},rl={_date:lo};al={evaluateInteractionItems:Ys,modes:{index(s,t,e,n){let i=xe(t,s),o=e.axis||"x",r=e.includeInvisible||!1,a=e.intersect?to(s,i,o,n,r):eo(s,i,o,!1,n,r),l=[];return a.length?(s.getSortedVisibleDatasetMetas().forEach(c=>{let d=a[0].index,h=c.data[d];h&&!h.skip&&l.push({element:h,datasetIndex:c.index,index:d})}),l):[]},dataset(s,t,e,n){let i=xe(t,s),o=e.axis||"xy",r=e.includeInvisible||!1,a=e.intersect?to(s,i,o,n,r):eo(s,i,o,!1,n,r);if(a.length>0){let l=a[0].datasetIndex,c=s.getDatasetMeta(l).data;a=[];for(let d=0;d<c.length;++d)a.push({element:c[d],datasetIndex:l,index:d})}return a},point(s,t,e,n){let i=xe(t,s),o=e.axis||"xy",r=e.includeInvisible||!1;return to(s,i,o,n,r)},nearest(s,t,e,n){let i=xe(t,s),o=e.axis||"xy",r=e.includeInvisible||!1;return eo(s,i,o,e.intersect,n,r)},x(s,t,e,n){let i=xe(t,s);return fa(s,i,"x",e.intersect,n)},y(s,t,e,n){let i=xe(t,s);return fa(s,i,"y",e.intersect,n)}}},ll=["left","top","right","bottom"];St={addBox(s,t){s.boxes||(s.boxes=[]),t.fullSize=t.fullSize||!1,t.position=t.position||"top",t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(e){t.draw(e)}}]},s.boxes.push(t)},removeBox(s,t){let e=s.boxes?s.boxes.indexOf(t):-1;e!==-1&&s.boxes.splice(e,1)},configure(s,t,e){t.fullSize=e.fullSize,t.position=e.position,t.weight=e.weight},update(s,t,e,n){if(!s)return;let i=Ct(s.options.layout.padding),o=Math.max(t-i.width,0),r=Math.max(e-i.height,0),a=Th(s.boxes),l=a.vertical,c=a.horizontal;ot(s.boxes,m=>{typeof m.beforeLayout=="function"&&m.beforeLayout()});let d=l.reduce((m,g)=>g.box.options&&g.box.options.display===!1?m:m+1,0)||1,h=Object.freeze({outerWidth:t,outerHeight:e,padding:i,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/d,hBoxMaxHeight:r/2}),u=Object.assign({},i);cl(u,Ct(n));let f=Object.assign({maxPadding:u,w:o,h:r,x:i.left,y:i.top},i),p=Dh(l.concat(c),h);Bs(a.fullSize,f,h,p),Bs(l,f,h,p),Bs(c,f,h,p)&&Bs(l,f,h,p),Ah(f),ma(a.leftAndTop,f,h,p),f.x+=f.w,f.y+=f.h,ma(a.rightAndBottom,f,h,p),s.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},ot(a.chartArea,m=>{let g=m.box;Object.assign(g,s.chartArea),g.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}},Ws=class{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,n){}removeEventListener(t,e,n){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,n,i){return e=Math.max(0,e||t.width),n=n||t.height,{width:e,height:Math.max(0,i?Math.floor(e/i):n)}}isAttached(t){return!0}updateConfig(t){}},jn=class extends Ws{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}},Hn="$chartjs",Rh={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},ba=s=>s===null||s==="";dl=Zr?{passive:!0}:!1;js=new Map,va=0;Kn=class extends Ws{acquireContext(t,e){let n=t&&t.getContext&&t.getContext("2d");return n&&n.canvas===t?(Oh(t,e),n):null}releaseContext(t){let e=t.canvas;if(!e[Hn])return!1;let n=e[Hn].initial;["height","width"].forEach(o=>{let r=n[o];tt(r)?e.removeAttribute(o):e.setAttribute(o,r)});let i=n.style||{};return Object.keys(i).forEach(o=>{e.style[o]=i[o]}),e.width=e.width,delete e[Hn],!0}addEventListener(t,e,n){this.removeEventListener(t,e);let i=t.$proxies||(t.$proxies={}),r={attach:Nh,detach:Bh,resize:$h}[e]||Wh;i[e]=r(t,e,n)}removeEventListener(t,e){let n=t.$proxies||(t.$proxies={}),i=n[e];if(!i)return;({attach:so,detach:so,resize:so}[e]||Ih)(t,e,i),n[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,n,i){return Qr(t,e,n,i)}isAttached(t){let e=t&&Rn(t);return!!(e&&e.isConnected)}};At=class{constructor(){H(this,"x");H(this,"y");H(this,"active",!1);H(this,"options");H(this,"$animations")}tooltipPosition(t){let{x:e,y:n}=this.getProps(["x","y"],t);return{x:e,y:n}}hasValue(){return Ae(this.x)&&Ae(this.y)}getProps(t,e){let n=this.$animations;if(!e||!n)return this;let i={};return t.forEach(o=>{i[o]=n[o]&&n[o].active()?n[o]._to:this[o]}),i}};H(At,"defaults",{}),H(At,"defaultRoutes");Xh=s=>s==="left"?"right":s==="right"?"left":s,ya=(s,t,e)=>t==="top"||t==="left"?s[t]+e:s[t]-e,xa=(s,t)=>Math.min(t||s,s);ke=class s extends At{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:n,_suggestedMax:i}=this;return t=Mt(t,Number.POSITIVE_INFINITY),e=Mt(e,Number.NEGATIVE_INFINITY),n=Mt(n,Number.POSITIVE_INFINITY),i=Mt(i,Number.NEGATIVE_INFINITY),{min:Mt(t,n),max:Mt(e,i),minDefined:pt(t),maxDefined:pt(e)}}getMinMax(t){let{min:e,max:n,minDefined:i,maxDefined:o}=this.getUserBounds(),r;if(i&&o)return{min:e,max:n};let a=this.getMatchingVisibleMetas();for(let l=0,c=a.length;l<c;++l)r=a[l].controller.getMinMax(this,t),i||(e=Math.min(e,r.min)),o||(n=Math.max(n,r.max));return e=o&&e>n?n:e,n=i&&e>n?e:n,{min:Mt(e,Mt(n,e)),max:Mt(n,Mt(e,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let 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(){lt(this.options.beforeUpdate,[this])}update(t,e,n){let{beginAtZero:i,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Ur(this,o,i),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let l=a<this.ticks.length;this._convertTicksToLabels(l?_a(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),r.display&&(r.autoSkip||r.source==="auto")&&(this.ticks=jh(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),l&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t=this.options.reverse,e,n;this.isHorizontal()?(e=this.left,n=this.right):(e=this.top,n=this.bottom,t=!t),this._startPixel=e,this._endPixel=n,this._reversePixels=t,this._length=n-e,this._alignToPixels=this.options.alignToPixels}afterUpdate(){lt(this.options.afterUpdate,[this])}beforeSetDimensions(){lt(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){lt(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),lt(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){lt(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){let e=this.options.ticks,n,i,o;for(n=0,i=t.length;n<i;n++)o=t[n],o.label=lt(e.callback,[o.value,n,t],this)}afterTickToLabelConversion(){lt(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){lt(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){let t=this.options,e=t.ticks,n=xa(this.ticks.length,t.ticks.maxTicksLimit),i=e.minRotation||0,o=e.maxRotation,r=i,a,l,c;if(!this._isVisible()||!e.display||i>=o||n<=1||!this.isHorizontal()){this.labelRotation=i;return}let d=this._getLabelSizes(),h=d.widest.width,u=d.highest.height,f=vt(this.chart.width-h,0,this.maxWidth);a=t.offset?this.maxWidth/n:f/(n-1),h+6>a&&(a=f/(n-(t.offset?.5:1)),l=this.maxHeight-Vs(t.grid)-e.padding-Ca(t.title,this.chart.options.font),c=Math.sqrt(h*h+u*u),r=En(Math.min(Math.asin(vt((d.highest.height+6)/a,-1,1)),Math.asin(vt(l/c,-1,1))-Math.asin(vt(u/c,-1,1)))),r=Math.max(i,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){lt(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){lt(this.options.beforeFit,[this])}fit(){let t={width:0,height:0},{chart:e,options:{ticks:n,title:i,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){let l=Ca(i,e.options.font);if(a?(t.width=this.maxWidth,t.height=Vs(o)+l):(t.height=this.maxHeight,t.width=Vs(o)+l),n.display&&this.ticks.length){let{first:c,last:d,widest:h,highest:u}=this._getLabelSizes(),f=n.padding*2,p=zt(this.labelRotation),m=Math.cos(p),g=Math.sin(p);if(a){let b=n.mirror?0:g*h.width+m*u.height;t.height=Math.min(this.maxHeight,t.height+b+f)}else{let b=n.mirror?0:m*h.width+g*u.height;t.width=Math.min(this.maxWidth,t.width+b+f)}this._calculatePadding(c,d,g,m)}}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,n,i){let{ticks:{align:o,padding:r},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){let d=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1),u=0,f=0;l?c?(u=i*t.width,f=n*e.height):(u=n*t.height,f=i*e.width):o==="start"?f=e.width:o==="end"?u=t.width:o!=="inner"&&(u=t.width/2,f=e.width/2),this.paddingLeft=Math.max((u-d+r)*this.width/(this.width-d),0),this.paddingRight=Math.max((f-h+r)*this.width/(this.width-h),0)}else{let d=e.height/2,h=t.height/2;o==="start"?(d=0,h=t.height):o==="end"&&(d=e.height,h=0),this.paddingTop=d+r,this.paddingBottom=h+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(){lt(this.options.afterFit,[this])}isHorizontal(){let{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,n;for(e=0,n=t.length;e<n;e++)tt(t[e].label)&&(t.splice(e,1),n--,e--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){let e=this.options.ticks.sampleSize,n=this.ticks;e<n.length&&(n=_a(n,e)),this._labelSizes=t=this._computeLabelSizes(n,n.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,e,n){let{ctx:i,_longestTextCache:o}=this,r=[],a=[],l=Math.floor(e/xa(e,n)),c=0,d=0,h,u,f,p,m,g,b,x,_,E,w;for(h=0;h<e;h+=l){if(p=t[h].label,m=this._resolveTickFontOptions(h),i.font=g=m.string,b=o[g]=o[g]||{data:{},gc:[]},x=m.lineHeight,_=E=0,!tt(p)&&!ct(p))_=Ls(i,b.data,b.gc,_,p),E=x;else if(ct(p))for(u=0,f=p.length;u<f;++u)w=p[u],!tt(w)&&!ct(w)&&(_=Ls(i,b.data,b.gc,_,w),E+=x);r.push(_),a.push(E),c=Math.max(_,c),d=Math.max(E,d)}Zh(o,e);let v=r.indexOf(c),y=a.indexOf(d),S=D=>({width:r[D]||0,height:a[D]||0});return{first:S(0),last:S(e-1),widest:S(v),highest:S(y),widths:r,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){let e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);let e=this._startPixel+t*this._length;return Or(this._alignToPixels?be(this.chart,e,0):e)}getDecimalForPixel(t){let e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){let e=this.ticks||[];if(t>=0&&t<e.length){let n=e[t];return n.$context||(n.$context=tu(this.getContext(),t,n))}return this.$context||(this.$context=Jh(this.chart.getContext(),this))}_tickSize(){let t=this.options.ticks,e=zt(this.labelRotation),n=Math.abs(Math.cos(e)),i=Math.abs(Math.sin(e)),o=this._getLabelSizes(),r=t.autoSkipPadding||0,a=o?o.widest.width+r:0,l=o?o.highest.height+r:0;return this.isHorizontal()?l*n>a*i?a/n:l/i:l*i<a*n?l/n:a/i}_isVisible(){let t=this.options.display;return t!=="auto"?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){let e=this.axis,n=this.chart,i=this.options,{grid:o,position:r,border:a}=i,l=o.offset,c=this.isHorizontal(),h=this.ticks.length+(l?1:0),u=Vs(o),f=[],p=a.setContext(this.getContext()),m=p.display?p.width:0,g=m/2,b=function(O){return be(n,O,m)},x,_,E,w,v,y,S,D,M,C,T,k;if(r==="top")x=b(this.bottom),y=this.bottom-u,D=x-g,C=b(t.top)+g,k=t.bottom;else if(r==="bottom")x=b(this.top),C=t.top,k=b(t.bottom)-g,y=x+g,D=this.top+u;else if(r==="left")x=b(this.right),v=this.right-u,S=x-g,M=b(t.left)+g,T=t.right;else if(r==="right")x=b(this.left),M=t.left,T=b(t.right)-g,v=x+g,S=this.left+u;else if(e==="x"){if(r==="center")x=b((t.top+t.bottom)/2+.5);else if(et(r)){let O=Object.keys(r)[0],z=r[O];x=b(this.chart.scales[O].getPixelForValue(z))}C=t.top,k=t.bottom,y=x+g,D=y+u}else if(e==="y"){if(r==="center")x=b((t.left+t.right)/2);else if(et(r)){let O=Object.keys(r)[0],z=r[O];x=b(this.chart.scales[O].getPixelForValue(z))}v=x-g,S=v-u,M=t.left,T=t.right}let A=Q(i.ticks.maxTicksLimit,h),P=Math.max(1,Math.ceil(h/A));for(_=0;_<h;_+=P){let O=this.getContext(_),z=o.setContext(O),G=a.setContext(O),$=z.lineWidth,L=z.color,V=G.dash||[],W=G.dashOffset,j=z.tickWidth,U=z.tickColor,B=z.tickBorderDash||[],F=z.tickBorderDashOffset;E=Qh(this,_,l),E!==void 0&&(w=be(n,E,$),c?v=S=M=T=w:y=D=C=k=w,f.push({tx1:v,ty1:y,tx2:S,ty2:D,x1:M,y1:C,x2:T,y2:k,width:$,color:L,borderDash:V,borderDashOffset:W,tickWidth:j,tickColor:U,tickBorderDash:B,tickBorderDashOffset:F}))}return this._ticksLength=h,this._borderValue=x,f}_computeLabelItems(t){let e=this.axis,n=this.options,{position:i,ticks:o}=n,r=this.isHorizontal(),a=this.ticks,{align:l,crossAlign:c,padding:d,mirror:h}=o,u=Vs(n.grid),f=u+d,p=h?-d:f,m=-zt(this.labelRotation),g=[],b,x,_,E,w,v,y,S,D,M,C,T,k="middle";if(i==="top")v=this.bottom-p,y=this._getXAxisLabelAlignment();else if(i==="bottom")v=this.top+p,y=this._getXAxisLabelAlignment();else if(i==="left"){let P=this._getYAxisLabelAlignment(u);y=P.textAlign,w=P.x}else if(i==="right"){let P=this._getYAxisLabelAlignment(u);y=P.textAlign,w=P.x}else if(e==="x"){if(i==="center")v=(t.top+t.bottom)/2+f;else if(et(i)){let P=Object.keys(i)[0],O=i[P];v=this.chart.scales[P].getPixelForValue(O)+f}y=this._getXAxisLabelAlignment()}else if(e==="y"){if(i==="center")w=(t.left+t.right)/2-f;else if(et(i)){let P=Object.keys(i)[0],O=i[P];w=this.chart.scales[P].getPixelForValue(O)}y=this._getYAxisLabelAlignment(u).textAlign}e==="y"&&(l==="start"?k="top":l==="end"&&(k="bottom"));let A=this._getLabelSizes();for(b=0,x=a.length;b<x;++b){_=a[b],E=_.label;let P=o.setContext(this.getContext(b));S=this.getPixelForTick(b)+o.labelOffset,D=this._resolveTickFontOptions(b),M=D.lineHeight,C=ct(E)?E.length:1;let O=C/2,z=P.color,G=P.textStrokeColor,$=P.textStrokeWidth,L=y;r?(w=S,y==="inner"&&(b===x-1?L=this.options.reverse?"left":"right":b===0?L=this.options.reverse?"right":"left":L="center"),i==="top"?c==="near"||m!==0?T=-C*M+M/2:c==="center"?T=-A.highest.height/2-O*M+M:T=-A.highest.height+M/2:c==="near"||m!==0?T=M/2:c==="center"?T=A.highest.height/2-O*M:T=A.highest.height-C*M,h&&(T*=-1),m!==0&&!P.showLabelBackdrop&&(w+=M/2*Math.sin(m))):(v=S,T=(1-C)*M/2);let V;if(P.showLabelBackdrop){let W=Ct(P.backdropPadding),j=A.heights[b],U=A.widths[b],B=T-W.top,F=0-W.left;switch(k){case"middle":B-=j/2;break;case"bottom":B-=j;break}switch(y){case"center":F-=U/2;break;case"right":F-=U;break;case"inner":b===x-1?F-=U:b>0&&(F-=U/2);break}V={left:F,top:B,width:U+W.width,height:j+W.height,color:P.backdropColor}}g.push({label:E,font:D,textOffset:T,options:{rotation:m,color:z,strokeColor:G,strokeWidth:$,textAlign:L,textBaseline:k,translation:[w,v],backdrop:V}})}return g}_getXAxisLabelAlignment(){let{position:t,ticks:e}=this.options;if(-zt(this.labelRotation))return t==="top"?"left":"right";let i="center";return e.align==="start"?i="left":e.align==="end"?i="right":e.align==="inner"&&(i="inner"),i}_getYAxisLabelAlignment(t){let{position:e,ticks:{crossAlign:n,mirror:i,padding:o}}=this.options,r=this._getLabelSizes(),a=t+o,l=r.widest.width,c,d;return e==="left"?i?(d=this.right+o,n==="near"?c="left":n==="center"?(c="center",d+=l/2):(c="right",d+=l)):(d=this.right-a,n==="near"?c="right":n==="center"?(c="center",d-=l/2):(c="left",d=this.left)):e==="right"?i?(d=this.left+o,n==="near"?c="right":n==="center"?(c="center",d-=l/2):(c="left",d-=l)):(d=this.left+a,n==="near"?c="left":n==="center"?(c="center",d+=l/2):(c="right",d=this.right)):c="right",{textAlign:c,x:d}}_computeLabelArea(){if(this.options.ticks.mirror)return;let 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(){let{ctx:t,options:{backgroundColor:e},left:n,top:i,width:o,height:r}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(n,i,o,r),t.restore())}getLineWidthForValue(t){let e=this.options.grid;if(!this._isVisible()||!e.display)return 0;let i=this.ticks.findIndex(o=>o.value===t);return i>=0?e.setContext(this.getContext(i)).lineWidth:0}drawGrid(t){let e=this.options.grid,n=this.ctx,i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t)),o,r,a=(l,c,d)=>{!d.width||!d.color||(n.save(),n.lineWidth=d.width,n.strokeStyle=d.color,n.setLineDash(d.borderDash||[]),n.lineDashOffset=d.borderDashOffset,n.beginPath(),n.moveTo(l.x,l.y),n.lineTo(c.x,c.y),n.stroke(),n.restore())};if(e.display)for(o=0,r=i.length;o<r;++o){let l=i[o];e.drawOnChartArea&&a({x:l.x1,y:l.y1},{x:l.x2,y:l.y2},l),e.drawTicks&&a({x:l.tx1,y:l.ty1},{x:l.tx2,y:l.ty2},{color:l.tickColor,width:l.tickWidth,borderDash:l.tickBorderDash,borderDashOffset:l.tickBorderDashOffset})}}drawBorder(){let{chart:t,ctx:e,options:{border:n,grid:i}}=this,o=n.setContext(this.getContext()),r=n.display?o.width:0;if(!r)return;let a=i.setContext(this.getContext(0)).lineWidth,l=this._borderValue,c,d,h,u;this.isHorizontal()?(c=be(t,this.left,r)-r/2,d=be(t,this.right,a)+a/2,h=u=l):(h=be(t,this.top,r)-r/2,u=be(t,this.bottom,a)+a/2,c=d=l),e.save(),e.lineWidth=o.width,e.strokeStyle=o.color,e.beginPath(),e.moveTo(c,h),e.lineTo(d,u),e.stroke(),e.restore()}drawLabels(t){if(!this.options.ticks.display)return;let n=this.ctx,i=this._computeLabelArea();i&&Ps(n,i);let o=this.getLabelItems(t);for(let r of o){let a=r.options,l=r.font,c=r.label,d=r.textOffset;ve(n,c,0,d,l,a)}i&&Rs(n)}drawTitle(){let{ctx:t,options:{position:e,title:n,reverse:i}}=this;if(!n.display)return;let o=bt(n.font),r=Ct(n.padding),a=n.align,l=o.lineHeight/2;e==="bottom"||e==="center"||et(e)?(l+=r.bottom,ct(n.text)&&(l+=o.lineHeight*(n.text.length-1))):l+=r.top;let{titleX:c,titleY:d,maxWidth:h,rotation:u}=su(this,l,e,a);ve(t,n.text,0,0,o,{color:n.color,maxWidth:h,rotation:u,textAlign:eu(a,e,i),textBaseline:"middle",translation:[c,d]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){let t=this.options,e=t.ticks&&t.ticks.z||0,n=Q(t.grid&&t.grid.z,-1),i=Q(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==s.prototype.draw?[{z:e,draw:o=>{this.draw(o)}}]:[{z:n,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:e,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){let e=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+"AxisID",i=[],o,r;for(o=0,r=e.length;o<r;++o){let a=e[o];a[n]===this.id&&(!t||a.type===t)&&i.push(a)}return i}_resolveTickFontOptions(t){let e=this.options.ticks.setContext(this.getContext(t));return bt(e.font)}_maxDigits(){let t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}},ls=class{constructor(t,e,n){this.type=t,this.scope=e,this.override=n,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){let e=Object.getPrototypeOf(t),n;ou(e)&&(n=this.register(e));let i=this.items,o=t.id,r=this.scope+"."+o;if(!o)throw new Error("class does not have id: "+t);return o in i||(i[o]=t,nu(t,r,n),this.override&&ht.override(t.id,t.overrides)),r}get(t){return this.items[t]}unregister(t){let e=this.items,n=t.id,i=this.scope;n in e&&delete e[n],i&&n in ht[i]&&(delete ht[i][n],this.override&&delete me[n])}};co=class{constructor(){this.controllers=new ls(Tt,"datasets",!0),this.elements=new ls(At,"elements"),this.plugins=new ls(Object,"plugins"),this.scales=new ls(ke,"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,n){[...e].forEach(i=>{let o=n||this._getRegistryForType(i);n||o.isForType(i)||o===this.plugins&&i.id?this._exec(t,o,i):ot(i,r=>{let a=n||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,e,n){let i=wn(t);lt(n["before"+i],[],n),e[t](n),lt(n["after"+i],[],n)}_getRegistryForType(t){for(let e=0;e<this._typedRegistries.length;e++){let n=this._typedRegistries[e];if(n.isForType(t))return n}return this.plugins}_get(t,e,n){let i=e.get(t);if(i===void 0)throw new Error('"'+t+'" is not a registered '+n+".");return i}},jt=new co,ho=class{constructor(){this._init=void 0}notify(t,e,n,i){if(e==="beforeInit"&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install")),this._init===void 0)return;let o=i?this._descriptors(t).filter(i):this._descriptors(t),r=this._notify(o,t,e,n);return e==="afterDestroy"&&(this._notify(o,t,"stop"),this._notify(this._init,t,"uninstall"),this._init=void 0),r}_notify(t,e,n,i){i=i||{};for(let o of t){let r=o.plugin,a=r[n],l=[e,i,o.options];if(lt(a,l,r)===!1&&i.cancelable)return!1}return!0}invalidate(){tt(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;let e=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),e}_createDescriptors(t,e){let n=t&&t.config,i=Q(n.options&&n.options.plugins,{}),o=ru(n);return i===!1&&!e?[]:lu(t,o,i,e)}_notifyStateChanges(t){let e=this._oldCache||[],n=this._cache,i=(o,r)=>o.filter(a=>!r.some(l=>a.plugin.id===l.plugin.id));this._notify(i(e,n),t,"stop"),this._notify(i(n,e),t,"start")}};Ea=new Map,gl=new Set;Ns=(s,t,e)=>{let n=ae(t,e);n!==void 0&&s.add(n)},po=class{constructor(t){this._config=gu(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=pl(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){let t=this._config;this.clearCache(),fl(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Vn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return Vn(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return Vn(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){let e=t.id,n=this.type;return Vn(`${n}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){let n=this._scopeCache,i=n.get(t);return(!i||e)&&(i=new Map,n.set(t,i)),i}getOptionScopes(t,e,n){let{options:i,type:o}=this,r=this._cachedScopes(t,n),a=r.get(e);if(a)return a;let l=new Set;e.forEach(d=>{t&&(l.add(t),d.forEach(h=>Ns(l,t,h))),d.forEach(h=>Ns(l,i,h)),d.forEach(h=>Ns(l,me[o]||{},h)),d.forEach(h=>Ns(l,ht,h)),d.forEach(h=>Ns(l,Dn,h))});let c=Array.from(l);return c.length===0&&c.push(Object.create(null)),gl.has(e)&&r.set(e,c),c}chartOptionScopes(){let{options:t,type:e}=this;return[t,me[e]||{},ht.datasets[e]||{},{type:e},ht,Dn]}resolveNamedOptions(t,e,n,i=[""]){let o={$shared:!0},{resolver:r,subPrefixes:a}=ka(this._resolverCache,t,i),l=r;if(bu(r,e)){o.$shared=!1,n=oe(n)?n():n;let c=this.createResolver(t,n,a);l=Le(r,n,c)}for(let c of e)o[c]=l[c];return o}createResolver(t,e,n=[""],i){let{resolver:o}=ka(this._resolverCache,t,n);return et(e)?Le(o,e,void 0,i):o}};mu=s=>et(s)&&Object.getOwnPropertyNames(s).some(t=>oe(s[t]));vu="4.5.1",yu=["top","bottom","left","right","chartArea"];$n={},La=s=>{let t=ml(s);return Object.values($n).filter(e=>e.canvas===t).pop()};ee=class{static register(...t){jt.add(...t),Aa()}static unregister(...t){jt.remove(...t),Aa()}constructor(t,e){let n=this.config=new po(e),i=ml(t),o=La(i);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.");let r=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||ul(i)),this.platform.updateConfig(n);let a=this.platform.acquireContext(i,r.aspectRatio),l=a&&a.canvas,c=l&&l.height,d=l&&l.width;if(this.id=Dr(),this.ctx=a,this.canvas=l,this.width=d,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new ho,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=Br(h=>this.update(h),r.resizeDelay||0),this._dataChanges=[],$n[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}te.listen(this,"complete",Ta),te.listen(this,"progress",xu),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:t,maintainAspectRatio:e},width:n,height:i,_aspectRatio:o}=this;return tt(t)?e&&o?o:i?n/i: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 jt}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Wi(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Ii(this.canvas,this.ctx),this}stop(){return te.stop(this),this}resize(t,e){te.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){let n=this.options,i=this.canvas,o=n.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(i,t,e,o),a=n.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,Wi(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),lt(n.onResize,[this,r],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){let e=this.options.scales||{};ot(e,(n,i)=>{n.id=i})}buildOrUpdateScales(){let t=this.options,e=t.scales,n=this.scales,i=Object.keys(n).reduce((r,a)=>(r[a]=!1,r),{}),o=[];e&&(o=o.concat(Object.keys(e).map(r=>{let a=e[r],l=fo(r,a),c=l==="r",d=l==="x";return{options:a,dposition:c?"chartArea":d?"bottom":"left",dtype:c?"radialLinear":d?"category":"linear"}}))),ot(o,r=>{let a=r.options,l=a.id,c=fo(l,a),d=Q(a.type,r.dtype);(a.position===void 0||Ma(a.position,c)!==Ma(r.dposition))&&(a.position=r.dposition),i[l]=!0;let h=null;if(l in n&&n[l].type===d)h=n[l];else{let u=jt.getScale(d);h=new u({id:l,type:d,ctx:this.ctx,chart:this}),n[h.id]=h}h.init(a,t)}),ot(i,(r,a)=>{r||delete n[a]}),ot(n,r=>{St.configure(this,r,r.options),St.addBox(this,r)})}_updateMetasets(){let t=this._metasets,e=this.data.datasets.length,n=t.length;if(t.sort((i,o)=>i.index-o.index),n>e){for(let i=e;i<n;++i)this._destroyDatasetMeta(i);t.splice(e,n-e)}this._sortedMetasets=t.slice(0).sort(Da("order","index"))}_removeUnreferencedMetasets(){let{_metasets:t,data:{datasets:e}}=this;t.length>e.length&&delete this._stacks,t.forEach((n,i)=>{e.filter(o=>o===n._dataset).length===0&&this._destroyDatasetMeta(i)})}buildOrUpdateControllers(){let t=[],e=this.data.datasets,n,i;for(this._removeUnreferencedMetasets(),n=0,i=e.length;n<i;n++){let o=e[n],r=this.getDatasetMeta(n),a=o.type||this.config.type;if(r.type&&r.type!==a&&(this._destroyDatasetMeta(n),r=this.getDatasetMeta(n)),r.type=a,r.indexAxis=o.indexAxis||uo(a,this.options),r.order=o.order||0,r.index=n,r.label=""+o.label,r.visible=this.isDatasetVisible(n),r.controller)r.controller.updateIndex(n),r.controller.linkScales();else{let l=jt.getController(a),{datasetElementType:c,dataElementType:d}=ht.datasets[a];Object.assign(l,{dataElementType:jt.getElement(d),datasetElementType:c&&jt.getElement(c)}),r.controller=new l(this,n),t.push(r.controller)}}return this._updateMetasets(),t}_resetElements(){ot(this.data.datasets,(t,e)=>{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){let e=this.config;e.update();let n=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),i=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;let o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let c=0,d=this.data.datasets.length;c<d;c++){let{controller:h}=this.getDatasetMeta(c),u=!i&&o.indexOf(h)===-1;h.buildOrUpdateElements(u),r=Math.max(+h.getMaxOverflow(),r)}r=this._minPadding=n.layout.autoPadding?r:0,this._updateLayout(r),i||ot(o,c=>{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Da("z","_idx"));let{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){ot(this.scales,t=>{St.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let t=this.options,e=new Set(Object.keys(this._listeners)),n=new Set(t.events);(!Si(e,n)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(let{method:n,start:i,count:o}of e){let r=n==="_removeElements"?-o:o;_u(t,i,r)}}_getUniformDataChanges(){let t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];let e=this.data.datasets.length,n=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),i=n(0);for(let o=1;o<e;o++)if(!Si(i,n(o)))return;return Array.from(i).map(o=>o.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;St.update(this,this.width,this.height,t);let e=this.chartArea,n=e.width<=0||e.height<=0;this._layers=[],ot(this.boxes,i=>{n&&i.position==="chartArea"||(i.configure&&i.configure(),this._layers.push(...i._layers()))},this),this._layers.forEach((i,o)=>{i._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,n=this.data.datasets.length;e<n;++e)this.getDatasetMeta(e).controller.configure();for(let e=0,n=this.data.datasets.length;e<n;++e)this._updateDataset(e,oe(t)?t({datasetIndex:e}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,e){let n=this.getDatasetMeta(t),i={meta:n,index:t,mode:e,cancelable:!0};this.notifyPlugins("beforeDatasetUpdate",i)!==!1&&(n.controller._update(e),i.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",i))}render(){this.notifyPlugins("beforeRender",{cancelable:!0})!==!1&&(te.has(this)?this.attached&&!te.running(this)&&te.start(this):(this.draw(),Ta({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){let{width:n,height:i}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(n,i)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins("beforeDraw",{cancelable:!0})===!1)return;let e=this._layers;for(t=0;t<e.length&&e[t].z<=0;++t)e[t].draw(this.chartArea);for(this._drawDatasets();t<e.length;++t)e[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){let e=this._sortedMetasets,n=[],i,o;for(i=0,o=e.length;i<o;++i){let r=e[i];(!t||r.visible)&&n.push(r)}return n}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0})===!1)return;let t=this.getSortedVisibleDatasetMetas();for(let e=t.length-1;e>=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){let e=this.ctx,n={meta:t,index:t.index,cancelable:!0},i=qi(this,t);this.notifyPlugins("beforeDatasetDraw",n)!==!1&&(i&&Ps(e,i),t.controller.draw(),i&&Rs(e),n.cancelable=!1,this.notifyPlugins("afterDatasetDraw",n))}isPointInArea(t){return Xt(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,n,i){let o=al.modes[e];return typeof o=="function"?o(this,t,n,i):[]}getDatasetMeta(t){let e=this.data.datasets[t],n=this._metasets,i=n.filter(o=>o&&o._dataset===e).pop();return i||(i={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},n.push(i)),i}getContext(){return this.$context||(this.$context=le(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){let e=this.data.datasets[t];if(!e)return!1;let n=this.getDatasetMeta(t);return typeof n.hidden=="boolean"?!n.hidden:!e.hidden}setDatasetVisibility(t,e){let n=this.getDatasetMeta(t);n.hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,n){let i=n?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,i);Je(e)?(o.data[e].hidden=!n,this.update()):(this.setDatasetVisibility(t,n),r.update(o,{visible:n}),this.update(a=>a.datasetIndex===t?i:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){let e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),te.remove(this),t=0,e=this.data.datasets.length;t<e;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");let{canvas:t,ctx:e}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),Ii(t,e),this.platform.releaseContext(e),this.canvas=null,this.ctx=null),delete $n[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){let t=this._listeners,e=this.platform,n=(o,r)=>{e.addEventListener(this,o,r),t[o]=r},i=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};ot(this.options.events,o=>n(o,i))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});let t=this._responsiveListeners,e=this.platform,n=(l,c)=>{e.addEventListener(this,l,c),t[l]=c},i=(l,c)=>{t[l]&&(e.removeEventListener(this,l,c),delete t[l])},o=(l,c)=>{this.canvas&&this.resize(l,c)},r,a=()=>{i("attach",a),this.attached=!0,this.resize(),n("resize",o),n("detach",r)};r=()=>{this.attached=!1,i("resize",o),this._stop(),this._resize(0,0),n("attach",a)},e.isAttached(this.canvas)?a():r()}unbindEvents(){ot(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},ot(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,n){let i=n?"set":"remove",o,r,a,l;for(e==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+i+"DatasetHoverStyle"]()),a=0,l=t.length;a<l;++a){r=t[a];let c=r&&this.getDatasetMeta(r.datasetIndex).controller;c&&c[i+"HoverStyle"](r.element,r.datasetIndex,r.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){let e=this._active||[],n=t.map(({datasetIndex:o,index:r})=>{let a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[r],index:r}});!As(n,e)&&(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,e))}notifyPlugins(t,e,n){return this._plugins.notify(this,t,e,n)}isPluginEnabled(t){return this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,n){let i=this.options.hover,o=(l,c)=>l.filter(d=>!c.some(h=>d.datasetIndex===h.datasetIndex&&d.index===h.index)),r=o(e,t),a=n?t:o(t,e);r.length&&this.updateHoverStyle(r,i.mode,!1),a.length&&i.mode&&this.updateHoverStyle(a,i.mode,!0)}_eventHandler(t,e){let n={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},i=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",n,i)===!1)return;let o=this._handleEvent(t,e,n.inChartArea);return n.cancelable=!1,this.notifyPlugins("afterEvent",n,i),(o||n.changed)&&this.render(),this}_handleEvent(t,e,n){let{_active:i=[],options:o}=this,r=e,a=this._getActiveElements(t,i,n,r),l=Ar(t),c=Cu(t,this._lastEvent,n,l);n&&(this._lastEvent=null,lt(o.onHover,[t,a,this],this),l&<(o.onClick,[t,a,this],this));let d=!As(a,i);return(d||e)&&(this._active=a,this._updateHoverStyles(a,i,e)),this._lastEvent=c,d}_getActiveElements(t,e,n,i){if(t.type==="mouseout")return[];if(!n)return e;let o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,i)}};H(ee,"defaults",ht),H(ee,"instances",$n),H(ee,"overrides",me),H(ee,"registry",jt),H(ee,"version",vu),H(ee,"getChart",La);_e=class extends At{constructor(e){super();H(this,"circumference");H(this,"endAngle");H(this,"fullCircles");H(this,"innerRadius");H(this,"outerRadius");H(this,"pixelMargin");H(this,"startAngle");this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,n,i){let o=this.getProps(["x","y"],i),{angle:r,distance:a}=Mi(o,{x:e,y:n}),{startAngle:l,endAngle:c,innerRadius:d,outerRadius:h,circumference:u}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),f=(this.options.spacing+this.options.borderWidth)/2,p=Q(u,c-l),m=es(r,l,c)&&l!==c,g=p>=dt||m,b=Zt(a,d+f,h+f);return g&&b}getCenterPoint(e){let{x:n,y:i,startAngle:o,endAngle:r,innerRadius:a,outerRadius:l}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],e),{offset:c,spacing:d}=this.options,h=(o+r)/2,u=(a+l+d+c)/2;return{x:n+Math.cos(h)*u,y:i+Math.sin(h)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:n,circumference:i}=this,o=(n.offset||0)/4,r=(n.spacing||0)/2,a=n.circular;if(this.pixelMargin=n.borderAlign==="inner"?.33:0,this.fullCircles=i>dt?Math.floor(i/dt):0,i===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let l=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(l)*o,Math.sin(l)*o);let c=1-Math.sin(Math.min(nt,i||0)),d=o*c;e.fillStyle=n.backgroundColor,e.strokeStyle=n.borderColor,Mu(e,this,d,r,a),Du(e,this,d,r,a),e.restore()}};H(_e,"id","arc"),H(_e,"defaults",{borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1}),H(_e,"defaultRoutes",{backgroundColor:"backgroundColor"}),H(_e,"descriptors",{_scriptable:!0,_indexable:e=>e!=="borderDash"});Iu=typeof Path2D=="function";Ut=class extends At{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){let n=this.options;if((n.tension||n.cubicInterpolationMode==="monotone")&&!n.stepped&&!this._pointsUpdated){let i=n.spanGaps?this._loop:this._fullLoop;Xr(this._points,n,t,i,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=sa(this,this.options.segment))}first(){let t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){let t=this.segments,e=this.points,n=t.length;return n&&e[t[n-1].end]}interpolate(t,e){let n=this.options,i=t[e],o=this.points,r=Gi(this,{property:e,start:i,end:i});if(!r.length)return;let a=[],l=Ru(n),c,d;for(c=0,d=r.length;c<d;++c){let{start:h,end:u}=r[c],f=o[h],p=o[u];if(f===p){a.push(f);continue}let m=Math.abs((i-f[e])/(p[e]-f[e])),g=l(f,p,m,n.stepped);g[e]=t[e],a.push(g)}return a.length===1?a[0]:a}pathSegment(t,e,n){return go(this)(t,this,e,n)}path(t,e,n){let i=this.segments,o=go(this),r=this._loop;e=e||0,n=n||this.points.length-e;for(let a of i)r&=o(t,this,a,{start:e,end:e+n-1});return!!r}draw(t,e,n,i){let o=this.options||{};(this.points||[]).length&&o.borderWidth&&(t.save(),Vu(t,this,n,i),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}};H(Ut,"id","line"),H(Ut,"defaults",{borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0}),H(Ut,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"}),H(Ut,"descriptors",{_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"});ze=class extends At{constructor(e){super();H(this,"parsed");H(this,"skip");H(this,"stop");this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,e&&Object.assign(this,e)}inRange(e,n,i){let o=this.options,{x:r,y:a}=this.getProps(["x","y"],i);return Math.pow(e-r,2)+Math.pow(n-a,2)<Math.pow(o.hitRadius+o.radius,2)}inXRange(e,n){return Pa(this,e,"x",n)}inYRange(e,n){return Pa(this,e,"y",n)}getCenterPoint(e){let{x:n,y:i}=this.getProps(["x","y"],e);return{x:n,y:i}}size(e){e=e||this.options||{};let n=e.radius||0;n=Math.max(n,n&&e.hoverRadius||0);let i=n&&e.borderWidth||0;return(n+i)*2}draw(e,n){let i=this.options;this.skip||i.radius<.1||!Xt(this,n,this.size(i)/2)||(e.strokeStyle=i.borderColor,e.lineWidth=i.borderWidth,e.fillStyle=i.backgroundColor,Tn(e,i,this.x,this.y))}getRange(){let e=this.options||{};return e.radius+e.hitRadius}};H(ze,"id","point"),H(ze,"defaults",{borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0}),H(ze,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});He=class extends At{constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){let{inflateAmount:e,options:{borderColor:n,backgroundColor:i}}=this,{inner:o,outer:r}=zu(this),a=Hu(r.radius)?is:$u;t.save(),(r.w!==o.w||r.h!==o.h)&&(t.beginPath(),a(t,io(r,e,o)),t.clip(),a(t,io(o,-e,r)),t.fillStyle=n,t.fill("evenodd")),t.beginPath(),a(t,io(o,e)),t.fillStyle=i,t.fill(),t.restore()}inRange(t,e,n){return no(this,t,e,n)}inXRange(t,e){return no(this,t,null,e)}inYRange(t,e){return no(this,null,t,e)}getCenterPoint(t){let{x:e,y:n,base:i,horizontal:o}=this.getProps(["x","y","base","horizontal"],t);return{x:o?(e+i)/2:e,y:o?n:(n+i)/2}}getRange(t){return t==="x"?this.width/2:this.height/2}};H(He,"id","bar"),H(He,"defaults",{borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0}),H(He,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});xl=Object.freeze({__proto__:null,ArcElement:_e,BarElement:He,LineElement:Ut,PointElement:ze}),mo=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],Ra=mo.map(s=>s.replace("rgb(","rgba(").replace(")",", 0.5)"));Sl={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(s,t,e){if(!e.enabled)return;let{data:{datasets:n},options:i}=s.config,{elements:o}=i,r=Oa(n)||Yu(i)||o&&Oa(o)||Gu();if(!e.forceOverride&&r)return;let a=Ku(s);n.forEach(a)}};El={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(s,t,e)=>{if(!e.enabled){Fa(s);return}let n=s.width;s.data.datasets.forEach((i,o)=>{let{_data:r,indexAxis:a}=i,l=s.getDatasetMeta(o),c=r||i.data;if(os([a,s.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;let d=s.scales[l.xAxisID];if(d.type!=="linear"&&d.type!=="time"||s.options.parsing)return;let{start:h,count:u}=Qu(l,c),f=e.threshold||4*n;if(u<=f){wl(i);return}tt(r)&&(i._data=c,delete i.data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(m){this._data=m}}));let p;switch(e.algorithm){case"lttb":p=qu(c,h,u,n,e);break;case"min-max":p=Xu(c,h,u,n);break;default:throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`)}i._decimated=p})},destroy(s){Fa(s)}};Gn=class{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,n){let{x:i,y:o,radius:r}=this;return e=e||{start:0,end:dt},t.arc(i,o,r,e.end,e.start,!0),!n.bounds}interpolate(t){let{x:e,y:n,radius:i}=this,o=t.angle;return{x:e+Math.cos(o)*i,y:n+Math.sin(o)*i,angle:o}}};Ml={id:"filler",afterDatasetsUpdate(s,t,e){let n=(s.data.datasets||[]).length,i=[],o,r,a,l;for(r=0;r<n;++r)o=s.getDatasetMeta(r),a=o.dataset,l=null,a&&a.options&&a instanceof Ut&&(l={visible:s.isDatasetVisible(r),index:r,fill:ef(a,r,n),chart:s,axis:o.controller.options.indexAxis,scale:o.vScale,line:a}),o.$filler=l,i.push(l);for(r=0;r<n;++r)l=i[r],!(!l||l.fill===!1)&&(l.fill=tf(i,r,e.propagate))},beforeDraw(s,t,e){let n=e.drawTime==="beforeDraw",i=s.getSortedVisibleDatasetMetas(),o=s.chartArea;for(let r=i.length-1;r>=0;--r){let a=i[r].$filler;a&&(a.line.updateControlPoints(o,a.axis),n&&a.fill&&oo(s.ctx,a,o))}},beforeDatasetsDraw(s,t,e){if(e.drawTime!=="beforeDatasetsDraw")return;let n=s.getSortedVisibleDatasetMetas();for(let i=n.length-1;i>=0;--i){let o=n[i].$filler;Va(o)&&oo(s.ctx,o,s.chartArea)}},beforeDatasetDraw(s,t,e){let n=t.meta.$filler;!Va(n)||e.drawTime!=="beforeDatasetDraw"||oo(s.ctx,n,s.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}},Ha=(s,t)=>{let{boxHeight:e=t,boxWidth:n=t}=s;return s.usePointStyle&&(e=Math.min(e,t),n=s.pointStyleWidth||Math.min(n,t)),{boxWidth:n,boxHeight:e,itemHeight:Math.max(t,e)}},vf=(s,t)=>s!==null&&t!==null&&s.datasetIndex===t.datasetIndex&&s.index===t.index,qn=class extends At{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,n){this.maxWidth=t,this.maxHeight=e,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let t=this.options.labels||{},e=lt(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(n=>t.filter(n,this.chart.data))),t.sort&&(e=e.sort((n,i)=>t.sort(n,i,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){let{options:t,ctx:e}=this;if(!t.display){this.width=this.height=0;return}let n=t.labels,i=bt(n.font),o=i.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=Ha(n,o),c,d;e.font=i.string,this.isHorizontal()?(c=this.maxWidth,d=this._fitRows(r,o,a,l)+10):(d=this.maxHeight,c=this._fitCols(r,i,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(d,t.maxHeight||this.maxHeight)}_fitRows(t,e,n,i){let{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],d=i+a,h=t;o.textAlign="left",o.textBaseline="middle";let u=-1,f=-d;return this.legendItems.forEach((p,m)=>{let g=n+e/2+o.measureText(p.text).width;(m===0||c[c.length-1]+g+2*a>r)&&(h+=d,c[c.length-(m>0?0:1)]=0,f+=d,u++),l[m]={left:0,top:f,row:u,width:g,height:i},c[c.length-1]+=g+a}),h}_fitCols(t,e,n,i){let{ctx:o,maxHeight:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],d=r-t,h=a,u=0,f=0,p=0,m=0;return this.legendItems.forEach((g,b)=>{let{itemWidth:x,itemHeight:_}=yf(n,e,o,g,i);b>0&&f+_+2*a>d&&(h+=u+a,c.push({width:u,height:f}),p+=u+a,m++,u=f=0),l[b]={left:p,top:f,col:m,width:x,height:_},u=Math.max(u,x),f+=_+a}),h+=u,c.push({width:u,height:f}),h}adjustHitBoxes(){if(!this.options.display)return;let t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:n,labels:{padding:i},rtl:o}}=this,r=Pe(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=_t(n,this.left+i,this.right-this.lineWidths[a]);for(let c of e)a!==c.row&&(a=c.row,l=_t(n,this.left+i,this.right-this.lineWidths[a])),c.top+=this.top+t+i,c.left=r.leftForLtr(r.x(l),c.width),l+=c.width+i}else{let a=0,l=_t(n,this.top+t+i,this.bottom-this.columnSizes[a].height);for(let c of e)c.col!==a&&(a=c.col,l=_t(n,this.top+t+i,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+i,c.left=r.leftForLtr(r.x(c.left),c.width),l+=c.height+i}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){let t=this.ctx;Ps(t,this),this._draw(),Rs(t)}}_draw(){let{options:t,columnSizes:e,lineWidths:n,ctx:i}=this,{align:o,labels:r}=t,a=ht.color,l=Pe(t.rtl,this.left,this.width),c=bt(r.font),{padding:d}=r,h=c.size,u=h/2,f;this.drawTitle(),i.textAlign=l.textAlign("left"),i.textBaseline="middle",i.lineWidth=.5,i.font=c.string;let{boxWidth:p,boxHeight:m,itemHeight:g}=Ha(r,h),b=function(v,y,S){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;i.save();let D=Q(S.lineWidth,1);if(i.fillStyle=Q(S.fillStyle,a),i.lineCap=Q(S.lineCap,"butt"),i.lineDashOffset=Q(S.lineDashOffset,0),i.lineJoin=Q(S.lineJoin,"miter"),i.lineWidth=D,i.strokeStyle=Q(S.strokeStyle,a),i.setLineDash(Q(S.lineDash,[])),r.usePointStyle){let M={radius:m*Math.SQRT2/2,pointStyle:S.pointStyle,rotation:S.rotation,borderWidth:D},C=l.xPlus(v,p/2),T=y+u;Vi(i,M,C,T,r.pointStyleWidth&&p)}else{let M=y+Math.max((h-m)/2,0),C=l.leftForLtr(v,p),T=ye(S.borderRadius);i.beginPath(),Object.values(T).some(k=>k!==0)?is(i,{x:C,y:M,w:p,h:m,radius:T}):i.rect(C,M,p,m),i.fill(),D!==0&&i.stroke()}i.restore()},x=function(v,y,S){ve(i,S.text,v,y+g/2,c,{strikethrough:S.hidden,textAlign:l.textAlign(S.textAlign)})},_=this.isHorizontal(),E=this._computeTitleHeight();_?f={x:_t(o,this.left+d,this.right-n[0]),y:this.top+d+E,line:0}:f={x:this.left+d,y:_t(o,this.top+E+d,this.bottom-e[0].height),line:0},Ui(this.ctx,t.textDirection);let w=g+d;this.legendItems.forEach((v,y)=>{i.strokeStyle=v.fontColor,i.fillStyle=v.fontColor;let S=i.measureText(v.text).width,D=l.textAlign(v.textAlign||(v.textAlign=r.textAlign)),M=p+u+S,C=f.x,T=f.y;l.setWidth(this.width),_?y>0&&C+M+d>this.right&&(T=f.y+=w,f.line++,C=f.x=_t(o,this.left+d,this.right-n[f.line])):y>0&&T+w>this.bottom&&(C=f.x=C+e[f.line].width+d,f.line++,T=f.y=_t(o,this.top+E+d,this.bottom-e[f.line].height));let k=l.x(C);if(b(k,T,v),C=zr(D,C+p+u,_?C+M:this.right,t.rtl),x(l.x(C),T,v),_)f.x+=M+d;else if(typeof v.text!="string"){let A=c.lineHeight;f.y+=Dl(v,A)+d}else f.y+=w}),Ki(this.ctx,t.textDirection)}drawTitle(){let t=this.options,e=t.title,n=bt(e.font),i=Ct(e.padding);if(!e.display)return;let o=Pe(t.rtl,this.left,this.width),r=this.ctx,a=e.position,l=n.size/2,c=i.top+l,d,h=this.left,u=this.width;if(this.isHorizontal())u=Math.max(...this.lineWidths),d=this.top+c,h=_t(t.align,h,this.right-u);else{let p=this.columnSizes.reduce((m,g)=>Math.max(m,g.height),0);d=c+_t(t.align,this.top,this.bottom-p-t.labels.padding-this._computeTitleHeight())}let f=_t(a,h,h+u);r.textAlign=o.textAlign(Mn(a)),r.textBaseline="middle",r.strokeStyle=e.color,r.fillStyle=e.color,r.font=n.string,ve(r,e.text,f,d,n)}_computeTitleHeight(){let t=this.options.title,e=bt(t.font),n=Ct(t.padding);return t.display?e.lineHeight+n.height:0}_getLegendItemAt(t,e){let n,i,o;if(Zt(t,this.left,this.right)&&Zt(e,this.top,this.bottom)){for(o=this.legendHitBoxes,n=0;n<o.length;++n)if(i=o[n],Zt(t,i.left,i.left+i.width)&&Zt(e,i.top,i.top+i.height))return this.legendItems[n]}return null}handleEvent(t){let e=this.options;if(!Cf(t.type,e))return;let n=this._getLegendItemAt(t.x,t.y);if(t.type==="mousemove"||t.type==="mouseout"){let i=this._hoveredItem,o=vf(i,n);i&&!o&<(e.onLeave,[t,i,this],this),this._hoveredItem=n,n&&!o&<(e.onHover,[t,n,this],this)}else n&<(e.onClick,[t,n,this],this)}};Tl={id:"legend",_element:qn,start(s,t,e){let n=s.legend=new qn({ctx:s.ctx,options:e,chart:s});St.configure(s,n,e),St.addBox(s,n)},stop(s){St.removeBox(s,s.legend),delete s.legend},beforeUpdate(s,t,e){let n=s.legend;St.configure(s,n,e),n.options=e},afterUpdate(s){let t=s.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(s,t){t.replay||s.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(s,t,e){let n=t.datasetIndex,i=e.chart;i.isDatasetVisible(n)?(i.hide(n),t.hidden=!0):(i.show(n),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:s=>s.chart.options.color,boxWidth:40,padding:10,generateLabels(s){let t=s.data.datasets,{labels:{usePointStyle:e,pointStyle:n,textAlign:i,color:o,useBorderRadius:r,borderRadius:a}}=s.legend.options;return s._getSortedDatasetMetas().map(l=>{let c=l.controller.getStyle(e?0:void 0),d=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:(d.width+d.height)/4,strokeStyle:c.borderColor,pointStyle:n||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:r&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:s=>s.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:s=>!s.startsWith("on"),labels:{_scriptable:s=>!["generateLabels","filter","sort"].includes(s)}}},Us=class extends At{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){let n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=e;let i=ct(n.text)?n.text.length:1;this._padding=Ct(n.padding);let o=i*bt(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){let t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){let{top:e,left:n,bottom:i,right:o,options:r}=this,a=r.align,l=0,c,d,h;return this.isHorizontal()?(d=_t(a,n,o),h=e+t,c=o-n):(r.position==="left"?(d=n+t,h=_t(a,i,e),l=nt*-.5):(d=o-t,h=_t(a,e,i),l=nt*.5),c=i-e),{titleX:d,titleY:h,maxWidth:c,rotation:l}}draw(){let t=this.ctx,e=this.options;if(!e.display)return;let n=bt(e.font),o=n.lineHeight/2+this._padding.top,{titleX:r,titleY:a,maxWidth:l,rotation:c}=this._drawArgs(o);ve(t,e.text,0,0,n,{color:e.color,maxWidth:l,rotation:c,textAlign:Mn(e.align),textBaseline:"middle",translation:[r,a]})}};Ll={id:"title",_element:Us,start(s,t,e){Sf(s,e)},stop(s){let t=s.titleBlock;St.removeBox(s,t),delete s.titleBlock},beforeUpdate(s,t,e){let n=s.titleBlock;St.configure(s,n,e),n.options=e},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}},Nn=new WeakMap,Al={id:"subtitle",start(s,t,e){let n=new Us({ctx:s.ctx,options:e,chart:s});St.configure(s,n,e),St.addBox(s,n),Nn.set(s,n)},stop(s){St.removeBox(s,Nn.get(s)),Nn.delete(s)},beforeUpdate(s,t,e){let n=Nn.get(s);St.configure(s,n,e),n.options=e},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}},zs={average(s){if(!s.length)return!1;let t,e,n=new Set,i=0,o=0;for(t=0,e=s.length;t<e;++t){let a=s[t].element;if(a&&a.hasValue()){let l=a.tooltipPosition();n.add(l.x),i+=l.y,++o}}return o===0||n.size===0?!1:{x:[...n].reduce((a,l)=>a+l)/n.size,y:i/o}},nearest(s,t){if(!s.length)return!1;let e=t.x,n=t.y,i=Number.POSITIVE_INFINITY,o,r,a;for(o=0,r=s.length;o<r;++o){let l=s[o].element;if(l&&l.hasValue()){let c=l.getCenterPoint(),d=Cn(t,c);d<i&&(i=d,a=l)}}if(a){let l=a.tooltipPosition();e=l.x,n=l.y}return{x:e,y:n}}};Pl={beforeTitle:Qt,title(s){if(s.length>0){let t=s[0],e=t.chart.data.labels,n=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(n>0&&t.dataIndex<n)return e[t.dataIndex]}return""},afterTitle:Qt,beforeBody:Qt,beforeLabel:Qt,label(s){if(this&&this.options&&this.options.mode==="dataset")return s.label+": "+s.formattedValue||s.formattedValue;let t=s.dataset.label||"";t&&(t+=": ");let e=s.formattedValue;return tt(e)||(t+=e),t},labelColor(s){let e=s.chart.getDatasetMeta(s.datasetIndex).controller.getStyle(s.dataIndex);return{borderColor:e.borderColor,backgroundColor:e.backgroundColor,borderWidth:e.borderWidth,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(s){let e=s.chart.getDatasetMeta(s.datasetIndex).controller.getStyle(s.dataIndex);return{pointStyle:e.pointStyle,rotation:e.rotation}},afterLabel:Qt,afterBody:Qt,beforeFooter:Qt,footer:Qt,afterFooter:Qt};Hs=class extends At{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(){let t=this._cachedAnimations;if(t)return t;let e=this.chart,n=this.options.setContext(this.getContext()),i=n.enabled&&e.options.animation&&n.animations,o=new $s(this.chart,i);return i._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=Lf(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){let{callbacks:n}=e,i=Dt(n,"beforeTitle",this,t),o=Dt(n,"title",this,t),r=Dt(n,"afterTitle",this,t),a=[];return a=Jt(a,ce(i)),a=Jt(a,ce(o)),a=Jt(a,ce(r)),a}getBeforeBody(t,e){return Ua(Dt(e.callbacks,"beforeBody",this,t))}getBody(t,e){let{callbacks:n}=e,i=[];return ot(t,o=>{let r={before:[],lines:[],after:[]},a=Ka(n,o);Jt(r.before,ce(Dt(a,"beforeLabel",this,o))),Jt(r.lines,Dt(a,"label",this,o)),Jt(r.after,ce(Dt(a,"afterLabel",this,o))),i.push(r)}),i}getAfterBody(t,e){return Ua(Dt(e.callbacks,"afterBody",this,t))}getFooter(t,e){let{callbacks:n}=e,i=Dt(n,"beforeFooter",this,t),o=Dt(n,"footer",this,t),r=Dt(n,"afterFooter",this,t),a=[];return a=Jt(a,ce(i)),a=Jt(a,ce(o)),a=Jt(a,ce(r)),a}_createItems(t){let e=this._active,n=this.chart.data,i=[],o=[],r=[],a=[],l,c;for(l=0,c=e.length;l<c;++l)a.push(wf(this.chart,e[l]));return t.filter&&(a=a.filter((d,h,u)=>t.filter(d,h,u,n))),t.itemSort&&(a=a.sort((d,h)=>t.itemSort(d,h,n))),ot(a,d=>{let h=Ka(t.callbacks,d);i.push(Dt(h,"labelColor",this,d)),o.push(Dt(h,"labelPointStyle",this,d)),r.push(Dt(h,"labelTextColor",this,d))}),this.labelColors=i,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,e){let n=this.options.setContext(this.getContext()),i=this._active,o,r=[];if(!i.length)this.opacity!==0&&(o={opacity:0});else{let a=zs[n.position].call(this,i,this._eventPosition);r=this._createItems(n),this.title=this.getTitle(r,n),this.beforeBody=this.getBeforeBody(r,n),this.body=this.getBody(r,n),this.afterBody=this.getAfterBody(r,n),this.footer=this.getFooter(r,n);let l=this._size=$a(this,n),c=Object.assign({},a,l),d=Wa(this.chart,n,c),h=ja(n,c,d,this.chart);this.xAlign=d.xAlign,this.yAlign=d.yAlign,o={opacity:1,x:h.x,y:h.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&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,n,i){let o=this.getCaretPosition(t,n,i);e.lineTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.lineTo(o.x3,o.y3)}getCaretPosition(t,e,n){let{xAlign:i,yAlign:o}=this,{caretSize:r,cornerRadius:a}=n,{topLeft:l,topRight:c,bottomLeft:d,bottomRight:h}=ye(a),{x:u,y:f}=t,{width:p,height:m}=e,g,b,x,_,E,w;return o==="center"?(E=f+m/2,i==="left"?(g=u,b=g-r,_=E+r,w=E-r):(g=u+p,b=g+r,_=E-r,w=E+r),x=g):(i==="left"?b=u+Math.max(l,d)+r:i==="right"?b=u+p-Math.max(c,h)-r:b=this.caretX,o==="top"?(_=f,E=_-r,g=b-r,x=b+r):(_=f+m,E=_+r,g=b+r,x=b-r),w=_),{x1:g,x2:b,x3:x,y1:_,y2:E,y3:w}}drawTitle(t,e,n){let i=this.title,o=i.length,r,a,l;if(o){let c=Pe(n.rtl,this.x,this.width);for(t.x=Bn(this,n.titleAlign,n),e.textAlign=c.textAlign(n.titleAlign),e.textBaseline="middle",r=bt(n.titleFont),a=n.titleSpacing,e.fillStyle=n.titleColor,e.font=r.string,l=0;l<o;++l)e.fillText(i[l],c.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+a,l+1===o&&(t.y+=n.titleMarginBottom-a)}}_drawColorBox(t,e,n,i,o){let r=this.labelColors[n],a=this.labelPointStyles[n],{boxHeight:l,boxWidth:c}=o,d=bt(o.bodyFont),h=Bn(this,"left",o),u=i.x(h),f=l<d.lineHeight?(d.lineHeight-l)/2:0,p=e.y+f;if(o.usePointStyle){let m={radius:Math.min(c,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},g=i.leftForLtr(u,c)+c/2,b=p+l/2;t.strokeStyle=o.multiKeyBackground,t.fillStyle=o.multiKeyBackground,Tn(t,m,g,b),t.strokeStyle=r.borderColor,t.fillStyle=r.backgroundColor,Tn(t,m,g,b)}else{t.lineWidth=et(r.borderWidth)?Math.max(...Object.values(r.borderWidth)):r.borderWidth||1,t.strokeStyle=r.borderColor,t.setLineDash(r.borderDash||[]),t.lineDashOffset=r.borderDashOffset||0;let m=i.leftForLtr(u,c),g=i.leftForLtr(i.xPlus(u,1),c-2),b=ye(r.borderRadius);Object.values(b).some(x=>x!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,is(t,{x:m,y:p,w:c,h:l,radius:b}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),is(t,{x:g,y:p+1,w:c-2,h:l-2,radius:b}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(m,p,c,l),t.strokeRect(m,p,c,l),t.fillStyle=r.backgroundColor,t.fillRect(g,p+1,c-2,l-2))}t.fillStyle=this.labelTextColors[n]}drawBody(t,e,n){let{body:i}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:d}=n,h=bt(n.bodyFont),u=h.lineHeight,f=0,p=Pe(n.rtl,this.x,this.width),m=function(S){e.fillText(S,p.x(t.x+f),t.y+u/2),t.y+=u+o},g=p.textAlign(r),b,x,_,E,w,v,y;for(e.textAlign=r,e.textBaseline="middle",e.font=h.string,t.x=Bn(this,g,n),e.fillStyle=n.bodyColor,ot(this.beforeBody,m),f=a&&g!=="right"?r==="center"?c/2+d:c+2+d:0,E=0,v=i.length;E<v;++E){for(b=i[E],x=this.labelTextColors[E],e.fillStyle=x,ot(b.before,m),_=b.lines,a&&_.length&&(this._drawColorBox(e,t,E,p,n),u=Math.max(h.lineHeight,l)),w=0,y=_.length;w<y;++w)m(_[w]),u=h.lineHeight;ot(b.after,m)}f=0,u=h.lineHeight,ot(this.afterBody,m),t.y-=o}drawFooter(t,e,n){let i=this.footer,o=i.length,r,a;if(o){let l=Pe(n.rtl,this.x,this.width);for(t.x=Bn(this,n.footerAlign,n),t.y+=n.footerMarginTop,e.textAlign=l.textAlign(n.footerAlign),e.textBaseline="middle",r=bt(n.footerFont),e.fillStyle=n.footerColor,e.font=r.string,a=0;a<o;++a)e.fillText(i[a],l.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+n.footerSpacing}}drawBackground(t,e,n,i){let{xAlign:o,yAlign:r}=this,{x:a,y:l}=t,{width:c,height:d}=n,{topLeft:h,topRight:u,bottomLeft:f,bottomRight:p}=ye(i.cornerRadius);e.fillStyle=i.backgroundColor,e.strokeStyle=i.borderColor,e.lineWidth=i.borderWidth,e.beginPath(),e.moveTo(a+h,l),r==="top"&&this.drawCaret(t,e,n,i),e.lineTo(a+c-u,l),e.quadraticCurveTo(a+c,l,a+c,l+u),r==="center"&&o==="right"&&this.drawCaret(t,e,n,i),e.lineTo(a+c,l+d-p),e.quadraticCurveTo(a+c,l+d,a+c-p,l+d),r==="bottom"&&this.drawCaret(t,e,n,i),e.lineTo(a+f,l+d),e.quadraticCurveTo(a,l+d,a,l+d-f),r==="center"&&o==="left"&&this.drawCaret(t,e,n,i),e.lineTo(a,l+h),e.quadraticCurveTo(a,l,a+h,l),e.closePath(),e.fill(),i.borderWidth>0&&e.stroke()}_updateAnimationTarget(t){let e=this.chart,n=this.$animations,i=n&&n.x,o=n&&n.y;if(i||o){let r=zs[t.position].call(this,this._active,this._eventPosition);if(!r)return;let a=this._size=$a(this,t),l=Object.assign({},r,this._size),c=Wa(e,t,l),d=ja(t,l,c,e);(i._to!==d.x||o._to!==d.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,d))}}_willRender(){return!!this.opacity}draw(t){let e=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(e);let i={width:this.width,height:this.height},o={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let 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=n,this.drawBackground(o,t,i,e),Ui(t,e.textDirection),o.y+=r.top,this.drawTitle(o,t,e),this.drawBody(o,t,e),this.drawFooter(o,t,e),Ki(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){let n=this._active,i=t.map(({datasetIndex:a,index:l})=>{let 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=!As(n,i),r=this._positionChanged(i,e);(o||r)&&(this._active=i,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,n=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let i=this.options,o=this._active||[],r=this._getActiveElements(t,o,e,n),a=this._positionChanged(r,t),l=e||!As(r,o)||a;return l&&(this._active=r,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),l}_getActiveElements(t,e,n,i){let o=this.options;if(t.type==="mouseout")return[];if(!i)return e.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);let r=this.chart.getElementsAtEventForMode(t,o.mode,o,n);return o.reverse&&r.reverse(),r}_positionChanged(t,e){let{caretX:n,caretY:i,options:o}=this,r=zs[o.position].call(this,t,e);return r!==!1&&(n!==r.x||i!==r.y)}};H(Hs,"positioners",zs);Rl={id:"tooltip",_element:Hs,positioners:zs,afterInit(s,t,e){e&&(s.tooltip=new Hs({chart:s,options:e}))},beforeUpdate(s,t,e){s.tooltip&&s.tooltip.initialize(e)},reset(s,t,e){s.tooltip&&s.tooltip.initialize(e)},afterDraw(s){let t=s.tooltip;if(t&&t._willRender()){let e={tooltip:t};if(s.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(s.ctx),s.notifyPlugins("afterTooltipDraw",e)}},afterEvent(s,t){if(s.tooltip){let e=t.replay;s.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:(s,t)=>t.bodyFont.size,boxWidth:(s,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:Pl},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:s=>s!=="filter"&&s!=="itemSort"&&s!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},Ol=Object.freeze({__proto__:null,Colors:Sl,Decimation:El,Filler:Ml,Legend:Tl,SubTitle:Al,Title:Ll,Tooltip:Rl}),Af=(s,t,e,n)=>(typeof t=="string"?(e=s.push(t)-1,n.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);Rf=(s,t)=>s===null?null:vt(Math.round(s),0,t);cs=class extends ke{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){let e=this._addedLabels;if(e.length){let n=this.getLabels();for(let{index:i,label:o}of e)n[i]===o&&n.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(tt(t))return null;let n=this.getLabels();return e=isFinite(e)&&n[e]===t?e:Pf(n,t,Q(e,t),this._addedLabels),Rf(e,n.length-1)}determineDataLimits(){let{minDefined:t,maxDefined:e}=this.getUserBounds(),{min:n,max:i}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(n=0),e||(i=this.getLabels().length-1)),this.min=n,this.max=i}buildTicks(){let t=this.min,e=this.max,n=this.options.offset,i=[],o=this.getLabels();o=t===0&&e===o.length-1?o:o.slice(t,e+1),this._valueRange=Math.max(o.length-(n?0:1),1),this._startValue=this.min-(n?.5:0);for(let r=t;r<=e;r++)i.push({value:r});return i}getLabelForValue(t){return Ya.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){let e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}};H(cs,"id","category"),H(cs,"defaults",{ticks:{callback:Ya}});fs=class extends ke{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 tt(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){let{beginAtZero:t}=this.options,{minDefined:e,maxDefined:n}=this.getUserBounds(),{min:i,max:o}=this,r=l=>i=e?i:l,a=l=>o=n?o:l;if(t){let l=Wt(i),c=Wt(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(i===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(i-l)}this.min=i,this.max=o}getTickLimit(){let t=this.options.ticks,{maxTicksLimit:e,stepSize:n}=t,i;return n?(i=Math.ceil(this.max/n)-Math.floor(this.min/n)+1,i>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${n} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),e=e||11),e&&(i=Math.min(e,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){let t=this.options,e=t.ticks,n=this.getTickLimit();n=Math.max(2,n);let i={maxTicks:n,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=Of(i,o);return t.bounds==="ticks"&&Ei(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(){let t=this.ticks,e=this.min,n=this.max;if(super.configure(),this.options.offset&&t.length){let i=(n-e)/Math.max(t.length-1,1)/2;e-=i,n+=i}this._startValue=e,this._endValue=n,this._valueRange=n-e}getLabelForValue(t){return ss(t,this.chart.options.locale,this.options.ticks.format)}},ds=class extends fs{determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=pt(t)?t:0,this.max=pt(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){let t=this.isHorizontal(),e=t?this.width:this.height,n=zt(this.options.ticks.minRotation),i=(t?Math.sin(n):Math.cos(n))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,o.lineHeight/i))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}};H(ds,"id","linear"),H(ds,"defaults",{ticks:{callback:ns.formatters.numeric}});Ks=s=>Math.floor(re(s)),Oe=(s,t)=>Math.pow(10,Ks(s)+t);hs=class extends ke{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){let n=fs.prototype.parse.apply(this,[t,e]);if(n===0){this._zero=!0;return}return pt(n)&&n>0?n:null}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!0);this.min=pt(t)?Math.max(0,t):null,this.max=pt(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!pt(this._userMin)&&(this.min=t===Oe(this.min,0)?Oe(this.min,-1):Oe(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:t,maxDefined:e}=this.getUserBounds(),n=this.min,i=this.max,o=a=>n=t?n:a,r=a=>i=e?i:a;n===i&&(n<=0?(o(1),r(10)):(o(Oe(n,-1)),r(Oe(i,1)))),n<=0&&o(Oe(i,-1)),i<=0&&r(Oe(n,1)),this.min=n,this.max=i}buildTicks(){let t=this.options,e={min:this._userMin,max:this._userMax},n=If(e,this);return t.bounds==="ticks"&&Ei(n,this,"value"),t.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}getLabelForValue(t){return t===void 0?"0":ss(t,this.chart.options.locale,this.options.ticks.format)}configure(){let t=this.min;super.configure(),this._startValue=re(t),this._valueRange=re(this.max)-re(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(re(t)-this._startValue)/this._valueRange)}getValueForPixel(t){let e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}};H(hs,"id","logarithmic"),H(hs,"defaults",{ticks:{callback:ns.formatters.logarithmic,major:{enabled:!0}}});Ce=class extends fs{constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){let t=this._padding=Ct(vo(this.options)/2),e=this.width=this.maxWidth-t.width,n=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+n/2+t.top),this.drawingArea=Math.floor(Math.min(e,n)/2)}determineDataLimits(){let{min:t,max:e}=this.getMinMax(!1);this.min=pt(t)&&!isNaN(t)?t:0,this.max=pt(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/vo(this.options))}generateTickLabels(t){fs.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((e,n)=>{let i=lt(this.options.pointLabels.callback,[e,n],this);return i||i===0?i:""}).filter((e,n)=>this.chart.getDataVisibility(n))}fit(){let t=this.options;t.display&&t.pointLabels.display?Nf(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,n,i){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((n-i)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,n,i))}getIndexAngle(t){let e=dt/(this._pointLabels.length||1),n=this.options.startAngle||0;return xt(t*e+zt(n))}getDistanceFromCenterForValue(t){if(tt(t))return NaN;let e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(tt(t))return NaN;let e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){let e=this._pointLabels||[];if(t>=0&&t<e.length){let n=e[t];return qf(this.getContext(),t,n)}}getPointPosition(t,e,n=0){let i=this.getIndexAngle(t)-mt+n;return{x:Math.cos(i)*e+this.xCenter,y:Math.sin(i)*e+this.yCenter,angle:i}}getPointPositionForValue(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}getPointLabelPosition(t){let{left:e,top:n,right:i,bottom:o}=this._pointLabelItems[t];return{left:e,top:n,right:i,bottom:o}}drawBackground(){let{backgroundColor:t,grid:{circular:e}}=this.options;if(t){let n=this.ctx;n.save(),n.beginPath(),Fl(this,this.getDistanceFromCenterForValue(this._endValue),e,this._pointLabels.length),n.closePath(),n.fillStyle=t,n.fill(),n.restore()}}drawGrid(){let t=this.ctx,e=this.options,{angleLines:n,grid:i,border:o}=e,r=this._pointLabels.length,a,l,c;if(e.pointLabels.display&&Yf(this,r),i.display&&this.ticks.forEach((d,h)=>{if(h!==0||h===0&&this.min<0){l=this.getDistanceFromCenterForValue(d.value);let u=this.getContext(h),f=i.setContext(u),p=o.setContext(u);Gf(this,f,l,r,p)}}),n.display){for(t.save(),a=r-1;a>=0;a--){let d=n.setContext(this.getPointLabelContext(a)),{color:h,lineWidth:u}=d;!u||!h||(t.lineWidth=u,t.strokeStyle=h,t.setLineDash(d.borderDash),t.lineDashOffset=d.borderDashOffset,l=this.getDistanceFromCenterForValue(e.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(){let t=this.ctx,e=this.options,n=e.ticks;if(!n.display)return;let i=this.getIndexAngle(0),o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(i),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!e.reverse)return;let c=n.setContext(this.getContext(l)),d=bt(c.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=d.string,r=t.measureText(a.label).width,t.fillStyle=c.backdropColor;let h=Ct(c.backdropPadding);t.fillRect(-r/2-h.left,-o-d.size/2-h.top,r+h.width,d.size+h.height)}ve(t,a.label,0,-o,d,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}};H(Ce,"id","radialLinear"),H(Ce,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:ns.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),H(Ce,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),H(Ce,"descriptors",{angleLines:{_fallback:"grid"}});Qn={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}},Lt=Object.keys(Qn);Ee=class extends ke{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e={}){let n=t.time||(t.time={}),i=this._adapter=new rl._date(t.adapters.date);i.init(e),Ze(n.displayFormats,i.formats()),this._parseOpts={parser:n.parser,round:n.round,isoWeekday:n.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return t===void 0?null:Ja(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){let t=this.options,e=this._adapter,n=t.time.unit||"day",{min:i,max:o,minDefined:r,maxDefined:a}=this.getUserBounds();function l(c){!r&&!isNaN(c.min)&&(i=Math.min(i,c.min)),!a&&!isNaN(c.max)&&(o=Math.max(o,c.max))}(!r||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),i=pt(i)&&!isNaN(i)?i:+e.startOf(Date.now(),n),o=pt(o)&&!isNaN(o)?o:+e.endOf(Date.now(),n)+1,this.min=Math.min(i,o-1),this.max=Math.max(i+1,o)}_getLabelBounds(){let t=this.getLabelTimestamps(),e=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],n=t[t.length-1]),{min:e,max:n}}buildTicks(){let t=this.options,e=t.time,n=t.ticks,i=n.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);let o=this.min,r=this.max,a=Ir(i,o,r);return this._unit=e.unit||(n.autoSkip?tl(e.minUnit,this.min,this.max,this._getLabelCapacity(o)):Xf(this,a.length,e.minUnit,this.min,this.max)),this._majorUnit=!n.major.enabled||this._unit==="year"?void 0:Qf(this._unit),this.initOffsets(i),t.reverse&&a.reverse(),sl(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let e=0,n=0,i,o;this.options.offset&&t.length&&(i=this.getDecimalForValue(t[0]),t.length===1?e=1-i:e=(this.getDecimalForValue(t[1])-i)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?n=o:n=(o-this.getDecimalForValue(t[t.length-2]))/2);let r=t.length<3?.5:.25;e=vt(e,0,r),n=vt(n,0,r),this._offsets={start:e,end:n,factor:1/(e+1+n)}}_generate(){let t=this._adapter,e=this.min,n=this.max,i=this.options,o=i.time,r=o.unit||tl(o.minUnit,e,n,this._getLabelCapacity(e)),a=Q(i.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=Ae(l)||l===!0,d={},h=e,u,f;if(c&&(h=+t.startOf(h,"isoWeek",l)),h=+t.startOf(h,c?"day":r),t.diff(n,e,r)>1e5*a)throw new Error(e+" and "+n+" are too far apart with stepSize of "+a+" "+r);let p=i.ticks.source==="data"&&this.getDataTimestamps();for(u=h,f=0;u<n;u=+t.add(u,a,r),f++)el(d,u,p);return(u===n||i.bounds==="ticks"||f===1)&&el(d,u,p),Object.keys(d).sort(Za).map(m=>+m)}getLabelForValue(t){let e=this._adapter,n=this.options.time;return n.tooltipFormat?e.format(t,n.tooltipFormat):e.format(t,n.displayFormats.datetime)}format(t,e){let i=this.options.time.displayFormats,o=this._unit,r=e||i[o];return this._adapter.format(t,r)}_tickFormatFunction(t,e,n,i){let o=this.options,r=o.ticks.callback;if(r)return lt(r,[t,e,n],this);let a=o.time.displayFormats,l=this._unit,c=this._majorUnit,d=l&&a[l],h=c&&a[c],u=n[e],f=c&&h&&u&&u.major;return this._adapter.format(t,i||(f?h:d))}generateTickLabels(t){let e,n,i;for(e=0,n=t.length;e<n;++e)i=t[e],i.label=this._tickFormatFunction(i.value,e,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){let e=this._offsets,n=this.getDecimalForValue(t);return this.getPixelForDecimal((e.start+n)*e.factor)}getValueForPixel(t){let e=this._offsets,n=this.getDecimalForPixel(t)/e.factor-e.end;return this.min+n*(this.max-this.min)}_getLabelSize(t){let e=this.options.ticks,n=this.ctx.measureText(t).width,i=zt(this.isHorizontal()?e.maxRotation:e.minRotation),o=Math.cos(i),r=Math.sin(i),a=this._resolveTickFontOptions(0).size;return{w:n*o+a*r,h:n*r+a*o}}_getLabelCapacity(t){let e=this.options.time,n=e.displayFormats,i=n[e.unit]||n.millisecond,o=this._tickFormatFunction(t,0,sl(this,[t],this._majorUnit),i),r=this._getLabelSize(o),a=Math.floor(this.isHorizontal()?this.width/r.w:this.height/r.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],e,n;if(t.length)return t;let i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(e=0,n=i.length;e<n;++e)t=t.concat(i[e].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){let t=this._cache.labels||[],e,n;if(t.length)return t;let i=this.getLabels();for(e=0,n=i.length;e<n;++e)t.push(Ja(this,i[e]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return Ti(t.sort(Za))}};H(Ee,"id","time"),H(Ee,"defaults",{bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}});us=class extends Ee{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=zn(e,this.min),this._tableRange=zn(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){let{min:e,max:n}=this,i=[],o=[],r,a,l,c,d;for(r=0,a=t.length;r<a;++r)c=t[r],c>=e&&c<=n&&i.push(c);if(i.length<2)return[{time:e,pos:0},{time:n,pos:1}];for(r=0,a=i.length;r<a;++r)d=i[r+1],l=i[r-1],c=i[r],Math.round((d+l)/2)!==c&&o.push({time:c,pos:r/(a-1)});return o}_generate(){let t=this.min,e=this.max,n=super.getDataTimestamps();return(!n.includes(t)||!n.length)&&n.splice(0,0,t),(!n.includes(e)||n.length===1)&&n.push(e),n.sort((i,o)=>i-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;let e=this.getDataTimestamps(),n=this.getLabelTimestamps();return e.length&&n.length?t=this.normalize(e.concat(n)):t=e.length?e:n,t=this._cache.all=t,t}getDecimalForValue(t){return(zn(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){let e=this._offsets,n=this.getDecimalForPixel(t)/e.factor-e.end;return zn(this._table,n*this._tableRange+this._minPos,!0)}};H(us,"id","timeseries"),H(us,"defaults",Ee.defaults);Il=Object.freeze({__proto__:null,CategoryScale:cs,LinearScale:ds,LogarithmicScale:hs,RadialLinearScale:Ce,TimeScale:Ee,TimeSeriesScale:us}),Jf=[ol,xl,Ol,Il]});var op={};So(op,{CardView:()=>ps,default:()=>Zn});module.exports=Zl(op);var rt=require("obsidian"),jl=qs(bs());var Jl=["AT","BE","CZ","DK","EE","FI","FR","DE","GR","HU","IS","IT","LV","LI","LT","LU","MT","NL","NO","PL","PT","SK","SI","ES","SE","CH"],tc=[{label:"\u{1F1EA}\u{1F1FA} Schengen 90/180 (example)",scope:{countries:Jl},window:{type:"rolling",days:180},threshold:90,note:"Example rule \u2014 add your own in Settings \u2192 CSV Card View."}],ni={defaultMode:"kanban-genre",notesColumns:["notes","note","Notes","Note","description","Description","review","Review"],statusColumn:"status",categoryColumn:"category",notesSubfolder:"Notes",columnWidths:{},selectColumns:["Category","Type","Rating","Status","rating","type","category","status","Score /5"],fileConfigs:{},residencyRules:tc,showResidency:!0},Xs="xlsx-card-view";var Eo=qs(bs()),ko=require("obsidian"),Qs=["Image","image","Cover","cover","Poster","poster","Thumbnail","thumbnail","Thumb","thumb","Photo","photo","Picture","picture","Img","img"];function Zs(s,t,e){let n=(t!=null?t:"").trim();if(!n)return null;if(/^(https?:|data:)/i.test(n))return n;let i=n.match(/!?\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/);if(i)n=i[1].trim();else{let r=n.match(/!\[[^\]]*\]\(([^)]+)\)/);r&&(n=r[1].trim())}if(/^(https?:|data:)/i.test(n))return n;let o=s.metadataCache.getFirstLinkpathDest(n,e);return o instanceof ko.TFile?s.vault.getResourcePath(o):null}var ec=15;function vs(s){return s>=1&&s<=ec}function ys(s){return s.replace(/[\\/:*?"<>|#^[\]]/g,"").replace(/\s+/g," ").trim().slice(0,100)}function Mo(s){return s.toLowerCase().replace(/[^\p{L}\p{N}/_-]+/gu,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function Gt(s){var i,o;if(!s||!s.trim())return{headers:[],rows:[]};let t=Eo.default.parse(s,{header:!0,skipEmptyLines:!0}),e=((i=t.meta.fields)!=null?i:[]).map(String),n=((o=t.data)!=null?o:[]).map(r=>{let a={};return e.forEach(l=>{a[l]=r[l]!=null?String(r[l]):""}),a});return{headers:e,rows:n}}function We(s,t){if(!s)return s;let e=s.startsWith("./")||s.startsWith("../")||s==="."||s==="..";if(!e&&s.includes("/"))return s;if(!e)return t?`${t}/${s}`:s;let n=t?t.split("/").filter(Boolean):[];for(let i of s.split("/"))if(!(i===""||i===".")){if(i===".."){n.pop();continue}n.push(i)}return n.join("/")}function Do(s,t,e){let n=e==="asc"?1:-1;return[...s].sort((i,o)=>{var u,f;let r=((u=i[t])!=null?u:"").trim(),a=((f=o[t])!=null?f:"").trim();if(!r&&!a)return 0;if(!r)return 1;if(!a)return-1;let l=parseFloat(r),c=parseFloat(a);return(!isNaN(l)&&!isNaN(c)&&/^-?[\d.]/.test(r)&&/^-?[\d.]/.test(a)?l-c:r.localeCompare(a,void 0,{numeric:!0,sensitivity:"base"}))*n})}function kt(s){return s.split(/[\s_-]+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}function To(s,t){let e=(s!=null?s:"").trim();if(!e||e.toLowerCase()==="unrated"||e==="\u2014"||e==="-")return"";if(/[★⭐☆]/.test(e))return e;if(/^\d+$/.test(e)){let o=parseInt(e,10);if(o>=1&&o<=5)return"\u2605".repeat(o)}let i=sc(e,t);return i&&i!==e&&i!=="\u2014"?i:""}function sc(s,t){var o;let e=t.toLowerCase();if(!["rating","score","score /5"].includes(e))return s;let n=s.toLowerCase().trim();return(o={excellent:"\u2605\u2605\u2605\u2605\u2605",great:"\u2605\u2605\u2605\u2605\u2605",good:"\u2605\u2605\u2605\u2605\u2606",fair:"\u2605\u2605\u2605\u2606\u2606",poor:"\u2605\u2605\u2606\u2606\u2606",bad:"\u2605\u2606\u2606\u2606\u2606",5:"\u2605\u2605\u2605\u2605\u2605",4:"\u2605\u2605\u2605\u2605\u2606",3:"\u2605\u2605\u2605\u2606\u2606",2:"\u2605\u2605\u2606\u2606\u2606",1:"\u2605\u2606\u2606\u2606\u2606",0:"\u2606\u2606\u2606\u2606\u2606",unrated:"\u2014","":"\u2014"}[n])!=null?o:s}function Lo(s,t){if(/^(year|released|decade)$/i.test((s!=null?s:"").trim()))return!0;let e=t.map(i=>(i!=null?i:"").trim()).filter(Boolean);return e.length<3?!1:e.filter(i=>/^(1[89]|20)\d{2}$/.test(i)).length/e.length>=.8}function Ao(s){let t=(s!=null?s:"").match(/\b(1[89]\d{2}|20\d{2})\b/);return t?`${Math.floor(parseInt(t[1],10)/10)*10}s`:null}function Po(s,t,e){var r;if(!t.length)return null;let n=Math.max(12,t.length/3),i=null,o=1/0;for(let a of s){if(e.has(a))continue;let l=new Set;for(let d of t)((r=d[a])!=null?r:"").split(",").forEach(h=>{let u=h.trim();u&&l.add(u)});if(l.size<2||l.size>n)continue;let c=Math.abs(Math.log(l.size/8));c<o&&(o=c,i=a)}return i}function It(s){return/^(categor(y|ies)|genres?|tags?|themes?|topics?)$/i.test((s!=null?s:"").trim())}function Ot(s,t,e,n,i,o){var M;document.body.querySelectorAll(".csv-select-picker").forEach(C=>C.remove());let r=document.body.createDiv({cls:"csv-select-picker"});r.style.position="fixed",r.style.zIndex="9999";let a=()=>{let C=s.getBoundingClientRect(),T=r.offsetHeight||280,k=C.bottom+4+T>window.innerHeight&&C.top-4-T>0;r.style.left=C.left+"px",r.style.top=k?C.top-4-T+"px":C.bottom+4+"px"};a();let l=C=>{!r.contains(C.target)&&C.target!==s&&d()},c=()=>d(),d=()=>{r.remove(),document.removeEventListener("mousedown",l),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",d)},h=r.createEl("input",{cls:"csv-picker-search",type:"text",placeholder:"Search or add\u2026"});h.focus();let u=r.createDiv({cls:"csv-picker-list"}),f=!!(o!=null&&o.multi),p=C=>C.split(",").map(T=>T.trim()).filter(Boolean),m=new Set(f?p(t):[]),g=()=>n([...m].join(", ")),b=f?Array.from(new Set(e.flatMap(p))):Array.from(new Set(e.filter(Boolean))),x=[],_=0,E=()=>{u.querySelectorAll(".csv-picker-item").forEach((C,T)=>{C.toggleClass("csv-picker-item--hover",T===_),T===_&&C.scrollIntoView({block:"nearest"})})},w=C=>{if(!f){n(C.isClear?"":C.value),d();return}C.isClear?m.clear():(m.has(C.value)?m.delete(C.value):m.add(C.value),C.isAdd&&!b.includes(C.value)&&b.push(C.value)),g(),C.isAdd?(h.value="",S("")):S(h.value)},v=C=>f?m.has(C):C===t,y=()=>f?m.size>0:!!t,S=C=>{u.empty(),x=[];let T=C?b.filter(k=>k.toLowerCase().includes(C.toLowerCase())):b;if(y()){x.push({value:"",isClear:!0});let k=u.createDiv({cls:"csv-picker-item csv-picker-clear"});k.setText(f?"\u2715 Clear all":"\u2715 Clear"),k.addEventListener("mousedown",A=>{A.preventDefault(),w({value:"",isClear:!0})})}if(T.forEach(k=>{x.push({value:k});let A=u.createDiv({cls:`csv-picker-item ${v(k)?"active":""}`});A.setText(f?`${m.has(k)?"\u2713 ":""}${k}`:k),A.addEventListener("mousedown",P=>{P.preventDefault(),w({value:k})})}),C&&!b.some(k=>k.toLowerCase()===C.toLowerCase())){x.push({value:C,isAdd:!0});let k=u.createDiv({cls:"csv-picker-item csv-picker-add"});k.setText(`+ Add "${C}"`),k.addEventListener("mousedown",A=>{A.preventDefault(),w({value:C,isAdd:!0})})}!T.length&&!C&&u.createDiv({cls:"csv-picker-empty",text:"No options yet. Type to add."}),_=Math.min(_,Math.max(x.length-1,0)),E()};f&&r.createEl("button",{cls:"csv-picker-done",text:"Done"}).addEventListener("mousedown",C=>{C.preventDefault(),d()}),S(""),a(),h.addEventListener("input",()=>{_=0,S(h.value),a()});let D=typeof window!="undefined"&&((M=window.matchMedia)==null?void 0:M.call(window,"(pointer: coarse)").matches);setTimeout(()=>{document.addEventListener("mousedown",l),D||(window.addEventListener("scroll",c,!0),window.addEventListener("resize",d))},0),h.addEventListener("keydown",C=>{if(C.key==="Escape"){d();return}if(C.key==="ArrowDown"){C.preventDefault(),x.length&&(_=(_+1)%x.length,E());return}if(C.key==="ArrowUp"){C.preventDefault(),x.length&&(_=(_-1+x.length)%x.length,E());return}if(C.key==="Enter")if(C.preventDefault(),x[_])w(x[_]);else{let T=h.value.trim();T&&(n(T),d())}})}function Ro(s,t,e){return!s[t]||t===e||(s[e]||(s[e]=s[t]),delete s[t]),s}var Ht=require("obsidian");var nc={source:["confirmed","inferred","conflict"],resolved:["yes","no"]};function Oo(s){var t;return(t=nc[s.trim().toLowerCase()])!=null?t:null}function Js(s){return/(^|[_\s-])(date|due|deadline)([_\s-]|$)/i.test(s.trim())}var Fo=/^\d{4}-\d{2}-\d{2}$/;function sn(s,t,e,n){let i=Js(t)&&(e===""||Fo.test(e)),o=s.createEl("input",{cls:n,type:i?"date":"text",value:e});i||(o.placeholder=t);let r=Oo(t);if(r){let a=`csv-dl-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-${Math.random().toString(36).slice(2,7)}`,l=s.createEl("datalist");l.id=a,r.forEach(c=>l.createEl("option",{value:c})),o.setAttr("list",a)}return o}var je=class extends Ht.Modal{constructor(t,e,n,i,o,r,a={},l=()=>!1){super(t),this.headers=e,this.isNotesCol=n,this.isSelectCol=i,this.getColumnValues=o,this.onSubmit=r,this.optionPresets=a,this.isBooleanCol=l}onOpen(){let{contentEl:t}=this;t.empty(),t.addClass("csv-add-modal"),t.createEl("h2",{text:"Add new entry",cls:"csv-modal-title"});let e=t.createDiv({cls:"csv-modal-form"}),n={};this.headers.forEach(d=>n[d]="");let i=this.headers.find(d=>["title","name"].includes(d.toLowerCase())),o=new Map;i&&this.getColumnValues(i).forEach(d=>{let h=d.trim().toLowerCase();h&&!o.has(h)&&o.set(h,d.trim())}),this.headers.forEach(d=>{var m;let h=e.createDiv({cls:"csv-modal-row"});h.createEl("label",{text:kt(d),cls:"csv-modal-label"});let u=(m=this.optionPresets[d])!=null?m:[],f=!this.isSelectCol(d)&&!It(d)&&!Js(d)&&vs(this.getColumnValues(d).length),p=!this.isNotesCol(d)&&(u.length>0||this.isSelectCol(d)&&!It(d)||f);if(this.isBooleanCol(d)){n[d]="0";let g=h.createDiv({cls:"csv-toggle"});g.createDiv({cls:"csv-toggle-knob"}),g.addEventListener("click",()=>{let b=!g.hasClass("is-on");g.toggleClass("is-on",b),n[d]=b?"1":"0"})}else if(this.isNotesCol(d)){let g=h.createEl("textarea",{cls:"csv-modal-textarea",placeholder:"Markdown supported\u2026"});g.addEventListener("input",()=>{n[d]=g.value})}else if(p){let g="__custom__",b=[];[...u,...this.getColumnValues(d)].forEach(E=>{let w=(E!=null?E:"").trim();w&&!b.some(v=>v.toLowerCase()===w.toLowerCase())&&b.push(w)});let x=h.createEl("select",{cls:"csv-modal-select"});x.createEl("option",{text:"\u2014",value:""}),b.forEach(E=>x.createEl("option",{text:E,value:E})),x.createEl("option",{text:"+ Custom\u2026",value:g});let _=h.createEl("input",{cls:"csv-modal-input csv-modal-custom",type:"text",placeholder:`Custom ${kt(d).toLowerCase()}`});_.hide(),_.addEventListener("input",()=>{n[d]=_.value}),_.addEventListener("keydown",E=>{E.key==="Enter"&&c()}),x.addEventListener("change",()=>{x.value===g?(_.show(),_.focus(),n[d]=_.value):(_.hide(),n[d]=x.value)})}else if(this.isSelectCol(d)){let b=h.createDiv({cls:"csv-modal-select-wrap"}).createDiv({cls:"csv-select-chip empty"});b.setText("\u2014 click to select \u2014"),b.addEventListener("click",x=>{x.stopPropagation(),Ot(b,n[d],this.getColumnValues(d),_=>{n[d]=_,b.setText(_||"\u2014 click to select \u2014"),b.toggleClass("empty",!_)},t,{multi:It(d)})})}else{let g=sn(h,d,"","csv-modal-input");if(g.addEventListener("input",()=>{n[d]=g.value}),g.addEventListener("keydown",b=>{b.key==="Enter"&&c()}),d===i&&o.size){let b=h.createDiv({cls:"csv-modal-dup-hint"});b.hide(),g.addEventListener("input",()=>{let x=o.get(g.value.trim().toLowerCase());x?(b.setText(`\u26A0 \u201C${x}\u201D is already in this file`),b.show()):b.hide()})}}});let r=t.createDiv({cls:"csv-modal-btns"});r.createEl("button",{text:"Cancel",cls:"csv-modal-cancel"}).addEventListener("click",()=>this.close()),r.createEl("button",{text:"Add entry",cls:"csv-modal-submit"}).addEventListener("click",()=>c());let c=()=>{if(!Object.values(n).some(h=>h.trim())){new Ht.Notice("Fill in at least one field.");return}this.onSubmit(n),this.close()}}onClose(){this.contentEl.empty()}},Ue=class extends Ht.Modal{constructor(e,n,i,o,r,a,l,c,d,h){super(e);this.vvHandler=null;this.row={...n},this.notesCol=i,this.headers=o,this.filePath=r,this.renderComponent=new Ht.Component,this.isNotesCol=a,this.isSelectCol=l,this.getColumnValues=c,this.onSave=d,this.onDelete=h,this.modalEl.addClass("csv-note-expander-modal")}onOpen(){var p,m,g,b,x;this.renderComponent.load();let{contentEl:e}=this;e.empty(),e.addClass("csv-note-expander");let n=window.visualViewport;if(n){let _=()=>{this.modalEl.style.setProperty("--csv-modal-vh",`${n.height}px`)};_(),n.addEventListener("resize",_),n.addEventListener("scroll",_),this.vvHandler=_}let i=e.createDiv({cls:"csv-expander-header"});i.createDiv({cls:"csv-expander-title",text:(m=this.row[(p=this.headers.find(_=>["title","name","Title","Name"].includes(_)))!=null?p:this.headers[0]])!=null?m:"\u2014"});let o=i.createDiv({cls:"csv-expander-header-btns"}),r=e.createDiv({cls:"csv-expander-fields"}),a=this.headers.find(_=>["title","name","Title","Name"].includes(_)),l=this.headers.find(_=>["author","Author","director","Director","artist","Artist","creator","Creator"].includes(_));this.headers.forEach(_=>{if(this.isNotesCol(_))return;let E=r.createDiv({cls:"csv-expander-field-row"});if(E.createDiv({cls:"csv-expander-field-label",text:kt(_)}),this.isSelectCol(_)||!It(_)&&!Js(_)&&vs(this.getColumnValues(_).length)){let v=E.createDiv({cls:`csv-select-chip ${this.row[_]?"":"empty"}`});v.setText(this.row[_]||"\u2014"),v.addEventListener("click",y=>{y.stopPropagation(),Ot(v,this.row[_],this.getColumnValues(_),S=>{this.row[_]=S,v.setText(S||"\u2014"),v.toggleClass("empty",!S)},e,{multi:It(_)})})}else{let v=E.createDiv({cls:"csv-expander-field-value",text:this.row[_]||"\u2014"});v.addEventListener("click",()=>{var D;v.empty();let y=sn(v,_,(D=this.row[_])!=null?D:"","csv-inline-input");y.focus(),y.type==="text"&&y.select();let S=()=>{this.row[_]=y.value,v.empty(),v.setText(y.value||"\u2014")};y.addEventListener("blur",S),y.addEventListener("keydown",M=>{M.key==="Enter"&&y.blur(),M.key==="Escape"&&(v.empty(),v.setText(this.row[_]||"\u2014"))})})}});let c=!1,d=this.notesCol&&(g=this.row[this.notesCol])!=null?g:"",h=null;if(this.notesCol){e.createDiv({cls:"csv-expander-divider"}).createDiv({cls:"csv-expander-notes-label",text:this.notesCol});let E=e.createDiv({cls:"csv-expander-rendered markdown-rendered"});E.title="Click to edit";let w=e.createDiv({cls:"csv-expander-editor"});w.style.display="none";let v=()=>{E.empty(),d.trim()?Ht.MarkdownRenderer.render(this.app,d,E,this.filePath,this.renderComponent):E.createDiv({cls:"csv-notes-empty",text:"+ Add note"})};v(),h=w.createEl("textarea",{cls:"csv-expander-textarea"}),h.value=d,h.addEventListener("input",()=>{d=h.value});let y=()=>{c||(c=!0,E.style.display="none",w.style.display="flex",h.value=d,h.focus())},S=()=>{c&&(c=!1,w.style.display="none",E.style.display="",d=h.value,v())};E.addEventListener("click",D=>{if(D.target.closest("a, button, input, textarea, [contenteditable]"))return;let C=window.getSelection();C&&C.toString().length>0||y()}),h.addEventListener("keydown",D=>{D.key==="Escape"&&(D.preventDefault(),h.blur())}),h.addEventListener("blur",S)}let u=e.createDiv({cls:"csv-expander-footer"});if(this.onDelete){let _=String((x=this.row[(b=this.headers.find(E=>["title","name","Title","Name"].includes(E)))!=null?b:this.headers[0]])!=null?x:"").trim();u.createEl("button",{cls:"csv-expander-delete-btn",text:"Delete"}).addEventListener("click",()=>{let E=_||"this entry";window.confirm(`Delete "${E}"? This can't be undone.`)&&(this.onDelete(),this.close())})}let f=u.createDiv({cls:"csv-expander-footer-right"});f.createEl("button",{cls:"csv-modal-cancel",text:"Cancel"}).addEventListener("click",()=>this.close()),f.createEl("button",{cls:"csv-expander-save-btn",text:"Save & close"}).addEventListener("click",()=>{this.notesCol&&(c&&h&&(d=h.value),this.row[this.notesCol]=d),this.onSave(this.row),this.close()})}onClose(){let e=window.visualViewport;e&&this.vvHandler&&(e.removeEventListener("resize",this.vvHandler),e.removeEventListener("scroll",this.vvHandler)),this.vvHandler=null,this.renderComponent.unload(),this.contentEl.empty()}};var tn=class extends Ht.Modal{constructor(t,e,n,i,o,r,a){super(t),this.headers=e,this.filePath=n,this.current={...i,habitColumns:i.habitColumns?[...i.habitColumns]:void 0},this.autoDetectedHabits=o,this.availableModes=r,this.onSave=a}onOpen(){var S,D,M;let{contentEl:t}=this;t.empty(),t.addClass("csv-add-modal"),t.createEl("h2",{text:"View settings for this file",cls:"csv-modal-title"}),t.createEl("p",{text:"These settings apply only to this file and override the global defaults.",cls:"csv-modal-desc"});let e=t.createDiv({cls:"csv-modal-form"}),n="\u2014 use global default \u2014",i=[n,...this.headers],o=(C,T,k)=>{let A=e.createDiv({cls:"csv-modal-row"});A.createEl("label",{text:C,cls:"csv-modal-label"});let P=A.createEl("select",{cls:"csv-modal-select"});i.forEach(O=>{let z=P.createEl("option",{text:O,value:O});(T!=null?T:n)===O&&(z.selected=!0)}),P.addEventListener("change",()=>k(P.value===n?void 0:P.value))};o("Category column (kanban grouping)",this.current.categoryColumn,C=>{this.current.categoryColumn=C}),o("Status column (row subgroups)",this.current.statusColumn,C=>{this.current.statusColumn=C}),o("Notes column",this.current.notesColumn,C=>{this.current.notesColumn=C});let r=e.createDiv({cls:"csv-modal-row"});r.createEl("label",{text:"Habit columns (dashboard)",cls:"csv-modal-label"});let a=r.createEl("p",{cls:"csv-modal-hint",text:"Select columns to track as habits. Auto-detected columns with binary values (0/1) are pre-selected."}),l=r.createDiv({cls:"csv-modal-checkbox-grid"}),c=new Set((S=this.current.habitColumns)!=null?S:this.autoDetectedHabits);this.headers.forEach(C=>{let T=l.createEl("label",{cls:"csv-modal-checkbox-label"}),k=T.createEl("input",{type:"checkbox"});k.checked=c.has(C),this.autoDetectedHabits.includes(C)&&!this.current.habitColumns&&T.addClass("auto-detected"),T.createSpan({text:C}),k.addEventListener("change",()=>{this.current.habitColumns||(this.current.habitColumns=[...this.autoDetectedHabits]),k.checked?this.current.habitColumns.includes(C)||this.current.habitColumns.push(C):this.current.habitColumns=this.current.habitColumns.filter(A=>A!==C)})});let d=e.createDiv({cls:"csv-modal-row"});d.createEl("label",{text:"Card fields (Library / Kanban)",cls:"csv-modal-label"}),d.createEl("p",{cls:"csv-modal-hint",text:"Columns shown under each card title. Rating renders as stars, theme/tag columns as pills. Leave all unchecked for title-only cards."});let h=d.createDiv({cls:"csv-modal-checkbox-grid"}),u=C=>this.headers.find(T=>C.some(k=>k.toLowerCase()===T.toLowerCase())),f=[u(["Author","Authors","Director","Artist","Creator","By"]),u(["Year","Date","Released"]),u(["Rating","Score","Score /5","Stars"]),u(["Theme","Tags","Tag","Mood"])].filter(C=>!!C),p=new Set((D=this.current.cardFields)!=null?D:f),m=!!this.current.cardFields;this.headers.forEach(C=>{let T=h.createEl("label",{cls:"csv-modal-checkbox-label"}),k=T.createEl("input",{type:"checkbox"});k.checked=p.has(C),f.includes(C)&&!m&&T.addClass("auto-detected"),T.createSpan({text:C}),k.addEventListener("change",()=>{this.current.cardFields||(this.current.cardFields=[...f]),k.checked?this.current.cardFields.includes(C)||this.current.cardFields.push(C):this.current.cardFields=this.current.cardFields.filter(A=>A!==C)})});let g="\u2014 title / primary field \u2014",b=e.createDiv({cls:"csv-modal-row"});b.createEl("label",{text:"Anki card front",cls:"csv-modal-label"}),b.createEl("p",{cls:"csv-modal-hint",text:"Column used as the front of each card when syncing to Anki. Other columns become the back."});let x=b.createEl("select",{cls:"csv-modal-select"});[g,...this.headers].forEach(C=>{var k;let T=x.createEl("option",{text:C,value:C});((k=this.current.ankiFrontCol)!=null?k:g)===C&&(T.selected=!0)}),x.addEventListener("change",()=>{this.current.ankiFrontCol=x.value===g?void 0:x.value});let _=e.createDiv({cls:"csv-modal-row"});_.createEl("label",{text:"Default view",cls:"csv-modal-label"});let E=_.createEl("select",{cls:"csv-modal-select"}),w=[["\u2014 use global default \u2014",""],...this.availableModes.map(C=>[C.label,C.id])],v=(M=this.current.defaultMode)!=null?M:"";v&&!this.availableModes.some(C=>C.id===v)&&w.push([`${v} (no longer available)`,v]),w.forEach(([C,T])=>{let k=E.createEl("option",{text:C,value:T});v===T&&(k.selected=!0)}),E.addEventListener("change",()=>{this.current.defaultMode=E.value?E.value:void 0});let y=t.createDiv({cls:"csv-modal-btns"});y.createEl("button",{text:"Cancel",cls:"csv-modal-cancel"}).addEventListener("click",()=>this.close()),y.createEl("button",{text:"Save",cls:"csv-modal-submit"}).addEventListener("click",()=>{this.onSave(this.current),this.close()})}onClose(){this.contentEl.empty()}},en=class extends Ht.Modal{constructor(e,n,i,o,r){super(e);this.title=n;this.initial=i;this.placeholder=o;this.onSubmit=r}onOpen(){let{contentEl:e}=this;e.empty(),e.addClass("csv-add-modal"),e.createEl("h2",{text:this.title,cls:"csv-modal-title"});let n=e.createEl("input",{cls:"csv-modal-field",type:"text"});n.value=this.initial,n.placeholder=this.placeholder,window.setTimeout(()=>{n.focus(),n.select()},0);let i=()=>{let r=n.value.trim();r&&(this.onSubmit(r),this.close())};n.addEventListener("keydown",r=>{r.key==="Enter"&&(r.preventDefault(),i())});let o=e.createDiv({cls:"csv-modal-btns"});o.createEl("button",{text:"Cancel",cls:"csv-modal-cancel"}).addEventListener("click",()=>this.close()),o.createEl("button",{text:"Create",cls:"csv-modal-submit"}).addEventListener("click",i)}onClose(){this.contentEl.empty()}};var ii=195,ic={AF:"Afghanistan",AL:"Albania",DZ:"Algeria",AD:"Andorra",AO:"Angola",AR:"Argentina",AM:"Armenia",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BD:"Bangladesh",BY:"Belarus",BE:"Belgium",BO:"Bolivia",BA:"Bosnia",BW:"Botswana",BR:"Brazil",BG:"Bulgaria",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CL:"Chile",CN:"China",CO:"Colombia",HR:"Croatia",CU:"Cuba",CY:"Cyprus",CZ:"Czechia",DK:"Denmark",DO:"Dominican Rep.",EC:"Ecuador",EG:"Egypt",ET:"Ethiopia",FI:"Finland",FR:"France",GE:"Georgia",DE:"Germany",GH:"Ghana",GR:"Greece",GT:"Guatemala",GY:"Guyana",HT:"Haiti",HN:"Honduras",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran",IQ:"Iraq",IE:"Ireland",IL:"Israel",IT:"Italy",JP:"Japan",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KP:"N. Korea",KR:"S. Korea",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Laos",LV:"Latvia",LB:"Lebanon",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MY:"Malaysia",ML:"Mali",MT:"Malta",MR:"Mauritania",MX:"Mexico",MD:"Moldova",MN:"Mongolia",ME:"Montenegro",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NP:"Nepal",NL:"Netherlands",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NO:"Norway",OM:"Oman",PK:"Pakistan",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PL:"Poland",PT:"Portugal",QA:"Qatar",RO:"Romania",RU:"Russia",RW:"Rwanda",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SG:"Singapore",SK:"Slovakia",SI:"Slovenia",SO:"Somalia",ZA:"South Africa",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SE:"Sweden",CH:"Switzerland",SY:"Syria",TJ:"Tajikistan",TZ:"Tanzania",TH:"Thailand",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",UG:"Uganda",UA:"Ukraine",AE:"UAE",GB:"United Kingdom",US:"United States",UY:"Uruguay",UZ:"Uzbekistan",VN:"Vietnam",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe",MC:"Monaco",BZ:"Belize"},oc={AF:["DZ","AO","BJ","BW","BF","BI","CM","CV","CF","TD","KM","CD","CG","CI","DJ","EG","GQ","ER","ET","GA","GM","GH","GN","GW","KE","LS","LR","LY","MG","MW","ML","MR","MU","MA","MZ","NA","NE","NG","RE","RW","ST","SN","SC","SL","SO","ZA","SS","SD","TZ","TG","TN","UG","ZM","ZW"],AN:["AQ"],AS:["AF","AM","AZ","BH","BD","BT","BN","KH","CN","CY","GE","IN","ID","IR","IQ","IL","JP","JO","KZ","KW","KG","LA","LB","MY","MV","MN","MM","NP","KP","OM","PK","PS","PH","QA","RU","SA","SG","KR","LK","SY","TW","TJ","TH","TL","TR","TM","AE","UZ","VN","YE"],EU:["AL","AD","AT","BY","BE","BA","BG","HR","CZ","DK","EE","FI","FR","DE","GR","HU","IS","IE","IT","XK","LV","LI","LT","LU","MT","MD","MC","ME","NL","MK","NO","PL","PT","RO","RU","SM","RS","SK","SI","ES","SE","CH","UA","GB","VA"],NA:["AG","BS","BB","BZ","CA","CR","CU","DM","DO","SV","GD","GT","HT","HN","JM","MX","NI","PA","KN","LC","VC","TT","US"],OC:["AU","FJ","KI","MH","FM","NR","NZ","PW","PG","WS","SB","TO","TV","VU"],SA:["AR","BO","BR","CL","CO","EC","GY","PY","PE","SR","UY","VE"]},Io={AF:"Africa",AN:"Antarctica",AS:"Asia",EU:"Europe",NA:"N. America",OC:"Oceania",SA:"S. America"},Vo={};for(let[s,t]of Object.entries(oc))for(let e of t)Vo[e]=s;function wt(s){return ic[s]||s}function $t(s){return!s||s.length!==2?"":String.fromCodePoint(...s.toUpperCase().split("").map(t=>t.charCodeAt(0)+127397))}function Vt(s){if(!s||s.indexOf("?")!==-1)return null;let t=new Date(s+"T12:00:00Z");return isNaN(t.getTime())?null:t}function xs(s){let t=Vt(s.date_entered),e=Vt(s.date_left);return!t||!e?0:Math.max(Math.round((e.getTime()-t.getTime())/864e5),1)}function No(s,t=new Date){let e=t.getTime(),n=null,i=-1/0;for(let o of s){let r=Vt(o.date_entered);if(!(!r||r.getTime()>e)){if(o.date_left.trim()!==""){let a=Vt(o.date_left);if(!a||a.getTime()<e)continue}r.getTime()>i&&(n=o,i=r.getTime())}}return n}function Bo(s){let t=b=>{var x,_,E,w,v,y,S,D;return{date_entered:(x=b.date_entered)!=null?x:"",date_left:(_=b.date_left)!=null?_:"",country:((E=b.country)!=null?E:"").trim().toUpperCase(),city:(w=b.city)!=null?w:"",visa_status:(v=b.visa_status)!=null?v:"",notes:(y=b.notes)!=null?y:"",source:((S=b.source)!=null?S:"").trim().toLowerCase(),resolved:(D=b.resolved)!=null?D:"",_src:b}},e=s.map(t).filter(b=>b.country),n=e.filter(b=>b.source==="confirmed"),i=e.filter(b=>b.source==="inferred"),o=e.filter(b=>b.source==="conflict"),r=[];for(let b of n){let x=Vt(b.date_entered),_=Vt(b.date_left);x&&_&&r.push([x.getTime(),_.getTime()])}let a=b=>{let x=Vt(b.date_entered),_=Vt(b.date_left);if(!x||!_)return!1;let E=x.getTime(),w=_.getTime();return r.some(([v,y])=>E<=y&&w>=v)},l=i.filter(b=>Vt(b.date_entered)&&Vt(b.date_left)&&!a(b)),c=new Set(n.map(b=>b.country)),d=new Set(i.map(b=>b.country)),h=new Set([...d].filter(b=>!c.has(b))),u=new Set([...c,...d]),f=new Map;for(let b of n)f.set(b.country,(f.get(b.country)||0)+xs(b));let p=[...f.entries()].map(([b,x])=>({iso:b,days:x})).sort((b,x)=>x.days-b.days||wt(b.iso).localeCompare(wt(x.iso))),m=p.reduce((b,x)=>b+x.days,0),g=new Set;for(let b of c){let x=Vo[b];x&&g.add(x)}return{confirmed:n,inferred:i,conflicts:o,inferredVisible:l,confRanges:r,confirmedCountries:c,inferredOnlyCountries:h,allCountries:u,countryDays:p,totalConfirmedDays:m,visitedContinents:g,worldPct:Math.round(c.size/ii*100)}}var oi=864e5;function zo(s){if(!s||s.indexOf("?")!==-1)return null;let t=Date.parse(s+"T00:00:00Z");return isNaN(t)?null:t}function rc(s,t,e,n){let i=Math.max(s,e),o=Math.min(t,n);return o<=i?0:Math.round((o-i)/oi)}function ac(s,t){var i;let e=s.window;if(e.type==="all-time")return{start:-1/0,end:1/0,label:"all time"};if(e.type==="calendar-year"){let o=new Date(t).getUTCFullYear();return{start:Date.UTC(o,0,1),end:Date.UTC(o+1,0,1),label:`in ${o}`}}let n=(i=e.days)!=null?i:180;return{start:t-n*oi,end:t+oi,label:`in last ${n} days`}}function Ho(s,t,e=Date.now()){var d,h,u;let n=(d=s.scope.countries)!=null?d:s.scope.country?[s.scope.country]:[],i=new Set(n.map(f=>f.toUpperCase())),o=new Set(((u=(h=s.exempt)==null?void 0:h.visa_status)!=null?u:[]).map(f=>f.toLowerCase().trim())),r=ac(s,e),a=0;for(let f of t){if(!i.has((f.country||"").toUpperCase())||o.has((f.visa_status||"").toLowerCase().trim()))continue;let p=zo(f.date_entered),m=zo(f.date_left);p===null||m===null||(a+=rc(p,m,r.start,r.end))}let l=s.threshold-a,c=a>=s.threshold?"over":a/s.threshold>=.8?"warn":"ok";return{rule:s,used:a,threshold:s.threshold,remaining:l,windowLabel:r.label,status:c}}var $o=["#c9a96e","#4a6fa5","#5ba06e","#a05b8a","#6ea0a0","#a0855b","#7a6ea0","#a06e6e","#6e8fa0","#a09e5b"],lc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function cc(){let s=new Map,t=0;return e=>(s.has(e)||s.set(e,$o[t++%$o.length]),s.get(e))}function dc(s){let t=document.body.createDiv({cls:"csv-tv-tooltip"}),e=null,n=(r,a)=>{let c=r+14,d=a+16,h=t.offsetWidth,u=t.offsetHeight;c+h+8>window.innerWidth&&(c=r-h-14),d+u+8>window.innerHeight&&(d=a-u-16),t.style.left=`${Math.max(8,c)}px`,t.style.top=`${Math.max(8,d)}px`},i=r=>{var c,d;let a=(d=(c=r.target)==null?void 0:c.closest("[data-tip]"))!=null?d:null,l=(a==null?void 0:a.getAttribute("data-tip"))||"";if(!a||!l){e&&(e=null,t.removeClass("is-on"));return}a!==e&&(e=a,t.setText(l),t.addClass("is-on")),n(r.clientX,r.clientY)},o=()=>{e=null,t.removeClass("is-on")};return s.addEventListener("pointermove",i),s.addEventListener("pointerleave",o),()=>{s.removeEventListener("pointermove",i),s.removeEventListener("pointerleave",o),t.remove()}}function ri(s){let t=xs(s);return t?`${t}d`:"\u2014"}function Ke(s){return s||"\u2014"}function Cs(s){return s.createDiv({cls:"csv-tv-table-wrap"}).createEl("table",{cls:"csv-tv-table"})}function _s(s,t,e,n){s.addClass("csv-tv-editable"),s.title="Click to edit";let i=()=>{s.empty(),s.setText(t[e]?t[e]:"\u2014")};i(),s.addEventListener("click",()=>{var r;if(s.querySelector("input"))return;s.empty();let o=sn(s,e,(r=t[e])!=null?r:"","csv-inline-input");o.focus(),o.type==="text"&&o.select(),o.addEventListener("blur",()=>{t[e]=o.value,n(),i()}),o.addEventListener("keydown",a=>{var l;a.key==="Enter"&&o.blur(),a.key==="Escape"&&(o.value=(l=t[e])!=null?l:"",o.blur())})})}async function Wo(s,t,e,n=()=>{},i=null,o=()=>{}){let r=Bo(t),a=s.createDiv({cls:"csv-tv"});if(!r.confirmed.length&&!r.inferred.length){a.createDiv({cls:"csv-empty-state",text:"No travel rows found. Expected columns: country, date_entered, date_left, source."});return}o(dc(a));let l=null,c=()=>{a.querySelectorAll(".country-path").forEach(f=>{let p=(f.getAttribute("data-iso")||"").toUpperCase();f.classList.toggle("cp-selected",!!l&&p===l)}),a.querySelectorAll(".csv-tv-seg").forEach(f=>{f.classList.toggle("is-dim",!!l&&f.getAttribute("data-iso")!==l)}),a.querySelectorAll("tr[data-iso]").forEach(f=>{f.classList.toggle("is-selected",!!l&&f.getAttribute("data-iso")===l)}),u.empty(),l&&(fc(u,r,l,()=>d(null)),u.scrollIntoView({behavior:"smooth",block:"nearest"}))},d=f=>{l=f&&f!==l?f:null,c()};hc(a,r);let h=a.createDiv({cls:"csv-tv-mapwrap"});h.createDiv({cls:"csv-tv-map-loading",text:"Loading map\u2026"});let u=a.createDiv({cls:"csv-tv-detailwrap"});i&&i.length&&pc(a,r.confirmed,i),gc(a,r,d),mc(a,r,d),bc(a,r,n);try{let f=await e();h.empty(),f?uc(h,f,r,d):h.createDiv({cls:"csv-tv-map-loading",text:"World map asset not found (world-map.svg)."})}catch(f){h.empty(),h.createDiv({cls:"csv-tv-map-loading",text:"Couldn't load world map."})}}function hc(s,t){let e=s.createDiv({cls:"csv-tv-stats"}),n=(c,d,h="")=>{let u=e.createDiv({cls:"csv-tv-stat"});u.createDiv({cls:"csv-tv-stat-label",text:c}),u.createDiv({cls:"csv-tv-stat-value",text:d}),h&&u.createDiv({cls:"csv-tv-stat-sub",text:h})},i=Math.round(t.allCountries.size/ii*100);n("Countries",String(t.confirmedCountries.size),`${t.worldPct}% of world`),n("Incl. photos",String(t.allCountries.size),`${i}% of world`),n("Continents",`${t.visitedContinents.size} / 7`,[...t.visitedContinents].map(c=>Io[c]||c).sort().join(", ")),n("Confirmed trips",String(t.confirmed.length)),n("Confirmed days",String(t.totalConfirmedDays));let o=new Set(t.confirmed.map(c=>c.city.trim().toLowerCase()).filter(Boolean));o.size&&n("Cities",String(o.size));let r=null,a=0;for(let c of t.confirmed){let d=xs(c);d>a&&(a=d,r=c)}if(r){let c=r.date_entered.slice(0,4);n("Longest trip",`${a}d`,`${$t(r.country)} ${wt(r.country)}${c?` \xB7 ${c}`:""}`)}let l=No(t.confirmed);if(l){let c=Vt(l.date_entered),d=Math.max(1,Math.round((Date.now()-c.getTime())/864e5)+1),h=s.createDiv({cls:"csv-tv-now"});h.createSpan({cls:"csv-tv-now-loc",text:`\u{1F4CD} Currently in ${$t(l.country)} ${wt(l.country)}`}),h.createSpan({cls:"csv-tv-now-sub",text:` \u2014 since ${l.date_entered} (day ${d})${l.city?` \xB7 ${l.city}`:""}`})}}function uc(s,t,e,n){let i=s.createDiv({cls:"csv-tv-map"});i.innerHTML=t,i.querySelectorAll(".country-path").forEach(r=>{let a=(r.getAttribute("data-iso")||"").toUpperCase();if(r.classList.remove("cp-unvisited","cp-confirmed","cp-inferred"),a&&e.confirmedCountries.has(a)){r.classList.add("cp-confirmed");let l=e.countryDays.find(c=>c.iso===a);r.setAttr("aria-label",`${wt(a)} \u2014 ${l&&l.days?l.days+"d confirmed":"confirmed"}`),r.setAttr("data-tip",`${wt(a)}${l&&l.days?" \xB7 "+l.days+"d":""} \xB7 click for trips`)}else a&&e.inferredOnlyCountries.has(a)?(r.classList.add("cp-inferred"),r.setAttr("aria-label",`${wt(a)} \u2014 photo evidence`),r.setAttr("data-tip",`${wt(a)} \xB7 photo evidence \xB7 click for trips`)):a?(r.classList.add("cp-unvisited"),r.setAttr("data-tip",wt(a))):r.classList.add("cp-unvisited");a&&r.addEventListener("click",()=>{e.allCountries.has(a)?n(a):n(null)})}),i.querySelectorAll(".country-path").forEach(r=>{try{let a=r.getBoundingClientRect();a.width&&a.height&&Math.max(a.width,a.height)<12&&r.classList.add("cp-tiny")}catch(a){}});let o=s.createDiv({cls:"csv-tv-map-legend"});o.createSpan({cls:"csv-tv-leg"}).innerHTML='<span class="csv-tv-dot cp-confirmed"></span> Confirmed',o.createSpan({cls:"csv-tv-leg"}).innerHTML='<span class="csv-tv-dot cp-inferred"></span> Photo evidence'}function fc(s,t,e,n){var g,b;let i=s.createDiv({cls:"csv-tv-detail"}),o=i.createDiv({cls:"csv-tv-detail-head"});o.createSpan({cls:"csv-tv-detail-flag",text:$t(e)});let r=o.createDiv({cls:"csv-tv-detail-titles"});r.createDiv({cls:"csv-tv-detail-name",text:wt(e)});let a=t.confirmed.filter(x=>x.country===e),l=t.inferred.filter(x=>x.country===e),c=(b=(g=t.countryDays.find(x=>x.iso===e))==null?void 0:g.days)!=null?b:0,d=new Set([...a,...l].map(x=>x.city.trim()).filter(Boolean)),h=[];a.length&&h.push(`${a.length} confirmed trip${a.length===1?"":"s"}`),c&&h.push(`${c}d total`),l.length&&h.push(`${l.length} photo-inferred`),d.size&&h.push(`${d.size} cit${d.size===1?"y":"ies"}`),r.createDiv({cls:"csv-tv-detail-sub",text:h.join(" \xB7 ")}),o.createEl("button",{cls:"csv-tv-detail-close",text:"\u2715",title:"Close"}).addEventListener("click",n);let u=nn([...a.map(x=>({r:x,inf:!1,date_entered:x.date_entered})),...l.map(x=>({r:x,inf:!0,date_entered:x.date_entered}))]);if(!u.length)return;let f=Cs(i),p=f.createEl("thead").createEl("tr");["","Entered","Left","Days","City","Visa"].forEach(x=>p.createEl("th",{text:x}));let m=f.createEl("tbody");for(let{r:x,inf:_}of u){let E=m.createEl("tr");E.createEl("td",{text:_?"\u{1F4F7}":"",cls:"csv-tv-flag",attr:_?{"data-tip":"Photo-inferred"}:{}}),E.createEl("td",{text:Ke(x.date_entered)}),E.createEl("td",{text:Ke(x.date_left)}),E.createEl("td",{text:ri(x)}),E.createEl("td",{text:x.city}),E.createEl("td",{text:x.visa_status})}}function pc(s,t,e){s.createDiv({cls:"csv-tv-sec-title",text:"Residency counters"});let n=s.createDiv({cls:"csv-tv-res-grid"});for(let i of e){let o=Ho(i,t),r=n.createDiv({cls:`csv-tv-res-card csv-tv-res-${o.status}`});r.createDiv({cls:"csv-tv-res-label",text:i.label});let a=r.createDiv({cls:"csv-tv-res-nums"});a.createSpan({cls:"csv-tv-res-used",text:String(o.used)}),a.createSpan({cls:"csv-tv-res-thresh",text:` / ${o.threshold}`}),a.createSpan({cls:"csv-tv-res-window",text:` ${o.windowLabel}`});let l=r.createDiv({cls:"csv-tv-res-bar"});l.createDiv({cls:"csv-tv-res-fill"}).style.width=`${Math.min(100,Math.round(o.used/o.threshold*100))}%`;let c=o.status==="over"?i.onExceed?`Over \u2014 ${i.onExceed}`:"Limit reached":`${o.remaining} day${o.remaining===1?"":"s"} left`;r.createDiv({cls:"csv-tv-res-status",text:c}),i.note&&r.createDiv({cls:"csv-tv-res-note",text:i.note})}s.createDiv({cls:"csv-tv-res-disclaimer",text:"Indicators only \u2014 not legal or tax advice. Based on confirmed trips."})}function gc(s,t,e){s.createDiv({cls:"csv-tv-sec-title",text:"Countries visited"});let n=Cs(s),i=n.createEl("thead").createEl("tr");["","Country","Total days"].forEach(r=>i.createEl("th",{text:r}));let o=n.createEl("tbody");for(let{iso:r,days:a}of t.countryDays){let l=o.createEl("tr",{cls:"csv-tv-row-click",attr:{"data-iso":r}});l.createEl("td",{text:$t(r),cls:"csv-tv-flag"}),l.createEl("td",{text:wt(r)}),l.createEl("td",{text:a?`${a}d`:"\u2014"}),l.addEventListener("click",()=>e(r))}if(t.inferredOnlyCountries.size){let r=s.createDiv({cls:"csv-tv-photo-only"});r.createSpan({text:"\u{1F4F7} Photo evidence only: "}),r.createSpan({text:[...t.inferredOnlyCountries].sort().map($t).join(" ")})}}function mc(s,t,e){s.createDiv({cls:"csv-tv-sec-title",text:"Timeline"});let n=cc(),i=[...t.confirmed.map(c=>({...c,_inf:!1})),...t.inferredVisible.map(c=>({...c,_inf:!0}))].filter(c=>c.date_entered&&c.date_left&&c.date_entered.indexOf("?")===-1),o=new Map;for(let c of i){let d=parseInt(c.date_entered.slice(0,4)),h=parseInt(c.date_left.slice(0,4));if(!(isNaN(d)||isNaN(h)))for(let u=d;u<=h;u++)o.has(u)||o.set(u,[]),o.get(u).push(c)}let r=[...o.keys()].sort((c,d)=>d-c),a=s.createDiv({cls:"csv-tv-timeline"});for(let c of r){let d=new Date(`${c}-01-01T12:00:00Z`).getTime(),h=new Date(`${c}-12-31T12:00:00Z`).getTime(),u=h-d,f=a.createDiv({cls:"csv-tv-tl-year"}),p=0,m=new Set;for(let _ of o.get(c)){if(m.add(_.country),_._inf)continue;let E=Math.max(new Date(_.date_entered+"T12:00:00Z").getTime(),d),w=Math.min(new Date(_.date_left+"T12:00:00Z").getTime(),h);E<=w&&(p+=Math.max(Math.round((w-E)/864e5)+1,1))}let g=f.createDiv({cls:"csv-tv-tl-label"});g.createSpan({text:String(c)}),g.createSpan({cls:"csv-tv-tl-sub",text:`${p?`${p}d \xB7 `:""}${m.size} ${m.size===1?"country":"countries"}`});let b=f.createDiv({cls:"csv-tv-month-row"});lc.forEach(_=>b.createDiv({cls:"csv-tv-month-tick",text:_}));let x=f.createDiv({cls:"csv-tv-track"});for(let _ of o.get(c)){let E=Math.max(new Date(_.date_entered+"T12:00:00Z").getTime(),d),w=Math.min(new Date(_.date_left+"T12:00:00Z").getTime(),h);if(E>w)continue;let v=(E-d)/u*100,y=Math.max((w-E+864e5)/u*100,.5),S=n(_.country),D=x.createDiv({cls:`csv-tv-seg${_._inf?" csv-tv-seg-inf":""}`});D.style.left=`${v}%`,D.style.width=`${y}%`,_._inf?(D.style.borderColor=S,D.style.background=S+"22",D.style.color=S):D.style.background=S,D.setAttr("data-iso",_.country),D.setAttr("data-tip",`${wt(_.country)} ${_.date_entered} \u2192 ${_.date_left} (${xs(_)}d)${_.visa_status?" ["+_.visa_status+"]":""}${_._inf?" [photo]":""}`),D.addEventListener("click",()=>e(_.country)),y>4?D.createSpan({cls:"csv-tv-seg-lbl",text:`${$t(_.country)} ${_.country}`}):y>2&&D.createSpan({cls:"csv-tv-seg-lbl",text:$t(_.country)})}}a.createDiv({cls:"csv-tv-tl-legend"}).setText("Confirmed (solid) \xB7 Photo inferred (outlined)")}function nn(s){return[...s].sort((t,e)=>!t.date_entered&&!e.date_entered?0:t.date_entered?e.date_entered?e.date_entered.localeCompare(t.date_entered):-1:1)}function bc(s,t,e){s.createDiv({cls:"csv-tv-sec-title",text:"Confirmed trips"}),s.createDiv({cls:"csv-tv-edit-hint",text:"Dates, city, visa and notes are editable \u2014 click a cell. Edit country in Table view."});let n=Cs(s),i=n.createEl("thead").createEl("tr");["","Country","Entered","Left","Duration","City","Visa","Notes"].forEach(r=>i.createEl("th",{text:r}));let o=n.createEl("tbody");for(let r of nn(t.confirmed)){let a=o.createEl("tr");a.createEl("td",{text:$t(r.country),cls:"csv-tv-flag"}),a.createEl("td",{text:wt(r.country)}),_s(a.createEl("td"),r._src,"date_entered",e),_s(a.createEl("td"),r._src,"date_left",e),a.createEl("td",{text:ri(r)}),_s(a.createEl("td"),r._src,"city",e),_s(a.createEl("td"),r._src,"visa_status",e),_s(a.createEl("td"),r._src,"notes",e)}if(t.inferred.length){let r=s.createEl("details",{cls:"csv-tv-details"});r.createEl("summary",{text:`\u{1F4F7} Photo inferred trips (${t.inferred.length})`});let a=Cs(r),l=a.createEl("thead").createEl("tr");["","Country","Entered","Left","Days","City"].forEach(d=>l.createEl("th",{text:d}));let c=a.createEl("tbody");for(let d of nn(t.inferred)){let h=c.createEl("tr");h.createEl("td",{text:$t(d.country),cls:"csv-tv-flag"}),h.createEl("td",{text:wt(d.country)}),h.createEl("td",{text:Ke(d.date_entered)}),h.createEl("td",{text:Ke(d.date_left)}),h.createEl("td",{text:ri(d)}),h.createEl("td",{text:d.city})}}if(t.conflicts.length){let r=s.createEl("details",{cls:"csv-tv-details csv-tv-details-warn"});r.createEl("summary",{text:`\u26A0 ${t.conflicts.length} conflict(s) \u2014 photo evidence contradicts a confirmed entry`});let a=Cs(r),l=a.createEl("thead").createEl("tr");["","Country (photos)","Dates","Detail"].forEach(d=>l.createEl("th",{text:d}));let c=a.createEl("tbody");for(let d of nn(t.conflicts)){let h=c.createEl("tr");h.createEl("td",{text:$t(d.country),cls:"csv-tv-flag"}),h.createEl("td",{text:d.country}),h.createEl("td",{text:`${Ke(d.date_entered)} \u2192 ${Ke(d.date_left)}`}),h.createEl("td",{text:d.notes})}}}var Ft=require("obsidian"),on=class extends Ft.PluginSettingTab{constructor(t,e){super(t,e),this.plugin=e}display(){let{containerEl:t}=this;t.empty(),t.createEl("h2",{text:"XLSX Card View"}),new Ft.Setting(t).setName("Default view mode").addDropdown(n=>n.addOption("kanban-genre","Kanban").addOption("table","Table").setValue(this.plugin.settings.defaultMode).onChange(async i=>{this.plugin.settings.defaultMode=i,await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Status column name").addText(n=>n.setValue(this.plugin.settings.statusColumn).onChange(async i=>{this.plugin.settings.statusColumn=i,await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Category/Genre column name").addText(n=>n.setValue(this.plugin.settings.categoryColumn).onChange(async i=>{this.plugin.settings.categoryColumn=i,await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Notes column names").setDesc("Comma-separated.").addText(n=>n.setValue(this.plugin.settings.notesColumns.join(", ")).onChange(async i=>{this.plugin.settings.notesColumns=i.split(",").map(o=>o.trim()),await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Select/dropdown columns").setDesc("Comma-separated column names that use a dropdown picker.").addText(n=>n.setValue(this.plugin.settings.selectColumns.join(", ")).onChange(async i=>{this.plugin.settings.selectColumns=i.split(",").map(o=>o.trim()),await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Notes subfolder").addText(n=>n.setPlaceholder("Notes").setValue(this.plugin.settings.notesSubfolder).onChange(async i=>{this.plugin.settings.notesSubfolder=i,await this.plugin.saveSettings()})),new Ft.Setting(t).setName("Reset column widths").addButton(n=>n.setButtonText("Reset").onClick(async()=>{this.plugin.settings.columnWidths={},await this.plugin.saveSettings(),new Ft.Notice("Column widths reset.")})),new Ft.Setting(t).setName("Residency counters (travel view)").setDesc("Show residency / tax day-gauges in the travel view.").addToggle(n=>n.setValue(this.plugin.settings.showResidency!==!1).onChange(async i=>{this.plugin.settings.showResidency=i,await this.plugin.saveSettings()})),t.createEl("h3",{text:"Residency rules"}),t.createEl("p",{cls:"setting-item-description",text:"Each rule counts days in the listed countries within the window, minus exempt visa rows, against the threshold. Counts confirmed trips only. Indicators, not legal/tax advice."});let e=t.createDiv({cls:"csv-rr-wrap"});this.renderResidencyRules(e)}renderResidencyRules(t){var o;t.empty();let e=(o=this.plugin.settings.residencyRules)!=null?o:this.plugin.settings.residencyRules=[],n=()=>void this.plugin.saveSettings();e.forEach((r,a)=>{var b,x,_,E,w,v;let l=t.createDiv({cls:"csv-rr-card"}),c=l.createDiv({cls:"csv-rr-head"}),d=c.createEl("input",{cls:"csv-rr-label",type:"text",value:r.label});d.placeholder="Label (e.g. \u{1F1EA}\u{1F1FA} Schengen 90/180)",d.addEventListener("input",()=>{r.label=d.value,n()});let h=c.createEl("button",{cls:"csv-rr-del",text:"\u2715"});h.setAttr("aria-label","Remove rule"),h.addEventListener("click",async()=>{e.splice(a,1),await this.plugin.saveSettings(),this.renderResidencyRules(t)});let u=l.createDiv({cls:"csv-rr-grid"}),f=(y,S,D,M="")=>{let C=u.createDiv({cls:"csv-rr-field"});C.createEl("label",{text:y});let T=C.createEl("input",{type:"text",value:S});M&&(T.placeholder=M),T.addEventListener("input",()=>{D(T.value),n()})},p=(b=r.scope.countries)!=null?b:r.scope.country?[r.scope.country]:[];f("Countries (ISO-2, comma)",p.join(", "),y=>{r.scope={countries:y.split(",").map(S=>S.trim().toUpperCase()).filter(Boolean)}},"US, GB");let m=u.createDiv({cls:"csv-rr-field"});m.createEl("label",{text:"Window"});let g=m.createEl("select");[["calendar-year","Calendar year"],["rolling","Rolling N days"],["all-time","All time"]].forEach(([y,S])=>{let D=g.createEl("option",{text:S,value:y});r.window.type===y&&(D.selected=!0)}),g.addEventListener("change",()=>{r.window={type:g.value,days:r.window.days},n(),this.renderResidencyRules(t)}),r.window.type==="rolling"&&f("Rolling days",String((x=r.window.days)!=null?x:180),y=>{let S=parseInt(y,10);r.window.days=isNaN(S)?void 0:S},"180"),f("Threshold (days)",String(r.threshold),y=>{let S=parseInt(y,10);r.threshold=isNaN(S)?0:S},"183"),f("Exempt visas (comma)",((E=(_=r.exempt)==null?void 0:_.visa_status)!=null?E:[]).join(", "),y=>{let S=y.split(",").map(D=>D.trim()).filter(Boolean);r.exempt=S.length?{visa_status:S}:void 0},"F-1, J-1"),f("On-exceed label",(w=r.onExceed)!=null?w:"",y=>{r.onExceed=y||void 0},"tax resident"),f("Note",(v=r.note)!=null?v:"",y=>{r.note=y||void 0},"optional caveat")}),t.createDiv({cls:"csv-rr-btns"}).createEl("button",{cls:"csv-rr-add",text:"+ Add rule"}).addEventListener("click",async()=>{e.push({label:"New rule",scope:{countries:[]},window:{type:"calendar-year"},threshold:183}),await this.plugin.saveSettings(),this.renderResidencyRules(t)})}};var de=require("obsidian"),jo=qs(bs());async function Uo(s,t,e,n){var G,$;let i=t.split(`
|
||
`).map(L=>L.trim()).filter(Boolean),o="";for(let L of i)if(L.startsWith("file:")){o=L.replace("file:","").trim();break}if(!o){e.createEl("p",{text:"Error: No file specified. Use: file: yourfile.csv",cls:"csv-add-error"});return}let r=s.vault.getAbstractFileByPath(n.sourcePath),a=($=(G=r==null?void 0:r.parent)==null?void 0:G.path)!=null?$:"",l=We(o,a),c=s.vault.getAbstractFileByPath(l);if(!c||!(c instanceof de.TFile)){e.createEl("p",{text:`Error: File not found: ${l}`,cls:"csv-add-error"});return}let d=[],h=[];try{let L=await s.vault.read(c),V=Gt(L);d=V.headers,h=V.rows}catch(L){e.createEl("p",{text:`Error reading file: ${L}`,cls:"csv-add-error"});return}if(!d.length){e.createEl("p",{text:"Error: No columns found in file",cls:"csv-add-error"});return}let u=["0","1","true","false","yes","no",""],f=L=>{let V=h.map(W=>{var j;return((j=W[L])!=null?j:"").toLowerCase().trim()});return V.length>0&&V.every(W=>u.includes(W))},p=L=>{let V=L.toLowerCase();if(["date","day","datum"].includes(V))return!0;let W=h.slice(0,5).map(j=>{var U;return(U=j[L])!=null?U:""});return W.length>0&&W.every(j=>/^\d{4}-\d{2}-\d{2}$/.test(j))},m=L=>{let V=L.toLowerCase();return["notes","note","comments","description","journal"].includes(V)},g=d.filter(L=>f(L)&&!p(L)),b=d.filter(L=>p(L)),x=d.filter(L=>m(L)),_=d.filter(L=>!g.includes(L)&&!b.includes(L)&&!x.includes(L)),E=e.createDiv({cls:"csv-add-form csv-add-compact"}),w=E.createEl("button",{cls:"csv-add-trigger",text:"+ New entry"});w.style.display="none";let v=E.createDiv({cls:"csv-add-card"}),y=v.createDiv({cls:"csv-add-card-header"});y.createEl("span",{cls:"csv-add-card-title",text:"New entry"});let S=y.createEl("button",{cls:"csv-add-card-close",text:"\xD7"}),D=v.createDiv({cls:"csv-add-rows"}),M={},C={},T=(L,V)=>{let W=D.createDiv({cls:`csv-add-row csv-add-row-${V}`});return W.createEl("span",{cls:"csv-add-row-label",text:kt(L)}),W};b.forEach(L=>{let W=T(L,"date").createEl("input",{cls:"csv-add-row-control",type:"date"});W.value=new Date().toISOString().split("T")[0],M[L]=W}),g.forEach(L=>{C[L]=!1;let W=T(L,"toggle").createEl("label",{cls:"csv-add-switch"}),j=W.createEl("input",{type:"checkbox",cls:"csv-add-switch-input"});W.createEl("span",{cls:"csv-add-switch-track"}),j.addEventListener("change",()=>{C[L]=j.checked}),M[L]=j}),_.forEach(L=>{let V=T(L,"field"),W=new Set(h.map(j=>{var U;return((U=j[L])!=null?U:"").trim()}).filter(Boolean));if(vs(W.size)){let j=V.createEl("select",{cls:"csv-add-row-control"});j.createEl("option",{text:"\u2014",value:""}),Array.from(W).sort().forEach(F=>j.createEl("option",{text:F,value:F})),j.createEl("option",{text:"+ Custom",value:"__custom__"});let U=D.createDiv({cls:"csv-add-row csv-add-row-custom"});U.style.display="none";let B=U.createEl("input",{cls:"csv-add-row-control",type:"text",placeholder:`Custom ${kt(L).toLowerCase()}`});D.insertBefore(U,V.nextSibling),j.addEventListener("change",()=>{U.style.display=j.value==="__custom__"?"flex":"none",j.value==="__custom__"&&B.focus()}),M[L]=j,M[`${L}__custom`]=B}else M[L]=V.createEl("input",{cls:"csv-add-row-control",type:"text",placeholder:kt(L)})}),x.forEach(L=>{let V=D.createDiv({cls:"csv-add-row csv-add-row-notes"});V.createEl("span",{cls:"csv-add-row-label",text:kt(L)}),M[L]=V.createEl("textarea",{cls:"csv-add-row-textarea",placeholder:"Optional notes\u2026"})});let k=v.createEl("button",{text:"Add",cls:"csv-add-submit"}),A=y.querySelector(".csv-add-card-title"),P=()=>{if(!b.length)return;let L=M[b[0]];if(!L)return;let V=L.value,W=h.find(j=>j[b[0]]===V);A&&A.setText(W?`Updating ${V}`:"New entry"),v.classList.toggle("is-updating",!!W),k.setText(W?"Update":"Add"),g.forEach(j=>{var I;let U=M[j];if(!U)return;let B=((I=W==null?void 0:W[j])!=null?I:"").toLowerCase().trim(),F=B==="1"||B==="true"||B==="yes";U.checked=F,C[j]=F}),[..._,...x].forEach(j=>{var F,I;let U=M[j];if(!U)return;let B=(F=W==null?void 0:W[j])!=null?F:"";if(U instanceof HTMLSelectElement)if(Array.from(U.options).find(R=>R.value===B)){U.value=B;let R=(I=M[`${j}__custom`])==null?void 0:I.closest(".csv-add-row-custom");R&&(R.style.display="none")}else U.value="";else U instanceof HTMLTextAreaElement,U.value=B})};if(P(),b.length){let L=M[b[0]];L==null||L.addEventListener("change",P)}let O=()=>{v.style.display="block",w.style.display="none";let L=v.querySelector(".csv-add-row-control");L==null||L.focus()},z=()=>{v.style.display="none",w.style.display=""};w.addEventListener("click",O),S.addEventListener("click",z),k.addEventListener("click",async()=>{let L={};d.forEach(I=>{var N,R,Y,K;g.includes(I)?L[I]=C[I]?"1":"0":M[I]instanceof HTMLSelectElement&&M[I].value==="__custom__"?L[I]=(R=(N=M[`${I}__custom`])==null?void 0:N.value)!=null?R:"":M[I]instanceof HTMLTextAreaElement?L[I]=M[I].value:L[I]=(K=(Y=M[I])==null?void 0:Y.value)!=null?K:""});let V=b.length>0&&b.some(I=>{var N;return((N=L[I])!=null?N:"").trim()}),W=[..._,...x].some(I=>{var N;return((N=L[I])!=null?N:"").trim()}),j=g.some(I=>C[I]);if(!V&&!W&&!j){new de.Notice("Please fill at least one field");return}let U=[];try{let I=await s.vault.read(c);U=Gt(I).rows}catch(I){new de.Notice(`Error reading file: ${I}`);return}let B=!1,F=-1;if(b.length>0){let I=b[0],N=L[I];if(F=U.findIndex(R=>R[I]===N),F>=0){B=!0;let R=U[F];d.forEach(Y=>{var K;(g.includes(Y)||((K=L[Y])!=null?K:"").trim())&&(R[Y]=L[Y])})}else U.push(L)}else U.push(L);try{let I=jo.default.unparse(U,{columns:d});await s.vault.modify(c,I),new de.Notice(B?`Updated entry for ${L[b[0]]||""}`:`Added entry to ${c.basename}`),h.length=0,h.push(...U),b.length>0?P():(g.forEach(N=>{C[N]=!1;let R=M[N];R&&(R.checked=!1)}),[..._,...x].forEach(N=>{let R=M[N];R instanceof HTMLSelectElement?R.selectedIndex=0:(R instanceof HTMLTextAreaElement||R)&&(R.value="");let Y=M[`${N}__custom`];if(Y){Y.value="";let K=Y.closest(".csv-add-row-custom");K&&(K.style.display="none")}})),setTimeout(async()=>{let N=s.vault.getAbstractFileByPath(n.sourcePath);if(N instanceof de.TFile){let R=s.workspace.activeLeaf;R&&await R.openFile(N,{state:{mode:"preview"}})}},300)}catch(I){new de.Notice(`Error saving: ${I}`)}})}function rn(s,t){let e=s.getFilteredRows();s.searchQuery.trim()&&t.createDiv({cls:"csv-search-results",text:`Found ${e.length} of ${s.rows.length} entries`});let i=t.createDiv({cls:"csv-table-wrapper"}).createEl("table",{cls:"csv-table"}),o=i.createEl("thead").createEl("tr");s.headers.forEach(l=>{let c=o.createEl("th");c.setText(l),c.addClass("csv-th-sortable"),s.tableSortCol===l&&c.createSpan({cls:"csv-th-sort-indicator",text:s.tableSortDir==="asc"?" \u25B2":" \u25BC"}),c.title="Click to sort",c.addEventListener("click",p=>{p.target.closest(".csv-col-resize-handle")||(s.tableSortCol!==l?(s.tableSortCol=l,s.tableSortDir="asc"):s.tableSortDir==="asc"?s.tableSortDir="desc":s.tableSortCol=null,s.renderView())});let d=s.settings.columnWidths[l];d&&(c.style.width=d+"px");let h=c.createDiv({cls:"csv-col-resize-handle"}),u=0,f=0;h.addEventListener("pointerdown",p=>{p.preventDefault(),p.stopPropagation(),h.setPointerCapture(p.pointerId),u=p.clientX,f=c.offsetWidth;let m=b=>{c.style.width=Math.max(60,f+b.clientX-u)+"px"},g=b=>{s.settings.columnWidths[l]=Math.max(60,f+b.clientX-u),h.removeEventListener("pointermove",m),h.removeEventListener("pointerup",g),s.persistSettings()};h.addEventListener("pointermove",m),h.addEventListener("pointerup",g)})}),o.createEl("th",{text:""});let r=matchMedia("(pointer: coarse)").matches,a=i.createEl("tbody");e.forEach(l=>{let c=a.createEl("tr");c.addEventListener("contextmenu",u=>s.openRowContextMenu(l,u)),s.headers.forEach(u=>{var p,m;let f=c.createEl("td");if(s.isNotesCol(u)){f.addClass("csv-table-notes-cell");let g=((p=l[u])!=null?p:"").replace(/#{1,6}\s/g,"").replace(/[*_>`]/g,"").split(`
|
||
`).filter(_=>_.trim()).slice(0,3).join(" \xB7 "),b=g?g.slice(0,200)+(g.length>200?"\u2026":""):"+ Add note",x=f.createSpan({text:b});g||x.addClass("csv-table-notes-empty"),f.title="Click to open note",f.addEventListener("click",_=>{_.stopPropagation(),s.openNoteExpander(l,u)})}else if(s.isSelectCol(u))s.renderSelectField(f,l,u);else{let g=(m=l[u])!=null?m:"";f.setText(g),g.length>80&&(f.title=g),vc(s,f,l,u)}});let d=c.createEl("td",{cls:"csv-table-action"}),h=s.notesFileExists(l);d.createEl("button",{cls:`csv-table-notes-btn ${h?"exists":""}`,text:h?"\u{1F4C4}":"\u271A",title:h?"Open notes":"Create notes"}).addEventListener("click",()=>s.openOrCreateNotes(l)),d.createEl("button",{cls:"csv-table-del-btn",text:"\u2715",title:"Delete row (Undo available)"}).addEventListener("click",()=>s.deleteWithUndo(l))}),r||requestAnimationFrame(()=>{a.querySelectorAll("td:not(.csv-table-notes-cell):not(.csv-table-action)").forEach(l=>{l.scrollHeight>l.clientHeight+1&&l.addClass("csv-cell--clipped")})})}function vc(s,t,e,n){t.addEventListener("click",()=>{var o;t.empty();let i=t.createEl("input",{cls:"csv-inline-input",value:(o=e[n])!=null?o:"",type:"text"});i.focus(),i.select(),i.addEventListener("blur",()=>{e[n]=i.value,s.scheduleSave(),t.empty(),t.setText(i.value||"\u2014")}),i.addEventListener("keydown",r=>{r.key==="Enter"&&i.blur(),r.key==="Escape"&&(t.empty(),t.setText(e[n]||"\u2014"))})})}function an(s){return!!(s.getCategoryCol()||s.getStatusCol()||Ko(s)||s.authorKey())}function Ko(s){return s.resolveCol(["Rating","rating","Score","score","Score /5","Stars","stars"])}function Es(s){var i;let t=(s!=null?s:"").trim();if(!t)return null;let e=((i=t.match(/★/g))!=null?i:[]).length;if(e>0)return e;let n=parseFloat(t);return isNaN(n)||n<=0?null:Math.min(5,n)}var Yo=["watched","read","finished","completed","done","yes","seen"],Go=["watching","reading","in progress","in-progress"],yc=["dropped","abandoned","dnf"];function xc(s){let t=s.toLowerCase();return Yo.includes(t)?"is-done":Go.includes(t)?"is-progress":yc.includes(t)?"is-dropped":""}function Ss(s,t){let e=new Map;return s.forEach(n=>t(n).forEach(i=>{var o;return e.set(i,((o=e.get(i))!=null?o:0)+1)})),e}function ws(s,t,e,n){if(!e.length)return;let i=s.createDiv({cls:"csv-stats-section"});i.createDiv({cls:"csv-stats-section-title",text:t});let o=Math.max(...e.map(r=>r.count));e.forEach(r=>{var h;let a=i.createDiv({cls:"csv-stats-bar-row"});a.createDiv({cls:"csv-stats-bar-label",text:r.label,attr:{title:r.label}});let c=a.createDiv({cls:"csv-stats-bar-track"}).createDiv({cls:`csv-stats-bar-fill ${(h=r.cls)!=null?h:""}`});c.style.width=`${Math.max(2,Math.round(r.count/o*100))}%`;let d=n>0?Math.round(r.count/n*100):0;a.createDiv({cls:"csv-stats-bar-count",text:`${r.count} \xB7 ${d}%`}),r.onClick&&(a.addClass("is-clickable"),a.title=`Show "${r.label}" in the library`,a.addEventListener("click",r.onClick))})}function qo(s,t){let e=s.getFilteredRows();if(s.searchQuery.trim()&&t.createDiv({cls:"csv-search-results",text:`Stats over ${e.length} of ${s.rows.length} entries`}),!e.length){t.createEl("p",{text:"No entries to chart.",cls:"csv-empty-state"});return}let n=t.createDiv({cls:"csv-stats-wrap"}),i=s.getStatusCol(),o=s.getCategoryCol(),r=Ko(s),a=s.authorKey(),l=s.resolveCol(["Year","year"]),c=n.createDiv({cls:"csv-stats-overview"}),d=(u,f)=>{let p=c.createDiv({cls:"csv-stats-chip"});p.createDiv({cls:"csv-stats-chip-value",text:u}),p.createDiv({cls:"csv-stats-chip-label",text:f})};if(d(String(e.length),"entries"),i){let u=e.filter(p=>{var m;return Yo.includes(((m=p[i])!=null?m:"").toLowerCase().trim())}).length;u>0&&d(`${u} \xB7 ${Math.round(u/e.length*100)}%`,"done");let f=e.filter(p=>{var m;return Go.includes(((m=p[i])!=null?m:"").toLowerCase().trim())}).length;f>0&&d(String(f),"in progress")}if(o){let u=Ss(e,f=>{var p;return((p=f[o])!=null?p:"").split(",").map(m=>m.trim()).filter(Boolean)});u.size>0&&d(String(u.size),o.toLowerCase()==="genre"||o.toLowerCase()==="genres"?"genres":"categories")}if(r){let u=e.map(f=>Es(f[r])).filter(f=>f!==null);if(u.length){let f=u.reduce((p,m)=>p+m,0)/u.length;d(`\u2605 ${f.toFixed(1)}`,`avg of ${u.length} rated`)}}let h=(u,f)=>{s.libraryStatusFilter=u!=null?u:"all",s.libraryGenreFilter=f!=null?f:"all",s.mode="library",s.renderView()};if(i){let u=Ss(e,p=>{var g;let m=((g=p[i])!=null?g:"").trim();return m?[m]:[]}),f=Array.from(u.entries()).sort((p,m)=>m[1]-p[1]).map(([p,m])=>({label:p,count:m,cls:xc(p),onClick:o?()=>h(p,null):void 0}));ws(n,`By ${i.toLowerCase()}`,f,e.length)}if(o){let u=Ss(e,p=>{var m;return((m=p[o])!=null?m:"").split(",").map(g=>g.trim()).filter(Boolean)}),f=Array.from(u.entries()).sort((p,m)=>m[1]-p[1]||p[0].localeCompare(m[0])).slice(0,12).map(([p,m])=>({label:p,count:m,onClick:()=>h(null,p)}));ws(n,`By ${o.toLowerCase()}`,f,e.length)}if(r){let u=new Map,f=0;if(e.forEach(p=>{var b;let m=Es(p[r]);if(m===null)return;let g=Math.min(5,Math.max(1,Math.round(m)));u.set(g,((b=u.get(g))!=null?b:0)+1),f++}),f>0){let p=[5,4,3,2,1].filter(m=>{var g;return((g=u.get(m))!=null?g:0)>0}).map(m=>({label:"\u2605".repeat(m),count:u.get(m),cls:"is-rating"}));ws(n,"Ratings",p,f)}}if(l){let u=Ss(e,f=>{var m;let p=((m=f[l])!=null?m:"").match(/\d{4}/);return p?[p[0]]:[]});if(u.size>1){let f=Array.from(u.entries()).sort((p,m)=>p[0].localeCompare(m[0])).map(([p,m])=>({label:p,count:m}));ws(n,"By year",f,e.length)}}if(a){let u=Ss(e,p=>{var g;let m=((g=p[a])!=null?g:"").trim();return m?[m]:[]}),f=Array.from(u.entries()).filter(([,p])=>p>1);if(f.length>=2){let p=f.sort((m,g)=>g[1]-m[1]||m[0].localeCompare(g[0])).slice(0,8).map(([m,g])=>({label:m,count:g}));ws(n,`Top ${a.toLowerCase()}s`,p,e.length)}}}function Nt(s){let t=s.fileCfg.kanbanGroupCol;if(t&&s.headers.includes(t))return t;let e=s.getCategoryCol();if(e)return e;let n=new Set;s.headers.forEach(r=>{s.isNotesCol(r)&&n.add(r)});let i=s.getDateCol();i&&n.add(i);let o=s.titleKey();return o&&n.add(o),Po(s.headers,s.rows,n)}function ln(s,t){let e=Nt(s);if(!e){t.createEl("p",{text:"No groupable column found.",cls:"csv-empty-state"});return}let n=s.getCategoryCol(),i=s.getStatusCol(),o=i===e?null:i,r=s.getFilteredRows();s.searchQuery.trim()&&t.createDiv({cls:"csv-search-results",text:`Found ${r.length} of ${s.rows.length} entries`});let a=t.createDiv({cls:"csv-kanban-groupbar"});a.createSpan({cls:"csv-kanban-groupbar-label",text:"Group by"});let l=a.createEl("select",{cls:"csv-library-filter-select"});s.headers.filter(g=>!s.isNotesCol(g)).forEach(g=>{let b=l.createEl("option",{text:g===n?`${g} (default)`:g,value:g});g===e&&(b.selected=!0)}),l.addEventListener("change",()=>{let g=s.fileCfg;g.kanbanGroupCol=l.value===n?void 0:l.value,s.saveFileCfg(g),s.renderView(!0)});let c=Lo(e,r.map(g=>{var b;return(b=g[e])!=null?b:""})),d=g=>{var _;let b=(_=g[e])!=null?_:"",x;if(c){let E=Ao(b);x=E?[E]:[]}else x=b.split(",").map(E=>E.trim()).filter(Boolean);return x.length||(x=["\u2014"]),x},h=new Set;r.forEach(g=>d(g).forEach(b=>h.add(b)));let u=Array.from(h).sort();if(!u.length){let g=t.createDiv({cls:"csv-empty-state"});g.createEl("p",{text:s.searchQuery?"No matching entries found.":`No "${e}" values found.`}),s.searchQuery&&g.createEl("button",{cls:"csv-clear-filters-btn",text:"Clear search"}).addEventListener("click",()=>{s.searchQuery="",s.renderView()});return}let f=["In progress","Finished","Not started"],p=o?Array.from(new Set([...f,...r.map(g=>{var b;return(b=g[o])!=null?b:""}).filter(Boolean)])).filter(g=>r.some(b=>{var x;return((x=b[o])!=null?x:"")==g})):[],m=t.createDiv({cls:"csv-kanban-board"});u.forEach(g=>{let b=r.filter(w=>d(w).includes(g));if(!b.length)return;let x=m.createDiv({cls:"csv-kanban-col"}),_=x.createDiv({cls:"csv-kanban-col-header"});_.createDiv({cls:"csv-kanban-col-title",text:g}),_.createDiv({cls:"csv-kanban-col-count",text:String(b.length)});let E=x.createDiv({cls:"csv-kanban-col-body"});if(o&&p.length){p.forEach(v=>{let y=b.filter(D=>{var M;return((M=D[o])!=null?M:"")===v});if(!y.length)return;let S=E.createDiv({cls:"csv-kanban-status-group"});S.createDiv({cls:`csv-kanban-status-label status-${v.toLowerCase().replace(/\s+/g,"-")}`,text:v}),y.forEach(D=>ai(s,S,D,o,e))});let w=new Set(p);b.filter(v=>{var y;return!w.has((y=v[o])!=null?y:"")}).forEach(v=>ai(s,E,v,o,e))}else b.forEach(w=>ai(s,E,w,o,e))})}function ai(s,t,e,n,i){var y,S,D,M,C,T;let o=t.createDiv({cls:"csv-kanban-card"}),r=s.getNotesCol(),a=(S=(y=s.getImageCol)==null?void 0:y.call(s))!=null?S:null;if(a){let k=Zs(s.app,(D=e[a])!=null?D:"",(C=(M=s.file)==null?void 0:M.path)!=null?C:"");if(k){let A=o.createEl("img",{cls:"csv-kanban-card-img",attr:{src:k,loading:"lazy",alt:""}});A.addEventListener("error",()=>A.remove())}}let l=o.createDiv({cls:"csv-kanban-card-title-row"});l.createDiv({cls:"csv-kanban-card-title",text:s.getTitle(e)}).addEventListener("click",k=>{k.stopPropagation(),s.openNoteExpander(e,r!=null?r:"")});let d=s.notesFileExists(e);l.createEl("button",{cls:`csv-kanban-notes-icon ${d?"exists":""}`,text:d?"\u{1F4C4}":"+",title:d?"Open notes file":"Create notes file"}).addEventListener("click",k=>{k.stopPropagation(),s.openOrCreateNotes(e)});let u=s.getSubtitle(e);u&&o.createDiv({cls:"csv-kanban-card-sub",text:u});let f=s.titleKey(),p=s.authorKey(),m=new Set([n,f,p,i].filter(Boolean)),g=o.createDiv({cls:"csv-kanban-card-meta"});s.headers.forEach(k=>{if(m.has(k)||s.isNotesCol(k)||!e[k])return;let A=g.createDiv({cls:"csv-kanban-chip"});if(A.createSpan({cls:"csv-chip-label",text:k+": "}),s.isSelectCol(k)){let P=A.createSpan({cls:"csv-chip-value csv-chip-select",text:e[k]});P.addEventListener("click",O=>{O.stopPropagation(),Ot(P,e[k],s.getColumnValues(k),z=>{e[k]=z,P.setText(z||"\u2014"),s.scheduleSave()},s.contentEl,{multi:It(k)})})}else{let P=e[k].length>40?e[k].slice(0,38)+"\u2026":e[k],O=A.createSpan({cls:"csv-chip-value",text:P});e[k].length>40&&(O.title=e[k])}});let b=s.getNotesCol(),x=!!(b&&((T=e[b])!=null&&T.trim())),_=o.createDiv({cls:"csv-kanban-notes-preview"});if(x&&b){let k=e[b].replace(/#{1,6}\s/g,"").replace(/[*_>`]/g,"").replace(/\n+/g," ").trim();_.setText(k.slice(0,120)+(k.length>120?"\u2026":"")),_.title="Click to edit"}else _.addClass("csv-kanban-notes-preview--empty"),b&&_.setText("+ Add note");let E=o.createDiv({cls:"csv-kanban-notes-editor"});E.style.display="none";let w=()=>{var z,G,$;let k=s.contentEl.querySelector(".csv-content-area"),A=(z=k==null?void 0:k.scrollLeft)!=null?z:0,P=(G=k==null?void 0:k.scrollTop)!=null?G:0;_.style.display="none",E.style.display="block",E.empty();let O=E.createEl("textarea",{cls:"csv-notes-textarea"});O.value=($=b?e[b]:"")!=null?$:"",O.addEventListener("click",L=>L.stopPropagation()),O.addEventListener("mousedown",L=>L.stopPropagation()),O.addEventListener("input",()=>{O.style.height="auto",O.style.height=O.scrollHeight+"px"}),O.addEventListener("keydown",L=>{L.key==="Escape"&&v(O.value,k,A,P)}),O.addEventListener("blur",()=>v(O.value,k,A,P)),O.focus({preventScroll:!0}),O.setSelectionRange(0,0),O.scrollTop=0,requestAnimationFrame(()=>{O.style.height="auto",O.style.height=Math.max(120,O.scrollHeight)+"px"})},v=(k,A,P,O)=>{if(b&&(e[b]=k,s.scheduleSave()),E.style.display="none",_.style.display="",k.trim()){let z=k.replace(/#{1,6}\s/g,"").replace(/[*_>`]/g,"").replace(/\n+/g," ").trim();_.setText(z.slice(0,120)+(z.length>120?"\u2026":"")),_.removeClass("csv-kanban-notes-preview--empty"),_.title="Click to edit"}else _.addClass("csv-kanban-notes-preview--empty"),_.setText(b?"+ Add note":""),_.removeAttribute("title");A&&(A.scrollLeft=P,A.scrollTop=O,requestAnimationFrame(()=>{A.scrollLeft=P,A.scrollTop=O,requestAnimationFrame(()=>{A.scrollLeft=P,A.scrollTop=O})}),setTimeout(()=>{A.scrollLeft=P,A.scrollTop=O},50))};_.addEventListener("click",k=>{if(k.stopPropagation(),b&&matchMedia("(pointer: coarse)").matches){s.openNoteExpander(e,b);return}w()}),o.addEventListener("contextmenu",k=>s.openRowContextMenu(e,k))}function cn(s,t){var D,M;let e=Nt(s),n=s.getStatusCol(),i=(D=s.titleKey())!=null?D:s.headers[0],o=s.authorKey();if(!e){t.createEl("p",{text:"No groupable column found.",cls:"csv-empty-state"});return}let r=new Set;s.rows.forEach(C=>{var k;((k=C[e])!=null?k:"").split(",").map(A=>A.trim()).filter(Boolean).forEach(A=>r.add(A))});let a=new Set;n&&s.rows.forEach(C=>{var k;let T=((k=C[n])!=null?k:"").trim();T&&a.add(T)});let l=t.createDiv({cls:"csv-library-filters"}),c=l.createEl("select",{cls:"csv-library-filter-select"});c.createEl("option",{text:"All",value:"all"});let d=["watched","read","finished","completed","done","yes","seen"],h=["watching","reading","in progress","in-progress"],u=Array.from(a).some(C=>d.includes(C.toLowerCase())),f=Array.from(a).some(C=>h.includes(C.toLowerCase()));(u||f)&&(c.createEl("option",{text:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500",value:"",attr:{disabled:"true"}}),u&&c.createEl("option",{text:"\u2713 Done",value:"__done__"}),f&&c.createEl("option",{text:"\u25D0 In Progress",value:"__inprogress__"}),c.createEl("option",{text:"\u25CB Not Started",value:"__notstarted__"})),a.size>0&&(c.createEl("option",{text:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500",value:"",attr:{disabled:"true"}}),Array.from(a).sort().forEach(C=>{c.createEl("option",{text:C,value:C})})),c.value=s.libraryStatusFilter;let p=l.createEl("select",{cls:"csv-library-filter-select"});p.createEl("option",{text:"All genres",value:"all"}),Array.from(r).sort().forEach(C=>{p.createEl("option",{text:C,value:C})}),p.value=s.libraryGenreFilter;let m=s.resolveCol(["Year","year","Date","date"]),g=s.resolveCol(["Rating","rating","Score","score","Score /5","Stars","stars"]),b=s.resolveCol(["Theme","theme","Tags","tags","Tag","tag","Mood","mood"]),x=(M=s.fileCfg.librarySort)!=null?M:"status",_=l.createEl("select",{cls:"csv-library-filter-select"}),E=[["status","Sort: Status"],["title","Sort: Title"]];g&&E.push(["rating","Sort: Rating"]),m&&E.push(["year","Sort: Year"]),E.forEach(([C,T])=>{let k=_.createEl("option",{text:T,value:C});C===x&&(k.selected=!0)}),_.addEventListener("change",()=>{let C=s.fileCfg;C.librarySort=_.value==="status"?void 0:_.value,s.saveFileCfg(C),s.renderView(!0)});let w=()=>{s.libraryStatusFilter=c.value,s.libraryGenreFilter=p.value,s.renderView(!0)};c.addEventListener("change",w),p.addEventListener("change",w);let v=s.rows.filter(C=>{var T,k;if(s.libraryStatusFilter!=="all"&&n){let A=((T=C[n])!=null?T:"").toLowerCase();if(s.libraryStatusFilter==="__done__"){if(!d.includes(A))return!1}else if(s.libraryStatusFilter==="__inprogress__"){if(!h.includes(A))return!1}else if(s.libraryStatusFilter==="__notstarted__"){if(d.includes(A)||h.includes(A))return!1}else if(A!==s.libraryStatusFilter.toLowerCase())return!1}if(s.libraryGenreFilter!=="all"&&!((k=C[e])!=null?k:"").split(",").map(P=>P.trim().toLowerCase()).includes(s.libraryGenreFilter.toLowerCase()))return!1;if(s.searchQuery.trim()){let A=s.searchQuery.toLowerCase().trim();if(!s.headers.some(P=>{var O;return((O=C[P])!=null?O:"").toLowerCase().includes(A)}))return!1}return!0});(s.libraryStatusFilter!=="all"||s.libraryGenreFilter!=="all"||s.searchQuery.trim())&&t.createDiv({cls:"csv-library-result-count",text:`Showing ${v.length} of ${s.rows.length} entries`});let y={};v.forEach(C=>{var k;let T=s.libraryGenreFilter!=="all"?[s.libraryGenreFilter]:((k=C[e])!=null?k:"Uncategorized").split(",").map(A=>A.trim()).filter(Boolean);T.length===0&&T.push("Uncategorized"),T.forEach(A=>{y[A]||(y[A]=[]),y[A].push(C)})});let S=t.createDiv({cls:"csv-library-sections"});if(Object.keys(y).sort().forEach(C=>{var j,U,B,F,I;let T=y[C],k=S.createEl("details",{cls:"csv-library-section"}),A=C.toLowerCase(),P=((j=s.fileCfg.collapsedGroups)!=null?j:[]).map(N=>N.toLowerCase());k.open=!((U=s.collapsedGroups)!=null&&U.has(A)||P.includes(A)),k.addEventListener("toggle",()=>{var Z;let N=s.fileCfg,R=((Z=N.collapsedGroups)!=null?Z:[]).map(X=>X.toLowerCase()),Y=new Set(R);k.open?Y.delete(A):Y.add(A);let K=Array.from(Y);K.length===R.length&&K.every(X=>R.includes(X))||(N.collapsedGroups=K,s.saveFileCfg(N))});let O=k.createEl("summary",{cls:"csv-library-section-header"});O.innerHTML=`<span class="csv-library-arrow">\u25B6</span> ${C} <span class="csv-library-count">${T.length}</span>`;let z=k.createDiv({cls:"csv-library-grid"}),G=(N,R)=>{var Y,K;return((Y=N[i])!=null?Y:"").localeCompare((K=R[i])!=null?K:"")},$=(N,R)=>N===null&&R===null?0:N===null?1:R===null?-1:R-N;T.sort((N,R)=>{var Y,K,Z,X;if(x==="title")return G(N,R);if(x==="rating"&&g)return $(Es((Y=N[g])!=null?Y:""),Es((K=R[g])!=null?K:""))||G(N,R);if(x==="year"&&m){let q=ut=>{var st;let J=((st=ut[m])!=null?st:"").match(/\d{4}/);return J?parseInt(J[0],10):null};return $(q(N),q(R))||G(N,R)}if(n){let q=((Z=N[n])!=null?Z:"").toLowerCase(),ut=((X=R[n])!=null?X:"").toLowerCase(),J=d.includes(q),st=d.includes(ut);if(J!==st)return J?-1:1;let at=h.includes(q),Rt=h.includes(ut);if(at!==Rt)return at?-1:1}return G(N,R)});let L=[o,m,g,b].filter(N=>!!N),V=(B=s.fileCfg.cardFields)!=null?B:L,W=(I=(F=s.getImageCol)==null?void 0:F.call(s))!=null?I:null;T.forEach(N=>{var X,q,ut,J,st,at,Rt;let R=z.createDiv({cls:"csv-library-card"});if(W){let it=Zs(s.app,(X=N[W])!=null?X:"",(ut=(q=s.file)==null?void 0:q.path)!=null?ut:"");if(it){let gt=R.createEl("img",{cls:"csv-library-card-img",attr:{src:it,loading:"lazy",alt:""}});gt.addEventListener("error",()=>gt.remove())}}let Y=R.createDiv({cls:"csv-library-card-title"});if(n){let it=((J=N[n])!=null?J:"").toLowerCase();d.includes(it)&&Y.createSpan({cls:"csv-library-done-dot"})}Y.createSpan({text:(st=N[i])!=null?st:"Untitled"});let K=[],Z=[];for(let it of V){if(!it)continue;let gt=String((at=N[it])!=null?at:"").trim();if(gt)if(it===g){let ft=To(gt,it);ft&&R.createDiv({cls:"csv-library-card-rating",text:ft})}else if(it===b)Z.push(...gt.split(",").map(ft=>ft.trim()).filter(Boolean));else if(it===m){let ft=gt.match(/\d{4}/);K.push(ft?ft[0]:gt)}else K.push(gt)}if(K.length&&R.createDiv({cls:"csv-library-card-meta",text:K.join(" \xB7 ")}),s.libraryGenreFilter!=="all"){let it=((Rt=N[e])!=null?Rt:"").split(",").map(gt=>gt.trim()).filter(gt=>gt&>.toLowerCase()!==s.libraryGenreFilter.toLowerCase());Z.push(...it)}if(Z.length){let it=R.createDiv({cls:"csv-library-card-tags"});Z.slice(0,3).forEach(gt=>{it.createSpan({cls:"csv-library-card-tag",text:gt})})}R.addEventListener("click",()=>{var it;s.openNoteExpander(N,(it=s.getNotesCol())!=null?it:"")}),R.addEventListener("contextmenu",it=>s.openRowContextMenu(N,it))})}),Object.keys(y).length===0){let C=S.createDiv({cls:"csv-empty-state"});C.createEl("p",{text:"No entries match your filters."}),C.createEl("button",{cls:"csv-clear-filters-btn",text:"Clear filters"}).addEventListener("click",()=>{s.libraryStatusFilter="all",s.libraryGenreFilter="all",s.searchQuery="",s.renderView()})}}var fn=require("obsidian");var Me=require("obsidian");var li=`---
|
||
obsidianUIMode: preview
|
||
obsidianEditingMode: source
|
||
---
|
||
`,ci=`
|
||
---
|
||
<small style="color:var(--text-faint)">Requires Dataview plugin with DataviewJS enabled</small>
|
||
`;function Xo(s){let{filePath:t,csvPath:e,habitCols:n,labels:i,dateCol:o}=s;return`${li}## Quick Add
|
||
|
||
\`\`\`csv-add
|
||
file: ${t}
|
||
\`\`\`
|
||
|
||
## Entries
|
||
|
||
\`\`\`csv-refresh
|
||
\`\`\`
|
||
|
||
\`\`\`dataviewjs
|
||
const csvData = await dv.io.csv("${e}");
|
||
if (!csvData || !csvData.length) {
|
||
dv.paragraph("No data found");
|
||
} else {
|
||
const data = csvData.array();
|
||
const habits = [${n.map(r=>`"${r}"`).join(", ")}];
|
||
const labels = [${i.map(r=>`"${r}"`).join(", ")}];
|
||
|
||
// View toggle state (stored in localStorage)
|
||
const viewKey = "csv-mobile-view-" + dv.current().file.path;
|
||
let showAll = localStorage.getItem(viewKey) === "all";
|
||
|
||
const container = dv.container;
|
||
|
||
// View toggle buttons
|
||
const toggleWrap = container.createEl("div", { cls: "csv-mobile-toggle" });
|
||
const recentBtn = toggleWrap.createEl("button", { text: "Recent", cls: showAll ? "" : "active" });
|
||
const allBtn = toggleWrap.createEl("button", { text: "All " + data.length, cls: showAll ? "active" : "" });
|
||
|
||
recentBtn.onclick = () => { localStorage.setItem(viewKey, "recent"); location.reload(); };
|
||
allBtn.onclick = () => { localStorage.setItem(viewKey, "all"); location.reload(); };
|
||
|
||
// Apply minimal styles
|
||
toggleWrap.style.cssText = "display:flex;gap:8px;margin-bottom:16px;";
|
||
[recentBtn, allBtn].forEach(btn => {
|
||
btn.style.cssText = "padding:6px 12px;border:none;background:transparent;color:var(--text-muted);font-size:13px;font-weight:500;cursor:pointer;border-radius:6px;";
|
||
if (btn.classList.contains("active")) {
|
||
btn.style.background = "var(--background-secondary)";
|
||
btn.style.color = "var(--text-normal)";
|
||
}
|
||
});
|
||
|
||
// Get entries based on view
|
||
const entries = showAll ? [...data].reverse() : data.slice(-10).reverse();
|
||
|
||
// Table wrapper
|
||
const tableWrap = container.createEl("div");
|
||
tableWrap.style.cssText = "overflow-x:auto;font-size:14px;";
|
||
|
||
// Render table
|
||
const table = tableWrap.createEl("table");
|
||
table.style.cssText = "width:100%;border-collapse:collapse;";
|
||
|
||
// Header
|
||
const thead = table.createEl("thead");
|
||
const headerRow = thead.createEl("tr");
|
||
["Date", ...labels].forEach(h => {
|
||
const th = headerRow.createEl("th", { text: h });
|
||
th.style.cssText = "text-align:left;padding:8px 10px;font-weight:500;color:var(--text-muted);font-size:12px;white-space:nowrap;border-bottom:1px solid var(--background-modifier-border);";
|
||
if (h !== "Date") th.style.textAlign = "center";
|
||
});
|
||
|
||
// Body
|
||
const tbody = table.createEl("tbody");
|
||
entries.forEach(r => {
|
||
const dateVal = r["${o}"];
|
||
let shortDate = "";
|
||
if (dateVal?.toFormat) {
|
||
shortDate = dateVal.toFormat("MM-dd");
|
||
} else if (dateVal instanceof Date) {
|
||
shortDate = (dateVal.getMonth()+1).toString().padStart(2,"0") + "-" + dateVal.getDate().toString().padStart(2,"0");
|
||
} else {
|
||
const s = String(dateVal ?? "");
|
||
shortDate = s.length >= 10 ? s.slice(5, 10) : s;
|
||
}
|
||
|
||
const row = tbody.createEl("tr");
|
||
const dateCell = row.createEl("td", { text: shortDate });
|
||
dateCell.style.cssText = "padding:10px;color:var(--text-muted);font-size:13px;";
|
||
|
||
habits.forEach(h => {
|
||
const td = row.createEl("td");
|
||
td.style.cssText = "padding:10px;text-align:center;";
|
||
const done = r[h] == "1" || r[h] == "true";
|
||
td.textContent = done ? "\u2713" : "\xB7";
|
||
td.style.color = done ? "var(--text-accent)" : "var(--text-faint)";
|
||
td.style.fontWeight = done ? "600" : "400";
|
||
});
|
||
});
|
||
|
||
if (!showAll && data.length > 10) {
|
||
const hint = container.createEl("p");
|
||
hint.style.cssText = "color:var(--text-faint);font-size:12px;margin-top:12px;";
|
||
hint.textContent = "Showing last 10 of " + data.length + " entries";
|
||
}
|
||
}
|
||
\`\`\`
|
||
${ci}`}function Qo(s){let{filePath:t,csvPath:e,titleKey:n,categoryCol:i,statusCol:o,authorKey:r,yearCol:a,ratingCol:l,themeCol:c,compactGrid:d}=s;return`${li}## Add Entry
|
||
|
||
\`\`\`csv-add
|
||
file: ${t}
|
||
\`\`\`
|
||
|
||
## Library
|
||
|
||
\`\`\`csv-refresh
|
||
\`\`\`
|
||
|
||
\`\`\`dataviewjs
|
||
const csvData = await dv.io.csv("${e}");
|
||
if (!csvData || !csvData.length) {
|
||
dv.paragraph("No data found");
|
||
} else {
|
||
const data = csvData.array();
|
||
const container = dv.container;
|
||
|
||
// Keys
|
||
const titleKey = "${n}";
|
||
const categoryCol = "${i}";
|
||
const statusCol = "${o}";
|
||
const authorKey = "${r}";
|
||
const yearCol = "${a}";
|
||
const ratingCol = "${l}";
|
||
const themeCol = "${c}";
|
||
const compactGrid = ${d};
|
||
|
||
// View state
|
||
const viewKey = "csv-mobile-view-" + dv.current().file.path;
|
||
const modeKey = "csv-mobile-mode-" + dv.current().file.path;
|
||
let viewMode = localStorage.getItem(modeKey) || "kanban";
|
||
|
||
// Inject styles
|
||
const style = container.createEl("style");
|
||
style.textContent = \`
|
||
.csv-m-toggle { display:flex; gap:8px; margin-bottom:16px; }
|
||
.csv-m-toggle button { padding:6px 12px; border:none; background:transparent; color:var(--text-muted); font-size:13px; font-weight:500; cursor:pointer; border-radius:6px; }
|
||
.csv-m-toggle button.active { background:var(--background-secondary); color:var(--text-normal); }
|
||
.csv-m-section { margin-bottom:14px; }
|
||
.csv-m-section summary { list-style:none; cursor:pointer; padding:6px 4px; font-weight:600; font-size:13px; display:flex; align-items:center; gap:8px; user-select:none; color:var(--text-normal); }
|
||
.csv-m-section summary::-webkit-details-marker { display:none; }
|
||
.csv-m-section summary .arrow { font-size:11px; color:var(--text-faint); transition:transform 0.2s; line-height:1; }
|
||
.csv-m-section[open] summary .arrow { transform:rotate(90deg); }
|
||
.csv-m-section summary .count { font-weight:500; font-size:12px; color:var(--text-faint); margin-left:auto; }
|
||
.csv-m-grid { display:grid; grid-template-columns:1fr; gap:8px; padding:8px 0 2px; }
|
||
.csv-m-grid.compact { grid-template-columns:1fr 1fr; gap:8px; }
|
||
.csv-m-card { padding:10px 12px; border-radius:10px; background:var(--background-secondary); display:flex; flex-direction:column; gap:4px; }
|
||
.csv-m-card-title { font-weight:600; font-size:13px; display:flex; align-items:center; gap:8px; line-height:1.3; }
|
||
.csv-m-watched-dot { display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--csv-green, #30A14E); flex-shrink:0; }
|
||
.csv-m-card-meta { font-size:12px; color:var(--text-muted); }
|
||
.csv-m-card-year { font-size:11px; color:var(--text-muted); }
|
||
.csv-m-card-rating { font-size:11px; color:var(--text-muted); letter-spacing:1px; }
|
||
.csv-m-card-theme { display:inline-block; align-self:flex-start; font-size:11px; padding:2px 8px; border-radius:999px; background:var(--background-modifier-border); color:var(--text-muted); margin-top:4px; }
|
||
.csv-m-card-status { display:inline-block; align-self:flex-start; font-size:11px; padding:2px 8px; border-radius:999px; margin-top:4px; background:var(--background-modifier-border); color:var(--text-muted); }
|
||
.csv-m-card-status.finished, .csv-m-card-status.read, .csv-m-card-status.watched { background:var(--csv-green-bg, rgba(52,199,89,0.13)); color:var(--csv-green, #30A14E); }
|
||
.csv-m-card-status.in-progress, .csv-m-card-status.reading, .csv-m-card-status.watching { background:var(--csv-blue-bg, rgba(0,122,255,0.13)); color:var(--csv-blue, #2E7CE6); }
|
||
\`;
|
||
|
||
// View toggle
|
||
const toggleWrap = container.createEl("div", { cls: "csv-m-toggle" });
|
||
["Kanban", "Table"].forEach(mode => {
|
||
const btn = toggleWrap.createEl("button", { text: mode });
|
||
if (mode.toLowerCase() === viewMode) btn.classList.add("active");
|
||
btn.onclick = () => { localStorage.setItem(modeKey, mode.toLowerCase()); location.reload(); };
|
||
});
|
||
|
||
if (viewMode === "table") {
|
||
// Table view
|
||
const tableWrap = container.createEl("div");
|
||
tableWrap.style.cssText = "overflow-x:auto;font-size:14px;";
|
||
const table = tableWrap.createEl("table");
|
||
table.style.cssText = "width:100%;border-collapse:collapse;";
|
||
const thead = table.createEl("thead");
|
||
const headerRow = thead.createEl("tr");
|
||
[titleKey, categoryCol, statusCol].filter(Boolean).forEach(h => {
|
||
const th = headerRow.createEl("th", { text: h });
|
||
// Match desktop table convention: uppercase, 11px, tracked, muted.
|
||
th.style.cssText = "text-align:left;padding:8px 10px;font-weight:600;color:var(--text-faint);font-size:11px;text-transform:uppercase;letter-spacing:0.05em;border-bottom:1px solid var(--background-modifier-border);";
|
||
});
|
||
const tbody = table.createEl("tbody");
|
||
data.slice(-30).reverse().forEach(r => {
|
||
const row = tbody.createEl("tr");
|
||
[titleKey, categoryCol, statusCol].filter(Boolean).forEach(col => {
|
||
const td = row.createEl("td", { text: String(r[col] ?? "") });
|
||
td.style.cssText = "padding:10px;font-size:13px;";
|
||
});
|
||
});
|
||
} else {
|
||
// Kanban view \u2014 group by category. String() guards against numeric values that
|
||
// Dataview's CSV parser coerces (e.g. the book "1984" \u2192 Number).
|
||
const groups = {};
|
||
data.forEach(r => {
|
||
const cats = String(r[categoryCol] || "Uncategorized").split(",").map(c => c.trim());
|
||
cats.forEach(cat => {
|
||
if (!groups[cat]) groups[cat] = [];
|
||
groups[cat].push(r);
|
||
});
|
||
});
|
||
|
||
// Negative/default states render as nothing \u2014 keeps cards quiet by default.
|
||
const NEGATIVE_STATUS = new Set(["", "no", "not started", "unwatched", "unread", "todo"]);
|
||
// Affirmative-finished values render as a green dot prefix on the title (matches desktop Library).
|
||
const WATCHED_AFFIRMATIVE = new Set(["yes", "watched", "seen", "finished", "read"]);
|
||
|
||
Object.keys(groups).sort().forEach(cat => {
|
||
const items = groups[cat];
|
||
const section = container.createEl("details", { cls: "csv-m-section" });
|
||
section.open = true;
|
||
const summary = section.createEl("summary");
|
||
summary.innerHTML = '<span class="arrow">\u25B6</span> ' + cat + ' <span class="count">' + items.length + '</span>';
|
||
|
||
const grid = section.createEl("div", { cls: "csv-m-grid" + (compactGrid ? " compact" : "") });
|
||
|
||
// Sort: green-dotted (read/watched/finished) first, then in-progress,
|
||
// then the rest. Mirrors desktop Library: section reads as catalogue
|
||
// (consumed \u2192 backlog), not a todo list.
|
||
items.sort((a, b) => {
|
||
const statusA = String(a[statusCol] || "").toLowerCase();
|
||
const statusB = String(b[statusCol] || "").toLowerCase();
|
||
const isDone = (s) => /^(yes|watched|seen|finished|read|done|completed)$/.test(s);
|
||
const isInProgress = (s) => s.includes("progress") || s.includes("reading") || s.includes("watching");
|
||
const doneA = isDone(statusA), doneB = isDone(statusB);
|
||
if (doneA !== doneB) return doneA ? -1 : 1;
|
||
const inProgressA = isInProgress(statusA), inProgressB = isInProgress(statusB);
|
||
if (inProgressA !== inProgressB) return inProgressA ? -1 : 1;
|
||
return String(a[titleKey] || "").localeCompare(String(b[titleKey] || ""));
|
||
});
|
||
|
||
items.forEach(r => {
|
||
const title = String(r[titleKey] ?? "").trim();
|
||
if (!title) return; // skip rows with no title \u2014 keeps the kanban free of "Untitled" cards
|
||
const status = String(r[statusCol] || "").trim();
|
||
const statusLc = status.toLowerCase();
|
||
const affirmative = WATCHED_AFFIRMATIVE.has(statusLc);
|
||
|
||
const card = grid.createEl("div", { cls: "csv-m-card" });
|
||
const titleEl = card.createEl("div", { cls: "csv-m-card-title" });
|
||
if (affirmative) {
|
||
titleEl.createEl("span", { cls: "csv-m-watched-dot", attr: { title: status } });
|
||
}
|
||
titleEl.createEl("span", { text: title });
|
||
|
||
// Year (small muted, just under title)
|
||
const year = yearCol ? String(r[yearCol] ?? "").trim() : "";
|
||
if (year) {
|
||
card.createEl("div", { cls: "csv-m-card-year", text: year });
|
||
}
|
||
|
||
// Author/Director \u2014 only in non-compact mode (movies skip director to save vertical room).
|
||
if (!compactGrid && authorKey && r[authorKey]) {
|
||
card.createEl("div", { cls: "csv-m-card-meta", text: String(r[authorKey]) });
|
||
}
|
||
|
||
// Rating (data is already rendered as unicode stars \u2014 render as-is, hide "unrated").
|
||
const rating = ratingCol ? String(r[ratingCol] ?? "").trim() : "";
|
||
if (rating && rating.toLowerCase() !== "unrated") {
|
||
card.createEl("div", { cls: "csv-m-card-rating", text: rating });
|
||
}
|
||
|
||
// Theme \u2014 small inline pill at the bottom. Multi-value (comma-separated) renders just the first.
|
||
const theme = themeCol ? String(r[themeCol] ?? "").split(",")[0].trim() : "";
|
||
if (theme) {
|
||
card.createEl("span", { cls: "csv-m-card-theme", text: theme });
|
||
}
|
||
|
||
// Status pill only for non-trivial states (e.g. "In progress").
|
||
// Affirmative values became the dot above; negative values render nothing.
|
||
if (status && !NEGATIVE_STATUS.has(statusLc) && !affirmative) {
|
||
const statusEl = card.createEl("span", { cls: "csv-m-card-status", text: status });
|
||
statusEl.classList.add(statusLc.replace(/\\s+/g, "-"));
|
||
}
|
||
});
|
||
});
|
||
}
|
||
}
|
||
\`\`\`
|
||
${ci}`}function Zo(s){let{filePath:t,csvPath:e,headers:n}=s;return`${li}## Add Entry
|
||
|
||
\`\`\`csv-add
|
||
file: ${t}
|
||
\`\`\`
|
||
|
||
## Entries
|
||
|
||
\`\`\`csv-refresh
|
||
\`\`\`
|
||
|
||
\`\`\`dataviewjs
|
||
// Generic mobile dashboard \u2014 expandable, scrollable table.
|
||
// Used for files without a category column (e.g. dictionary).
|
||
const csvData = await dv.io.csv("${e}");
|
||
if (!csvData || !csvData.length) {
|
||
dv.paragraph("No data found");
|
||
} else {
|
||
const data = csvData.array();
|
||
const headers = [${n.map(i=>JSON.stringify(i)).join(", ")}];
|
||
const container = dv.container;
|
||
|
||
const viewKey = "csv-mobile-view-" + dv.current().file.path;
|
||
let showAll = localStorage.getItem(viewKey) === "all";
|
||
|
||
const style = container.createEl("style");
|
||
style.textContent = \`
|
||
.csv-m-toggle { display:flex; gap:8px; margin-bottom:16px; }
|
||
.csv-m-toggle button { padding:6px 12px; border:none; background:transparent; color:var(--text-muted); font-size:13px; font-weight:500; cursor:pointer; border-radius:6px; }
|
||
.csv-m-toggle button.active { background:var(--background-secondary); color:var(--text-normal); }
|
||
.csv-m-tablewrap { overflow-x:auto; -webkit-overflow-scrolling:touch; border:1px solid var(--background-modifier-border); border-radius:8px; }
|
||
.csv-m-tablewrap table { min-width:100%; border-collapse:collapse; font-size:13px; }
|
||
.csv-m-tablewrap th { text-align:left; padding:10px 12px; font-weight:600; color:var(--text-faint); font-size:11px; text-transform:uppercase; letter-spacing:0.05em; white-space:nowrap; border-bottom:1px solid var(--background-modifier-border); background:var(--background-secondary); position:sticky; top:0; }
|
||
.csv-m-tablewrap td { padding:10px 12px; vertical-align:top; border-bottom:1px solid var(--background-modifier-border); }
|
||
/* Keep short fields on one line; the last column (typically long text like
|
||
Meaning or Description) is the only one that wraps. */
|
||
.csv-m-tablewrap td:not(:last-child) { white-space:nowrap; }
|
||
.csv-m-tablewrap td:last-child { white-space:normal; min-width:200px; }
|
||
.csv-m-tablewrap tr:last-child td { border-bottom:none; }
|
||
.csv-m-hint { color:var(--text-faint); font-size:12px; margin-top:8px; }
|
||
\`;
|
||
|
||
// Recent / All toggle \u2014 expandable by tapping "All"
|
||
const toggleWrap = container.createEl("div", { cls: "csv-m-toggle" });
|
||
const recentBtn = toggleWrap.createEl("button", { text: "Recent" });
|
||
const allBtn = toggleWrap.createEl("button", { text: "All " + data.length });
|
||
if (!showAll) recentBtn.classList.add("active");
|
||
else allBtn.classList.add("active");
|
||
recentBtn.onclick = () => { localStorage.setItem(viewKey, "recent"); location.reload(); };
|
||
allBtn.onclick = () => { localStorage.setItem(viewKey, "all"); location.reload(); };
|
||
|
||
const entries = showAll ? [...data].reverse() : data.slice(-15).reverse();
|
||
|
||
const tableWrap = container.createEl("div", { cls: "csv-m-tablewrap" });
|
||
const table = tableWrap.createEl("table");
|
||
const thead = table.createEl("thead");
|
||
const headerRow = thead.createEl("tr");
|
||
headers.forEach(h => headerRow.createEl("th", { text: h }));
|
||
const tbody = table.createEl("tbody");
|
||
entries.forEach(r => {
|
||
const row = tbody.createEl("tr");
|
||
headers.forEach(h => row.createEl("td", { text: String(r[h] ?? "") }));
|
||
});
|
||
|
||
if (!showAll && data.length > 15) {
|
||
const hint = container.createEl("p", { cls: "csv-m-hint" });
|
||
hint.textContent = "Showing last 15 of " + data.length + " entries \u2014 tap All to expand";
|
||
}
|
||
}
|
||
\`\`\`
|
||
${ci}`}async function Jo(s){var c,d,h,u,f,p,m,g,b,x;if(!s.file)return;let t=(d=(c=s.file.parent)==null?void 0:c.path)!=null?d:"",e=t?`${t}/Mobile`:"Mobile";await s.app.vault.adapter.exists(e)||await s.app.vault.adapter.mkdir(e);let n=`${e}/${s.file.basename}.md`,i=s.file.path,o=s.getDateCol(),r=s.getCategoryCol(),a="../"+s.file.name,l;if(o){let _=s.getBooleanColumns();l=Xo({filePath:a,csvPath:i,habitCols:_,labels:_.map(kt),dateCol:o})}else if(r){let _=(f=(u=(h=s.titleKey())!=null?h:s.resolveCol(["Quote","quote","Headline","headline","Phrase","phrase"]))!=null?u:s.headers[0])!=null?f:"Title";l=Qo({filePath:a,csvPath:i,titleKey:_,categoryCol:r,statusCol:(p=s.getStatusCol())!=null?p:"Status",authorKey:(m=s.authorKey())!=null?m:"",yearCol:(g=s.resolveCol(["Year","year","Released","released"]))!=null?g:"",ratingCol:(b=s.resolveCol(["Rating","rating","Score","score","Stars","stars"]))!=null?b:"",themeCol:(x=s.resolveCol(["Theme","theme","Subgenre","subgenre","Mood","mood"]))!=null?x:"",compactGrid:s.titleKey()!==null})}else l=Zo({filePath:a,csvPath:i,headers:s.headers});try{let _=s.app.vault.getAbstractFileByPath(n);_&&_ instanceof Me.TFile?(await s.app.vault.modify(_,l),new Me.Notice(`Updated: ${n}`)):(await s.app.vault.create(n,l),new Me.Notice(`Created: ${n}`))}catch(_){let E=s.app.vault.getAbstractFileByPath(n);E instanceof Me.TFile&&(await s.app.vault.modify(E,l),new Me.Notice(`Updated: ${n}`))}}var he=require("obsidian"),_c="http://127.0.0.1:8765",Cc=6;async function tr(s,t){let e;try{e=await(0,he.requestUrl)({url:_c,method:"POST",contentType:"application/json",body:JSON.stringify({action:s,version:Cc,params:t}),throw:!1})}catch(i){throw new Error("Couldn't reach Anki. Is the desktop app open with the AnkiConnect add-on installed?")}let n=e.json;if(n.error)throw new Error(n.error);return n.result}function Sc(s){var e,n,i;let t=s.fileCfg.ankiFrontCol;return t&&s.headers.includes(t)?t:(i=(n=(e=s.titleKey())!=null?e:s.resolveCol(["Quote","Headline","Phrase","Term","Word","Question","Front","Name","Title"]))!=null?n:s.headers[0])!=null?i:null}function di(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function wc(s,t,e){return s.headers.filter(n=>{var i;return n!==e&&((i=t[n])!=null?i:"").trim()}).map(n=>`<b>${di(n)}:</b> ${di(t[n].trim())}`).join("<br>")}async function er(s){if(!s.file)return;let t=Sc(s);if(!t){new he.Notice("No column to use as the Anki card front.",6e3);return}let e=s.file.basename,n=s.rows.filter(o=>{var r;return((r=o[t])!=null?r:"").trim()});if(!n.length){new he.Notice(`Nothing to sync \u2014 no rows with a "${t}" value.`,6e3);return}let i=new he.Notice(`Syncing ${n.length} cards to Anki deck \u201C${e}\u201D\u2026`,0);try{await tr("createDeck",{deck:e});let o=n.map(c=>({deckName:e,modelName:"Basic",fields:{Front:di(c[t].trim()),Back:wc(s,c,t)},options:{allowDuplicate:!1,duplicateScope:"deck"},tags:["csv-card-view"]})),r=await tr("addNotes",{notes:o}),a=r.filter(c=>c!=null).length,l=r.length-a;i.hide(),new he.Notice(`Anki sync: ${a} added${l?`, ${l} already present`:""} (deck \u201C${e}\u201D).`,6e3)}catch(o){i.hide(),new he.Notice(`Anki sync failed: ${o instanceof Error?o.message:String(o)}`,8e3)}}function dn(s){return s.resolveCol(["Type","type","Kind","kind","Item","item"])}function fi(s){var t;return(t=s.resolveCol(["Project","project","Projects","projects","Area","area"]))!=null?t:Nt(s)}function or(s){return s.resolveCol(["Due","due","Deadline","deadline","Due Date","Due date","due date"])}function hn(s){return s.resolveCol(["Priority","priority","Prio","prio","Importance","importance"])}var Ec=["task","todo","to-do","action",""],kc=["task","todo","to-do","action","note","idea","reference","ref"],rr=["done","complete","completed","finished","closed","resolved","yes","x","\u2713","true"],Mc={high:0,med:1,medium:1,normal:1,low:2};function Ye(s){if(or(s)||hn(s))return!0;let t=dn(s);return t?s.rows.some(e=>{var n;return kc.includes(((n=e[t])!=null?n:"").trim().toLowerCase())}):!1}function Dc(s,t,e){var n;return e?Ec.includes(((n=t[e])!=null?n:"").trim().toLowerCase()):!0}function Tc(s,t,e){if(Dc(s,t,e))return"task";let n=(e?t[e]:"").trim().toLowerCase();return n==="idea"||n==="ideas"?"idea":"note"}function hi(s,t,e){var n;return e?rr.includes(((n=t[e])!=null?n:"").trim().toLowerCase()):!1}function sr(s){let t=Mc[(s!=null?s:"").trim().toLowerCase()];return t===void 0?3:t}function nr(s){return(s!=null?s:"").trim()?0:1}function Lc(){return new Date().toISOString().slice(0,10)}function Ac(s,t){let e=new Map;s.rows.forEach(o=>{var a,l;let r=((a=o[t])!=null?a:"").trim();r&&rr.includes(r.toLowerCase())&&e.set(r,((l=e.get(r))!=null?l:0)+1)});let n="done",i=0;return e.forEach((o,r)=>{o>i&&(n=r,i=o)}),n}function ar(s,t){var D;let e=fi(s),n=dn(s),i=s.getStatusCol(),o=or(s),r=hn(s),a=(D=s.titleKey())!=null?D:s.headers[0],l=t.createDiv({cls:"csv-library-filters"}),c=new Set;e&&s.rows.forEach(M=>{var C;((C=M[e])!=null?C:"").split(",").map(T=>T.trim()).filter(Boolean).forEach(T=>c.add(T))});let d=l.createEl("select",{cls:"csv-library-filter-select"});d.createEl("option",{text:e?"All projects":"All",value:"all"}),Array.from(c).sort().forEach(M=>d.createEl("option",{text:M,value:M})),d.value=s.taskProjectFilter;let h=new Set;n&&s.rows.forEach(M=>{var T;let C=((T=M[n])!=null?T:"").trim();C&&h.add(C)});let u=null;h.size>0&&(u=l.createEl("select",{cls:"csv-library-filter-select"}),u.createEl("option",{text:"All types",value:"all"}),Array.from(h).sort().forEach(M=>u.createEl("option",{text:M,value:M})),u.value=s.taskTypeFilter);let f=()=>{s.taskProjectFilter=d.value,u&&(s.taskTypeFilter=u.value),s.renderView(!0)};d.addEventListener("change",f),u==null||u.addEventListener("change",f);let p=s.searchQuery.toLowerCase().trim(),m=s.rows.filter(M=>{var C,T;return!(s.taskProjectFilter!=="all"&&e&&!((C=M[e])!=null?C:"").split(",").map(A=>A.trim().toLowerCase()).includes(s.taskProjectFilter.toLowerCase())||s.taskTypeFilter!=="all"&&n&&((T=M[n])!=null?T:"").trim().toLowerCase()!==s.taskTypeFilter.toLowerCase()||p&&!s.headers.some(k=>{var A;return((A=M[k])!=null?A:"").toLowerCase().includes(p)}))});(s.taskProjectFilter!=="all"||s.taskTypeFilter!=="all"||p)&&t.createDiv({cls:"csv-library-result-count",text:`Showing ${m.length} of ${s.rows.length} entries`});let g={},b={},x={},_={task:g,note:b,idea:x},E=M=>{var T;return e&&((T=M[e])!=null?T:"").split(",").map(k=>k.trim()).filter(Boolean)[0]||"\u2014"};m.forEach(M=>{var k;let C=_[Tc(s,M,n)],T=E(M);((k=C[T])!=null?k:C[T]=[]).push(M)});let w=t.createDiv({cls:"csv-tasks"}),v=Lc(),y=i?Ac(s,i):"done";ui(w,"Tasks",g,(M,C)=>{C.sort((T,k)=>{var O,z,G,$,L,V;let A=hi(s,T,i),P=hi(s,k,i);if(A!==P)return A?1:-1;if(r){let W=sr((O=T[r])!=null?O:"")-sr((z=k[r])!=null?z:"");if(W)return W}if(o){let W=nr((G=T[o])!=null?G:"")-nr(($=k[o])!=null?$:"");if(W)return W;let j=((L=T[o])!=null?L:"").localeCompare((V=k[o])!=null?V:"");if(j)return j}return s.getTitle(T).localeCompare(s.getTitle(k))}),C.forEach(T=>{var $;let k=hi(s,T,i),A=M.createEl("tr"),P=A.createEl("td",{cls:"csv-tasks-check-cell"});if(i){let L=P.createEl("span",{cls:`csv-tasks-check ${k?"is-done":""}`,text:k?"\u2713":""});L.setAttr("title",k?"Mark not done":"Mark done"),L.addEventListener("click",V=>{V.stopPropagation(),T[i]=k?"":y,s.scheduleSave(),s.renderView(!0)})}ir(s,A,T,a,k);let O=A.createEl("td",{cls:"csv-tasks-due"}),z=o?(($=T[o])!=null?$:"").slice(0,10):"";O.setText(z||"\u2014"),z&&!k&&z<v&&O.addClass("csv-tasks-overdue");let G=A.createEl("td",{cls:"csv-tasks-priority",text:r&&T[r]||"\u2014"});r&&(G.addClass("csv-tasks-editable"),G.addEventListener("click",L=>{var W;L.stopPropagation();let V=Array.from(new Set([...s.getColumnValues(r),"high","medium","low"]));Ot(G,(W=T[r])!=null?W:"",V,j=>{T[r]=j,s.scheduleSave(),s.renderView(!0)},s.contentEl)})),A.addEventListener("contextmenu",L=>s.openRowContextMenu(T,L))})},["","Name","Due","Priority"]);let S=(M,C)=>{C.sort((T,k)=>s.getTitle(T).localeCompare(s.getTitle(k))),C.forEach(T=>{let k=M.createEl("tr"),A=n&&T[n]||"",P=k.createEl("td",{cls:"csv-tasks-type-cell"});A&&P.createSpan({cls:"csv-tasks-type-pill",text:A}),ir(s,k,T,a,!1),k.addEventListener("contextmenu",O=>s.openRowContextMenu(T,O))})};if(ui(w,"Notes",b,S,["Type","Name"]),ui(w,"Ideas",x,S,["Type","Name"]),Object.keys(g).length===0&&Object.keys(b).length===0&&Object.keys(x).length===0){let M=w.createDiv({cls:"csv-empty-state"});M.createEl("p",{text:p||s.taskProjectFilter!=="all"||s.taskTypeFilter!=="all"?"No entries match your filters.":"No tasks yet."}),(p||s.taskProjectFilter!=="all"||s.taskTypeFilter!=="all")&&M.createEl("button",{cls:"csv-clear-filters-btn",text:"Clear filters"}).addEventListener("click",()=>{s.taskProjectFilter="all",s.taskTypeFilter="all",s.searchQuery="",s.renderView()})}}function ui(s,t,e,n,i){if(Object.keys(e).length===0)return;s.createDiv({cls:"csv-tasks-section-header",text:t});let o=s.createDiv({cls:"csv-tasks-section"});Object.keys(e).sort().forEach(r=>{let a=e[r],l=o.createEl("details",{cls:"csv-tasks-group"});l.open=!0;let c=l.createEl("summary",{cls:"csv-tasks-group-header"});c.innerHTML=`<span class="csv-tasks-arrow">\u25B6</span> ${r} <span class="csv-tasks-count">${a.length}</span>`;let d=l.createEl("table",{cls:"csv-tasks-table"}),u=d.createEl("thead").createEl("tr");i.forEach(p=>u.createEl("th",{text:p}));let f=d.createEl("tbody");n(f,a)})}function ir(s,t,e,n,i){let o=t.createEl("td",{cls:"csv-tasks-name-cell"}),r=o.createSpan({cls:`csv-tasks-link ${i?"csv-tasks-done":""}`,text:e[n]||"Untitled"}),a=s.getNotesCol();r.addEventListener("click",()=>{a?s.openNoteExpander(e,a):s.openOrCreateNotes(e)});let l=s.notesFileExists(e),c=o.createEl("button",{cls:`csv-tasks-page-icon ${l?"exists":""}`,text:l?"\u{1F4C4}":"+"});c.setAttr("title",l?"Open page":"Create page"),c.addEventListener("click",d=>{d.stopPropagation(),s.openOrCreateNotes(e)})}function un(s){let t=[];return s.isTravelFile()&&t.push({id:"travel",label:"Travel"}),s.hasDateColumn()&&t.push({id:"dashboard",label:"Dashboard"}),Ye(s)&&t.push({id:"tasks",label:"Tasks"}),Nt(s)&&(t.push({id:"library",label:"Cards"}),t.push({id:"kanban-genre",label:"Kanban"})),t.push({id:"table",label:"Table"}),s.rows.length>0&&t.push({id:"focus",label:"Focus"}),an(s)&&t.push({id:"stats",label:"Stats"}),t}function lr(s,t){var f,p,m;let e=t.createDiv({cls:"csv-toolbar"});e.createDiv({cls:"csv-toolbar-title",text:(p=(f=s.file)==null?void 0:f.basename)!=null?p:""});let n=e.createDiv({cls:"csv-toolbar-controls"});n.createDiv({cls:"csv-row-count",text:`${s.rows.length} entries`});let i=n.createDiv({cls:"csv-mode-group"}),o=un(s),r=i.createEl("select",{cls:"csv-mode-select",attr:{"aria-label":"View mode"}});if(o.forEach(({id:g,label:b})=>{let x=r.createEl("option",{text:b,value:g});s.mode===g&&(x.selected=!0)}),r.addEventListener("change",()=>{s.mode=r.value,s.renderView()}),s.mode!=="dashboard"){let g=n.createEl("button",{cls:"csv-cfg-btn csv-search-toggle",text:"\u{1F50D}",title:"Search"}),b=n.createDiv({cls:"csv-search-wrap"}),x=b.createDiv({cls:"csv-search-input-wrap"}),_=x.createEl("input",{cls:"csv-search-input",type:"text",placeholder:"Search...",value:s.searchQuery,attr:{inputmode:"search",enterkeyhint:"search",autocomplete:"off"}}),E=x.createEl("button",{cls:"csv-search-clear",text:"\xD7",title:"Clear search"});E.toggleClass("is-hidden",!s.searchQuery),b.createEl("button",{cls:"csv-search-done",text:"Done",title:"Dismiss keyboard"}).addEventListener("click",y=>{if(y.preventDefault(),!_.value){e.removeClass("csv-toolbar--search-expanded"),g.removeClass("has-query"),s.searchQuery="",s.renderView(!0);return}_.blur()});let v=null;_.addEventListener("input",y=>{s.searchQuery=y.target.value,E.toggleClass("is-hidden",!s.searchQuery),g.toggleClass("has-query",!!s.searchQuery),v!==null&&window.clearTimeout(v),v=window.setTimeout(()=>{v=null,s.renderView(!0)},120)}),_.addEventListener("keydown",y=>{y.key==="Enter"&&(y.preventDefault(),_.blur())}),E.addEventListener("click",()=>{s.searchQuery="",_.value="",E.addClass("is-hidden"),g.removeClass("has-query"),_.focus({preventScroll:!0}),s.renderView(!0)}),s.searchQuery&&g.addClass("has-query"),g.addEventListener("click",()=>{e.addClass("csv-toolbar--search-expanded"),_.focus({preventScroll:!0})})}if(s.mode==="table"&&s.hasDateColumn()){let g=(m=s.fileCfg.sortNewestFirst)!=null?m:!0;n.createEl("button",{cls:`csv-cfg-btn ${g?"active":""}`,text:g?"\u2193 Newest":"\u2191 Oldest",title:"Toggle sort order"}).addEventListener("click",()=>{var _;let x=s.fileCfg;x.sortNewestFirst=!((_=x.sortNewestFirst)==null||_),s.saveFileCfg(x),s.tableSortCol=null,s.renderViewPreservingScroll()})}let a=()=>{var g,b;new tn(s.app,s.headers,(b=(g=s.file)==null?void 0:g.path)!=null?b:"",s.fileCfg,s.autoDetectBooleanColumns(),un(s),x=>{s.saveFileCfg(x),x.defaultMode&&(s.mode=x.defaultMode),s.renderView()}).open()},l=()=>Jo(s),c=()=>s.backupToArchive(),d=()=>er(s);n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary",text:"\u2699 Columns",title:"Configure columns for this file"}).addEventListener("click",a),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary",text:"\u{1F4F1} Mobile",title:"Generate mobile dashboard with add form"}).addEventListener("click",l),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary",text:"\u{1F4BE} Backup",title:"Copy this file to Archive/ with today's date"}).addEventListener("click",c),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary",text:"\u{1F3B4} Anki",title:"Sync rows to Anki (needs Anki desktop + AnkiConnect)"}).addEventListener("click",d),n.createEl("button",{cls:"csv-add-btn",text:"+ Add"}).addEventListener("click",()=>s.openAddModal()),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-overflow",text:"\u22EF",title:"More actions"}).addEventListener("click",g=>{let b=new fn.Menu;b.addItem(x=>x.setTitle("Columns").setIcon("settings").onClick(a)),b.addItem(x=>x.setTitle("Mobile dashboard").setIcon("smartphone").onClick(l)),b.addItem(x=>x.setTitle("Backup").setIcon("save").onClick(c)),b.addItem(x=>x.setTitle("Sync to Anki").setIcon("layers").onClick(d)),b.addSeparator(),b.addItem(x=>x.setTitle("Built 2026-06-29 01:33").setIcon("info").setDisabled(!0)),b.showAtMouseEvent(g)}),n.createEl("button",{cls:"csv-cfg-btn csv-cfg-btn-secondary csv-info-btn",text:"\u24D8",title:"Built 2026-06-29 01:33 \u2014 click to confirm"}).addEventListener("click",()=>new fn.Notice("csv-card-view \u2014 built 2026-06-29 01:33",4e3))}function Pc(s){return s&&typeof s=="object"&&"basename"in s?s:null}var Rc=["Author","author","By","by","Source","source","Speaker","speaker","Artist","artist","Director","director"];async function cr(s,t,e,n){var x,_,E;let i=t.split(`
|
||
`).map(w=>w.trim()).filter(Boolean),o=w=>{var v,y;return(y=(v=i.find(S=>S.startsWith(w+":")))==null?void 0:v.slice(w.length+1).trim())!=null?y:""},r=o("file");if(!r){e.createEl("p",{text:"Error: No file specified. Use: file: yourfile.csv",cls:"csv-add-error"});return}let a=s.vault.getAbstractFileByPath(n.sourcePath),l=(_=(x=a==null?void 0:a.parent)==null?void 0:x.path)!=null?_:"",c=We(r,l),d=Pc(s.vault.getAbstractFileByPath(c));if(!d){e.createEl("p",{text:`Error: File not found: ${c}`,cls:"csv-add-error"});return}let h=[],u=[];try{let w=Gt(await s.vault.read(d));h=w.headers,u=w.rows}catch(w){e.createEl("p",{text:`Error reading file: ${w}`,cls:"csv-add-error"});return}if(!u.length){e.createEl("p",{text:"No entries in file.",cls:"csv-add-error"});return}let f=o("field"),p=(E=h.find(w=>w.toLowerCase()===f.toLowerCase()))!=null?E:h[0],m=Rc.map(w=>h.find(v=>v===w)).find(Boolean),g=e.createDiv({cls:"csv-random-card"}),b=()=>{var C;g.empty();let w=u.filter(T=>{var k;return((k=T[p])!=null?k:"").trim()}),v=w.length?w:u,y=v[Math.floor(Math.random()*v.length)];g.createDiv({cls:"csv-random-text",text:y[p]||"\u2014"});let S=m?((C=y[m])!=null?C:"").trim():"";S&&g.createDiv({cls:"csv-random-sub",text:`\u2014 ${S}`});let D=g.createDiv({cls:"csv-random-foot"});D.createSpan({cls:"csv-random-src",text:d.basename}),D.createEl("button",{cls:"csv-random-btn",text:"\u21BB",title:"Another one"}).addEventListener("click",b)};b()}var yo=null;async function tp(){if(yo)return yo;let s=await Promise.resolve().then(()=>(Nl(),Vl));return s.Chart.register(s.LineController,s.LineElement,s.PointElement,s.LinearScale,s.CategoryScale,s.Filler,s.Tooltip),yo=s,s}async function Bl(s,t){var W,j,U;let e=s.getDateCol();if(!e){t.createEl("p",{text:"No date column detected.",cls:"csv-empty-state"});return}let n=s.getBooleanColumns(),i=s.getNotesCol(),o=s.formatDate(new Date),r=[...s.rows].sort((B,F)=>{var I,N;return((I=B[e])!=null?I:"").localeCompare((N=F[e])!=null?N:"")});s.selectedDate||(s.selectedDate=o);let a=r.find(B=>B[e]===s.selectedDate),l=s.selectedDate===o;t.addClass("csv-dashboard");let c=[...new Set([...r.map(B=>B[e]),o])].filter(Boolean).sort(),d=t.createDiv({cls:"csv-dash-nav"});d.createEl("button",{cls:"csv-dash-nav-btn csv-dash-back-btn",text:"\u25C0"}).addEventListener("click",()=>{let B=c.indexOf(s.selectedDate);if(B>0)s.selectedDate=c[B-1],s.renderView();else if(B===-1&&c.length>0){let F=c.filter(I=>I<s.selectedDate);F.length>0&&(s.selectedDate=F[F.length-1],s.renderView())}});let u=d.createDiv({cls:"csv-dash-date"});l&&u.createSpan({cls:"csv-dash-today-dot"});let f=u.createEl("select",{cls:"csv-dash-date-select"});if(c.forEach(B=>{let F=f.createEl("option",{text:B,value:B});B===s.selectedDate&&(F.selected=!0)}),f.addEventListener("change",()=>{s.selectedDate=f.value,s.renderView()}),d.createEl("button",{cls:"csv-dash-nav-btn",text:"\u25B6"}).addEventListener("click",()=>{let B=c.indexOf(s.selectedDate);if(B>=0&&B<c.length-1)s.selectedDate=c[B+1],s.renderView();else if(B===-1){let F=c.filter(I=>I>s.selectedDate);F.length>0&&(s.selectedDate=F[0],s.renderView())}}),l||d.createEl("button",{cls:"csv-dash-today-btn",text:"Today"}).addEventListener("click",()=>{s.selectedDate=o,s.renderView()}),!a){let B=t.createDiv({cls:"csv-dash-add-section"});B.createEl("p",{text:`No entry for ${s.selectedDate}`}),B.createEl("button",{cls:"csv-dash-add-btn",text:`+ Add entry for ${s.selectedDate}`}).addEventListener("click",()=>{let I={};s.headers.forEach(N=>I[N]=""),I[e]=s.selectedDate,s.rows.push(I),s.scheduleSave(),s.renderView()})}if(a){let B=t.createDiv({cls:"csv-dash-habits"});B.createEl("h3",{text:s.selectedDate===o?"Today":s.selectedDate,cls:"csv-dash-section-title"});let F=B.createDiv({cls:"csv-dash-habits-grid"});n.forEach(N=>{let R=s.isTruthy(a[N]),Y=F.createDiv({cls:`csv-dash-habit ${R?"checked":""}`}),K=Y.createEl("button",{cls:"csv-dash-habit-check",text:R?"\u25CF":"\u25CB"});Y.createSpan({cls:"csv-dash-habit-label",text:N}),K.addEventListener("click",()=>{a[N]=R?"0":"1",s.scheduleSave(),s.renderViewPreservingScroll()})});let I=n.filter(N=>s.isTruthy(a[N])).length;if(B.createDiv({cls:"csv-dash-habits-count",text:`${I} of ${n.length} complete`}),i&&((W=a[i])!=null&&W.trim())){let N=B.createDiv({cls:"csv-dash-notes-preview"});N.createEl("strong",{text:"Notes: "}),N.createSpan({text:a[i].slice(0,200)+(a[i].length>200?"\u2026":"")})}}let m=t.createDiv({cls:"csv-dash-chart-section"});m.createEl("h3",{text:"Progress",cls:"csv-dash-section-title"});let b=m.createDiv({cls:"csv-dash-chart-wrap"}).createEl("canvas",{cls:"csv-dash-chart"}),x=r.map(B=>{var I;return((I=B[e])!=null?I:"").slice(5)}),_=r.map(B=>n.filter(F=>s.isTruthy(B[F])).length);s.chartInstance&&(s.chartInstance.destroy(),s.chartInstance=null);let{Chart:E}=await tp();if(!b.isConnected)return;s.chartInstance=new E(b,{type:"line",data:{labels:x,datasets:[{label:"Habits done",data:_,borderColor:"#378ADD",backgroundColor:"rgba(55,138,221,0.08)",borderWidth:1.5,pointRadius:3,tension:.3,fill:!0}]},options:{responsive:!0,maintainAspectRatio:!1,scales:{y:{min:0,max:n.length||8,ticks:{stepSize:1}}},plugins:{tooltip:{enabled:!0}}}});let w=t.createDiv({cls:"csv-dash-stats-section"});w.createEl("h3",{text:"Stats",cls:"csv-dash-section-title"});let v=r.length,y=r.reduce((B,F)=>B+n.filter(I=>s.isTruthy(F[I])).length,0),S=v>0?(y/v).toFixed(1):"0",D=r.filter(B=>n.every(F=>s.isTruthy(B[F]))).length,M=0,C=0,T=null;for(let B of r){let F=n.filter(R=>s.isTruthy(B[R])).length,I=s.parseDate((j=B[e])!=null?j:""),N=!0;T&&I&&Math.round((I.getTime()-T.getTime())/864e5)!==1&&(N=!1),F>=1&&(N||T===null)?(C++,C>M&&(M=C)):F>=1?(C=1,C>M&&(M=C)):C=0,T=I}let k=0,A=new Date;A.setHours(0,0,0,0);let P=A;for(let B=r.length-1;B>=0;B--){let F=s.parseDate((U=r[B][e])!=null?U:"");if(!F)break;let I=Math.round((P.getTime()-F.getTime())/(1e3*60*60*24));if(k===0&&I>1||k>0&&I!==1)break;if(n.filter(R=>s.isTruthy(r[B][R])).length>=1)k++,P=F;else break}let O=w.createDiv({cls:"csv-dash-stats-bar"});O.innerHTML=`<strong>${v}</strong> days logged \xB7 <strong>${S}</strong> avg/day \xB7 <strong>${D}</strong> perfect days \xB7 current streak <strong>${k}d</strong> \xB7 best streak <strong>${M}d</strong>`;let G=t.createDiv({cls:"csv-dash-cards-section"}).createDiv({cls:"csv-dash-cards-grid"}),$=new Date().getFullYear(),L={language:"\u25CB",read:"\u2261",gym:"\u229E",vitamins:"\u2299",cardio:"\u2191",meditate:"\u25CE",challenge:"\u273F",journal:"\u270E",exercise:"\u229E",water:"\u{1F4A7}",sleep:"\u{1F319}",study:"\u{1F4DA}"};n.map(B=>{let F=r.filter(K=>s.isTruthy(K[B])),I=F.length>0?F[F.length-1][e]:null,N=new Set;F.forEach(K=>{var X;let Z=s.parseDate((X=K[e])!=null?X:"");Z&&N.add(Z.getFullYear())});let R=r.filter(K=>{var X;let Z=s.parseDate((X=K[e])!=null?X:"");return Z&&Z.getFullYear()===$}),Y=R.filter(K=>s.isTruthy(K[B])).length;return{habit:B,doneCount:F.length,doneThisYear:Y,totalThisYear:R.length,lastDone:I,years:Array.from(N).sort()}}).sort((B,F)=>!B.lastDone&&!F.lastDone?0:B.lastDone?F.lastDone?F.lastDone.localeCompare(B.lastDone):-1:1).forEach(({habit:B,doneCount:F,doneThisYear:I,totalThisYear:N,lastDone:R,years:Y})=>{var st;let K=G.createDiv({cls:"csv-dash-habit-card"}),Z=(st=L[B.toLowerCase()])!=null?st:"\u25CB",X=K.createDiv({cls:"csv-dash-habit-card-header"});if(X.createSpan({cls:"csv-dash-habit-icon",text:Z}),X.createSpan({cls:"csv-dash-habit-card-name",text:kt(B)}),Y.length>0&&K.createDiv({cls:"csv-dash-habit-years"}).setText(Y.join(" \xB7 ")),K.createDiv({cls:"csv-dash-habit-card-thisyear",text:`${I} of ${N} complete this year`}),K.createDiv({cls:"csv-dash-habit-card-alltime",text:`${F} of ${v} all time`}),R){let at=s.parseDate(R),Rt=at?at.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):R;K.createDiv({cls:"csv-dash-habit-card-last",text:`Last logged: ${Rt}`})}else K.createDiv({cls:"csv-dash-habit-card-last",text:"Never logged"});let q=v>0?F/v*100:0,J=K.createDiv({cls:"csv-dash-habit-progress"}).createDiv({cls:"csv-dash-habit-progress-bar"});J.style.width=`${q}%`,K.addEventListener("click",()=>{s.selectedHabit=s.selectedHabit===B?null:B,s.renderViewPreservingScroll()}),s.selectedHabit===B&&K.addClass("selected")}),s.selectedHabit&&n.includes(s.selectedHabit)&&ep(s,t,r,e,s.selectedHabit)}function ep(s,t,e,n,i){var M,C,T;let o=t.createDiv({cls:"csv-dash-timeline-section"}),r=o.createDiv({cls:"csv-dash-timeline-header"});r.createEl("h3",{text:`${kt(i)} Timeline`,cls:"csv-dash-section-title"});let a=r.createEl("select",{cls:"csv-dash-year-select"}),l=new Set;e.forEach(k=>{var P;let A=s.parseDate((P=k[n])!=null?P:"");A&&l.add(A.getFullYear())}),l.add(new Date().getFullYear()),Array.from(l).sort().reverse().forEach(k=>{let A=a.createEl("option",{text:String(k),value:String(k)});k===s.timelineYear&&(A.selected=!0)}),a.addEventListener("change",()=>{s.timelineYear=parseInt(a.value),s.renderViewPreservingScroll()}),r.createEl("button",{cls:"csv-dash-timeline-close",text:"\u2715"}).addEventListener("click",()=>{s.selectedHabit=null,s.renderViewPreservingScroll()});let d=new Map;e.forEach(k=>{var A;d.set((A=k[n])!=null?A:"",s.isTruthy(k[i]))});let h=o.createDiv({cls:"csv-dash-timeline-grid-wrap"}),u=h.createDiv({cls:"csv-dash-timeline-months"});["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].forEach(k=>u.createSpan({cls:"csv-dash-timeline-month-label",text:k}));let p=h.createDiv({cls:"csv-dash-timeline-calendar"}),m=p.createDiv({cls:"csv-dash-timeline-day-labels"});for(let k=1;k<=31;k++)m.createDiv({cls:"csv-dash-timeline-day-label",text:k%5===0||k===1?String(k):""});for(let k=0;k<12;k++){let A=p.createDiv({cls:"csv-dash-timeline-month-col"}),P=new Date(s.timelineYear,k+1,0).getDate();for(let O=1;O<=31;O++){if(O>P){A.createDiv({cls:"csv-dash-timeline-cell empty"});continue}let z=`${s.timelineYear}-${String(k+1).padStart(2,"0")}-${String(O).padStart(2,"0")}`,G=(M=d.get(z))!=null?M:!1,$=d.has(z),L=new Date(s.timelineYear,k,O)>new Date,V=A.createDiv({cls:`csv-dash-timeline-cell ${L?"future":""} ${G?"done":""} ${$&&!G?"missed":""} ${!$&&!L?"no-entry":""}`});V.title=`${z}: ${L?"Future":G?"\u2713 Done":$?"\u2717 Missed":"No entry"}`}}let g=e.filter(k=>{var P;let A=s.parseDate((P=k[n])!=null?P:"");return A&&A.getFullYear()===s.timelineYear}),b=g.filter(k=>s.isTruthy(k[i])).length,x=g.length,_=0,E=0,w=0,v=null;for(let k of e){let A=s.isTruthy(k[i]),P=s.parseDate((C=k[n])!=null?C:""),O=!0;v&&P&&Math.round((P.getTime()-v.getTime())/864e5)!==1&&(O=!1),A&&(O||v===null)?(w++,w>E&&(E=w)):A?w=1:w=0,v=P}let y=new Date;y.setHours(0,0,0,0);let S=y;for(let k=e.length-1;k>=0;k--){let A=s.parseDate((T=e[k][n])!=null?T:"");if(!A)break;let P=Math.round((S.getTime()-A.getTime())/(1e3*60*60*24));if(_===0&&P>1||_>0&&P!==1)break;if(s.isTruthy(e[k][i]))_++,S=A;else break}let D=o.createDiv({cls:"csv-dash-timeline-stats"});D.innerHTML=`<strong>${b}</strong> of ${x} in ${s.timelineYear} \xB7 current streak <strong>${_}d</strong> \xB7 best streak <strong>${E}d</strong>`}function zl(s,t){var x,_;let e=s.getFilteredRows();if(s.searchQuery.trim()&&t.createDiv({cls:"csv-search-results",text:`Found ${e.length} of ${s.rows.length} entries`}),!e.length){let E=t.createDiv({cls:"csv-empty-state"});E.createEl("p",{text:s.searchQuery?"No matching entries found.":"No entries yet."}),s.searchQuery&&E.createEl("button",{cls:"csv-clear-filters-btn",text:"Clear search"}).addEventListener("click",()=>{s.searchQuery="",s.renderView()});return}s.focusIndex>=e.length&&(s.focusIndex=e.length-1),s.focusIndex<0&&(s.focusIndex=0);let n=e[s.focusIndex],i=(x=s.titleKey())!=null?x:s.headers[0],o=s.getNotesCol(),r=s.authorKey(),a=t.createDiv({cls:"csv-focus-wrap",attr:{tabindex:"0"}}),l=E=>{s.focusIndex=(E%e.length+e.length)%e.length,s.focusNavPending=!0,s.renderView(!0)},c=a.createDiv({cls:"csv-focus-card"});c.createDiv({cls:"csv-focus-position",text:`${s.focusIndex+1} / ${e.length}`});let d=c.createDiv({cls:"csv-focus-title",text:s.getTitle(n)});o&&(d.addClass("is-clickable"),d.title="Open entry",d.addEventListener("click",()=>s.openNoteExpander(n,o)));let h=s.getSubtitle(n);if(h&&c.createDiv({cls:"csv-focus-sub",text:h}),o&&o!==i&&((_=n[o])!=null&&_.trim())){let E=c.createDiv({cls:"csv-focus-notes"});s.renderMarkdownInto(E,n[o])}let u=new Set([i,o,r].filter(Boolean)),f=s.headers.filter(E=>{var w;return!u.has(E)&&((w=n[E])!=null?w:"").trim()});if(f.length){let E=c.createDiv({cls:"csv-focus-meta"});f.forEach(w=>{let v=E.createDiv({cls:"csv-kanban-chip"});if(v.createSpan({cls:"csv-chip-label",text:w+": "}),s.isSelectCol(w)){let y=v.createSpan({cls:"csv-chip-value csv-chip-select",text:n[w]});y.addEventListener("click",S=>{S.stopPropagation(),Ot(y,n[w],s.getColumnValues(w),D=>{n[w]=D,y.setText(D||"\u2014"),s.scheduleSave()},s.contentEl,{multi:It(w)})})}else v.createSpan({cls:"csv-chip-value",text:n[w]})})}c.addEventListener("contextmenu",E=>s.openRowContextMenu(n,E));let p=a.createDiv({cls:"csv-focus-nav"}),m=p.createEl("button",{cls:"csv-focus-nav-btn",text:"\u2039",title:"Previous (\u2190)"}),g=p.createEl("button",{cls:"csv-focus-nav-btn csv-focus-nav-rand",text:"\u{1F500}",title:"Random entry"}),b=p.createEl("button",{cls:"csv-focus-nav-btn",text:"\u203A",title:"Next (\u2192)"});m.addEventListener("click",()=>l(s.focusIndex-1)),b.addEventListener("click",()=>l(s.focusIndex+1)),g.addEventListener("click",()=>{if(e.length<2)return;let E=s.focusIndex;for(;E===s.focusIndex;)E=Math.floor(Math.random()*e.length);l(E)}),a.addEventListener("keydown",E=>{E.key==="ArrowLeft"?(E.preventDefault(),l(s.focusIndex-1)):E.key==="ArrowRight"&&(E.preventDefault(),l(s.focusIndex+1))}),(s.focusNavPending||document.activeElement===document.body)&&(s.focusNavPending=!1,a.focus({preventScroll:!0}))}var Pt=require("obsidian"),$l=qs(bs());var sp=[{id:"table",label:"Table"},{id:"library",label:"Cards"},{id:"kanban-genre",label:"Kanban"}];function Hl(s){return s&&typeof s=="object"&&"basename"in s?s:null}function np(s){let t=s.split(`
|
||
`).map(r=>r.trim()).filter(Boolean),e=r=>{var a,l;return(l=(a=t.find(c=>c.toLowerCase().startsWith(r+":")))==null?void 0:a.slice(r.length+1).trim())!=null?l:""},n=e("mode").toLowerCase(),i=n==="kanban"||n==="kanban-genre"?"kanban-genre":n==="cards"||n==="card"||n==="library"?"library":"table",o=parseInt(e("height"),10);return{file:e("file"),mode:i,height:Number.isFinite(o)&&o>0?o:null,collapse:e("collapse").split(",").map(r=>r.trim()).filter(Boolean)}}var xo=class extends Pt.MarkdownRenderChild{constructor(e,n,i,o,r){super(e);this.file=null;this.headers=[];this.rows=[];this.searchQuery="";this.tableSortCol=null;this.tableSortDir="asc";this.libraryStatusFilter="all";this.libraryGenreFilter="all";this.collapsedGroups=new Set;this.saveTimer=null;this.lastWritten=null;this.contentArea=null;this.app=n,this.settings=i,this.persistSettings=o,this.opts=r,this.mode=r.mode,this.collapsedGroups=new Set(r.collapse.map(a=>a.toLowerCase()))}get renderComponent(){return this}get contentEl(){return this.containerEl}get asView(){return this}async onload(){if(this.containerEl.addClass("csv-inline-view"),!this.opts.file){this.renderError("No file specified. Use: file: yourfile.csv");return}await this.reload()&&(this.renderView(),this.registerEvent(this.app.vault.on("modify",async e=>{if(!this.file||e.path!==this.file.path)return;let n=await this.app.vault.read(this.file);if(n===this.lastWritten)return;let i=Gt(n);this.headers=i.headers,this.rows=i.rows,this.renderView()})),this.registerEvent(this.app.vault.on("rename",(e,n)=>{this.file&&n===this.file.path&&(this.file=Hl(e))})))}onunload(){this.saveTimer&&window.clearTimeout(this.saveTimer)}async reload(){let e=Hl(this.app.vault.getAbstractFileByPath(this.opts.file));if(!e)return this.renderError(`File not found: ${this.opts.file}`),!1;this.file=e;try{let n=Gt(await this.app.vault.read(e));this.headers=n.headers,this.rows=n.rows}catch(n){return this.renderError(`Error reading file: ${n instanceof Error?n.message:String(n)}`),!1}return!0}renderError(e){this.containerEl.empty(),this.containerEl.createEl("p",{text:`csv-view: ${e}`,cls:"csv-add-error"})}scheduleSave(){this.saveTimer&&window.clearTimeout(this.saveTimer),this.saveTimer=window.setTimeout(()=>void this.doSave(),600)}async doSave(){if(this.file)try{let e=$l.default.unparse(this.rows,{columns:this.headers});this.lastWritten=e,await this.app.vault.modify(this.file,e)}catch(e){new Pt.Notice(`Couldn't save ${this.file.name}: ${e instanceof Error?e.message:String(e)}`,8e3)}}get fileCfg(){var e;return this.file?(e=this.settings.fileConfigs[this.file.path])!=null?e:{}:{}}saveFileCfg(e){this.file&&(this.settings.fileConfigs[this.file.path]=e,this.persistSettings())}resolveCol(e){for(let n of e){let i=this.headers.find(o=>o.toLowerCase()===n.toLowerCase());if(i)return i}return null}getNotesCol(){return this.fileCfg.notesColumn?this.fileCfg.notesColumn:this.resolveCol(["Notes","notes","Note","note","Summary","summary","Review","review","Quote","quote","Quotes","quotes","Comment","comment","Comments","comments","Description","description","Annotation","annotation"])}isNotesCol(e){let n=this.getNotesCol();return n?e===n:this.settings.notesColumns.some(i=>i.toLowerCase()===e.toLowerCase())}isSelectCol(e){return this.settings.selectColumns.some(n=>n.toLowerCase()===e.toLowerCase())}getStatusCol(){var e;return this.fileCfg.statusColumn?(e=this.headers.find(n=>n.toLowerCase()===this.fileCfg.statusColumn.toLowerCase()))!=null?e:null:this.resolveCol(["Status","status","State","state","Progress","progress","Stage","stage","Read","read","Watched","watched","Seen","seen","Done","done","Completed","completed"])}getCategoryCol(){var e;return this.fileCfg.categoryColumn?(e=this.headers.find(n=>n.toLowerCase()===this.fileCfg.categoryColumn.toLowerCase()))!=null?e:null:this.resolveCol(["Category","category","Categories","categories","Genre","genre","Genres","genres","Type","type","Types","types","Tag","tag","Tags","tags","Topic","topic","Topics","topics","Subject","subject","Section","section"])}titleKey(){var e;return(e=this.resolveCol(["Title","title","Name","name"]))!=null?e:void 0}authorKey(){var e;return(e=this.resolveCol(["Author","author","Authors","authors","Director","director","Artist","artist","Creator","creator","By","by"]))!=null?e:void 0}getTitle(e){var i;let n=this.titleKey();return(i=n?e[n]:e[this.headers[0]])!=null?i:"\u2014"}getSubtitle(e){var i;let n=this.authorKey();return n&&(i=e[n])!=null?i:""}getColumnValues(e){return Array.from(new Set(this.rows.map(n=>{var i;return(i=n[e])!=null?i:""}).filter(Boolean))).sort()}getImageCol(){var e;return this.fileCfg.imageColumn?(e=this.headers.find(n=>n.toLowerCase()===this.fileCfg.imageColumn.toLowerCase()))!=null?e:null:this.resolveCol(Qs)}getBooleanColumns(){var n;if((n=this.fileCfg.habitColumns)!=null&&n.length)return this.fileCfg.habitColumns.filter(i=>this.headers.includes(i));let e=["0","1","true","false","yes","no",""];return this.headers.filter(i=>i===this.getDateCol()||this.isNotesCol(i)?!1:this.rows.map(o=>{var r;return((r=o[i])!=null?r:"").toLowerCase().trim()}).every(o=>e.includes(o)))}getDateCol(){if(this.headers.length===0)return null;let e=this.headers[0];if(["date","day","datum"].includes(e.toLowerCase()))return e;let n=/^\d{4}-\d{2}-\d{2}$/,i=this.rows.slice(0,5);return i.length>0&&i.every(o=>{var r;return n.test((r=o[e])!=null?r:"")})?e:null}getFilteredRows(){var i;let e=this.rows;if(this.searchQuery.trim()){let o=this.searchQuery.toLowerCase().trim();e=e.filter(r=>this.headers.some(a=>{var l;return((l=r[a])!=null?l:"").toLowerCase().includes(o)}))}if(this.mode==="table"&&this.tableSortCol&&this.headers.includes(this.tableSortCol)){let o=this.tableSortCol,r=this.tableSortDir;return[...e].sort((a,l)=>{var d,h;let c=((d=a[o])!=null?d:"").localeCompare((h=l[o])!=null?h:"",void 0,{numeric:!0});return r==="asc"?c:-c})}let n=this.getDateCol();if(this.mode==="table"&&n){let o=(i=this.fileCfg.sortNewestFirst)!=null?i:!0;e=[...e].sort((r,a)=>{var c,d;let l=((c=r[n])!=null?c:"").localeCompare((d=a[n])!=null?d:"");return o?-l:l})}return e}notesFilePath(e){var a,l,c;let n=ys(this.getTitle(e)),i=(c=(l=(a=this.file)==null?void 0:a.parent)==null?void 0:l.path)!=null?c:"",o=this.settings.notesSubfolder.trim(),r=o?i?`${i}/${o}`:o:i;return(0,Pt.normalizePath)(`${r}/${n}.md`)}notesFileExists(e){return!!this.app.vault.getAbstractFileByPath(this.notesFilePath(e))}async openOrCreateNotes(e){var o;let n=this.notesFilePath(e),i=this.app.vault.getAbstractFileByPath(n);if(!i){let a=["---",...this.headers.filter(h=>!this.isNotesCol(h)&&e[h]).map(h=>`${h}: "${e[h].replace(/"/g,'\\"')}"`),"---","",`# ${this.getTitle(e)}`,"",""].join(`
|
||
`),l=this.headers.find(h=>this.isNotesCol(h)),c=a+(l&&((o=e[l])!=null&&o.trim())?e[l]:""),d=n.substring(0,n.lastIndexOf("/"));d&&!this.app.vault.getAbstractFileByPath(d)&&await this.app.vault.createFolder(d),i=await this.app.vault.create(n,c),new Pt.Notice(`Created: ${i.name}`)}await this.app.workspace.getLeaf("tab").openFile(i)}deleteWithUndo(e){let n=this.rows.indexOf(e);if(n<0)return;this.rows.splice(n,1),this.scheduleSave(),this.renderView();let i=this.getTitle(e)||"entry",o=document.createDocumentFragment();o.createSpan({text:`Deleted \u201C${i}\u201D. `});let r=o.createEl("button",{text:"Undo",cls:"csv-notice-undo"}),a=new Pt.Notice(o,6e3);r.addEventListener("click",()=>{r.hasAttribute("disabled")||(r.setAttribute("disabled","true"),this.rows.splice(Math.min(n,this.rows.length),0,e),this.scheduleSave(),this.renderView(),a.hide(),new Pt.Notice(`Restored \u201C${i}\u201D`,2500))})}openRowContextMenu(e,n){let i=new Pt.Menu;i.addItem(r=>r.setTitle("Open / Create Notes file").setIcon("file-text").onClick(()=>void this.openOrCreateNotes(e))),i.addItem(r=>r.setTitle("Open entry").setIcon("maximize").onClick(()=>{var a;return this.openNoteExpander(e,(a=this.getNotesCol())!=null?a:"")}));let o=this.getStatusCol();if(o){let r=this.getColumnValues(o);r.length&&(i.addSeparator(),r.forEach(a=>{a!==e[o]&&i.addItem(l=>l.setTitle(`Mark as: ${a}`).onClick(()=>{e[o]=a,this.scheduleSave(),this.renderView()}))}))}i.addSeparator(),i.addItem(r=>r.setTitle("Delete").setIcon("trash").onClick(()=>this.deleteWithUndo(e))),i.showAtMouseEvent(n)}openNoteExpander(e,n){var i,o;new Ue(this.app,e,n,this.headers,(o=(i=this.file)==null?void 0:i.path)!=null?o:"",this.isNotesCol.bind(this),this.isSelectCol.bind(this),this.getColumnValues.bind(this),r=>{Object.assign(e,r),this.scheduleSave(),this.renderView()},()=>this.deleteWithUndo(e)).open()}openAddModal(){new je(this.app,this.headers,this.isNotesCol.bind(this),this.isSelectCol.bind(this),this.getColumnValues.bind(this),e=>{this.rows.push(e),this.scheduleSave(),this.renderView(),new Pt.Notice(`Added: ${this.getTitle(e)}`)},{},e=>this.getBooleanColumns().includes(e)).open()}renderSelectField(e,n,i){var a;let o=(a=n[i])!=null?a:"",r=e.createDiv({cls:`csv-select-chip ${o?"":"empty"}`});return r.setText(o||"\u2014"),i.toLowerCase()==="status"&&o&&r.addClass(`status-chip-${o.toLowerCase().replace(/\s+/g,"-")}`),r.addEventListener("click",l=>{var c;l.stopPropagation(),Ot(r,(c=n[i])!=null?c:"",this.getColumnValues(i),d=>{n[i]=d,r.setText(d||"\u2014"),this.scheduleSave()},this.contentEl)}),r}renderMarkdownInto(e,n){var i,o;Pt.MarkdownRenderer.render(this.app,n,e,(o=(i=this.file)==null?void 0:i.path)!=null?o:"",this.renderComponent)}renderViewPreservingScroll(){this.renderView()}renderView(e=!1){let n=this.containerEl;e?this.contentArea&&this.contentArea.empty():(n.empty(),this.renderToolbar(n),this.contentArea=n.createDiv({cls:"csv-content-area"}),this.opts.height&&(this.contentArea.style.maxHeight=this.opts.height+"px"));let i=this.contentArea;if(i){if(i.toggleClass("csv-content-area--no-yscroll",this.mode==="kanban-genre"||this.mode==="table"),!this.headers.length){i.createDiv({cls:"csv-empty-state"}).createEl("p",{text:"This file is empty."});return}if(this.rows.length===0){let o=i.createDiv({cls:"csv-empty-state"});o.createEl("p",{text:"No entries yet."}),o.createEl("button",{cls:"csv-empty-state-action",text:"+ Add the first entry"}).addEventListener("click",()=>this.openAddModal());return}(this.mode==="library"||this.mode==="kanban-genre")&&!Nt(this.asView)&&(this.mode="table"),this.mode==="library"?cn(this.asView,i):this.mode==="kanban-genre"?ln(this.asView,i):rn(this.asView,i)}}renderToolbar(e){var c,d;let n=e.createDiv({cls:"csv-toolbar csv-inline-toolbar"});n.createDiv({cls:"csv-toolbar-title",text:(d=(c=this.file)==null?void 0:c.basename)!=null?d:""}).addEventListener("click",()=>{this.file&&this.app.workspace.getLeaf("tab").openFile(this.file)});let i=n.createDiv({cls:"csv-toolbar-controls"});i.createDiv({cls:"csv-row-count",text:`${this.rows.length} entries`});let o=!!Nt(this.asView),r=i.createDiv({cls:"csv-mode-group"});sp.forEach(({id:h,label:u})=>{if((h==="library"||h==="kanban-genre")&&!o)return;r.createEl("button",{cls:`csv-mode-btn ${this.mode===h?"active":""}`,text:u}).addEventListener("click",()=>{this.mode=h,this.renderView()})});let a=i.createEl("input",{cls:"csv-search-input",type:"text",placeholder:"Search\u2026",value:this.searchQuery,attr:{inputmode:"search",enterkeyhint:"search",autocomplete:"off"}}),l=null;a.addEventListener("input",h=>{this.searchQuery=h.target.value,l!==null&&window.clearTimeout(l),l=window.setTimeout(()=>{l=null,this.renderView(!0)},120)}),i.createEl("button",{cls:"csv-add-btn",text:"+ Add"}).addEventListener("click",()=>this.openAddModal())}};function Wl(s,t,e,n){n("csv-view",(i,o,r)=>{var h,u,f;let a=np(i),l=(f=(u=(h=s.vault.getAbstractFileByPath(r.sourcePath))==null?void 0:h.parent)==null?void 0:u.path)!=null?f:"",c=a.file?We(a.file,l):a.file,d=new xo(o,s,t,e,{...a,file:c});r.addChild(d)})}var Gs,ps=class extends rt.FileView{constructor(e,n,i){super(e);this.headers=[];this.rows=[];this.saveTimer=null;this.searchQuery="";this.contentArea=null;this.selectedDate=null;this.selectedHabit=null;this.chartInstance=null;this.timelineYear=new Date().getFullYear();this.libraryStatusFilter="all";this.libraryGenreFilter="all";this.collapsedGroups=new Set;this.taskProjectFilter="all";this.taskTypeFilter="all";this.focusIndex=0;this.focusNavPending=!1;this.tableSortCol=null;this.tableSortDir="asc";this.settings=n,this.persistSettings=i,this.mode=n.defaultMode,this.renderComponent=new rt.Component,this.renderComponent.load()}getViewType(){return Xs}getDisplayText(){var e,n;return(n=(e=this.file)==null?void 0:e.basename)!=null?n:"Card View"}getIcon(){return"table"}async onLoadFile(e){var o;try{let r=await this.app.vault.read(e),a=Gt(r);this.headers=a.headers,this.rows=a.rows}catch(r){console.error("CardView load error",r),this.headers=[],this.rows=[],new rt.Notice(`Couldn't read ${e.name}: ${r instanceof Error?r.message:String(r)}`,8e3)}this.file&&((o=this.settings.fileConfigs[this.file.path])!=null&&o.defaultMode)?this.mode=this.settings.fileConfigs[this.file.path].defaultMode:this.isTravelFile()?this.mode="travel":this.hasDateColumn()?this.mode="dashboard":this.mode=this.settings.defaultMode;let n=this.mode==="kanban-genre"||this.mode==="library",i=this.mode==="dashboard";(n&&!Nt(this)||i&&!this.hasDateColumn()||this.mode==="travel"&&!this.isTravelFile()||this.mode==="stats"&&!an(this)||this.mode==="tasks"&&!Ye(this))&&(this.mode="table"),this.selectedDate=null,this.focusIndex=0,this.tableSortCol=null,this.renderView()}async onUnloadFile(e){this.chartInstance&&(this.chartInstance.destroy(),this.chartInstance=null),this.headers=[],this.rows=[],this.contentEl.empty()}scheduleSave(){this.saveTimer&&window.clearTimeout(this.saveTimer),this.saveTimer=window.setTimeout(()=>this.doSave(),600)}async doSave(){if(this.file)try{let e=jl.default.unparse(this.rows,{columns:this.headers});await this.app.vault.modify(this.file,e)}catch(e){console.error("CardView save error",e),new rt.Notice(`Couldn't save ${this.file.name}: ${e instanceof Error?e.message:String(e)}`,8e3)}}get fileCfg(){var e;return this.file?(e=this.settings.fileConfigs[this.file.path])!=null?e:{}:{}}saveFileCfg(e){this.file&&(this.settings.fileConfigs[this.file.path]=e,this.persistSettings())}resolveCol(e){for(let n of e){let i=this.headers.find(o=>o.toLowerCase()===n.toLowerCase());if(i)return i}return null}getNotesCol(){return this.fileCfg.notesColumn?this.fileCfg.notesColumn:this.resolveCol(["Notes","notes","Note","note","Summary","summary","Review","review","Quote","quote","Quotes","quotes","Comment","comment","Comments","comments","Description","description","Annotation","annotation"])}isNotesCol(e){let n=this.getNotesCol();return n?e===n:this.settings.notesColumns.some(i=>i.toLowerCase()===e.toLowerCase())}isSelectCol(e){return this.settings.selectColumns.some(n=>n.toLowerCase()===e.toLowerCase())}getStatusCol(){var e;return this.fileCfg.statusColumn?(e=this.headers.find(n=>n.toLowerCase()===this.fileCfg.statusColumn.toLowerCase()))!=null?e:null:this.resolveCol(["Status","status","State","state","Progress","progress","Stage","stage","Read","read","Watched","watched","Seen","seen","Done","done","Completed","completed"])}getCategoryCol(){var e;return this.fileCfg.categoryColumn?(e=this.headers.find(n=>n.toLowerCase()===this.fileCfg.categoryColumn.toLowerCase()))!=null?e:null:this.resolveCol(["Category","category","Categories","categories","Genre","genre","Genres","genres","Type","type","Types","types","Tag","tag","Tags","tags","Topic","topic","Topics","topics","Subject","subject","Section","section"])}titleKey(){var e;return(e=this.resolveCol(["Title","title","Name","name"]))!=null?e:void 0}authorKey(){var e;return(e=this.resolveCol(["Author","author","Authors","authors","Director","director","Artist","artist","Creator","creator","By","by"]))!=null?e:void 0}getTitle(e){var i;let n=this.titleKey();return(i=n?e[n]:e[this.headers[0]])!=null?i:"\u2014"}getSubtitle(e){var i;let n=this.authorKey();return n&&(i=e[n])!=null?i:""}getColumnValues(e){return Array.from(new Set(this.rows.map(n=>{var i;return(i=n[e])!=null?i:""}).filter(Boolean))).sort()}getImageCol(){var e;return this.fileCfg.imageColumn?(e=this.headers.find(n=>n.toLowerCase()===this.fileCfg.imageColumn.toLowerCase()))!=null?e:null:this.resolveCol(Qs)}notesFilePath(e){var a,l,c;let n=ys(this.getTitle(e)),i=(c=(l=(a=this.file)==null?void 0:a.parent)==null?void 0:l.path)!=null?c:"",o=this.settings.notesSubfolder.trim(),r=o?i?`${i}/${o}`:o:i;return(0,rt.normalizePath)(`${r}/${n}.md`)}notesFileExists(e){return!!this.app.vault.getAbstractFileByPath(this.notesFilePath(e))}deleteWithUndo(e){let n=this.rows.indexOf(e);if(n<0)return;this.rows.splice(n,1),this.scheduleSave(),this.renderViewPreservingScroll();let i=this.getTitle(e)||"entry",o=document.createDocumentFragment();o.createSpan({text:`Deleted \u201C${i}\u201D. `});let r=o.createEl("button",{text:"Undo",cls:"csv-notice-undo"}),a=new rt.Notice(o,6e3);r.addEventListener("click",()=>{if(r.hasAttribute("disabled"))return;r.setAttribute("disabled","true");let l=Math.min(n,this.rows.length);this.rows.splice(l,0,e),this.scheduleSave(),this.renderViewPreservingScroll(),a.hide(),new rt.Notice(`Restored \u201C${i}\u201D`,2500)})}openRowContextMenu(e,n){let i=new rt.Menu;i.addItem(r=>r.setTitle("Open / Create Notes file").setIcon("file-text").onClick(()=>this.openOrCreateNotes(e))),i.addItem(r=>r.setTitle("Open entry").setIcon("maximize").onClick(()=>{var a;return this.openNoteExpander(e,(a=this.getNotesCol())!=null?a:"")}));let o=this.getStatusCol();if(o){let r=this.getColumnValues(o);r.length&&(i.addSeparator(),r.forEach(a=>{a!==e[o]&&i.addItem(l=>l.setTitle(`Mark as: ${a}`).onClick(()=>{e[o]=a,this.scheduleSave(),this.renderViewPreservingScroll()}))}))}i.addSeparator(),i.addItem(r=>r.setTitle("Delete").setIcon("trash").onClick(()=>this.deleteWithUndo(e))),i.showAtMouseEvent(n)}async openOrCreateNotes(e){var o,r;let n=this.notesFilePath(e),i=this.app.vault.getAbstractFileByPath(n);if(!i){let a=this.headers.filter(p=>!this.isNotesCol(p)&&e[p]).map(p=>`${p}: "${e[p].replace(/"/g,'\\"')}"`),l=Ye(this)?fi(this):null,c=l?((o=e[l])!=null?o:"").split(",").map(p=>Mo(p.trim())).filter(Boolean).map(p=>`project-${p}`):[];c.length&&a.unshift(`tags: [${c.join(", ")}]`);let d=["---",...a,"---","",`# ${this.getTitle(e)}`,"",""].join(`
|
||
`),h=this.headers.find(p=>this.isNotesCol(p)),u=d+(h&&((r=e[h])!=null&&r.trim())?e[h]:""),f=n.substring(0,n.lastIndexOf("/"));f&&!this.app.vault.getAbstractFileByPath(f)&&await this.app.vault.createFolder(f),i=await this.app.vault.create(n,u),new rt.Notice(`Created: ${i.name}`)}await this.app.workspace.getLeaf("tab").openFile(i)}openNoteExpander(e,n){var i,o;new Ue(this.app,e,n,this.headers,(o=(i=this.file)==null?void 0:i.path)!=null?o:"",this.isNotesCol.bind(this),this.isSelectCol.bind(this),this.getColumnValues.bind(this),r=>{Object.assign(e,r),this.scheduleSave(),this.renderViewPreservingScroll()},()=>this.deleteWithUndo(e)).open()}renderViewPreservingScroll(){var l,c,d,h,u;let e=this.contentEl,n=e.querySelector(".csv-content-area"),i=e.querySelector(".csv-table-wrapper"),o=e.querySelector(".csv-kanban-board"),r={contentTop:(l=n==null?void 0:n.scrollTop)!=null?l:0,contentLeft:(c=n==null?void 0:n.scrollLeft)!=null?c:0,tableLeft:(d=i==null?void 0:i.scrollLeft)!=null?d:0,tableTop:(h=i==null?void 0:i.scrollTop)!=null?h:0,boardLeft:(u=o==null?void 0:o.scrollLeft)!=null?u:0,cols:new Map};e.querySelectorAll(".csv-kanban-col").forEach(f=>{var g,b;let p=(b=(g=f.querySelector(".csv-kanban-col-title"))==null?void 0:g.textContent)!=null?b:"",m=f.querySelector(".csv-kanban-col-body");p&&m&&r.cols.set(p,m.scrollTop)}),this.renderView();let a=()=>{let f=this.contentEl.querySelector(".csv-content-area"),p=this.contentEl.querySelector(".csv-table-wrapper"),m=this.contentEl.querySelector(".csv-kanban-board");f&&(f.scrollTop=r.contentTop,f.scrollLeft=r.contentLeft),p&&(p.scrollLeft=r.tableLeft,p.scrollTop=r.tableTop),m&&(m.scrollLeft=r.boardLeft),this.contentEl.querySelectorAll(".csv-kanban-col").forEach(g=>{var E,w;let b=(w=(E=g.querySelector(".csv-kanban-col-title"))==null?void 0:E.textContent)!=null?w:"",x=g.querySelector(".csv-kanban-col-body"),_=r.cols.get(b);x&&_!=null&&(x.scrollTop=_)})};a(),requestAnimationFrame(()=>{a(),requestAnimationFrame(a)}),setTimeout(a,50)}openAddModal(){let e={};if(Ye(this)){let n=dn(this);n&&(e[n]=["Task","Note","Idea"]);let i=hn(this);i&&(e[i]=["Low","Medium","High"])}new je(this.app,this.headers,this.isNotesCol.bind(this),this.isSelectCol.bind(this),this.getColumnValues.bind(this),n=>{this.rows.push(n),this.scheduleSave(),this.renderViewPreservingScroll(),new rt.Notice(`Added: ${this.getTitle(n)}`)},e,n=>this.getBooleanColumns().includes(n)).open()}renderSelectField(e,n,i){var a;let o=(a=n[i])!=null?a:"",r=e.createDiv({cls:`csv-select-chip ${o?"":"empty"}`});return r.setText(o||"\u2014"),i.toLowerCase()==="status"&&o&&r.addClass(`status-chip-${o.toLowerCase().replace(/\s+/g,"-")}`),r.addEventListener("click",l=>{var c;l.stopPropagation(),Ot(r,(c=n[i])!=null?c:"",this.getColumnValues(i),d=>{n[i]=d,r.setText(d||"\u2014"),r.className=`csv-select-chip ${d?"":"empty"}`,i.toLowerCase()==="status"&&d&&r.addClass(`status-chip-${d.toLowerCase().replace(/\s+/g,"-")}`),this.scheduleSave()},this.contentEl,{multi:It(i)})}),r}renderView(e=!1){var o;let n=this.contentEl;e?this.contentArea&&this.contentArea.empty():(n.empty(),n.addClass("csv-card-view-root"),this.renderComponent.unload(),this.renderComponent=new rt.Component,this.renderComponent.load(),lr(this,n),this.contentArea=n.createDiv({cls:"csv-content-area"}),this.installTouchScrollGuard(this.contentArea));let i=this.contentArea;if(i){if(i.toggleClass("csv-content-area--no-yscroll",this.mode==="kanban-genre"||this.mode==="table"),!this.headers.length){let r=i.createDiv({cls:"csv-empty-state csv-empty-state--big"});r.createEl("h3",{text:"This file is empty"}),r.createEl("p",{text:"Add a header row in your spreadsheet app, then come back \u2014 or click + Add in the toolbar to start fresh."});return}if(this.rows.length===0){let r=i.createDiv({cls:"csv-empty-state csv-empty-state--big"});r.createEl("h3",{text:"No entries yet"}),r.createEl("button",{cls:"csv-empty-state-action",text:"+ Add the first entry"}).addEventListener("click",()=>this.openAddModal()),r.createEl("p",{cls:"csv-empty-state-hint",text:`${this.headers.length} column${this.headers.length===1?"":"s"} detected: ${this.headers.slice(0,5).join(", ")}${this.headers.length>5?"\u2026":""}`});return}this.mode==="travel"?Wo(i,this.rows,()=>this.loadMapSvg(),()=>this.scheduleSave(),this.settings.showResidency===!1?null:(o=this.settings.residencyRules)!=null?o:null,r=>this.renderComponent.register(r)):this.mode==="dashboard"?Bl(this,i):this.mode==="library"?cn(this,i):this.mode==="kanban-genre"?ln(this,i):this.mode==="stats"?qo(this,i):this.mode==="focus"?zl(this,i):this.mode==="tasks"?ar(this,i):rn(this,i)}}installTouchScrollGuard(e){if(!matchMedia("(pointer: coarse)").matches)return;let n=0,i=0,o=!1;e.addEventListener("touchstart",r=>{r.touches.length===1&&(n=r.touches[0].clientX,i=r.touches[0].clientY,o=!1)},{capture:!0,passive:!0}),e.addEventListener("touchmove",r=>{if(r.touches.length!==1||o)return;let a=Math.abs(r.touches[0].clientX-n),l=Math.abs(r.touches[0].clientY-i);(a>10||l>10)&&(o=!0)},{capture:!0,passive:!0}),e.addEventListener("click",r=>{o&&(r.preventDefault(),r.stopImmediatePropagation())},!0)}async backupToArchive(){var a,l;if(!this.file)return;let e=(l=(a=this.file.parent)==null?void 0:a.path)!=null?l:"",n=e?`${e}/Archive`:"Archive";await this.app.vault.adapter.exists(n)||await this.app.vault.adapter.mkdir(n);let i=new Date().toISOString().slice(0,10),o=`${n}/${this.file.basename}_${i}.${this.file.extension}`;if(await this.app.vault.adapter.exists(o)){new rt.Notice(`Backup already exists for today: ${o}`);return}let r=await this.app.vault.readBinary(this.file);await this.app.vault.adapter.writeBinary(o,r),new rt.Notice(`Backed up to ${o}`)}hasDateColumn(){return this.getDateCol()!==null}isTravelFile(){let e=new Set(this.headers.map(n=>n.toLowerCase()));return e.has("country")&&e.has("date_entered")&&e.has("date_left")&&e.has("source")}async loadMapSvg(){if(Gs!==void 0)return Gs;let e=(0,rt.normalizePath)(`${this.app.vault.configDir}/plugins/csv-card-view/world-map.svg`);try{Gs=await this.app.vault.adapter.read(e)}catch(n){Gs=null}return Gs}getFilteredRows(){var i;let e=this.rows;if(this.searchQuery.trim()){let o=this.searchQuery.toLowerCase().trim();e=e.filter(r=>this.headers.some(a=>{var c;return((c=r[a])!=null?c:"").toLowerCase().includes(o)}))}if(this.mode==="table"&&this.tableSortCol&&this.headers.includes(this.tableSortCol))return Do(e,this.tableSortCol,this.tableSortDir);let n=this.getDateCol();if(this.mode==="table"&&n){let o=(i=this.fileCfg.sortNewestFirst)!=null?i:!0;e=[...e].sort((r,a)=>{var h,u;let l=(h=r[n])!=null?h:"",c=(u=a[n])!=null?u:"",d=l.localeCompare(c);return o?-d:d})}return e}getDateCol(){if(this.headers.length===0)return null;let e=this.headers[0],n=e.toLowerCase();if(["date","day","datum"].includes(n))return e;let i=this.rows.slice(0,5),o=/^\d{4}-\d{2}-\d{2}$/;return i.length>0&&i.every(a=>{var l;return o.test((l=a[e])!=null?l:"")})?e:null}getBooleanColumns(){return this.fileCfg.habitColumns&&this.fileCfg.habitColumns.length>0?this.fileCfg.habitColumns.filter(e=>this.headers.includes(e)):this.autoDetectBooleanColumns()}autoDetectBooleanColumns(){let e=["0","1","true","false","yes","no",""];return this.headers.filter(n=>n===this.getDateCol()||this.isNotesCol(n)?!1:this.rows.map(o=>{var r;return((r=o[n])!=null?r:"").toLowerCase().trim()}).every(o=>e.includes(o)))}parseDate(e){let n=e.match(/^(\d{4})-(\d{2})-(\d{2})$/);return n?new Date(parseInt(n[1]),parseInt(n[2])-1,parseInt(n[3])):null}formatDate(e){let n=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0");return`${n}-${i}-${o}`}isTruthy(e){let n=(e!=null?e:"").toLowerCase().trim();return n==="1"||n==="true"||n==="yes"}renderMarkdownInto(e,n){var i,o;rt.MarkdownRenderer.render(this.app,n,e,(o=(i=this.file)==null?void 0:i.path)!=null?o:"",this.renderComponent)}cycleMode(){let e=un(this);if(e.length<2)return;let n=e.findIndex(i=>i.id===this.mode);this.mode=e[(n+1)%e.length].id,this.renderView()}onunload(){this.renderComponent.unload(),this.saveTimer&&window.clearTimeout(this.saveTimer)}},ip=[{id:"tasks",command:"Create tasks file",defaultName:"Tasks",headers:["Title","Type","Project","Status","Priority","Due","Notes"],mode:"tasks"},{id:"travel",command:"Create travel file",defaultName:"Travel",headers:["Country","date_entered","date_left","source","Notes"],mode:"travel"},{id:"habits",command:"Create habit tracker file",defaultName:"Habits",headers:["Date","Exercise","Meditate","Read","Notes"],mode:"dashboard"}],Zn=class extends rt.Plugin{constructor(){super(...arguments);this.settings=ni}async onload(){await this.loadSettings(),this.registerView(Xs,e=>new ps(e,this.settings,()=>this.saveSettings())),this.registerExtensions(["csv"],Xs),this.addSettingTab(new on(this.app,this)),this.registerMarkdownCodeBlockProcessor("csv-add",async(e,n,i)=>{await Uo(this.app,e.trim(),n,i)}),this.registerMarkdownCodeBlockProcessor("csv-random",async(e,n,i)=>{await cr(this.app,e.trim(),n,i)}),Wl(this.app,this.settings,()=>this.saveSettings(),(e,n)=>this.registerMarkdownCodeBlockProcessor(e,n)),this.addCommand({id:"add-entry",name:"Add entry to current CSV",checkCallback:e=>{let n=this.app.workspace.getActiveViewOfType(ps);return n?(e||n.openAddModal(),!0):!1}}),this.addCommand({id:"cycle-view-mode",name:"Cycle view mode",checkCallback:e=>{let n=this.app.workspace.getActiveViewOfType(ps);return n?(e||n.cycleMode(),!0):!1}});for(let e of ip)this.addCommand({id:`create-${e.id}`,name:e.command,callback:()=>this.createTemplateFile(e)});this.registerEvent(this.app.vault.on("rename",async(e,n)=>{e instanceof rt.TFile&&e.extension==="csv"&&this.settings.fileConfigs[n]&&(Ro(this.settings.fileConfigs,n,e.path),await this.saveSettings())})),this.registerEvent(this.app.vault.on("delete",async e=>{e instanceof rt.TFile&&this.settings.fileConfigs[e.path]&&(delete this.settings.fileConfigs[e.path],await this.saveSettings())})),this.registerMarkdownCodeBlockProcessor("csv-refresh",(e,n,i)=>{let o=n.createEl("button",{cls:"csv-refresh-btn"});o.innerHTML="\u21BB refresh",o.addEventListener("click",async()=>{let r=i.sourcePath,a=this.app.vault.getAbstractFileByPath(r);if(a instanceof rt.TFile){let l=this.app.workspace.activeLeaf;l&&await l.openFile(a,{state:{mode:"preview"}})}})})}async createTemplateFile(e){new en(this.app,e.command,e.defaultName,"File name (without .csv)",async n=>{let i=this.app.workspace.getActiveFile(),o=i!=null&&i.parent&&i.parent.path!=="/"?`${i.parent.path}/`:"",r=ys(n),a=(0,rt.normalizePath)(`${o}${r}.csv`);for(let c=2;this.app.vault.getAbstractFileByPath(a);c++)a=(0,rt.normalizePath)(`${o}${r} ${c}.csv`);let l=await this.app.vault.create(a,e.headers.join(",")+`
|
||
`);this.settings.fileConfigs[l.path]={...this.settings.fileConfigs[l.path],defaultMode:e.mode},await this.saveSettings(),await this.app.workspace.getLeaf("tab").openFile(l),new rt.Notice(`Created: ${l.name}`)}).open()}async loadSettings(){var e;this.settings=Object.assign({},ni,await this.loadData()),this.settings.residencyRules=JSON.parse(JSON.stringify((e=this.settings.residencyRules)!=null?e:[]))}async saveSettings(){await this.saveData(this.settings)}};
|
||
/*! Bundled license information:
|
||
|
||
papaparse/papaparse.min.js:
|
||
(* @license
|
||
Papa Parse
|
||
v5.5.3
|
||
https://github.com/mholt/PapaParse
|
||
License: MIT
|
||
*)
|
||
|
||
@kurkle/color/dist/color.esm.js:
|
||
(*!
|
||
* @kurkle/color v0.3.4
|
||
* https://github.com/kurkle/color#readme
|
||
* (c) 2024 Jukka Kurkela
|
||
* Released under the MIT License
|
||
*)
|
||
|
||
chart.js/dist/chunks/helpers.dataset.js:
|
||
(*!
|
||
* Chart.js v4.5.1
|
||
* https://www.chartjs.org
|
||
* (c) 2025 Chart.js Contributors
|
||
* Released under the MIT License
|
||
*)
|
||
|
||
chart.js/dist/chart.js:
|
||
(*!
|
||
* Chart.js v4.5.1
|
||
* https://www.chartjs.org
|
||
* (c) 2025 Chart.js Contributors
|
||
* Released under the MIT License
|
||
*)
|
||
*/
|