import{useEventListener,useDebounceFn}from"@vueuse/core";import{defineComponent,ref,onMounted,onBeforeUnmount,h}from"vue";import{atou,LoadingIcon}from"vuepress-shared/client";import"../styles/echarts.scss";const parseEChartsConfig=(config,type)=>{if(type==="js"){const exports={},module={exports};return eval(config),module.exports}return JSON.parse(config)};var ECharts=defineComponent({name:"ECharts",props:{config:{type:String,required:!0},id:{type:String,required:!0},title:{type:String,default:""},type:{type:String,default:"json"}},setup(t){const o=ref();let e;const r=ref(!0);return onMounted(()=>{Promise.all([import("echarts"),new Promise(n=>setTimeout(n,MARKDOWN_ENHANCE_DELAY))]).then(([n])=>{const i=parseEChartsConfig(atou(t.config),t.type);e=n.init(o.value),e.setOption(i),r.value=!1}),useEventListener("resize",useDebounceFn(()=>e==null?void 0:e.resize(),100))}),onBeforeUnmount(()=>{e==null||e.dispose()}),()=>[t.title?h("div",{class:"echarts-title"},decodeURIComponent(t.title)):null,h("div",{class:"echarts-wrapper"},[h("div",{ref:o,class:"echarts-container",id:t.id}),r.value?h(LoadingIcon,{class:"echarts-loading",height:360}):null])]}});export{ECharts as default};
//# sourceMappingURL=ECharts.js.map
