"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.js");
const index = require("../../../../../../node_modules/.pnpm/@amap_amap-jsapi-loader@1.0.1/node_modules/@amap/amap-jsapi-loader/dist/index.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");
const type = require("../../../../../utils/type.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");
require("../../../../../enums/pageEnum.js");
require("../../../../../router/index.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 chartEditStore = require("../../../../../store/modules/chartEditStore/chartEditStore.js");
const config = require("./config.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 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: {
    chartConfig: {
      type: Object,
      required: true
    }
  },
  setup(__props) {
    const props = __props;
    let {
      amapKey,
      amapStyleKey,
      amapLon,
      amapLat,
      amapZindex,
      mapMarkerType,
      lang,
      amapStyleKeyCustom,
      features,
      viewMode,
      pitch,
      skyColor,
      marker
    } = reactivity_esmBundler.toRefs(props.chartConfig.option.mapOptions);
    let mapIns = null;
    let markers = [];
    let AMapIns = null;
    const vChartRef = reactivity_esmBundler.ref();
    const initMap = (newData) => {
      index.default.load({
        key: amapKey.value,
        //api服务key--另外需要在public中使用安全密钥！！！
        version: "1.4.8",
        // 指定要加载的 JSAPI 的版本，缺省时默认为 1.4.15
        plugins: ["AMap.PlaceSearch", "AMap.AutoComplete"]
        // 需要使用的的插件列表
      }).then((AMap) => {
        AMapIns = AMap;
        mapIns = new AMap.Map(vChartRef.value, {
          resizeEnable: true,
          zoom: amapZindex.value,
          // 地图显示的缩放级别
          center: [amapLon.value, amapLat.value],
          lang: lang.value,
          features: features.value,
          pitch: pitch.value,
          // 地图俯仰角度，有效范围 0 度- 83 度
          skyColor: skyColor.value,
          viewMode: viewMode.value,
          // 地图模式
          willReadFrequently: true
        });
        dataHandle(props.chartConfig.option.dataset);
        let satellite = new AMap.TileLayer.Satellite();
        let roadNet = new AMap.TileLayer.RoadNet();
        if (newData.amapStyleKey === config.ThemeEnum.WEIXIN) {
          mapIns.add([satellite, roadNet]);
        } else {
          mapIns.remove([satellite, roadNet]);
          mapIns.setMapStyle(`amap://styles/${amapStyleKeyCustom.value !== "" ? amapStyleKeyCustom.value : amapStyleKey.value}`);
        }
      }).catch((e) => {
      });
    };
    const dataHandle = (newData) => {
      if (!mapIns && !AMapIns) {
        initMap(props.chartConfig.option);
        return;
      }
      if (type.isArray(newData.markers)) {
        mapIns.remove(markers);
        markers = [];
        if (mapMarkerType.value === config.MarkerEnum.MARKER) {
          newData.markers.forEach((markerItem) => {
            const markerInstance = new AMapIns.Marker({
              position: [markerItem.position[0], markerItem.position[1]],
              offset: new AMapIns.Pixel(-13, -30)
            });
            markers.push(markerInstance);
            markerInstance.setMap(mapIns);
          });
        } else if (mapMarkerType.value === config.MarkerEnum.CIRCLE_MARKER) {
          newData.markers.forEach((markerItem) => {
            const markerInstance = new AMapIns.CircleMarker({
              center: [markerItem.position[0], markerItem.position[1]],
              radius: markerItem.value,
              ...marker.value
            });
            markers.push(markerInstance);
            markerInstance.setMap(mapIns);
          });
        }
      }
    };
    const stopWatch = runtimeCore_esmBundler.watch(
      () => props.chartConfig.option.mapOptions,
      (option) => {
        initMap(option);
      },
      {
        immediate: true,
        deep: true
      }
    );
    runtimeCore_esmBundler.watch(
      () => props.chartConfig.option.dataset,
      (newData) => {
        try {
          dataHandle(newData);
        } catch (error) {
          console.log(error);
        }
      },
      {
        deep: false
      }
    );
    useChartDataFetch_hook.useChartDataFetch(props.chartConfig, chartEditStore.useChartEditStore, (newData) => {
      stopWatch();
      dataHandle(newData);
    });
    return (_ctx, _cache) => {
      return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", {
        ref_key: "vChartRef",
        ref: vChartRef
      }, null, 512);
    };
  }
});
exports.default = _sfc_main;
