"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const dynamicImportHelper = require("../../../../../../_virtual/dynamic-import-helper.js");
require("../../../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.js");
const config = require("./config.js");
const index_esm_min = require("../../../../../../node_modules/.pnpm/vue-echarts@6.6.1_echarts@5.4.3_vue@3.3.4/node_modules/vue-echarts/dist/index.esm.min.js");
const useCanvasInitOptions_hook = require("../../../../../hooks/useCanvasInitOptions.hook.js");
require("../../../../../store/modules/designStore/designStore.js");
require("../../../../../settings/designSetting.js");
require("../../../../../../node_modules/.pnpm/screenfull@6.0.2/node_modules/screenfull/index.js");
require("../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_root.js");
require("../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGetTag.js");
require("../../../../../../node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.js");
require("../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseClone.js");
require("../../../../../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.js");
const router = require("../../../../../utils/router.js");
require("../../../../../../node_modules/.pnpm/vue3-lazyload@0.2.5-beta_a6dezdz3je235ci4e3tu4rayna/node_modules/vue3-lazyload/dist/vue3-lazyload.esm.js");
require("../../../../../components/GoSkeleton/index.vue.js");
require("../../../../../components/GoLoading/index.js");
const useChartDataFetch_hook = require("../../../../../hooks/useChartDataFetch.hook.js");
require("../../../../../api/axios.js");
require("../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/index.js");
require("../../../../../store/modules/langStore/langStore.js");
const chart = require("../../../../public/chart.js");
const chartEditStore = require("../../../../../store/modules/chartEditStore/chartEditStore.js");
const mapWithoutHainanIsLands = require("./mapWithoutHainanIsLands.json.js");
const install = require("../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/chart/map/install.js");
const install$4 = require("../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/geo/install.js");
const install$5 = require("../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/chart/effectScatter/install.js");
const install$6 = require("../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/visualMap/install.js");
const echarts = require("../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/core/echarts.js");
const runtimeCore_esmBundler = require("../../../../../../node_modules/.pnpm/@vue_runtime-core@3.3.4/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js");
const extension = require("../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/extension.js");
const install$1 = require("../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/dataset/install.js");
const installCanvasRenderer = require("../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/renderer/installCanvasRenderer.js");
const install$2 = require("../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/grid/install.js");
const install$3 = require("../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/tooltip/install.js");
const reactivity_esmBundler = require("../../../../../../node_modules/.pnpm/@vue_reactivity@3.3.4/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js");
const _sfc_main = /* @__PURE__ */ runtimeCore_esmBundler.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_hook.useCanvasInitOptions(props.chartConfig.option, props.themeSetting);
    extension.use([
      install.install,
      install$1.install,
      installCanvasRenderer.install,
      install$2.install,
      install$3.install,
      install$4.install,
      install$5.install,
      install$6.install
    ]);
    const option = reactivity_esmBundler.reactive({
      value: chart.mergeTheme(props.chartConfig.option, props.themeSetting, config.includes)
    });
    const vChartRef = reactivity_esmBundler.ref();
    const getGeojson = (regionId) => {
      return new Promise((resolve) => {
        dynamicImportHelper.default(/* @__PURE__ */ Object.assign({ "./mapGeojson/110000.json": () => Promise.resolve().then(() => require("./mapGeojson/110000.json.js")), "./mapGeojson/120000.json": () => Promise.resolve().then(() => require("./mapGeojson/120000.json.js")), "./mapGeojson/130000.json": () => Promise.resolve().then(() => require("./mapGeojson/130000.json.js")), "./mapGeojson/140000.json": () => Promise.resolve().then(() => require("./mapGeojson/140000.json.js")), "./mapGeojson/150000.json": () => Promise.resolve().then(() => require("./mapGeojson/150000.json.js")), "./mapGeojson/210000.json": () => Promise.resolve().then(() => require("./mapGeojson/210000.json.js")), "./mapGeojson/220000.json": () => Promise.resolve().then(() => require("./mapGeojson/220000.json.js")), "./mapGeojson/230000.json": () => Promise.resolve().then(() => require("./mapGeojson/230000.json.js")), "./mapGeojson/310000.json": () => Promise.resolve().then(() => require("./mapGeojson/310000.json.js")), "./mapGeojson/320000.json": () => Promise.resolve().then(() => require("./mapGeojson/320000.json.js")), "./mapGeojson/330000.json": () => Promise.resolve().then(() => require("./mapGeojson/330000.json.js")), "./mapGeojson/340000.json": () => Promise.resolve().then(() => require("./mapGeojson/340000.json.js")), "./mapGeojson/350000.json": () => Promise.resolve().then(() => require("./mapGeojson/350000.json.js")), "./mapGeojson/360000.json": () => Promise.resolve().then(() => require("./mapGeojson/360000.json.js")), "./mapGeojson/370000.json": () => Promise.resolve().then(() => require("./mapGeojson/370000.json.js")), "./mapGeojson/410000.json": () => Promise.resolve().then(() => require("./mapGeojson/410000.json.js")), "./mapGeojson/420000.json": () => Promise.resolve().then(() => require("./mapGeojson/420000.json.js")), "./mapGeojson/430000.json": () => Promise.resolve().then(() => require("./mapGeojson/430000.json.js")), "./mapGeojson/440000.json": () => Promise.resolve().then(() => require("./mapGeojson/440000.json.js")), "./mapGeojson/450000.json": () => Promise.resolve().then(() => require("./mapGeojson/450000.json.js")), "./mapGeojson/460000.json": () => Promise.resolve().then(() => require("./mapGeojson/460000.json.js")), "./mapGeojson/500000.json": () => Promise.resolve().then(() => require("./mapGeojson/500000.json.js")), "./mapGeojson/510000.json": () => Promise.resolve().then(() => require("./mapGeojson/510000.json.js")), "./mapGeojson/520000.json": () => Promise.resolve().then(() => require("./mapGeojson/520000.json.js")), "./mapGeojson/530000.json": () => Promise.resolve().then(() => require("./mapGeojson/530000.json.js")), "./mapGeojson/540000.json": () => Promise.resolve().then(() => require("./mapGeojson/540000.json.js")), "./mapGeojson/610000.json": () => Promise.resolve().then(() => require("./mapGeojson/610000.json.js")), "./mapGeojson/620000.json": () => Promise.resolve().then(() => require("./mapGeojson/620000.json.js")), "./mapGeojson/630000.json": () => Promise.resolve().then(() => require("./mapGeojson/630000.json.js")), "./mapGeojson/640000.json": () => Promise.resolve().then(() => require("./mapGeojson/640000.json.js")), "./mapGeojson/650000.json": () => Promise.resolve().then(() => require("./mapGeojson/650000.json.js")), "./mapGeojson/710000.json": () => Promise.resolve().then(() => require("./mapGeojson/710000.json.js")), "./mapGeojson/810000.json": () => Promise.resolve().then(() => require("./mapGeojson/810000.json.js")), "./mapGeojson/820000.json": () => Promise.resolve().then(() => require("./mapGeojson/820000.json.js")), "./mapGeojson/china.json": () => Promise.resolve().then(() => require("./mapGeojson/china.json.js")), "./mapGeojson/empty.json": () => Promise.resolve().then(() => require("./mapGeojson/empty.json.js")) }), `./mapGeojson/${regionId}.json`).then((data) => {
          echarts.registerMap(regionId, { geoJSON: data.default, specialAreas: {} });
          resolve(true);
        });
      });
    };
    echarts.registerMap(`${props.chartConfig.option.mapRegion.adcode}`, { geoJSON: {}, specialAreas: {} });
    const registerMapInitAsync = async () => {
      await runtimeCore_esmBundler.nextTick();
      const adCode = `${props.chartConfig.option.mapRegion.adcode}`;
      if (adCode !== "china") {
        await getGeojson(adCode);
      } else {
        await hainanLandsHandle(props.chartConfig.option.mapRegion.showHainanIsLands);
      }
      vEchartsSetOption();
    };
    registerMapInitAsync();
    const vEchartsSetOption = () => {
      option.value = props.chartConfig.option;
      chart.setOption(vChartRef.value, props.chartConfig.option);
    };
    const dataSetHandle = async (dataset) => {
      props.chartConfig.option.series.forEach((item) => {
        if (item.type === "effectScatter" && dataset.point)
          item.data = dataset.point;
        else if (item.type === "map" && dataset.map)
          item.data = dataset.map;
      });
      if (dataset.pieces)
        props.chartConfig.option.visualMap.pieces = dataset.pieces;
      router.isPreview() && vEchartsSetOption();
    };
    const hainanLandsHandle = async (newData) => {
      if (newData) {
        await getGeojson("china");
      } else {
        echarts.registerMap("china", { geoJSON: mapWithoutHainanIsLands.default, specialAreas: {} });
      }
    };
    runtimeCore_esmBundler.watch(
      () => props.chartConfig.option.dataset,
      (newData) => {
        dataSetHandle(newData);
      },
      {
        immediate: true,
        deep: false
      }
    );
    runtimeCore_esmBundler.watch(
      () => props.chartConfig.option.mapRegion.showHainanIsLands,
      async (newData) => {
        try {
          await hainanLandsHandle(newData);
          vEchartsSetOption();
        } catch (error) {
          console.log(error);
        }
      },
      {
        deep: false
      }
    );
    runtimeCore_esmBundler.watch(
      () => `${props.chartConfig.option.mapRegion.adcode}`,
      async (newData) => {
        try {
          await getGeojson(newData);
          props.chartConfig.option.geo.map = newData;
          props.chartConfig.option.series.forEach((item) => {
            if (item.type === "map")
              item.map = newData;
          });
          vEchartsSetOption();
        } catch (error) {
          console.log(error);
        }
      },
      {
        deep: false
      }
    );
    useChartDataFetch_hook.useChartDataFetch(props.chartConfig, chartEditStore.useChartEditStore, (newData) => {
      dataSetHandle(newData);
    });
    return (_ctx, _cache) => {
      return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(reactivity_esmBundler.unref(index_esm_min.default), {
        ref_key: "vChartRef",
        ref: vChartRef,
        "init-options": reactivity_esmBundler.unref(initOptions),
        theme: __props.themeColor,
        option: option.value,
        "manual-update": reactivity_esmBundler.unref(router.isPreview)(),
        autoresize: ""
      }, null, 8, ["init-options", "theme", "option", "manual-update"]);
    };
  }
});
exports.default = _sfc_main;
