var m = (d, y, o) => new Promise((r, t) => {
  var i = (a) => {
    try {
      c(o.next(a));
    } catch (u) {
      t(u);
    }
  }, s = (a) => {
    try {
      c(o.throw(a));
    } catch (u) {
      t(u);
    }
  }, c = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(i, s);
  c((o = o.apply(d, y)).next());
});
import { ref as h, onMounted as b, openBlock as _, createElementBlock as k, createVNode as B, withCtx as f, createElementVNode as x, normalizeClass as C, toDisplayString as v, createBlock as S, createTextVNode as V } from "vue";
import { l as I, a9 as D } from "./index2.js";
import { _ as N } from "./index23.js";
const O = { class: "s-tree-common" }, T = { class: "node-title" }, E = {
  key: 1,
  class: "node-title"
}, F = {
  __name: "STree",
  props: {
    // 是否展开所有节点
    expandAll: {
      type: Boolean,
      default: !1
    },
    // 树节点属性
    props: {
      type: Object,
      default: () => ({
        children: "children",
        label: "name",
        value: "value"
      })
    },
    // 是否添加复选框
    checkable: {
      type: Boolean,
      default: !1
    },
    // 树高度
    height: {
      type: Number,
      default: 300
    },
    // 获取一级节点数据
    levelOneChildren: {
      type: Function,
      default: () => {
      }
    },
    // 获取二级节点数据
    levelTwoChildren: {
      type: Function,
      default: () => {
      }
    },
    // 默认选中项，支持 v-model 双向绑定
    modelValue: {
      type: [String, Array],
      default() {
        return "";
      }
    },
    // 默认选中第一个节点
    selectFirstOne: {
      type: Boolean,
      default: !1
    },
    // 是否显示图标
    showIcon: {
      type: Boolean,
      default: !1
    },
    // 显示字数长度 超过15字符显示省略号并且鼠标悬浮tooltip显示
    showLength: {
      type: [Number, String],
      default: 15
    }
  },
  emits: ["select:modelValue"],
  setup(d, { emit: y }) {
    const o = d, r = y, t = h([]), i = h([]), s = h([]), c = h([]), a = (n, e) => m(this, null, function* () {
      e.expanded && (!e.node.dataRef.children || e.node.dataRef.children.length === 0) && (e.node.dataRef.children = yield o.levelOneChildren(e.node.dataRef.id)), n.value = n;
    }), u = (n, e) => {
      r("select:modelValue", n, e);
    }, K = () => m(this, null, function* () {
      var n, e, p;
      s.value = [], t.value = yield o.levelTwoChildren(), (n = t.value) != null && n.length && t.value[0] && ((e = t.value[0].children) != null && e.length) && (o.selectFirstOne && (t.value[0].selected = !0, i.value.push(((p = t.value[0]) == null ? void 0 : p.id) || ""), r("select:modelValue", t.value[0].id || "", t.value[0])), s.value = [t.value[0].id]);
    }), g = (n) => ["D", "G", "C", "D"][n];
    return b(() => {
      K();
    }), (n, e) => {
      const p = D, w = N;
      return _(), k("div", O, [
        B(w, {
          selectedKeys: i.value,
          "onUpdate:selectedKeys": e[0] || (e[0] = (l) => i.value = l),
          checkedKeys: s.value,
          "onUpdate:checkedKeys": e[1] || (e[1] = (l) => s.value = l),
          expandedKeys: c.value,
          "onUpdate:expandedKeys": e[2] || (e[2] = (l) => c.value = l),
          "default-expand-all": d.expandAll,
          checkable: d.checkable,
          "tree-data": t.value,
          showIcon: d.showIcon,
          height: d.height,
          onExpand: a,
          onSelect: u
        }, {
          icon: f((l) => [
            x("div", {
              class: C(["node-icon", g(l.type)])
            }, v(g(l.type)), 3)
          ]),
          title: f((l) => [
            l.title.length > 15 ? (_(), S(p, {
              key: 0,
              placement: "topLeft"
            }, {
              title: f(() => [
                V(v(l.title), 1)
              ]),
              default: f(() => [
                x("div", T, v(l.title.slice(0, 15)) + "...", 1)
              ]),
              _: 2
            }, 1024)) : (_(), k("div", E, v(l.title), 1))
          ]),
          _: 1
        }, 8, ["selectedKeys", "checkedKeys", "expandedKeys", "default-expand-all", "checkable", "tree-data", "showIcon", "height"])
      ]);
    };
  }
}, j = /* @__PURE__ */ I(F, [["__scopeId", "data-v-387e921d"]]);
export {
  j as default
};
