import "../../../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.mjs";
import B from "../../../../../../node_modules/.pnpm/vue-echarts@6.6.1_echarts@5.4.3_vue@3.3.4/node_modules/vue-echarts/dist/index.esm.min.mjs";
import { useCanvasInitOptions } from "../../../../../hooks/useCanvasInitOptions.hook.mjs";
import { seriesItem, includes } from "./config.mjs";
import { mergeTheme } from "../../../../public/chart.mjs";
import "../../../../../store/modules/designStore/designStore.mjs";
import "../../../../../settings/designSetting.mjs";
import "../../../../../../node_modules/.pnpm/screenfull@6.0.2/node_modules/screenfull/index.mjs";
import isObject from "../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isObject.mjs";
import "../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_root.mjs";
import "../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGetTag.mjs";
import "../../../../../../node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.mjs";
import cloneDeep from "../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/cloneDeep.mjs";
import "../../../../../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.mjs";
import { isPreview } from "../../../../../utils/router.mjs";
import "../../../../../../node_modules/.pnpm/vue3-lazyload@0.2.5-beta_a6dezdz3je235ci4e3tu4rayna/node_modules/vue3-lazyload/dist/vue3-lazyload.esm.mjs";
import "../../../../../components/GoSkeleton/index.vue.mjs";
import "../../../../../components/GoLoading/index.mjs";
import { useChartDataFetch } from "../../../../../hooks/useChartDataFetch.hook.mjs";
import "../../../../../api/axios.mjs";
import "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/index.mjs";
import "../../../../../store/modules/langStore/langStore.mjs";
import { useChartEditStore } from "../../../../../store/modules/chartEditStore/chartEditStore.mjs";
import { install } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/dataset/install.mjs";
import { install as install$2 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/chart/bar/install.mjs";
import { install as install$3 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/grid/install.mjs";
import { install as install$4 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/tooltip/install.mjs";
import { install as install$5 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/legend/install.mjs";
import { defineComponent, computed, watch, nextTick, openBlock, createBlock } from "../../../../../../node_modules/.pnpm/@vue_runtime-core@3.3.4/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.mjs";
import { use } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/extension.mjs";
import { install as install$1 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/renderer/installCanvasRenderer.mjs";
import { ref, unref } from "../../../../../../node_modules/.pnpm/@vue_reactivity@3.3.4/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    themeSetting: {
      type: Object,
      required: true
    },
    themeColor: {
      type: Object,
      required: true
    },
    chartConfig: {
      type: Object,
      required: true
    }
  },
  setup(__props) {
    const props = __props;
    const initOptions = useCanvasInitOptions(props.chartConfig.option, props.themeSetting);
    use([install, install$1, install$2, install$3, install$4, install$5]);
    const replaceMergeArr = ref();
    const option = computed(() => {
      return mergeTheme(props.chartConfig.option, props.themeSetting, includes);
    });
    watch(
      () => props.chartConfig.option.dataset,
      (newData, oldData) => {
        try {
          if (!isObject(newData) || !("dimensions" in newData))
            return;
          if (Array.isArray(newData == null ? void 0 : newData.dimensions)) {
            const seriesArr = [];
            const oldDimensions = Array.isArray(oldData == null ? void 0 : oldData.dimensions) && oldData.dimensions.length >= 1 ? oldData.dimensions.length : 1;
            const newDimensions = newData.dimensions.length >= 1 ? newData.dimensions.length : 1;
            const dimensionsGap = newDimensions - oldDimensions;
            if (dimensionsGap < 0) {
              props.chartConfig.option.series.splice(newDimensions - 1);
            } else if (dimensionsGap > 0) {
              if (!oldData || !(oldData == null ? void 0 : oldData.dimensions) || !Array.isArray(oldData == null ? void 0 : oldData.dimensions) || !(oldData == null ? void 0 : oldData.dimensions.length)) {
                props.chartConfig.option.series = [];
              }
              for (let i = 0; i < dimensionsGap; i++) {
                seriesArr.push(cloneDeep(seriesItem));
              }
              props.chartConfig.option.series.push(...seriesArr);
            }
            replaceMergeArr.value = ["series"];
            nextTick(() => {
              replaceMergeArr.value = [];
            });
          }
        } catch (error) {
          console.log(error);
        }
      },
      {
        deep: false
      }
    );
    const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore);
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(B), {
        ref_key: "vChartRef",
        ref: vChartRef,
        "init-options": unref(initOptions),
        theme: __props.themeColor,
        option: option.value,
        "manual-update": unref(isPreview)(),
        "update-options": {
          replaceMerge: replaceMergeArr.value
        },
        autoresize: ""
      }, null, 8, ["init-options", "theme", "option", "manual-update", "update-options"]);
    };
  }
});
export {
  _sfc_main as default
};
