import{ref as b,inject as y,onMounted as O,watch as p,onActivated as w,onBeforeUnmount as E,createElementBlock as j,openBlock as z}from"/vue.js";import{m as u}from"./nc-main.DEgIQeOo.js";import _ from"./nc-echart.DgXwGxFW.js";import{e as k}from"./element-resize-detector.D4BrbixK.js";import"./service-worker.DGZzV4eE.js";const f=["legendselectchanged","legendselected","legendunselected","legendunscroll","datazoom","datarangeselected","timelinechanged","timelineplaychanged","restore","dataviewchanged","magictypechanged","geoselectchanged","geoselected","geounselected","pieselectchanged","pieselected","pieunselected","mapselectchanged","mapselected","mapunselected","axisareaselected","focusnodeadjacency","unfocusnodeadjacency","brush","brushselected","rendered","finished","click","dblclick","mouseover","mouseout","mousedown","mouseup","globalout"],N=Object.assign({name:"NcChart"},{__name:"nc-chart",props:{options:{type:[Object],required:!1},initOptions:{type:[Object],required:!1,default:void 0},theme:{type:[String,Object],default:"light"},group:{type:String,default:void 0},autoResize:{type:Boolean,default:!0},update:{type:Number,default:void 0}},emits:f,setup(g,{emit:h}){console.debug("* nc-chart lazy-loaded");const r=b(null),s=y("state");let e,i,l;const m=h,n=g;function d(t){if(t){e||a();try{e.setOption(t||{},!0)}catch(o){u.setError(s,`echarts watch option, set option failed with error '${o}'`)}}}O(function(){n.options&&a(),p(()=>n.options,t=>{d(t)}),p(()=>n.update,()=>{d(n.options)})}),w(function(){n.autoResize&&e&&e.resize()}),E(()=>{i&&i.uninstall(r.value),i=null,e&&e.dispose(),e=null});function a(){if(!e){l=n.manualOptions;try{e=_.init(r.value,n.theme,n.initOptions||{})}catch(t){u.setError(s,`echarts init failed with error '${t}'`)}n.group&&(e.group=n.group);try{e.setOption(l||n.options||{},!0)}catch(t){u.setError(s,`echarts set option failed with error '${t}'`)}setTimeout(()=>{i=k({}),i.listenTo(r.value,()=>{e&&e.resize&&e.resize()})},100),f.forEach(t=>{e.on(t,o=>{m(t,o)})}),Object.defineProperties(n,{width:{configurable:!0,get:()=>c("width","getWidth")},height:{configurable:!0,get:()=>c("height","getHeight")},isDisposed:{configurable:!0,get:()=>!!c("isDisposed","isDisposed")},computedOptions:{configurable:!0,get:()=>c("computedOptions","getOption")}})}}function c(t,o){return e||a(),e[o]()}return(t,o)=>(z(),j("div",{class:"nc-chart",ref_key:"chartElem",ref:r},null,512))}});export{N as default};
