import { defineComponent as p, ref as f, watch as l, nextTick as c, onBeforeUnmount as d, createElementBlock as s, openBlock as u } from "vue";
import * as r from "echarts/core";
import { GridComponent as h, DataZoomComponent as C, LegendComponent as _ } from "echarts/components";
import { BarChart as B } from "echarts/charts";
import { CanvasRenderer as k } from "echarts/renderers";
import { defaultOption as v } from "./model/options.js";
const x = {
  name: "CiEchartBar"
}, V = /* @__PURE__ */ p({
  ...x,
  props: {
    option: { default: () => v },
    immediate: { type: Boolean, default: !1 }
  },
  setup(n) {
    r.use([h, C, _, B, k]);
    const o = f(null);
    let e = null;
    const t = n;
    function a() {
      e ? e.clear() : e = r.init(o.value), e.setOption(t.option);
    }
    return l(
      () => t.option,
      (i, m) => {
        c(() => {
          a();
        });
      },
      { deep: !0, immediate: t.immediate }
    ), d(() => {
      e && e.dispose();
    }), (i, m) => (u(), s("div", {
      id: "CiEchartBar",
      ref_key: "chartRef",
      ref: o
    }, null, 512));
  }
});
export {
  V as default
};
