import "../../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.mjs";
import { renderIcon } from "../../../../utils/utils.mjs";
import "../../../../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.mjs";
import { fetchPathByName, routerTurnByPath } from "../../../../utils/router.mjs";
import { getLocalStorage, setSessionStorage } from "../../../../utils/storage.mjs";
import "../../../../store/modules/designStore/designStore.mjs";
import { goDialog } from "../../../../utils/plugin.mjs";
import "../../../../components/GoLoading/index.mjs";
import { PreviewEnum } from "../../../../enums/pageEnum.mjs";
import { StorageEnum } from "../../../../enums/storageEnum.mjs";
import { useRoute } from "../../../../../node_modules/.pnpm/vue-router@4.0.12_vue@3.3.4/node_modules/vue-router/dist/vue-router.esm-bundler.mjs";
import { useChartEditStore } from "../../../../store/modules/chartEditStore/chartEditStore.mjs";
import { syncData } from "../../ContentEdit/components/EditTools/hooks/useSyncUpdate.hook.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 { icon } from "../../../../plugins/icon.mjs";
import { l as lodashExports } from "../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.mjs";
import { defineComponent, computed, resolveComponent, openBlock, createBlock, withCtx, createElementBlock, Fragment, renderList, resolveDynamicComponent, createElementVNode as createBaseVNode } from "../../../../../node_modules/.pnpm/@vue_runtime-core@3.3.4/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.mjs";
import { toDisplayString } 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 { BrowsersOutlineIcon, SendIcon, AnalyticsIcon } = icon.ionicons5;
    const chartEditStore = useChartEditStore();
    const routerParamsInfo = useRoute();
    const previewHandle = () => {
      const path = fetchPathByName(PreviewEnum.CHART_PREVIEW_NAME, "href");
      if (!path)
        return;
      const { id } = routerParamsInfo.params;
      const previewId = typeof id === "string" ? id : id[0];
      const storageInfo = chartEditStore.getStorageInfo;
      const sessionStorageInfo = getLocalStorage(StorageEnum.GO_CHART_STORAGE_LIST) || [];
      if (sessionStorageInfo == null ? void 0 : sessionStorageInfo.length) {
        const repeateIndex = sessionStorageInfo.findIndex((e) => e.id === previewId);
        if (repeateIndex !== -1) {
          sessionStorageInfo.splice(repeateIndex, 1, { id: previewId, ...storageInfo });
          setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo);
        } else {
          sessionStorageInfo.push({
            id: previewId,
            ...storageInfo
          });
          setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo);
        }
      } else {
        setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [{ id: previewId, ...storageInfo }]);
      }
      routerTurnByPath(path, [previewId], void 0, true);
    };
    const sendHandle = () => {
      goDialog({
        message: "保存当前设计，需要表单提交相关信息",
        positiveText: "了然",
        closeNegativeText: true,
        onPositiveCallback: () => {
        }
      });
    };
    const btnList = [
      {
        select: true,
        title: "同步内容",
        type: "primary",
        icon: renderIcon(AnalyticsIcon),
        event: syncData
      },
      {
        select: true,
        title: "预览",
        icon: renderIcon(BrowsersOutlineIcon),
        event: previewHandle
      },
      {
        select: true,
        title: "保存",
        icon: renderIcon(SendIcon),
        event: sendHandle
      }
    ];
    const comBtnList = computed(() => {
      if (chartEditStore.getEditCanvas.isCodeEdit) {
        return btnList;
      }
      const cloneList = lodashExports.cloneDeep(btnList);
      cloneList.shift();
      return cloneList;
    });
    return (_ctx, _cache) => {
      const _component_n_button = resolveComponent("n-button");
      const _component_n_space = resolveComponent("n-space");
      return openBlock(), createBlock(_component_n_space, { class: "go-mt-0" }, {
        default: withCtx(() => [
          (openBlock(true), createElementBlock(Fragment, null, renderList(comBtnList.value, (item, index) => {
            return openBlock(), createBlock(_component_n_button, {
              key: item.title,
              type: item.type,
              ghost: "",
              onClick: item.event
            }, {
              icon: withCtx(() => [
                (openBlock(), createBlock(resolveDynamicComponent(item.icon)))
              ]),
              default: withCtx(() => [
                createBaseVNode("span", null, toDisplayString(item.title), 1)
              ]),
              _: 2
            }, 1032, ["type", "onClick"]);
          }), 128))
        ]),
        _: 1
      });
    };
  }
});
export {
  _sfc_main as default
};
