import { defineComponent as w, reactive as S, resolveComponent as k, openBlock as l, createElementBlock as u, Fragment as E, renderList as L, normalizeClass as _, createVNode as g, withCtx as O, createElementVNode as o, createCommentVNode as I, toDisplayString as D, createBlock as J, withDirectives as b, vShow as F, ref as R, onMounted as T, nextTick as f, renderSlot as V } from "vue";
import { C as d } from "../Shared/base-PQGakkrl.js";
const q = {
  key: 0,
  class: "sideNav-menu-iconOperate"
}, z = /* @__PURE__ */ w({
  name: "ClSidemenuMenu",
  __name: "Menu",
  props: {
    activeId: {
      type: String,
      default: ""
    },
    activePId: {
      type: Array,
      default: () => []
    },
    openId: {
      type: Array,
      default: () => []
    },
    list: {
      type: Array,
      default: () => []
    }
  },
  emits: ["onClick"],
  setup(i, { emit: y }) {
    const r = y, M = S({
      keyIndex: `DhhReportAnalysis-${d.getRandom(8)}`
    }), e = (a) => {
      r("onClick", a);
    };
    return (a, A) => {
      const m = k("cl-link"), v = k("cl-sidemenu-menu"), C = k("cl-transition-slideupdown");
      return l(), u("ul", null, [
        (l(!0), u(E, null, L(i.list, (n) => (l(), u("li", {
          key: `${M.keyIndex}-${n.id}`,
          class: _({
            "sideNav-menu-submenu": n.list && n.list.length > 0,
            "sideNav-menu-active": !(n.list && n.list.length > 0) && i.activeId === n.id,
            "sideNav-menu-parent-active": n.list && n.list.length > 0 && i.activePId.includes(n.id)
          })
        }, [
          g(m, {
            isWaves: !0,
            onOnClick: (x) => e(n)
          }, {
            default: O(() => [
              n.list && n.list.length > 0 ? (l(), u("span", q, [
                o("i", {
                  class: _({
                    clIconFont: !0,
                    "clIcon-caret-right": !0,
                    "icon-rotate": !0,
                    "rotate-90": i.openId.includes(n.id)
                  })
                }, null, 2)
              ])) : I("", !0),
              o("span", null, D(n.name), 1)
            ]),
            _: 2
          }, 1032, ["onOnClick"]),
          n.list && n.list.length > 0 ? (l(), J(C, { key: 0 }, {
            default: O(() => [
              b(g(v, {
                activeId: i.activeId,
                activePId: i.activePId,
                openId: i.openId,
                list: n.list,
                onOnClick: e
              }, null, 8, ["activeId", "activePId", "openId", "list"]), [
                [F, i.openId.includes(n.id)]
              ])
            ]),
            _: 2
          }, 1024)) : I("", !0)
        ], 2))), 128))
      ]);
    };
  }
}), U = {
  key: 0,
  class: "panel-sideNav"
}, W = { class: "sideNav-wrapper sideNav-wrapper-rowMult" }, H = /* @__PURE__ */ w({
  name: "ClSidemenu",
  __name: "Index",
  props: {
    active: String,
    list: {
      type: Array,
      required: !0,
      default: () => []
    }
  },
  emits: ["onChangeMenu"],
  setup(i, { emit: y }) {
    const r = i, M = y, e = S({
      keyIndex: `SideMenu-${d.getRandom(8)}`,
      isMenushrink: !1,
      menuActive: r.active,
      menuActiveParent: [],
      menuOpenPid: []
    }), a = R([]), A = {
      menuJson: {}
    }, m = (t) => {
      M("onChangeMenu", t);
    }, v = () => {
      const t = d.getTreeLastParent(e.menuActive, A.menuJson, !1);
      let s = [];
      t.length > 0 && (s = t.map((c) => c.id)), e.menuActiveParent = s;
    }, C = () => {
      const t = r.list, s = [], c = {};
      t.forEach((h) => {
        const { id: P, name: B } = h;
        c[h.id] = {
          id: P,
          name: B,
          parentId: "0"
        }, h.list && (s.push(P), h.list.forEach((N) => {
          N.parentId = P, c[N.id] = N;
        }));
      });
      const p = d.isEmpty(e.menuActive) ? t[0].id : e.menuActive;
      A.menuJson = c, a.value = t, e.menuActive = p, e.menuOpenPid = s, v();
    }, n = () => {
      C(), f(() => {
        m(e.menuActive);
      });
    };
    T(() => {
      f(() => {
        n();
      });
    });
    const x = () => {
      e.isMenushrink = !e.isMenushrink;
    }, $ = (t) => {
      const s = t.id;
      if (d.isUndefined(t.list))
        e.menuActive = s, v(), m(e.menuActive);
      else {
        const { menuOpenPid: c } = e, p = c.indexOf(s);
        p > -1 ? e.menuOpenPid.splice(p, 1) : e.menuOpenPid.push(s);
      }
    };
    return (t, s) => {
      const c = k("cl-link");
      return e.menuActive.length > 0 ? (l(), u("div", U, [
        o("div", {
          class: _({
            "sideNav-menu": !0,
            "sideNav-minify": !0,
            "sideNav-minify-shrink": e.isMenushrink
          })
        }, [
          g(c, {
            className: "sideNav-menu-minify",
            onOnClick: x
          }, {
            default: O(() => [
              o("i", {
                class: _({
                  clIconFont: !0,
                  "clIcon-angle-double-left": !e.isMenushrink,
                  "clIcon-angle-double-right": e.isMenushrink
                })
              }, null, 2)
            ]),
            _: 1
          }),
          g(z, {
            list: a.value,
            activeId: e.menuActive,
            activePId: e.menuActiveParent,
            openId: e.menuOpenPid,
            onOnClick: $
          }, null, 8, ["list", "activeId", "activePId", "openId"])
        ], 2),
        o("div", W, [
          V(t.$slots, "default")
        ])
      ])) : I("", !0);
    };
  }
});
export {
  H as default
};
//# sourceMappingURL=ClSidemenu.js.map
