import "../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.mjs";
import { MenuEnum } from "../../../enums/editPageEnum.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 "../../../router/index.mjs";
import { colorCustomMerge, getFilterStyle, getBlendModeStyle, animationsClass, getTransformStyle } 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 { useContextMenu } from "../hooks/useContextMenu.hook.mjs";
import { useChartEditStore } from "../../../store/modules/chartEditStore/chartEditStore.mjs";
import { SCALE_KEY } from "../../preview/hooks/useScale.hook.mjs";
import { useLayout } from "./hooks/useLayout.hook.mjs";
import { useAddKeyboard } from "../hooks/useKeyboard.hook.mjs";
import { mousedownHandleUnStop, dragHandle, dragoverHandle, useMouseHandle } from "./hooks/useDrag.hook.mjs";
import { useComponentStyle, useSizeStyle } from "./hooks/useStyle.hook.mjs";
import ContentBox from "../ContentBox/index.vue.mjs";
import _sfc_main$1 from "./components/EditGroup/index.vue.mjs";
import EditRange from "./components/EditRange/index.vue.mjs";
import EditRule from "./components/EditRule/index.vue.mjs";
import EditShapeBox from "./components/EditShapeBox/index.vue.mjs";
import { defineComponent, provide, computed, onMounted, openBlock, createBlock, withCtx, createVNode, createElementVNode as createBaseVNode, createElementBlock, Fragment, renderList, resolveDynamicComponent } from "../../../../node_modules/.pnpm/@vue_runtime-core@3.3.4/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.mjs";
import { unref } from "../../../../node_modules/.pnpm/@vue_reactivity@3.3.4/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.mjs";
import { normalizeStyle, normalizeClass } from "../../../../node_modules/.pnpm/@vue_shared@3.3.4/node_modules/@vue/shared/dist/shared.esm-bundler.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  setup(__props) {
    const chartEditStore = useChartEditStore();
    const { handleContextMenu } = useContextMenu();
    provide(SCALE_KEY, null);
    useLayout(async () => {
    });
    const { mouseenterHandle, mouseleaveHandle, mousedownHandle, mouseClickHandle } = useMouseHandle();
    const optionsHandle = (targetList, allList, targetInstance) => {
      if (chartEditStore.getTargetChart.selectId.length > 1) {
        return allList.filter((i) => [MenuEnum.GROUP, MenuEnum.DELETE].includes(i.key));
      }
      const statusMenuEnums = [];
      if (targetInstance.status.lock) {
        statusMenuEnums.push(MenuEnum.LOCK);
      } else {
        statusMenuEnums.push(MenuEnum.UNLOCK);
      }
      if (targetInstance.status.hide) {
        statusMenuEnums.push(MenuEnum.HIDE);
      } else {
        statusMenuEnums.push(MenuEnum.SHOW);
      }
      return targetList.filter((i) => !statusMenuEnums.includes(i.key));
    };
    const themeSetting = computed(() => {
      const chartThemeSetting = chartEditStore.getEditCanvasConfig.chartThemeSetting;
      return chartThemeSetting;
    });
    const themeColor = computed(() => {
      const colorCustomMergeData = colorCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo);
      return colorCustomMergeData[chartEditStore.getEditCanvasConfig.chartThemeColor];
    });
    computed(() => {
      return chartEditStore.getEditCanvasConfig.filterShow;
    });
    const rangeStyle = computed(() => {
      const background = chartEditStore.getEditCanvasConfig.background;
      const backgroundImage = chartEditStore.getEditCanvasConfig.backgroundImage;
      const selectColor = chartEditStore.getEditCanvasConfig.selectColor;
      const backgroundColor = background ? background : void 0;
      const computedBackground = selectColor ? { background: backgroundColor } : { background: `url(${backgroundImage}) no-repeat center center / cover !important` };
      return {
        ...computedBackground,
        width: "inherit",
        height: "inherit"
      };
    });
    onMounted(() => {
      useAddKeyboard();
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(ContentBox), {
        id: "go-chart-edit-layout",
        flex: true,
        showTop: false,
        showBottom: true,
        depth: 1,
        xScroll: true,
        disabledScroll: true,
        onMousedown: unref(mousedownHandleUnStop),
        onDrop: unref(dragHandle),
        onDragover: unref(dragoverHandle),
        onDragenter: unref(dragoverHandle)
      }, {
        aside: withCtx(() => []),
        bottom: withCtx(() => []),
        default: withCtx(() => [
          createVNode(unref(EditRule), null, {
            default: withCtx(() => [
              createBaseVNode("div", {
                id: "go-chart-edit-content",
                onContextmenu: _cache[0] || (_cache[0] = //@ts-ignore
                (...args) => unref(handleContextMenu) && unref(handleContextMenu)(...args))
              }, [
                createVNode(unref(EditRange), null, {
                  default: withCtx(() => [
                    createBaseVNode("div", {
                      style: normalizeStyle({
                        ...unref(getFilterStyle)(unref(chartEditStore).getEditCanvasConfig),
                        ...rangeStyle.value
                      })
                    }, [
                      (openBlock(true), createElementBlock(Fragment, null, renderList(unref(chartEditStore).getComponentList, (item, index) => {
                        return openBlock(), createElementBlock("div", {
                          key: item.id
                        }, [
                          item.isGroup ? (openBlock(), createBlock(unref(_sfc_main$1), {
                            key: 0,
                            groupData: item,
                            groupIndex: index
                          }, null, 8, ["groupData", "groupIndex"])) : (openBlock(), createBlock(unref(EditShapeBox), {
                            key: 1,
                            "data-id": item.id,
                            index,
                            style: normalizeStyle({
                              ...unref(useComponentStyle)(item.attr, index),
                              ...unref(getBlendModeStyle)(item.styles)
                            }),
                            item,
                            onClick: ($event) => unref(mouseClickHandle)($event, item),
                            onMousedown: ($event) => unref(mousedownHandle)($event, item),
                            onMouseenter: ($event) => unref(mouseenterHandle)($event, item),
                            onMouseleave: ($event) => unref(mouseleaveHandle)($event, item),
                            onContextmenu: ($event) => unref(handleContextMenu)($event, item, optionsHandle)
                          }, {
                            default: withCtx(() => [
                              (openBlock(), createBlock(resolveDynamicComponent(item.chartConfig.chartKey), {
                                class: normalizeClass(["edit-content-chart", unref(animationsClass)(item.styles.animations)]),
                                chartConfig: item,
                                themeSetting: themeSetting.value,
                                themeColor: themeColor.value,
                                style: normalizeStyle({
                                  ...unref(useSizeStyle)(item.attr),
                                  ...unref(getFilterStyle)(item.styles),
                                  ...unref(getTransformStyle)(item.styles)
                                })
                              }, null, 8, ["class", "chartConfig", "themeSetting", "themeColor", "style"]))
                            ]),
                            _: 2
                          }, 1032, ["data-id", "index", "style", "item", "onClick", "onMousedown", "onMouseenter", "onMouseleave", "onContextmenu"]))
                        ]);
                      }), 128))
                    ], 4)
                  ]),
                  _: 1
                })
              ], 32)
            ]),
            _: 1
          })
        ]),
        _: 1
      }, 8, ["onMousedown", "onDrop", "onDragover", "onDragenter"]);
    };
  }
});
export {
  _sfc_main as default
};
