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 "../../../../../../node_modules/.pnpm/echarts-liquidfill@3.1.0_echarts@5.4.3/node_modules/echarts-liquidfill/src/liquidFillSeries.mjs";
import "../../../../../../node_modules/.pnpm/echarts-liquidfill@3.1.0_echarts@5.4.3/node_modules/echarts-liquidfill/src/liquidFillView.mjs";
import "../../../../../../node_modules/.pnpm/screenfull@6.0.2/node_modules/screenfull/index.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 { isString, isNumber } from "../../../../../utils/type.mjs";
import "../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseClone.mjs";
import "../../../../../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.mjs";
import { isPreview } from "../../../../../utils/router.mjs";
import { colorGradientCustomMerge } from "../../../../../utils/style.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 "../../../../../settings/designSetting.mjs";
import { defaultTheme } from "../../../../../settings/chartThemes/index.mjs";
import { useChartEditStore } from "../../../../../store/modules/chartEditStore/chartEditStore.mjs";
import "../../../../../store/modules/designStore/designStore.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 { defineComponent, watch, 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 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/renderer/installCanvasRenderer.mjs";
import { install as install$1 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/grid/install.mjs";
import { reactive, 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]);
    const chartEditStore = useChartEditStore();
    const option = reactive({
      value: {}
    });
    watch(
      () => chartEditStore.getEditCanvasConfig.chartThemeColor,
      (newColor) => {
        try {
          if (!isPreview()) {
            const themeColor = colorGradientCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)[newColor] || colorGradientCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)[defaultTheme];
            props.chartConfig.option.series[0].backgroundStyle.color = themeColor[2];
            props.chartConfig.option.series[0].color[0].colorStops = [
              {
                offset: 0,
                color: themeColor[0]
              },
              {
                offset: 1,
                color: themeColor[1]
              }
            ];
          }
          option.value = props.chartConfig.option;
        } catch (error) {
          console.log(error);
        }
      },
      {
        immediate: true
      }
    );
    const dataHandle = (newData) => {
      newData = isString(newData) ? parseFloat(newData) : newData;
      return parseFloat(newData.toFixed(2));
    };
    watch(
      () => props.chartConfig.option.dataset,
      (newData) => {
        if (!isString(newData) && !isNumber(newData))
          return;
        props.chartConfig.option.series[0].data = [dataHandle(newData)];
        option.value = props.chartConfig.option;
      },
      {
        immediate: true,
        deep: false
      }
    );
    useChartDataFetch(props.chartConfig, useChartEditStore, (newData) => {
      option.value.series[0].data = [dataHandle(newData)];
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(B), {
        theme: __props.themeColor,
        "init-options": unref(initOptions),
        option: option.value,
        autoresize: ""
      }, null, 8, ["theme", "init-options", "option"]);
    };
  }
});
export {
  _sfc_main as default
};
