import { defineComponent as P, shallowRef as v, createVNode as t, Fragment as B, resolveComponent as u, isVNode as h } from "vue";
import { ElIcon as V } from "element-plus";
import { useResolveVnode as m, useReloadCompNode as w } from "@klweb/compose-app-engine";
import { u as x, H as R, i as S, I as C, J as k, K as g, L as G, d as M, e as U, M as _, N as z, O as H, P as O, Q as T, R as j, B as D, S as K, U as A, V as E } from "./main-Blxobku2.js";
import { e as F } from "./index-BbdVezoQ.js";
const {
  IconSelectParent: L,
  IconCancelSelect: J,
  IconSelectPrev: Q,
  IconSelectNext: q,
  IconAddComp: W,
  IconVisible: X,
  IconHidden: Y,
  IconCopy: Z,
  IconPastePrev: $,
  IconPasteInner: ee,
  IconPasteNext: oe,
  IconRefresh: de,
  IconAgain: se,
  IconEditMetadata: ae,
  IconUp: te,
  IconDown: le,
  IconDel: ne
} = F;
function r(o) {
  return typeof o == "function" || Object.prototype.toString.call(o) === "[object Object]" && !h(o);
}
const Ce = /* @__PURE__ */ P({
  name: "KlCompContextMenu",
  components: {
    ElIcon: V
  },
  props: {
    index: {
      type: Number,
      default: 0
    },
    compNode: {
      type: Object,
      default: () => ({})
    }
  },
  setup(o) {
    const c = {
      useCreateRootCompPickView: C,
      useGetParentCompNodeById: k,
      useGetPrevCompNodeById: g,
      useGetNextCompNodeById: G,
      usePrevSortCompNodeById: M,
      useNextSortCompNodeById: U,
      useShowCompNode: _,
      useHideCompNode: z,
      useReloadCompNode: w,
      useCopyCompNodeById: H,
      usePasteCompNode: O,
      usePasteCompNodeToPrevCompNode: T,
      usePasteCompNodeToNextCompNode: j,
      useRemoveCompNodeById: D
    }, d = o.compNode.type === "page", p = o.compNode.type === "component", n = o.compNode.isVisible, l = x(o.compNode.compId), i = R(), N = v([{
      label: "选择父级组件",
      icon: L,
      fn: "useGetParentCompNodeById",
      disabled: !!d
    }, {
      label: "取消选中",
      icon: J,
      fn: "useCreateRootCompPickView",
      disabled: !!d
    }, {
      label: "选择前一个组件",
      icon: Q,
      fn: "useGetPrevCompNodeById",
      disabled: !!["one", "first"].includes(l)
    }, {
      label: "选择后一个组件",
      icon: q,
      fn: "useGetNextCompNodeById",
      disabled: !!["one", "last"].includes(l)
    }, {
      divided: !0
    }, {
      label: "向前移动",
      icon: te,
      size: 16,
      fn: "usePrevSortCompNodeById",
      disabled: !!["one", "first"].includes(l)
    }, {
      label: "向后移动",
      icon: le,
      size: 16,
      fn: "useNextSortCompNodeById",
      disabled: !!["one", "last"].includes(l)
    }, {
      label: "插入组件",
      icon: W,
      fn: "handleViewCompRepository",
      disabled: !!p
    }, {
      label: n ? "隐藏组件" : "显示组件",
      icon: n ? Y : X,
      fn: n ? "useHideCompNode" : "useShowCompNode",
      disabled: !1
    }, {
      divided: !0
    }, {
      label: "刷新当前页面",
      icon: de,
      fn: "handleUpdatePageCanvas",
      disabled: !1
    }, {
      label: "重新渲染组件",
      icon: se,
      fn: "useReloadCompNode",
      disabled: !1
    }, {
      label: "查看/编辑组件元数据",
      icon: ae,
      fn: "handleViewCompMetadata",
      disabled: !1
    }, {
      divided: !0
    }, {
      label: "复制",
      icon: Z,
      fn: "useCopyCompNodeById",
      disabled: !!d
    }, {
      label: "粘贴至前面",
      icon: $,
      fn: "usePasteCompNodeToPrevCompNode",
      disabled: !!(!i || d)
    }, {
      label: "粘贴至内部",
      icon: ee,
      fn: "usePasteCompNode",
      disabled: !!(!i || p)
    }, {
      label: "粘贴至后面",
      icon: oe,
      fn: "usePasteCompNodeToNextCompNode",
      disabled: !!(!i || d)
    }, {
      label: "删除",
      icon: ne,
      fn: "useRemoveCompNodeById",
      disabled: !!d
    }]), f = () => {
      K(o.compNode);
    }, b = () => {
      A.value = String(Date.now()), setTimeout(() => {
        C();
      }, 10);
    }, I = () => {
      E(o.compNode);
    }, y = (e, s) => {
      if (e === "handleViewCompMetadata")
        f();
      else if (e === "handleUpdatePageCanvas")
        b();
      else if (e === "handleViewCompRepository")
        I();
      else if (["useGetParentCompNodeById", "useGetPrevCompNodeById", "useGetNextCompNodeById"].includes(e)) {
        const a = c[e](s);
        a && S(a.compId);
      } else
        c[e](s);
    };
    return () => t(B, null, [N.value.map((e) => {
      let s, a;
      return e.divided ? t("li", {
        class: "divided"
      }, null) : e.disabled ? t("li", {
        class: "disabled"
      }, [t(u("el-icon"), {
        size: e.size
      }, r(s = m(e.icon)) ? s : {
        default: () => [s]
      }), e.label]) : t("li", {
        onClick: () => y(e.fn, o.compNode.compId)
      }, [t(u("el-icon"), {
        size: e.size
      }, r(a = m(e.icon)) ? a : {
        default: () => [a]
      }), e.label]);
    })]);
  }
});
export {
  Ce as default
};
