import { defineStore } from "pinia";
import { ChartModeEnum, LayerModeEnum } from "./chartLayoutStore.d.mjs";
import "../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.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 "../../../../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 "../../../enums/pageEnum.mjs";
import { StorageEnum } from "../../../enums/storageEnum.mjs";
import { getLocalStorage, setLocalStorage } from "../../../utils/storage.mjs";
import "../../../router/index.mjs";
import "../designStore/designStore.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 { useChartEditStore } from "../chartEditStore/chartEditStore.mjs";
const chartEditStore = useChartEditStore();
const { GO_CHART_LAYOUT_STORE } = StorageEnum;
const storageChartLayout = getLocalStorage(GO_CHART_LAYOUT_STORE);
const useChartLayoutStore = defineStore({
  id: "useChartLayoutStore",
  state: () => ({
    // 图层控制
    layers: true,
    // 图表组件
    charts: true,
    // 详情设置（收缩为true）
    details: false,
    // 组件列表展示类型（默认单列）
    chartType: ChartModeEnum.SINGLE,
    // 图层类型（默认图片）
    layerType: LayerModeEnum.THUMBNAIL,
    // 当前加载数量
    percentage: 0,
    // 是否重置当前画布位置
    rePositionCanvas: false,
    // 防止值不存在
    ...storageChartLayout
  }),
  getters: {
    getLayers() {
      return this.layers;
    },
    getCharts() {
      return this.charts;
    },
    getDetails() {
      return this.details;
    },
    getChartType() {
      return this.chartType;
    },
    getLayerType() {
      return this.layerType;
    },
    getPercentage() {
      return this.percentage;
    },
    getRePositionCanvas() {
      return this.rePositionCanvas;
    }
  },
  actions: {
    setItem(key, value, computedScale = true) {
      this.$patch((state) => {
        state[key] = value;
      });
      setLocalStorage(GO_CHART_LAYOUT_STORE, this.$state);
      this.rePositionCanvas = true;
      if (computedScale) {
        setTimeout(() => {
          chartEditStore.computedScale();
        }, 500);
      }
    },
    setItemUnHandle(key, value) {
      this.$patch((state) => {
        state[key] = value;
      });
    }
  }
});
export {
  useChartLayoutStore
};
