import "../../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.mjs";
import { setTitle } from "../../../../utils/utils.mjs";
import "../../../../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.mjs";
import { fetchRouteParamsLocation } from "../../../../utils/router.mjs";
import "../../../../store/modules/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 { icon } from "../../../../plugins/icon.mjs";
import "../../../../settings/designSetting.mjs";
import { useChartEditStore } from "../../../../store/modules/chartEditStore/chartEditStore.mjs";
import { EditCanvasConfigEnum } from "../../../../store/modules/chartEditStore/chartEditStore.d.mjs";
import { vShow, withKeys } from "../../../../../node_modules/.pnpm/@vue_runtime-dom@3.3.4/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.mjs";
import { defineComponent, computed, resolveComponent, openBlock, createBlock, withCtx, createVNode, createTextVNode, withDirectives, createElementVNode as createBaseVNode, nextTick } from "../../../../../node_modules/.pnpm/@vue_runtime-core@3.3.4/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.mjs";
import { ref, unref } from "../../../../../node_modules/.pnpm/@vue_reactivity@3.3.4/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.mjs";
import { toDisplayString } from "../../../../../node_modules/.pnpm/@vue_shared@3.3.4/node_modules/@vue/shared/dist/shared.esm-bundler.mjs";
const _hoisted_1 = { class: "title" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  setup(__props) {
    const { FishIcon } = icon.ionicons5;
    const chartEditStore = useChartEditStore();
    const focus = ref(false);
    const inputInstRef = ref(null);
    const fetchProhectInfoById = () => {
      const id = fetchRouteParamsLocation();
      if (id.length) {
        return id[0];
      }
      return "";
    };
    const title = ref(fetchProhectInfoById() || "");
    const comTitle = computed(() => {
      title.value = title.value.replace(/\s/g, "");
      const newTitle = title.value.length ? title.value : "新项目";
      setTitle(`工作空间-${newTitle}`);
      chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.PROJECT_NAME, newTitle);
      return newTitle;
    });
    const handleFocus = () => {
      focus.value = true;
      nextTick(() => {
        inputInstRef.value && inputInstRef.value.focus();
      });
    };
    const handleBlur = () => {
      focus.value = false;
    };
    return (_ctx, _cache) => {
      const _component_n_icon = resolveComponent("n-icon");
      const _component_n_button = resolveComponent("n-button");
      const _component_n_text = resolveComponent("n-text");
      const _component_n_input = resolveComponent("n-input");
      const _component_n_space = resolveComponent("n-space");
      return openBlock(), createBlock(_component_n_space, null, {
        default: withCtx(() => [
          createVNode(_component_n_icon, {
            size: "20",
            depth: 3
          }, {
            default: withCtx(() => [
              createVNode(unref(FishIcon))
            ]),
            _: 1
          }),
          createVNode(_component_n_text, { onClick: handleFocus }, {
            default: withCtx(() => [
              createTextVNode(" 工作空间 - "),
              withDirectives(createVNode(_component_n_button, {
                secondary: "",
                size: "tiny"
              }, {
                default: withCtx(() => [
                  createBaseVNode("span", _hoisted_1, toDisplayString(comTitle.value), 1)
                ]),
                _: 1
              }, 512), [
                [vShow, !focus.value]
              ])
            ]),
            _: 1
          }),
          withDirectives(createVNode(_component_n_input, {
            ref_key: "inputInstRef",
            ref: inputInstRef,
            size: "small",
            type: "text",
            maxlength: "16",
            "show-count": "",
            placeholder: "请输入项目名称",
            value: title.value,
            "onUpdate:value": _cache[0] || (_cache[0] = ($event) => title.value = $event),
            valueModifiers: { trim: true },
            onKeyup: withKeys(handleBlur, ["enter"]),
            onBlur: handleBlur
          }, null, 8, ["value", "onKeyup"]), [
            [vShow, focus.value]
          ])
        ]),
        _: 1
      });
    };
  }
});
export {
  _sfc_main as default
};
