import{defineComponent,ref,onMounted,h}from"vue";import{atou}from"vuepress-shared/lib/client";import"../styles/chart.scss";const LOADING_SVG='<svg xmlns="http://www.w3.org/2000/svg" class="loading-icon" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid"><circle cx="50" cy="50" r="0" fill="none" stroke="currentColor" stroke-width="2"><animate attributeName="r" repeatCount="indefinite" dur="1s" values="0;40" keyTimes="0;1" keySplines="0 0.2 0.8 1" calcMode="spline" begin="0s"/><animate attributeName="opacity" repeatCount="indefinite" dur="1s" values="1;0" keyTimes="0;1" keySplines="0.2 0 0.8 1" calcMode="spline" begin="0s"/></circle><circle cx="50" cy="50" r="0" fill="none" stroke="currentColor" stroke-width="2"><animate attributeName="r" repeatCount="indefinite" dur="1s" values="0;40" keyTimes="0;1" keySplines="0 0.2 0.8 1" calcMode="spline" begin="-0.3333333333333333s"/><animate attributeName="opacity" repeatCount="indefinite" dur="1s" values="1;0" keyTimes="0;1" keySplines="0.2 0 0.8 1" calcMode="spline" begin="-0.3333333333333333s"/></circle><circle cx="50" cy="50" r="0" fill="none" stroke="currentColor" stroke-width="2"><animate attributeName="r" repeatCount="indefinite" dur="1s" values="0;40" keyTimes="0;1" keySplines="0 0.2 0.8 1" calcMode="spline" begin="-0.6666666666666666s"/><animate attributeName="opacity" repeatCount="indefinite" dur="1s" values="1;0" keyTimes="0;1" keySplines="0.2 0 0.8 1" calcMode="spline" begin="-0.6666666666666666s"/></circle></svg>',parseChartConfig=(config,type)=>{if(type==="json")return JSON.parse(config);const exports={},module={exports};return eval(config),module.exports};var ChartJS=defineComponent({name:"ChartJS",props:{config:{type:String,required:!0},id:{type:String,required:!0},title:{type:String,default:""},type:{type:String,default:"json"}},setup(e){const r=ref(),n=ref(),i=ref(!0);return onMounted(()=>{Promise.all([import("chart.js/auto"),new Promise(t=>setTimeout(t,MARKDOWN_ENHANCE_DELAY))]).then(([{default:t}])=>{t.defaults.maintainAspectRatio=!1;const a=parseChartConfig(atou(e.config),e.type),o=n.value.getContext("2d");new t(o,a),i.value=!1})}),()=>[e.title?h("div",{class:"chart-title"},decodeURIComponent(e.title)):null,i.value?h("div",{class:"chart-loading-wrapper",innerHTML:LOADING_SVG}):null,h("div",{ref:r,class:"chart-wrapper",id:e.id,style:{display:i.value?"none":"block"}},h("canvas",{ref:n,height:400}))]}});export{ChartJS as default};
//# sourceMappingURL=ChartJS.js.map
